:root {
  color-scheme: dark;
  --bg: #0a0d13;
  --panel: #121722;
  --panel-2: #181e2c;
  --line: #242c3d;
  --line-strong: #364058;
  --text: #e8ebf2;
  --muted: #8d96aa;
  --accent: #35d6c0;
  --accent-ink: #04201c;
  --warn: #f5b84a;
  --hot: #ff6b5e;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
h2.sub { margin-top: 22px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.spacer { flex: 1 1 auto; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.hint.warn { color: var(--warn); }
.empty { color: var(--muted); font-size: 14px; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.lede { color: var(--muted); font-size: 16px; max-width: 56ch; }

/* ----------------------------------------------------------------- controls */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover:not(:disabled) { border-color: var(--muted); background: #202739; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #5be3d0; border-color: #5be3d0; }
.btn.danger { color: var(--hot); border-color: #5a2e2c; background: #1f1517; }
.btn.danger:hover:not(:disabled) { background: #2b1a1c; border-color: var(--hot); }
.btn.danger.armed { background: var(--hot); border-color: var(--hot); color: #2a0906; }
.btn.on { color: var(--accent); border-color: var(--accent); }

input[type="text"], select {
  font: inherit;
  color: var(--text);
  background: #0d111a;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}
input[type="text"]::placeholder { color: #5b6478; }
input[type="text"].invalid { border-color: var(--hot); background: #1f1517; }
.time-input { width: 6.5ch; text-align: center; font-family: var(--mono); font-variant-numeric: tabular-nums; padding-left: 4px; padding-right: 4px; box-sizing: content-box; }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { width: 17px; height: 17px; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ landing */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.landing-inner { width: 100%; max-width: 640px; display: grid; gap: 18px; }
.create-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.create-form input { flex: 1 1 220px; padding: 12px 14px; font-size: 16px; border-radius: 12px; }
.recent-rooms { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.recent-rooms li { display: flex; gap: 12px; align-items: baseline; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.recent-rooms a { font-weight: 600; text-decoration: none; }
.recent-rooms .muted { font-family: var(--mono); font-size: 12px; }

/* --------------------------------------------------------------------- room */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 13, 19, 0.9);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}
.brand { color: var(--accent); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px; text-decoration: none; }
.room-name { appearance: none; background: none; border: 1px solid transparent; color: var(--text); font: inherit; font-weight: 600; font-size: 16px; padding: 4px 8px; border-radius: 8px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-name:hover { border-color: var(--line-strong); }

.pill { font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 7px; vertical-align: 1px; }
.pill.live { color: var(--text); }
.pill.live::before { background: var(--accent); box-shadow: 0 0 0 3px rgba(53, 214, 192, 0.2); }
.pill.down { color: var(--hot); border-color: #5a2e2c; }
.pill.down::before { background: var(--hot); }

.call-banner {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin: 16px auto 0;
  width: min(1180px, calc(100% - 40px));
  padding: 14px 20px;
  border-radius: var(--radius);
  background: #10302c;
  border: 1px solid var(--accent);
}
.call-banner.flash { animation: flash 0.9s ease-out; }
@keyframes flash { from { background: var(--accent); } to { background: #10302c; } }
.call-tag { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.call-text { font-size: clamp(18px, 2.6vw, 26px); font-weight: 650; line-height: 1.25; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  width: min(1180px, calc(100% - 40px));
  margin: 16px auto 48px;
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.editor-card { grid-column: 1 / -1; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 14px; }

/* -------------------------------------------------------------------- clock */
.clock-card { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.state-label { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.clock {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: clamp(72px, 15vw, 168px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: #59627a;
  margin: 4px 0 14px;
}
.clock.running { color: var(--text); }
.clock.paused { color: var(--warn); }
.controls { justify-content: center; gap: 10px; }
.controls .btn.big { min-width: 150px; }
.sync { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); width: 100%; display: grid; gap: 8px; justify-items: center; }
.sync-label { font-size: 13px; color: var(--muted); }
.nudges { justify-content: center; }
.set-form { margin-left: 10px; flex-wrap: nowrap; }

/* ------------------------------------------------------------------ up next */
.next-up { margin: 12px 0 14px; padding: 14px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-strong); display: grid; gap: 2px; }
.next-in { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; color: var(--accent); }
.next-text { font-size: 19px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.next-up.none .next-text { color: var(--muted); font-weight: 500; font-size: 16px; }
.next-up.soon { border-color: var(--warn); }
.next-up.soon .next-in { color: var(--warn); }
.next-up.now { border-color: var(--hot); background: #241719; }
.next-up.now .next-in { color: var(--hot); }

.upcoming, .called, .quick-list { list-style: none; margin: 0; padding: 0; display: grid; }
.upcoming li, .called li, .quick-list li { display: flex; align-items: baseline; gap: 12px; padding: 7px 2px; border-top: 1px solid var(--line); }
.upcoming li:first-child, .called li:first-child { border-top: 0; }
.called { margin-top: 6px; }
.called li { color: var(--muted); }
.called li:first-child:not(.empty) { color: var(--text); }
.when { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); min-width: 5ch; text-align: right; flex: none; }
.what { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tag { flex: none; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 6px; }

/* ------------------------------------------------------------- quick timers */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  appearance: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
}
.chip:hover:not(:disabled) { border-color: var(--accent); }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }
.chip-time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.quick-form input[type="text"]:first-child { flex: 1 1 160px; }
.quick-list { margin-top: 12px; }
.quick-list li { align-items: center; }
.quick-list .when { color: var(--accent); font-weight: 700; font-size: 17px; }
.quick-list li.soon .when { color: var(--warn); }

/* -------------------------------------------------------------------- voice */
.say-form { margin-top: 12px; flex-wrap: nowrap; }
.say-form input { flex: 1 1 auto; }
.scope { text-transform: none; letter-spacing: 0; font-weight: 500; color: #5b6478; margin-left: 6px; }
.voice-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; align-items: center; margin-top: 12px; }
.voice-grid label { color: var(--muted); font-size: 14px; }
.voice-grid select, .voice-grid input { width: 100%; }
.voice-actions { margin-top: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ------------------------------------------------------------------- editor */
.editor-head, .editor-row {
  display: grid;
  grid-template-columns: 28px 8.5ch minmax(0, 1fr) 8.5ch 8.5ch auto;
  gap: 10px;
  align-items: center;
}
.editor-head { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.editor-head span:last-child { width: 68px; }
.editor-rows { display: grid; gap: 8px; padding: 10px 0 6px; }
.editor-row .time-input { width: auto; box-sizing: border-box; }
.editor-row .text-input { width: 100%; }
.editor-row.off .text-input, .editor-row.off .time-input { color: var(--muted); }
.editor-row .btn { width: 68px; }

/* ------------------------------------------------------------------ overlay */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(6, 8, 12, 0.86); backdrop-filter: blur(6px); }
.overlay-card { width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 18px; padding: 30px; display: grid; gap: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  max-width: calc(100% - 32px);
  background: #e8ebf2;
  color: #0a0d13;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.toast.error { background: var(--hot); color: #2a0906; }

/* ------------------------------------------------------------------- narrow */
@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .set-form { margin-left: 0; }
}
@media (max-width: 640px) {
  .top { padding: 10px 16px; }
  .top .spacer { display: none; }
  .room-name { flex: 1 1 auto; text-align: left; }
  .grid, .call-banner { width: calc(100% - 32px); }
  .card { padding: 16px; }
  .controls { width: 100%; }
  .controls .btn.big { min-width: 0; flex: 1 1 100%; }
  .editor-head { display: none; }
  .editor-row { grid-template-columns: 24px repeat(3, minmax(0, 1fr)) auto; gap: 8px; padding: 12px 0 4px; border-top: 1px solid var(--line); }
  .editor-row .text-input { grid-column: 1 / -1; grid-row: 2; }
  .editor-row .btn { width: auto; }
  .say-form, .quick-form { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .call-banner.flash { animation: none; }
  .btn { transition: none; }
}
