:root {
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
    margin: 0;
    background: #0c1118;
    color: #e7edf5;
    font-family: Arial, sans-serif;
}

.top_nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(16px, 3vw, 36px);
    background: linear-gradient(110deg, #172334, #101821 68%);
    border-bottom: 1px solid #2b394a;
}

.nav_brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
    white-space: nowrap;
}

.nav_kicker {
    color: #7fa5d9;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.17em;
    text-transform: uppercase;
}

.nav_brand strong {
    color: #f2f6fb;
    font-size: 19px;
    letter-spacing: -0.02em;
}

.market_switch {
    display: flex;
    gap: 6px;
    padding: 5px;
    border: 1px solid #344254;
    border-radius: 17px;
    background: #0b131d;
}

.market_link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 194px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: #b9c6d7;
    text-decoration: none;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.market_link:hover,
.market_link:focus-visible {
    background: #1a2a3e;
    border-color: #405a78;
    color: #fff;
    transform: translateY(-1px);
}

.market_link:focus-visible,
#next_btn:focus-visible {
    outline: 2px solid #8dbdff;
    outline-offset: 3px;
}

.market_link.active {
    background: #253b55;
    border-color: #5d83b5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.market_badge {
    display: grid;
    flex: 0 0 36px;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 700;
}

.market_badge.btc {
    background: #463319;
    color: #ffbc58;
}

.market_badge.avax {
    background: #482a32;
    color: #ff7986;
}

.market_badge.eth {
    background: #293653;
    color: #9db7ff;
}

.market_badge.sol {
    background: #263944;
    color: #6fffd2;
}

.market_badge.advanced {
    border-radius: 10px;
    background: #183a5d;
    color: #8dbdff;
    font-size: 11px;
    letter-spacing: -0.02em;
}

.market_copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.market_copy strong {
    font-size: 14px;
    letter-spacing: 0.02em;
}

.market_copy small {
    color: #94a5b9;
    font-size: 11px;
}

.market_quote {
    margin-left: auto;
    color: #89a0b8;
    font-size: 11px;
    white-space: nowrap;
}

#page {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(290px, 3fr);
    gap: 16px;
    min-height: calc(100vh - 97px);
    padding: 18px clamp(16px, 3vw, 36px);
}

#chart_wrapper,
#levels_panel {
    min-width: 0;
    padding: 20px;
    border: 1px solid #263444;
    border-radius: 16px;
    background: #121b26;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

#chart_wrapper h2,
#levels_panel h2 {
    margin: 0 0 16px;
    color: #f4f7fb;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

#chart_container {
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 420px;
}

#levels_panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 134px);
    overflow-y: auto;
    color: #b9c6d7;
}

#levels_panel.overview_panel {
    justify-content: center;
}

#levels_panel.overview_panel #next_btn {
    margin-top: 16px;
}

.panel_kicker {
    color: #7fa5d9;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.overview_panel p {
    max-width: 32ch;
    margin: 0;
    color: #9aacc0;
    font-size: 14px;
    line-height: 1.6;
}

#levels_table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#levels_table th,
#levels_table td {
    padding: 11px 9px;
    border-bottom: 1px solid #2b394a;
    text-align: left;
}

#levels_table th {
    color: #94a9bf;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#levels_table tr:hover td {
    background: #192738;
}

#levels_table .current_price_row td {
    color: #78a9ff;
    font-weight: 700;
}

#next_btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin-top: auto;
    padding: 14px 16px;
    border: 1px solid #5a8be3;
    border-radius: 11px;
    background: #2866c7;
    box-shadow: 0 5px 16px rgba(24, 91, 192, 0.2);
    color: white;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

#next_btn::after {
    content: '→';
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

#next_btn:hover {
    background: #397be1;
    box-shadow: 0 7px 20px rgba(24, 91, 192, 0.32);
    transform: translateY(-1px);
}

#page.combined_page {
    display: block;
}

.combined_page #chart_wrapper {
    width: 100%;
}

.combined_page #chart_container {
    height: calc(100vh - 250px);
    min-height: 520px;
}

.overview_toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-bottom: 14px;
}

.overview_toolbar p {
    margin: 0;
    color: #91a4ba;
    font-size: 12px;
}

.line_legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend_item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid #344254;
    border-radius: 8px;
    background: #0e1722;
    color: #d3dce7;
    font-size: 12px;
}

.legend_item strong {
    color: #91a4ba;
    font-size: 11px;
}

.legend_swatch {
    display: inline-block;
    width: 22px;
    border-top: 2px solid;
}

/* Match overview and Advanced chart layers: W white, D red, 4H yellow, 1H blue. */
.legend_swatch.weekly {
    border-color: #fff;
}

.legend_swatch.daily {
    border-color: #f00;
}

.legend_swatch.hours4 {
    border-color: #ff0;
}

.legend_swatch.hourly {
    border-color: #3179f5;
}

#chart_status {
    margin: 12px 0 0;
    color: #9aacc0;
    font-size: 13px;
}

#chart_status[hidden] {
    display: none;
}

.text-center {
    text-align: center !important;
}

@media (max-width: 960px) {
    #page {
        grid-template-columns: minmax(0, 1fr);
    }

    #chart_container {
        height: 60vh;
        min-height: 360px;
    }

    .combined_page #chart_container {
        height: 70vh;
        min-height: 420px;
    }

    #levels_panel {
        max-height: none;
    }

    #levels_panel.overview_panel {
        align-items: flex-start;
    }

    #next_btn {
        margin-top: 8px;
    }
}

@media (max-width: 1100px) {
    .top_nav {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .market_switch {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        width: 100%;
    }

    .market_link {
        flex: 1 1 0;
        min-width: 0;
    }

    #page {
        padding-top: 14px;
    }
}

@media (max-width: 620px) {
    .market_switch {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .market_link {
        gap: 8px;
        padding: 9px;
    }

    .market_badge {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .market_quote,
    .market_copy small {
        display: none;
    }

    #chart_wrapper,
    #levels_panel {
        padding: 15px;
    }
}
