:root {
  color-scheme: light;
  --ink: #15201b;
  --muted: #5e6a64;
  --paper: #fffdf7;
  --ground: #edf1e9;
  --green: #12372a;
  --green-2: #245846;
  --lime: #d9f27c;
  --line: #d7ddd5;
  --red: #b42318;
  --red-soft: #fff0ee;
  --success: #176b45;
  --success-soft: #e9f7ef;
  --amber: #8a5a00;
  --amber-soft: #fff6db;
  --shadow: 0 18px 55px rgba(18, 55, 42, .12);
  --radius: 22px;
  --focus: 0 0 0 3px #fff, 0 0 0 6px #245846;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ground); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(217, 242, 124, .55), transparent 31rem),
    linear-gradient(180deg, #f8faf3 0, var(--ground) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select { font: inherit; }
[hidden] { display: none !important; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 10px 14px; color: var(--green); background: var(--lime); border-radius: 10px; font-weight: 850; }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.shell { width: min(760px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 54px; }

/* Header */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 850; letter-spacing: -.02em; color: var(--ink); text-decoration: none; min-height: 44px; border-radius: 12px; }
.za-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--green); border-radius: 12px; font-size: 12px; letter-spacing: .08em; }
.top-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.practice-tag { padding: 7px 11px; color: var(--green); background: rgba(255,255,255,.68); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 800; }
.lang-picker { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: var(--green); }
.lang-picker select { min-height: 44px; padding: 0 10px; color: var(--green); background: white; border: 1px solid var(--line); border-radius: 12px; font-weight: 800; cursor: pointer; }
.mainnav { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.navbtn { min-height: 44px; padding: 0 14px; color: var(--green); background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 12px; font-weight: 850; cursor: pointer; }
.navbtn[aria-current="page"] { color: white; background: var(--green); border-color: var(--green); }
.lang-note { margin: -10px 0 16px; padding: 10px 14px; color: var(--amber); background: var(--amber-soft); border: 1px solid #efd48a; border-radius: 12px; font-size: 13px; font-weight: 700; }

/* Hero */
.hero { padding: 30px; color: white; background: var(--green); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero::after { content: ""; position: absolute; width: 260px; height: 260px; right: -95px; top: -105px; background: var(--lime); border-radius: 50%; opacity: .9; pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.eyebrow { margin: 0 0 8px; color: var(--lime); font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
h1 { max-width: 570px; margin: 0; font-size: clamp(32px, 7vw, 54px); line-height: .98; letter-spacing: -.055em; }
.hero-copy { max-width: 565px; margin: 18px 0 18px; color: #dce9e2; font-size: 16px; }
.facts { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 22px; padding: 0; list-style: none; }
.facts li { padding: 8px 11px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); border-radius: 10px; font-size: 13px; font-weight: 750; }
.mode-group { margin: 0 0 14px; }
.mode-group h2 { margin: 0 0 8px; color: var(--lime); font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.hero .inline-msg { margin-top: 14px; color: var(--ink); }

.primary, .secondary, .danger { min-height: 49px; padding: 0 18px; border-radius: 13px; border: 0; cursor: pointer; font-weight: 850; transition: transform .16s ease, filter .16s ease; }
a.primary, a.secondary { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.primary { color: var(--green); background: var(--lime); }
.secondary { color: var(--green); background: white; border: 1px solid var(--line); }
.danger { color: white; background: var(--red); }
.primary:hover, .secondary:hover, .danger:hover { transform: translateY(-1px); filter: brightness(.98); }
.primary[disabled], .secondary[disabled], .danger[disabled] { cursor: not-allowed; opacity: .45; transform: none; }
.small { min-height: 44px; padding: 0 14px; font-size: 14px; }

:focus-visible { outline: none; box-shadow: var(--focus); }
.hero :focus-visible { box-shadow: 0 0 0 3px var(--green), 0 0 0 6px var(--lime); }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, main:focus { outline: none; box-shadow: none; }

.notice { margin-top: 15px; padding: 14px 16px; color: var(--muted); background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; }
.notice strong { color: var(--ink); }
.inline-msg { padding: 12px 14px; background: var(--amber-soft); border: 1px solid #efd48a; border-radius: 12px; font-size: 14px; font-weight: 650; }
.inline-msg.ok { background: var(--success-soft); border-color: #b9e0c8; }
.inline-msg.err { background: var(--red-soft); border-color: #f1c2bc; color: #7a1d17; }

/* Cards */
.card { margin-top: 18px; padding: 24px; background: var(--paper); border: 1px solid rgba(18,55,42,.08); border-radius: var(--radius); box-shadow: var(--shadow); }
.card h2 { margin: 0; font-size: clamp(22px, 5vw, 31px); line-height: 1.15; letter-spacing: -.035em; }
.card h3 { margin: 24px 0 10px; font-size: 18px; letter-spacing: -.02em; }
.lead { margin: 8px 0 0; color: var(--muted); }

/* Quiz */
.progress-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: center; color: var(--muted); font-size: 13px; font-weight: 800; }
.progress-track { height: 9px; margin: 12px 0 18px; background: #e5e9e3; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--green-2); border-radius: inherit; transition: width .24s ease; }
.timer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 16px; padding: 10px 14px; background: #f3f5f0; border: 1px solid var(--line); border-radius: 12px; }
.timer strong { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--green); letter-spacing: -.01em; }
.timer span { color: var(--muted); font-size: 12px; font-weight: 750; }
.timer.low { background: var(--red-soft); border-color: #f1c2bc; }
.timer.low strong { color: var(--red); }
.category { display: inline-block; margin-bottom: 10px; padding: 6px 9px; color: var(--green); background: #ecf4e9; border-radius: 8px; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.helper { margin: 9px 0 20px; color: var(--muted); font-size: 14px; }
.sign-visual { display: grid; place-items: center; min-height: 190px; margin: 0 0 20px; padding: 16px; background: #f5f7f3; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.sign-visual img { display: block; width: auto; max-width: min(100%, 250px); height: 160px; object-fit: contain; }
.sign-visual.road img, .sign-visual.diagram img { max-width: min(100%, 360px); border-radius: 10px; }
.sign-visual img { height: 160px; }
.sign-visual.diagram img { width: 100%; max-width: 560px; height: auto; max-height: 440px; }
.sign-visual.small { min-height: 0; margin: 8px 0; padding: 10px; background: white; }
.sign-visual.small img { height: 96px; }
.sign-visual.small.diagram img { height: auto; max-height: 240px; max-width: 360px; }
.options { display: grid; gap: 11px; }
.option { width: 100%; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; min-height: 60px; padding: 10px 14px; color: var(--ink); text-align: left; background: white; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; transition: border-color .14s ease, background .14s ease, transform .14s ease; }
.option:hover { border-color: #8da598; transform: translateY(-1px); }
.option[aria-checked="true"] { border-color: var(--green); background: #f0f7ef; box-shadow: inset 0 0 0 1px var(--green); }
.option:focus-visible { box-shadow: var(--focus); }
.letter { display: grid; place-items: center; width: 30px; height: 30px; color: var(--green); background: #edf2ed; border-radius: 9px; font-weight: 900; }
.option[aria-checked="true"] .letter { color: white; background: var(--green); }
.option-text { font-weight: 720; }
.quiz-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; }
.leave-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.leave-bar p { flex: 1 1 220px; margin: 0; }

/* Results */
.result-head { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.score-ring { display: grid; place-items: center; width: 98px; height: 98px; color: white; background: var(--green); border: 8px solid var(--lime); border-radius: 50%; font-size: 22px; font-weight: 900; }
.result-head p { margin: 4px 0 0; color: var(--muted); }
.breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 22px 0; }
.breakdown div { padding: 13px; background: #f3f5f0; border-radius: 12px; }
.breakdown strong, .breakdown span { display: block; }
.breakdown strong { font-size: 19px; }
.breakdown span { color: var(--muted); font-size: 12px; font-weight: 750; }
.verdict { display: inline-block; margin-top: 7px; padding: 3px 8px; border-radius: 7px; font-size: 12px; font-style: normal; font-weight: 900; }
.verdict.pass { color: #0f5e33; background: var(--success-soft); }
.verdict.fail { color: #8f1d24; background: var(--red-soft); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.save-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.review { margin-top: 26px; }
.review h3 { font-size: 18px; }
.review-item { margin-top: 12px; padding: 16px; border-radius: 14px; border-left: 5px solid var(--success); background: var(--success-soft); }
.review-item.wrong { border-left-color: var(--red); background: var(--red-soft); }
.review-item h4 { margin: 0 0 8px; font-size: 15px; }
.review-item p { margin: 5px 0 0; font-size: 13px; }
.review-item b { color: var(--ink); }
.sources { margin-top: 17px; font-size: 12px; color: var(--muted); }
.sources a, .credit a { color: var(--green); font-weight: 800; }
.credit { margin: 18px 4px 0; font-size: 12px; color: var(--muted); }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 18px; }
.tile { padding: 14px; background: #f3f5f0; border-radius: 14px; }
.tile strong { display: block; font-size: 24px; letter-spacing: -.02em; }
.tile span { color: var(--muted); font-size: 12px; font-weight: 800; }
.chart-wrap { margin-top: 8px; padding: 12px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: #e5e9e3; stroke-width: 1; }
.chart-target { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-line { fill: none; stroke: var(--green-2); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--green-2); stroke: white; stroke-width: 2; }
.chart-label { fill: var(--muted); font-size: 11px; font-weight: 700; }
.bars { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 12px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.bar-row.weak { border-color: #f1c2bc; background: var(--red-soft); }
.bar-row .name { font-weight: 800; font-size: 14px; }
.bar-row .pct { font-weight: 850; font-variant-numeric: tabular-nums; font-size: 14px; }
.bar-row .track { grid-column: 1 / -1; height: 8px; background: #e5e9e3; border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--green-2); border-radius: inherit; }
.bar-row.weak .fill { background: var(--red); }
.bar-row .meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 700; }
.weak-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; color: #8f1d24; background: white; border-radius: 6px; font-size: 11px; font-weight: 900; }
.attempts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.attempt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 14px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.attempt .mode { font-weight: 850; }
.attempt .when { color: var(--muted); font-size: 12px; font-weight: 700; }
.attempt .score { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; }
.attempt .chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { padding: 2px 8px; border-radius: 7px; font-size: 12px; font-weight: 850; }
.chip.pass { color: #0f5e33; background: var(--success-soft); }
.chip.fail { color: #8f1d24; background: var(--red-soft); }
.muted { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Sign library */
.lib-search { margin-top: 16px; max-width: 420px; }
.lib-search input { min-height: 48px; padding: 0 14px; color: var(--ink); background: white; border: 1.5px solid var(--line); border-radius: 12px; }
.lib-count { margin: 10px 0 0; color: var(--muted); font-size: 13px; font-weight: 750; }
.lib-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; color: var(--green); background: #ecf4e9; border-radius: 10px; font-size: 13px; font-weight: 850; text-decoration: none; }
.lib-group h3 { scroll-margin-top: 12px; }
.lib-n { font-size: 14px; font-weight: 700; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.lib-card { display: grid; grid-template-rows: auto auto 1fr; align-content: start; gap: 4px; width: 100%; height: 100%; min-height: 44px; padding: 10px; color: var(--ink); text-align: left; background: white; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; transition: border-color .14s ease, transform .14s ease; }
.lib-card:hover { border-color: #8da598; transform: translateY(-1px); }
.lib-img { display: grid; place-items: center; height: 96px; background: #f5f7f3; border-radius: 10px; }
.lib-img img { max-width: 90%; max-height: 84px; object-fit: contain; }
.lib-code { color: var(--green); font-size: 12px; font-weight: 900; letter-spacing: .04em; }
.lib-name { font-size: 13px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sign-visual.lib-big { margin-top: 16px; }
.sign-visual.lib-big img { height: 220px; max-width: min(100%, 300px); }
.sign-visual.lib-big.road img { max-width: min(100%, 420px); }

/* Account */
.form { display: grid; gap: 14px; max-width: 420px; margin-top: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 850; font-size: 14px; }
.field input { min-height: 48px; padding: 0 14px; color: var(--ink); background: white; border: 1.5px solid var(--line); border-radius: 12px; }
.field input:focus-visible { border-color: var(--green-2); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tabs button[aria-pressed="true"] { color: white; background: var(--green); border-color: var(--green); }
.privacy { margin-top: 16px; padding: 14px 16px; background: #f3f5f0; border-radius: 14px; font-size: 14px; }
.privacy p { margin: 0; }
.danger-zone { margin-top: 26px; padding: 16px; border: 1.5px solid #f1c2bc; border-radius: 14px; }
.danger-zone h3 { margin-top: 0; }

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 760px); padding-top: 14px; }
  .hero { padding: 24px 20px; border-radius: 22px; }
  .hero::after { width: 180px; height: 180px; right: -82px; top: -90px; }
  .card { padding: 19px 16px; }
  .result-head { grid-template-columns: 1fr; }
  .score-ring { width: 86px; height: 86px; }
  .quiz-actions { align-items: stretch; }
  .quiz-actions button { flex: 1; }
  .hero .result-actions > * { flex: 1 1 100%; }
}

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