:root {
  --bg: #07080A;
  --panel: #0D0F12;
  --raised: #15181B;
  --button: #171A1E;
  --border: #22262B;
  --line: #1D2025;
  --strong: #2F343B;
  --text: #E7E9EC;
  --muted: #9AA1AA;
  --dim: #8E959E;
  --faint: #5A6169;
  --amber: #FFB020;
  --live: #FF453A;
  --live-text: #FF6B5E;
  --green: #3DDC84;
  --blue: #A9C4FF;
  --mint: #7CE8A8;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input { font: inherit; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.mono { font-family: var(--mono); }
.label { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: var(--dim); }
.press { transition: transform .12s ease, filter .2s; }
.press:active:not(:disabled) { transform: scale(.97); }

/* Header */
.header { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.header .titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex-grow: 1; }
.header .brand { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .14em; color: var(--amber); }
.header .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 13px; font-family: var(--mono); font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.away { height: 26px; padding: 0 9px; border: 1px solid var(--strong); border-radius: 13px; background: var(--button); font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--blue); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: rgba(61,220,132,.10); color: var(--green); }
.chip.wait { background: rgba(255,176,32,.12); color: var(--amber); }
.chip.net { background: rgba(122,167,255,.10); color: var(--blue); }

/* Output */
.top { flex-shrink: 0; padding: 12px 16px 0; display: flex; flex-direction: column; gap: 10px; }
.thumb { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #050505; box-shadow: 0 0 0 1px #2A2F35; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .tag { position: absolute; top: 8px; padding: 2px 6px; border-radius: 3px; background: rgba(0,0,0,.55); font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .1em; }
.thumb .tag.left { left: 8px; color: var(--live-text); display: flex; align-items: center; gap: 5px; }
.thumb .tag.left::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
.thumb .tag.right { right: 8px; color: #B8BEC6; font-weight: 400; }
.thumb .cover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(40,6,5,.82); font-size: 13px; font-weight: 800; letter-spacing: .14em; color: var(--live-text); }
.thumb .none { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.now { display: grid; grid-template-columns: 82px 44px minmax(0, 1fr); align-items: baseline; row-gap: 6px; font-size: 13px; }
.now .num { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--amber); }
.now .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now .live { color: var(--live-text); }

/* Body */
.contents { display: contents; }
.body.scroll { overflow: auto; }
.body { flex-grow: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 12px; }
.go { flex-grow: 1; min-height: 130px; border: 0; border-radius: 10px; background: var(--amber); color: #1A1206; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.go .big { font-size: 46px; font-weight: 800; letter-spacing: .06em; }
.go .hint { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.go.resume { background: #FF9F0A; }
.go:disabled { background: #111316; color: var(--faint); border: 1px solid var(--border); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.btn { height: 56px; border: 1px solid var(--strong); border-radius: 8px; background: var(--button); font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.btn:disabled { border-color: var(--border); background: var(--panel); color: var(--faint); }
.panic { height: 56px; border: 1px solid #5A2A27; border-radius: 8px; background: transparent; color: var(--live-text); font-size: 13px; font-weight: 800; letter-spacing: .1em; }
.panic.armed { border-color: var(--live); background: rgba(255,69,58,.16); }
.panic:disabled { border-color: var(--border); color: var(--faint); }

.list { flex-grow: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); -webkit-overflow-scrolling: touch; }
.list .head { display: flex; align-items: center; gap: 8px; height: 26px; padding: 0 12px; background: #14171A; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; color: #B8BEC6; }
.list .head .mono { font-size: 10.5px; color: var(--amber); font-weight: 400; }
.cue { width: 100%; display: grid; grid-template-columns: 18px 46px minmax(0, 1fr) auto; align-items: center; gap: 4px; min-height: 44px; padding: 0 12px; border: 0; border-bottom: 1px solid #16191C; background: transparent; text-align: left; font-size: 13px; }
.cue .mark { font-size: 11px; }
.cue .num { font-family: var(--mono); font-size: 11.5px; color: var(--amber); }
.cue .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cue .state { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; }
.cue.on { background: rgba(255,69,58,.10); box-shadow: inset 3px 0 0 var(--live); }
.cue.on .mark, .cue.on .state { color: var(--live-text); }
.cue.next { box-shadow: inset 3px 0 0 var(--amber); }
.cue.next .mark, .cue.next .state { color: var(--amber); }
.cue.done .state { color: var(--faint); }
.cue.picked { background: rgba(122,167,255,.14); box-shadow: inset 3px 0 0 #7AA7FF; }
.fire { height: 56px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--faint); font-size: 13px; font-weight: 800; letter-spacing: .08em; padding: 0 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fire.ready { border-color: var(--amber); background: var(--amber); color: #1A1206; }

.section { display: flex; align-items: baseline; gap: 8px; }
.section .note { font-size: 11px; color: var(--faint); }
.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.shots.single { grid-template-columns: minmax(0, 1fr); }
.shot { min-height: 64px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 8px 10px; border: 1px solid var(--strong); border-radius: 8px; background: var(--button); text-align: left; }
.shot .line { display: flex; align-items: center; gap: 6px; }
.shot .num { font-family: var(--mono); font-size: 10.5px; color: var(--amber); }
.shot .kind { font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.shot .kind.video { color: var(--amber); }
.shot .kind.audio { color: var(--blue); }
.shot .kind.overlay { color: var(--mint); }
.shot .state { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.shot .name { font-size: 13px; font-weight: 600; line-height: 1.25; }
.shots.single .name { font-size: 15px; }
.shot.playing { border-color: var(--live); background: rgba(255,69,58,.12); }
.shot.playing .state { color: var(--live-text); }
.shot:disabled { opacity: .5; }

.music { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--raised); }
.music .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-grow: 1; }
.music .song { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--strong); border-radius: 6px; background: var(--button); padding: 0; display: flex; align-items: center; justify-content: center; }
.icon svg { width: 14px; height: 14px; fill: var(--text); }
.icon:disabled svg { fill: var(--faint); }
.pill { font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; }
.pill.duck { background: rgba(122,167,255,.16); color: var(--blue); }
.pill.pause { background: rgba(255,176,32,.16); color: var(--amber); }

.roomcard { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.roomcard .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.roomcard.up .dot { background: var(--green); }
.roomcard .what { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.roomcard .state { font-size: 14px; font-weight: 600; }
.roomcard .clock { font-family: var(--mono); font-size: 20px; font-weight: 700; color: #F1ECE2; }

.offline { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid #5C4A1E; border-radius: 10px; background: rgba(255,176,32,.06); margin: 12px 16px 0; }
.offline strong { font-size: 15px; color: #FFD58A; }
.offline span { font-size: 13px; line-height: 1.5; color: #D6DAE0; }
.warning { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: #FFD58A; }
.warning::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex-shrink: 0; }

.tabs { height: 64px; flex-shrink: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); background: var(--panel); }
.tabs button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--dim); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; }
.tabs button::before { content: ""; width: 22px; height: 3px; border-radius: 2px; background: transparent; }
.tabs button[aria-selected="true"] { color: var(--amber); }
.tabs button[aria-selected="true"]::before { background: var(--amber); }

/* Pairing and messages */
.center { flex-grow: 1; display: flex; flex-direction: column; gap: 22px; padding: 56px 24px 24px; overflow: auto; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.hero .brand { font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .16em; color: var(--amber); }
.hero h1 { margin: 0; font-size: 22px; }
.hero p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); text-align: center; }
.card .code { font-family: var(--mono); font-size: 44px; font-weight: 700; letter-spacing: .2em; color: var(--amber); }
.card p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.card.ok { align-items: stretch; text-align: left; border-color: #1f3a2c; background: rgba(61,220,132,.06); }
.card.ok strong { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--green); }
.card.ok strong::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #B8BEC6; }
.field input { height: 48px; border: 1px solid #2A2F35; border-radius: 8px; background: #111316; color: var(--text); padding: 0 14px; font-size: 16px; }
.primary { height: 56px; border: 0; border-radius: 10px; background: var(--amber); color: #1A1206; font-size: 15px; font-weight: 800; letter-spacing: .06em; }
.primary:disabled { background: #2A2F35; color: var(--faint); }
.small { font-size: 12.5px; line-height: 1.5; color: var(--muted); text-align: center; margin: 0; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #2A2F35; border-top-color: var(--amber); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); padding: 12px 14px; border: 1px solid #5C4A1E; border-radius: 10px; background: #1B1608; color: #FFD58A; font-size: 13px; line-height: 1.45; box-shadow: 0 8px 24px rgba(0,0,0,.5); }

/* A picture older than 2 s (or with no connection): dimmed, and said. */
.thumb img.old { opacity: .45; }
.thumb .tag.stale { right: 8px; color: var(--amber); font-weight: 700; }
