:root {
    color-scheme: dark;
    --bg: #05070a;
    --bg-deep: #020407;
    --panel: rgba(9, 13, 18, 0.92);
    --panel-strong: rgba(14, 20, 28, 0.96);
    --line: rgba(148, 163, 184, 0.18);
    --text: #edf3f8;
    --muted: #8da0b4;
    --cyan: #38bdf8;
    --green: #34d399;
    --amber: #fbbf24;
    --red: #fb7185;
    --ink: #0b1016;
    --radius: 8px;
    --tap-size: 44px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
select,
input {
    font: inherit;
}

.charts-lite-body {
    overflow: hidden;
    overscroll-behavior: none;
}

.lite-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    background:
        linear-gradient(180deg, rgba(56, 189, 248, 0.05), transparent 26%),
        var(--bg);
}

.lite-topbar {
    grid-column: 1 / -1;
    min-height: 64px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(5, 7, 10, 0.86);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-lockup,
.market-readout,
.price-block,
.freshness-chip,
.control-group,
.toggle-strip,
.toggle-strip label,
.refresh-button,
.sheet-button,
.intel-header,
.intel-close {
    display: flex;
    align-items: center;
}

.brand-lockup {
    gap: 10px;
    min-width: 0;
}

.brand-lockup svg {
    width: 22px;
    height: 22px;
    color: var(--cyan);
}

.brand-name,
.brand-subtitle,
.symbol-code,
.price-value,
.rail-label,
.control-group > span {
    display: block;
}

.brand-name {
    font-size: 14px;
    font-weight: 700;
}

.brand-subtitle,
.rail-label,
.control-group > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.4;
}

.market-readout {
    gap: 12px;
    min-width: 0;
}

.price-block {
    gap: 10px;
    min-width: 0;
}

.symbol-code {
    color: var(--cyan);
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    font-weight: 700;
}

.price-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

.freshness-chip {
    min-height: 32px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    gap: 8px;
    background: rgba(15, 23, 42, 0.72);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.freshness-chip.is-fresh {
    color: var(--green);
    border-color: rgba(52, 211, 153, 0.28);
}

.freshness-chip.is-stale {
    color: var(--amber);
    border-color: rgba(251, 191, 36, 0.34);
}

.freshness-chip.is-error {
    color: var(--red);
    border-color: rgba(251, 113, 133, 0.34);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 14px currentColor;
}

.chart-stage {
    position: relative;
    min-height: 0;
    border-right: 1px solid var(--line);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
        #020305;
    background-size: 64px 64px;
}

#lite-chart {
    position: absolute;
    inset: 0;
}

.plan-strip {
    position: absolute;
    top: 10px;
    left: 14px;
    right: 74px;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    pointer-events: none;
}

.plan-strip.is-hidden {
    display: none;
}

.plan-chip {
    min-width: 0;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 9px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 6px;
    background: rgba(2, 6, 12, 0.84);
    color: var(--text);
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

.plan-chip.wait {
    flex: 1 1 auto;
    color: #facc15;
    border-color: rgba(250, 204, 21, 0.34);
    background: rgba(113, 63, 18, 0.38);
}

.plan-chip.buy {
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.36);
    background: rgba(20, 83, 45, 0.38);
}

.plan-chip.sell {
    color: #fdba74;
    border-color: rgba(245, 158, 11, 0.38);
    background: rgba(120, 53, 15, 0.38);
}

.chart-watermark {
    position: absolute;
    left: 18px;
    top: 48px;
    z-index: 4;
    pointer-events: none;
    display: flex;
    gap: 10px;
    align-items: baseline;
    font-family: "JetBrains Mono", monospace;
}

.chart-watermark span:first-child {
    font-size: 30px;
    font-weight: 700;
    color: rgba(237, 243, 248, 0.22);
}

.chart-watermark span:last-child {
    font-size: 14px;
    color: rgba(56, 189, 248, 0.42);
}

.source-ribbon {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 4;
    max-width: min(620px, calc(100% - 32px));
    padding: 8px 10px;
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: var(--radius);
    background: rgba(3, 7, 12, 0.82);
    color: #b7d8e8;
    font-size: 12px;
    line-height: 1.35;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.chart-state {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    background: rgba(2, 3, 5, 0.72);
    color: var(--muted);
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
}

.chart-state.is-hidden {
    display: none;
}

.lite-control-bar {
    grid-column: 1 / -1;
    min-height: 76px;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    background: rgba(5, 7, 10, 0.94);
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
}

.control-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    min-width: max-content;
}

.symbol-picker select {
    height: 34px;
    min-width: 126px;
    padding: 0 34px 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-strong);
    color: var(--text);
}

.segmented,
.toggle-strip {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(15, 23, 42, 0.58);
}

.segmented {
    display: grid;
    grid-template-columns: repeat(4, 46px);
    overflow: hidden;
}

.tf-button {
    min-width: 46px;
    height: 34px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: 700;
}

.tf-button:last-child {
    border-right: 0;
}

.tf-button.active {
    background: rgba(56, 189, 248, 0.14);
    color: var(--cyan);
}

.toggle-strip {
    gap: 0;
    overflow: hidden;
}

.toggle-strip label {
    min-height: 34px;
    gap: 7px;
    padding: 0 10px;
    border-right: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.toggle-strip label:last-child {
    border-right: 0;
}

.toggle-strip input {
    accent-color: var(--cyan);
}

.toggle-strip label:has(input:checked) {
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
}

.refresh-button {
    align-self: flex-end;
    height: 34px;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid rgba(56, 189, 248, 0.32);
    border-radius: var(--radius);
    background: rgba(56, 189, 248, 0.12);
    color: var(--cyan);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.sheet-button {
    align-self: flex-end;
    height: 34px;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(15, 23, 42, 0.62);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.refresh-button svg,
.sheet-button svg,
.intel-close svg {
    width: 16px;
    height: 16px;
}

.refresh-button:disabled {
    cursor: wait;
    opacity: 0.58;
}

.refresh-button,
.sheet-button,
.intel-close,
.tf-button {
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.refresh-button:active,
.sheet-button:active,
.intel-close:active,
.tf-button:active {
    transform: translateY(1px);
}

.refresh-button:focus-visible,
.sheet-button:focus-visible,
.intel-close:focus-visible,
.tf-button:focus-visible,
.toggle-strip input:focus-visible,
.raw-notes summary:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

.intel-scrim {
    display: none;
}

.intel-rail {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    background: var(--panel);
}

.intel-rail:focus {
    outline: none;
}

.intel-header {
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.intel-header strong {
    display: block;
    margin-top: 3px;
    color: var(--text);
    font-size: 14px;
}

.intel-close {
    display: none;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(15, 23, 42, 0.62);
    color: var(--text);
    cursor: pointer;
}

.intel-section {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.intel-section:first-child {
    padding-top: 0;
}

.intel-section:last-child {
    border-bottom: 0;
}

.intel-section p {
    margin: 6px 0 0;
    color: #dce8f1;
    font-size: 13px;
    line-height: 1.45;
}

.guide-overview {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.guide-status-row,
.guide-path-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.guide-status {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    font-weight: 800;
}

.guide-status.wait {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(120, 53, 15, 0.3);
    color: #fcd34d;
}

.guide-status.buy {
    border-color: rgba(52, 211, 153, 0.4);
    background: rgba(6, 78, 59, 0.32);
    color: #86efac;
}

.guide-status.sell {
    border-color: rgba(251, 113, 133, 0.4);
    background: rgba(136, 19, 55, 0.28);
    color: #fda4af;
}

.guide-mode {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-align: right;
}

.guide-summary {
    margin: 11px 0 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.5;
    text-wrap: pretty;
}

.guide-waiting {
    margin: 10px 0 0;
    padding: 9px 10px;
    border-left: 3px solid var(--amber);
    background: rgba(113, 63, 18, 0.2);
    color: #f8e8b0;
    font-size: 12px;
    line-height: 1.45;
}

.guide-path-list {
    display: grid;
    gap: 9px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.guide-path {
    padding: 11px;
    border: 1px solid var(--line);
    border-left-width: 3px;
    border-radius: var(--radius);
    background: rgba(3, 7, 12, 0.58);
}

.guide-path.long {
    border-left-color: var(--green);
}

.guide-path.short {
    border-left-color: var(--red);
}

.guide-direction {
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
}

.guide-path.long .guide-path-header strong {
    color: var(--green);
}

.guide-path.short .guide-path-header strong {
    color: #fda4af;
}

.guide-path-header strong {
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    white-space: nowrap;
}

.guide-levels {
    display: grid;
    gap: 5px;
    margin: 10px 0 0;
}

.guide-levels > div {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 8px;
}

.guide-levels dt,
.guide-levels dd {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
}

.guide-levels dt {
    color: var(--muted);
    font-weight: 700;
}

.guide-levels dd {
    color: var(--text);
    font-family: "JetBrains Mono", monospace;
    font-weight: 700;
}

.guide-path-reason,
.guide-invalidation,
.guide-supporting,
.guide-glossary p {
    text-wrap: pretty;
}

.guide-path-reason {
    margin: 9px 0 0;
    color: #c9d5df;
    font-size: 11px;
    line-height: 1.45;
}

.guide-invalidation {
    margin: 8px 0 0;
    padding-top: 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    color: #f7c9d0;
    font-size: 11px;
    line-height: 1.45;
}

.guide-supporting {
    padding-left: 9px;
    border-left: 2px solid rgba(56, 189, 248, 0.45);
    color: var(--muted) !important;
}

.guide-glossary {
    margin: 12px 0 0;
    padding: 11px;
    border: 1px solid rgba(56, 189, 248, 0.22);
    border-radius: var(--radius);
    background: rgba(8, 47, 73, 0.18);
}

.guide-glossary p {
    margin: 7px 0 0;
    color: #cfe3ed;
    font-size: 11px;
    line-height: 1.5;
}

.guide-data-section {
    display: grid;
    gap: 11px;
}

.guide-data-section > div + div {
    padding-top: 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.raw-notes {
    margin-top: 2px;
    padding: 12px 0 4px;
}

.raw-notes summary {
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
}

.note-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.note-item {
    border: 1px solid var(--line);
    border-left: 3px solid var(--cyan);
    border-radius: var(--radius);
    padding: 9px 10px;
    background: rgba(3, 7, 12, 0.55);
    color: #dce8f1;
    font-size: 12px;
    line-height: 1.45;
}

.note-item.warning {
    border-left-color: var(--amber);
}

.note-item.danger {
    border-left-color: var(--red);
}

@media (max-width: 980px) {
    .charts-lite-body {
        overflow: hidden;
    }

    .lite-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr) auto;
        height: 100dvh;
        min-height: 100dvh;
    }

    .chart-stage {
        min-height: 0;
        border-right: 0;
    }

    .intel-rail {
        position: fixed;
        z-index: 12;
        left: max(0px, env(safe-area-inset-left));
        right: max(0px, env(safe-area-inset-right));
        bottom: 0;
        max-height: min(78dvh, 720px);
        padding: 0 14px calc(14px + env(safe-area-inset-bottom));
        border: 1px solid var(--line);
        border-bottom: 0;
        border-radius: 10px 10px 0 0;
        background: rgba(7, 10, 15, 0.98);
        box-shadow: 0 -24px 70px rgba(0, 0, 0, 0.42);
        transform: translateY(calc(100% + 22px));
        transition: transform 180ms ease;
        pointer-events: none;
        overscroll-behavior: contain;
    }

    .intel-rail.is-open {
        transform: translateY(0);
        pointer-events: auto;
    }

    .intel-header {
        position: sticky;
        z-index: 2;
        top: 0;
        margin: 0 -14px;
        padding: 14px;
        background: rgba(7, 10, 15, 0.98);
    }

    .intel-close {
        display: flex;
    }

    .intel-scrim {
        position: fixed;
        z-index: 11;
        inset: 0;
        display: block;
        background: rgba(0, 0, 0, 0.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease;
    }

    .intel-scrim.is-open {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 680px) {
    :root {
        --tap-size: 36px;
    }

    .lite-shell {
        background:
            linear-gradient(180deg, rgba(56, 189, 248, 0.04), transparent 22%),
            var(--bg-deep);
    }

    .lite-topbar {
        min-height: 50px;
        padding: 5px 9px;
        align-items: center;
        flex-direction: row;
        gap: 8px;
    }

    .brand-lockup {
        gap: 7px;
    }

    .brand-lockup svg {
        width: 16px;
        height: 16px;
    }

    .brand-name {
        font-size: 11px;
        line-height: 1.1;
    }

    .brand-subtitle {
        display: none;
    }

    .market-readout {
        margin-left: auto;
        flex-direction: column;
        align-items: flex-end;
        gap: 3px;
    }

    .price-block {
        gap: 6px;
    }

    .symbol-code {
        font-size: 10px;
    }

    .price-value {
        font-size: 16px;
        line-height: 1;
    }

    .freshness-chip {
        min-height: 19px;
        padding: 0 7px;
        gap: 5px;
        font-size: 9px;
    }

    .status-dot {
        width: 6px;
        height: 6px;
    }

    .chart-stage {
        min-height: 0;
        border-top: 1px solid rgba(148, 163, 184, 0.08);
        border-bottom: 1px solid rgba(148, 163, 184, 0.08);
        background-size: 52px 52px;
    }

    .chart-watermark {
        left: 12px;
        top: 44px;
        gap: 7px;
    }

    .plan-strip {
        top: 8px;
        left: 8px;
        right: 56px;
        gap: 4px;
    }

    .plan-chip {
        height: 22px;
        padding: 0 5px;
        border-radius: 5px;
        font-size: 8px;
    }

    .chart-watermark span:first-child {
        font-size: 20px;
        color: rgba(237, 243, 248, 0.2);
    }

    .chart-watermark span:last-child {
        font-size: 12px;
    }

    .source-ribbon {
        display: none;
    }

    .lite-control-bar {
        align-items: stretch;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 42px 78px;
        gap: 7px;
        min-height: 92px;
        padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        border-top-color: rgba(148, 163, 184, 0.2);
        background: rgba(5, 7, 10, 0.97);
        overflow-x: visible;
    }

    .symbol-picker {
        display: none;
    }

    .control-group,
    .segmented,
    .toggle-strip {
        min-width: 0;
    }

    .timeframe-group {
        grid-column: 1 / -1;
    }

    .toggle-group {
        grid-column: 1;
    }

    .control-group {
        gap: 4px;
    }

    .control-group > span {
        font-size: 9px;
    }

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

    .tf-button {
        height: var(--tap-size);
        min-width: 0;
        font-size: 12px;
    }

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

    .toggle-strip label {
        justify-content: center;
        min-height: 34px;
        min-width: 0;
        padding: 0 5px;
        font-size: 10px;
        gap: 4px;
    }

    .toggle-strip span {
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1;
    }

    .toggle-strip input {
        width: 14px;
        height: 14px;
        margin: 0;
    }

    .refresh-button {
        width: 100%;
        min-width: 42px;
        height: 34px;
        justify-content: center;
        align-self: stretch;
        padding: 0;
        font-size: 0;
    }

    .sheet-button {
        width: 100%;
        min-width: 78px;
        height: 34px;
        justify-content: center;
        align-self: stretch;
        padding: 0 8px;
        gap: 6px;
        font-size: 10px;
    }

    .refresh-button svg,
    .sheet-button svg {
        width: 17px;
        height: 17px;
    }

    .refresh-button {
        background: rgba(56, 189, 248, 0.14);
    }

    .sheet-button[aria-expanded="true"] {
        border-color: rgba(56, 189, 248, 0.45);
        color: var(--cyan);
        background: rgba(56, 189, 248, 0.12);
    }

    .intel-header {
        padding-bottom: 10px;
    }

    .intel-section {
        padding: 10px 0;
    }

    .intel-section p,
    .note-item {
        font-size: 12px;
    }

    .guide-summary {
        font-size: 13px;
    }

    .guide-path-reason,
    .guide-invalidation,
    .guide-glossary p {
        font-size: 11px;
    }

    .note-list {
        gap: 7px;
    }
}

@media (max-width: 430px) {
    .toggle-strip label span {
        display: inline;
        max-width: 42px;
    }

    .toggle-strip label {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .intel-rail,
    .intel-scrim {
        transition: none;
    }
}
