:root {
  --canvas: #eef0ec;
  --surface: #ffffff;
  --ink: #1e2622;
  --muted: #5f6a64;
  --line: #d3d8d2;
  --brass: #8f6e2c;
  --brass-ink: #ffffff;
  --alert: #a53a28;
  --ok: #2e7a57;
  --serif: "Bodoni Moda", Didot, "Times New Roman", serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #141917;
    --surface: #1c2320;
    --ink: #e6eae6;
    --muted: #9ba59f;
    --line: #2f3934;
    --brass: #c8a25a;
    --brass-ink: #1a1508;
    --alert: #e07a64;
    --ok: #6cc49a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--canvas); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.loading, .empty { color: var(--muted); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.wordmark { font: 600 22px/1.1 var(--serif); text-decoration: none; white-space: nowrap; }
.wordmark span { margin-left: 8px; font: 500 13px var(--sans); color: var(--brass); }
.topbar nav { display: flex; align-items: center; gap: 20px; flex: 1; }
.topbar nav a { color: var(--muted); font-weight: 500; text-decoration: none; }
.topbar nav a:hover, .topbar nav a[aria-current] { color: var(--ink); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.page { max-width: 1320px; margin: 0 auto; padding: 28px 28px 140px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 26px; }
.toolbar h1 { margin: 0 auto 0 0; font: 600 32px/1.1 var(--serif); }
.toolbar input[type="search"] { width: 280px; }

/* Venues and zones */
.venue { margin-bottom: 44px; }
.venue > header {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.venue h2 { margin: 0; font: 500 25px/1.2 var(--serif); }
.venue h2 a { text-decoration: none; }
.venue h2 a:hover { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.meta { color: var(--muted); font-size: 13px; }

.zones { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.zone {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 16px 14px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
}
/* The channel band: every tile carries the colour of what it plays. */
.zone::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--ch); }
.zone.is-offline::before { background: repeating-linear-gradient(180deg, var(--ch) 0 7px, transparent 7px 13px); }
.zone.is-stopped::before { opacity: .35; }
.zone-head { display: flex; align-items: center; gap: 9px; }
.zone h3 { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--ok); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.is-offline .status { color: var(--alert); }
.now { margin: 0; min-height: 1.5em; font-size: 14px; font-style: italic; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick input { width: 16px; height: 16px; margin: 0; accent-color: var(--brass); }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.source { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.volume { display: grid; grid-template-columns: auto 1fr 2.4em; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.volume output { text-align: right; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--ch, var(--brass)); }
.actions { display: flex; gap: 8px; }
.problem { margin: 0; font-size: 13px; color: var(--alert); }

/* Controls */
select, input:not([type="checkbox"]):not([type="range"]):not([type="color"]) {
  min-width: 0; padding: 7px 9px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px;
}
.field select { font-size: 15px; }
input[type="color"] { width: 42px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.btn {
  padding: 7px 14px; font: 500 14px var(--sans); color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
}
.btn:hover { border-color: var(--muted); }
.btn.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.link { padding: 0; font: inherit; color: var(--brass); background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--alert); }

/* Bulk bar */
.bulk {
  position: fixed; left: 50%; bottom: 20px; z-index: 10; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px); padding: 12px 16px;
  color: var(--surface); background: var(--ink); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}
.bulk .btn { color: var(--surface); background: transparent; border-color: rgba(255, 255, 255, .35); }
.bulk .link { color: inherit; }
.bulk-vol { display: flex; align-items: center; gap: 6px; }
.bulk-vol input { width: 72px; }

/* Panels, tables, forms */
.panel { margin-top: 28px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.panel h2 { margin: 0 0 6px; font: 500 23px var(--serif); }
.hint { max-width: 72ch; margin: 0 0 16px; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-bottom: 18px; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 6px 8px; text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); }
.table td { padding: 8px; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table td input:not([type="checkbox"]):not([type="color"]) { width: 100%; }
.table .wide { min-width: 320px; }
.narrow { max-width: 96px; }
.row-actions { white-space: nowrap; }
.row-actions > * + * { margin-left: 14px; }
.inline-form, .row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.row-form { margin-bottom: 14px; }
.inline-form label, .row-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.inline-form .grow { flex: 1; min-width: 260px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.days legend { margin-bottom: 4px; padding: 0; font-size: 12px; font-weight: 500; color: var(--muted); }
.days label { flex-direction: row; align-items: center; gap: 5px; padding: 5px 8px; font-size: 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 2px; background: var(--ch); }
.tabs { display: flex; gap: 4px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.tabs a { margin-bottom: -1px; padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--ink); border-color: var(--brass); }

/* Sign in */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 380px; padding: 34px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.login-card .wordmark { margin: 0 0 10px; font-size: 30px; line-height: 1.15; }
.login-card .wordmark span { display: block; margin: 6px 0 0; font-size: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.form-error { margin: 0; font-size: 14px; color: var(--alert); }

#toast { position: fixed; top: 78px; right: 24px; z-index: 20; max-width: 380px; padding: 10px 16px; color: var(--surface); background: var(--ink); border-radius: 6px; }
#toast[data-kind="error"] { color: #fff; background: var(--alert); }
dialog { max-width: 520px; padding: 24px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
dialog::backdrop { background: rgba(20, 25, 23, .5); }
dialog h2 { margin: 0 0 8px; font: 500 23px var(--serif); }
dialog code { display: block; margin: 14px 0; padding: 12px; font-size: 15px; word-break: break-all; background: var(--canvas); border-radius: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 12px 18px; padding: 12px 16px; }
  .user > span { display: none; }
  .page { padding: 20px 16px 170px; }
  .toolbar input[type="search"] { width: 100%; }
  .bulk { left: 12px; right: 12px; bottom: 12px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
