:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #18212d;
  --muted: #5b6676;
  --line: #dde3ea;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --accent: #2f6fab;
  --soft: #eaf1f8;
  --warn-bg: #fff6e5;
  --warn-ink: #7a4b00;
  --warn-line: #f0d39a;
  --ok-bg: #e9f6ee;
  --ok-ink: #1d6b3c;
  --bad-bg: #fdecec;
  --bad-ink: #9b2222;
  --c1: #2e7d4f;
  --c2a: #2f6fab;
  --c2b: #c26a00;
  --c3: #b3261e;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --card: #171e28; --ink: #e6ebf1; --muted: #9aa6b5; --line: #2a3442;
    --brand: #3d7cc0; --accent: #6ea8e6; --soft: #1c2938;
    --warn-bg: #2d2412; --warn-ink: #f0c878; --warn-line: #5a4520;
    --ok-bg: #13281c; --ok-ink: #7fd3a0; --bad-bg: #2f1616; --bad-ink: #f19a9a;
    --c1: #5cc58a; --c2a: #6ea8e6; --c2b: #f0a24a; --c3: #f07a72;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --card: #171e28; --ink: #e6ebf1; --muted: #9aa6b5; --line: #2a3442;
  --brand: #3d7cc0; --accent: #6ea8e6; --soft: #1c2938;
  --warn-bg: #2d2412; --warn-ink: #f0c878; --warn-line: #5a4520;
  --ok-bg: #13281c; --ok-ink: #7fd3a0; --bad-bg: #2f1616; --bad-ink: #f19a9a;
  --c1: #5cc58a; --c2a: #6ea8e6; --c2b: #f0a24a; --c3: #f07a72;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "PT Sans", Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
.wrap { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 28px; padding-bottom: 40px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand b { display: block; font-size: 18px; letter-spacing: .2px; }
.brand small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.2; }
.logo-bg { fill: var(--brand); } .logo-fg { fill: #fff; }
.top-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.link:hover { background: var(--soft); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 16px; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.badge-proto { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 999px; padding: 2px 10px; margin-bottom: 12px; }

label.field { display: block; margin: 14px 0; }
label.field span { display: block; font-weight: 600; margin-bottom: 6px; }
label.field em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 14px; }
input[type=text], input[type=password], select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
input:focus, select:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 1px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); padding: 11px 18px; border-radius: 10px; cursor: pointer; font-weight: 600; min-height: 46px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: space-between; margin-top: 20px; }
.err { color: var(--bad-ink); margin-top: 10px; min-height: 1.5em; }

.progress { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress .sec { font-size: 13px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .4px; }
.bar { flex: 1; height: 6px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.ref { font-size: 13px; color: var(--muted); white-space: nowrap; }

.qtext { font-size: 20px; line-height: 1.4; font-weight: 600; margin: 4px 0 14px; }
.help { background: var(--soft); border-radius: 10px; padding: 10px 14px; font-size: 14.5px; margin: 0 0 14px; }
.judge { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 0 0 14px; }

.terms { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.term { border: 1px dashed var(--accent); background: transparent; color: var(--accent); border-radius: 999px; padding: 3px 11px; font-size: 13.5px; cursor: pointer; }
.term[aria-expanded="true"] { background: var(--soft); border-style: solid; }
.termdef { background: var(--soft); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; font-size: 14.5px; margin: 0 0 14px; }
.termdef b { display: block; margin-bottom: 4px; }
.termdef small { display: block; color: var(--muted); margin-top: 6px; }

.example { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 8px 0 0; background: var(--bg); }
.example b { color: var(--accent); font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px; display: block; margin-bottom: 2px; }

.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.yesno .btn { min-height: 56px; font-size: 17px; }
.opts { display: grid; gap: 10px; margin-top: 6px; }
.opt { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; background: var(--card); }
.opt:hover { border-color: var(--accent); }
.opt input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.opt .ol { flex: 1; }
.opt .op { display: inline-block; font-size: 12.5px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.opt.checked { border-color: var(--brand); background: var(--soft); }
.opt .example { margin-top: 8px; }
.grouphead { font-weight: 700; margin: 10px 0 0; font-size: 14px; color: var(--muted); }

.result-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.classbox { min-width: 120px; text-align: center; border-radius: 16px; padding: 14px 18px; color: #fff; }
.classbox small { display: block; font-size: 13px; opacity: .9; }
.classbox b { display: block; font-size: 44px; line-height: 1.05; letter-spacing: .5px; }
.cls-1 { background: var(--c1); } .cls-2а { background: var(--c2a); } .cls-2б { background: var(--c2b); } .cls-3 { background: var(--c3); } .cls-x { background: var(--muted); }
.rule { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.rule.decisive { border-color: var(--brand); border-width: 2px; }
.rule .rh { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 600; }
.rule .pill { font-size: 13px; border-radius: 999px; padding: 1px 10px; color: #fff; white-space: nowrap; }
.rule .exc { margin-top: 8px; font-size: 14.5px; background: var(--soft); border-radius: 8px; padding: 8px 12px; }
.rule .exc s { color: var(--muted); }
.note { border-radius: 10px; padding: 10px 14px; margin-top: 12px; font-size: 14.5px; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.note.ok { background: var(--ok-bg); color: var(--ok-ink); }
.note.bad { background: var(--bad-bg); color: var(--bad-ink); }
.note.info { background: var(--soft); }
.note ul { margin: 6px 0 0; padding-left: 20px; }

details.path { margin-top: 16px; }
details.path summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.path ol { padding-left: 22px; margin: 10px 0 0; }
.path li { margin: 0 0 8px; font-size: 14.5px; }
.path li span { display: block; font-weight: 600; }

.modal { position: fixed; inset: 0; background: rgba(10, 16, 24, .55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 10; }
.modal-box { background: var(--card); border-radius: var(--radius); max-width: 720px; width: 100%; padding: 24px; position: relative; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
table.t th, table.t td { text-align: left; border-bottom: 1px solid var(--line); padding: 8px 6px; vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; }
.stub { margin: 10px 0; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 14px 0 22px; }
.foot p { margin: 6px 0; }

@media (max-width: 560px) {
  .card { padding: 18px; }
  h1 { font-size: 21px; }
  .qtext { font-size: 18px; }
  .brand small { display: none; }
  .classbox b { font-size: 36px; }
  .progress { flex-wrap: wrap; }
  .bar { flex-basis: 100%; order: 3; }
}
