:root {
  --bg: #f6f5f2; --card: #fff; --text: #1d1d1f; --muted: #6e6e73; --line: #e3e1dc;
  --accent: #ff7a45; --accent-text: #fff; --danger: #d93025; --ok: #1e8e3e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121214; --card: #1c1c1f; --text: #f2f2f4; --muted: #9a9aa0; --line: #2c2c31;
          --accent: #ff8c5c; --danger: #ff6b5e; --ok: #4cc26b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: 20px 16px 48px; }
[hidden] { display: none !important; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 26px; margin: 4px 0 2px; }
h2 { font-size: 18px; margin: 0 0 10px; }
a { color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; }
.sub { color: var(--muted); margin: 0 0 4px; font-size: 14px; }
.sub.err, .error { color: var(--danger); }
.error { font-size: 14px; margin: 8px 0 0; min-height: 1px; }
.hint { color: var(--muted); font-size: 14px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 10px 0 20px; }
.bar > div { height: 100%; background: var(--accent); width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 0 0 18px; }
.card p:first-child { margin-top: 0; }
label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 12px; }
label input { display: block; width: 100%; margin-top: 4px; }
input, select { font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
                background: var(--bg); color: var(--text); min-width: 0; }
#code { font-size: 26px; letter-spacing: 6px; text-align: center; }
button { font: inherit; border: 0; border-radius: 10px; padding: 11px 16px; background: var(--accent);
         color: var(--accent-text); cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
button.link { background: none; color: var(--accent); padding: 4px 0; }
button.quiet { background: var(--bg); color: var(--text); border: 1px solid var(--line); padding: 7px 12px; font-size: 14px; }
button.danger { background: none; color: var(--danger); border: 1px solid var(--line); padding: 7px 12px; font-size: 14px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
form.inline { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
form.inline input { flex: 1 1 180px; }
.tabs { display: flex; gap: 4px; margin: 6px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent;
          white-space: nowrap; font-size: 15px; }
.tabs a.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1 1 200px; min-width: 0; }
.list .grow small { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.list .empty { color: var(--muted); font-size: 14px; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 1px 7px; }
.invite { border-color: var(--accent); }
.invite .row { margin-top: 10px; }
dl { margin: 8px 0 12px; } dt { font-weight: 600; font-size: 14px; } dd { margin: 2px 0 10px; color: var(--muted); font-size: 14px; }
code { font: 14px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.newToken { background: var(--bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 12px; margin: 12px 0; }
.newToken p { margin: 0 0 8px; font-size: 14px; }
.newToken code { display: block; margin-bottom: 10px; font-size: 15px; }
details { margin: 12px 0 0; font-size: 14px; } summary { cursor: pointer; color: var(--accent); }
details ol { padding-left: 20px; } details li { margin: 4px 0; }
.add { display: block; text-align: center; background: var(--accent); color: var(--accent-text);
       border-radius: 12px; padding: 16px; font-size: 18px; font-weight: 600; cursor: pointer; margin: 0; }
.add input { display: none; }
#log { list-style: none; padding: 0; margin: 12px 0 0; font-size: 14px; }
#log:empty { display: none; }
#log li { padding: 4px 0; color: var(--muted); }
#log li.ok { color: var(--ok); } #log li.err { color: var(--danger); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.it { position: relative; aspect-ratio: 1; cursor: pointer; }
.it img, .it .ph { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; background: var(--line); display: block; }
.it .ph { display: grid; place-items: center; color: var(--muted); font-size: 30px; }
.it.waiting img, .it.waiting .ph { opacity: .55; }
.it.waiting::after { content: ""; position: absolute; inset: -3px; border: 2px dashed var(--muted); border-radius: 14px; pointer-events: none; }
.it .play { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.55); color: #fff; border-radius: 10px;
            padding: 1px 7px; font-size: 12px; pointer-events: none; }
.it .bad { position: absolute; left: 6px; right: 6px; bottom: 6px; background: var(--danger); color: #fff; border-radius: 8px;
           padding: 2px 6px; font-size: 11px; text-align: center; pointer-events: none; }
.it .del { position: absolute; top: -4px; right: -4px; width: 30px; height: 30px; padding: 0; z-index: 1;
           border-radius: 15px; background: var(--card); color: var(--text); border: 1px solid var(--line);
           font-size: 16px; line-height: 28px; }
.it .del.armed { width: auto; padding: 0 10px; background: var(--danger); color: #fff; border-color: var(--danger); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; grid-column: 1 / -1; }
#viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: grid; place-items: center; z-index: 10; }
#viewer img, #viewer video { max-width: 100vw; max-height: 100vh; }
#viewer .close { position: fixed; top: 12px; right: 12px; background: rgba(255,255,255,.2); color: #fff; }
