/* CACSR Control Room. Layout: a broadcast desk. "Next on air" band, then the queue beside the run controls, then the published log. */
:root {
  --bg: #f3f6f4; --surface: #ffffff; --line: #d7e1dc; --fg: #101614; --muted: #5a6a63;
  --green: #217058; --green-soft: #e3efe9; --red: #a31a22; --red-soft: #f6e4e5;
  --ink: #0b0f0d; --on-ink: #f3f6f4; --ink-muted: #9fb3aa; --warn: #8a5a00; --warn-soft: #fbf0d9;
  --font-display: "Bebas Neue", "Oswald", Impact, "Arial Narrow", sans-serif;
  --font-body: "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0c1110; --surface: #141b19; --line: #26332e; --fg: #e8efec; --muted: #94a69e;
  --green: #3fa284; --green-soft: #17302a; --red: #e0545b; --red-soft: #3a1a1c;
  --ink: #050807; --on-ink: #e8efec; --warn: #e2b04a; --warn-soft: #3a2e14; color-scheme: dark; } }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.55; }
.wrap { max-width: 1180px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); display: grid; gap: 20px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: 22px; }
h2 { font-size: 18px; font-weight: 700; }
a { color: var(--green); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.ar { font-weight: 600; color: var(--muted); font-size: 14px; }
.strong { font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.err { margin: 0; background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 8px 12px; font-weight: 600; font-size: 14px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* header */
header.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand > span:last-child { display: grid; }
.mark { width: 40px; height: 40px; border-radius: 10px; background: var(--green); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-size: 26px; line-height: 1; flex: none; }
.brand-name { font-family: var(--font-display); font-size: 32px; letter-spacing: .02em; line-height: 1; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .linkish { text-decoration: none; color: var(--muted); font-weight: 600; padding: 6px 10px; border-radius: 6px; background: none; border: 0; font-size: 14px; }
.nav a:hover, .linkish:hover { color: var(--fg); background: var(--surface); }
.nav a.on { color: var(--fg); background: var(--surface); border: 1px solid var(--line); }
.nav form { margin: 0; }
.status-line { font-size: 13px; color: var(--muted); margin-top: -8px; }
.status-line.warn { color: var(--warn); }

/* on-air band */
.onair { background: var(--ink); color: var(--on-ink); border-radius: 14px; padding: 20px 22px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 28px; align-items: center; }
.onair .label { color: var(--ink-muted); }
.onair .topic { font-size: clamp(20px, 3vw, 28px); font-weight: 700; line-height: 1.3; margin-top: 4px; overflow-wrap: anywhere; }
.onair .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.clock { text-align: end; }
.clock .t { font-family: var(--font-display); font-size: 54px; line-height: .95; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.clock .sub { font-size: 13px; color: var(--ink-muted); }
.paused-banner { grid-column: 1 / -1; background: var(--red); color: #fff; border-radius: 8px; padding: 8px 12px; font-weight: 600; font-size: 14px; }
@media (max-width: 640px) { .onair { grid-template-columns: 1fr; } .clock { text-align: start; } }

/* chips */
.chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border: 1px solid transparent; white-space: nowrap; }
.chip.study { background: var(--green-soft); color: var(--green); }
.chip.attract { background: var(--red-soft); color: var(--red); }
.onair .chip.study { background: #217058; color: #fff; }
.onair .chip.attract { background: #a31a22; color: #fff; }
.chip.series { background: transparent; border-color: var(--line); color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 600; }
.onair .chip.series { border-color: #34423c; color: #c6d4ce; }
.chip.live { background: var(--green-soft); color: var(--green); }
.chip.draft { background: var(--warn-soft); color: var(--warn); }
.chip.failed { background: var(--red-soft); color: var(--red); }

/* layout */
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.side { display: grid; gap: 20px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 14px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* forms */
form.add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 180px) auto; gap: 8px; }
@media (max-width: 560px) { form.add { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 6px; }
.stack .btn { margin-top: 8px; }
label { font-size: 13px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], textarea, select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
textarea { resize: vertical; min-height: 160px; line-height: 1.6; }
.btn { border: 1px solid var(--green); background: var(--green); color: #fff; border-radius: 8px; padding: 9px 16px; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--green); }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); font-size: 14px; line-height: 1; }
.icon-btn:hover:not(:disabled) { color: var(--fg); border-color: var(--muted); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* auth */
.auth { display: grid; place-items: start center; padding-top: 6vh; }
.auth-card { width: 100%; max-width: 420px; gap: 8px; }
.auth-card .btn { margin-top: 10px; }
.auth-card h1 + .hint { margin-bottom: 6px; }

/* queue */
ol.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qi { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.qi.first { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.qi .pos { font-family: var(--font-display); font-size: 26px; color: var(--muted); text-align: center; line-height: 1; font-variant-numeric: tabular-nums; }
.qi .txt { font-weight: 600; overflow-wrap: anywhere; }
.qi .sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.qi .actions { display: flex; gap: 4px; }
.qi.editing { grid-template-columns: 1fr; }
.edit-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 160px); gap: 8px; }
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 560px) { .qi { grid-template-columns: 28px minmax(0, 1fr); } .qi .actions { grid-column: 2; } .edit-row { grid-template-columns: 1fr; } }
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); }

/* setup */
ul.setup, ul.tokens { list-style: none; margin: 0; padding: 0; display: grid; }
ul.setup li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.setup li:last-child { border-bottom: 0; }
ul.setup input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--green); }
ul.setup label { font-size: inherit; font-weight: 400; }
ul.setup .s-label { font-weight: 600; }
ul.setup .s-detail { font-size: 13px; color: var(--muted); }
ul.setup li.done .s-label { color: var(--muted); text-decoration: line-through; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); width: 0; transition: width .3s; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.save-note { font-size: 13px; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.date { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
td a { font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
td select { width: auto; padding: 4px 8px; }
.links { display: flex; gap: 10px; flex-wrap: wrap; }
.dash { color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

ul.tokens li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.token-new { display: grid; gap: 8px; background: var(--green-soft); border-radius: 10px; padding: 12px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; z-index: 20; max-width: calc(100vw - 32px); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* summary tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.stat .num { font-family: var(--font-display); font-size: 44px; line-height: 1; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .num.small { font-size: 30px; padding-block: 7px 0; }
.stat .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.sub.warn { color: var(--warn); font-weight: 600; }
.sub.bad { color: var(--red); font-weight: 600; }

/* connections */
.health { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .health { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .health { grid-template-columns: 1fr; } }
.hp { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; min-width: 0; }
.hp-top { display: flex; align-items: center; gap: 8px; }
.hp-state { margin-inline-start: auto; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.hp.ok .dot { background: var(--green); } .hp.ok .hp-state { color: var(--green); }
.hp.warn .dot, .hp.untested .dot { background: var(--warn); } .hp.warn .hp-state, .hp.untested .hp-state { color: var(--warn); }
.hp.error .dot { background: var(--red); } .hp.error .hp-state { color: var(--red); }
.hp.error { border-color: var(--red); }
.hp .hint { overflow-wrap: anywhere; }
.hp-fix { font-size: 13px; font-weight: 700; text-decoration: none; }

/* coming up */
ol.cal { list-style: none; margin: 0; padding: 0; display: grid; }
ol.cal li { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
ol.cal li:last-child { border-bottom: 0; }
.cal-day { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-topic { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
ol.cal li.gap .cal-topic { color: var(--red); font-weight: 600; }

/* activity */
ol.activity { list-style: none; margin: 0; padding: 0; display: grid; }
ol.activity li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
ol.activity li:last-child { border-bottom: 0; }
ol.activity li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
ol.activity li .hint { white-space: nowrap; }

/* settings */
.settings-intro { gap: 6px; }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 900px) { .settings { grid-template-columns: 1fr; } }
.setting-group { scroll-margin-top: 16px; }
.setting { display: grid; gap: 5px; }
.setting-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.setting.toggle { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding-block: 4px; }
.setting input[type="password"], .setting input[type="text"] { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.small-link { justify-self: start; padding: 0; font-size: 13px; color: var(--red); }
.test-result { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; flex: 1 1 200px; }
.test-result .hint { overflow-wrap: anywhere; }
input.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; margin: 0; transition: background .2s; flex: none; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
input.switch:checked { background: var(--green); }
input.switch:checked::after { transform: translateX(18px); }
