/* cinema operator console — modern, server-side first.
   Tokens, type scale, light/dark via prefers-color-scheme, subtle shadows. */

:root {
  /* type scale */
  --t-xs: 11px;
  --t-sm: 12px;
  --t-base: 14px;
  --t-md: 16px;
  --t-lg: 20px;
  --t-xl: 28px;
  --t-2xl: 40px;

  /* spacing scale (4-px grid) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;

  /* radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* shadows */
  --sh-1: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --sh-2: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-3: 0 12px 32px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.05);

  /* fonts */
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "JetBrains Mono",
               Menlo, Consolas, monospace;

  /* colour tokens (light) */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-elev: #ffffff;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #ede9fe;
  --accent-ink: #ffffff;
  --error: #b91c1c;
  --error-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bar: #0b1220;
  --bar-ink: #e2e8f0;
  --bar-ink-strong: #ffffff;
  --bar-muted: #94a3b8;
  --focus: 0 0 0 3px rgba(124, 58, 237, 0.35);

  /* live accent — used only for "playing now" / heartbeat states */
  --live: #d97706;
  --live-soft: #fef3c7;
  --live-glow: rgba(245, 158, 11, 0.45);
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #0f1729;
  --surface-elev: #15203a;
  --ink: #e2e8f0;
  --ink-2: #f1f5f9;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --border: #1f2a44;
  --border-strong: #2c3a5a;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-soft: rgba(167, 139, 250, 0.18);
  --accent-ink: #0b1220;
  --error: #fca5a5;
  --error-soft: rgba(248, 113, 113, 0.15);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --ok: #86efac;
  --ok-soft: rgba(34, 197, 94, 0.15);
  --bar: #050913;
  --bar-ink: #cbd5e1;
  --bar-ink-strong: #ffffff;
  --bar-muted: #64748b;
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 4px 12px rgba(0, 0, 0, 0.4);
  --sh-3: 0 12px 32px rgba(0, 0, 0, 0.5);
  --focus: 0 0 0 3px rgba(167, 139, 250, 0.4);

  /* live accent — brighter on dark for legibility */
  --live: #fbbf24;
  --live-soft: rgba(251, 191, 36, 0.16);
  --live-glow: rgba(251, 191, 36, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(circle at 1px 1px, var(--dot-color, rgba(255, 255, 255, 0.04)) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  background-attachment: fixed, fixed;
  color: var(--ink);
  font: var(--t-base)/1.55 var(--font-sans);
  font-feature-settings: "kern", "liga";
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
:root            { --dot-color: rgba(15, 23, 42, 0.045); }
[data-theme="dark"] { --dot-color: rgba(255, 255, 255, 0.035); }
main { flex: 1; padding: var(--s-6) 0 var(--s-10); }

.container { max-width: 1180px; margin: 0 auto; padding: 0 var(--s-6); }

/* ---------------- App shell (sidebar + main) ---------------- */

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bar);
  color: var(--bar-ink);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 40;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-weight: 700;
  font-size: var(--t-md);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bar-ink-strong);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sidebar-brand .brand-mark { color: var(--accent); filter: drop-shadow(0 0 8px var(--live-glow, rgba(167, 139, 250, 0.5))); }

.sidebar-nav {
  flex: 1;
  padding: var(--s-3) var(--s-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--bar-ink);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 120ms ease, color 120ms ease;
}
.sidebar-link svg { color: var(--bar-muted); flex-shrink: 0; transition: color 120ms ease; }
.sidebar-link:hover { background: rgba(255, 255, 255, 0.05); color: var(--bar-ink-strong); }
.sidebar-link:hover svg { color: var(--bar-ink-strong); }
.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--bar-ink-strong);
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar-link.active svg { color: var(--accent); }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bar-muted);
  padding: var(--s-3) 12px 6px;
  margin-top: var(--s-2);
}

.sidebar-foot {
  padding: var(--s-3);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.sidebar-foot-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-sm);
  color: var(--bar-ink);
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.sidebar-foot-btn:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.16); }
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
}
.sidebar-user-name { color: var(--bar-ink-strong); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logout { color: var(--bar-muted); font-size: 12px; }
.sidebar-logout:hover { color: var(--accent); }

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* avoid overflow inside grid track */
}

.topbar-thin {
  height: 52px;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-6);
  background: transparent;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}
[data-theme="dark"] .topbar-thin { background: rgba(11, 18, 32, 0.65); }
.topbar-thin .topbar-spacer { flex: 1; }
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px;
  color: var(--ink);
  cursor: pointer;
}
.palette-trigger-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: var(--t-sm);
  transition: color 120ms ease, border-color 120ms ease;
}
.palette-trigger-inline:hover { color: var(--ink-2); border-color: var(--accent); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 19, 0.5);
  z-index: 35;
}

.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }

/* ---------- Mobile / narrow ---------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 248px;
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }
  .sidebar-mobile-open { transform: translateX(0); }
  .sidebar-backdrop[style*="display"] { display: block; }
  .sidebar-toggle { display: inline-flex; }
}

/* ---------------- Auth (login) shell ---------------- */
.auth-shell { display: block; }
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-6);
  padding: var(--s-8);
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: none;
}
.auth-brand .brand-mark { color: var(--accent); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------------- Topbar ---------------- */

.topbar {
  background: var(--bar);
  color: var(--bar-ink);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 4px 16px rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  height: 56px;
}
.brand {
  font-weight: 700;
  font-size: var(--t-base);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bar-ink-strong);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-soft));
  flex-shrink: 0;
}
.nav {
  display: flex;
  gap: var(--s-1);
  margin-left: var(--s-3);
  flex: 1;
}
.nav a {
  color: var(--bar-ink);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  transition: background 120ms ease, color 120ms ease;
}
.nav a.muted { color: var(--bar-muted); }
.nav a:hover { color: var(--bar-ink-strong); background: rgba(255, 255, 255, 0.06); }
.nav a.active { color: var(--bar-ink-strong); background: rgba(255, 255, 255, 0.08); }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: 13px;
}
.user-name { color: var(--bar-ink); font-weight: 500; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--bar-ink);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.theme-toggle:hover {
  color: var(--bar-ink-strong);
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.16);
}
.theme-toggle:focus-visible { outline: none; box-shadow: var(--focus); }

.footer {
  padding: var(--s-5) 0;
  border-top: 1px solid var(--border);
  margin-top: var(--s-8);
  font-size: var(--t-sm);
  color: var(--muted);
}

/* ---------------- Typography ---------------- */

h1 {
  font-size: 32px;
  margin: 0 0 var(--s-4);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink-2);
}
h2 { font-size: var(--t-lg); margin: 0 0 var(--s-2); font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); }
h3 { font-size: var(--t-md); margin: 0 0 var(--s-2); font-weight: 600; letter-spacing: -0.005em; color: var(--ink-2); }
p { margin: var(--s-2) 0; }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.mono { font-family: var(--font-mono); font-size: 0.95em; font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------------- Cards & tiles ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-6);
  margin-bottom: var(--s-4);
  box-shadow: var(--sh-1);
}
.card + .card { margin-top: var(--s-4); }

.auth-card {
  max-width: 420px;
  margin: var(--s-10) auto;
  box-shadow: var(--sh-2);
}

.grid { display: grid; gap: var(--s-3); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.tile {
  display: block;
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  box-shadow: var(--sh-1);
}
.tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
  color: var(--ink);
}
.tile h3 { color: var(--ink-2); }
.tile p { margin-top: 6px; }

/* ---------------- Forms ---------------- */

label {
  display: block;
  margin: var(--s-3) 0 6px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="search"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: var(--t-base);
  font-family: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  appearance: none;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

textarea { min-height: 80px; resize: vertical; }

/* ---------------- Buttons ---------------- */

button, .button, .button-ghost, .button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease,
              box-shadow 120ms ease, transform 80ms ease;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--surface-2); border-color: var(--muted-2); }
button:focus-visible, .button:focus-visible,
.button-ghost:focus-visible, .button-danger:focus-visible { outline: none; box-shadow: var(--focus); }
button:active, .button:active { transform: translateY(1px); }
button:disabled, .button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button.primary, .button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  margin-top: var(--s-4);
  box-shadow: var(--sh-1);
}
button.primary:hover, .button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

button.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--bar-ink);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.3);
  text-underline-offset: 3px;
}
button.link:hover { color: var(--bar-ink-strong); text-decoration-color: var(--bar-ink-strong); background: transparent; }

.button-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}
.button-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }

.button-danger {
  background: var(--surface);
  border-color: var(--error);
  color: var(--error);
}
.button-danger:hover { background: var(--error-soft); border-color: var(--error); color: var(--error); }

.inline { display: inline; margin: 0; padding: 0; }

/* ---------------- Flash ---------------- */

.flash {
  padding: 12px 14px;
  margin-bottom: var(--s-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted-2);
  background: var(--surface);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.flash::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}
.flash.error { border-left-color: var(--error); background: var(--error-soft); color: var(--error); }
.flash.error::before { background: var(--error); }
.flash.warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.flash.warn::before { background: var(--warn); }
.flash.ok { border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.flash.ok::before { background: var(--ok); }

/* ---------------- Layout helpers ---------------- */

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
}
.actions { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.actions-card { background: transparent; border: none; padding: 0; box-shadow: none; }

.stack > * + * { margin-top: var(--s-2); }
.stack label { margin-top: var(--s-3); }
.form-card { max-width: 640px; }

/* ---------------- Tables ---------------- */

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: var(--s-3);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  background: var(--surface-2);
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12px; }

/* Stats: per-row expand */
.stats-row-open { background: var(--surface-2); }
.stats-row-open + .stats-detail { background: var(--surface-2); }
.stats-detail td { padding: var(--s-3) var(--s-4); }
.raw-payload {
  margin: 0;
  padding: 10px 12px;
  background: var(--bar);
  color: var(--bar-ink);
  font-size: 12px;
  border-radius: var(--r-sm);
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------------- Badges ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  line-height: 1.4;
}
.badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}
.badge-draft     { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge-published { background: var(--ok-soft);   color: var(--ok);    border-color: transparent; }
.badge-playing   { background: var(--live-soft); color: var(--live);  border-color: transparent; }
.badge-playing::before {
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live-glow);
  opacity: 1;
  animation: live-pulse 1.4s ease-in-out infinite;
}
.badge-done      { background: var(--surface-2); color: var(--muted); border-color: var(--border); opacity: 0.8; }
.badge-cancelled { background: var(--error-soft); color: var(--error); border-color: transparent; }

/* Reusable live indicator: <span class="live-dot"></span> */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live-glow);
  animation: live-pulse 1.4s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--live-glow); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .badge-playing::before, .live-dot { animation: none; }
}

/* ---------------- Definition list ---------------- */

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px var(--s-4);
  margin: var(--s-3) 0;
}
.kv dt {
  color: var(--muted);
  font-size: var(--t-sm);
  letter-spacing: 0.02em;
  font-weight: 500;
}
.kv dd { margin: 0; font-size: var(--t-base); color: var(--ink); font-variant-numeric: tabular-nums; }
/* Two-column compact KV (label / value pairs across the row). */
.kv-grid-2 {
  grid-template-columns: 180px 1fr 180px 1fr;
  gap: 8px var(--s-4);
}
@media (max-width: 720px) {
  .kv-grid-2 { grid-template-columns: 140px 1fr; }
}

/* ---------------- Duration preview ---------------- */

.duration-preview {
  margin-top: var(--s-4);
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--ink-2);
}
.duration-preview-empty {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.duration-preview-error {
  background: var(--error-soft);
  border: 1px solid transparent;
  border-left: 3px solid var(--error);
  color: var(--error);
}
.duration-pieces { list-style: none; padding: 0; margin: 0 0 6px; }
.duration-pieces li { padding: 2px 0; color: var(--muted); }
.duration-total { margin: 4px 0 0; font-weight: 600; }
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ---------------- Dashboard / landing ---------------- */

.hero-band {
  position: relative;
  padding: var(--s-8) var(--s-6);
  margin-bottom: var(--s-5);
  background:
    radial-gradient(circle at 12% 8%, var(--accent-soft), transparent 40%),
    radial-gradient(circle at 90% 90%, var(--live-soft), transparent 50%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  overflow: hidden;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s-3);
}
.hero-state-live .hero-eyebrow { color: var(--live); }
.hero-title {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 var(--s-3);
  color: var(--ink-2);
}
.hero-meta {
  font-size: var(--t-md);
  margin: 0;
}
.hero-actions {
  margin-top: var(--s-5);
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

/* Now-happening band: schedule list left, live snapshot right. */
.now-happening {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
@media (max-width: 880px) {
  .now-happening { grid-template-columns: 1fr; }
}
.today-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.today-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: var(--s-3);
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.today-row:last-child { border-bottom: none; }
.today-row-past { opacity: 0.55; }
.today-row-now {
  background: var(--live-soft);
  border-left: 2px solid var(--live);
  margin: 0 calc(var(--s-3) * -1);
  padding-left: var(--s-3);
  padding-right: var(--s-3);
  border-radius: var(--r-sm);
}
.today-row-now .today-time { color: var(--live); }
.today-row-now .today-title { color: var(--ink-2); font-weight: 600; }
.today-time {
  color: var(--ink-2);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.today-title { color: var(--ink-2); text-decoration: none; }
.today-title:hover { color: var(--accent); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
  box-shadow: var(--sh-1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-label {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  font-size: 36px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--ink-2);
  font-feature-settings: "kern", "liga", "ss01";
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.kpi-unit {
  font-size: 18px;
  color: var(--muted);
  font-weight: 500;
}
.kpi-hint { margin: 0; }

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--s-4);
}
@media (max-width: 800px) {
  .dashboard-bottom { grid-template-columns: 1fr; }
  .hero-title { font-size: 28px; }
  .kpi-value { font-size: 28px; }
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-2);
}
.quick-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.quick-link:hover {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateY(-1px);
  color: var(--ink);
}
.quick-link-title { font-weight: 600; color: var(--ink-2); }

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.activity-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: var(--s-3);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.activity-row:last-child { border-bottom: none; }
.activity-action { font-weight: 500; color: var(--ink-2); }
.activity-ts { color: var(--muted); }

/* ---------------- Sparkline ---------------- */

.spark-wrap   { margin-top: 6px; }
.spark-host   { display: inline-flex; }
.spark-host.accent .sparkline { color: var(--accent); }
.spark-host.live   .sparkline { color: var(--live); }
.sparkline    { display: block; opacity: 0.85; }
.spark-meta   { margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------------- Command palette ---------------- */

.palette-trigger {
  position: fixed;
  bottom: var(--s-5);
  left: var(--s-5);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  background: var(--surface-elev);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--sh-2);
  font-size: var(--t-sm);
  transition: color 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.palette-trigger:hover { color: var(--ink-2); border-color: var(--accent); transform: translateY(-1px); }
.palette-trigger-label { font-weight: 500; }

.palette-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  line-height: 1.2;
}

.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5, 9, 19, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
[data-theme="light"] .palette-overlay { background: rgba(15, 23, 42, 0.35); }

.palette-dialog {
  width: min(620px, calc(100vw - 32px));
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px var(--s-4);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.palette-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--t-md);
  font-family: var(--font-sans);
  padding: 0;
}
.palette-input::placeholder { color: var(--muted-2); }

.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
}
.palette-item-active { background: var(--accent-soft); }
.palette-item-active .palette-label { color: var(--ink-2); }
.palette-kind {
  flex-shrink: 0;
  width: 90px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}
.palette-label { flex: 1; }
.palette-empty { padding: 24px; text-align: center; }

.palette-foot {
  display: flex;
  gap: var(--s-4);
  padding: 8px var(--s-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--t-xs);
}

/* ---------------- Toasts ---------------- */

.toast-stack {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: min(420px, calc(100vw - var(--s-6) * 2));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-elev);
  color: var(--ink);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted-2);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-3);
  font-size: var(--t-sm);
  line-height: 1.45;
}
.toast-info  { border-left-color: var(--accent); }
.toast-info  .toast-icon { color: var(--accent); }
.toast-ok    { border-left-color: var(--ok); }
.toast-ok    .toast-icon { color: var(--ok); }
.toast-warn  { border-left-color: var(--warn); }
.toast-warn  .toast-icon { color: var(--warn); }
.toast-error { border-left-color: var(--error); }
.toast-error .toast-icon { color: var(--error); }
.toast-icon  { flex-shrink: 0; line-height: 0; margin-top: 1px; }
.toast-body  { flex: 1; }
.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  margin: -2px -4px 0 0;
}
.toast-close:hover { color: var(--ink-2); }

.toast-enter        { transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.toast-enter-start  { opacity: 0; transform: translateY(8px); }
.toast-enter-end    { opacity: 1; transform: translateY(0); }
.toast-leave        { transition: opacity 320ms ease, transform 320ms ease; }
.toast-leave-start  { opacity: 1; transform: translateY(0); }
.toast-leave-end    { opacity: 0; transform: translateY(8px); }

/* ---------------- Control panel ---------------- */

.control-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--s-4);
}
.control-grid > .card { margin-bottom: 0; }
.control-grid #control-snapshot-card { grid-row: span 2; }
@media (max-width: 980px) {
  .control-grid { grid-template-columns: 1fr; }
  .control-grid #control-snapshot-card { grid-row: auto; }
}

.snapshot-frame {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
}
.snapshot-frame img { width: 100%; height: auto; display: block; }

.control-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.control-btn {
  width: 100%;
  margin-top: 0 !important;
  padding: 12px 14px;
  font-weight: 600;
  font-size: var(--t-sm);
  letter-spacing: 0.02em;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ---------------- Content filter ---------------- */

.content-filter { margin-top: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.content-filter-row {
  display: flex;
  gap: var(--s-2);
  align-items: stretch;
  flex-wrap: wrap;
}
.content-filter-row input[type="search"] {
  flex: 1;
  min-width: 240px;
  margin: 0;
}
.content-filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tag-chip {
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, filter 120ms ease;
}
.tag-chip:hover { filter: brightness(1.08); }
.tag-chip-on { box-shadow: inset 0 0 0 1px var(--accent); }
.tag-chip-x {
  display: inline-block;
  font-weight: 700;
  margin-right: 2px;
  opacity: 0.85;
}

/* ---------------- Empty states ---------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-10) var(--s-6);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.empty-state svg { color: var(--muted-2); opacity: 0.7; }
.empty-state h3 { color: var(--ink-2); font-weight: 600; margin: 0; }
.empty-state p { margin: 0; max-width: 38ch; line-height: 1.5; }
.empty-state .actions { margin-top: var(--s-2); }

/* ---------------- Week grid ---------------- */

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--s-2);
  margin-top: var(--s-4);
}
.week-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 220px;
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.week-day:hover { border-color: var(--border-strong); }
.week-day-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--sh-1);
  background: var(--surface);
  position: relative;
}
.week-day-today::after {
  content: "Сегодня";
  position: absolute;
  top: -8px;
  right: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.4;
}
.week-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--t-sm);
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: var(--s-2);
}
.week-day-head .weekday {
  font-weight: 700;
  text-transform: uppercase;
  font-size: var(--t-xs);
  color: var(--ink-2);
  letter-spacing: 0.08em;
}
.week-day-head .daynum { font-variant-numeric: tabular-nums; }
.week-empty { padding: var(--s-3) 0; text-align: center; font-size: var(--t-sm); color: var(--muted-2); }

/* ---------------- Show chips ---------------- */

.show-chip {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: var(--t-sm);
  border-radius: var(--r-sm);
  transition: border-color 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
.show-chip:hover {
  border-color: var(--border-strong);
  box-shadow: var(--sh-1);
  transform: translateX(1px);
  color: var(--ink);
}
.show-chip-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.show-chip-title {
  color: var(--ink);
  margin: 3px 0;
  word-break: break-word;
  font-weight: 500;
}
.show-chip-meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: var(--t-xs); }
.show-chip-draft     { border-left-color: var(--muted-2); }
.show-chip-published { border-left-color: var(--ok); }
.show-chip-playing   { border-left-color: var(--accent); background: var(--accent-soft); }
.show-chip-done      { border-left-color: var(--muted-2); opacity: 0.65; }
.show-chip-cancelled { border-left-color: var(--error); opacity: 0.55; }
.show-chip-cancelled .show-chip-title { text-decoration: line-through; }

@media (max-width: 1000px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-day { min-height: auto; }
}

/* ---------------- Misc utilities ---------------- */

hr { border: none; border-top: 1px solid var(--border); margin: var(--s-4) 0; }

::selection { background: var(--accent); color: var(--accent-ink); }

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