/* ===== Tokens ===== */
:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E3E7EE;
  --border-strong: #CDD4E0;
  --grid: #EEF2F7;
  --dots: #DCE1EA;
  --ink: #0F172A;
  --ink-2: #3B4559;
  --muted: #5B6478;
  --faint: #94A3B8;
  --accent: #2F6BFF;
  --accent-dark: #1D4ED8;
  --accent-soft: #9DB8FF;
  --accent-tint: #F0F5FF;
  --accent-ring: rgba(47, 107, 255, 0.14);
  --green: #12A150;
  --green-dark: #0E7C3D;
  --green-tint: #EEFAF2;
  --green-ring: rgba(18, 161, 80, 0.14);
  --danger: #B42318;
  --danger-border: #F3C4C0;
  --bar-dim: #C3CAD6;
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dots { background-color: var(--bg); background-image: radial-gradient(var(--dots) 1px, transparent 1px); background-size: 22px 22px; }
.tag {
  font-family: var(--mono); font-size: 12px; letter-spacing: 1.5px; color: var(--accent);
  direction: ltr; unicode-bidi: isolate;
}

/* ===== Buttons & fields ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-size: 15px; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--faint); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-soft { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-dark); font-weight: 700; }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { color: var(--danger); border-color: var(--danger); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.btn-green-outline { background: var(--surface); border-color: var(--green); color: var(--green-dark); font-weight: 700; }
.btn-lg { height: 56px; padding: 0 24px; font-size: 17px; border-radius: 12px; }
.btn-icon { width: 44px; padding: 0; }
.btn svg { flex-shrink: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  height: 44px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 12px;
  font-size: 16px; background: var(--surface); outline: none; width: 100%;
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 8px; padding: 6px 10px;
  font-family: var(--mono); font-size: 12px; color: var(--muted); direction: ltr;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.figure {
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex; align-items: center; justify-content: center;
}
.figure img { max-width: 100%; max-height: 100%; display: block; }
.figure img.photo { width: 100%; height: 100%; object-fit: cover; }

.segs { display: grid; gap: 4px; }
.segs > i { height: 4px; border-radius: 2px; background: var(--border); display: block; }
.segs > i.done { background: var(--accent); }
.segs > i.cur { background: var(--accent-soft); }
.bar { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* Toast & modal */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
}
@media (min-width: 640px) { .modal-back { align-items: center; } }
.modal {
  background: var(--surface); border-radius: 20px; padding: 22px; width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 60px rgba(15, 23, 42, .2);
}
.modal h2 { margin: 0; font-size: 20px; }
.modal p { margin: 0; color: var(--muted); line-height: 1.55; }
.modal .row { display: flex; gap: 10px; flex-wrap: wrap; }
.modal .row .btn { flex: 1 1 140px; }

/* ===== Participant (phone) ===== */
.p-app { min-height: 100vh; min-height: 100dvh; display: flex; justify-content: center; }
.p-screen { width: 100%; max-width: 520px; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.p-pad { padding: 28px 22px 28px; }
.p-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.p-hero { display: flex; flex-direction: column; gap: 12px; margin-top: 9vh; }
.p-hero h1 { margin: 0; font-size: 34px; line-height: 1.15; font-weight: 800; }
.stats2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--mono); font-size: 22px; font-weight: 700; direction: ltr; text-align: right; }
.stat span { font-size: 13px; color: var(--muted); }
.p-grow { flex: 1 1 auto; min-height: 24px; }
.join-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 12px 32px rgba(15, 23, 42, .06); }
.join-card label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.join-card .input { height: 54px; font-size: 17px; padding: 0 16px; border-radius: 12px; }
.join-card .note { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }
.err { color: var(--danger); font-size: 14px; min-height: 0; }

.p-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 32px 26px; }
.p-center h1 { margin: 0; font-size: 32px; font-weight: 800; }
.p-center p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--muted); max-width: 320px; }
.ring-wrap { width: 128px; height: 128px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: center; }
.ring-in { width: 96px; height: 96px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ring-in.ok { border: 2px solid var(--green); background: var(--green-tint); }
.ring-in.wait { border: 2px solid var(--accent); background: var(--accent-tint); }
.spin { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.done-tag { color: var(--green-dark); }

.q-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 20px 14px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; z-index: 5; }
.q-head .row { display: flex; align-items: center; justify-content: space-between; }
.q-num { font-size: 15px; font-weight: 700; }
.q-num span { color: var(--muted); font-weight: 400; }
.timer { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 6px 12px 6px 8px; }
.timer b { font-family: var(--mono); font-weight: 700; font-size: 18px; direction: ltr; }
.timer.low { border-color: #F5C08A; background: #FFF7EE; }
.timer.low b { color: #9A3C00; }
.timer.low circle.fg { stroke: #E8590C; }
.q-body { flex: 1; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.q-body .figure { height: 34vh; max-height: 220px; min-height: 120px; flex-shrink: 0; padding: 8px; }
.q-body.long .figure { height: 22vh; max-height: 150px; }
.q-text { margin: 2px 0 0; font-size: 22px; line-height: 1.4; font-weight: 700; white-space: pre-line; }
.q-body.long .q-text { font-size: 18px; line-height: 1.55; font-weight: 600; }
.answers { display: flex; flex-direction: column; gap: 10px; }
.ans {
  display: flex; align-items: flex-start; gap: 12px; min-height: 58px; padding: 13px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-size: 17px; font-weight: 500;
  text-align: right; line-height: 1.45; width: 100%; transition: background .12s, border-color .12s, box-shadow .12s;
}
.q-body.long .ans { font-size: 16px; font-weight: 400; line-height: 1.5; }
.ans .badge {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); margin-top: -2px;
}
.ans .t { flex: 1; padding-top: 2px; }
.ans[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.ans[aria-pressed="true"] .badge { background: var(--accent); border-color: var(--accent); color: #fff; }
.q-foot { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 10px; position: sticky; bottom: 0; }
.q-foot .btn-lg { flex: 1; }
.q-foot .btn-icon { width: 56px; height: 56px; flex: 0 0 56px; }
.jump-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.jump-grid button { height: 44px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font-family: var(--mono); font-weight: 700; }
.jump-grid button.miss { border-color: #F5C08A; background: #FFF7EE; color: #9A3C00; }

/* ===== Presenter ===== */
.host { min-height: 100vh; display: flex; flex-direction: column; }
.host-bar { position: fixed; top: 12px; left: 12px; display: flex; gap: 8px; z-index: 20; opacity: .35; transition: opacity .2s; }
.host-bar:hover { opacity: 1; }
.host-lobby { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4vw; padding: 5vh 5vw; }
@media (max-width: 900px) { .host-lobby { grid-template-columns: 1fr; } }
.host-col { display: flex; flex-direction: column; gap: 2.4vh; min-width: 0; }
.host-title { margin: 0; font-size: clamp(32px, 4.4vw, 72px); line-height: 1.1; font-weight: 800; }
.host .stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.host .stat b { font-size: clamp(20px, 2vw, 30px); }
.host .stat span { font-size: clamp(13px, 1.05vw, 16px); }
.big-count { display: flex; align-items: baseline; gap: 14px; }
.big-count b { font-family: var(--mono); font-size: clamp(48px, 6vw, 96px); font-weight: 700; line-height: 1; color: var(--accent); }
.big-count span { font-size: clamp(18px, 1.7vw, 26px); color: var(--ink-2); }
.names { display: flex; flex-wrap: wrap; gap: 8px; max-height: 22vh; overflow: hidden; align-content: flex-start; }
.names span { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 7px 14px; font-size: clamp(14px, 1.2vw, 18px); animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.qr-card { background: var(--surface); border: 1px solid var(--border); border-radius: 28px; padding: 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 24px 60px rgba(15, 23, 42, .08); }
.qr-card canvas, .qr-card img, .qr-card svg { width: min(38vh, 30vw, 420px); height: auto; aspect-ratio: 1; display: block; }
.join-url { font-family: var(--mono); font-size: clamp(22px, 2.6vw, 40px); font-weight: 700; direction: ltr; }
.room-code { font-family: var(--mono); color: var(--accent); font-weight: 700; font-size: clamp(22px, 2vw, 32px); letter-spacing: 4px; direction: ltr; }

.host-run { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vh; padding: 5vh 5vw; text-align: center; }
.big-timer { font-family: var(--mono); font-weight: 700; font-size: clamp(80px, 16vw, 240px); line-height: 1; direction: ltr; letter-spacing: -2px; }
.big-timer.low { color: #C2410C; }
.run-progress { width: min(900px, 90%); display: flex; flex-direction: column; gap: 12px; }
.run-progress .bar { height: 14px; border-radius: 7px; }
.run-progress .bar > i { border-radius: 7px; transition: width .6s; }
.run-meta { display: flex; justify-content: space-between; font-size: clamp(16px, 1.5vw, 24px); color: var(--muted); }
.run-meta b { color: var(--ink); font-family: var(--mono); }
.run-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.mini-join { position: fixed; bottom: 20px; right: 20px; display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 14px; }
.mini-join canvas, .mini-join svg { width: 92px; height: 92px; }
.mini-join .join-url { font-size: 18px; }

.review { flex: 1; display: flex; flex-direction: column; gap: 2.6vh; padding: 4vh 5vw 3.5vh; }
.review-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-left: 104px; }
.review-top .left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.qbadge { font-family: var(--mono); font-size: clamp(15px, 1.3vw, 20px); color: var(--accent); letter-spacing: 1.5px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 14px; direction: ltr; }
.answered-box { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-size: clamp(14px, 1.25vw, 19px); color: var(--muted); }
.answered-box b { font-family: var(--mono); color: var(--ink); font-size: 1.15em; }
.answered-box .sep { color: var(--border-strong); }
.review-segs { display: grid; gap: 5px; min-width: min(420px, 40vw); }
.review-segs > i { height: 6px; border-radius: 3px; }
.review-q { display: flex; gap: 2.5vw; align-items: center; }
.review-q .figure { width: clamp(160px, 17vw, 260px); height: clamp(100px, 10vw, 150px); flex-shrink: 0; padding: 6px; }
.review-q h1 { margin: 0; font-size: clamp(24px, 3.1vw, 50px); line-height: 1.25; font-weight: 700; white-space: pre-line; }
.review-q h1.long { font-size: clamp(20px, 2.1vw, 34px); }
.rows { display: flex; flex-direction: column; gap: 1.4vh; flex: 1; justify-content: center; }
.rrow { display: grid; grid-template-columns: auto minmax(120px, 30%) minmax(0, 1fr) auto; align-items: center; gap: 1.4vw; padding: 1.2vh 1.2vw; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); transition: border-color .3s, box-shadow .3s; }
.rrow.correct { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-ring); }
.rrow .badge { width: clamp(36px, 3.2vw, 50px); height: clamp(36px, 3.2vw, 50px); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: clamp(16px, 1.5vw, 23px); font-weight: 700; background: var(--bg); color: var(--ink-2); border: 1px solid var(--border); transition: all .3s; }
.rrow.correct .badge { background: var(--green); color: #fff; border-color: var(--green); }
.rrow .txt { font-size: clamp(16px, 1.75vw, 27px); font-weight: 600; display: flex; align-items: center; gap: 10px; line-height: 1.3; }
.rrow .txt.long { font-size: clamp(14px, 1.2vw, 19px); font-weight: 500; }
.rrow .track { height: clamp(22px, 2.8vh, 40px); background: #F0F2F6; border-radius: 10px; overflow: hidden; }
.rrow .fill { height: 100%; border-radius: 10px; background: var(--accent); width: 0; transition: width .7s cubic-bezier(.2, .8, .2, 1), background .3s; }
.review.revealed .rrow .fill { background: var(--bar-dim); }
.review.revealed .rrow.correct .fill { background: var(--green); }
.rrow .num { display: flex; align-items: baseline; gap: 10px; min-width: 7.5em; }
.rrow .num b { font-family: var(--mono); font-size: clamp(20px, 2.1vw, 32px); font-weight: 700; }
.rrow .num span { font-family: var(--mono); font-size: clamp(13px, 1.15vw, 17px); color: var(--muted); direction: ltr; }
.check-ic { display: none; }
.rrow.correct .check-ic { display: inline-block; }
.review-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.review-foot .btn { height: clamp(46px, 6.5vh, 60px); padding: 0 clamp(16px, 1.8vw, 28px); font-size: clamp(15px, 1.3vw, 19px); border-radius: 14px; }
.kbd-hint { font-size: 12px; color: var(--faint); text-align: center; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sum-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; text-align: right; cursor: pointer; font-size: 15px; }
.sum-item:hover { border-color: var(--accent); }
.sum-item .t { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sum-item .m { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.sum-item .m .q { font-family: var(--mono); color: var(--accent); direction: ltr; unicode-bidi: isolate; }
.sum-item .bar { height: 6px; border-radius: 3px; width: 100%; }
.sum-item .bar > i { background: var(--green); }

/* ===== Admin ===== */
.adm-top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 10; }
.adm-top .brand-mark { width: 36px; height: 36px; }
.adm-wrap { max-width: 1360px; margin: 0 auto; padding: 24px; }
.adm-cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.adm-side { flex: 1 1 300px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 900px) { .adm-side { position: sticky; top: 84px; max-height: calc(100vh - 100px); } .adm-side .qlist { overflow-y: auto; } }
.adm-main { flex: 999 1 560px; min-width: 0; padding: 24px; display: flex; flex-direction: column; gap: 22px; }
.sec { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.qlist-card { padding: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.qlist-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; }
.qlist { display: flex; flex-direction: column; gap: 2px; }
.qitem { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; font-size: 15px; width: 100%; text-align: right; }
.qitem:hover { background: var(--surface-2); }
.qitem.on { background: var(--accent-tint); border-color: var(--accent); font-weight: 500; }
.qitem .n { font-family: var(--mono); width: 30px; height: 26px; border-radius: 6px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.qitem.on .n { background: var(--accent); color: #fff; border-color: var(--accent); }
.qitem .tx { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qitem .st { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; direction: ltr; }
.qitem .grip { cursor: grab; color: var(--faint); display: flex; }
.qitem.dragging { opacity: .4; }
.qitem.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.qitem .warn { width: 8px; height: 8px; border-radius: 50%; background: #E8590C; flex-shrink: 0; }
.ed-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ed-head h2 { margin: 0; font-size: 22px; }
.img-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.img-row .figure { width: 260px; height: 150px; flex-shrink: 0; padding: 6px; position: relative; }
.img-row .figure.empty { color: var(--faint); font-size: 14px; flex-direction: column; gap: 6px; }
.img-row .figure.drag { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.img-tools { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.img-tools .row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset { font-family: var(--mono); font-size: 11px; color: var(--accent-dark); background: var(--accent-tint); border: 1px solid #C9D8FF; border-radius: 6px; padding: 3px 8px; direction: ltr; }
.arow { display: flex; align-items: center; gap: 12px; padding: 4px 6px 4px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.arow.ok { border-color: var(--green); background: #F6FCF8; }
.arow input[type=radio] { width: 20px; height: 20px; accent-color: var(--green); flex-shrink: 0; margin: 0; cursor: pointer; }
.arow .badge { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.arow.ok .badge { background: var(--green); color: #fff; border-color: var(--green); }
.arow .atext { flex: 1; min-width: 0; height: 44px; border: none; background: transparent; font-size: 17px; outline: none; }
.arow .cnt { font-family: var(--mono); font-size: 13px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.arow .okt { font-family: var(--mono); background: var(--green-tint); color: var(--green-dark); font-size: 12px; font-weight: 700; border-radius: 6px; padding: 4px 8px; direction: ltr; }
.arow .rm { width: 34px; height: 34px; border: none; background: transparent; border-radius: 8px; color: var(--faint); display: flex; align-items: center; justify-content: center; }
.arow .rm:hover { background: var(--bg); color: var(--danger); }
.ed-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; border-top: 1px solid var(--border); padding-top: 18px; }
.save-state { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); direction: ltr; }
.save-state .dot.busy { background: #E8590C; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }

.quiz-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.quiz-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.quiz-card h3 { margin: 0; font-size: 19px; }
.quiz-card .meta { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.quiz-card .meta b { font-family: var(--mono); color: var(--ink); }
.quiz-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sess-list { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border); padding-top: 10px; }
.sess { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); padding: 4px 0; }
.sess a { font-weight: 500; text-decoration: none; }
.status { font-family: var(--mono); font-size: 11px; border-radius: 6px; padding: 2px 7px; direction: ltr; border: 1px solid var(--border); }
.status.lobby, .status.running { color: var(--green-dark); border-color: var(--green); background: var(--green-tint); }

.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 60vh; overflow-y: auto; }
.picker button { aspect-ratio: 4 / 3; padding: 6px; }
.picker button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login form { width: 100%; max-width: 380px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login h1 { margin: 0; font-size: 24px; }
