/* RFP Autocue — Right Formula Productions house style: ground #0d0d10, accent #e10600,
   dark cards, one red primary action, uppercase section words, red numerals. */
:root {
  --bg: #0d0d10; --card: #16161b; --card2: #1d1d24; --line: #2a2a33;
  --text: #f2f2f4; --muted: #8d8d99; --red: #e10600; --red-d: #b30500; --green: #2bd46b; --amber: #ffb020;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .9em; background: var(--card2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- chrome ---------- */
.top { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.top .lockup { height: 30px; width: auto; display: block; }
.top .divider { width: 1px; height: 22px; background: var(--line); }
.top .section { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; color: var(--muted); }
.top .spacer { flex: 1; }
.top a.navlink { text-decoration: none; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.top a.navlink.on, .top a.navlink:hover { color: var(--text); background: var(--card); }
.meta { display: flex; gap: 18px; padding: 10px 20px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); border-bottom: 1px solid var(--line); }
.meta b { color: var(--red); font-weight: 700; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: transparent; padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #444; background: var(--card2); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-d); border-color: var(--red-d); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.danger { color: #ff6b66; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #55555f; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #fff; color: #000; padding: 10px 18px; border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 99; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: min(380px, 100%); display: grid; gap: 14px; }
.login img { height: 40px; justify-self: start; }
.login h1 { margin: 6px 0 0; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.login .err { color: #ff6b66; min-height: 1.2em; font-size: 14px; margin: 0; }

/* ---------- library ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.lib-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.lib-bar input { flex: 1; min-width: 200px; }
.group { margin-bottom: 26px; }
.group h2 { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 10px; display: flex; gap: 10px; align-items: baseline; }
.group h2 .code { color: var(--red); font-size: 15px; }
.group h2 .n { color: var(--muted); font-weight: 500; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card .title { font-weight: 700; font-size: 16px; cursor: pointer; }
.card .title:hover { text-decoration: underline; }
.card .sub { color: var(--muted); font-size: 13px; }
.card .sub b { color: var(--red); }
.card .acts { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.empty-lib { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal > div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(520px, 100%); max-height: 92vh; overflow: auto; display: grid; gap: 14px; }
.modal.wide > div { width: min(1100px, 100%); }
.modal h3 { margin: 0; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.modal label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp textarea { width: 100%; height: 50vh; font-family: var(--mono); font-size: 13px; resize: none; }
.cmp h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }

/* ---------- editor ---------- */
.ed { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: calc(100vh - 59px); }
.ed-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.ed-head { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.ed-head .code-in { width: 110px; text-transform: uppercase; font-weight: 700; color: var(--red); letter-spacing: .06em; }
.ed-head .title-in { flex: 1; min-width: 160px; font-weight: 600; }
.save-state { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 6px; min-width: 120px; }
.save-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.save-state.pending::before { background: var(--amber); }
.save-state.error::before { background: var(--red); }
.ed .body { flex: 1; min-height: 0; overflow: auto; background: var(--bg); padding: 22px 26px; font-size: 18px; line-height: 1.6; outline: none; white-space: pre-wrap; overflow-wrap: break-word; }
.ed .body:empty::before { content: "Start typing the script…"; color: var(--muted); }
.ed .body b { font-weight: 800; }
.ed .body mark { background: var(--red); color: #fff; padding: 0 .12em; border-radius: 3px; }
.ed .body .dir { color: #7d8597; font-style: italic; }
.ed .body .ed-marker { color: var(--red); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: 14px; border-top: 1px solid rgba(225,6,0,.35); padding-top: 8px; margin-top: 6px; }
.ed .body .ed-pause { color: var(--amber); font-family: var(--mono); font-size: 14px; }
.ed-tb { display: flex; align-items: center; gap: 2px; margin: 10px 16px 6px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; width: fit-content; max-width: calc(100% - 32px); }
.ed-tb button { width: 36px; height: 34px; display: grid; place-items: center; background: transparent; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; }
.ed-tb button:hover { background: var(--card2); color: var(--text); }
.ed-tb button.on { background: var(--red); color: #fff; }
.ed-tb svg { width: 18px; height: 18px; fill: currentColor; }
.ed-tb .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.ed-side { overflow: auto; padding: 16px; display: grid; gap: 18px; align-content: start; }
.side-h { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; margin: 0 0 8px; }
.help { font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.help div { display: flex; justify-content: space-between; gap: 8px; }
.mk-list { display: grid; gap: 6px; }
.mk-list button { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.mk-list b { color: var(--red); margin-right: 8px; }
.ed-stats { font-size: 13px; color: var(--muted); }
.ed-stats b { color: var(--red); }

/* ---------- operator ---------- */
.op { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - 59px); }
.op-left { display: flex; flex-direction: column; min-width: 0; padding: 16px; gap: 14px; overflow: auto; }
.op-preview { flex: none; width: 100%; height: min(62vh, calc((100vw - 380px - 34px) * 9 / 16)); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; cursor: ns-resize; overscroll-behavior: contain; }
.op-hint { font-size: 12px; color: var(--muted); }
.op-right { border-left: 1px solid var(--line); overflow: auto; padding: 16px; }
.room-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.room-code { font: 700 34px/1 var(--mono); letter-spacing: .14em; color: var(--red); }
.qr-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.qr { background: var(--card2); border-radius: 10px; padding: 12px; display: grid; gap: 8px; justify-items: center; text-align: center; font-size: 12px; }
.qr .q { background: #fff; padding: 8px; border-radius: 6px; line-height: 0; }
.qr .q svg { width: 128px; height: 128px; }
.qr b { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; }
.qr .url { word-break: break-all; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.disp-full { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.disp-full .hd { display: flex; align-items: center; gap: 8px; }
.disp-full .hd input { flex: 1; padding: 5px 8px; }
.disp-full .grid { display: grid; grid-template-columns: 96px 1fr 44px; gap: 6px 10px; align-items: center; font-size: 13px; color: var(--muted); }
.disp-full .grid input[type=range] { width: 100%; }
.disp-full .grid output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.disp-full .tgls { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- controls component ---------- */
.ctl { display: grid; gap: 16px; }
.ctl-now { display: grid; gap: 6px; }
.ctl-title { font-weight: 700; font-size: 17px; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.ctl-title .code { color: var(--red); letter-spacing: .06em; }
.ctl-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctl-meta { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.ctl-meta .left { color: var(--red); font-weight: 700; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; flex: none; }
.ctl.offline .ctl-meta .dot { background: var(--amber); }
.ctl-progress { height: 10px; background: var(--card2); border-radius: 99px; overflow: hidden; cursor: pointer; }
.ctl-progress > div { height: 100%; background: var(--red); width: 0; }
.ctl-transport { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn-ic { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; padding: 0; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.btn-ic svg { width: 22px; height: 22px; fill: currentColor; }
.btn-ic.sm { width: 40px; height: 40px; }
.btn-ic.sm svg { width: 18px; height: 18px; }
.btn-ic:active { background: var(--card2); }
.btn-play { width: 86px; height: 86px; border-radius: 50%; border: 0; background: var(--red); color: #fff; display: grid; place-items: center; cursor: pointer; touch-action: manipulation; box-shadow: 0 6px 24px rgba(225,6,0,.35); }
.btn-play svg { width: 36px; height: 36px; fill: currentColor; }
.btn-play.on { background: #fff; color: var(--red); box-shadow: none; }
.ctl-row { display: flex; align-items: center; gap: 10px; }
.ctl-nudge { justify-content: center; }
.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.ctl-speed { display: grid; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.ctl-speed .lbl { flex: 1; }
.ctl-speed output { font: 700 26px/1 var(--font); color: var(--red); min-width: 2.2ch; text-align: center; font-variant-numeric: tabular-nums; }
.ctl-speed .wpm { font-size: 12px; color: var(--muted); min-width: 72px; text-align: right; }
input[type=range] { accent-color: var(--red); width: 100%; height: 28px; }
.ctl-h { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 8px 14px; cursor: pointer; }
.chips b { color: var(--red); margin-right: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-left: auto; }
.seg button { background: transparent; border: 0; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--red); color: #fff; }
.ctl-scripts summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; padding: 6px 0; }
.ctl-scripts input { width: 100%; margin: 8px 0; }
.ctl-scripts .list { display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.ctl-scripts .list button { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; cursor: pointer; }
.ctl-scripts .list button.on { border-color: var(--red); }
.ctl-scripts .code { color: var(--red); font-weight: 700; margin-right: 8px; }
.disp { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; margin-bottom: 8px; opacity: .55; }
.disp.online { opacity: 1; }
.disp .dot, .disp-full .dot { background: #555; }
.disp.online .dot, .disp-full.online .dot { background: var(--green); }
.disp-name { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.disp-ctl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.disp-ctl .val { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; color: var(--red); font-weight: 700; }
.tog { display: inline-flex; align-items: center; gap: 6px; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.tog svg { width: 16px; height: 16px; fill: currentColor; }
.tog.on { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- prompter surface ---------- */
.pr-stage { position: relative; overflow: hidden; background: #000; color: #fff; container-type: size; user-select: none; -webkit-user-select: none;
  --size: 7; --margin: 10; --lh: 1.35; --cue: 33; }
.pr-flip { position: absolute; inset: 0; }
.pr-scroll { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.pr-text { padding: 0 calc(var(--margin) * 1cqw); font-size: calc(var(--size) * 1cqw); line-height: var(--lh); font-weight: 600; padding-bottom: 100cqh; }
.pr-text p { margin: 0; overflow-wrap: break-word; }
.pr-text b { color: #fff; font-weight: 900; }
.pr-text u { text-decoration-thickness: .08em; text-underline-offset: .12em; }
.pr-text mark { background: var(--red); color: #fff; padding: 0 .12em; border-radius: .08em; }
.pr-text .dir { color: #7d8597; font-style: italic; font-weight: 500; font-size: .7em; }
.pr-nodirs .pr-text .dir { display: none; }
.pr-yellow .pr-text { color: #ffe14a; }
.pr-upper .pr-text { text-transform: uppercase; }
.pr-gap { height: calc(var(--size) * var(--lh) * .7cqw); }
.pr-marker { font-size: .38em; text-transform: uppercase; letter-spacing: .16em; color: var(--red); display: flex; align-items: center; gap: .6em; line-height: 1; padding: .9em 0 .5em; font-weight: 800; }
.pr-marker span { background: var(--red); color: #fff; border-radius: 4px; padding: .25em .5em; letter-spacing: 0; }
.pr-marker::after { content: ""; flex: 1; height: 2px; background: rgba(225,6,0,.5); }
.pr-nomarkers .pr-marker { visibility: hidden; }
.pr-pause { height: 0; }
.pr-lead { height: calc(var(--size) * var(--lh) * 2cqw); }
.pr-cue { position: absolute; left: 0; top: calc(var(--cue) * 1cqh); transform: translateY(-50%); width: calc(max(var(--margin) * .8, 1.8) * 1cqw); max-width: 6cqw; display: flex; justify-content: center; pointer-events: none; }
.pr-cue svg { width: 70%; fill: var(--red); filter: drop-shadow(0 0 6px rgba(225,6,0,.6)); }
.pr-cue::after { content: ""; position: absolute; left: 100%; width: calc(100cqw - 100%); top: 50%; height: 1px; background: rgba(225,6,0,.18); }
.pr-count { position: absolute; left: 50%; top: calc(var(--cue) * 1cqh); transform: translate(-50%, -50%); pointer-events: none; }
.pr-count span { display: grid; place-items: center; width: 22cqh; height: 22cqh; border-radius: 50%; background: rgba(225,6,0,.92); color: #fff; font: 800 12cqh/1 var(--font); box-shadow: 0 0 0 1.2cqh rgba(225,6,0,.25); }
.pr-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #555; font-size: 4cqw; text-transform: uppercase; letter-spacing: .12em; }

/* ---------- display page ---------- */
body.display { overflow: hidden; background: #000; }
body.display .pr-stage { position: fixed; inset: 0; }
.dsp-ui { position: fixed; top: 0; right: 0; left: 0; padding: 12px; display: flex; gap: 8px; justify-content: flex-end; align-items: center; transition: opacity .3s; z-index: 10; }
.dsp-ui.idle { opacity: 0; pointer-events: none; }
.dsp-ui .badge { margin-right: auto; background: rgba(0,0,0,.6); border: 1px solid var(--line); padding: 6px 12px; border-radius: 99px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; display: flex; align-items: center; gap: 8px; }
.dsp-ui .badge.off .dot { background: var(--amber); }
.dsp-panel { position: fixed; top: 64px; right: 12px; width: min(360px, calc(100vw - 24px)); max-height: calc(100vh - 80px); overflow: auto; z-index: 11; }
.join { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.join form { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(400px, 100%); display: grid; gap: 14px; }
.join img { height: 36px; justify-self: start; }
.join h1 { margin: 0; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.join .code-in { font: 700 28px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; text-align: center; }
.join .err { color: #ff6b66; min-height: 1.2em; margin: 0; font-size: 14px; }

/* ---------- remote page ---------- */
body.remote .rm { max-width: 520px; margin: 0 auto; padding: 14px 16px 40px; }
body.remote .top { padding: 12px 16px; }
.rm-preview { width: 100%; height: calc((min(100vw, 520px) - 32px) * 9 / 16); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.rm-hint { font-size: 11px; color: var(--muted); text-align: center; margin: 6px 0 14px; text-transform: uppercase; letter-spacing: .1em; }

@media (max-width: 900px) {
  .ed, .op { grid-template-columns: 1fr; height: auto; }
  .ed .body { min-height: 60vh; }
  .op-preview { height: calc((100vw - 34px) * 9 / 16); }
  .ed-main { border-right: 0; }
  .op-right { border-left: 0; border-top: 1px solid var(--line); }
  .top .section { display: none; }
}
.dsp-ui .btn { background: rgba(13,13,16,.85); }

.dsp-tip { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 12px; padding: 14px 16px; font-size: 14px; line-height: 1.5; z-index: 12; display: grid; gap: 10px; }
.dsp-tip .share { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.dsp-tip .btn { justify-self: end; }
body.display .dsp-ui { padding-top: max(12px, env(safe-area-inset-top)); }
