:root {
  --bg: #f7f3ea; --card: #fffdf8; --ink: #1d1a16; --muted: #5a5248; --line: #e0d6c3;
  --go: #0f6a3b; --go-ink: #ffffff; --stop: #a3261d; --stop-ink: #ffffff; --soft: #ece4d3;
  --accent: #8a3b12; --stage: #0e1116;
  /* Self-hosted Tiro/Mukta first; then Devanagari fonts phones already have (Android: Noto, iPhone: Kohinoor),
     so the page is readable before the web fonts arrive or if they never do. */
  --serif: 'Tiro Devanagari Marathi', 'Noto Serif Devanagari', 'Kohinoor Devanagari', 'Devanagari Sangam MN', 'Nirmala UI', 'Mangal', serif;
  --sans: 'Mukta', 'Noto Sans Devanagari', 'Kohinoor Devanagari', 'Devanagari Sangam MN', 'Nirmala UI', 'Mangal', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 21px/1.65 var(--serif); font-synthesis: none; -webkit-text-size-adjust: 100%; }
main { max-width: 560px; margin: 0 auto; padding: 22px 16px 40px; }
.org { text-align: center; padding: 6px 8px 18px; }
.org-name { font-size: 28px; line-height: 1.35; margin: 0; color: var(--accent); }
.org-event { font-size: 22px; margin: 2px 0 0; }
.org-mode { display: inline-block; font: 500 16px/1.4 var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; margin: 10px 0 0; }
section { display: none; }
body[data-state="loading"] #s-loading, body[data-state="ready"] #s-ready, body[data-state="useedge"] #s-useedge,
body[data-state="joining"] #s-joining, body[data-state="lobby"] #s-lobby,
body[data-state="ended"] #s-ended, body[data-state="refused"] #s-refused, body[data-state="invalid"] #s-invalid,
body[data-state="nomic"] #s-nomic, body[data-state="nocam"] #s-nocam, body[data-state="error"] #s-error, body[data-state="live"] #s-live { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 22px; }
h1 { font-size: 30px; font-weight: 400; line-height: 1.3; margin: 0 0 6px; }
.flat { font: 500 22px/1.4 var(--sans); color: var(--muted); margin: 0 0 22px; }
p { margin: 0 0 14px; }
.big { display: block; width: 100%; min-height: 76px; border: 0; border-radius: 14px; font: 700 26px/1.3 var(--sans); cursor: pointer; }
.go { background: var(--go); color: var(--go-ink); }
a.big { line-height: 76px; text-align: center; text-decoration: none; }
.note { font-size: 18px; color: var(--muted); margin-top: 18px; }
.help { display: block; margin-top: 18px; font: 500 20px/1.4 var(--sans); color: var(--ink); }
.spinner { width: 56px; height: 56px; border: 6px solid var(--soft); border-top-color: var(--go); border-radius: 50%; animation: spin 1s linear infinite; margin: 8px 0 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* In the meeting: video fills the screen, large controls along the bottom. Switch-side appears only on
   phones with both a front and a back camera. There is no camera on/off button. */
body[data-state="live"] { background: var(--stage); }
body[data-state="live"] main { max-width: none; padding: 0; height: 100%; }
body[data-state="live"] .org { display: none; }
#s-live { height: 100%; }
.live { position: relative; display: flex; flex-direction: column; height: 100%; }
#stage { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 6px; padding: 6px; grid-template-columns: 1fr 1fr; align-content: start; }
/* One tile, or a spotlight/share with nobody else: fill the stage. */
#stage[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; align-content: stretch; }
/* Explicit heights, not aspect-ratio: with overflow hidden, grid rows shrank below the aspect ratio and tiles overlapped. */
.tile { position: relative; background: #1c222c; border-radius: 12px; overflow: hidden; height: 62vw; max-height: 46vh; border: 3px solid transparent; transition: border-color .2s; }
#stage[data-count="1"] .tile { height: 100%; max-height: none; }
.tile.spot, .tile.share { grid-column: 1 / -1; height: 56vh; max-height: none; }
/* Landscape video (a hall camera or laptop): full width, 16:9, shown whole rather than cropped. */
.tile.wide { grid-column: 1 / -1; height: 56vw; max-height: 52vh; }
.tile.wide .vid, .tile.spot .vid, .tile.share .vid { background: #000; }
#stage[data-count="1"] .tile.spot, #stage[data-count="1"] .tile.share { height: 100%; }
.tile.spot { border-color: #e0b64a; }
.tile.speaking { border-color: #37c871; }
.tile .vid, .tile .vid > div, .tile video { position: absolute; inset: 0; width: 100%; height: 100%; }
.face { position: absolute; inset: 0; display: grid; place-items: center; }
.face b { display: grid; place-items: center; width: 38%; max-width: 110px; aspect-ratio: 1; border-radius: 50%; background: #3a4558; color: #fff; font: 700 clamp(28px, 9vw, 56px)/1 var(--sans); }
.tile.has-video .face { display: none; }
.tile .label { position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 1; background: rgba(0,0,0,.6); color: #fff; font: 500 15px/1.35 var(--sans); padding: 2px 8px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: fit-content; max-width: calc(100% - 12px); }
.waiting { color: #cfd6e0; display: grid; place-items: center; text-align: center; padding: 24px; font-size: 22px; grid-column: 1 / -1; min-height: 50vh; }
#self { position: absolute; right: 12px; top: 12px; width: 26vw; max-width: 140px; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; background: #222; border: 2px solid #fff; }
#self[hidden] { display: none; }
#self-video, #self-video > div, #self-video video { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Switching camera lives on your own picture: tap it to flip. */
#self-flip { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); color: #fff; font: 700 13px/1.5 var(--sans); text-align: center; padding: 3px 2px; }
#self-flip[hidden] { display: none; }
#notice { position: absolute; left: 12px; right: 12px; top: 12px; z-index: 2; background: #fff7e0; color: var(--ink); border: 2px solid #e0b64a; border-radius: 12px; padding: 12px 14px; font: 500 19px/1.45 var(--sans); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
#notice[hidden] { display: none; }
.who { color: #cfd6e0; font: 500 16px/1.4 var(--sans); padding: 6px 12px 0; }
.controls { display: grid; grid-template-columns: repeat(var(--buttons, 3), 1fr); gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: #151a22; }
.controls button { min-height: 84px; border: 0; border-radius: 14px; font: 700 20px/1.2 var(--sans); cursor: pointer; }
.controls .off { background: #3a4150; color: #fff; }
.controls .on { background: var(--go); color: #fff; }
.controls .leave { background: var(--stop); color: var(--stop-ink); }
.controls button:disabled { opacity: .5; }

/* ---------- registration page ---------- */
.field { display: block; margin: 0 0 18px; }
.field span { display: block; font: 500 20px/1.4 var(--sans); margin: 0 0 6px; }
.field input { width: 100%; font: 500 26px/1.3 var(--sans); padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--go); }
.field.bad input { border-color: var(--stop); }
.field .err { display: none; color: var(--stop); font: 500 17px/1.4 var(--sans); margin-top: 4px; }
.field.bad .err { display: block; }
.quiet { display: block; width: 100%; margin-top: 12px; min-height: 60px; border: 2px solid var(--line); border-radius: 14px; background: transparent; color: var(--ink); font: 500 21px/1.3 var(--sans); cursor: pointer; }
.preview { position: relative; width: 100%; aspect-ratio: 3/4; max-height: 52vh; background: #111; border-radius: 14px; overflow: hidden; margin: 0 0 14px; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.meter { height: 18px; border-radius: 9px; background: var(--soft); overflow: hidden; margin: 6px 0 18px; }
.meter i { display: block; height: 100%; width: 0; background: var(--go); transition: width .08s linear; }
.summary { font: 500 20px/1.6 var(--sans); background: var(--soft); border-radius: 12px; padding: 12px 16px; margin: 14px 0; }
.code { font: 700 44px/1.1 var(--sans); letter-spacing: 6px; color: var(--accent); margin: 6px 0 14px; }
.done { color: var(--go); }
.nomatch { color: var(--stop); font: 500 18px/1.5 var(--sans); margin: 0 0 16px; }
