:root {
  --bg: #f3f5f7; --card: #fff; --text: #1a1f24; --muted: #667085; --line: #e3e7ec;
  --brand: #1f6feb; --brand-ink: #fff;
  --ans: #2e9e4f; --notans: #e5484d; --mark: #7c3aed; --idle: #d0d5dd; --warn: #f59e0b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }
.app { min-height: 100vh; display: flex; flex-direction: column; }

.center { max-width: 480px; margin: 8vh auto; padding: 0 16px; width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.brand { font-weight: 700; font-size: 22px; margin: 0 0 4px; }
.brand span { color: var(--brand); }
.muted { color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field input { padding: 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 18px; }
.field input.code { text-transform: uppercase; letter-spacing: 4px; font-weight: 600; }
.btn { padding: 12px 18px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { background: var(--notans); color: #fff; border-color: var(--notans); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--notans); margin: 8px 0 0; font-size: 14px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 12px 0; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; text-align: right; }
.instructions li { margin: 6px 0; }

/* test screen */
.top { position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top .title { font-weight: 600; flex: 1; min-width: 160px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 6px 12px; border-radius: 8px; background: #eef4ff; color: var(--brand); }
.timer.low { background: #fff1f1; color: var(--notans); }
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { border: 0; background: #fff; padding: 6px 10px; font-size: 13px; }
.lang button.on { background: var(--brand); color: #fff; }
.main { display: grid; grid-template-columns: 1fr 300px; gap: 16px; padding: 16px; flex: 1; }
.qpanel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.qhead .no { font-weight: 700; }
.qhead .sec { color: var(--muted); font-size: 13px; }
.directions { background: #fbfbfc; border-left: 3px solid var(--idle); padding: 8px 12px; margin: 8px 0 12px; white-space: pre-wrap; font-size: 15px; }
.qtext { white-space: pre-wrap; line-height: 1.55; margin: 6px 0 12px; }
.qtext.hi { font-size: 17px; }
.figure { max-width: 100%; max-height: 320px; display: block; margin: 8px 0 12px; border: 1px solid var(--line); border-radius: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; cursor: pointer; }
.opt:hover { border-color: var(--brand); }
.opt.on { border-color: var(--brand); background: #eef4ff; }
.opt .lbl { font-weight: 700; min-width: 22px; }
.opt .txt { white-space: pre-wrap; line-height: 1.5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.side { display: flex; flex-direction: column; gap: 12px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.palette button { height: 40px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-weight: 600; position: relative; }
.palette button.cur { outline: 2px solid var(--brand); outline-offset: 1px; }
.palette .s-ans, .legend .s-ans { background: var(--ans); color: #fff; border-color: var(--ans); }
.palette .s-not, .legend .s-not { background: var(--notans); color: #fff; border-color: var(--notans); }
.palette .s-mark, .legend .s-mark { background: var(--mark); color: #fff; border-color: var(--mark); }
.palette .s-idle, .legend .s-idle { background: #fff; color: var(--text); border-color: var(--idle); }
.palette button.s-mark.has::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--ans); border: 1px solid #fff; }
.save { font-size: 12px; color: var(--muted); }
.result { text-align: center; }
.result .score { font-size: 48px; font-weight: 800; color: var(--brand); margin: 8px 0; }
.result .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.result .grid div { background: #f8fafc; border-radius: 8px; padding: 10px; }
.result .grid b { display: block; font-size: 22px; }
@media (max-width: 860px) {
  .main { grid-template-columns: 1fr; padding: 12px; }
  .side { order: 2; }
  .palette { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
}

.logo { width: 72px; height: 72px; display: block; margin: 0 0 8px; }
.foot { margin: 16px 0 0; font-size: 13px; }

.figcrop { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin: 8px 0 12px; max-width: 100%; height: 120px; }
.figcrop img { position: absolute; max-width: none; visibility: hidden; }
