:root {
    color-scheme: dark;
    --bg: #0b0f12;
    --bg-wash: rgba(79, 209, 197, 0.08);
    --surface: #11161a;
    --surface-2: #171d22;
    --surface-3: #1d242a;
    --border: #2a333b;
    --border-soft: #20282f;
    --text: #edf2f4;
    --muted: #94a1aa;
    --faint: #68757f;
    --accent: #4fd1c5;
    --accent-strong: #7dd3fc;
    --good: #42d392;
    --bad: #ff6b6b;
    --warn: #f4c95d;
    --chart-bg: #0c1115;
    --grid: #1b252d;
    --sidebar-bg: rgba(17, 22, 26, 0.96);
    --brand-bg: #0c1d1f;
    --brand-border: rgba(79, 209, 197, 0.42);
    --heading: #dfe7eb;
    --chart-title: #ffffff;
    --primary-text: #062323;
    --focus: rgba(79, 209, 197, 0.75);
    --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
    --status-warn-bg: #272116;
    --status-good-bg: rgba(66, 211, 146, 0.12);
    --status-error-bg: rgba(255, 107, 107, 0.14);
    --pill-bg: rgba(79, 209, 197, 0.1);
    --pill-border: rgba(79, 209, 197, 0.28);
    --up-bg: rgba(66, 211, 146, 0.12);
    --down-bg: rgba(255, 107, 107, 0.13);
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f7fb;
    --bg-wash: rgba(15, 159, 154, 0.11);
    --surface: #ffffff;
    --surface-2: #eef3f7;
    --surface-3: #e5edf4;
    --border: #cfd9e4;
    --border-soft: #e2e8f0;
    --text: #17212b;
    --muted: #5f6f7c;
    --faint: #8897a6;
    --accent: #0f9f9a;
    --accent-strong: #2563eb;
    --good: #11845f;
    --bad: #c43c3c;
    --warn: #a96800;
    --chart-bg: #fbfdff;
    --grid: #e4ebf2;
    --sidebar-bg: rgba(255, 255, 255, 0.96);
    --brand-bg: #e8fbf8;
    --brand-border: rgba(15, 159, 154, 0.34);
    --heading: #26323d;
    --chart-title: #101820;
    --primary-text: #ffffff;
    --focus: rgba(15, 159, 154, 0.5);
    --panel-shadow: 0 10px 24px rgba(25, 36, 52, 0.08);
    --shadow: 0 16px 34px rgba(25, 36, 52, 0.1);
    --status-warn-bg: rgba(169, 104, 0, 0.12);
    --status-good-bg: rgba(17, 132, 95, 0.12);
    --status-error-bg: rgba(196, 60, 60, 0.12);
    --pill-bg: rgba(15, 159, 154, 0.1);
    --pill-border: rgba(15, 159, 154, 0.28);
    --up-bg: rgba(17, 132, 95, 0.11);
    --down-bg: rgba(196, 60, 60, 0.11);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, var(--bg-wash), transparent 260px),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
    overflow: hidden;
}

button,
select,
input {
    font: inherit;
}

button,
select {
    color: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    height: 100vh;
    min-height: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    padding: 18px;
    border-right: 1px solid var(--border);
    background: var(--sidebar-bg);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--brand-border);
    border-radius: 8px;
    background: var(--brand-bg);
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h2,
.chart-header h3,
.chart-header p,
.ticker-card span,
.ticker-card strong,
.ticker-card small,
.session-list,
.session-list dt,
.session-list dd {
    margin: 0;
}

.brand h1 {
    font-size: 19px;
    line-height: 1.15;
}

.brand p,
.eyebrow {
    color: var(--muted);
    font-size: 12px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--panel-shadow);
}

.control-panel,
.session-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

.session-panel {
    margin-top: auto;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.panel h2 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--heading);
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--status-warn-bg);
    color: var(--warn);
    font-size: 12px;
    font-weight: 700;
}

.status-dot::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-dot.ready {
    background: var(--status-good-bg);
    color: var(--good);
}

.status-dot.error {
    background: var(--status-error-bg);
    color: var(--bad);
}

.field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.field span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.field strong {
    color: var(--accent-strong);
    font-family: var(--mono);
    font-size: 12px;
}

select {
    width: 100%;
    min-height: 40px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    outline: none;
}

select:focus-visible,
button:focus-visible,
input[type="range"]:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.button-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 10px;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.playback-icon {
    flex: 0 0 auto;
}

button svg polygon,
button svg rect {
    fill: currentColor;
    stroke: none;
}

button:not(:disabled):hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.primary-action {
    gap: 8px;
    background: var(--accent);
    color: var(--primary-text);
    font-weight: 800;
}

.icon-action {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--muted);
}

.icon-action:not(:disabled):hover {
    border-color: var(--accent);
    color: var(--accent);
}

input[type="range"] {
    width: 100%;
    height: 26px;
    margin: 0;
    accent-color: var(--accent);
}

.time-card {
    display: grid;
    gap: 5px;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--chart-bg);
}

.time-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.time-card strong {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 30px;
    line-height: 1;
}

.session-list {
    display: grid;
    gap: 11px;
}

.session-list div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
}

.session-list div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.session-list dt {
    color: var(--muted);
    font-size: 12px;
}

.session-list dd {
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    text-align: right;
}

.workspace {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 12px;
    min-width: 0;
    min-height: 0;
    padding: 14px;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
    padding: 0 4px;
}

.eyebrow {
    margin-bottom: 3px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar h2 {
    font-size: 22px;
    line-height: 1.2;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-meta strong {
    flex: 0 0 auto;
    min-width: 76px;
    padding: 7px 10px;
    border: 1px solid var(--pill-border);
    border-radius: 999px;
    background: var(--pill-bg);
    color: var(--accent);
    font-size: 12px;
    text-align: center;
}

.theme-toggle {
    flex: 0 0 auto;
    gap: 6px;
    min-height: 34px;
    padding: 0 10px;
    border-color: var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
}

.theme-toggle:not(:disabled):hover {
    border-color: var(--accent);
    background: var(--surface-2);
    color: var(--accent);
}

.theme-toggle span {
    overflow: visible;
    text-overflow: clip;
}

.ticker-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.ticker-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.ticker-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.ticker-card strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-family: var(--mono);
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticker-card small {
    justify-self: end;
    min-width: 70px;
    padding: 4px 7px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 800;
    text-align: right;
}

.ticker-card.up small {
    background: var(--up-bg);
    color: var(--good);
}

.ticker-card.down small {
    background: var(--down-bg);
    color: var(--bad);
}

.charts-grid {
    display: grid;
    grid-template-rows: repeat(3, minmax(170px, 1fr));
    gap: 12px;
    min-height: 0;
}

.chart-panel {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--chart-bg);
    box-shadow: var(--shadow);
}

.chart-header {
    position: absolute;
    top: 12px;
    left: 14px;
    right: 80px;
    z-index: 5;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.chart-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--chart-title);
    font-size: 14px;
    line-height: 1.2;
}

.chart-header h3 span {
    display: inline-flex;
    min-height: 20px;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1;
}

.chart-header p {
    margin-top: 5px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.35;
}

.chart-header .up {
    color: var(--good);
}

.chart-header .down {
    color: var(--bad);
}

.chart-header .vwap {
    color: var(--warn);
}

.chart-box {
    width: 100%;
    height: 100%;
}

.chart-empty {
    position: absolute;
    inset: 52px 16px 16px;
    display: none;
    place-items: center;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--faint);
    font-size: 13px;
}

.chart-panel.is-empty .chart-empty {
    display: grid;
}

.chart-panel.is-empty .chart-box {
    opacity: 0.15;
}

@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 270px minmax(0, 1fr);
    }

    .ticker-card {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .ticker-card small {
        justify-self: start;
    }
}

@media (max-width: 820px) {
    body {
        overflow: auto;
    }

    .app-shell {
        display: block;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .session-panel {
        margin-top: 0;
    }

    .workspace {
        min-height: 920px;
        overflow: visible;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-meta {
        width: 100%;
        justify-content: space-between;
    }

    .ticker-strip {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-rows: repeat(3, 320px);
    }
}

@media (max-width: 520px) {
    .sidebar,
    .workspace {
        padding: 12px;
    }

    .brand {
        align-items: flex-start;
    }

    .time-card strong {
        font-size: 26px;
    }

    .chart-header {
        right: 12px;
    }

    .chart-header p {
        font-size: 11px;
    }
}
