:root {
    color-scheme: light;
    --bg: #e7e9e8;
    --panel: #f8f9f7;
    --panel-alt: #edf0ee;
    --line: #b8bfbc;
    --line-strong: #737e7a;
    --text: #18201e;
    --muted: #5f6c68;
    --green: #187844;
    --amber: #8b6500;
    --red: #b43a32;
    --blue: #286b98;
    --context-accent: #59645f;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

body[data-context="still"] { --context-accent: #286b98; }
body[data-context="walk"] { --context-accent: #187844; }
body[data-context="run"] { --context-accent: #b43a32; }
body[data-context="bike"] { --context-accent: #9a6500; }
body[data-context="car"] { --context-accent: #70539a; }
body[data-context="bus"] { --context-accent: #14766f; }
body[data-context="train"] { --context-accent: #355b85; }
body[data-context="subway"] { --context-accent: #8f3f73; }

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    min-width: 280px;
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-variant-numeric: tabular-nums;
}

button, select { font: inherit; }
.console {
    width: min(100% - 32px, 1080px);
    margin: 0 auto;
    padding: 24px 0 calc(36px + env(safe-area-inset-bottom));
}

.masthead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    min-height: 72px;
    padding: 0 0 16px;
    border-bottom: 1px solid var(--line-strong);
}
.kicker { margin: 0 0 7px; color: var(--green); font-size: .7rem; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(1.15rem, 3.2vw, 1.65rem); font-weight: 600; letter-spacing: -.02em; }
.header-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .72rem; white-space: nowrap; }

.panel { border: 1px solid var(--line); background: var(--panel); }
.player-panel, .controls-panel { margin-top: 16px; }
.panel-heading {
    min-height: 43px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-alt);
}
.panel-heading > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.index { color: var(--green); font-size: .68rem; }
h2 { margin: 0; font-size: .76rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.heading-value { color: var(--muted); font-size: .64rem; text-align: right; overflow-wrap: anywhere; }

.player-panel { border-top: 4px solid var(--context-accent); transition: border-color .25s ease; }
.player-heading { min-height: 54px; }
.context-readout { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.context-readout span { color: var(--muted); font-size: .58rem; letter-spacing: .04em; }
.context-readout strong { color: var(--context-accent); font-size: .78rem; font-weight: 600; transition: color .25s ease; }
.player-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(240px, .85fr); }
.now-playing { padding: 0 16px 16px; border-right: 1px solid var(--line); }
.now-playing .field-label, .queue .field-label { margin-left: 0; }
.playlist-name { min-height: 1.1em; margin: 0 0 17px; color: var(--context-accent); font-size: clamp(1.55rem, 5vw, 2.75rem); line-height: 1.05; transition: color .25s ease; }
.track-line { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; font-size: .76rem; }
.track-line strong { font-weight: 600; }
.track-line span { color: var(--muted); white-space: nowrap; }
.player-progress { height: 11px; border: 1px solid var(--line); background: #fff; }
.player-progress span { display: block; width: 0; height: 100%; background: var(--context-accent); transition: width .2s linear, background-color .25s ease; }
.player-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; color: var(--muted); font-size: .58rem; }
.transport { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; margin-top: 17px; }
button.context-primary { border-color: var(--context-accent); background: var(--context-accent); transition: background-color .25s ease, border-color .25s ease; }
.queue { min-width: 0; padding: 0 16px 16px; }
.playlist-tracks { margin: 0; padding: 0; list-style: none; counter-reset: tracks; border-top: 1px solid var(--line); }
.playlist-tracks li { display: grid; grid-template-columns: 27px minmax(0, 1fr); align-items: center; min-height: 37px; border-bottom: 1px solid #d8dcda; color: var(--muted); font-size: .7rem; counter-increment: tracks; }
.playlist-tracks li::before { content: "0" counter(tracks); color: var(--line-strong); font-size: .58rem; }
.playlist-tracks li.current { color: var(--context-accent); font-weight: 600; }
.playlist-tracks li.current::before { color: var(--context-accent); }
.playlist-tracks li.playlist-empty { display: block; padding: 12px 0; line-height: 1.45; counter-increment: none; }
.playlist-tracks li.playlist-empty::before { content: none; }

.control-row {
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto auto;
    align-items: center;
    gap: 9px;
    padding: 13px 12px;
}
.control-row label, .field-label, dt { color: var(--muted); font-size: .64rem; letter-spacing: .05em; }
select, button {
    min-height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 0;
}
select { width: 100%; padding: 0 34px 0 10px; color: var(--text); background: #fff; }
button { padding: 0 18px; color: var(--text); background: #dce1de; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--text); background: #cfd6d2; }
button.primary { border-color: #0f6135; color: #fff; background: var(--green); }
button:disabled, select:disabled { cursor: default; opacity: .38; }
select:focus-visible, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.model-specs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 0;
    border-top: 1px solid var(--line);
}
.model-specs div { min-width: 0; padding: 10px 12px; border-right: 1px solid var(--line); }
.model-specs div:last-child { border-right: 0; }
dt { margin-bottom: 5px; }
dd { margin: 0; overflow-wrap: anywhere; }
.model-specs dd { font-size: .72rem; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(350px, .95fr); gap: 16px; margin-top: 16px; }
.inference-panel, .telemetry-panel { min-width: 0; }
.tag {
    display: inline-block;
    padding: 3px 6px;
    border: 1px solid var(--line-strong);
    color: var(--green);
    background: #f3f6f4;
    font-size: .64rem;
    white-space: nowrap;
}
.tag.fallback, .tag.neutral { color: var(--amber); }
.tag.stable { color: var(--green); }
.field-label { margin: 22px 16px 7px; }
.activity {
    min-height: 1.15em;
    margin: 0 16px;
    color: var(--green);
    font-size: clamp(1.85rem, 6vw, 3.4rem);
    line-height: 1;
    overflow-wrap: anywhere;
}
.candidate-line { display: flex; align-items: flex-start; gap: 9px; min-height: 58px; padding: 13px 16px; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.confidence-header { display: flex; justify-content: space-between; gap: 16px; margin: 4px 16px 7px; color: var(--muted); font-size: .66rem; }
.confidence-header strong { color: var(--text); font-weight: 500; }
.meter { height: 12px; margin: 0 16px 18px; border: 1px solid var(--line); background: #fff; }
.meter span { display: block; width: 0; height: 100%; background: var(--green); transition: width .2s linear; }

.telemetry-table { margin: 0; }
.telemetry-table div {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) minmax(0, 1fr);
    align-items: center;
    min-height: 35px;
    border-bottom: 1px solid #d8dcda;
}
.telemetry-table div:last-child { border-bottom: 0; }
.telemetry-table dt, .telemetry-table dd { padding: 7px 11px; }
.telemetry-table dd { color: #34413d; font-size: .69rem; text-align: right; }
.telemetry-table .dot { margin-right: 7px; }
.dot { display: inline-block; width: 7px; height: 7px; border: 1px solid #737e7a; background: #c7cdca; }
.dot.good { border-color: var(--green); background: var(--green); }
.dot.warn { border-color: var(--amber); background: var(--amber); }
.dot.bad { border-color: var(--red); background: var(--red); }

.probabilities { margin-top: 16px; }
.probability-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; padding: 9px 12px 12px; }
.probability-item { display: grid; grid-template-columns: 76px minmax(0, 1fr) 52px; align-items: center; gap: 10px; min-height: 29px; font-size: .68rem; text-transform: uppercase; }
.probability-track { height: 8px; border: 1px solid var(--line); background: #fff; }
.probability-track i { display: block; height: 100%; background: var(--blue); transition: width .2s linear; }
.probability-item b { text-align: right; font-weight: 500; }
.empty { grid-column: 1 / -1; margin: 10px 0; color: var(--muted); font-size: .68rem; }

.notice {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    margin-top: 16px;
    padding: 10px 12px;
    border: 1px solid #b99d51;
    color: #66551f;
    background: #fff9e8;
    font-size: .66rem;
    line-height: 1.45;
}
.notice[hidden] { display: none; }
.notice strong { color: var(--amber); font-weight: 500; }
.notice.error { border-color: #bd7771; color: #783b36; background: #fff0ef; }
.notice.error strong { color: var(--red); }
footer { display: flex; justify-content: space-between; gap: 16px; padding: 12px 1px 0; color: #68736f; font-size: .58rem; }

@media (max-width: 760px) {
    .console { width: min(100% - 20px, 1080px); padding-top: 14px; }
    .workspace { grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
    .player-panel, .controls-panel, .probabilities, .notice { margin-top: 10px; }
    .player-layout { grid-template-columns: 1fr; }
    .now-playing { border-right: 0; border-bottom: 1px solid var(--line); }
    .control-row { grid-template-columns: 1fr 1fr; }
    .control-row label { grid-column: 1 / -1; }
    .control-row select { grid-column: 1 / -1; }
    .model-specs { grid-template-columns: repeat(2, 1fr); }
    .model-specs div { border-bottom: 1px solid var(--line); }
    .model-specs div:nth-child(2n) { border-right: 0; }
    .model-specs div:last-child { border-bottom: 0; }
    .probability-list { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
    .masthead { align-items: flex-start; flex-direction: column; gap: 10px; }
    .header-state { align-self: flex-end; }
    .panel-heading { align-items: flex-start; }
    .player-heading { flex-direction: column; }
    .context-readout { align-items: flex-start; text-align: left; }
    .control-row { grid-template-columns: 1fr; }
    .control-row label, .control-row select { grid-column: auto; }
    .model-specs { grid-template-columns: 1fr; }
    .model-specs div, .model-specs div:nth-child(2n) { border-right: 0; border-bottom: 1px solid var(--line); }
    .model-specs div:last-child { border-bottom: 0; }
    .telemetry-table div { grid-template-columns: minmax(112px, 1fr) minmax(0, 1fr); }
    .notice { grid-template-columns: 1fr; }
    footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; }
}
