/* ============================================================
   Тренажёр ПДД Грузии — оформление
   Тёмная тема по умолчанию, светлая по системной настройке или
   переключателю. Мобильные: нижняя панель навигации.
   ============================================================ */

:root {
  --ink: #eaf0ff;
  --ink-soft: #b6c2e2;
  --ink-mute: #8994b5;
  --bg: #080d1c;
  --bg-2: #101a38;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --surface-solid: #121a33;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);

  --brand: #6d8cff;
  --brand-2: #8b5cf6;
  --brand-ink: #ffffff;
  --cyan: #22d3ee;
  --ok: #2ee08a;
  --ok-dim: rgba(46, 224, 138, 0.14);
  --bad: #ff5d7a;
  --bad-dim: rgba(255, 93, 122, 0.14);
  --warn: #ffb02e;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow: 0 18px 50px -22px rgba(0, 0, 0, 0.75);
  --shadow-soft: 0 8px 26px -18px rgba(0, 0, 0, 0.6);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Inter, Roboto,
    'Helvetica Neue', Arial, sans-serif;

  --tap: 46px;
  --wrap: 1120px;
  --header-h: 66px;
}

html[data-theme='light'],
html[data-theme='auto'] {
  color-scheme: light dark;
}

@media (prefers-color-scheme: light) {
  html[data-theme='auto'] {
    --ink: #101728;
    --ink-soft: #3d4a68;
    --ink-mute: #6a7796;
    --bg: #eef2fd;
    --bg-2: #ffffff;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-2: #ffffff;
    --surface-solid: #ffffff;
    --line: rgba(16, 23, 40, 0.1);
    --line-strong: rgba(16, 23, 40, 0.2);
    --brand: #3f5ce8;
    --brand-2: #7c3aed;
    --ok: #12a361;
    --ok-dim: rgba(18, 163, 97, 0.12);
    --bad: #e02a4e;
    --bad-dim: rgba(224, 42, 78, 0.1);
    --warn: #b96b00;
    --shadow: 0 20px 46px -26px rgba(20, 32, 70, 0.42);
    --shadow-soft: 0 10px 24px -18px rgba(20, 32, 70, 0.35);
  }
}

html[data-theme='light'] {
  --ink: #101728;
  --ink-soft: #3d4a68;
  --ink-mute: #6a7796;
  --bg: #eef2fd;
  --bg-2: #ffffff;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-2: #ffffff;
  --surface-solid: #ffffff;
  --line: rgba(16, 23, 40, 0.1);
  --line-strong: rgba(16, 23, 40, 0.2);
  --brand: #3f5ce8;
  --brand-2: #7c3aed;
  --ok: #12a361;
  --ok-dim: rgba(18, 163, 97, 0.12);
  --bad: #e02a4e;
  --bad-dim: rgba(224, 42, 78, 0.1);
  --warn: #b96b00;
  --shadow: 0 20px 46px -26px rgba(20, 32, 70, 0.42);
  --shadow-soft: 0 10px 24px -18px rgba(20, 32, 70, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 2.5px solid var(--brand);
  outline-offset: 3px;
  border-radius: 8px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  border-radius: 0 0 12px 0;
}
.skip-link:focus {
  left: 0;
}

/* ---------- фон ---------- */

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 78% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%),
    radial-gradient(900px 600px at 8% 8%, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent 72%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

.app-bg__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}
.app-bg__glow--1 {
  width: 44vw;
  height: 44vw;
  top: -14vw;
  right: -8vw;
  background: color-mix(in srgb, var(--cyan) 30%, transparent);
}
.app-bg__glow--2 {
  width: 38vw;
  height: 38vw;
  bottom: -16vw;
  left: -10vw;
  background: color-mix(in srgb, var(--brand-2) 34%, transparent);
}

/* Дорожная разметка: пунктир по центру, едва заметный */
.app-bg__road {
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image: repeating-linear-gradient(
    to bottom,
    color-mix(in srgb, var(--ink) 12%, transparent) 0 26px,
    transparent 26px 62px
  );
  background-size: 2px 100%;
  background-position: 50% 0;
  background-repeat: no-repeat;
  mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 62%, transparent);
}

/* ---------- шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px) saturate(160%);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 clamp(14px, 3vw, 26px);
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--brand) 80%, transparent);
}
.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand__text strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand__text small {
  font-size: 11.5px;
  color: var(--ink-mute);
}

.topnav {
  display: flex;
  gap: 4px;
  margin-left: 10px;
}
.topnav a {
  padding: 9px 14px;
  border-radius: 11px;
  font-size: 14.5px;
  font-weight: 550;
  color: var(--ink-soft);
  transition: background 0.18s, color 0.18s;
}
.topnav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.topnav a[aria-current='page'] {
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--ink);
}

.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.icon-sun {
  display: none;
}
.icon-moon {
  display: block;
}
html[data-theme='light'] .icon-sun {
  display: block;
}
html[data-theme='light'] .icon-moon {
  display: none;
}
@media (prefers-color-scheme: light) {
  html[data-theme='auto'] .icon-sun {
    display: block;
  }
  html[data-theme='auto'] .icon-moon {
    display: none;
  }
}

/* ---------- основной контейнер ---------- */

.main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(14px, 3vw, 26px) 40px;
}

@media (max-width: 720px) {
  .main {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }
}

.stack {
  display: grid;
  gap: clamp(14px, 2vw, 20px);
}

/* ---------- карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 24px);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.card--flat {
  box-shadow: none;
}

.card__title {
  font-size: 17px;
  margin-bottom: 4px;
}
.card__sub {
  color: var(--ink-mute);
  font-size: 14px;
}

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: var(--brand-ink);
  font-size: 15.5px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.18s, filter 0.18s;
  box-shadow: 0 14px 30px -18px color-mix(in srgb, var(--brand) 90%, transparent);
  text-align: center;
}
.btn:hover {
  filter: brightness(1.07);
}
.btn:active {
  transform: translateY(1px) scale(0.995);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.btn--ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}
.btn--ghost:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  filter: none;
}

.btn--sm {
  min-height: 38px;
  padding: 8px 15px;
  font-size: 14px;
  border-radius: 11px;
}

.btn--lg {
  min-height: 56px;
  padding: 16px 30px;
  font-size: 17px;
  border-radius: 17px;
}

.btn--block {
  width: 100%;
}

.btn--danger {
  background: linear-gradient(140deg, var(--bad), #b3244a);
  box-shadow: none;
}

/* ---------- бейджи и мелочи ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge--ok {
  background: var(--ok-dim);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  color: var(--ok);
}
.badge--bad {
  background: var(--bad-dim);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
  color: var(--bad);
}
.badge--warn {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-color: color-mix(in srgb, var(--warn) 38%, transparent);
  color: var(--warn);
}

.muted {
  color: var(--ink-mute);
}
.small {
  font-size: 13.5px;
}
.nums {
  font-variant-numeric: tabular-nums;
}

/* ---------- главный экран ---------- */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(700px 300px at 88% 0%, color-mix(in srgb, var(--brand) 24%, transparent), transparent 70%),
    var(--surface);
  padding: clamp(20px, 3.4vw, 34px);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: clamp(18px, 3vw, 34px);
  align-items: center;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(25px, 4.4vw, 40px);
  margin-bottom: 12px;
}

.hero__lead {
  color: var(--ink-soft);
  font-size: clamp(14.5px, 1.6vw, 16.5px);
  max-width: 52ch;
  margin-bottom: 20px;
}

.hero__rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

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

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .hero__ring {
    order: -1;
    justify-self: start;
  }
}

/* Кольцо прогресса */
.ring {
  --size: 172px;
  position: relative;
  width: var(--size);
  height: var(--size);
  flex-shrink: 0;
}
.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring__track {
  stroke: var(--line);
}
.ring__value {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 2px;
}
.ring__label b {
  font-size: 30px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.ring__label span {
  font-size: 12px;
  color: var(--ink-mute);
}

@media (max-width: 520px) {
  .ring {
    --size: 132px;
  }
  .ring__label b {
    font-size: 24px;
  }
}

/* Плитки статистики */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.tile__value {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.tile__label {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.tile--ok .tile__value {
  color: var(--ok);
}
.tile--bad .tile__value {
  color: var(--bad);
}

/* Плитки-ссылки на режимы */
.modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.mode {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: transform 0.16s, border-color 0.16s, background 0.16s;
}
.mode:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.mode__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: var(--brand);
}
.mode__icon--warn {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}
.mode__icon--ok {
  background: var(--ok-dim);
  color: var(--ok);
}
.mode h3 {
  font-size: 16px;
  margin-bottom: 3px;
}
.mode p {
  font-size: 13.5px;
  color: var(--ink-mute);
}

/* ---------- заголовок раздела ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.page-head h1 {
  font-size: clamp(22px, 3.2vw, 30px);
}
.page-head p {
  color: var(--ink-mute);
  font-size: 14.5px;
  margin-top: 5px;
}

/* ---------- темы ---------- */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 13px;
}

.topic {
  display: grid;
  gap: 11px;
  padding: 16px 17px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: transform 0.16s, border-color 0.16s, background 0.16s;
}
.topic:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.topic__top {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.topic__num {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.topic__name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.topic__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-mute);
}

.category-card__code {
  display: grid;
  place-items: center;
  min-width: 68px;
  min-height: 52px;
  padding: 7px 10px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.category-card__description {
  display: block;
  margin-top: 4px;
  color: var(--ink-mute);
  font-size: 12.5px;
  line-height: 1.35;
}

.bar {
  height: 7px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), var(--cyan));
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- экран вопроса ---------- */

.quiz {
  display: grid;
  gap: 16px;
}

.quiz-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  display: grid;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
}

.quiz-bar__row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quiz-bar__title {
  font-size: 14.5px;
  font-weight: 650;
}

.quiz-bar__spacer {
  margin-left: auto;
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 16px;
  padding: 6px 12px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.timer--warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.timer--danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 50%, transparent);
  background: var(--bad-dim);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.62;
  }
}

/* Точки прогресса по билету */
.dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.dots__item {
  width: 100%;
  max-width: 26px;
  height: 6px;
  flex: 1 1 8px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.25s, transform 0.25s;
}
.dots__item--ok {
  background: var(--ok);
}
.dots__item--bad {
  background: var(--bad);
}
.dots__item--current {
  background: var(--brand);
  transform: scaleY(1.7);
}

.question-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.question-card__media {
  position: relative;
  background: #05070f;
  display: grid;
  place-items: center;
  cursor: zoom-in;
  border-bottom: 1px solid var(--line);
}
.question-card__media img {
  width: 100%;
  max-height: min(46vh, 420px);
  object-fit: contain;
}

.question-card__body {
  padding: clamp(16px, 2.6vw, 26px);
  display: grid;
  gap: 16px;
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-mute);
}

.question-text {
  font-size: clamp(17px, 2.2vw, 21px);
  font-weight: 620;
  line-height: 1.4;
  letter-spacing: -0.015em;
}

/* Варианты ответа */
.answers {
  display: grid;
  gap: 9px;
}

.answer {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  width: 100%;
  min-height: var(--tap);
  padding: 13px 15px;
  border-radius: 15px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font-size: 15.5px;
  line-height: 1.45;
  transition: border-color 0.16s, background 0.16s, transform 0.12s;
}
.answer:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--brand) 55%, transparent);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}
.answer:active:not(:disabled) {
  transform: scale(0.995);
}
.answer:disabled {
  cursor: default;
}

.answer__num {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.answer__text {
  flex: 1;
}

.answer__mark {
  flex-shrink: 0;
  display: none;
  font-size: 19px;
  line-height: 1.35;
}

.answer--correct {
  border-color: color-mix(in srgb, var(--ok) 65%, transparent);
  background: var(--ok-dim);
}
.answer--correct .answer__num {
  background: var(--ok);
  border-color: var(--ok);
  color: #04150c;
}
.answer--correct .answer__mark {
  display: block;
  color: var(--ok);
}

.answer--wrong {
  border-color: color-mix(in srgb, var(--bad) 65%, transparent);
  background: var(--bad-dim);
}
.answer--wrong .answer__num {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.answer--wrong .answer__mark {
  display: block;
  color: var(--bad);
}

.answer--dim {
  opacity: 0.55;
}

/* Пояснение */
.explain {
  border-radius: 17px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 15px 17px;
  display: grid;
  gap: 11px;
  animation: rise 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
}

.explain__verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}
.explain__verdict--ok {
  color: var(--ok);
}
.explain__verdict--bad {
  color: var(--bad);
}

.explain__short {
  font-size: 15.5px;
  line-height: 1.5;
}

.explain__law {
  font-size: 14.5px;
  line-height: 1.62;
  color: var(--ink-soft);
  padding-left: 13px;
  border-left: 3px solid color-mix(in srgb, var(--brand) 50%, transparent);
  white-space: pre-wrap;
}

.explain details summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  min-height: 32px;
}
.explain details summary::-webkit-details-marker {
  display: none;
}
.explain details summary::before {
  content: '▸';
  transition: transform 0.2s;
}
.explain details[open] summary::before {
  transform: rotate(90deg);
}
.explain details > div {
  padding-top: 9px;
}

.explain__progress {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--ink-mute);
  padding-top: 3px;
}

.streak-dots {
  display: inline-flex;
  gap: 4px;
}
.streak-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  display: block;
}
.streak-dots i.on {
  background: var(--ok);
}

.quiz-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- результат ---------- */

.verdict {
  display: grid;
  gap: 18px;
  place-items: center;
  text-align: center;
  padding: clamp(24px, 4vw, 40px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.verdict--passed {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: radial-gradient(600px 260px at 50% 0%, var(--ok-dim), transparent 70%), var(--surface);
}
.verdict--failed {
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: radial-gradient(600px 260px at 50% 0%, var(--bad-dim), transparent 70%), var(--surface);
}
.verdict h1 {
  font-size: clamp(26px, 4.6vw, 38px);
}
.verdict__icon {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 38px;
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}
.verdict--passed .verdict__icon {
  background: var(--ok-dim);
  color: var(--ok);
}
.verdict--failed .verdict__icon {
  background: var(--bad-dim);
  color: var(--bad);
}

.verdict__stats {
  display: flex;
  gap: clamp(14px, 3vw, 34px);
  flex-wrap: wrap;
  justify-content: center;
}
.verdict__stat b {
  display: block;
  font-size: 27px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.verdict__stat span {
  font-size: 12.5px;
  color: var(--ink-mute);
}

/* Разбор списком */
.review {
  display: grid;
  gap: 9px;
}
.review__item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.review__head {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 13px 15px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.review__badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}
.review__badge--ok {
  background: var(--ok-dim);
  color: var(--ok);
}
.review__badge--bad {
  background: var(--bad-dim);
  color: var(--bad);
}
.review__badge--skip {
  background: var(--surface-2);
  color: var(--ink-mute);
}
.review__q {
  flex: 1;
  font-size: 14.5px;
  line-height: 1.4;
}
.review__body {
  padding: 0 15px 15px;
  display: grid;
  gap: 12px;
}

/* ---------- профиль и формы ---------- */

.form {
  display: grid;
  gap: 13px;
  max-width: 420px;
}
.field {
  display: grid;
  gap: 6px;
}
.field label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input,
.field select {
  min-height: var(--tap);
  padding: 12px 15px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  font-size: 15.5px;
  transition: border-color 0.16s;
}
.field input:focus,
.field select:focus {
  border-color: var(--brand);
  outline: none;
}
.field__hint {
  font-size: 12.5px;
  color: var(--ink-mute);
}

.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.tabs button {
  min-height: 38px;
  padding: 7px 17px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-mute);
  cursor: pointer;
}
.tabs button[aria-selected='true'] {
  background: var(--brand);
  color: #fff;
}

.form-error {
  font-size: 14px;
  color: var(--bad);
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--bad-dim);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
}

.rows {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--surface-solid);
  font-size: 14.5px;
  flex-wrap: wrap;
}
.row--link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.16s;
}
.row--link:hover {
  background: var(--surface-2);
}
.row--link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.row__arrow {
  color: var(--ink-mute);
  font-size: 24px;
  line-height: 1;
}
.row__main {
  flex: 1;
  min-width: 140px;
}
.row__sub {
  font-size: 12.5px;
  color: var(--ink-mute);
}
/* Кнопки строки держатся вместе и не расползаются на узком экране */
.row__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.explain__source {
  color: var(--brand);
  font-size: 13.5px;
  font-weight: 600;
  width: fit-content;
}

/* ---------- нижняя панель (мобильные) ---------- */

.tabbar {
  display: none;
}

@media (max-width: 720px) {
  .topnav {
    display: none;
  }
  .brand__text small {
    display: none;
  }
  #profile-link {
    display: none;
  }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 6px 2px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-mute);
  }
  .tabbar a[aria-current='page'] {
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, transparent);
  }

  .quiz-bar {
    position: sticky;
    top: calc(var(--header-h) - 2px);
  }
}

/* ---------- лайтбокс ---------- */

.lightbox[hidden] {
  display: none;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 6, 14, 0.92);
  backdrop-filter: blur(8px);
}
.lightbox img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 12px;
}
.lightbox__close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- всплывающие сообщения ---------- */

.toasts {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  width: min(440px, calc(100vw - 28px));
}
@media (max-width: 720px) {
  .toasts {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
}
.toast {
  padding: 12px 16px;
  border-radius: 13px;
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 14.5px;
  animation: toastIn 0.26s ease-out;
}
.toast--bad {
  border-color: color-mix(in srgb, var(--bad) 55%, transparent);
  color: var(--bad);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ---------- прочее ---------- */

.center-note {
  display: grid;
  gap: 14px;
  place-items: center;
  text-align: center;
  padding: clamp(30px, 7vw, 70px) 20px;
  color: var(--ink-mute);
}
.center-note h2 {
  color: var(--ink);
  font-size: 20px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
}
.chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.chip[aria-pressed='true'] {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 6, 14, 0.6);
  backdrop-filter: blur(6px);
  animation: fade 0.2s ease-out;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.sheet__panel {
  width: min(440px, 100%);
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Telegram Mini App
   Шапку рисует сам Telegram, поэтому свою убираем и на любой
   ширине оставляем нижнюю панель — мини-апп всегда «телефонный».
   ============================================================ */

html[data-tg] .topbar {
  display: none;
}

/* Высоту окна задаёт Telegram, а не 100vh */
html[data-tg] body {
  min-height: var(--tg-viewport, 100vh);
}

html[data-tg] .main {
  padding-top: 14px;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

html[data-tg] .tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}

html[data-tg] .tabbar a {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
}
html[data-tg] .tabbar a[aria-current='page'] {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}

/* [hidden] у ссылки админки должен побеждать display из правил выше */
.tabbar a[hidden],
.topnav a[hidden] {
  display: none;
}

html[data-tg] .quiz-bar {
  top: 0;
}

/* Пока доступ не подтверждён, навигация не нужна */
body[data-gated='1'] .topbar,
body[data-gated='1'] .tabbar {
  display: none;
}
body[data-gated='1'] .main {
  padding-bottom: 40px;
}

/* ---------- справочник штрафов и архив ---------- */

.fines__notes ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--ink-mute);
  font-size: 14px;
}

.fines__source {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-mute);
}

.fines__section + .fines__section {
  margin-top: 0;
}

.fines__title {
  font-size: 17px;
  margin-bottom: 12px;
}

.fines__list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fines__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.fines__item:first-child {
  border-top: none;
}

.fines__text {
  display: grid;
  gap: 4px;
  flex: 1 1 260px;
}

.fines__what {
  font-size: 15px;
  line-height: 1.45;
}

.fines__note {
  font-size: 13px;
  color: var(--ink-mute);
}

.fines__right {
  display: grid;
  justify-items: end;
  gap: 2px;
  flex: 0 0 auto;
  text-align: right;
}

.fines__penalty {
  font-weight: 700;
  font-size: 15px;
}

.fines__article {
  font-size: 12px;
  color: var(--ink-mute);
  white-space: nowrap;
}

.archive-link {
  display: grid;
  gap: 4px;
}
.archive-link span {
  font-weight: 650;
}
.archive-link small {
  color: var(--ink-mute);
  font-size: 13px;
}

.archive__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  margin-bottom: 10px;
}

.archive__list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive__link {
  display: block;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
}
.archive__list li:first-child .archive__link {
  border-top: none;
}
