:root {
  /* Layout: one calm column on phones (exam, file, check). From 900px the editor and the result sit side by side. */
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --fg: #1f2430;
  --muted: #5f6b7d;
  --line: #e1e6ee;
  --accent: #1a73e8;
  --accent-ink: #ffffff;
  --accent-tint: #e8f0fe;
  --ok: #188038;
  --ok-bg: #e6f4ea;
  --bad: #c5221f;
  --bad-bg: #fce8e6;
  --warn: #8a5a00;
  --warn-bg: #fef7e0;
  --shadow: 0 1px 2px rgba(60,64,67,.12), 0 2px 8px rgba(60,64,67,.08);
  --font-body: "Inter", "Mukta", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media not all /* dark mode off; change back to (prefers-color-scheme: dark) to re-enable */ {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --surface: #1a1d23;
    --surface-2: #232730;
    --fg: #e8eaed;
    --muted: #a0a7b4;
    --line: #333844;
    --accent: #8ab4f8;
    --accent-ink: #0b1d3a;
    --accent-tint: #24324d;
    --ok: #81c995;
    --ok-bg: #1b3325;
    --bad: #f28b82;
    --bad-bg: #3c1d1b;
    --warn: #fdd663;
    --warn-bg: #3a3012;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #1a1d23;
  --surface-2: #232730;
  --fg: #e8eaed;
  --muted: #a0a7b4;
  --line: #333844;
  --accent: #8ab4f8;
  --accent-ink: #0b1d3a;
  --accent-tint: #24324d;
  --ok: #81c995;
  --ok-bg: #1b3325;
  --bad: #f28b82;
  --bad-bg: #3c1d1b;
  --warn: #fdd663;
  --warn-bg: #3a3012;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.5 var(--font-body);
  padding-block: 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app { max-width: 980px; margin: 0 auto; }
h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 700; line-height: 1.2; }
h2 { font-size: 18px; font-weight: 700; text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.brand h1 { color: var(--fg); }
.lang { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.lang button { border: 0; background: transparent; padding: 6px 14px; min-height: 40px; cursor: pointer; font-weight: 600; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.lead { margin-top: 10px; color: var(--muted); max-width: 62ch; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: start; }
  .span2 { grid-column: 1 / -1; }
}

.exams { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.opt { text-align: left; border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 10px 12px 10px 42px; min-height: 56px; cursor: pointer; position: relative; display: flex; flex-direction: column; justify-content: center; }
.opt::before { content: ""; position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; border: 2px solid var(--muted); background: var(--surface); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.opt[aria-pressed="true"]::before { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 4px, var(--surface) 5px); }
.opt b { font-weight: 700; line-height: 1.2; }
.opt small { color: var(--muted); font-size: 14px; line-height: 1.2; }

.rules { display: flex; flex-direction: column; gap: 10px; }
.specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0; }
.specs div { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; }
.specs dt { font-size: 13px; color: var(--muted); }
.specs dd { margin: 0; font-family: var(--font-mono); font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 15px; }
.note a { color: inherit; font-weight: 700; }
.fields4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); min-width: 0; }
input[type="number"], input[type="text"] { width: 100%; min-height: 46px; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface); color: var(--fg); font-family: var(--font-mono); font-size: 16px; }

.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.tabs button { border: 0; background: transparent; min-height: 50px; padding: 6px 8px; cursor: pointer; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; }
.tabs button + button { border-left: 1.5px solid var(--line); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.tick { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ok); color: var(--surface); font-size: 13px; line-height: 1; }

.stage { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; justify-items: center; gap: 8px; }
#view { display: block; max-width: 100%; height: auto; background: #fff; box-shadow: 0 0 0 1px var(--line); touch-action: pan-y; }
#view.drag { cursor: grab; touch-action: none; }
.tag { position: absolute; top: 10px; left: 10px; background: var(--fg); color: var(--bg); font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.cap { font-size: 14px; color: var(--muted); text-align: center; }

.controls { display: flex; flex-direction: column; gap: 12px; }
.ctl { display: flex; flex-direction: column; gap: 6px; }
.ctl label { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.ctl output { font-family: var(--font-mono); color: var(--muted); font-weight: 400; }
input[type="range"] { width: 100%; min-height: 36px; accent-color: var(--accent); }
.hint { font-size: 14px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.fields2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 8px 18px; border-radius: 10px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; text-align: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { min-height: 46px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn .mono { font-weight: 500; font-size: 14px; opacity: 0.9; }

.verdict { border-radius: 10px; padding: 12px 14px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict.wait { background: var(--surface-2); color: var(--muted); }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checks li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 4px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.checks li:first-child { border-top: 0; }
.mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; color: var(--surface); }
.mark.ok { background: var(--ok); }
.mark.bad { background: var(--bad); }
.ck-main { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ck-main b { font-weight: 600; }
.ck-main .mono { font-size: 15px; }
.ck-hint { grid-column: 2; font-size: 14px; color: var(--muted); }
.dl { display: flex; flex-direction: column; gap: 10px; }
#msg { min-height: 1.4em; font-size: 15px; color: var(--muted); }
.foot { margin-top: 18px; color: var(--muted); font-size: 14px; text-align: center; }
@media (prefers-reduced-motion: no-preference) {
  .opt, .btn { transition: background-color 0.15s, border-color 0.15s; }
}
.note.ok { background: var(--ok-bg); color: var(--ok); }
