:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece8de;
  --ink: #1d2422;
  --muted: #5e6864;
  --line: rgba(29, 36, 34, .14);
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 107, 92, .1);
  --good: #17693f;
  --good-soft: #dff1e5;
  --bad: #a93a22;
  --bad-soft: #f9e3dc;
  --shadow: 0 1px 2px rgba(40, 36, 24, .06), 0 8px 24px rgba(40, 36, 24, .06);
  --sans: "Noto Sans Georgian", "Segoe UI", Sylfaen, system-ui, sans-serif;
  --serif: "Noto Serif Georgian", Sylfaen, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14181a;
    --surface: #1d2326;
    --surface-2: #272e31;
    --ink: #e9ece8;
    --muted: #a0aaa6;
    --line: rgba(233, 236, 232, .15);
    --accent: #52c4ad;
    --accent-ink: #0d1c19;
    --accent-soft: rgba(82, 196, 173, .14);
    --good: #76d59b;
    --good-soft: rgba(118, 213, 155, .15);
    --bad: #f39a83;
    --bad-soft: rgba(243, 154, 131, .15);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14181a;
  --surface: #1d2326;
  --surface-2: #272e31;
  --ink: #e9ece8;
  --muted: #a0aaa6;
  --line: rgba(233, 236, 232, .15);
  --accent: #52c4ad;
  --accent-ink: #0d1c19;
  --accent-soft: rgba(82, 196, 173, .14);
  --good: #76d59b;
  --good-soft: rgba(118, 213, 155, .15);
  --bad: #f39a83;
  --bad-soft: rgba(243, 154, 131, .15);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button, a, label { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
sub { font-size: .72em; line-height: 0; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 10px; }
.noscript { text-align: center; padding: 32px 16px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 880px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 600; color: var(--accent); min-height: 44px; }
.brand span { color: var(--ink); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 1px solid transparent; border-radius: 10px; cursor: pointer; color: var(--muted); transition: color .15s, background-color .15s; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }

main { max-width: 880px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right)) 64px max(16px, env(safe-area-inset-left)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: 15px; font-weight: 500; }

/* ტესტების ჩამონათვალი */
.back { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500; }
.back:hover { color: var(--ink); }
.catalog { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.panel.test-card h2 { font: 700 clamp(23px, 3.6vw, 29px)/1.25 var(--serif); margin: 6px 0 0; }
.test-card .stats { margin-top: 14px; }
.card-note { margin-top: 14px; padding: 9px 13px; border-radius: 10px; background: var(--accent-soft); font-size: 15px; font-variant-numeric: tabular-nums; }
.card-note a { color: var(--accent); font-weight: 600; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

/* სწავლა */
.study-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 2px 0 10px; }
.study-title h1 { font: 700 clamp(23px, 4vw, 32px)/1.25 var(--serif); text-wrap: balance; }
.study-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 10px; }
.search { width: 100%; min-height: 50px; padding: 10px 16px; font-size: 17px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 13px; transition: border-color .15s; }
.search:hover, .search:focus { border-color: var(--accent); }
.search:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 0; border-radius: 13px; }
.search::placeholder { color: var(--muted); }
.study-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; margin-top: 8px; }
#study-count { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.study .q-text { font-size: 18px; }
.study .opt { padding-top: 8px; padding-bottom: 8px; min-height: 44px; }
.study .options.figs .opt { min-height: 120px; padding-bottom: 10px; }
@media (min-width: 640px) { .study .options:not(.figs) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ტესტის არჩევა */
.hero { padding: 26px 0 26px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 15px; }
.hero h1 { font: 700 clamp(32px, 6.4vw, 50px)/1.15 var(--serif); margin: 8px 0 12px; text-wrap: balance; }
.hero p.lead { color: var(--muted); max-width: 58ch; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 18px; font-variant-numeric: tabular-nums; }
.stats b { font-size: 24px; font-weight: 700; display: block; line-height: 1.2; }
.stats span { color: var(--muted); font-size: 14px; }

.resume {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; margin-bottom: 18px;
}
.resume strong { display: block; }
.resume span { color: var(--muted); font-size: 15px; }
.resume .row { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.panel h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.set {
  position: relative; display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; cursor: pointer; min-height: 60px;
  transition: border-color .15s, background-color .15s;
}
.set:hover { border-color: var(--accent); }
.set:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.set:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.set input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; margin: 0; }
.set div { min-width: 0; }
.set b { display: block; font-weight: 600; line-height: 1.3; }
.set small { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.opts { display: flex; flex-wrap: wrap; gap: 4px 26px; margin: 18px 0 20px; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

/* ტესტი */
.quiz-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 10px; }
.quiz-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.quiz-count { font-weight: 600; }
.tally { display: flex; gap: 14px; align-items: center; }
.tally span { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 15px; }
.tally .g { color: var(--good); }
.tally .b { color: var(--bad); }
.bar { height: 6px; margin-top: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: transform .25s ease; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(18px, 3.4vw, 28px); box-shadow: var(--shadow); margin-top: 6px; animation: rise .22s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.q-tag { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.q-tag b { color: var(--accent); font-weight: 700; }
.q-text { font: 600 clamp(19px, 3vw, 23px)/1.42 var(--sans); margin: 6px 0 16px; text-wrap: pretty; scroll-margin-top: 90px; }
.q-text:focus { outline: none; }
.q-fig { display: flex; justify-content: center; background: var(--surface-2); border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.q-fig .cap { display: block; }

.mol { display: block; width: 100%; height: auto; margin: 0 auto; overflow: visible; }
.mol .lbl { font-family: Arial, Helvetica, sans-serif; }
.mol .num { font-family: Arial, Helvetica, sans-serif; font-size: 11.5px; fill: var(--accent); font-weight: 700; }

.options { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.options.figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .options.figs:not(.wide) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 520px) { .options.figs.wide { grid-template-columns: minmax(0, 1fr); } }
.opt {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; min-width: 0;
  padding: 10px 44px 10px 12px; text-align: left; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 13px; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.options.figs .opt { flex-direction: column; align-items: stretch; padding: 10px 12px 14px; min-height: 130px; }
button.opt:not([disabled]):hover { border-color: var(--accent); background: var(--accent-soft); }
ul.options { list-style: none; margin: 0; padding: 0; }
.opt.static { cursor: default; }
.opt .figwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.opt .figwrap .body { width: 100%; flex: none; }
.opt .cap { color: var(--muted); font-size: 13.5px; line-height: 1.35; text-align: center; }
.opt.right .cap { color: var(--good); font-weight: 600; }
mark { background: #f6d860; color: #1d2422; border-radius: 3px; padding: 0 1px; }
.opt[disabled] { cursor: default; color: inherit; }
.opt .n {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: var(--surface-2); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  transition: background-color .15s, color .15s;
}
.opt .t { min-width: 0; font-weight: 500; }
.options.figs .opt .t { text-align: center; margin: auto 0; }
.opt .body { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
.opt .mark { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); font-weight: 700; font-size: 18px; line-height: 1; }
.options.figs .opt .mark { top: 13px; transform: none; }
@media (max-width: 520px) {
  .options.figs.wide .opt { flex-direction: row; align-items: center; min-height: 96px; padding: 10px 34px 10px 12px; }
  .options.figs.wide .opt .n { align-self: flex-start; }
}
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .n { background: var(--good); color: var(--surface); }
.opt.right .mark { color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .n { background: var(--bad); color: var(--surface); }
.opt.wrong .mark { color: var(--bad); }
.opt.dim { opacity: .62; }

.verdict { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 11px 14px; border-radius: 12px; font-weight: 600; animation: rise .18s ease; }
.verdict.ok { background: var(--good-soft); color: var(--good); }
.verdict.no { background: var(--bad-soft); color: var(--bad); }

.nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.nav .right-group { display: flex; gap: 8px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 12px; text-align: center; }
@media (hover: none), (max-width: 640px) { .hint { display: none; } }

details.map { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
details.map summary { cursor: pointer; padding: 12px 16px; font-weight: 600; min-height: 44px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 5px; padding: 0 12px 14px; }
.map-grid a {
  display: grid; place-items: center; min-height: 44px; border-radius: 8px; text-decoration: none; font-size: 13.5px;
  background: var(--surface-2); font-variant-numeric: tabular-nums; border: 2px solid transparent;
}
.map-grid a.ok { background: var(--good-soft); color: var(--good); font-weight: 700; }
.map-grid a.no { background: var(--bad-soft); color: var(--bad); font-weight: 700; text-decoration: line-through; }
.map-grid a.cur { border-color: var(--accent); }

/* შედეგები */
.result { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; }
@media (max-width: 560px) { .result { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } }
.ring { position: relative; width: 148px; height: 148px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 700 34px/1 var(--sans); font-variant-numeric: tabular-nums; }
.result h1 { font: 700 clamp(26px, 4.6vw, 34px)/1.2 var(--serif); margin-bottom: 8px; text-wrap: balance; }
.result-counts { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
.result-counts b { color: var(--ink); }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
@media (max-width: 560px) { .result-actions { justify-content: center; } .result-counts { justify-content: center; } }

.review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 28px 0 10px; }
.review-head h2 { font-size: 20px; font-weight: 700; scroll-margin-top: 16px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: transparent; min-height: 40px; padding: 4px 14px; border-radius: 9px; cursor: pointer; font-size: 15px; font-variant-numeric: tabular-nums; transition: background-color .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.review { display: grid; gap: 10px; }
.review article { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 16px 18px; content-visibility: auto; contain-intrinsic-size: auto 240px; }
.review .q-text { font-size: 17px; margin: 4px 0 10px; }
.review .opt { min-height: 44px; }
.review .options.figs .opt { min-height: 96px; }
.empty { text-align: center; color: var(--muted); padding: 26px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: 15px; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 22px; width: min(92vw, 420px); box-shadow: var(--shadow); overscroll-behavior: contain; }
dialog::backdrop { background: rgba(10, 14, 12, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
