/* 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: repeat(auto-fill, minmax(140px, 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 { font-size: 12.5px; color: var(--soft); margin: 10px 0 5px; }
.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; }
.thumbs { display: grid; grid-template-columns: 2fr 3fr; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); height: 28vh; min-height: 150px; max-height: 240px;
  background: linear-gradient(to top, var(--bg) 70%, transparent); }
.thumbs .btn { font-size: 22px; border-radius: 20px; height: 100%; }
.thumbs .next { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 26px; }
/* Controls a deck declares: one row per kind, grouped under optional headings. */
.actions { grid-template-columns: 1fr; }
.ctl-group { grid-column: 1 / -1; font-size: 12.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); margin: 8px 0 2px; }
.ctl-field { display: grid; gap: 6px; }
.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; }

/* 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; }

/* Jump to a slide */
.jump summary { font-weight: 700; font-size: 15px; cursor: pointer; list-style: none; }
.jump summary::-webkit-details-marker { display: none; }
.jump summary::after { content: ' ▾'; color: var(--soft); }
.jump[open] summary::after { content: ' ▴'; }
.slide-list { display: grid; gap: 6px; margin-top: 10px; max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.slide-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; text-align: left; font-weight: 600;
  font-size: 15px; min-height: 52px; padding: 10px 12px; }
.slide-row-no { color: var(--soft); font-variant-numeric: tabular-nums; }
.slide-row-title { overflow-wrap: anywhere; }
.slide-row.current { border-color: var(--accent); color: #fff; }

/* Rows above Prev/Next: blank screen, and scroll (pages without slide controls). */
.thumbs { grid-template-rows: auto 1fr; height: 34vh; max-height: 300px; }
.thumbs.with-scroll { grid-template-rows: auto auto 1fr; height: 42vh; max-height: 370px; }
.blank-btn { grid-column: 1 / -1; height: 52px; font-size: 16px; border-radius: 14px; }
.blank-btn.on { background: #3a2b0c; border-color: #a16207; 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; }
.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; }
