:root { --bg:#0e1116; --panel:#171b22; --line:#2a303a; --text:#eef1f5; --muted:#9aa4b2; --accent:#4c9aff; --bad:#ff6b6b; }
* { box-sizing: border-box; }
[hidden] { display:none !important; } /* a hidden part stays hidden even when its own style sets display */
html, body { margin:0; background:var(--bg); color:var(--text); font:18px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
/* iPhone notch, home bar and rounded corners (the page asks for viewport-fit=cover) */
body { padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
h1 { margin:0 0 4px; font-size:32px; }
.muted { color:var(--muted); }
.note { min-height:1.5em; color:var(--bad); }
.card { max-width:460px; margin:8vh auto; padding:28px; background:var(--panel); border:1px solid var(--line); border-radius:14px; }
label { display:block; margin:18px 0 6px; color:var(--muted); font-size:16px; }
input, textarea, select { width:100%; min-height:44px; padding:12px 14px; font:inherit; color:var(--text); background:var(--bg); border:1px solid var(--line); border-radius:10px; }
input:focus, textarea:focus, select:focus { outline:2px solid var(--accent); }
button { min-height:44px; min-width:44px; padding:10px 18px; font:inherit; color:var(--text); background:#222934; border:1px solid var(--line); border-radius:10px; cursor:pointer; }
button:hover { border-color:var(--accent); }
button.primary { background:var(--accent); border-color:var(--accent); color:#06101f; font-weight:600; }
button.off { background:var(--bad); border-color:var(--bad); color:#190606; }
button:disabled { opacity:.5; cursor:default; }
.row { display:flex; gap:10px; margin-top:22px; flex-wrap:wrap; }
header { display:flex; align-items:center; flex-wrap:wrap; gap:6px 14px; padding:8px 16px; border-bottom:1px solid var(--line); }
header .title { white-space:nowrap; }
.headbtns { display:flex; flex-wrap:wrap; gap:8px; margin-left:auto; }
.headbtns button { padding:8px 14px; }
#panes { display:grid; grid-template-columns:minmax(0,2fr) minmax(320px,1fr); gap:14px; padding:14px; align-items:start; }
.pane { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:14px; min-width:0; }
.pane h2 { margin:0 0 10px; font-size:20px; }
.pane-error { color:var(--bad); }
/* Phone: one column. Video tiles stack full width, one above the other; the judge pane sits below them. */
@media (max-width: 800px) {
  #panes { grid-template-columns:1fr; padding:8px; gap:10px; }
  html, body { font-size:17px; }
  .pane { padding:10px; }
  .tiles { grid-template-columns:1fr; }
  .controls { flex-wrap:wrap; }
}

/* video plugin */
.tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); gap:10px; }
.tile { position:relative; background:#000; border-radius:12px; overflow:hidden; aspect-ratio:4/3; }
.tile video { width:100%; height:100%; object-fit:cover; background:#000; }
.tile .label { position:absolute; left:8px; bottom:8px; padding:3px 10px; border-radius:8px; background:rgba(0,0,0,.65); font-size:16px; }
.controls { display:flex; gap:10px; margin-top:12px; }
.vnote { color:var(--muted); font-size:16px; margin:8px 0 0; }

/* judge plugin */
.judge-form textarea { min-height:90px; resize:vertical; }
.judge-form .row { margin-top:10px; }
.judge-log { margin-top:14px; display:flex; flex-direction:column; gap:12px; max-height:60vh; overflow:auto; }
.judge-item { border-left:3px solid var(--accent); padding-left:12px; }
.judge-item.bad { border-color:var(--bad); }
.judge-item .q { color:var(--muted); font-size:16px; }
.judge-item .a { white-space:pre-wrap; overflow-wrap:anywhere; }
.judge-item a { color:var(--accent); }
button.danger { border-color:var(--bad); color:var(--bad); }
.tile.speaking { outline:3px solid #3ddc84; outline-offset:-3px; }

/* connection quality dot (LiveKit): excellent / good / poor / lost / unknown */
.tile .cq { position:absolute; right:10px; top:10px; width:14px; height:14px; border-radius:50%; border:2px solid rgba(0,0,0,.6); background:#6b7380; }
.tile .cq[data-q="excellent"] { background:#3ddc84; }
.tile .cq[data-q="good"] { background:#b8e04a; }
.tile .cq[data-q="poor"] { background:#ffb020; }
.tile .cq[data-q="lost"] { background:var(--bad); }

/* signaling reconnect strip (app.js) */
.netbanner { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:6px 12px; padding:6px 14px; background:#3a2a10; color:#ffd89b; border-bottom:1px solid #7a5a1e; font-size:16px; text-align:center; } /* in the page flow under the header: never covers it */
.netbanner[hidden] { display:none; }
.netbanner button { padding:4px 14px; margin:0; }

/* mic state badge on every tile, fix-it card, ?debug=1 device line, reload-loop card */
.tile .micbadge { position:absolute; left:8px; top:8px; max-width:calc(100% - 44px); padding:2px 10px; border-radius:8px; font-size:15px; background:rgba(0,0,0,.65); color:#d7ffe6; }
.tile .micbadge[data-mic="muted"] { color:var(--muted); }
.tile .micbadge[data-mic="starting"] { color:var(--muted); }
.tile .micbadge[data-mic="blocked"], .tile .micbadge[data-mic="silent"], .tile .micbadge[data-mic="nomic"] { background:var(--bad); color:#190606; font-weight:600; }
.miccard { margin:0 0 12px; padding:12px 14px; background:#2a1414; border:1px solid var(--bad); border-radius:12px; }
.miccard ol { margin:8px 0 12px; padding-left:22px; font-size:16px; }
.deviceline { position:fixed; left:0; right:0; bottom:0; z-index:60; margin:0; padding:4px 8px calc(4px + env(safe-area-inset-bottom)); background:rgba(0,0,0,.85); color:#9fe3b0; font:12px/1.35 ui-monospace, Menlo, monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
.loopcard { margin:0 0 18px; padding:14px; background:#2a2210; border:1px solid #7a5a1e; border-radius:12px; }
.loopcard p { margin:6px 0 12px; font-size:16px; color:#ffd89b; }

/* ---- finished-app parts: first-open help, spinner, waiting card, end screen, sheets, recordings, judge hints ---- */
.boot { margin:0; padding:14px 16px; background:#2a2210; color:#ffd89b; font-size:16px; }
.how { margin:14px 0 4px; padding-left:22px; color:var(--muted); font-size:16px; }
.how li { margin:4px 0; }
.linkline { margin:10px 0 0; color:var(--muted); font-size:15px; overflow-wrap:anywhere; }
.note strong { color:var(--bad); }
.spin { display:inline-block; width:16px; height:16px; vertical-align:-2px; border:2px solid var(--line); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.waiting { display:flex; gap:12px; align-items:flex-start; margin:10px 14px 0; padding:12px 14px; background:#14202e; border:1px solid #28456b; border-radius:12px; }
.waiting .spin { margin-top:6px; flex:none; }
.waiting p { margin:4px 0; }
.waiting .row { margin-top:8px; }
.stats { margin:14px 0 4px; padding-left:22px; }
.stats li { margin:4px 0; }
.err { color:var(--bad); }
summary { display:flex; align-items:center; min-height:44px; cursor:pointer; font-weight:600; }
.recsbox { margin-top:18px; border-top:1px solid var(--line); padding-top:6px; }
#endscreen .recsbox { margin-top:22px; }
.recordings h2 { margin:10px 0 6px; font-size:20px; }
.reclist { display:flex; flex-direction:column; gap:10px; margin:10px 0; }
.recitem { padding:10px 12px; background:var(--bg); border:1px solid var(--line); border-radius:12px; }
.recitem .recname { display:block; overflow-wrap:anywhere; font-size:16px; }
.recitem .recline { display:block; font-size:15px; }
.recitem .row { margin-top:10px; }
.recitem .recmsg { margin:6px 0 0; }
.recitem .recmsg:empty, .vnote:empty { display:none; }
.empty { margin:8px 0; color:var(--muted); font-size:16px; }
.offercard { margin:0 0 18px; padding:14px; background:#14202e; border:1px solid #28456b; border-radius:12px; }
.offercard p { margin:6px 0 10px; font-size:16px; color:var(--muted); }
.offercard .row { margin-top:8px; }
.sheet { position:fixed; inset:0; z-index:70; display:flex; align-items:flex-end; justify-content:center; background:rgba(0,0,0,.6); }
.sheet[hidden] { display:none; }
.sheetbox { width:100%; max-width:520px; max-height:92vh; overflow:auto; padding:18px 18px calc(18px + env(safe-area-inset-bottom)); background:var(--panel); border:1px solid var(--line); border-radius:16px 16px 0 0; }
.sheetbox h2 { margin:0 0 8px; font-size:22px; }
.sheetbox > div > button { display:block; width:100%; margin-top:12px; }
.sheetbox .recitem button { width:auto; margin-top:0; }
.sheetbox .vnote { margin:4px 2px 0; }
@media (min-width: 640px) { .sheet { align-items:center; } .sheetbox { border-radius:16px; } }
/* judge pane */
.judge-hint { margin:10px 0 0; padding:10px 12px; background:var(--bg); border:1px dashed var(--line); border-radius:12px; }
.judge-hint p { margin:0 0 6px; color:var(--muted); font-size:16px; }
.judge-hint button { display:block; width:100%; margin-top:8px; text-align:left; }
.judge-item.working { border-color:var(--muted); color:var(--muted); }
.judge-item .retry { margin-top:6px; }
.judge-tools { display:flex; justify-content:flex-end; margin-top:10px; }
