/* Layout: one centred card per step; the call is three equal tiles over a question board. */
:root {
  --bg: #f3f1fa;
  --surface: #ffffff;
  --ink: #23213a;
  --muted: #6b6886;
  --accent: #5b4bd6;
  --accent-ink: #ffffff;
  --go: #23a26d;
  --stop: #d64b5b;
  --warn: #e0a423;
  --line: #dcd8ee;
  --tile: #2b2846;
  --owl: #b98a5a;
  --owl-belly: #ead7bd;
  --owl-tuft: #8f6740;
  --owl-eye: #fffdf6;
  --owl-pupil: #23213a;
  --owl-beak: #f2a93b;
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17152a; --surface: #221f3a; --ink: #f1effa; --muted: #a6a2c4; --accent: #8b7dff; --accent-ink: #17152a;
    --line: #36325a; --tile: #2e2a4f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17152a; --surface: #221f3a; --ink: #f1effa; --muted: #a6a2c4; --accent: #8b7dff; --accent-ink: #17152a;
  --line: #36325a; --tile: #2e2a4f; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.45;
  padding: env(safe-area-inset-top, 0) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0)
    max(16px, env(safe-area-inset-left, 0px));
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#app { min-height: 100%; display: grid; place-items: center; padding-block: 24px; }

.card {
  width: min(460px, 100%); background: var(--surface); border-radius: var(--radius); padding: 28px;
  display: grid; gap: 16px; box-shadow: 0 8px 30px rgb(35 33 58 / 0.08);
}
h1 { margin: 0; font-size: 1.6rem; text-wrap: balance; }
.lead { margin: 0; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 0.9rem; }
.error { margin: 0; color: var(--stop); font-weight: 600; }

form { display: grid; gap: 12px; }
input {
  font: inherit; font-size: 1.15rem; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--bg); color: var(--ink); width: 100%;
}
.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 14px 20px;
  font-weight: 700; font-size: 1.05rem;
}
.primary:disabled { opacity: 0.45; cursor: default; }
.primary.big { font-size: 1.25rem; padding: 18px 24px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }

.who { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.who button {
  border: 2px solid var(--line); background: var(--bg); color: var(--ink); border-radius: var(--radius);
  padding: 28px 12px; font-size: 1.4rem; font-weight: 700;
}
.who button:hover { border-color: var(--accent); }

.eyebrow { margin: 0 0 4px; color: var(--accent); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.card h2 { margin: 0 0 10px; font-size: 1.1rem; }
.invite-head { display: grid; gap: 4px; }
.prep { background: var(--bg); border-radius: 14px; padding: 16px; display: grid; gap: 10px; }
.prep h2 { margin: 0; }
.prep-text p { margin: 0 0 8px; white-space: pre-line; overflow-wrap: anywhere; }
.prep-text p:last-child { margin-bottom: 0; }
.prep-text a { color: var(--accent); }
.prep-done { display: grid; gap: 6px; }
.ticks { display: flex; flex-wrap: wrap; gap: 8px; }
.ticks button { border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 16px; font-weight: 700; }
.ticks button[aria-pressed="true"] { border-color: var(--go); background: var(--go); color: #fff; }
.ticks button:disabled { cursor: default; opacity: 0.8; }
.confirm { display: grid; gap: 10px; padding: 16px; border-radius: 14px; border: 2px solid var(--accent); }
.confirm p { margin: 0; }
.preview { position: relative; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: var(--tile); }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; }
.meter { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
#meter-fill { height: 100%; width: 0; background: var(--go); transition: width 80ms linear; }

/* Call */
.call { width: min(1200px, 100%); display: grid; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; position: relative; }
.tile {
  margin: 0; position: relative; background: var(--tile); border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 4 / 3; outline: 4px solid transparent; transition: outline-color 120ms;
}
.tile.speaking { outline-color: var(--go); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.me video { transform: scaleX(-1); }
.tile figcaption {
  position: absolute; left: 10px; bottom: 10px; background: rgb(0 0 0 / 0.55); color: #fff; border-radius: 10px;
  padding: 4px 10px; font-weight: 700; display: flex; gap: 8px; align-items: center;
}
.tag { font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.8; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #d9d6f0; text-align: center; padding: 16px; }
.tile-status { position: absolute; top: 10px; left: 0; right: 0; text-align: center; margin: 0; color: #d9d6f0; font-size: 0.9rem; }

.timothy { display: grid; place-items: center; background: linear-gradient(180deg, #3b3570, var(--tile)); }
.owl { width: 62%; height: auto; transition: transform 200ms; }
.timothy[data-state="joining"] .owl { opacity: 0.45; }
.owl-body { fill: var(--owl); }
.owl-belly { fill: var(--owl-belly); }
.owl-tuft { fill: var(--owl-tuft); }
.owl-eye { fill: var(--owl-eye); }
.owl-pupil { fill: var(--owl-pupil); transition: cx 300ms, cy 300ms; }
.owl-beak, .owl-beak-lower { fill: var(--owl-beak); }
/* Timothy raises a wing before he interrupts (like a raised hand on a video call) */
.owl-wing { fill: var(--owl-tuft); transform-origin: 156px 118px; transform: rotate(60deg) scale(0.6); opacity: 0;
  transition: transform 250ms ease-out, opacity 150ms; }
.timothy.hand .owl-wing { transform: none; opacity: 1; }
.owl-beak-lower { transform-origin: 100px 120px; }

.board {
  background: var(--surface); border-radius: var(--radius); padding: 16px 20px; display: grid;
  grid-template-columns: 1fr auto; align-items: baseline; gap: 4px 16px;
}
.board-label { margin: 0; grid-column: 1 / -1; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.board-question { margin: 0; font-size: 1.35rem; font-weight: 700; text-wrap: balance; }
.board-clock { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-views { margin: 0; grid-column: 1 / -1; color: var(--ink); display: flex; gap: 6px 18px; flex-wrap: wrap; }
.board-views b { color: var(--accent); }

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hears { margin: 0 auto 0 0; color: var(--muted); }
.hears.ok { color: var(--go); font-weight: 700; }
.pill { border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 18px; font-weight: 700; }
.pill.on { background: var(--stop); border-color: var(--stop); color: #fff; }
.pill.danger { color: var(--stop); }
.pill.help { border-color: var(--warn); color: var(--ink); }
.notice { margin: 0; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 2px solid var(--line);
  font-weight: 700; }
.notice[data-level="info"] { border-color: var(--go); }
.notice[data-level="warn"] { border-color: var(--warn); }
.notice[data-level="urgent"] { border-color: var(--stop); background: var(--stop); color: #fff; font-size: 1.2rem; }

.overlay { position: fixed; inset: 0; background: rgb(23 21 42 / 0.6); display: grid; place-items: center; z-index: 20; }
.banner {
  position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 30;
}

@media (max-width: 760px) {
  /* Phone: Timothy and the friend stacked full width; your own picture sits in the friend's corner */
  .tiles { grid-template-columns: 1fr; gap: 10px; }
  .tile { aspect-ratio: 16 / 10; }
  .tile.me { position: absolute; right: 8px; bottom: 8px; width: 32%; aspect-ratio: 4 / 3; z-index: 5;
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.35); border-radius: 12px; }
  .tile.me figcaption { display: none; }
  .owl { width: auto; height: 82%; }
  .board { grid-template-columns: 1fr; }
  .hears { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
