/* ============================================================
   Keemia Kompass — õppeveeb
   soe, rahulik, ajakirjalik stiil.
   Väliseid fonte ega pilte ei laadita.
   ============================================================ */

:root {
  --bg: #f4f1e8;
  --surface: #fffdf7;
  --surface-2: #faf7ee;
  --ink: #14231d;
  --muted: #637168;
  --green: #0c6b52;
  --green-dark: #08503d;
  --lime: #d9f36a;
  --amber: #c26a16;
  --red: #c75245;
  --line: rgba(20, 35, 29, 0.12);
  --line-strong: rgba(20, 35, 29, 0.22);
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 18px 40px -24px rgba(20, 35, 29, 0.35);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 85% -5%, rgba(217, 243, 106, 0.16), transparent 70%),
    radial-gradient(ellipse 50% 35% at 0% 10%, rgba(12, 107, 82, 0.05), transparent 70%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: rgba(12, 107, 82, 0.18); }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
  border-radius: 6px;
}

.container {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(244, 241, 232, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--lime);
  font-size: 17px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav__link {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav__link:hover { color: var(--ink); text-decoration: none; background: rgba(20, 35, 29, 0.05); }
.nav__link[aria-current="page"] { color: var(--ink); background: rgba(20, 35, 29, 0.07); }

.nav__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.header-progress {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}
.header-progress .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 26px -14px rgba(12, 107, 82, 0.7);
}
.btn--primary:hover { background: var(--green-dark); }

.btn--lime {
  background: var(--lime);
  color: var(--ink);
  box-shadow: 0 12px 26px -16px rgba(20, 35, 29, 0.5);
}
.btn--lime:hover { background: #cdeb4d; }

.btn--ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}
.btn--ghost:hover { background: rgba(20, 35, 29, 0.05); }

.btn--soft {
  background: rgba(20, 35, 29, 0.06);
  color: var(--ink);
}
.btn--soft:hover { background: rgba(20, 35, 29, 0.1); }

.btn--small { padding: 8px 15px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- hero ---------- */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 40px;
  align-items: center;
  padding: 64px 0 36px;
}

.hero__kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 18px;
}
.hero__kicker::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--lime);
  border-radius: 2px;
}

.hero__title {
  font-family: var(--serif);
  font-size: clamp(44px, 6.4vw, 72px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -1.5px;
  margin-bottom: 18px;
}
.hero__title em {
  font-style: italic;
  color: var(--green);
  position: relative;
  white-space: nowrap;
}
.hero__title em::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 4px;
  height: 0.32em;
  background: var(--lime);
  z-index: -1;
  border-radius: 3px;
}

.hero__sub {
  font-size: 17px;
  color: var(--muted);
  max-width: 54ch;
  margin-bottom: 28px;
}

.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; }

.hero__panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.ring-wrap { position: relative; width: 230px; height: 230px; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 12; }
.ring-value {
  fill: none;
  stroke: var(--green);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.ring-center strong {
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1;
  letter-spacing: -1px;
}
.ring-center span { font-size: 13px; color: var(--muted); margin-top: 6px; }

.orbit {
  position: absolute;
  border: 1px dashed rgba(12, 107, 82, 0.25);
  border-radius: 50%;
  animation: orbit-glow 5s ease-in-out infinite;
  pointer-events: none;
}
.orbit--1 { width: 286px; height: 286px; }
.orbit--2 { width: 344px; height: 344px; animation-delay: 1.6s; opacity: 0.55; }
.orbit::after {
  content: "";
  position: absolute;
  top: 8%;
  left: 18%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  opacity: 0.6;
}

@keyframes orbit-glow {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 10px 0 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat__num {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.stat__label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat--accent .stat__num { color: var(--green); }

/* ---------- sections ---------- */

.section { padding-top: 56px; }
.section--tight { padding-top: 34px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: clamp(26px, 3.4vw, 34px);
  letter-spacing: -0.6px;
  line-height: 1.15;
}
.section-head p { color: var(--muted); font-size: 15px; margin-top: 6px; max-width: 62ch; }

/* ---------- dashboard cards ---------- */

.dash-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.card--flat { box-shadow: none; }

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title h3 {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: -0.3px;
}
.card-title .hint { font-size: 12.5px; color: var(--muted); }

.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); }
.chart-grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart-area { fill: rgba(12, 107, 82, 0.08); }
.chart-line { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--green); }
.chart-dot:last-child { fill: var(--lime); stroke: var(--green); stroke-width: 2; }

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-s);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.weak-list { display: flex; flex-direction: column; gap: 10px; }
.weak-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.weak-item:hover { border-color: var(--line-strong); background: var(--surface); text-decoration: none; }
.weak-item__icon {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: rgba(20, 35, 29, 0.06);
  font-size: 17px;
  flex: none;
}
.weak-item__body { min-width: 0; flex: 1; }
.weak-item__body strong { display: block; font-size: 14.5px; color: var(--ink); }
.weak-item__body span { font-size: 12.5px; color: var(--muted); }
.weak-item__pct {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--amber);
}

/* ---------- topic grid ---------- */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.topic-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.topic-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent, var(--green));
}
.topic-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.topic-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 23px;
}
.topic-card__num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}
.topic-card__icon {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: rgba(20, 35, 29, 0.05);
  font-size: 20px;
}

.topic-card h3 {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.3;
  margin-bottom: 6px;
}
.topic-card p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 18px;
}

.topic-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 12px;
  color: var(--muted);
}
.topic-card__status { font-weight: 700; }
.topic-card__status--done { color: var(--green); }
.topic-card__status--started { color: var(--amber); }
.topic-card__best { font-family: var(--mono); display: inline-flex; align-items: center; gap: 6px; }

.level { display: inline-flex; align-items: center; gap: 3px; }
.level__pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(20, 35, 29, 0.14);
}
.level__pip--on { background: var(--green); }

.chip--level { gap: 8px; }
.chip--level .level { margin-right: 2px; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(20, 35, 29, 0.08);
  overflow: hidden;
}
.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent, var(--green));
  transition: width 0.5s ease;
}

/* ---------- promo row ---------- */

.promo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-top: 18px;
}

.promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.promo h3 { font-family: var(--serif); font-size: 20px; letter-spacing: -0.3px; margin-bottom: 3px; }
.promo p { font-size: 13.5px; color: var(--muted); }
.promo--mistakes { border-color: rgba(199, 82, 69, 0.3); background: #fdf4f0; }
.promo--mistakes h3 { color: var(--red); }

/* ---------- topic page ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin: 30px 0 18px;
}
.back-link:hover { color: var(--ink); text-decoration: none; }

.topic-hero {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.topic-hero__icon {
  width: 58px; height: 58px;
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 16px;
  font-size: 27px;
  background: rgba(20, 35, 29, 0.06);
  border: 1px solid var(--line);
}
.topic-hero h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 4.2vw, 42px);
  letter-spacing: -0.9px;
  line-height: 1.1;
  margin-bottom: 8px;
}
.topic-hero p { color: var(--muted); max-width: 70ch; font-size: 15.5px; }

.topic-hero__meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.chip--done { color: var(--green); border-color: rgba(12, 107, 82, 0.3); background: rgba(12, 107, 82, 0.06); }
.chip--best { font-family: var(--mono); }

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  padding-top: 26px;
  align-items: start;
}

.lesson-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 14px;
}
.lesson-card h3 {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: -0.3px;
  margin-bottom: 10px;
}
.lesson-card p { margin-bottom: 10px; font-size: 15px; }
.lesson-card p:last-child { margin-bottom: 0; }
.lesson-card ul, .lesson-card ol { padding-left: 22px; margin: 8px 0; }
.lesson-card li { margin-bottom: 6px; font-size: 15px; }
.lesson-card strong { color: var(--green-dark); }

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 86px;
}

.formula-card {
  background: var(--ink);
  color: #f4f1e8;
  border-radius: var(--radius);
  padding: 22px;
}
.formula-card h3 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--lime);
  margin-bottom: 14px;
}
.formula-card ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.formula-card li {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.45;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(244, 241, 232, 0.12);
}
.formula-card li:last-child { border-bottom: none; padding-bottom: 0; }

.example-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.example-card h3 { font-family: var(--serif); font-size: 19px; margin-bottom: 4px; }
.example-card .example-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 14px; }
.example-card ol { padding-left: 20px; }
.example-card li { font-size: 14.5px; margin-bottom: 8px; }
.example-answer {
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: var(--radius-s);
  background: rgba(217, 243, 106, 0.28);
  border: 1px solid rgba(12, 107, 82, 0.18);
  font-size: 14px;
}
.example-answer strong { color: var(--green-dark); }

.side-cta {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.side-cta p { font-size: 13.5px; color: var(--muted); margin: 6px 0 14px; }

.next-topic {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 26px 0 0;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.next-topic span { font-size: 13px; color: var(--muted); }
.next-topic strong { font-size: 15px; }

/* ---------- quiz ---------- */

.quiz-wrap { max-width: 780px; margin: 0 auto; padding: 40px 0 10px; }

.quiz-head { margin-bottom: 18px; }
.quiz-head__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.quiz-head__label { font-family: var(--mono); font-size: 12.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.quiz-head__score { font-size: 13.5px; font-weight: 700; color: var(--green); }

.quiz-progress { height: 8px; border-radius: 999px; background: rgba(20, 35, 29, 0.08); overflow: hidden; }
.quiz-progress__fill { height: 100%; background: var(--green); border-radius: 999px; transition: width 0.35s ease; }

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  margin-top: 22px;
}

.quiz-topic-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 0;
}

.quiz-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.quiz-level {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-2);
}

.quiz-question {
  font-family: var(--serif);
  font-size: clamp(21px, 3vw, 27px);
  line-height: 1.3;
  letter-spacing: -0.4px;
  margin-bottom: 22px;
}

.options { display: flex; flex-direction: column; gap: 10px; }

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.14s ease;
}
.option:hover { border-color: var(--green); background: rgba(12, 107, 82, 0.03); }
.option__letter {
  flex: none;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(20, 35, 29, 0.06);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}
.option--selected { border-color: var(--green); background: rgba(12, 107, 82, 0.06); }
.option--selected .option__letter { background: var(--green); color: #fff; }

.option--correct { border-color: var(--green); background: rgba(12, 107, 82, 0.1); }
.option--correct .option__letter { background: var(--green); color: #fff; }
.option--wrong { border-color: var(--red); background: rgba(199, 82, 69, 0.08); }
.option--wrong .option__letter { background: var(--red); color: #fff; }
.option--muted { opacity: 0.6; }
.option[disabled] { cursor: default; }

/* ---------- numbriline vastus ja lüngad ---------- */

.answer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.answer-input {
  width: 180px;
  max-width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.answer-input::placeholder { color: #a3ada4; font-weight: 400; font-size: 15px; letter-spacing: 0; }
.answer-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(12, 107, 82, 0.14);
}
.answer-input--ok { border-color: var(--green); background: rgba(12, 107, 82, 0.07); }
.answer-input--bad { border-color: var(--red); background: rgba(199, 82, 69, 0.07); }
.answer-input[disabled] { opacity: 0.9; cursor: default; }

.answer-unit {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--muted);
}

.gaps-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  font-family: var(--mono);
  font-size: clamp(16px, 2.6vw, 20px);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.2px;
  padding: 6px 0;
}

.gap-seg { white-space: pre-wrap; }

.gap-input {
  width: 52px;
  margin: 3px 4px;
  padding: 7px 2px;
  text-align: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.gap-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(12, 107, 82, 0.14);
}
.gap-input--ok { border-color: var(--green); background: rgba(12, 107, 82, 0.08); }
.gap-input--bad { border-color: var(--red); background: rgba(199, 82, 69, 0.08); }
.gap-input[disabled] { opacity: 0.9; cursor: default; }

.feedback {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14.5px;
}
.feedback--correct { border-color: rgba(12, 107, 82, 0.35); background: rgba(12, 107, 82, 0.06); }
.feedback--wrong { border-color: rgba(199, 82, 69, 0.35); background: rgba(199, 82, 69, 0.06); }
.feedback__title { font-weight: 800; margin-bottom: 4px; }
.feedback--correct .feedback__title { color: var(--green); }
.feedback--wrong .feedback__title { color: var(--red); }

.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.quiz-actions__hint { font-size: 13px; color: var(--muted); }

/* ---------- result ---------- */

.result-wrap { max-width: 820px; margin: 0 auto; padding: 40px 0 10px; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px;
  text-align: center;
}

.result-ring { position: relative; width: 190px; height: 190px; margin: 0 auto 18px; }
.result-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.result-ring .ring-track { stroke-width: 13; }
.result-ring .ring-value { stroke-width: 13; }
.result-ring__center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.result-ring__center strong { font-family: var(--serif); font-size: 40px; letter-spacing: -1px; line-height: 1; }
.result-ring__center span { color: var(--muted); font-size: 13px; margin-top: 4px; }

.result-title { font-family: var(--serif); font-size: clamp(26px, 3.6vw, 34px); letter-spacing: -0.6px; margin-bottom: 8px; }
.result-lead { color: var(--muted); font-size: 15.5px; max-width: 58ch; margin: 0 auto 20px; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.review { margin-top: 26px; text-align: left; }
.review h3 { font-family: var(--serif); font-size: 21px; margin-bottom: 12px; }

.review-item {
  display: flex;
  gap: 13px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  margin-bottom: 9px;
}
.review-item__mark {
  flex: none;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}
.review-item--correct .review-item__mark { background: rgba(12, 107, 82, 0.12); color: var(--green); }
.review-item--wrong .review-item__mark { background: rgba(199, 82, 69, 0.12); color: var(--red); }
.review-item__body { font-size: 14px; }
.review-item__body strong { display: block; margin-bottom: 3px; font-size: 14.5px; }
.review-item__body span { color: var(--muted); }
.review-item__body .correct-line { color: var(--green); }

/* ---------- custom builder ---------- */

.builder-wrap { max-width: 880px; margin: 0 auto; padding: 40px 0 10px; }
.builder-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.builder-card h1 { font-family: var(--serif); font-size: clamp(30px, 4vw, 40px); letter-spacing: -0.8px; margin-bottom: 8px; }
.builder-card > p { color: var(--muted); margin-bottom: 24px; max-width: 64ch; }

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
  margin: 22px 0 10px;
}

.topic-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.topic-check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.topic-check:hover { background: var(--surface-2); }
.topic-check input { position: absolute; opacity: 0; pointer-events: none; }
.topic-check__box {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  transition: all 0.14s ease;
}
.topic-check input:checked + .topic-check__box {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.topic-check input:focus-visible + .topic-check__box { outline: 3px solid var(--green); outline-offset: 2px; }
.topic-check strong { font-weight: 600; }
.topic-check .tc-icon { margin-left: auto; font-size: 16px; opacity: 0.8; }

.count-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.count-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.count-pill {
  padding: 9px 17px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.14s ease;
}
.count-pill:hover { border-color: var(--green); }
.count-pill--active { background: var(--ink); border-color: var(--ink); color: var(--lime); }

.builder-summary {
  margin-top: 24px;
  padding: 15px 17px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  font-size: 14px;
  color: var(--muted);
}
.builder-summary strong { color: var(--ink); }
.builder-actions { margin-top: 20px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- progress page ---------- */

.progress-wrap { padding: 40px 0 10px; }
.progress-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; margin-top: 22px; }

.attempt-list { display: flex; flex-direction: column; }
.attempt {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.attempt:last-child { border-bottom: none; }
.attempt__date { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 84px; flex: none; }
.attempt__mode { flex: 1; font-weight: 600; }
.attempt__score { font-family: var(--mono); font-weight: 700; }
.attempt__score--pass { color: var(--green); }
.attempt__score--fail { color: var(--red); }

.mastery-list { display: flex; flex-direction: column; gap: 13px; }
.mastery { display: grid; grid-template-columns: 150px 1fr 92px; gap: 12px; align-items: center; font-size: 13.5px; }
.mastery__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mastery__pct { font-family: var(--mono); text-align: right; color: var(--muted); white-space: nowrap; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-grid .stat { padding: 16px 18px; }
.stat-grid .stat__num { font-size: 26px; }

/* ---------- mistakes ---------- */

.mistakes-wrap { padding: 40px 0 10px; max-width: 880px; margin: 0 auto; }
.mistake-group { margin-top: 18px; }
.mistake-group__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.mistake-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  margin-bottom: 7px;
  font-size: 14.5px;
}
.mistake-item__q { flex: 1; }
.mistake-item__q span { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.mistake-item a.btn { align-self: center; }

/* ---------- empty state ---------- */

.empty-state {
  text-align: center;
  padding: 54px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty-state__icon {
  width: 58px; height: 58px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: rgba(12, 107, 82, 0.08);
  font-size: 26px;
}
.empty-state h3 { font-family: var(--serif); font-size: 23px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #f4f1e8;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 16px 40px -12px rgba(20, 35, 29, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}
.toast--visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--line);
  padding: 26px 0 calc(34px + env(safe-area-inset-bottom));
  font-size: 13px;
  color: var(--muted);
}
.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--ink); }
.footer-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.linklike { font: inherit; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; padding: 0; }
.linklike:hover { color: var(--red); }

/* ---------- animations ---------- */

.rise { animation: rise-in 0.45s ease both; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise { animation: none; }
  .orbit { animation: none; }
  .topic-card, .btn { transition: none; }
  .ring-value, .quiz-progress__fill, .bar__fill { transition: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 1060px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .lesson-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 900px) {
  .dash-grid, .progress-grid { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; padding-top: 44px; gap: 30px; }
  .hero__panel { min-height: 250px; }
  .lesson-layout { grid-template-columns: 1fr; }
  .side-stack { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .promo-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .site-header__inner { flex-wrap: wrap; gap: 8px; padding: 10px 0; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .header-progress { margin-left: auto; }
  .topic-picker { grid-template-columns: 1fr; }
  .mastery { grid-template-columns: 110px 1fr 80px; }
}

@media (max-width: 600px) {
  .container { width: calc(100% - 32px); }
  .topic-grid { grid-template-columns: 1fr; }
  .hero__title { font-size: clamp(38px, 10vw, 52px); }
  .quiz-card, .result-card, .builder-card { padding: 22px 18px; }
  .answer-input { width: 150px; font-size: 17px; }
  .gap-input { width: 46px; font-size: 16px; margin: 3px 3px; }
  .lesson-card { padding: 20px 18px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat__num { font-size: 25px; }
  .section { padding-top: 42px; }
  .quiz-actions { flex-direction: column; align-items: stretch; }
  .quiz-actions .btn { width: 100%; }
  .result-actions .btn { width: 100%; }
}

@media (max-width: 380px) {
  .hero__cta .btn { width: 100%; }
  .btn { width: 100%; }
  .promo .btn { width: auto; }
  .quiz-actions .btn { width: 100%; }
  .brand { font-size: 18px; }
}
