:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #eef1ef;
  --text: #1d2726;
  --muted: #5b6866;
  --line: #d9dedb;
  --primary: #1f5f6b;
  --primary-ink: #ffffff;
  --primary-soft: #dcebec;
  --accent: #b86b12;
  --ok: #1e7a46;
  --ok-soft: #e1f2e7;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --warn-soft: #fbf0dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 30, .06), 0 4px 16px rgba(20, 30, 30, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111817;
    --surface: #18211f;
    --surface-2: #1f2a28;
    --text: #e6ecea;
    --muted: #9aa8a5;
    --line: #2d3a37;
    --primary: #5fb3bf;
    --primary-ink: #0d1716;
    --primary-soft: #1d3a3e;
    --accent: #e3a45a;
    --ok: #5cc98a;
    --ok-soft: #173325;
    --bad: #f08a80;
    --bad-soft: #3a1e1c;
    --warn-soft: #3a2f1b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 17px; line-height: 1.5;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hidden { display: none !important; }

/* ---------- layout */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand span { font-size: 1rem; }
.topnav { margin-left: auto; display: flex; gap: 4px; }
.topnav a {
  text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 10px; font-size: .95rem;
}
.topnav a.active, .topnav a:hover { background: var(--primary-soft); color: var(--text); }
main { max-width: 960px; margin: 0 auto; padding: 20px 16px 110px; }
footer.site { max-width: 960px; margin: 0 auto; padding: 8px 16px 100px; color: var(--muted); font-size: .85rem; }
footer.site a { color: var(--muted); margin-right: 14px; }

.tabbar { display: none; }
@media (max-width: 720px) {
  .topnav { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px;
    text-decoration: none; color: var(--muted); font-size: .72rem;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--primary); font-weight: 600; }
  body { font-size: 16px; }
  h1 { font-size: 1.4rem; }
}

/* ---------- components */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile .num { font-size: 1.7rem; font-weight: 700; }
.tile .lbl { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 600;
  background: var(--primary); color: var(--primary-ink); cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--primary); border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

.action-card {
  display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.action-card:hover { border-color: var(--primary); }
.action-card .t { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.action-card .d { color: var(--muted); font-size: .92rem; margin-top: 4px; }
.badge {
  display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 99px;
  background: var(--primary-soft); color: var(--text);
}
.badge.warn { background: var(--warn-soft); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=search], select {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); min-height: 48px;
}
input:focus, select:focus, .btn:focus-visible, .opt:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 1px; border-color: var(--primary); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; font-size: .95rem; }
.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; accent-color: var(--primary); }
.challenge { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); margin-bottom: 14px; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.field-error { color: var(--bad); font-size: .9rem; margin-top: 4px; }

.hero { padding: 8px 0 10px; }
.hero h1 { font-size: 1.9rem; }
@media (max-width: 720px) { .hero h1 { font-size: 1.5rem; } }
.indep { font-size: .85rem; color: var(--muted); border-left: 0; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }

/* ---------- questions */
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem; padding: 6px 12px; border-radius: 10px; background: var(--surface-2); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.qstem { font-size: 1.08rem; font-weight: 600; margin: 6px 0 14px; }
.qhint { font-size: .9rem; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; min-height: 52px;
}
.opt .letter {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  font-size: .9rem; background: var(--surface-2);
}
.opt.multi .letter { border-radius: 7px; }
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.sel .letter { background: var(--primary); color: var(--primary-ink); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .letter { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.explain { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.explain .verdict { font-weight: 700; margin-bottom: 4px; }
.explain .verdict.ok { color: var(--ok); }
.explain .verdict.bad { color: var(--bad); }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; margin: 12px 0; }
.navgrid button {
  min-height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: .85rem; cursor: pointer;
}
.navgrid button.answered { background: var(--primary-soft); border-color: var(--primary); }
.navgrid button.current { outline: 2px solid var(--primary); font-weight: 700; }
.navgrid button.ok { background: var(--ok-soft); border-color: var(--ok); }
.navgrid button.bad { background: var(--bad-soft); border-color: var(--bad); }
.progressbar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progressbar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }

.score {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.score .big { font-size: 3rem; font-weight: 800; line-height: 1; }
.score .verdict { font-size: 1.2rem; font-weight: 700; }
.score .verdict.ok { color: var(--ok); }
.score .verdict.bad { color: var(--bad); }
.result-item { border-top: 1px solid var(--line); padding: 14px 0; }
.result-item:first-child { border-top: 0; }
.result-item .mini-opts { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: .95rem; }
.result-item .mini-opts li { padding: 6px 10px; border-radius: 8px; }
.result-item .mini-opts li.right { background: var(--ok-soft); }
.result-item .mini-opts li.wrong { background: var(--bad-soft); }

.chapter-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.chapter-row:first-child { border-top: 0; }
.chapter-row .name { font-weight: 600; }
.chapter-row .meta { color: var(--muted); font-size: .85rem; grid-column: 1 / -1; }

/* ---------- atlas */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 99px; padding: 6px 12px;
  font: inherit; font-size: .88rem; cursor: pointer; min-height: 36px;
}
.chip.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.atlas-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.atlas-card { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.atlas-card:hover { border-color: var(--primary); }
.atlas-card .code { font-size: .8rem; font-weight: 700; color: var(--primary); }
.atlas-card .nm { font-weight: 700; margin: 2px 0 4px; }
.atlas-card .kz { font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.profile-head .code { display: inline-block; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 3px 10px; border-radius: 8px; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 16px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; font: inherit; color: var(--muted); padding: 10px 12px; cursor: pointer; border-bottom: 3px solid transparent;
  white-space: nowrap; font-weight: 600; flex: 1 1 auto;
}
@media (max-width: 420px) { .tabs button { padding: 10px 6px; font-size: .92rem; } }
.tabs button.active { color: var(--text); border-bottom-color: var(--primary); }
ul.symptoms { padding: 0; margin: 0; list-style: none; display: grid; gap: 8px; }
ul.symptoms li { padding: 10px 12px 10px 38px; position: relative; background: var(--surface-2); border-radius: 10px; }
ul.symptoms li::before {
  content: ""; position: absolute; left: 14px; top: 17px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
}
.merksatz { background: var(--warn-soft); border-radius: 12px; padding: 12px 14px; margin-top: 14px; }
.merksatz b { display: block; margin-bottom: 2px; }

.course svg { width: 100%; height: auto; display: block; }
.course .area { fill: var(--primary); opacity: 0; transition: opacity .8s .6s; }
.course .line { fill: none; stroke: var(--primary); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.course .grid-line { stroke: var(--line); stroke-width: 1; }
.course .axis-label { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.course .dot { fill: var(--surface); stroke: var(--primary); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; }
.course .dot-num { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); opacity: 0; }
.course.play .area { opacity: .16; }
.course.play .dot, .course.play .dot-num { animation: pop .35s ease-out forwards; }
.course .dot.active { fill: var(--primary); }
.course .dot.active + .dot-num { fill: var(--primary-ink); }
.course svg { max-width: 560px; margin: 0 auto; }
@keyframes pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
.phase-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.phase-list li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px; border-radius: 10px; background: var(--surface-2); cursor: pointer; border: 2px solid transparent; }
.phase-list li.active { border-color: var(--primary); }
.phase-list .pn { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.phase-list .pl { font-weight: 700; }
.phase-list .pd { font-size: .82rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .course .line { transition: none !important; }
  .course .dot, .course .dot-num { animation: none !important; opacity: 1; }
  .progressbar > i { transition: none; }
}

.compare { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .93rem; }
.compare th, .compare td { text-align: left; vertical-align: top; padding: 10px; border-bottom: 1px solid var(--line); }
.compare thead th { background: var(--surface-2); position: sticky; top: 0; }
.compare th[scope=row] { color: var(--muted); font-weight: 600; width: 22%; }
@media (max-width: 560px) {
  .compare, .compare thead, .compare tbody, .compare tr, .compare th, .compare td { display: block; width: auto; }
  .compare thead { display: none; }
  .compare tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
  .compare th[scope=row] { background: var(--surface-2); width: auto; border-bottom: 0; padding: 8px 10px; }
  .compare td { border-bottom: 0; padding: 8px 10px; }
  .compare td::before { content: attr(data-label); display: block; font-size: .78rem; font-weight: 700; color: var(--primary); }
}
.cmp-list { margin: 0; padding-left: 18px; }
.cmp-list li { margin-bottom: 3px; }
.diff { background: var(--primary-soft); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* legal pages */
.legal { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }
.legal h2 { margin-top: 1.4em; }
.placeholder { background: var(--warn-soft); padding: 1px 6px; border-radius: 6px; font-weight: 700; }
