/* Shared styles for the phone pages (join, audience, presenter). Mobile-first, system fonts, no external requests. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font: 400 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ light pages */
body.light { --bg: #f6f4ef; --card: #ffffff; --ink: #15171b; --soft: #5b6270; --line: #e2ded5; --accent: #2f5bea; --ok: #15803d; --warn: #b45309;
  background: var(--bg); color: var(--ink); }
.shell { max-width: 560px; margin: 0 auto; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); min-height: 100dvh; display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--soft); }
.brand { font-weight: 700; color: var(--ink); letter-spacing: .01em; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3ad; }
.is-open .dot { background: #22c55e; }
.is-connecting .dot { background: #eab308; }
.is-offline .dot, .is-closed .dot { background: #f97316; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.stage { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.center { text-align: center; margin: auto 0; padding: 24px 8px; }
.big-title { font-size: 26px; line-height: 1.2; font-weight: 700; margin: .2em 0; }
.muted { color: var(--soft); }
.note { font-size: 14px; color: var(--soft); }
.foot { font-size: 12.5px; color: var(--soft); text-align: center; line-height: 1.4; }
.banner { border-radius: 14px; padding: 12px 14px; font-size: 15px; background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* join */
.join-form { display: grid; gap: 12px; }
.code-input { width: 100%; font: 800 34px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; text-align: center; text-transform: uppercase;
  padding: 16px 10px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.code-input:focus { outline: none; border-color: var(--accent); }
.primary { border: 0; border-radius: 16px; padding: 16px; font-weight: 700; font-size: 18px; background: var(--accent); color: #fff; cursor: pointer; }
.primary:disabled { opacity: .5; }

/* audience poll */
.prompt { font-size: 23px; line-height: 1.25; margin: 0 0 14px; }
.options { display: grid; gap: 10px; }
.opt { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; width: 100%;
  padding: 14px 18px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); text-align: left; font-size: 18px; font-weight: 600;
  cursor: pointer; transition: border-color .15s, transform .05s; touch-action: manipulation; }
.opt:active:not(:disabled) { transform: scale(.985); }
.opt:disabled { cursor: default; }
.opt-label, .opt-num { position: relative; z-index: 1; }
.opt-num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--soft); }
.opt-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--accent) 16%, transparent); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.opt.mine { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.opt.mine .opt-label::after { content: '  ✓ your answer'; font-size: 13px; font-weight: 700; color: var(--accent); }
.opt.pending { border-color: var(--accent); opacity: .8; }
.opt:disabled:not(.mine) { opacity: .72; }
.options:not(.with-results) .opt-num { display: none; }
.status-line { font-weight: 700; font-size: 16px; min-height: 1.4em; }
.status-line.ok { color: var(--ok); }
.results-note { text-align: center; padding: 16px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 7%, var(--card)); border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--line)); font-weight: 600; }

/* ------------------------------------------------------------- presenter */
body.dark { --bg: #0d0f13; --card: #171a21; --card2: #1f232c; --ink: #f2f4f7; --soft: #9aa3b2; --line: #2a2f3a; --accent: #4f7cff; --ok: #22c55e; --danger: #ef4444;
  background: var(--bg); color: var(--ink); overscroll-behavior: none; }
/* Column layout: the content area takes the free space, so the thumb zone stays at the bottom
   whether or not the banner is showing (a hidden banner would shift grid rows). */
.remote { height: 100dvh; display: flex; flex-direction: column; }
.remote > .r-main { flex: 1 1 auto; min-height: 0; }
.remote > .r-top, .remote > .r-banner, .remote > .thumbs { flex: none; }
.r-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 8px; font-size: 13.5px; color: var(--soft); }
.r-top .pill { background: var(--card); border-color: var(--line); color: var(--ink); }
.r-code { font: 700 13.5px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.r-banner { margin: 0 12px 6px; border-radius: 12px; padding: 10px 12px; font-size: 14px; background: #3b1d0a; color: #fed7aa; border: 1px solid #7c2d12; }
.r-banner button { margin-left: 8px; }
.r-main { overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.r-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.slide-no { font: 800 42px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.slide-no small { font-size: 20px; color: var(--soft); font-weight: 600; }
.slide-title { margin-top: 6px; font-size: 17px; font-weight: 600; line-height: 1.3; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.timer-face { font: 800 46px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; flex: 1; }
.timer-face.done { color: var(--danger); }
.timer-face.paused { color: var(--soft); }
.btn { border: 1px solid var(--line); background: var(--card2); color: var(--ink); border-radius: 12px; padding: 12px 14px; font-weight: 700; font-size: 15px;
  min-height: 48px; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; }
.btn.primary-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.on { background: #14351f; border-color: var(--ok); color: #bbf7d0; }
.btn.danger { border-color: #7f1d1d; color: #fecaca; }
.actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.ix-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.chip { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--soft); border: 1px solid var(--line); }
.chip.open { background: #14351f; color: #86efac; border-color: #166534; }
.chip.revealed { background: #1e2a4d; color: #c7d2fe; border-color: #3730a3; }
.ix-prompt { font-weight: 700; font-size: 16px; line-height: 1.3; margin: 2px 0 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 4px; font-size: 13.5px; font-weight: 700; color: var(--soft); min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg.locked { opacity: .6; }
.seg-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--soft); margin: 10px 0 5px; }
.seg-label .icon { width: 16px; height: 16px; opacity: .8; }
.ix-stats { font-size: 14px; color: var(--soft); margin: 10px 0; }
.ix-stats b { color: var(--ink); font-size: 18px; }
.ix-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preview { margin-top: 12px; font-size: 14px; }
.preview-label { font-size: 12px; color: var(--soft); margin-top: 6px; }
.other-open { font-size: 13.5px; color: #fde68a; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* The always-there controls. A line, a lighter surface and a shadow above it say
   this is a fixed dock, not the end of the list — so the scrolling above it reads
   as scrolling rather than as the whole remote. */
.thumbs { display: grid; grid-template-columns: 2fr 3fr; grid-template-rows: auto 1fr; gap: 10px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); height: 34vh; min-height: 150px; max-height: 300px;
  background: var(--card); border-top: 1px solid color-mix(in srgb, var(--line) 80%, var(--ink));
  box-shadow: 0 -10px 24px rgba(0, 0, 0, .38); z-index: 2; }
.thumbs .btn { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 22px; border-radius: 20px; height: 100%; }
.thumbs .btn .icon { width: 28px; height: 28px; }
.thumbs .next { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 26px; }
/* The scrolling area doesn't look scrollable on a phone, so fade the last few
   pixels and show a chevron while there is more below. Tapping it scrolls on. */
.r-main-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.r-main-wrap > .r-main { flex: 1 1 auto; }
.more-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 56px; display: grid; place-items: end center;
  padding-bottom: 4px; pointer-events: auto; cursor: pointer;
  background: linear-gradient(to top, var(--bg) 22%, transparent); }
.more-fade[hidden] { display: none; }
.more-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line); color: var(--soft);
  font: 700 12px/1 system-ui, sans-serif; animation: nudge 1.8s ease-in-out infinite; }
.more-pill .icon { width: 15px; height: 15px; }
@keyframes nudge { 50% { transform: translateY(3px); } }

/* Our own scroll position bar: a phone hides the real one until you touch it. */
.rail { position: absolute; top: 4px; right: 3px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--line); }
.rail[hidden] { display: none; }
.rail-thumb { position: absolute; left: 0; width: 3px; border-radius: 2px; background: var(--soft); opacity: .55; }

/* Timers: green to start, amber while running, and icon-only reset. */
.timer-go { display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 104px;
  background: #14351f; border-color: #166534; color: #bbf7d0; }
.timer-go.running { background: #3a2b0c; border-color: #a16207; color: #fde68a; }
.timer-go .icon { width: 18px; height: 18px; }
.timer-reset { display: grid; place-items: center; width: 52px; padding: 0; }
.timer-reset .icon { width: 19px; height: 19px; }
/* − 5:00 + Start ↺ on one line, with the clock taking the slack. */
/* minmax(0,1fr) on the clock: it gives way rather than pushing the reset off-screen. */
.timer-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px; }
.timer-row .timer-face { font-size: clamp(26px, 9vw, 40px); text-align: center; }
.timer-step { display: grid; place-items: center; width: 40px; min-width: 40px; padding: 0; }
.timer-step .icon { width: 19px; height: 19px; }
.timer-row .timer-go { min-width: 0; gap: 6px; padding: 11px 12px; }
.timer-row .timer-reset { width: 44px; }
/* Common lengths, thin enough not to compete with the clock. */
.timer-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 9px; }
.preset { min-height: 34px; padding: 7px 4px; font-size: 13px; border-radius: 10px; color: var(--soft); }

/* A choice of colours shows the colours themselves, in small square targets. */
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px 5px 6px; border-radius: 10px;
  background: var(--card2); border: 1px solid var(--line); color: var(--soft); font: 700 12px/1 system-ui, sans-serif;
  cursor: pointer; touch-action: manipulation; }
.swatch-dot { width: 16px; height: 16px; border-radius: 5px; border: 1px solid rgba(255,255,255,.22); }
.swatches button.picked { border-color: var(--ink); color: var(--ink); background: var(--card); }
.swatches button:disabled { opacity: .45; }
/* A compact field shares the tile row: one tile beside it, two columns for itself. */
.ctl-field.compact { gap: 5px; align-content: start; grid-column: span 2; }
.ctl-clear { display: grid; place-items: center; width: 46px; min-width: 46px; padding: 0; color: var(--soft); }
.ctl-clear .icon { width: 17px; height: 17px; }

/* ---------------------------------------------------------- icon tiles
   Square, tinted by purpose: mid-talk you find a control by its shape and
   colour, and read the label only to confirm. */
.icon { width: 24px; height: 24px; flex: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  aspect-ratio: 1 / .82; padding: 10px 6px; border-radius: 16px; cursor: pointer; touch-action: manipulation;
  font: 700 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-align: center;
  color: var(--ink); background: color-mix(in srgb, var(--tone) 10%, var(--card2));
  border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--line)); }
.tile .icon { color: var(--tone); width: 26px; height: 26px; }
.tile-label { overflow-wrap: anywhere; }
.tile:active:not(:disabled) { transform: scale(.97); }
.tile:disabled { opacity: .4; }
/* On: the tile fills with its own colour, so "live" reads across the room. */
.tile.on { background: color-mix(in srgb, var(--tone) 78%, #000); border-color: var(--tone); color: #fff; }
.tile.on .icon { color: #fff; }

/* A toggle says which state it is in three ways: the switch icon's position,
   the fill, and the word — so it survives glare, colour blindness and a glance. */
.tile-state { position: absolute; top: 7px; right: 7px; font: 800 9.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em; padding: 3px 5px; border-radius: 6px; background: var(--card); color: var(--soft);
  border: 1px solid var(--line); }
.tile { position: relative; }
.tile.on .tile-state { background: #fff; color: color-mix(in srgb, var(--tone) 70%, #000); border-color: #fff; }
.tile[data-tone="toggle"]:not(.on) { border-style: dashed; }

/* One hue per purpose. Muted enough for a dark room, distinct at a glance. */
.tile { --tone: var(--accent); }
[data-tone="present"] { --tone: #6366f1; }
[data-tone="jump"] { --tone: #a855f7; }
[data-tone="join"] { --tone: #14b8a6; }
[data-tone="blank"] { --tone: #f59e0b; }
[data-tone="button"] { --tone: #38bdf8; }
[data-tone="toggle"] { --tone: #22c55e; }
[data-tone="momentary"] { --tone: #ec4899; }

/* Controls a deck declares: one row per kind, grouped under optional headings. */
/* A group folds away, so a deck with many controls isn't a wall of text. */
.ctl-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.group { border: 1px solid var(--line); border-radius: 14px; background: var(--card2); overflow: hidden; }
.group + .group, .group + .ctl-body, .ctl-body + .group { margin-top: 10px; }
.group summary { display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; list-style: none;
  font: 800 12.5px/1 system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); }
.group summary::-webkit-details-marker { display: none; }
.group summary::before { content: '›'; font-size: 17px; line-height: 1; transition: transform .15s; color: var(--soft); }
.group[open] summary::before { transform: rotate(90deg); }
.group-name { flex: 1; }
.group-count { font-size: 11.5px; padding: 2px 7px; border-radius: 999px; background: var(--card); color: var(--soft); }
/* minmax(0,1fr): a row with fixed buttons must shrink its field, not the card. */
.ctl-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 0 10px 10px; }
.ctl-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.ctl-field .row { min-width: 0; }
.ctl-field .seg-label { margin: 0; }
.ctl-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.num-label { flex: 1; }
.num-value { font: 800 20px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.ctl-field .btn { min-width: 56px; }
.slider { width: 100%; accent-color: var(--accent); height: 34px; }
.ctl-input { flex: 1; min-width: 0; font: 500 16px system-ui, sans-serif; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card2); color: var(--ink); }
.ctl-input:focus { outline: none; border-color: var(--accent); }
.readout-value { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }

/* End session: small, top-right of the slide line. Deliberately a modest target,
   because it is irreversible — the two confirmations do the rest. */
.slide-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.end-mini { display: inline-flex; align-items: center; gap: 5px; flex: none; align-self: flex-start;
  padding: 6px 10px; border-radius: 10px; font: 700 12px/1 system-ui, sans-serif;
  background: #dc2626; border: 1px solid #dc2626; color: #fff; cursor: pointer; touch-action: manipulation; }
.end-mini .icon { width: 14px; height: 14px; }
.end-mini:active { background: #991b1b; border-color: #991b1b; }
.end-mini:disabled { opacity: .4; }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.danger:disabled { opacity: .45; }
.end-step { display: grid; gap: 12px; }
.end-step p { margin: 0; font-size: 15px; line-height: 1.4; color: var(--ink); }
.sheet .chip { background: #3f1d1d; color: #fca5a5; border-color: #7f1d1d; }

/* Unlock screen on the phone (a claim link from the deck's QR). */
.unlock-screen { max-width: 420px; margin: 0 auto; padding-top: 12vh; }
.unlock-screen h1 { margin-bottom: .2em; }
.unlock-screen .join-form { margin-top: 20px; }
.code-input.pw { font: 600 22px/1.2 system-ui, -apple-system, sans-serif; letter-spacing: normal; text-transform: none;
  background: var(--card); color: var(--ink); border-color: var(--line); }
.unlock-screen .status-line { color: #fca5a5; font-size: 15px; }
.unlock-screen .foot { margin-top: 18px; }

/* The deck's own name, tinted to match its first slide. Wraps rather than truncating. */
.deck-title { margin: 0 12px 6px; padding: 9px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line);
  font-size: 15px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.timer-face.clock { font-size: 38px; }
.timer-face.clock.paused { color: var(--soft); }

/* Jump to slide: full-screen sheet of slide numbers */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(4, 6, 10, .72); display: flex; align-items: flex-end; }
.modal[hidden] { display: none; }
.sheet { width: 100%; max-height: 82vh; display: flex; flex-direction: column; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 17px; }
.slide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.slide-cell { min-height: 58px; font-size: 18px; font-variant-numeric: tabular-nums; }
.slide-cell.current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Rows above Prev/Next: blank screen, and scroll (pages without slide controls). */
.thumbs.with-scroll { grid-template-rows: auto auto 1fr; height: 42vh; max-height: 370px; }
.blank-btn { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 52px; font-size: 16px; border-radius: 14px; }
.blank-btn .icon { color: var(--tone); }
.blank-btn.on { background: color-mix(in srgb, var(--tone) 22%, var(--card)); border-color: var(--tone); color: #fde68a; }
.blank-btn.on .icon { color: #fde68a; }
.scroll-row { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: relative; padding-bottom: 8px; }
.thumbs .scroll-btn { height: 64px; font-size: 17px; border-radius: 16px; }
.thumbs .scroll-btn .icon { width: 22px; height: 22px; }
.scroll-bar { position: absolute; left: 4px; right: 4px; bottom: 0; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.scroll-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--soft); }
.empty-state h1 { color: var(--ink); font-size: 22px; }
.toast-host { position: fixed; left: 50%; bottom: calc(30vh + 8px); transform: translateX(-50%); display: grid; gap: 6px; z-index: 10; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #000c; color: #fff; padding: 9px 14px; border-radius: 12px; font-size: 14px; text-align: center; }
