:root {
  --bg: #fff8f1; --card: #ffffff; --ink: #2b2140; --muted: #6f6787;
  --accent: #ff5d8f; --accent-ink: #fff; --line: #eadff0; --danger: #d63c3c;
  --rec: #e5383b; --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17131f; --card: #221c2e; --ink: #f2edf8; --muted: #a89fbd; --line: #362d47; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  min-height: 100vh;
}
h1, h2 { margin: 0 0 .25rem; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; }
.muted { color: var(--muted); margin: 0 0 1rem; }
.error { color: var(--danger) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.emoji { font-size: 2.5rem; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; }
.topbar nav { display: flex; align-items: center; gap: .75rem; }
.chip { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: .15rem .6rem; border-radius: 999px; }
.link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.link:hover { color: var(--ink); text-decoration: underline; }

.wrap { max-width: 960px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.center-page { min-height: 80vh; display: grid; place-items: center; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card.narrow { width: 100%; max-width: 380px; text-align: center; }

input[type=password], .initials-row input {
  width: 100%; font-size: 1.1rem; padding: .75rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.initials-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
.initials-row label.first { flex: 3; }
.initials-row label.first input { text-transform: none; font-size: 1.3rem; text-align: left; }
.initials-row label { flex: 1; font-size: .85rem; color: var(--muted); text-align: left; }
.initials-row input { text-align: center; text-transform: uppercase; font-size: 2rem; font-weight: 700; margin-top: .25rem; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  padding: .7rem 1.1rem; border-radius: 999px; cursor: pointer; min-height: 44px;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.record { background: var(--rec); border-color: var(--rec); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.wide { width: 100%; margin-top: 1rem; }

.stage {
  position: relative; background: #000; border-radius: 12px; overflow: hidden;
  aspect-ratio: 16 / 9; max-height: 70vh; display: grid; place-items: center;
}
@media (max-width: 600px) and (orientation: portrait) { .stage { aspect-ratio: 3 / 4; } }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage video.mirror { transform: scaleX(-1); }
.placeholder { color: #bbb; text-align: center; padding: 1rem; }
.rec-badge {
  position: absolute; top: .75rem; left: .75rem; background: rgba(0,0,0,.65); color: #fff;
  padding: .3rem .7rem; border-radius: 999px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: .4rem;
}
.rec-badge .dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: .75rem; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.status { min-height: 1.5em; margin: .75rem 0; }
.help-link { color: var(--accent); font-weight: 700; }

.controls, .saved, .confirm { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.saved { justify-content: space-between; }
.confirm p { width: 100%; margin: 0; font-weight: 600; }
.toggle { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.toggle input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.tile { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.tile.mine { border-color: var(--accent); }
.tile.is-hidden { border-style: dashed; }
.tile video { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; object-fit: contain; }
.tile figcaption { display: flex; justify-content: space-between; align-items: center; padding: .5rem .75rem; }
.tile figcaption .muted { margin: 0; font-size: .85rem; }
