/* === Дизайн-токены === */
:root, [data-theme="dark"] {
  /* Цвета фона */
  --bg: #0d1117; --bg2: #161b22; --bg3: #21262d;
  /* Цвета текста */
  --text: #c9d1d9; --text-bright: #f0f6fc; --text-muted: #8b949e; --text-dim: #484f58;
  /* Рамки */
  --border: #30363d; --border2: #21262d;
  /* Акценты */
  --accent: #58a6ff; --green: #3fb950; --red: #f85149; --yellow: #d29922;
  /* Код */
  --code-bg: #161b22; --code-color: #79c0ff;
  /* Состояния ответов */
  --correct-bg: #0f2d1a; --correct-border: #238636;
  --incorrect-bg: #2d0f0f; --incorrect-border: #f85149;
  --timeout-bg: #2d1f0f;
  /* Активный элемент */
  --active-bg: #1f6feb; --active-border: #1f6feb;
  /* Бренд */
  --go-blue: #00ADD8;
  --btn-green: #238636; --btn-green-hover: #2ea043;
  /* Медали */
  --medal-gold: #ffd700; --medal-silver: #c0c0c0; --medal-bronze: #cd7f32;
  /* Скругления */
  --r-sm: 4px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px; --r-pill: 16px;
  /* Тени */
  --shadow-card: none;
  /* Контейнер */
  --container-max: 720px;
  /* Переходы */
  --transition: 0.15s;
}
[data-theme="light"] {
  --bg: #f6f8fa; --bg2: #ffffff; --bg3: #eaeef2;
  --text: #1f2328; --text-bright: #1b1f24; --text-muted: #59636e; --text-dim: #8b949e;
  --border: #d1d9e0; --border2: #e8ecf0;
  --accent: #0969da; --green: #1a7f37; --red: #cf222e; --yellow: #9a6700;
  --code-bg: #eef1f6; --code-color: #0550ae;
  --correct-bg: #dafbe1; --correct-border: #1a7f37;
  --incorrect-bg: #ffebe9; --incorrect-border: #cf222e;
  --timeout-bg: #fff8c5;
  --active-bg: #0969da; --active-border: #0969da;
  --go-blue: #007d9c;
  --shadow-card: 0 1px 3px rgba(27,31,36,0.04), 0 1px 2px rgba(27,31,36,0.06);
}

/* === Сброс и база === */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 2rem 1rem;
}
.container { max-width: var(--container-max); width: 100%; }

/* === Карточка (переиспользуемый паттерн) === */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}

/* === Верхняя панель (логотип + тема) === */
nav {
  margin-bottom: 1.5rem; display: flex; align-items: center;
  padding: 0.5rem 0;
}
.nav-logo {
  display: flex; align-items: baseline; gap: 0;
  text-decoration: none; white-space: nowrap;
  transition: opacity var(--transition);
}
.nav-logo:hover { opacity: 0.8; text-decoration: none; }
.nav-logo-go {
  font-size: 1.6rem; font-weight: 900; color: var(--go-blue);
  letter-spacing: -0.03em; line-height: 1;
}
.nav-logo-sep {
  font-size: 1.1rem; font-weight: 300; color: var(--border);
  margin: 0 0.25em; opacity: 0.5;
}
.nav-logo-text {
  font-size: 1rem; font-weight: 500; color: var(--text-muted);
  letter-spacing: 0.01em;
}
.theme-toggle {
  margin-left: auto; background: none; border: 1px solid var(--border);
  color: var(--text-muted); padding: 0.4rem 0.5rem; border-radius: var(--r-md);
  cursor: pointer; font-size: 1rem; line-height: 1; transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text); background: var(--bg2); }

/* === Нижняя навигация (sticky bottom tab bar) === */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: center;
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 0.4rem 0; padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
  box-shadow: var(--shadow-card);
}
.bottom-nav-inner {
  display: flex; width: 100%; max-width: var(--container-max); justify-content: space-around;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  text-decoration: none; color: var(--text-muted);
  font-size: 0.7rem; font-weight: 500; padding: 0.25rem 0.75rem;
  border-radius: var(--r-md); transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a:hover { color: var(--text); }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav .bnav-icon { font-size: 1.2rem; line-height: 1; }
.bottom-nav-spacer { height: 3.5rem; }

/* === Pull-to-refresh (Telegram Mini App) === */
.ptr {
  display: flex; justify-content: center; align-items: center;
  height: 0; overflow: hidden; transition: none; opacity: 0;
}
.ptr-icon {
  font-size: 1.5rem; color: var(--text-muted); transition: transform 0.1s linear;
  display: inline-block;
}
.ptr-ready .ptr-icon { color: var(--accent); }
.ptr-loading .ptr-icon { animation: ptr-spin 0.6s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* === Bot footer === */
.bot-footer {
  margin-top: 1.25rem; padding: 0.75rem 1rem; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  display: flex; align-items: center; gap: 0.75rem;
  box-shadow: var(--shadow-card);
}
.bot-footer-icon { font-size: 1.3rem; flex-shrink: 0; line-height: 1; }
.bot-footer-text { flex: 1; color: var(--text-muted); font-size: 0.9rem; }
.bot-footer-link {
  flex-shrink: 0; padding: 0.4rem 1rem; background: var(--accent); color: #fff;
  border-radius: var(--r-md); text-decoration: none; font-weight: 600; font-size: 0.85rem;
  transition: opacity var(--transition);
}
.bot-footer-link:hover { opacity: 0.85; }

/* === Кнопки === */
.btn-primary {
  display: inline-block; padding: 0.75rem 2rem; background: var(--btn-green); color: #fff;
  border: none; border-radius: var(--r-md); font-size: 1.1rem; cursor: pointer;
  font-weight: 600; transition: background 0.2s; text-decoration: none;
}
.btn-primary:hover { background: var(--btn-green-hover); }
.btn-primary:disabled { background: var(--bg3); color: var(--text-dim); cursor: not-allowed; }

/* === Значки сложности === */
.diff-badge, .diff-tag {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: var(--r-xl);
  font-size: 0.8rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.diff-easy { background: var(--correct-bg); color: var(--green); }
.diff-medium { background: var(--timeout-bg); color: var(--yellow); }
.diff-hard { background: var(--incorrect-bg); color: var(--red); }

.diff-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.diff-dot.easy { background: var(--green); }
.diff-dot.medium { background: var(--yellow); }
.diff-dot.hard { background: var(--red); }

/* === Код === */
.q-text code, .explanation code, .accordion-question code {
  background: var(--code-bg); padding: 0.15rem 0.4rem; border-radius: var(--r-sm);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.9em; color: var(--code-color);
}

/* === Навигация между страницами === */
.page-nav { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border2); }
.page-nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.page-nav-links a {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.6rem 0.75rem; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-md); text-decoration: none; transition: border-color var(--transition);
  min-width: 0; overflow: hidden; box-shadow: var(--shadow-card);
}
.page-nav-links a:hover { border-color: var(--accent); }
.page-nav-links .nav-label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.page-nav-links .nav-text { font-size: 0.8rem; color: var(--text); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-nav-links .nav-next { text-align: right; }
.page-nav-links .nav-placeholder { visibility: hidden; }
.page-nav-all { display: block; text-align: center; margin-top: 0.75rem; font-size: 0.85rem; color: var(--accent); text-decoration: none; }
.page-nav-all:hover { text-decoration: underline; }

/* === Общие заголовки и стили текста === */
h1 { color: var(--text-bright); font-size: 1.6rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-muted); margin-bottom: 0.5rem; font-size: 0.95rem; line-height: 1.6; }
.stats { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1rem; }
.green { color: var(--green); }
.name-error { display: none; color: var(--red); font-size: 0.85rem; margin-top: 0.3rem; }
.name-error.show { display: block; }

/* ========================================
   Квиз (quiz.html) и Собеседование (interview.html)
   ======================================== */
.screen { display: none; }
.screen.active { display: block; }

.interview-features { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1rem; }
.iv-feature {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; color: var(--text-muted); text-align: left;
}
.iv-icon { font-size: 1rem; flex-shrink: 0; }

.start-card-form { margin-top: 0.75rem; padding: 1.25rem; }

.start-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 1.5rem; text-align: center; box-shadow: var(--shadow-card);
}
.start-card h1 { font-size: 1.6rem; color: var(--text-bright); margin-bottom: 0.75rem; }
.start-summary { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; margin-bottom: 1.25rem; }
.diff-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 0.5rem; background: var(--bg3); }
.diff-bar span { height: 100%; }
.diff-bar .db-easy { width: 30%; background: var(--green); }
.diff-bar .db-medium { width: 40%; background: var(--yellow); }
.diff-bar .db-hard { width: 30%; background: var(--red); }
.diff-bar-even .db-easy, .diff-bar-even .db-medium, .diff-bar-even .db-hard { width: 33.33%; }
.diff-legend { display: flex; justify-content: center; gap: 1rem; margin-bottom: 1.25rem; font-size: 0.8rem; color: var(--text-muted); }
.diff-legend span { display: flex; align-items: center; gap: 0.3rem; }
.start-card input {
  width: 100%; max-width: 300px; padding: 0.75rem 1rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text); font-size: 1rem; outline: none; margin-bottom: 1rem;
}
.start-card input:focus { border-color: var(--accent); }
.start-card input::placeholder { color: var(--text-dim); }
.start-db-stats {
  display: flex; justify-content: center; align-items: center; gap: 0.4rem;
  flex-wrap: wrap; font-size: 0.85rem; color: var(--text-muted); margin-top: 1.25rem;
}
.start-db-stats .sep { color: var(--text-dim); }
.start-db-stats span { display: inline-flex; align-items: center; gap: 0.3rem; }
.start-db-stats + .start-db-stats { margin-top: 0.25rem; }

/* Details (общий стиль для how-to и scoring-info) */
.info-details { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0.75rem 1rem; box-shadow: var(--shadow-card); }
.info-details summary { cursor: pointer; color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.info-details summary:hover { color: var(--text); }

.how-to { margin-top: 1.25rem; }
.how-to-steps { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.how-to-step {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.6rem; background: var(--bg); border: 1px solid var(--border2);
  border-radius: var(--r-md);
}
.how-to-num {
  flex-shrink: 0; width: 1.8rem; height: 1.8rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border-radius: 50%;
  font-weight: 700; font-size: 0.8rem; color: var(--accent);
}
.how-to-text { font-size: 0.85rem; color: var(--text); line-height: 1.4; }
.how-to-text small { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 0.1rem; }
.diff-scores { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.2rem; }
.diff-scores span { display: flex; align-items: center; gap: 0.35rem; }
.diff-scores .pts, .scoring-info .pts {
  margin-left: auto; font-style: normal; font-weight: 600; font-size: 0.7rem;
  color: var(--text-muted); background: var(--bg3);
  padding: 0.1rem 0.4rem; border-radius: var(--r-sm); white-space: nowrap;
}

.next-countdown {
  display: none; margin: 1.25rem 0 0; padding: 0.6rem 1rem;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color var(--transition);
}
.next-countdown:hover { border-color: var(--accent); }
.next-countdown-bar {
  position: absolute; top: 0; left: 0; height: 100%;
  background: var(--accent); opacity: 0.12;
  transition: none;
}
.next-countdown-text {
  position: relative; text-align: center;
  color: var(--text); font-size: 0.85rem; font-family: inherit;
}
.next-countdown-text span { color: var(--accent); font-weight: 600; }

.btn-quit {
  display: block; margin: 1.5rem auto 0; padding: 0.5rem 1.25rem;
  background: none; border: none; border-radius: 0;
  color: var(--text-dim); font-size: 0.8rem; cursor: pointer;
  font-family: inherit; transition: color var(--transition);
  text-decoration: none;
}
.btn-quit:hover { color: var(--red); }

/* Прогресс-бар раунда */
.progress-bar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; margin-bottom: 0.75rem; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.progress-text { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }

/* Таймер */
.timer-bar { height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-bottom: 0.5rem; }
.timer-fill { height: 100%; background: var(--green); width: 100%; transition: width 1s linear, background-color 0.5s; }
.timer-fill.warning { background: var(--yellow); }
.timer-fill.danger { background: var(--red); }
.timer-text { text-align: right; font-size: 0.85rem; color: var(--text-muted); }

/* Вопрос квиза */
.q-header { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; color: var(--text-muted); font-size: 0.9rem; }
.q-text {
  font-size: 1.15rem; color: var(--text-bright); line-height: 1.6; margin-bottom: 1.5rem;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.options { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.5rem; }
.option-btn {
  padding: 1rem 1.25rem; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text); font-size: 1rem; cursor: pointer;
  text-align: left; transition: all 0.2s; font-family: inherit;
  box-shadow: var(--shadow-card);
}
.option-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--bg); }
.option-btn:disabled { cursor: default; }
.option-btn.correct { background: var(--correct-bg); border-color: var(--green); color: var(--green); }
.option-btn.incorrect { background: var(--incorrect-bg); border-color: var(--red); color: var(--red); }
.option-btn.dimmed { opacity: 0.4; }

.q-topic-badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: var(--r-xl);
  font-size: 0.75rem; font-weight: 500; background: var(--bg3);
  color: var(--text-muted); border: 1px solid var(--border);
}

/* Обратная связь */
.answer-result {
  display: none; margin-top: 1rem; padding: 1rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.answer-result.show { display: block; }
.answer-result.is-correct { border-color: var(--green); }
.answer-result.is-incorrect { border-color: var(--red); }
.answer-result.is-timeout { border-color: var(--yellow); }
.answer-result .feedback { font-size: 0.95rem; font-weight: 600; }
.answer-result .feedback.show { display: block; }
.answer-result.is-correct .feedback { color: var(--green); }
.answer-result.is-incorrect .feedback { color: var(--red); }
.answer-result.is-timeout .feedback { color: var(--yellow); }
.answer-result .explanation {
  display: none; margin-top: 0.75rem; padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--text); font-size: 0.9rem; line-height: 1.6;
}
.answer-result .explanation.show { display: block; }

/* Результат */
.result-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 2rem; text-align: center; box-shadow: var(--shadow-card);
}
.result-card h2 { font-size: 1.5rem; color: var(--text-bright); margin-bottom: 1rem; }
.result-score { font-size: 3rem; font-weight: bold; color: var(--accent); margin-bottom: 0.25rem; }
.result-details { color: var(--text-muted); margin-bottom: 2rem; }
.lb-title { color: var(--text-bright); margin-bottom: 1rem; font-size: 1.1rem; }
.result-verdict {
  padding: 0.75rem 1rem; border-radius: var(--r-md); margin-bottom: 1rem;
  background: var(--bg); border: 1px solid var(--border); font-size: 0.95rem;
  color: var(--text); text-align: left; line-height: 1.5;
}
.topic-results { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.5rem; text-align: left; }
.topic-result-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; border-radius: var(--r-md);
  background: var(--bg); border: 1px solid var(--border2);
  font-size: 0.85rem;
}
.tr-status { flex-shrink: 0; font-size: 0.9rem; width: 1.5rem; text-align: center; }
.tr-name { flex: 1; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-score { flex-shrink: 0; color: var(--text-muted); font-size: 0.8rem; }
.tr-pct { flex-shrink: 0; font-weight: 600; font-size: 0.85rem; width: 2.5rem; text-align: right; }
.tr-good .tr-pct { color: var(--green); }
.tr-ok .tr-pct { color: var(--yellow); }
.tr-bad .tr-pct { color: var(--red); }

.md-links { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.md-links a { color: var(--accent); text-decoration: none; margin: 0 0.75rem; }
.md-links a:hover { text-decoration: underline; }
.no-leaderboard-note { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: 1.5rem; padding: 0.75rem 1rem; background: var(--bg2); border-radius: var(--r-md); border: 1px solid var(--border); }
.no-leaderboard-note a { color: var(--accent); text-decoration: none; }
.no-leaderboard-note a:hover { text-decoration: underline; }

/* === Лидерборд (общий для квиза и страницы лидеров) === */
.lb-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 2rem; text-align: left; }
.lb-entry {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.75rem; border-radius: var(--r-md);
  background: var(--bg2); border: 1px solid var(--border2);
  transition: background var(--transition); box-shadow: var(--shadow-card);
}
.lb-entry:hover { background: var(--bg3); }
.lb-entry:nth-child(1), .lb-entry.top-1 { border-color: var(--medal-gold); }
.lb-entry:nth-child(2), .lb-entry.top-2 { border-color: var(--medal-silver); }
.lb-entry:nth-child(3), .lb-entry.top-3 { border-color: var(--medal-bronze); }
.lb-rank { flex-shrink: 0; width: 2.2rem; text-align: center; font-size: 1.2rem; line-height: 1; }
.lb-rank-num { color: var(--text-dim); font-weight: 700; font-size: 0.9rem; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { color: var(--text-bright); font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stats { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.15rem; }
.lb-score-val { color: var(--green); font-weight: 700; }
.lb-score-col { flex-shrink: 0; text-align: right; }
.lb-score-val { font-size: 1.3rem; line-height: 1; }
.lb-score-label { color: var(--text-dim); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* ========================================
   Страница лидеров (leaderboard.html)
   ======================================== */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-dim); font-size: 1.1rem; }
.empty a { color: var(--accent); text-decoration: none; }
.empty a:hover { text-decoration: underline; }
.scoring-info { margin-top: 1.25rem; }
.scoring-info p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.75rem; line-height: 1.5; }
.scoring-info ul { list-style: none; margin: 0.5rem 0; padding: 0; }
.scoring-info li { color: var(--text); font-size: 0.85rem; padding: 0.2rem 0; display: flex; align-items: center; gap: 0.4rem; }

/* ========================================
   Индекс вопросов (questions.html)
   ======================================== */
.intro { color: var(--text-muted); font-size: 0.95rem; line-height: 1.7; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border2); }
.intro a { color: var(--accent); }
.topic-card {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 0.75rem 1rem; margin-bottom: 0.5rem; text-decoration: none; color: inherit;
  transition: all var(--transition); box-shadow: var(--shadow-card);
}
.topic-card:hover { border-color: var(--accent); background: var(--bg3); }
.topic-rank { flex-shrink: 0; width: 2.2rem; text-align: center; font-weight: 700; font-size: 1rem; color: var(--text-dim); }
.topic-card:hover .topic-rank { color: var(--accent); }
.topic-info { flex: 1; min-width: 0; }
.topic-title { color: var(--text-bright); font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-desc {
  color: var(--text-muted); font-size: 0.85rem; line-height: 1.4; margin-top: 0.15rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.topic-count-col { flex-shrink: 0; text-align: right; }
.topic-count-val { color: var(--green); font-weight: 700; font-size: 1.3rem; line-height: 1; }
.topic-count-label { color: var(--text-dim); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* ========================================
   Страница темы (topic.html)
   ======================================== */
.topics-nav-wrap { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border2); }
.topics-nav {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  max-height: 6rem; overflow: hidden;
  transition: max-height 0.3s ease;
}
.topics-nav.expanded { max-height: 100rem; }
.topics-nav a {
  padding: 0.3rem 0.7rem; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-pill); color: var(--text-muted); font-size: 0.8rem;
  text-decoration: none; transition: all 0.2s; white-space: nowrap;
}
.topics-nav a:hover { border-color: var(--accent); color: var(--text); }
.topics-nav a.current { background: var(--active-bg); border-color: var(--active-border); color: #fff; }
.topics-nav-toggle {
  display: none; margin-top: 0.5rem; padding: 0.25rem 0;
  background: none; border: none; color: var(--accent); font-size: 0.8rem;
  cursor: pointer; font-family: inherit; transition: all var(--transition);
}
.topics-nav-toggle:hover { color: var(--text); }
.topic-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 0.25rem;
}
.topic-header h1 { margin: 0; }
.toggle-all {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 0.35rem 0.75rem; border-radius: 6px; cursor: pointer;
  font-size: 0.8rem; font-family: inherit; transition: all 0.2s;
  white-space: nowrap; flex-shrink: 0; margin-top: 0.3rem;
}
.toggle-all:hover { border-color: var(--accent); color: var(--text); }
.topic-page-desc { color: var(--text-muted); font-size: 0.95rem; line-height: 1.65; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border2); }

/* Аккордеон вопросов */
.accordion {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-lg);
  margin-bottom: 0.75rem; overflow: hidden; transition: border-color 0.2s;
  box-shadow: var(--shadow-card);
}
.accordion:hover { border-color: var(--text-dim); }
.accordion-header { padding: 1rem 1.25rem; cursor: pointer; display: flex; align-items: flex-start; gap: 0.75rem; user-select: none; }
.accordion-num { color: var(--text-dim); font-size: 0.85rem; min-width: 2rem; padding-top: 0.1rem; font-weight: 600; }
.accordion-question { flex: 1; font-size: 1rem; line-height: 1.5; color: var(--text-bright); }
.accordion-toggle { color: var(--text-dim); font-size: 1.2rem; transition: transform 0.2s; line-height: 1; padding-top: 0.1rem; }
.accordion.open .accordion-toggle { transform: rotate(90deg); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.accordion.open .accordion-body { max-height: 800px; }
.accordion-body-inner { padding: 0 1.25rem 1.25rem; padding-left: 3.5rem; }
.answer { display: inline-block; background: var(--correct-bg); border: 1px solid var(--correct-border); color: var(--green); padding: 0.35rem 0.75rem; border-radius: 6px; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.75rem; }
.explanation { color: var(--text-muted); font-size: 0.95rem; line-height: 1.7; }
.q-link { display: inline-block; margin-top: 0.75rem; color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.q-link:hover { text-decoration: underline; }

/* ========================================
   Страница вопроса (question.html)
   ======================================== */
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 0.4rem; }
.q-meta { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.topic-label { color: var(--text-muted); font-size: 0.9rem; }
.option {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-lg); font-size: 1rem; color: var(--text); transition: all var(--transition);
  box-shadow: var(--shadow-card);
}
.option:hover { background: var(--bg3); }
.option-badge {
  flex-shrink: 0; width: 2.2rem; height: 2.2rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border-radius: 50%;
  font-weight: 700; font-size: 0.9rem; color: var(--text-muted);
}
.option-text { flex: 1; min-width: 0; line-height: 1.5; }
.option.correct { background: var(--correct-bg); border-color: var(--correct-border); }
.option.correct .option-badge { background: var(--correct-border); color: #fff; }
.option.correct .option-text { color: var(--green); font-weight: 600; }
.answer-section {
  background: var(--bg2); border: 1px solid var(--border); border-left: 3px solid var(--green);
  border-radius: var(--r-lg); padding: 1.5rem; margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}
.answer-heading {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; color: var(--accent); font-size: 1.1rem;
  margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.answer-heading svg { flex-shrink: 0; color: var(--accent); }

/* === Подробное объяснение (explanation-full) === */
.explanation-full { color: var(--text); font-size: 0.95rem; line-height: 1.7; }
.explanation-full p { margin: 0.75rem 0; }
.explanation-full p:first-child { margin-top: 0; }
.explanation-full p:last-child { margin-bottom: 0; }
.explanation-full code {
  background: var(--code-bg); padding: 0.15rem 0.4rem; border-radius: var(--r-sm);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.9em; color: var(--code-color);
}
.explanation-full pre {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 1rem 1.25rem; margin: 1rem 0; overflow-x: auto; line-height: 1.5;
}
.explanation-full pre code {
  background: none; padding: 0; border-radius: 0; font-size: 0.85rem; color: var(--text-bright);
}
.explanation-full ul, .explanation-full ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.explanation-full li { margin-bottom: 0.35rem; }
.explanation-full strong { color: var(--text-bright); }
.explanation-full h3 { color: var(--text-bright); font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
.explanation-full h4 { color: var(--text-bright); font-size: 1rem; margin: 1rem 0 0.4rem; }

/* ========================================
   Страница ошибки (error.html)
   ======================================== */
.error-page { text-align: center; padding: 4rem 2rem; }
.error-emoji { font-size: 4rem; margin-bottom: 1rem; }
.error-code { font-size: 5rem; font-weight: 800; color: var(--text-dim); line-height: 1; margin-bottom: 0.5rem; }
.error-title { color: var(--text-bright); font-size: 1.5rem; margin-bottom: 0.75rem; }
.error-message { color: var(--text-muted); font-size: 1rem; margin-bottom: 2rem; line-height: 1.6; }

/* ========================================
   README (readme.html)
   ======================================== */
.readme-body { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 2rem; box-shadow: var(--shadow-card); }

/* ========================================
   KB - база знаний (index)
   ======================================== */
.kb-stats {
  display: flex; justify-content: center; gap: 1.5rem;
  margin: 1.5rem 0; padding: 1rem;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.kb-stat { text-align: center; }
.kb-stat-val { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.kb-stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.kb-section-title { font-size: 1rem; color: var(--text-muted); margin: 1.5rem 0 0.75rem; font-weight: 500; }
.lang-icon { width: 2rem; height: 2rem; object-fit: contain; }
.kb-topics-preview {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  padding: 0 0.25rem; margin-bottom: 1.25rem;
}
.kb-topic-chip {
  font-size: 0.7rem; padding: 0.2rem 0.5rem;
  background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--r-sm);
  color: var(--text-muted); text-decoration: none; transition: all var(--transition);
  white-space: nowrap;
}
.kb-topic-chip:hover { color: var(--accent); border-color: var(--accent); background: var(--bg2); }
.kb-cta {
  text-align: center; margin: 1.5rem 0;
  padding: 1.25rem; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
.kb-cta-text { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.75rem; }
.kb-cta-links { display: flex; justify-content: center; gap: 0.75rem; flex-wrap: wrap; }
.kb-cta-link {
  font-size: 0.85rem; padding: 0.5rem 1rem;
  background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--r-md);
  color: var(--text); text-decoration: none; transition: all var(--transition);
}
.kb-cta-link:hover { border-color: var(--accent); color: var(--accent); }

/* ========================================
   Светлая тема (дополнения)
   ======================================== */
[data-theme="light"] .bottom-nav {
  box-shadow: 0 -1px 3px rgba(27,31,36,0.06);
}

/* ========================================
   Мобильная адаптация
   ======================================== */
@media (max-width: 480px) {
  .start-card, .result-card { padding: 1.25rem; border-radius: var(--r-lg); }
  .start-card h1 { font-size: 1.5rem; }
  .start-card input { max-width: 100%; padding: 0.65rem 0.85rem; font-size: 0.95rem; }
  .btn-primary { padding: 0.65rem 1.5rem; font-size: 1rem; }
  .q-text { font-size: 1.05rem; padding: 1rem; margin-bottom: 1rem; }
  .option-btn { padding: 0.75rem 1rem; font-size: 0.95rem; }
  .options { gap: 0.5rem; }
  .answer-result { padding: 0.75rem; }
  .answer-result .feedback { font-size: 0.9rem; }
  .result-score { font-size: 2.5rem; }
}
