:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #222631;
  --line: #2e3340;
  --text: #eef0f4;
  --muted: #9aa1b1;
  --accent: #0a84ff;
  --danger: #ff453a;
  --live: #ff3b30;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; touch-action: manipulation;
}
button:hover { border-color: #46506a; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); }
button.small { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: .45; cursor: not-allowed; }
input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.screen { min-height: 100%; }
#home, #consent { display: grid; place-items: center; padding: 16px; }
.card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.card h1 { margin: 0; font-size: 24px; }
.card h2 { margin: 0; font-size: 18px; }
.card p { margin: 0; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin-top: -6px !important; }
.error { color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

/* Session layout */
#session { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 7px; border-radius: 6px; background: var(--panel-2); }
.badge.presenter { background: var(--live); color: #fff; }
.code { color: var(--muted); font-size: 13px; }
.code b { color: var(--text); letter-spacing: .08em; }
.peers { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.peer { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 8px;
  border-radius: 999px; background: var(--panel-2); white-space: nowrap; }
.peer .dot { width: 7px; height: 7px; border-radius: 50%; background: #666; }
.peer .dot.connected { background: #32d74b; }
.peer .dot.connecting { background: #ffd60a; }
.peer .dot.failed { background: var(--danger); }

.banner { background: var(--live); color: #fff; font-size: 13px; font-weight: 600;
  padding: 6px 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.banner button { background: rgba(0,0,0,.25); border-color: transparent; color: #fff; padding: 4px 10px; }

.stage { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage canvas { position: absolute; touch-action: none; cursor: crosshair; }
.status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.6); padding: 10px 16px; border-radius: 10px; color: var(--muted);
  text-align: center; max-width: 80%; pointer-events: none; }
.unmute { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--accent); color: #fff; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.flash.on { opacity: .6; transition: none; }

.gallery { display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--panel); border-top: 1px solid var(--line); }
.shots { flex: 1; display: flex; gap: 6px; overflow-x: auto; }
.shots a { flex: none; display: block; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.shots img { display: block; height: 48px; }

.toolbar {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.toolbar .group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.toolbar button { display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 10px; min-width: 52px; font-size: 18px; line-height: 1; }
.toolbar button span { font-size: 11px; color: var(--muted); }
.toolbar button.active { border-color: var(--accent); background: #12305a; }
.toolbar button.on span { color: #32d74b; }
.swatches { display: flex; gap: 4px; padding: 0 4px; }
.swatch { width: 28px; height: 28px; min-width: 0 !important; padding: 0 !important; border-radius: 50%;
  background: var(--c); border: 2px solid transparent; }
.swatch.active { border-color: #fff; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 10; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 20;
  background: var(--panel-2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; max-width: 90%; }

@media (max-width: 560px) {
  .toolbar button { min-width: 44px; padding: 6px 7px; }
  .code { display: none; }
}
