/* CuePage. One dark, high-contrast look for booths, front desks and stages. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/ahn-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/ahn-latin-ext.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0a0c0f;
  --panel: #13161b;
  --panel-2: #1a1e25;
  --panel-3: #232833;
  --line: #2a303b;
  --text: #f3f5f8;
  --muted: #9aa4b2;
  --dim: #6b7482;
  --cue: #ffb21a; /* amber cue light */
  --cue-ink: #1a1100;
  --go: #2fd27a; /* ready / live */
  --stop: #ff4d4d;
  --warn: #ffcc4d;
  --info: #6aa8ff;
  --radius: 18px;
  --radius-s: 12px;
  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--cue); }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; white-space: nowrap;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--cue); border-color: var(--cue); color: var(--cue-ink); }
.btn.primary:hover { background: #ffc24d; }
.btn.go { background: var(--go); border-color: var(--go); color: #04170c; }
.btn.danger { background: transparent; border-color: #5c2a2a; color: #ff8a8a; }
.btn.danger:hover { background: #2a1416; }
.btn.stop { background: var(--stop); border-color: var(--stop); color: #fff; letter-spacing: .06em; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 11px; }
.btn.block { width: 100%; }
.icon { width: 22px; height: 22px; flex: none; }

/* ---------- inputs ---------- */
.field { display: grid; gap: 7px; }
.field > span { font-weight: 700; font-size: 15px; color: var(--muted); }
.input, .textarea {
  width: 100%; min-height: 52px; padding: 12px 15px; border-radius: 13px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: 17px;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--cue); box-shadow: 0 0 0 3px rgba(255,178,26,.18); }
.textarea { resize: vertical; line-height: 1.35; }
.hint { color: var(--muted); font-size: 14px; }
.error-text { color: #ff9c9c; font-weight: 700; min-height: 1.2em; }

/* ---------- shell ---------- */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  border-bottom: 1px solid var(--line); background: rgba(10,12,15,.92);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
}
.top .title { font-weight: 800; font-size: 19px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .title small { display: block; font-weight: 700; font-size: 13px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.top .spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; text-decoration: none; color: var(--text); }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--cue); display: grid; place-items: center; flex: none; }
.logo svg { width: 20px; height: 20px; }

.page { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 28px calc(18px + var(--safe-r)) calc(40px + var(--safe-b)) calc(18px + var(--safe-l)); }
.narrow { max-width: 460px; }
.center-col { display: grid; place-items: center; min-height: 100%; }
h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 22px; margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 18px; margin: 0 0 26px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.links { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 18px; font-size: 15px; }
.links a { color: var(--muted); }

/* ---------- home ---------- */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.mode {
  display: grid; gap: 10px; align-content: start; text-align: left;
  min-height: 210px; padding: 26px; border-radius: 22px; cursor: pointer;
  border: 1px solid var(--line); background: linear-gradient(160deg, var(--panel-2), var(--panel));
  color: var(--text); text-decoration: none; transition: transform .1s ease, border-color .15s ease;
}
.mode:hover { border-color: #3b4351; }
.mode:active { transform: scale(.985); }
.mode .glyph { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--cue); color: var(--cue-ink); }
.mode.pager .glyph { background: var(--info); color: #06142a; }
.mode .glyph svg { width: 30px; height: 30px; }
.mode b { font-size: 28px; }
.mode span { color: var(--muted); font-size: 17px; }
.resume { margin-bottom: 18px; }

.rooms { display: grid; gap: 12px; }
.room-row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 16px 16px 16px 22px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
}
.room-row b { font-size: 21px; }
.room-row .row { justify-content: flex-end; }
.room-row .btn { min-width: 132px; }
@media (max-width: 560px) {
  .room-row { grid-template-columns: 1fr; }
  .room-row .row { justify-content: stretch; }
  .room-row .btn { flex: 1; min-width: 0; }
}

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 700; font-size: 14px; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.ok { background: var(--go); box-shadow: 0 0 10px rgba(47,210,122,.6); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--stop); box-shadow: 0 0 10px rgba(255,77,77,.6); }
.banner { margin: 12px auto 0; max-width: 1100px; padding: 12px 16px; border-radius: 14px; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: #2b2410; border: 1px solid #5a4a14; color: #ffe08a; }
.banner.bad { background: #2b1214; border: 1px solid #5c2328; color: #ffb3b3; }

/* ---------- remote ---------- */
body.fixed #app { height: 100vh; height: 100dvh; overflow: hidden; }
.remote { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* flex + margin:auto centres the grid but never pushes its first row out of reach when it overflows */
.cue-area { flex: 1; display: flex; padding: 18px calc(18px + var(--safe-r)) 18px calc(18px + var(--safe-l)); min-height: 0; overflow: auto; }
.cue-grid { margin: auto; display: grid; gap: var(--gap, 16px); grid-template-columns: repeat(var(--cols, 3), var(--tile-w, 220px)); justify-content: center; align-content: center; }
.cue {
  position: relative; height: var(--tile-h, 140px); border-radius: 20px; border: 2px solid var(--line);
  background: linear-gradient(170deg, #1d222b, #151920); color: var(--text); cursor: pointer;
  display: grid; place-items: center; padding: 14px; text-align: center;
  font-weight: 800; font-size: var(--tile-font, 22px); line-height: 1.15; overflow: hidden;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: transform .08s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.cue::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--cue-color, transparent); }
.cue:hover { border-color: #3d4554; }
.cue:active { transform: scale(.965); }
.cue .label { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.cue .kind { position: absolute; left: 12px; bottom: 10px; font-size: 12px; font-weight: 700; color: var(--dim); letter-spacing: .05em; text-transform: uppercase; }
.cue .key { position: absolute; right: 12px; bottom: 9px; font-size: 12px; font-weight: 800; color: var(--dim); }
.cue.fired { border-color: var(--cue); box-shadow: 0 0 0 4px rgba(255,178,26,.25); background: linear-gradient(170deg, #2a2412, #1a170e); }
.cue.playing { border-color: var(--go); box-shadow: 0 0 0 4px rgba(47,210,122,.22); }
.cue.playing .kind { color: var(--go); }
.cue.failed { border-color: var(--stop); }
.cue.add { border-style: dashed; color: var(--muted); background: transparent; font-size: calc(var(--tile-font, 22px) * .8); }
.cue.uploading { cursor: default; }
.cue .bar { position: absolute; left: 0; bottom: 0; height: 6px; background: var(--cue); width: 0; transition: width .2s; }
.cue .tools { position: absolute; inset: auto 8px 8px 8px; display: flex; gap: 6px; justify-content: center; }
.cue .tools button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.cue .tools button.del { color: #ff8a8a; }
.cue.editing { cursor: default; padding-bottom: 58px; }
.cue.editing .kind { display: none; }
.cue.editing .label { -webkit-line-clamp: 2; }

.bottom {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
  border-top: 1px solid var(--line); background: var(--panel);
}
.feedback { flex: 1; min-width: 200px; font-weight: 700; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.feedback.ok { color: var(--go); }
.feedback.warn { color: var(--warn); }
.feedback.bad { color: #ff8a8a; }
.empty { text-align: center; color: var(--muted); max-width: 520px; display: grid; gap: 16px; justify-items: center; }
.empty b { color: var(--text); font-size: 22px; }

/* ---------- player / screen (full screen surfaces) ---------- */
.surface { position: fixed; inset: 0; background: #000; overflow: hidden; }
.surface video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.surface .chip {
  position: absolute; left: calc(14px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); z-index: 5;
  display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-radius: 999px;
  background: rgba(20,22,26,.86); border: 1px solid #2c313a; font-weight: 700; font-size: 14px; color: #e8ebf0;
  transition: opacity .6s ease;
}
.surface .chip.quiet { opacity: 0; pointer-events: none; }
.gate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, #1a1f27, #07080a 70%); padding: 24px; }
.gate .card { width: min(520px, 100%); text-align: center; }
.gate h1 { font-size: 30px; }
.gate .big { min-height: 72px; font-size: 22px; border-radius: 18px; }
.gate details { text-align: left; color: var(--muted); font-size: 15px; margin-top: 8px; }
.gate summary { cursor: pointer; font-weight: 700; color: var(--text); }
.gate ol { padding-left: 20px; margin: 8px 0 0; }

.tapbar {
  position: absolute; bottom: calc(12px + var(--safe-b)); left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 8px; padding: 8px; border-radius: 16px; background: rgba(20,22,26,.92); border: 1px solid #2c313a;
  transition: opacity .3s ease; max-width: calc(100vw - 24px); overflow-x: auto;
}
.tapbar.hide { opacity: 0; pointer-events: none; }

/* ---------- pager screen renderer (shared with previews) ---------- */
.pv { position: relative; overflow: hidden; background: var(--pv-bg, #000); color: var(--pv-fg, #fff); container-type: size; }
.pv-inner { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--pv-pad, 4%); }
.pv-text {
  width: 100%; text-align: center; font-family: var(--font); font-weight: 800; line-height: 1.12;
  letter-spacing: -.005em; overflow-wrap: normal; text-wrap: balance;
}
.pv-text.break { overflow-wrap: anywhere; }
.pv-text.nowrap > div { white-space: nowrap; }
.pv-text > div { text-wrap: balance; }
.pv.scroll .pv-inner { place-items: start center; }
.pv.scroll .pv-text { will-change: transform; }
.pv.mirror .pv-inner { transform: scaleX(-1); }
.pv .pv-dot { position: absolute; right: 10px; top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--stop); z-index: 3; }

/* ---------- sender ---------- */
.sender { flex: 1; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; padding: 18px calc(18px + var(--safe-r)) calc(18px + var(--safe-b)) calc(18px + var(--safe-l)); max-width: 1400px; width: 100%; margin: 0 auto; align-items: start; }
@media (max-width: 900px) { .sender { grid-template-columns: 1fr; } }
.compose .textarea { min-height: 150px; font-size: 22px; font-weight: 700; }
.compose .actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.compose .actions .primary { min-height: 64px; font-size: 21px; }
.preview-wrap { display: grid; gap: 8px; }
.preview-wrap .pv { width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; border: 1px solid var(--line); }
.preview-label { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--muted); font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 54px; height: 40px; border-radius: 10px; border: 2px solid var(--line); cursor: pointer; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { min-height: 40px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel-3); color: var(--text); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.quick button { min-height: 58px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 700; font-size: 16px; text-align: left; cursor: pointer; line-height: 1.2; }
.quick button:hover { background: var(--panel-3); }
.quick button:active { transform: scale(.98); }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 2px; font-weight: 800; }
.color-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.color-pick input[type="color"] { width: 46px; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); padding: 2px; }
.recent { display: grid; gap: 6px; }
.recent button { text-align: left; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--cue); color: var(--cue-ink); font-size: 13px; font-weight: 800; margin-left: 6px; }
.people { display: grid; gap: 10px; }
.person { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 16px 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.person .who b { font-size: 18px; }
.person .who div { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.person .note { margin-top: 6px; color: var(--text); font-size: 15px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: var(--panel-3); color: var(--muted); margin-left: 6px; vertical-align: 2px; }
.tag.admin { background: #2c2410; color: var(--cue); }
.tag.pending { background: #10223b; color: var(--info); }
.tag.denied, .tag.disabled { background: #2b1214; color: #ff9c9c; }
.ai { margin-top: 6px; font-size: 14px; color: var(--muted); }
.ai b { color: var(--text); }
@media (max-width: 640px) { .person { grid-template-columns: 1fr; } }
.meter { height: 10px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--go); }

/* ---------- dialogs & toasts ---------- */
dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--text); padding: 24px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; }
dialog .row { justify-content: flex-end; margin-top: 18px; }
.toasts { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(520px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 13px 16px; border-radius: 14px; background: #22262e; border: 1px solid var(--line); font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: rise .2s ease; }
.toast.bad { border-color: #5c2328; color: #ffb3b3; }
.toast.ok { border-color: #1d4d33; color: #a8f0c6; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--cue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition: none !important; } }
