/* Экзамен по таджвиду · чертёжный бланк.
   Палитра и приёмы согласованы с wiki.bahur.store: чёрный лист,
   волосяные линии, приводные метки, штриховка, узловые точки сетки. */

:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: rgba(255, 255, 255, 0.032);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --surface-glass: rgba(255, 255, 255, 0.035);
  --text: #f2f2f4;
  --text-soft: rgba(255, 255, 255, 0.6);
  /* текстовые подписи держим выше WCAG AA (4.5:1), декор — отдельным токеном */
  --text-faint: rgba(255, 255, 255, 0.58);
  /* --muted: приводные метки, штриховка, перекрестие — чистый декор,
     пороги контраста к нему не применяются. */
  --muted: rgba(255, 255, 255, 0.34);
  /* --line: волосяные разделители и рамки. Тоже чистый декор: порог 3:1
     к нему не применяется, иначе линия перестаёт быть волосяной. */
  --line: rgba(255, 255, 255, 0.12);
  --lit: rgba(255, 255, 255, 0.05);
  /* канты интерактивных элементов — не ниже 3:1 по WCAG 1.4.11 */
  --control-line: rgba(255, 255, 255, 0.46);
  --line-strong: rgba(255, 255, 255, 0.6);
  --inverse-bg: #f2f2f4;
  --inverse-text: #0a0a0b;
  --recording: #ff5a4e;
  --focus: #f2f2f4;
  --radius: 0;
  --grid-step: 22px;
  /* ширина чертёжного листа: одна на шапку, лист, узлы и подвал */
  --sheet-w: 780px;
  /* вынос приводных уголков за рамку — не больше отступа листа */
  --mark-out: 10px;
  /* поверхности вдавленных плашек и их тени (см. docs/design/wiki-spec.md) */
  --plate: #141416;
  --plate-chip: #1b1b1e;
  --plate-in: rgba(0, 0, 0, 0.75);
  --plate-out: rgba(255, 255, 255, 0.045);
  --hatch: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4'><path d='M 0,4 l 4,-4 M -1,1 l 2,-2 M 3,5 l 2,-2' stroke='%23ffffff' stroke-opacity='0.13' stroke-width='0.7'/></svg>");
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-ar: 'Amiri', 'Noto Naskh Arabic', serif;
  --font-mono: ui-monospace, Menlo, 'SF Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  /* моношрифтовый слой: три ступени, других размеров в моно нет */
  --mono-lg: 12px;
  --mono-md: 11px;
  --mono-sm: 10px;
  /* Брейкпоинты проекта: 400 (узкий телефон), 480 (телефон), 640 (крупный
     телефон), 760 (десктопная раскладка), 1180 (лист уже экрана). Других
     порогов не заводить — иначе компоненты рвутся вразнобой. */
  --track-label: 0.18em;
  --track-pill: 0.14em;
}

/* Белый бланк — тема по умолчанию: тот же чертёж, чёрным по белому.
   Основа чисто белая, без серых полутонов; линии и шрифт — чёрные. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: rgba(10, 10, 11, 0.025);
  --surface-strong: rgba(10, 10, 11, 0.06);
  --surface-glass: rgba(255, 255, 255, 0.88);
  --text: #0a0a0b;
  --text-soft: rgba(10, 10, 11, 0.66);
  --text-faint: rgba(10, 10, 11, 0.58);
  /* декор, порог 3:1 не применяется — см. комментарий в тёмном :root */
  --line: rgba(10, 10, 11, 0.16);
  --control-line: rgba(10, 10, 11, 0.52);
  --line-strong: rgba(10, 10, 11, 0.82);
  --inverse-bg: #0a0a0b;
  --inverse-text: #ffffff;
  --focus: #0a0a0b;
  --muted: rgba(10, 10, 11, 0.4);
  --lit: rgba(10, 10, 11, 0.045);
  --recording: #c9271b;
  --plate: #f3f3f5;
  --plate-chip: #ececef;
  --plate-in: rgba(20, 19, 16, 0.1);
  --plate-out: rgba(255, 255, 255, 0.95);
  --hatch: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4'><path d='M 0,4 l 4,-4 M -1,1 l 2,-2 M 3,5 l 2,-2' stroke='%230a0a0b' stroke-opacity='0.18' stroke-width='0.7'/></svg>");
}

:root[data-theme="light"] .level-bar { background: rgba(10, 10, 11, 0.12); }

/* ── Вдавленные плашки ──────────────────────────────────────
   Один приём в обеих темах: плашка чуть отличается от фона и получает
   ДВЕ мягкие внутренние тени — тёмную сверху-слева и светлую снизу-справа.
   На чёрном светлая тень слабее (иначе выглядит подсветкой), на белом —
   сильнее. Конструкция снята с карточек фабрик на wiki.bahur.store. */

.level.is-open,
.levels-locked {
  border-color: transparent;
  background: var(--plate);
  box-shadow:
    inset 4px 4px 11px var(--plate-in),
    inset -3px -3px 10px var(--plate-out);
}

/* чипы закрытых уровней — маленькие плашки того же семейства */
.locked-chip {
  border-color: transparent;
  background: var(--plate-chip);
  box-shadow:
    inset 2px 2px 5px var(--plate-in),
    inset -2px -2px 5px var(--plate-out);
}

/* Вдавленная плашка на белом — как карточки фабрик (Luzi, EPS) на вики:
   светлая плашка и ДВЕ мягкие внутренние тени — тёмная сверху-слева,
   белая снизу-справа. Плашка выглядит вдавленной в бумагу. */
:root[data-theme="light"] .btn {
  color: var(--text);
  background: var(--plate);
  box-shadow:
    inset 3px 3px 8px rgba(20, 19, 16, 0.13),
    inset -3px -3px 8px var(--plate-out);
}

/* заблокированная кнопка не «вдавливается» под курсором */
:root[data-theme="light"] .btn:hover:not(:disabled) {
  box-shadow:
    inset 4px 4px 10px rgba(20, 19, 16, 0.17),
    inset -4px -4px 10px rgba(255, 255, 255, 0.92);
}

/* активный пункт меню вдавлен, само меню — белая пилюля с тенью-отрывом */
:root[data-theme="light"] .tab.is-on {
  background: var(--plate);
  box-shadow:
    inset 2px 2px 6px rgba(20, 19, 16, 0.09),
    inset -2px -2px 6px rgba(255, 255, 255, 0.95);
}

:root[data-theme="light"] .tabbar {
  border-color: rgba(10, 10, 11, 0.14);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1), 0 1px 2px rgba(15, 23, 42, 0.06);
}

:root[data-theme="light"] .btn.is-ghost {
  color: var(--text);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--control-line);
}

:root[data-theme="light"] .btn.is-ghost:hover { background: rgba(10, 10, 11, 0.05); }
:root[data-theme="light"] .btn.is-quiet { color: var(--text-soft); background: transparent; box-shadow: none; }
/* На бумаге неон слепит и не читается: смешиваем цвет уровня с чёрным.
   Доля подобрана по худшей точке шкалы (жёлто-зелёная зона ~40%):
   42% держат ≥4.5:1 на белом по всей шкале, 62% давали всего 2.9:1. */
:root[data-theme="light"] .score-hero.is-scored .score-percent,
:root[data-theme="light"] .level-percent,
:root[data-theme="light"] .level.is-scored .level-verdict,
:root[data-theme="light"] .result-item .score {
  color: color-mix(in srgb, var(--score-color) 42%, #0a0a0b);
  text-shadow: none;
}


/* Навигация: нижняя на телефоне, верхняя на десктопе */

.sitenav { display: none; }

/* Пустой контейнер меню не должен рисовать свою рамку: на экранах
   результата и кабинета navItems() пуст, и оставалось висеть кольцо. */
.tabbar:empty, .sitenav-tabs:empty { display: none; }

/* Плавающая пилюля-сегментник, как .pillrow на вики */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  max-width: calc(100vw - 16px);
  padding: 3px;
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  transition: transform 0.22s var(--ease), opacity 0.22s var(--ease);
}

/* при прокрутке вниз меню уходит, чтобы не закрывать контент */
html.nav-hidden .tabbar {
  transform: translate(-50%, calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .tabbar { transition: none; }
}

.tab {
  min-height: 44px;
  padding: 10px clamp(9px, 3.4vw, 18px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  touch-action: manipulation;
  transition: color 0.14s, background-color 0.14s;
}

.tab.is-on { color: var(--text); background: var(--lit); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* меню есть — освобождаем место, чтобы подвал не уезжал под него */
html.has-tabbar body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
html.is-exam .tabbar { display: none; }
html.is-exam body { padding-bottom: 0; }

@media (min-width: 760px) {
  .tabbar { display: none; }
  html.has-tabbar body { padding-bottom: 0; }

  .sitenav { display: block; }

  html.is-exam .sitenav { display: none; }

  .sitenav-inner {
    max-width: var(--sheet-w);
    height: auto;
    margin: 0 auto;
    padding: 26px 56px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .sitenav-mark {
    min-height: 44px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: var(--mono-md);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
  }

  .sitenav-mark:hover { color: var(--text); }
  .sitenav-mark:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .sitenav-tabs {
    display: flex;
    align-self: center;
    padding: 4px;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 999px;
  }

  .sitenav-tabs .tab { min-height: 44px; padding: 10px 16px; }
}

/* Переключатель темы: в шапке на десктопе, в профиле на телефоне */

.theme-toggle {
  min-height: 44px;
  padding: 12px 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  background: var(--bg);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--mono-lg);
  letter-spacing: var(--track-pill);
  text-transform: uppercase;
  touch-action: manipulation;
  transition: border-color 0.14s, background-color 0.14s, color 0.14s;
}

.theme-toggle:hover { border-color: var(--line-strong); background: var(--surface); }
.theme-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* половинка круга — светлая/тёмная сторона */
.theme-dial {
  width: 13px;
  height: 13px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(to right, currentColor 0 50%, transparent 50% 100%);
}

/* Профиль и настройки */

.profile-card { margin-top: 20px; }
.profile-name { margin-top: 8px; font-family: var(--font-display); font-size: clamp(26px, 5.4vw, 34px); font-weight: 500; }

.profile-meta {
  margin-top: 20px;
  display: grid;
  gap: 14px 28px;
  grid-template-columns: repeat(auto-fit, minmax(120px, auto));
  justify-content: start;
}

.profile-meta dt { color: var(--text-faint); font-family: var(--font-mono); font-size: var(--mono-lg); letter-spacing: var(--track-pill); text-transform: uppercase; }
.profile-meta dd { margin-top: 4px; font-size: 16px; }

.settings {
  margin-top: 14px;
  border: 1px solid var(--line);
}

.setting-row {
  width: 100%;
  min-height: 62px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  transition: background-color 0.14s;
}

.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-row:hover { background: var(--surface); }
.setting-row:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
.setting-row b { display: block; font-size: 15px; font-weight: 500; }
.setting-row small { display: block; margin-top: 3px; color: var(--text-soft); font-size: 13px; }

.setting-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: var(--mono-lg);
  letter-spacing: var(--track-pill);
  text-transform: uppercase;
  white-space: nowrap;
}

@media (min-width: 760px) {
  .sitenav-right { display: flex; align-items: center; gap: 14px; align-self: stretch; }
}

/* Точечная сетка по левому краю — «поле чертежа» */
body::before {
  content: "";
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  z-index: -2;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1.3px);
  background-size: var(--grid-step) var(--grid-step);
  -webkit-mask-image: linear-gradient(to right, #000, transparent 92%),
    radial-gradient(140% 55% at 0% 28%, #000 30%, rgba(0, 0, 0, 0.25) 62%, #000 100%);
  mask-image: linear-gradient(to right, #000, transparent 92%),
    radial-gradient(140% 55% at 0% 28%, #000 30%, rgba(0, 0, 0, 0.25) 62%, #000 100%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

/* Приводные метки — переиспользуемый компонент: внутри любого .frame
   лежат absolute, на уровне страницы — fixed. Как на wiki.bahur.store. */
.marks { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
/* Метки листа НЕ fixed: иначе уголки висят на экране при прокрутке
   и читаются как «застрявшие квадраты». Крепим к документу. */
.marks.is-page { top: 0; left: 0; right: 0; height: 100vh; z-index: 0; }

/* Рамка блока: та же конструкция, что .frame на вики */
.frame { position: relative; padding: 26px; }

@media (max-width: 640px) {
  .frame { padding: 20px; }
}

/* баннеру и карточкам граница нужна — рисуем явно */
.welcome-hero, .profile-card { border: 1px solid var(--line); }
.marks .tick { position: absolute; background: var(--muted); }
.marks .tick.tl-v { top: 2px; left: 26px; width: 1px; height: 18px; }
.marks .tick.tl-h { top: 26px; left: 2px; width: 18px; height: 1px; }
.marks .tick.tr-v { top: 2px; right: 26px; width: 1px; height: 18px; }
.marks .tick.tr-h { top: 26px; right: 2px; width: 18px; height: 1px; }
.marks .tick.bl-v { bottom: 2px; left: 26px; width: 1px; height: 18px; }
.marks .tick.bl-h { bottom: 26px; left: 2px; width: 18px; height: 1px; }
.marks .tick.br-v { bottom: 2px; right: 26px; width: 1px; height: 18px; }
.marks .tick.br-h { bottom: 26px; right: 2px; width: 18px; height: 1px; }

.marks .hatch {
  position: absolute;
  width: 18px;
  height: 18px;
  opacity: 0.8;
  background-image: var(--hatch);
  background-size: 5px 5px;
}

.marks .hatch.tr { top: 2px; right: 2px; }
.marks .hatch.bl { bottom: 2px; left: 2px; }



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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html {
  min-width: 320px;
  /* clip, а не hidden: hidden на body не мешает html растягиваться
     от декоративных элементов, и страница начинает ездить вбок */
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }
::selection { color: var(--inverse-text); background: var(--inverse-bg); }

.skip-link {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 10px 14px;
  color: var(--inverse-text);
  background: var(--inverse-bg);
  transform: translateY(-110%);
}

.skip-link:focus { transform: none; }

/* Шапка */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  color: var(--text);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--sheet-w);
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.topbar-label {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: var(--track-pill);
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-soft);
}

.topbar-timer {
  font-family: var(--font-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.topbar-timer.is-low { font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
/* Атрибут hidden обязан побеждать: авторский display:block иначе
   перебивает браузерный [hidden]{display:none}, и полоса таймера
   висит чёрной чертой под шапкой на всех экранах подряд. */
[hidden] { display: none !important; }

.timebar { width: 100%; height: 3px; display: block; border: 0; background: var(--surface-strong); -webkit-appearance: none; appearance: none; }
.timebar::-webkit-progress-bar { background: var(--surface-strong); }
.timebar::-webkit-progress-value { background: var(--text); }
.timebar::-moz-progress-bar { background: var(--text); }

/* Основной лист */

.sheet-wrap { flex: 1; display: flex; position: relative; }

.sheet {
  flex: 1;
  width: 100%;
  max-width: var(--sheet-w);
  min-width: 0;
  margin: 0 auto;
  padding: 40px 16px 56px;
}

@media (min-width: 400px) {
  :root { --mark-out: 14px; }
  .sheet { padding-left: 20px; padding-right: 20px; }
}

.screen { animation: screen-in 0.22s var(--ease); }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 760px) {
  :root { --sheet-w: 1120px; --mark-out: 22px; }

  .sheet {
    position: relative;
    padding: 72px 64px 96px;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }

  /* узловые точки на углах листа — как на чертёжной сетке */
  /* узловые точки по углам листа — отдельным слоем, кант у всех четырёх.
     Показываем только когда лист УЖЕ экрана: иначе точки садятся ровно
     на край вьюпорта и обрезаются пополам. */
  .sheet-nodes {
    position: absolute;
    inset: 0;
    max-width: var(--sheet-w);
    margin: 0 auto;
    pointer-events: none;
    display: none;
  }

  @media (min-width: 1180px) {
    .sheet-nodes { display: block; }
  }

  .sheet-nodes span {
    position: absolute;
    width: 8px;
    height: 8px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--bg);
  }

  .sheet-nodes .n-tl { top: -4.5px; left: -4.5px; }
  .sheet-nodes .n-tr { top: -4.5px; right: -4.5px; }
  .sheet-nodes .n-bl { bottom: -4.5px; left: -4.5px; }
  .sheet-nodes .n-br { bottom: -4.5px; right: -4.5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .screen { animation: none; }
  /* !important здесь оправдан: заглушить анимации нужно поверх любых
     компонентных правил, иначе часть из них переживёт сброс */
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Типографика */

h1, h2 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0.005em;
  text-wrap: balance;
}

h1 { font-size: clamp(32px, 6.4vw, 48px); }
h2 { font-size: clamp(24px, 5vw, 33px); }
.screen h1[tabindex="-1"]:focus-visible, .screen h2[tabindex="-1"]:focus-visible {
  outline: none;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.lede {
  max-width: 52ch;
  margin-top: 14px;
  color: var(--text-soft);
  font-size: 17px;
  text-wrap: pretty;
}

.statement { max-width: none; }
.rule { margin: 28px 0; border: 0; border-top: 1px solid var(--line); }

/* Микро-подписи набраны моноширинным, как на технических листах */
.kicker {
  margin-bottom: 10px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: var(--mono-md);
  font-weight: 400;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
}



/* мигающий курсор в подписи — деталь с вики */
.kicker .cur { animation: blink 1.1s steps(1) infinite; }

@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .kicker .cur { animation: none; }
}

.ar { font-family: var(--font-ar); direction: rtl; unicode-bidi: isolate; font-synthesis: none; letter-spacing: normal; font-weight: 400; }

.ar-hero {
  padding: 12px 0 4px;
  font-family: var(--font-ar);
  font-size: clamp(60px, 13vw, 84px);
  line-height: 1.9;
  text-align: center;
  direction: rtl;
}

.ar-hero.is-compact { font-size: clamp(44px, 9vw, 62px); }

.ar-line {
  font-family: var(--font-ar);
  font-size: clamp(36px, 7vw, 46px);
  line-height: 2.05;
  text-align: right;
  direction: rtl;
}

.ar-hero,
.ar-line,
.match .tag,
.compose-out,
.compose-tiles .opt {
  font-synthesis: none;
  font-style: normal;
  font-weight: 400;
  letter-spacing: normal;
}

/* Кнопки */

/* Вдавленная плашка — точная конструкция .cta с wiki.bahur.store:
   светлый градиент и ДВЕ внутренние тени дают физическую вдавленность. */
.btn {
  min-height: 44px;
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius);
  color: var(--inverse-text);
  background: linear-gradient(#e7e7ea, #fbfbfc);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.34),
    inset 0 -1px 2px rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: box-shadow 0.15s, transform 0.1s;
}

/* вторичная пилюля — точная копия .wiki-more с эталона */
.btn.is-pill {
  min-height: 44px;
  padding: 11px 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  background: transparent;
  box-shadow: none;
  font-family: var(--font-mono);
  font-size: var(--mono-lg);
  font-weight: 400;
  letter-spacing: var(--track-pill);
  text-transform: uppercase;
}

.btn.is-pill:hover { border-color: var(--control-line); color: var(--text); background: transparent; box-shadow: none; }

/* предупреждение о пустом ответе на кнопке */
.btn.is-warning {
  color: #fff;
  background: linear-gradient(#8e2b23, #b3352c);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 -1px 2px rgba(255, 255, 255, 0.16);
  font-size: 12px;
}

/* Три уровня: вдавленная плашка → призрак с внутренним кантом → голый текст */
.btn:hover {
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.42),
    inset 0 -1px 2px rgba(255, 255, 255, 0.85);
}

.btn:active { transform: translateY(1px); }

.btn.is-ghost {
  min-height: 46px;
  color: var(--text);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn.is-ghost:hover { background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px var(--line-strong); }

.btn.is-quiet {
  min-height: 44px;
  padding: 10px 4px;
  color: var(--text-soft);
  background: transparent;
  box-shadow: none;
  font-weight: 500;
}

.btn.is-quiet:hover { color: var(--text); background: transparent; box-shadow: none; text-decoration: underline; text-underline-offset: 4px; }
.btn:focus-visible, .opt:focus-visible, .check:focus-visible, .stepper button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}


.btn:disabled {
  color: var(--text-faint);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: not-allowed;
  transform: none;
}

.btn.is-recording { color: #fff; background: var(--recording); box-shadow: inset 0 2px 4px rgba(0,0,0,.3); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn-block { width: 100%; }

/* Главная и кабинет */

/* Баннер — конструкция баннера wiki.bahur.store/prays: сетка ОДИНАКОВЫХ
   квадратов на любом экране (шаг задан токеном, а не долей ширины, поэтому
   квадрат на телефоне и на десктопе одного размера), крупные штрихованные
   зоны по краям, чистое поле под текстом. Линии проходят насквозь — они
   волосяные и текст не рассекают, подложек под текст не делаем. */

:root { --hero-cell: 116px; }

@media (min-width: 760px) {
  :root { --hero-cell: 132px; }
}

.welcome-hero,
.cta-banner {
  position: relative;
  padding: 26px 24px 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  border: 1px solid var(--line);
  isolation: isolate;
  /* overflow не режем: приводные уголки .marks.is-out живут ЗА рамкой,
     а штриховка и так позиционирована строго внутри */
  /* Сетку рисуем ОТ ПРАВОГО края: штриховка тоже прижата вправо, и так её
     левая граница всегда ложится ровно на линию сетки. Если вести сетку
     слева, справа остаётся обрезок, а штриховка начинается посреди ячейки —
     получается тот самый «висящий шов» посреди баннера. */
  background-image:
    repeating-linear-gradient(to left, var(--line) 0 1px, transparent 1px var(--hero-cell)),
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hero-cell));
  background-position: right top, left top;
}

.welcome-hero { min-height: calc(var(--hero-cell) * 3); }
.cta-banner { min-height: calc(var(--hero-cell) * 2); margin-top: 52px; }

/* Штриховка — крупной зоной от правого края внутрь, как на эталоне,
   а не одиноким квадратом посередине. Ширина кратна шагу сетки,
   поэтому край штриховки всегда ложится ровно на линию. */
.hero-hatch {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: calc(var(--hero-cell) * 2);
  background-image: var(--hatch);
  opacity: 0.75;
  pointer-events: none;
}

@media (max-width: 640px) {
  /* на узком экране правая зона съедает пол-экрана — оставляем одну колонку */
  .hero-hatch { width: var(--hero-cell); }
}

/* Приводные уголки СНАРУЖИ рамки — как у баннера на прайсе.
   Вынос НЕ должен превышать боковой отступ листа, иначе уголки уезжают
   за край экрана и страница начинает ездить вбок. Поэтому вынос —
   отдельный токен, синхронный с padding листа на каждом брейкпоинте. */
.marks.is-out { inset: calc(-1 * var(--mark-out)); }

.welcome-hero h1 {
  max-width: 12ch;
  font-size: clamp(38px, 8vw, 76px);
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.welcome-hero h1 em { font-style: italic; font-weight: 500; color: var(--text-soft); }
:root[data-theme="light"] .welcome-hero h1 em { color: rgba(10, 10, 11, 0.5); }
.cta-banner h2 { font-size: clamp(30px, 5.6vw, 52px); }

/* кикер под заголовком — ритм эталона */
.kicker.is-under { margin: 14px 0 0; }
.welcome-hero .lede { max-width: 46ch; position: relative; }

/* Шапка экзамена: таймер и единственный выход */
.topbar-right { display: flex; align-items: center; gap: 14px; }
/* цель нажатия не меньше 44px: кнопка есть на всех экранах экзамена */
.topbar-exit { min-height: 44px; padding: 8px 12px; font-size: 12px; }

.level { cursor: default; }

/* содержимое баннера — поверх сетки и штриховки */
.welcome-hero > *:not(.hero-hatch):not(.marks),
.cta-banner > *:not(.hero-hatch):not(.marks) { position: relative; z-index: 1; }

/* Флаг у имени преподавателя: единственная цветная деталь на бланке,
   поэтому набирается системным эмодзи-шрифтом и не масштабируется. */
.flag {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  font-size: 1em;
  letter-spacing: normal;
  vertical-align: -0.08em;
}

/* Мета-блок баннера с перекрестием — деталь эталона */
.hero-actions { margin-top: 22px; }

.hero-meta {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--mono-md);
  line-height: 1.5;
  letter-spacing: var(--track-pill);
}

.crosshair {
  position: relative;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.crosshair::before, .crosshair::after {
  content: "";
  position: absolute;
  background: var(--muted);
}

.crosshair::before { left: 50%; top: -5px; bottom: -5px; width: 1px; transform: translateX(-50%); }
.crosshair::after { top: 50%; left: -5px; right: -5px; height: 1px; transform: translateY(-50%); }

.result-list { margin-top: 28px; border-top: 1px solid var(--line); }
.result-item { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.result-item p { min-width: 0; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.result-item .meta { color: var(--text-soft); font-size: 13px; }
.result-item .score { font-family: var(--font-mono); font-size: 20px; font-variant-numeric: tabular-nums; }

/* Формы */

.form { margin-top: 28px; display: grid; gap: 20px; }
.field label { display: block; margin-bottom: 7px; color: var(--text-soft); font-size: 13px; font-weight: 600; letter-spacing: var(--track-pill); }

.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--control-line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 17px;
  transition: color 0.14s, background-color 0.14s, border-color 0.14s;
}

.field input::placeholder { color: var(--text-faint); }
.field input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--line-strong); }
.field .err { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; color: var(--recording); font-size: 13px; font-weight: 600; }
.field.is-invalid input { border-style: dashed; border-color: var(--line-strong); }
.field.is-invalid .err { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; margin-top: 6px; }

/* Водяной знак на экранах вопросов */

.watermark {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-content: space-around;
  gap: 40px 12px;
  overflow: hidden;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.watermark span {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--mono-md);
  letter-spacing: var(--track-pill);
  text-align: center;
  opacity: 0.055;
  transform: rotate(-24deg);
  /* на белом та же непрозрачность читается заметно слабее — поднимаем,
     иначе знак перестаёт выполнять свою работу */
  }

:root[data-theme="light"] .watermark span {
  opacity: 0.085;
  white-space: nowrap;
}

html.is-exam .screen { position: relative; }

/* содержимое вопросов не выделяется и не копируется */
html.is-exam .q-head, html.is-exam .ar-hero, html.is-exam .ar-line,
html.is-exam .statement, html.is-exam .read-rows, html.is-exam .compose-given {
  -webkit-user-select: none;
  user-select: none;
}

@media print {
  html.is-exam body * { visibility: hidden; }
  html.is-exam body::after {
    content: "Печать экзамена отключена";
    visibility: visible;
    font-family: sans-serif;
  }
}

/* Пошаговая анкета */

.wizard { position: relative; }

.wizard-steps {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: 6px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
}

.wstep { position: relative; }
.wstep + .wstep { border-left: 1px solid var(--line); }
.wstep.is-done::after { content: ""; position: absolute; inset: 0; background-image: var(--hatch); }
.wstep.is-now { background: var(--text); }

.wizard-q {
  font-size: clamp(28px, 6vw, 40px);
  text-wrap: balance;
}

.wizard-field { margin-top: 26px; }

/* строка бланка: только нижняя линия, крупный ввод */
.wizard-field input {
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--control-line);
  background: transparent;
  font-family: var(--font-display);
  font-size: clamp(26px, 6vw, 34px);
}

/* фокус должен быть заметен сам по себе, а не «чуть более жирной» линией */
.wizard-field input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-bottom-color: var(--text);
  border-bottom-width: 2px;
}

.wizard-hint {
  display: block;
  margin-top: 10px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--mono-lg);
  letter-spacing: var(--track-pill);
  text-transform: uppercase;
}

.wizard-field.is-invalid input { border-bottom-color: var(--recording); }
.wizard-field.is-invalid .wizard-hint { display: none; }
.wizard-back { margin-top: 12px; }

/* Расписание занятий */

.schedule-picker {
  min-width: 0;
  margin-top: 12px;
  padding: 30px 0 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
}

.schedule-picker legend {
  padding: 0;
  font-family: var(--font-display);
  font-size: clamp(25px, 5vw, 32px);
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
}

.field-hint { margin-top: 8px; color: var(--text-soft); font-size: 14px; }

.day-strip {
  margin-top: 18px;
  padding: 3px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(88px, 1fr);
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
  scrollbar-width: thin;
}

.day-option { min-width: 0; scroll-snap-align: start; cursor: pointer; touch-action: manipulation; }

.day-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.day-face {
  min-height: 62px;
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--control-line);
  color: var(--text);
  background: var(--surface-glass);
  text-align: center;
  transition: color 0.14s, background-color 0.14s, border-color 0.14s, transform 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .day-option:hover .day-face { border-color: var(--line-strong); transform: translateY(-2px); }
}
.day-option input:checked + .day-face { color: var(--inverse-text); background: var(--inverse-bg); border-color: var(--line-strong); }
.day-option input:focus-visible + .day-face { outline: 2px solid var(--focus); outline-offset: 2px; }
.day-short { font-size: 16px; font-weight: 600; }
.day-full { margin-top: 2px; color: var(--text-soft); font-size: 12px; }
.day-option input:checked + .day-face .day-full { color: var(--inverse-text); }

.schedule-picker > .err { display: none; margin-top: 8px; color: var(--recording); font-size: 13px; font-weight: 600; }
.schedule-picker.is-invalid > .err { display: block; }
.schedule-picker.is-invalid .day-strip { border-left: 2px solid var(--line-strong); }

.time-window {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--surface-glass);
}

.time-heading {
  padding-bottom: 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 13px;
}

.time-heading strong {
  min-width: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(25px, 5vw, 34px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  overflow-wrap: anywhere;
  text-align: right;
}

.time-slider {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 8px 16px;
  color: var(--text-soft);
  font-size: 13px;
}

.time-slider output { color: var(--text); font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }

.time-slider input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
  accent-color: var(--text);
  touch-action: pan-y;
  -webkit-appearance: none;
  appearance: none;
}

.time-slider input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); }
.time-slider input[type="range"]::-webkit-slider-thumb {
  width: 30px;
  height: 36px;
  margin-top: -17px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-appearance: none;
}
.time-slider input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); }
.time-slider input[type="range"]::-moz-range-thumb { width: 30px; height: 36px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.time-slider input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.time-scale { display: flex; justify-content: space-between; color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.sound-toggle {
  width: 100%;
  min-height: 60px;
  margin-top: 22px;
  padding: 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}

.sound-toggle b, .sound-toggle small { display: block; }
.sound-toggle b { font-size: 13px; }
.sound-toggle small { margin-top: 2px; color: var(--text-soft); font-size: 12px; }
.sound-switch { flex: 0 0 48px; height: 28px; padding: 4px; border: 1px solid var(--line-strong); background: var(--surface); }
.sound-switch span { display: block; width: 18px; height: 18px; background: var(--text); transition: transform 0.16s var(--ease); }
.sound-toggle[aria-pressed="true"] .sound-switch span { transform: translateX(20px); }
.sound-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

@media (min-width: 760px) {
  .day-strip { grid-auto-flow: initial; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: visible; }
}

/* Вопросы */

.q-head { margin-bottom: 24px; }
.q-title { font-family: var(--font-display); font-size: clamp(21px, 4.6vw, 27px); font-weight: 500; line-height: 1.25; text-wrap: balance; }
.q-note { margin-top: 8px; color: var(--text-soft); font-size: 14px; text-wrap: pretty; }

.stepper {
  width: min(300px, 100%);
  margin: 8px auto 0;
  display: flex;
  align-items: stretch;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stepper button {
  flex: 0 0 68px;
  min-height: 68px;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-size: 26px;
  touch-action: manipulation;
}

.stepper button:hover { color: var(--inverse-text); background: var(--inverse-bg); }
.stepper button:active { transform: translateY(1px); }

.stepper output {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

.stepper output.is-empty { color: var(--text-faint); font-family: var(--font-ui); font-size: 15px; }
.yesno { min-width: 0; margin-top: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border: 0; }
.yesno .opt { min-height: 84px; font-size: 16px; }
.yesno .opt input { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
.yesno .opt span { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: center; }
.yesno .opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }

.opt {
  padding: 14px 16px;
  /* плитка ответа — вдавленная плашка: иначе самый нажимаемый элемент
     экзамена читается как неинтерактивный. Кант не рисуем — роль канта
     здесь выполняет сама вдавленность. */
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--plate);
  box-shadow:
    inset 3px 3px 8px var(--plate-in),
    inset -2px -2px 7px var(--plate-out);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  touch-action: manipulation;
  transition: color 0.14s, background-color 0.14s, box-shadow 0.14s, transform 0.1s;
}

.opt:hover {
  box-shadow:
    inset 4px 4px 10px var(--plate-in),
    inset -2px -2px 8px var(--plate-out);
}
.opt:active { transform: translateY(1px); }
/* выбранная плитка — сплошная инверсия без вдавленности: так выбор
   отличается от «нажимаемого, но не выбранного» состояния */
.opt.is-on {
  color: var(--inverse-text);
  background: var(--inverse-bg);
  border-color: var(--line-strong);
  box-shadow: none;
}

.checks { margin-top: 24px; overflow: visible; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

.check {
  width: 100%;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 16px;
  text-align: left;
  touch-action: manipulation;
  transition: color 0.14s, background-color 0.14s;
}

.check input { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
.check input:focus-visible + .box { outline: 2px solid var(--focus); outline-offset: 3px; }

.check + .check { border-top: 1px solid var(--line); }
.check:hover { background: var(--surface-strong); }

.check .box {
  flex: 0 0 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--control-line);
  border-radius: var(--radius);
  color: transparent;
  background: transparent;
  font-size: 14px;
}

.check.is-on .box { color: var(--inverse-text); background: var(--inverse-bg); border-color: var(--line-strong); }
.check .ru { flex: 1; min-width: 0; }
.check .ar { color: var(--text-soft); font-size: 32px; line-height: 1.6; }

.match { margin-top: 24px; display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px 18px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.match .opt { position: relative; min-height: 62px; display: flex; align-items: center; justify-content: center; }
.match .opt .ar { font-size: 35px; line-height: 1.65; }
.match .opt.is-paired { border-style: double; border-color: var(--line-strong); }
.match .opt.is-paired.is-on { color: var(--inverse-text); background: var(--inverse-bg); }

.match .tag {
  position: absolute;
  top: 3px;
  left: 9px;
  color: var(--text-soft);
  font-family: var(--font-ar);
  font-size: 15px;
  line-height: 1.6;
  direction: rtl;
}

.match-hint { margin-top: 16px; color: var(--text-faint); font-size: 13px; text-align: center; }
.compose-given { margin-top: 6px; color: var(--text-soft); font-size: 15px; text-align: center; }
.compose-given .ar { font-size: 32px; }

.compose-out {
  min-height: 96px;
  margin: 22px auto 0;
  padding: 6px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-family: var(--font-ar);
  font-size: 46px;
  line-height: 1.9;
  direction: rtl;
}

.compose-out.is-empty { color: var(--text-faint); font-family: var(--font-ui); font-size: 15px; }
.compose-tiles { margin-top: 18px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; direction: rtl; }
.compose-tiles .opt { min-width: 68px; min-height: 68px; padding: 6px 14px 10px; font-family: var(--font-ar); font-size: 36px; line-height: 1.7; }
.compose-tiles .opt.is-used { color: var(--text-faint); background: var(--bg); border-color: var(--line); box-shadow: none; cursor: default; }
.compose-ctrl { margin-top: 16px; display: flex; justify-content: center; gap: 10px; }
.compose-ctrl .btn { min-height: 44px; padding: 10px 18px; font-size: 12px; }

/* Чтение и запись */

.read-rows { margin-top: 20px; overflow: visible; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); list-style: none; }
.read-row { padding: 14px 20px; }
.read-row + .read-row { border-top: 1px solid var(--line); }

.recorder {
  margin-top: 24px;
  padding: 20px;
  display: grid;
  gap: 14px;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.rec-status { display: flex; align-items: center; gap: 9px; color: var(--text-soft); font-size: 14px; }
.rec-dot { width: 10px; height: 10px; background: var(--recording); animation: rec-pulse 1.1s ease-in-out infinite; }
.recorder audio { width: 100%; }
.reading-actions { margin-top: 0; justify-content: center; }
.recording-playback { width: 100%; }

@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

/* Метаданные и результат */

.task-meta {
  margin-top: 18px;
  padding: 16px 0;
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 10px 36px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.task-meta div { display: grid; gap: 2px; }
.task-meta dt { color: var(--text-faint); font-size: 12px; letter-spacing: var(--track-pill); text-transform: uppercase; }
.task-meta dd { font-size: 18px; font-weight: 500; }

.score-hero {
  margin-top: 28px;
  padding: 36px 24px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.score-percent { color: var(--text); font-family: var(--font-display); font-size: clamp(68px, 17vw, 110px); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.score-caption { margin-top: 10px; color: var(--text-soft); font-size: 15px; }
.breakdown { margin-top: 26px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

.breakdown-row { padding: 12px 18px; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font-size: 15px; }
.breakdown-row + .breakdown-row { border-top: 1px solid var(--line); }
.breakdown-row .pts { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown-row.is-muted { color: var(--text-faint); }

.notice { margin-top: 22px; padding: 10px 0 10px 16px; border-left: 3px solid var(--line-strong); color: var(--text-soft); font-size: 14px; overflow-wrap: anywhere; }
.notice.is-error { border-left-color: var(--recording); color: var(--text); }

.rec-secure-link { color: var(--text); text-underline-offset: 3px; }
.rec-secure-link:hover { text-decoration-thickness: 2px; }

/* Оценённый результат: тёмная плашка, чтобы читался цвет уровня */

/* Вдавленная плашка + мягкое свечение цвета уровня поверх неё.
   Оба слоя задаём здесь: правило идёт после общего блока плашек,
   и разнесённые объявления просто перебивали бы друг друга. */
.score-hero.is-scored {
  position: relative;
  padding: 44px 24px 34px;
  border: 1px solid transparent;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--score-color) 12%, transparent), transparent 70%),
    var(--plate);
  box-shadow:
    inset 4px 4px 11px var(--plate-in),
    inset -3px -3px 10px var(--plate-out);
}

/* штриховка по краям плашки результата */
.score-hero.is-scored::before,
.score-hero.is-scored::after {
  content: "";
  position: absolute;
  top: 0;
  width: 16px;
  height: 16px;
  background-image: var(--hatch);
  background-size: 5px 5px;
  opacity: 0.85;
}

.score-hero.is-scored::before { left: 0; }
.score-hero.is-scored::after { right: 0; }

.score-hero.is-scored .score-percent {
  color: var(--score-color, var(--text));
  text-shadow: 0 0 42px color-mix(in srgb, var(--score-color, #fff) 42%, transparent);
}

.score-percent i { font-style: normal; font-size: 0.42em; letter-spacing: 0.02em; }
.score-hero.is-scored .score-caption { color: var(--text-soft); }
.score-hero.is-scored .level-bar { max-width: 320px; margin: 22px auto 0; }
.score-points { margin-top: 14px; color: var(--text-faint); font-family: var(--font-mono); font-size: var(--mono-lg); letter-spacing: var(--track-pill); font-variant-numeric: tabular-nums; text-transform: uppercase; }

/* Лестница уровней */

.levels-teaser { margin-top: 40px; }
.levels { margin-top: 20px; list-style: none; display: grid; gap: 12px; }

.level {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Закрытые уровни: одна узкая полоса вместо шести карточек */

.levels-locked {
  position: relative;
  margin-top: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border: 1px solid transparent;
  overflow: hidden;
}

/* штриховки внутри вдавленной плашки нет — она забивала мягкие тени */

.locked-chip {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--mono-lg);
  color: var(--text-soft);
}

.locked-note {
  position: relative;
  z-index: 1;
  margin-left: 4px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: var(--mono-lg);
  letter-spacing: var(--track-pill);
  text-transform: uppercase;
}

/* Вердикт бывает длинным («нужно повторить материал»), поэтому строка
   переносится, а дети умеют сжиматься — иначе карточка распирает экран. */
.level-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
}

.level-head > * { min-width: 0; }

.level-n {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
}

.level-lock, .level-verdict {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--track-pill);
  text-transform: uppercase;
}

/* «доступен»/«закрыт» короткие — их не рвём; вердикт переносим */
.level-lock { white-space: nowrap; }

.level-lock { color: var(--text-faint); }
.level-lock.is-ready { color: var(--text); }
.level-topic { margin-top: 6px; color: var(--text-soft); font-size: 15px; }
/* на плашке фон светлее страницы, поэтому берём более тёмный токен:
   --text-faint даёт на ней только 4.4:1 */
.level-hint { margin-top: 10px; color: var(--text-soft); font-size: 13px; }

/* Пройденный уровень горит цветом результата */

.level.is-scored {
  border-color: transparent;
  background:
    radial-gradient(90% 120% at 0% 0%, color-mix(in srgb, var(--score-color) 9%, transparent), transparent 65%),
    var(--plate);
  box-shadow:
    inset 4px 4px 11px var(--plate-in),
    inset -3px -3px 10px var(--plate-out);
}

.level.is-scored .level-verdict { color: var(--score-color, var(--text)); }
.level.is-scored .level-topic { color: var(--text-soft); }

.level-score { margin-top: 18px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; }

.level-percent {
  color: var(--score-color, var(--text));
  font-family: var(--font-display);
  font-size: clamp(46px, 12vw, 64px);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px color-mix(in srgb, var(--score-color) 50%, transparent);
}

.level-percent i { font-style: normal; font-size: 0.42em; }
.level-points { color: var(--text-faint); font-family: var(--font-mono); font-size: var(--mono-md); letter-spacing: var(--track-pill); font-variant-numeric: tabular-nums; text-transform: uppercase; }

.level-bar {
  height: 4px;
  margin-top: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.level-bar span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--score-color, currentColor);
  animation: level-fill 0.9s var(--ease) both;
}

@keyframes level-fill {
  from { transform: scaleX(0); transform-origin: left; }
  to { transform: scaleX(1); transform-origin: left; }
}


@media (prefers-reduced-motion: reduce) {
  .level-bar span { animation: none; }
}

/* Старые браузеры без color-mix: свечение отключается, цвет остаётся */
/* Старые браузеры без color-mix: гаснет только свечение, вдавленность
   плашки остаётся — она построена на обычных inset-тенях. */
@supports not (color: color-mix(in srgb, red 50%, transparent)) {
  .level-percent, .score-hero.is-scored .score-percent { text-shadow: none; }
}

/* Подвал */

.pagefoot {
  width: 100%;
  max-width: var(--sheet-w);
  margin: 0 auto;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 13px;
}

.noscript { padding: 24px; font-size: 16px; text-align: center; }

@media (max-width: 480px) {
  .match { grid-template-columns: 1fr 1.35fr; gap: 8px 10px; }
  .match .opt .ar { font-size: 31px; }
  .task-meta { gap: 8px 20px; }
  .btn-row .btn { flex: 1 1 100%; }
  .pagefoot { flex-direction: column; gap: 2px; }
  .result-item { grid-template-columns: 1fr; }
}
