:root {
  /* warm paper neutrals: coolors.co/palette/e7decd-efe8db-f4efe6-faf7f0-fbfaf8, buttons a step deeper so they stand out */
  --bg: #f4efe6; --surface: #fbfaf8; --surface-2: #faf7f0; --line: #e4dccc;
  --text: #3a3128; --muted: #857a6b; --accent: #d9cdb6; --accent-2: #efe8db; --on-accent: #3a3128; --accent-ink: #7d6b52;
  --danger: #b42318; --warn-bg: #fbecc8; --warn: #7a4a0e; --ok: #3f7d3a;
  --shadow: 0 10px 30px rgba(58, 49, 40, .1);
  color-scheme: light dark;
}
/* dark: the device's choice unless the home menu picked one (data-theme on <html>, set by js/i18n.js) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916; --surface: #25221e; --surface-2: #2d2a25; --line: #3e3a33;
    --text: #f4efe6; --muted: #b3aa9b; --accent: #e7decd; --accent-2: #3f3a31; --on-accent: #2a251f; --accent-ink: #e7decd;
    --danger: #f08a7e; --warn-bg: #3b2c12; --warn: #f3c969; --ok: #8fc98a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #1b1916; --surface: #25221e; --surface-2: #2d2a25; --line: #3e3a33;
  --text: #f4efe6; --muted: #b3aa9b; --accent: #e7decd; --accent-2: #3f3a31; --on-accent: #2a251f; --accent-ink: #e7decd;
  --danger: #f08a7e; --warn-bg: #3b2c12; --warn: #f3c969; --ok: #8fc98a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
/* no double-tap zoom (taps respond at once); pinch zoom still works */
html { touch-action: manipulation; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
body.busy { cursor: progress; }
body.busy .btn.primary { opacity: .6; pointer-events: none; }
body.nodb #createBtn, body.nodb #joinForm button { opacity: .5; pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
code { font-size: .9em; }

/* ---------- buttons and fields ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 16px; font-weight: 600; min-height: 44px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; border-radius: 10px; position: relative; }
.btn:active { transform: scale(.98); }
.field {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px;
}
.field:focus, .codein:focus, #text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.lbl { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.link { background: none; border: 0; color: var(--accent-ink); padding: 4px 0; font-weight: 600; }

/* ---------- home ---------- */
.home { max-width: 520px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }
.brand { display: flex; align-items: center; gap: 12px; margin: 8px 0 20px; }
.brand .logo { font-size: 30px; width: 52px; height: 52px; display: grid; place-items: center; background: var(--accent-2); border-radius: 16px; overflow: hidden; flex: none; border: 0; padding: 0; cursor: pointer; }
.brand .logo:active { transform: scale(.94); }
.brand h1 { font-size: 22px; }
.brand .tag { margin: 0; color: var(--muted); font-size: 14px; }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 14px 4px 6px; min-height: 44px; flex: none; }
.me .av { font-size: 22px; }
.me .burger { font-size: 18px; line-height: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 17px; margin-bottom: 10px; }
.card p { margin: 0 0 12px; }
.resume { border-color: var(--accent); }
.roomlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.roomrow { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.roomrow .txt, .merow .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.encnote { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.encnote p { margin: 4px 0 0; }
.roomrow .txt { align-items: flex-start; gap: 3px; }
.roomrow .txt b { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roomrow small, .merow small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roomrow .go { flex: none; color: var(--accent-ink); font-weight: 600; font-size: 14px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.pager .pg { color: var(--muted); font-size: 14px; }
.pager button:disabled { opacity: .4; }
.joinrow { display: flex; gap: 10px; }
.codein {
  flex: 1; min-width: 0; font: 600 24px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .25em; text-align: center;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 52px;
}
.codein::placeholder { font: 16px system-ui, sans-serif; letter-spacing: 0; }
.joinrow .btn { min-width: 88px; }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 12px; }
.features div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.features b { display: block; margin-bottom: 2px; }
.features span { font-size: 13px; color: var(--muted); }
.features .wide { grid-column: 1 / -1; }
.note { border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; font-size: 14px; }
.note.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- chat ---------- */
/* pinned to all four edges rather than a 100dvh height, which can come out short in an iPhone home-screen app */
.chat { position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; background: var(--bg); }
.bar {
  display: flex; align-items: center; gap: 4px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.icon { background: none; border: 0; min-width: 44px; height: 44px; border-radius: 12px; font-size: 22px; display: grid; place-items: center; position: relative; }
.icon:active { background: var(--surface-2); }
.people { display: flex; gap: 3px; font-size: 15px; padding: 0 8px; }
.bar .dot { position: absolute; top: 8px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
.ttl { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.ttl b { font-size: 16px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.codechip { border: 0; background: var(--accent-2); color: var(--accent-ink); font: 600 13px ui-monospace, Menlo, monospace; letter-spacing: .08em; border-radius: 999px; padding: 2px 10px; margin-top: 1px; }
.dmbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 14px; background: var(--accent-2); font-size: 13px; }
.list { flex: 1; overflow-y: auto; padding: 12px 12px 4px; overscroll-behavior: contain; }
.indm .list { background: color-mix(in srgb, var(--accent-2) 45%, var(--bg)); }
.empty { color: var(--muted); text-align: center; margin: 30px 20px; font-size: 14px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 12px; max-width: 86%; }
.msg.cont { margin-top: 3px; }
.msg.mine { margin-left: auto; align-items: flex-end; }
.who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0 4px 3px; }
.who .av { font-size: 18px; }
.who .nm { color: var(--text); font-weight: 600; }
.who time { font-size: 12px; }
.mine .who .av, .mine .who .nm { display: none; }
.bub {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 8px 13px;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; user-select: text; min-width: 0;
}
.mine .bub { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bub a { color: inherit; text-decoration: underline; }
/* a bubble and its ⋯ menu button, the button on the outer side */
.brow { display: flex; align-items: center; gap: 2px; max-width: 100%; }
.mine .brow { flex-direction: row-reverse; }
.more { flex: none; width: 30px; height: 30px; border: 0; background: none; color: var(--muted); border-radius: 50%; font-size: 18px; line-height: 1; padding: 0; cursor: pointer; }
.more:hover, .more:active { background: var(--surface-2); color: var(--text); }
.re { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.re:empty { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 1px 8px; font-size: 13px; min-height: 26px; }
.chip.on { border-color: var(--accent); background: var(--accent-2); }
.chip.big { font-size: 24px; padding: 4px 10px; min-height: 46px; min-width: 46px; }
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.composer.off { opacity: .5; pointer-events: none; }
#text {
  flex: 1; resize: none; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 9px 14px; min-height: 42px; max-height: 160px; line-height: 1.4;
}
.send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); font-size: 18px; }

/* ---------- sheets ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(40, 28, 22, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); animation: up .18s ease-out;
}
@media (min-width: 600px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { font-size: 18px; margin-bottom: 10px; }
.sheet p { margin: 0 0 10px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
@media (min-width: 600px) { .actions { flex-direction: row-reverse; flex-wrap: wrap; } .actions .btn { flex: 1; } }
/* a menu of many choices: two columns on a wide screen, in reading order, the destructive one across the bottom */
@media (min-width: 600px) { .actions.many { display: grid; grid-template-columns: 1fr 1fr; } .actions.many .btn.danger { grid-column: 1 / -1; } .sheet:has(.actions.many) { max-width: 600px; } }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 10px 0; }
.avbtn { font-size: 24px; aspect-ratio: 1; border: 2px solid transparent; background: var(--surface-2); border-radius: 12px; padding: 0; }
.avbtn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-2); }
.seg { display: flex; flex-direction: column; gap: 6px; }
.seg button { text-align: left; border: 2px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.seg button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-2); font-weight: 600; }
.share { text-align: center; }
.bigcode { font: 700 52px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .18em; margin: 4px 0 8px; color: var(--accent-ink); }
.linkrow { margin: 10px 0; }
.linkrow .field { font-size: 16px; text-align: center; } /* under 16px, iPhone zooms in when it gets focus */
.qr { width: 200px; height: 200px; margin: 6px auto 0; background: #fff; border-radius: 12px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.plist { list-style: none; margin: 0; padding: 0; }
ul.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.plist li.away { opacity: .55; }
ul.plist .av { font-size: 26px; }
ul.plist .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
ul.plist .nm b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
ul.plist small { color: var(--muted); }
.badge { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; font: 600 11px/18px system-ui; min-width: 18px; height: 18px; border-radius: 9px; font-style: normal; }
.quote { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 8px; white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.reactrow { display: flex; justify-content: space-between; gap: 6px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(64px + env(safe-area-inset-top)); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: 100%; transition: opacity .3s, transform .3s; }
.toast.out { opacity: 0; transform: translateY(-6px); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); } }

/* ---------- emoji / GIF ---------- */
.tool { flex: none; width: 40px; height: 42px; border: 0; background: none; border-radius: 12px; font-size: 22px; padding: 0; }
.tool.giftool { font: 700 12px/1 system-ui, sans-serif; letter-spacing: .02em; }
.tool[aria-pressed="true"] { background: var(--accent-2); color: var(--accent-ink); }
.composer .tool + .tool { margin-left: -6px; }
.picker { background: var(--surface); border-top: 1px solid var(--line); height: min(300px, 42dvh); display: flex; flex-direction: column; padding: 8px 10px 0; }
.cats { display: flex; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.cats button { border: 0; background: none; font-size: 20px; width: 40px; height: 34px; border-radius: 10px; }
.cats button[aria-selected="true"] { background: var(--accent-2); }
.emojigrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; padding: 6px 0; }
.emo { border: 0; background: none; font-size: 26px; height: 42px; border-radius: 10px; padding: 0; }
.emo:active, .emo:hover { background: var(--surface-2); }
.gifq-in { min-height: 40px; }
.gifgrid { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; display: flex; align-items: flex-start; gap: 6px; padding: 8px 0; }
.gifgrid p { flex: 1; text-align: center; }
.gifcol { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.gifpick { display: block; width: 100%; border: 0; padding: 0; margin: 0; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.gifpick img { display: block; width: 100%; height: auto; }
.gifby { font-size: 11px; color: var(--muted); text-align: right; padding: 2px 2px 6px; }
.bub.gifbub { padding: 0; background: none; border: 0; overflow: hidden; border-radius: 14px; }
.mine .bub.gifbub { background: none; }
.bub.gifbub img { background: var(--surface-2); display: block; max-width: min(240px, 62vw); height: auto; border-radius: 14px; }
.quote.gifq img { display: block; max-width: 160px; height: auto; border-radius: 10px; }

/* ---------- saved records ---------- */
.reclist { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rec { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.rec small { color: var(--muted); }
.hmenu h3 { font-size: 15px; margin: 18px 0 8px; }
.hmenu .reclist { max-height: 40dvh; overflow-y: auto; }
.merow { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.merow .av { font-size: 28px; }
.merow .chev { color: var(--muted); font-size: 20px; }
.ttl small { font-size: 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { flex: none; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.tab[aria-selected="true"] { border-color: var(--accent); background: var(--accent-2); color: var(--accent-ink); font-weight: 600; }
.bub.ro { cursor: default; }
.rofoot { margin: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); text-align: center; font-size: 13px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--line); }

/* pinned announcements: one line until opened */
.pins { background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px; }
.pins .pinhead { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; color: inherit; font: inherit; padding: 8px 14px; text-align: left; cursor: pointer; }
.pins .pinhead .one { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pins .pinhead .n { color: var(--muted); font-size: 12px; flex: none; }
.pins .pinhead .chev { color: var(--muted); flex: none; transition: transform .15s; }
.pins.open .pinhead .chev { transform: rotate(180deg); }
.pins ul { list-style: none; margin: 0; padding: 0 14px 8px; display: grid; gap: 6px; max-height: 40dvh; overflow-y: auto; }
.pins li { display: flex; align-items: flex-start; gap: 8px; background: var(--accent-2); border-radius: 10px; padding: 7px 10px; }
.pins li .go { flex: 1; min-width: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; padding: 0; white-space: pre-wrap; word-break: break-word; cursor: pointer; }
.pins li small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.pins li .unpin { flex: none; }
/* replies */
.rpq { display: block; max-width: 100%; border: 0; border-left: 3px solid var(--accent); background: var(--surface-2); color: var(--muted); font: inherit; font-size: 13px;
  text-align: left; border-radius: 8px; padding: 4px 9px; margin: 0 2px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.rpq b { color: var(--text); font-weight: 600; }
.replybar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px; background: var(--surface); border-top: 1px solid var(--line); font-size: 13px; }
.replybar .rtxt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 8px; }
.replybar .rtxt b { color: var(--text); }
.icon.small { min-width: 32px; width: 32px; height: 32px; font-size: 14px; }
.msg.flash .bub { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
/* a pinned GIF is a small thumbnail that never pushes the bar wider than the screen */
.pins li .go { overflow: hidden; }
.pins li .go img { display: block; max-width: 100%; max-height: 120px; width: auto; height: auto; border-radius: 8px; }
.pins ul { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
.pins li { min-width: 0; }

/* opened from the home screen: a little extra room under the status bar (and clear of the blur band, should an
   older install still draw under it) */
@media (display-mode: standalone) {
  .home { padding-top: calc(env(safe-area-inset-top) + 20px); }
  .bar { padding-top: calc(env(safe-area-inset-top) + 14px); }
  .toasts { top: calc(76px + env(safe-area-inset-top)); }
  /* iOS reports no bottom inset here, so leave room for the home indicator ourselves, like Messenger does */
  .composer { padding-bottom: max(28px, calc(8px + env(safe-area-inset-bottom))); }
  body.typing .composer { padding-bottom: 8px; }
  .rofoot { padding-bottom: max(28px, calc(10px + env(safe-area-inset-bottom))); }
  .sheet { padding-bottom: max(32px, calc(16px + env(safe-area-inset-bottom))); }
}


/* language: the page is written in Traditional Chinese, so other languages stay hidden until js/i18n.js fills them in */
html.l10n body { visibility: hidden; }
html.opening #home { display: none; }
/* the loading screen, while nothing else can show yet: it fades in only if the wait is noticeable, and says it is
   connecting once it has been a while (the words wait for the translation) */
.splash { display: none; }
html.opening .splash, html.l10n .splash { position: fixed; inset: 0; z-index: 10; visibility: visible; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); color: var(--text); animation: fade .3s .15s both; }
.splash img { width: 72px; height: 72px; border-radius: 20px; background: var(--accent-2); }
.splash b { font-size: 22px; letter-spacing: .02em; }
.splash .spin { width: 26px; height: 26px; margin-top: 8px; border: 3px solid var(--line); border-top-color: var(--accent-ink); border-radius: 50%; animation: spin .8s linear infinite; }
.splash p { margin: 0; color: var(--muted); font-size: 14px; animation: fade .4s 2.5s both; }
html.l10n .splash p { visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .splash .spin { animation-duration: 2.4s; } }
.hmenu .merow + .merow { margin-top: 8px; }
.langs { display: flex; flex-direction: column; gap: 6px; }
.langs .btn[aria-checked="true"] { border-color: var(--accent); background: var(--accent-2); font-weight: 600; }
.brand .logo img { width: 100%; height: 100%; display: block; }

/* ---------- photos, polls, draws ---------- */
.picker.short { height: auto; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.morepanel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 0; }
.morebtn { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 14px; padding: 12px 6px; font: inherit; font-size: 14px; }
.morebtn .i { font-size: 26px; line-height: 1; }
.morebtn:active, .morebtn:hover { background: var(--accent-2); }
.bub.imgbub { padding: 4px; border-radius: 18px; font: inherit; cursor: zoom-in; }
/* in the chat every photo is a 4:3 window onto the picture; tapping shows all of it */
.photo { display: block; width: min(240px, 60vw); height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-2); border-radius: 14px; }
.quote.gifq .photo { width: 160px; border-radius: 10px; }
.pins li .go .photo { width: 120px; max-width: 100%; border-radius: 8px; }
.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center; animation: fade .15s; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .icon { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; color: #fff; background: rgba(255, 255, 255, .15); }
/* a poll or a draw is a card, also in my own (accent-coloured) bubble */
.bub.pollbub, .bub.drawbub { background: var(--surface); border-color: var(--line); color: var(--text); white-space: normal; width: min(300px, 74vw); padding: 10px 12px; }
.mine .bub.pollbub, .mine .bub.drawbub { background: var(--surface); border-color: var(--accent); color: var(--text); }
.pollbox, .drawbox { display: flex; flex-direction: column; gap: 6px; }
.ph { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--accent-ink); font-weight: 600; }
.ph small { color: var(--muted); font-weight: 400; }
.pq { font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.pf { color: var(--muted); font-size: 12px; }
.opt { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 6px 10px; font: inherit; font-size: 14px; text-align: left; overflow: hidden; cursor: pointer; }
.opt .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-2); transition: width .3s; }
.opt .ol, .opt .oc { position: relative; }
.opt .ol { flex: 1; min-width: 0; word-break: break-word; }
.opt .oc { color: var(--muted); font-variant-numeric: tabular-nums; }
.opt.on { border-color: var(--accent-ink); font-weight: 600; }
.opt:disabled { cursor: default; opacity: 1; }
.pollbox.closed .opt { opacity: .8; }
.voters > div { padding: 8px 0; border-bottom: 1px solid var(--line); }
.voters p { margin: 2px 0 0; }
.winners { display: flex; flex-wrap: wrap; gap: 6px; }
.win { background: var(--accent-2); border: 1px solid var(--accent); border-radius: 999px; padding: 4px 12px; font-weight: 600; }
.drawbox.fresh .win { animation: pop .45s calc(.8s + var(--i) * .45s) both; }
@keyframes pop { 0% { opacity: 0; transform: scale(.4); } 70% { transform: scale(1.12); } 100% { opacity: 1; transform: none; } }
.drawbox details { font-size: 13px; color: var(--muted); }
.drawbox summary { cursor: pointer; }
.drawbox details p { margin: 4px 0 0; }
.pollopts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.seg.row { flex-direction: row; }
.seg.row button { flex: 1; text-align: center; }
.lblrow { display: flex; justify-content: space-between; align-items: flex-end; }
.picklist { display: flex; flex-direction: column; max-height: 36dvh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick:last-child { border-bottom: 0; }
.pick input { width: 20px; height: 20px; accent-color: var(--accent-ink); }
.pick .av { font-size: 22px; }
.pick .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field.num { width: 110px; }
@media (prefers-reduced-motion: reduce) { .drawbox.fresh .win { animation: none; } }

/* ---------- moderation, mentions, unread, typing ---------- */
/* the list and what floats over its bottom edge: who's typing, and the way back to the newest message */
.listwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.typingbar { position: absolute; left: 12px; bottom: 6px; max-width: calc(100% - 90px); background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; border-radius: 999px; padding: 3px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.jump { position: absolute; right: 12px; bottom: 8px; min-width: 40px; height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 14px; box-shadow: var(--shadow); cursor: pointer; }
.newline { display: flex; align-items: center; gap: 8px; margin: 16px 4px 4px; color: var(--accent-ink); font-size: 12px; font-weight: 600; }
.newline::before, .newline::after { content: ""; flex: 1; border-top: 1px solid var(--accent); }
.ment { font-weight: 600; color: var(--accent-ink); }
.mine .ment { color: inherit; }
.ment.self { background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 0 2px; }
.msg.atme .bub { box-shadow: inset 3px 0 0 var(--accent-ink); }
.edited { color: var(--muted); font-size: 11px; margin: 1px 6px 0; }
.msg.folded { margin-top: 6px; }
.foldbtn { border: 1px dashed var(--line); background: none; color: var(--muted); border-radius: 14px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.mentionbar { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; background: var(--surface); border-top: 1px solid var(--line); }
.mentionbar .chip { flex: none; min-height: 32px; padding: 2px 12px; font-size: 14px; }
.replist { list-style: none; margin: 0; padding: 0; }
.replist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.replist .go { display: block; width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left; padding: 0; white-space: pre-wrap; word-break: break-word; cursor: pointer; }
.replist small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.replist .row { display: flex; gap: 8px; margin-top: 8px; }
textarea.field { resize: vertical; font: inherit; line-height: 1.45; }
.legal { margin-top: 4px; }
.legal a { color: var(--muted); }

/* ---------- lecture Q&A ---------- */
.qtabs { padding: 6px 12px; }
.qtabs .tab { position: relative; }
.qtabs .dot { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
.inqa .list { padding-top: 10px; }
.qh { font-size: 13px; color: var(--muted); margin: 14px 4px 6px; font-weight: 600; }
.qnote { margin: 0 0 10px; background: var(--accent-2); color: var(--accent-ink); font-size: 13px; }
.qcard { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 0 0 8px; }
.qcard.live { border-color: var(--accent-ink); box-shadow: 0 0 0 2px var(--accent-2); }
.qcard.done { opacity: .7; }
.qcard.waiting { border-style: dashed; }
.upvote { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 48px; min-height: 52px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; font-size: 13px; color: var(--muted); }
.upvote b { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.upvote.on { border-color: var(--accent-ink); background: var(--accent-2); color: var(--accent-ink); }
.upvote:disabled { cursor: default; }
.qbody { flex: 1; min-width: 0; }
.qwho { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 13px; color: var(--muted); }
.qwho span { color: var(--text); font-weight: 600; }
.qmine { background: var(--accent-2); color: var(--accent-ink); border-radius: 999px; padding: 0 8px; }
.qwho time { font-size: 12px; }
.qtext { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.qtools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qans { margin-top: 8px; padding: 6px 0 2px 10px; border-left: 3px solid var(--accent-ink); }
.qans .qwho small { font-size: 11px; }
.qansq { max-height: 6.5em; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0 0 8px; }
.qlive { display: inline-block; background: var(--accent-ink); color: var(--surface); border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.qdone { margin: 12px 0 8px; }
.qdone summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 4px; }
.qdone .qcard { margin-top: 8px; }
.askbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 6px 14px; background: var(--surface); border-top: 1px solid var(--line); font-size: 14px; }
.askbar label { display: flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.askbar input { width: 18px; height: 18px; accent-color: var(--accent-ink); }
.askbar small { color: var(--muted); font-size: 12px; }
#recList .qcard { margin-top: 8px; }

/* ---------- the projector screen ---------- */
.show { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 3vw; padding: 4vh 4vw; background: var(--bg); overflow: hidden; font-size: clamp(18px, 1.6vw, 34px); }
.smain { display: flex; flex-direction: column; gap: 2vh; min-height: 0; overflow-y: auto; }
.smain h2 { font-size: 1.1em; color: var(--muted); font-weight: 600; }
.snow { background: var(--surface); border: 3px solid var(--accent-ink); border-radius: 24px; padding: 2.5vh 2vw; }
.snow p { margin: .3em 0; font-size: 1.7em; font-weight: 700; line-height: 1.3; white-space: pre-wrap; word-break: break-word; }
.snow small { color: var(--muted); }
.snow .qlive { font-size: .7em; }
.sans { margin-top: 1.2vh; padding-left: 1vw; border-left: 4px solid var(--accent-ink); }
.sans p { margin: .2em 0 0; font-size: 1.15em; font-weight: 500; line-height: 1.4; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.slist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.4vh; }
.slist li { display: flex; gap: 1em; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.6vh 1.4vw; }
.slist .sv { flex: none; min-width: 3.2em; font-weight: 700; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.slist .st { flex: 1; min-width: 0; line-height: 1.35; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.slist .st small { display: block; color: var(--muted); font-size: .7em; margin-top: .2em; }
.shint { color: var(--muted); font-size: 1.1em; }
.shint.big { font-size: 1.6em; margin: auto 0; text-align: center; }
.sside { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1vh; min-height: 0; overflow-y: auto; }
.stitle { font-size: 1.2em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sqr { width: min(100%, 30vh); background: #fff; border-radius: 16px; padding: 8px; }
.sqr svg { display: block; width: 100%; height: auto; }
.sjoin { margin: 0; color: var(--muted); font-size: .9em; }
.shost { font-weight: 600; }
.scode { font: 700 2.4em ui-monospace, Menlo, monospace; letter-spacing: .12em; color: var(--accent-ink); line-height: 1.1; }
.sppl { margin: 0; color: var(--muted); font-size: .85em; }
.spoll, .spollbox { width: 100%; text-align: left; }
.show .pollbox { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.4vh 1.2vw; font-size: .9em; }
.show .pq { font-size: 1.05em; }
.show .opt { font-size: .85em; min-height: 2.2em; }
.smain > .spollbox .pollbox { font-size: 1.3em; }
.sexit { position: fixed; top: 10px; right: 10px; opacity: .25; }
.sexit:hover, .sexit:focus-visible { opacity: 1; }
@media (max-width: 700px), (orientation: portrait) {
  /* one column that scrolls as a whole: each part as tall as its content, so the last question isn't cut off */
  .show { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: auto; align-content: start; overflow-y: auto; font-size: 18px; padding-bottom: calc(4vh + env(safe-area-inset-bottom)); }
  /* min-height back to auto: with the base rule's min-height: 0 each row could shrink below its content and the rows overlapped */
  .smain, .sside { overflow: visible; min-height: auto; }
  .sside { order: -1; }
  .sqr { width: 200px; }
}
