:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --amber: #f59e0b;
  --code-bg: #090d16;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: 60px;
}

header {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 16px 24px;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.brand-badge {
  background: var(--accent);
  color: #090d16;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 800;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  transition: all 0.15s;
}

.tab-btn.active,
.tab-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
}

.container {
  max-width: 1120px;
  margin: 24px auto;
  padding: 0 20px;
}

.accent-text {
  color: var(--accent);
  margin-left: 6px;
  font-weight: 600;
}

.muted-text {
  color: var(--muted);
  font-size: 0.88rem;
}

/* Toolbar & Filters */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.progress-bar-wrap {
  flex: 1;
  min-width: 200px;
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  width: 0%;
  transition: width 0.3s ease;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--accent);
  color: #090d16;
  border-color: var(--accent);
  font-weight: 700;
}

.search-input {
  margin-left: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  min-width: 210px;
}

/* Flashcard Stage */
.flashcard-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  min-height: 430px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 8px;
  flex-wrap: wrap;
}

.module-tag {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-weight: 700;
}

.status-pill {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.status-mastered {
  background: rgba(34, 197, 94, 0.2);
  color: var(--green);
}

.status-review {
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber);
}

.status-unseen {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.question-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}

.question-ru {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.answer-box {
  display: none;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 12px;
  animation: fadeIn 0.2s ease;
}

.answer-box.visible {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.short-answer {
  background: rgba(56, 189, 248, 0.08);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 16px;
  font-size: 0.98rem;
}

.details-list {
  margin: 12px 0 16px 20px;
}

.details-list li {
  margin-bottom: 8px;
  color: #e2e8f0;
}

pre.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.83rem;
  color: #cbd5e1;
  margin-top: 12px;
}

.card-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.88rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent);
  color: #090d16;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #7dd3fc;
}

.btn-green {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border-color: var(--green);
}

.btn-amber {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border-color: var(--amber);
}

/* Simulators */
.sim-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.sim-steps {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.step-pill {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  transition: all 0.15s;
}

.step-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.sim-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.sim-box h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

.reg-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface);
  border-radius: 6px;
  margin-bottom: 6px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.83rem;
}

.reg-highlight {
  border: 1px solid var(--accent);
  color: var(--accent);
}

/* Wiki Accordion & Cheat Sheet */
.section-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.accordion-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.accordion-header {
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.accordion-header:hover {
  background: var(--surface-hover);
}

.accordion-body {
  padding: 0 18px 18px 18px;
  display: none;
  border-top: 1px solid var(--border);
}

.accordion-item.open .accordion-body {
  display: block;
  padding-top: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table.cheat-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}

table.cheat-table th,
table.cheat-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.88rem;
  vertical-align: top;
}

table.cheat-table th {
  background: #0b1120;
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* Длинное слово заголовка не должно расширять страницу при крупном тексте на 320 px. */
.route-view h2 {
  overflow-wrap: break-word;
}

.kbd-hint {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin-top: 12px;
}

.filter-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}

.level-chip {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.level-chip.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(56, 189, 248, 0.16);
  font-weight: 700;
}

.level-badge {
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 700;
}

.level-base {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.level-senior {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.level-deep {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.practical-box {
  background: rgba(168, 85, 247, 0.09);
  border-left: 4px solid #a855f7;
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 14px 0;
  font-size: 0.93rem;
  color: #f1f5f9;
}

/* Reading and review controls */
button, input, summary { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn, .chip, .level-chip, .step-pill, summary { min-height: 44px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:disabled:hover { background: var(--bg); border-color: var(--border); }
.study-settings summary { cursor: pointer; display: list-item; padding: 8px 0; }
.study-settings .filter-row { margin: 12px 0; }
.search-input { font-size: 1rem; max-width: 100%; min-height: 44px; }
.recall-prompt { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
.storage-notice { padding: 12px; border: 1px solid var(--amber); border-radius: 8px; margin-bottom: 12px; }
/* Новая версия на сервере: строка в липкой шапке, видна с любого места страницы */
.update-banner { position: fixed; right: 16px; bottom: 16px; z-index: 70; max-width: calc(100% - 32px); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); box-shadow: 0 6px 20px rgba(2, 6, 23, 0.5); font-size: 0.9rem; }
.update-banner.hidden { display: none; }
.site-version { margin: 28px 0 8px; text-align: center; font-size: 0.75rem; color: var(--muted); }
@media (max-width: 640px) {
  /* Телефон: у верхнего края — внизу уже нижняя панель и кнопки карточки */
  .update-banner { top: max(8px, env(safe-area-inset-top, 0px)); bottom: auto; left: 8px; right: 8px; max-width: none; flex-wrap: nowrap; }
  .update-banner span { flex: 1; min-width: 0; }
}
.flashcard-stage { scroll-margin-top: 140px; }
.answer-box { scroll-margin-top: 140px; }
.flashcard-stage > div, .sim-grid > *, .accordion-header > * { min-width: 0; }
.question-title, .question-ru, .answer-box, .accordion-body, .sim-card { overflow-wrap: anywhere; }
pre.code-block { max-width: 100%; overflow-wrap: normal; }
.accordion-header { width: 100%; border: 0; background: transparent; color: var(--text); text-align: left; flex-wrap: wrap; }
.accordion-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sim-grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.reg-row { flex-wrap: wrap; }

@media (max-width: 640px) {
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
  header { position: static; padding: 10px 12px; }
  .header-inner { gap: 8px; }
  .brand { font-size: 0.95rem; gap: 8px; }
  .brand-badge { white-space: nowrap; }
  .nav-tabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding: 4px 2px; }
  .tab-btn { flex: 0 0 auto; white-space: nowrap; }
  .container { margin: 12px auto; padding: 0 12px; }
  .toolbar { padding: 12px; margin-bottom: 12px; gap: 4px; }
  .progress-row { gap: 8px; }
  .progress-bar-wrap { min-width: 80px; }
  .progress-row > div:first-child { width: 100%; }
  .search-input { width: 100%; min-width: 0; }
  .flashcard-stage { padding: 16px; min-height: 0; scroll-margin-top: 12px; }
  .answer-box { scroll-margin-top: 12px; }
  .card-meta { gap: 6px; margin-bottom: 12px; }
  .question-title { font-size: 1.15rem; }
  .card-controls { position: sticky; bottom: 0; background: var(--surface); margin: 16px -4px -4px; padding: 12px 4px max(12px, env(safe-area-inset-bottom, 0px)); gap: 8px; }
  .card-controls .btn { justify-content: center; padding: 9px 7px; font-size: 0.82rem; min-width: 0; overflow-wrap: anywhere; }
  .card-navigation { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr); width: 100%; }
  .card-grades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  /* Панель заняла бы больше 30 % экрана (fitCardControls): прилипает только строка навигации */
  .card-controls.controls-compact { display: contents; }
  .card-controls.controls-compact .card-navigation { position: sticky; bottom: 0; z-index: 5; width: auto; margin: 16px -4px 0; padding: 12px 4px max(12px, env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--border); }
  .card-controls.controls-compact > :not(.card-navigation) { margin-top: 10px; }
  .card-controls.controls-compact .card-navigation { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) minmax(0, 1fr); }
  .card-controls.controls-compact .nav-label { display: none; }
  .kbd-hint { display: none; }
  .short-answer, .practical-box { padding: 12px; }
  .sim-card { padding: 16px; }
  .accordion-header { padding: 12px; }
  .accordion-body { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


.translated-answer { margin: 12px 0 16px; }
.translated-answer summary { cursor: pointer; padding: 8px 0; color: var(--accent); }
.translated-answer p { margin-top: 8px; }
.content-references { margin: 16px 0; color: var(--muted); font-size: 0.9rem; }
.content-references ul { margin-left: 20px; }
.content-references a { color: var(--accent); text-underline-offset: 3px; }

.practice-box { margin-top: 20px; border: 1px solid var(--accent); border-radius: 10px; padding: 12px; }
.practice-box summary { cursor: pointer; padding: 8px 0; color: var(--accent); }
.practice-box p { margin: 10px 0; }
.practice-solution { margin-top: 16px; border-top: 1px solid var(--border); }

.learning-hint, .step-recall { margin: 16px 0; padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.channel-scene { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.select-paths { list-style: none; padding: 0; display: grid; gap: 10px; margin: 16px 0; }
.select-path { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.select-path code, .select-path strong { overflow-wrap: anywhere; }
.select-path p { margin: 6px 0 0; }
.select-path-arrow { color: var(--accent); font-size: 1.4rem; }
@media (max-width: 600px) {
  .select-path { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .select-path-arrow { transform: rotate(90deg); justify-self: start; }
}
.channel-part { min-width: 0; padding: 14px; background: var(--bg); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: 10px; }
.channel-sender { border-top-color: var(--amber); }
.channel-state { border-top-color: var(--green); }
.channel-part h4 { margin-bottom: 8px; }
.channel-transfer { margin-top: 12px; padding: 12px; border-left: 3px solid var(--accent); }
.step-recall p, .step-recall details { margin-top: 10px; }
.sim-navigation { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.sim-navigation .btn { flex: 1 1 150px; white-space: normal; }
.sim-step-start { scroll-margin-top: 140px; }
.sim-step-start:focus { outline: 2px solid var(--accent); outline-offset: 4px; }
.related-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.related-links a { color: var(--accent); text-underline-offset: 3px; padding: 10px 0; min-width: 0; overflow-wrap: anywhere; }
#quiz-container > .sim-card { scroll-margin-top: 140px; }
@media (max-width: 600px) {
  .channel-scene { grid-template-columns: minmax(0, 1fr); }
}

/* --- План 13 недель (#/plan) --- */
.plan-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.plan-today { padding: 10px 12px; border-left: 4px solid var(--accent); background: rgba(56, 189, 248, 0.08); border-radius: 6px; }
.plan-today a { color: var(--accent); overflow-wrap: anywhere; }
.plan-review { margin: 10px 0 0; }
[data-review-start] { white-space: normal; text-align: left; max-width: 100%; }
.plan-weeks { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-chip { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-width: 64px; justify-content: center; }
.plan-chip.is-current { border-color: var(--amber); }
.plan-chip-count { font-size: 0.75rem; color: var(--muted); }
/* Телефон: недели в одну прокручиваемую строку — первый экран остаётся за задачей дня. */
@media (max-width: 640px) {
  .plan-weeks { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; padding: 2px 2px 6px; scrollbar-width: thin; }
  .plan-chip { flex: 0 0 auto; }
}
.plan-settings-row { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; min-width: 0; }
.plan-settings-row input[type="date"] { max-width: 100%; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 44px; }
.plan-file { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
.plan-file:focus-visible + .btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan-week h2 { margin: 4px 0 12px; }
.plan-week h2:focus { outline: none; }
.plan-week > p { margin-bottom: 8px; }
.plan-day { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); }
.plan-day.is-today h3 { color: var(--amber); }
.plan-day h3, .plan-block h3 { font-size: 1.05rem; margin-bottom: 8px; }
.plan-tasks { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.plan-task { min-width: 0; }
.plan-task { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.plan-task.is-optional { border-style: dashed; }
.plan-task-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.plan-task-row input[type="checkbox"] { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--green); }
.plan-task-row label { flex: 1 1 220px; cursor: pointer; }
.plan-task input:checked + label { color: var(--muted); text-decoration: line-through; }
.plan-optional { font-size: 0.75rem; color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.5); border-radius: 999px; padding: 0 8px; margin-left: 6px; white-space: nowrap; }
.plan-links { margin-top: 6px; gap: 4px 14px; font-size: 0.9rem; }
.plan-links a { overflow-wrap: anywhere; }
.plan-hint summary, .plan-talk summary { font-size: 0.9rem; }
.plan-talk-body p { margin: 6px 0; }
.plan-dialog-them { color: var(--muted); }
.plan-block { margin-top: 24px; }
.plan-block ul { padding-left: 20px; }
.plan-block a { color: var(--accent); overflow-wrap: anywhere; }
.plan-materials-group h4 { margin: 10px 0 4px; font-size: 0.95rem; color: var(--muted); }
.plan-predict-list { padding-left: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.plan-predict { min-width: 0; }
.plan-answer { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font: inherit; margin-top: 4px; }
.plan-pager { margin-top: 24px; justify-content: space-between; }
.plan-rules { margin-top: 12px; }
.plan-chip.active .plan-chip-count { color: inherit; opacity: 0.85; }
.plan-secondary { font-size: 0.72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; text-decoration: none; display: inline-block; }
.plan-unreviewed { font-size: 0.72rem; color: var(--amber); border: 1px dashed rgba(245, 158, 11, 0.6); border-radius: 999px; padding: 0 6px; margin-left: 6px; white-space: nowrap; }
.plan-link { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; min-width: 0; }
.plan-start-note { margin-top: 8px; color: var(--amber); }
.plan-start-note:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan-calendar { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.plan-calendar-status { margin: 0; overflow-wrap: anywhere; }
.plan-calendar > summary { cursor: pointer; display: list-item; min-height: 28px; }
.plan-calendar-edit { color: var(--accent); }
.plan-calendar[open] .plan-calendar-edit { display: none; }
.plan-readonly { margin: 10px 0 0; }
.plan-start-note .btn { margin-left: 8px; }
.plan-calendar select { max-width: 100%; min-width: 0; min-height: 44px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.plan-accept { margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--border); font-size: 0.9rem; overflow-wrap: anywhere; }
.plan-accept p { margin: 2px 0; }
.plan-gap { color: var(--muted); }
/* Тренажёр проговора (js/talk-trainer.js): кнопка под задачей и окно-шторка */
.talk-trainer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.talk-last { font-size: 0.82rem; }
.talk-sheet { max-height: 92vh; overflow-y: auto; }
.talk-body > * + * { margin-top: 10px; }
.talk-progress { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.talk-step-time.is-over { color: var(--amber); font-weight: 700; }
.talk-step-name { font-size: 1.2rem; }
.talk-step-name:focus-visible, #talk-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.talk-phrase em { color: var(--text); }
.talk-model { padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 6px; overflow-wrap: anywhere; }
.talk-rates { border: 0; padding: 0; margin-top: 14px; }
.talk-rates legend { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.talk-rate { min-height: 44px; }
.talk-rate-said { border-color: var(--green); }
.talk-rate-partial { border-color: var(--amber); }
.talk-results { padding-left: 20px; }
.talk-result-said::marker { color: var(--green); }
.talk-result-partial::marker { color: var(--amber); }
.talk-weak { overflow-wrap: anywhere; }
.plan-model summary { font-size: 0.9rem; }
.plan-model p { margin: 6px 0; overflow-wrap: anywhere; }

/* --- Схема-доска планировщика (board) и компактные шаги --- */
.step-pill { display: inline-flex; align-items: center; gap: 8px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em; height: 1.6em; border-radius: 999px; border: 1px solid currentColor; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .sim-steps { gap: 6px; }
  .step-pill { padding: 6px; min-width: 44px; justify-content: center; }
  .step-pill .step-title { display: none; }
}
.board-wrap { margin-top: 16px; }
.board-legend { font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; }
.board-panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) { .board-panels.is-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.board-panel { margin: 0; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.board-caption { font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.board-lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.board-lane { min-width: 0; padding: 10px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; background: var(--surface); }
.lane-p { border-left-color: var(--green); }
.lane-grq { border-left-color: var(--accent); }
.lane-netpoll { border-left-color: #a855f7; }
.lane-syscall, .lane-m { border-left-color: var(--amber); }
.lane-sysmon, .lane-timer, .lane-other { border-left-color: var(--muted); }
.board-lane-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; margin-bottom: 8px; }
.board-tag { font-size: 0.8rem; color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.5); border-radius: 999px; padding: 0 8px; }
.board-state { font-size: 0.78rem; color: var(--muted); }
.board-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 4px 0; min-width: 0; }
.board-slot-label { font-size: 0.78rem; color: var(--muted); min-width: 7.5em; }
.board-items { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; min-width: 0; }
.board-empty { font-size: 0.85rem; color: var(--muted); }
.g-chip { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; padding: 3px 9px; border-radius: 999px; border: 1px solid rgba(56, 189, 248, 0.6); background: rgba(56, 189, 248, 0.1); font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.85rem; min-width: 0; }
.g-chip.is-changed { border: 2px solid var(--amber); background: rgba(245, 158, 11, 0.14); }
.g-flag { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; font-size: 0.75rem; color: var(--muted); }
.g-changed { font-size: 0.7rem; font-weight: 700; color: var(--amber); text-transform: uppercase; letter-spacing: 0.03em; }
/* Значок изменения: янтарная плашка с тёмной «Δ» читается на любом фоне фишки, включая белую и чёрную дорожки GC */
.g-delta { display: inline-grid; place-items: center; min-width: 1.45em; height: 1.45em; padding: 0 3px; border-radius: 5px; background: var(--amber); color: #0f172a; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; font-size: 0.78rem; font-weight: 800; line-height: 1; align-self: center; }
/* Дорожка, где на шаге что-то изменилось: янтарная рамка; левая полоса сохраняет цвет вида дорожки */
.board-lane.has-change { border-top-color: var(--amber); border-right-color: var(--amber); border-bottom-color: var(--amber); box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35); }
.board-note { margin-top: 6px; font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
.board-formula { margin-bottom: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }
.board-formula-label { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; font-weight: 700; color: var(--accent); }
.board-changes { margin-top: 12px; padding: 10px 12px; border-left: 3px solid var(--amber); background: rgba(245, 158, 11, 0.06); border-radius: 6px; }
.board-changes h4 { font-size: 0.85rem; margin-bottom: 6px; }
.board-changes ol, .board-changes ul { padding-left: 20px; margin: 0; }
.board-changes li { margin: 3px 0; overflow-wrap: anywhere; }
/* На телефоне дорожки идут столбиком и уводят итог шага далеко вниз: список — сразу под подписью панели. */
@media (max-width: 640px) {
  .board-panel { display: flex; flex-direction: column; }
  .board-panel > .board-caption { order: -2; }
  .board-panel > .board-changes { order: -1; margin: 0 0 12px; }
}
.sim-table { margin-top: 16px; }
.sim-table > summary { color: var(--accent); cursor: pointer; }
.lane-g { border-left-color: var(--accent); }
.board-predict { margin-top: 16px; padding: 12px 14px; border: 1px dashed var(--accent); border-radius: 10px; background: rgba(56, 189, 248, 0.06); }
.board-predict h4 { font-size: 0.9rem; margin-bottom: 6px; }
.board-predict p { margin: 4px 0; }
.board-reveal { margin-top: 12px; }
.board-reveal > summary { color: var(--accent); cursor: pointer; font-weight: 600; }
.board-reveal-body > .short-answer { margin-top: 12px; }
.lane-dir { border-left-color: var(--accent); }
.lane-table { border-left-color: var(--green); }
.lane-group { border-left-color: #a855f7; }
.lane-var { border-left-color: var(--amber); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* Каналы и трёхцветная разметка GC: цвет фишки повторяет цвет множества, смысл несёт заголовок дорожки */
.lane-chan { border-left-color: #14b8a6; }
.lane-white { border-left-color: var(--text); }
.lane-white .g-chip, .lane-white .g-chip.is-changed { background: #f8fafc; color: #0f172a; }
.lane-white .g-chip { border-color: #cbd5e1; }
.lane-white .g-flag { color: #334155; }
.lane-white .g-changed { color: #b45309; }
.lane-grey { border-left-color: #64748b; }
.lane-grey .g-chip, .lane-grey .g-chip.is-changed { background: #475569; color: #f8fafc; }
.lane-grey .g-chip { border-color: #94a3b8; }
.lane-grey .g-flag { color: #e2e8f0; }
.lane-grey .g-changed { color: #fcd34d; }
.lane-black { border-left-color: #000; }
.lane-black .g-chip, .lane-black .g-chip.is-changed { background: #000; color: #f8fafc; }
.lane-black .g-chip { border-color: #64748b; }
.lane-black .g-flag { color: #cbd5e1; }

/* --- Практикум (#/practice) --- */
.practice-invariants { margin: 16px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 8px; background: var(--surface); }
.practice-invariants > summary { cursor: pointer; font-weight: 600; }
.practice-invariants-list { margin-top: 8px; padding-left: 20px; overflow-wrap: anywhere; }
.practice-invariants-list code { overflow-wrap: anywhere; word-break: break-word; }
.practice-index { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.practice-index-item { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); min-width: 0; }
.practice-index-item p { margin-top: 6px; color: #cbd5e1; overflow-wrap: anywhere; }
.practice-index-link { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; color: var(--accent); text-underline-offset: 3px; padding: 6px 0; }
.practice-week { margin-top: 18px; }
.practice-task { min-width: 0; }
.practice-meta { font-size: 0.88rem; color: var(--muted); }
.practice-meta a { color: var(--accent); text-underline-offset: 3px; display: inline-block; padding: 10px 0; }
.practice-title-en { color: var(--muted); margin-top: 2px; }
.practice-goal { margin-top: 12px; overflow-wrap: anywhere; }
.practice-section { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); min-width: 0; }
.practice-section h3 { font-size: 1.05rem; margin-bottom: 8px; overflow-wrap: anywhere; }
.practice-section h4 { font-size: 0.95rem; margin: 16px 0 6px; }
.practice-section ul { padding-left: 20px; }
.practice-section li { margin: 4px 0; overflow-wrap: anywhere; }
.practice-section p { overflow-wrap: anywhere; }
.practice-contract li { margin: 6px 0; }
.practice-file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.practice-copy-status { font-size: 0.85rem; color: var(--green); min-width: 0; overflow-wrap: anywhere; }
pre.practice-code { white-space: pre; tab-size: 4; max-width: 100%; }
pre.practice-code:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.practice-hint, .practice-talk, .practice-reference, .practice-tests { margin-top: 8px; }
/* Справка практикума (data/guides.js): оглавление, шаги тренировки, таблица команд */
.practice-guide-toc ul { margin: 12px 0 0; padding-left: 20px; }
.practice-guide-toc li { margin: 4px 0; }
.practice-guide-section h3:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.practice-guide-file h4 { margin: 14px 0 6px; font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.9rem; }
.practice-guide-steps { padding-left: 22px; }
.practice-guide-steps > li { margin: 14px 0; }
.practice-guide-steps .muted-text { margin: 6px 0 0; overflow-wrap: anywhere; white-space: pre-line; }
.practice-guide-commands { margin: 8px 0 0; }
.practice-guide-commands dt { margin-top: 12px; }
.practice-guide-commands dt code { white-space: pre-wrap; overflow-wrap: anywhere; }
.practice-guide-commands dd { margin: 2px 0 0 16px; color: var(--muted); }
.practice-guide-check { margin-top: 12px; padding: 8px 12px; border-left: 3px solid var(--green); background: var(--surface); border-radius: 6px; }
.practice-guide-links { padding-left: 20px; }
/* Трек (data/tracks.js): шаги-каты блока, отметка из плана, чужой код для разбора */
.practice-section .track-steps { list-style: none; padding: 0; margin: 10px 0 0; }
.practice-section .track-step { margin: 0; padding: 14px 0; border-top: 1px solid var(--border); min-width: 0; }
.practice-section .track-step:first-child { border-top: 0; padding-top: 4px; }
.track-step h4 { margin: 0 0 4px; font-size: 1rem; line-height: 1.45; overflow-wrap: anywhere; }
.track-step h4:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.track-label { display: inline-block; min-width: 3.4em; font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.85rem; color: var(--accent); }
.track-done { display: inline-block; margin-left: 8px; font-size: 0.75rem; font-weight: 400; color: var(--green); border: 1px solid rgba(34, 197, 94, 0.5); border-radius: 999px; padding: 0 8px; white-space: nowrap; vertical-align: middle; }
.track-step.is-done .track-label { color: var(--green); }
.track-when { margin: 0 0 6px; font-size: 0.88rem; }
.track-when a, .track-sources a, .track-variation a { color: var(--accent); text-underline-offset: 3px; }
.track-step p { margin: 6px 0; }
.track-step .related-links { margin-top: 8px; gap: 8px 14px; }
.track-sources { font-size: 0.88rem; overflow-wrap: anywhere; }
.track-review > summary { font-weight: 600; }
.track-variation { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 6px; min-width: 0; }
.track-variation p { margin: 4px 0; }
.track-rules, .track-versions { margin-top: 12px; }
/* Переход на блок или кату: заголовок не уходит под закреплённую шапку (на телефоне шапка не закреплена). */
.practice-track .practice-guide-section h3, .track-step h4 { scroll-margin-top: 130px; }
@media (max-width: 640px) { .practice-track .practice-guide-section h3, .track-step h4 { scroll-margin-top: 12px; } }
.practice-hint > summary, .practice-talk > summary, .practice-reference > summary, .practice-tests > summary { cursor: pointer; color: var(--accent); padding: 8px 0; }
.practice-hint p, .practice-talk p { margin: 6px 0 4px; overflow-wrap: anywhere; }
.practice-pager { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.practice-pager .btn { min-width: 0; overflow-wrap: anywhere; }

/* Quiz: режим «сначала свой ответ» */
.quiz-mode { margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.quiz-mode-toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; min-height: 44px; }
.quiz-mode-toggle input { width: 18px; height: 18px; }
.quiz-mode p { margin: 4px 0 0; overflow-wrap: anywhere; }
.quiz-own { display: none; margin: 16px 0 0; }
.quiz-own label { display: block; font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.quiz-own textarea { display: block; width: 100%; max-width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: inherit; font: inherit; resize: vertical; }
.quiz-own textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quiz-own-status { display: inline-block; margin-left: 8px; font-size: 0.9rem; overflow-wrap: anywhere; }
.answer-first .quiz-own { display: block; }
.answer-first .quiz-options:not(.revealed) { display: none; }

/* Вход и синхронизация (js/auth.js): справа от названия, в одной строке с ним */
.header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand account" "nav nav"; gap: 12px 16px; }
.brand { grid-area: brand; min-width: 0; }
.nav-tabs { grid-area: nav; }
.account { grid-area: account; justify-self: end; display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-signin { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.account-signin:hover { border-color: var(--accent); background: rgba(56, 189, 248, 0.14); }
.account-signin:focus-visible, .account-signout:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-icon { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.account-chip { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 4px 4px 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.account-avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); color: #090d16; font-weight: 800; font-size: 0.85rem; }
.account-email { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.84rem; color: var(--text); }
.account-status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.account-status[hidden] { display: none; }
.account-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.account-status[data-kind="ok"] .account-dot { background: var(--green); }
.account-status[data-kind="busy"] .account-dot { background: var(--amber); }
.account-status[data-kind="warn"] .account-dot { background: #f87171; }
.account-status[data-kind="warn"] { color: #fca5a5; }
.account-signout { min-height: 28px; padding: 4px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.account-signout:hover { color: var(--text); background: var(--surface-hover); }
@media (prefers-reduced-motion: no-preference) {
  .account-status[data-kind="busy"] .account-dot { animation: account-pulse 1s ease-in-out infinite alternate; }
}
@keyframes account-pulse { from { opacity: 0.35; } to { opacity: 1; } }
@media (max-width: 640px) {
  .account-signin { min-height: 32px; padding: 4px 12px 4px 10px; font-size: 0.8rem; }
  .account-email, .account-status-label, .account-signin-full { display: none; }
  .account-chip { gap: 6px; }
}
@media (min-width: 641px) {
  .account-signin-short { display: none; }
}
.sync-choice { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--amber); border-radius: 8px; background: var(--surface); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sync-choice p { margin: 0; flex-basis: 100%; overflow-wrap: anywhere; }

/* Практикум: проверка на сервере */
.practice-solution-input { display: block; width: 100%; max-width: 100%; box-sizing: border-box; margin: 6px 0 8px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--code-bg); color: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; resize: vertical; }
.practice-solution-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.practice-check-ok { color: var(--green); font-weight: 600; }
.practice-check-fail { color: #f87171; font-weight: 600; }
.practice-check-tests { list-style: none; padding-left: 0; }
.practice-check-tests li { margin: 4px 0; overflow-wrap: anywhere; }
.signin-notice { position: fixed; z-index: 80; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(640px, calc(100% - 32px)); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; padding: 10px 44px 10px 14px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); overflow-wrap: anywhere; }
.signin-notice-close { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; }
.signin-notice-close:hover, .signin-notice-close:focus-visible { color: var(--text); background: rgba(148, 163, 184, 0.15); }
@media (max-width: 640px) {
  .signin-notice { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 8px); }
}

/* --- Разделы: счётчик во вкладке; нижняя панель и шторка «Ещё» на телефоне --- */
.tab-btn { display: inline-flex; align-items: center; gap: 6px; }
.tab-count { padding: 0 7px; border-radius: 999px; background: var(--surface-hover); color: var(--muted); font-size: 0.75rem; font-weight: 700; line-height: 1.5; }
.tab-count:empty { display: none; }
.tab-btn.active .tab-count { background: rgba(56, 189, 248, 0.2); color: var(--text); }
#practice-title:focus { outline: none; } /* фокус ставится программно для читалки, рамка не нужна */
.bottom-nav { display: none; }
.nav-icon { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 640px) {
  :root { --bottom-nav-h: 58px; }
  /* --bottom-nav-space — фактическая высота панели (fitCardControls), с крупным текстом она больше */
  html { scroll-padding-bottom: calc(var(--bottom-nav-space, calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px))) + 8px); }
  body { padding-bottom: calc(var(--bottom-nav-space, calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px))) + 16px); }
  header { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .header-inner { grid-template-areas: "brand account"; }
  .nav-tabs { display: none; }
  .bottom-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); background: rgba(15, 23, 42, 0.97); border-top: 1px solid var(--border); backdrop-filter: blur(10px); }
  .bottom-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: var(--bottom-nav-h); padding: 6px 2px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.7rem; font-weight: 600; line-height: 1.1; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .bottom-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-tab.active { color: var(--accent); }
  .bottom-tab.active::before { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .bottom-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 12px; }
  /* Кнопки карточки стоят над панелью, а не под ней */
  .card-controls, .card-controls.controls-compact .card-navigation { bottom: var(--bottom-nav-space, calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px))); padding-bottom: 12px; }
  body.keyboard-open { padding-bottom: 16px; }
  body.keyboard-open .bottom-nav { display: none; }
  body.keyboard-open .card-controls, body.keyboard-open .card-controls.controls-compact .card-navigation { bottom: 0; }
}
.more-sheet { width: 100%; max-width: 640px; max-height: 85vh; margin: auto auto 0; padding: 0; border: 1px solid var(--border); border-bottom: 0; border-radius: 16px 16px 0 0; background: var(--surface); color: var(--text); }
.more-sheet::backdrop { background: rgba(2, 6, 23, 0.65); }
.more-sheet-body { padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.more-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 10px; }
.more-sheet-head h2 { font-size: 1rem; }
.more-close { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-size: 1.1rem; cursor: pointer; }
.more-close:hover { color: var(--text); background: var(--surface-hover); }
.more-list { list-style: none; display: grid; gap: 8px; }
.more-item { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); text-decoration: none; }
.more-item .nav-icon { color: var(--accent); }
.more-item strong { display: block; font-size: 0.95rem; }
.more-item small { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.more-item.active { border-color: var(--accent); background: rgba(56, 189, 248, 0.1); }
.more-item:focus-visible, .more-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .more-sheet[open] { animation: sheet-up 0.18s ease-out; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
/* viewport-fit=cover: на iPhone в альбомной ориентации текст не уходит под вырез экрана */
header { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.container { padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
@media (max-width: 640px) {
  header { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .container { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
}
@media (max-width: 340px) { .bottom-tab { padding-left: 0; padding-right: 0; font-size: 0.66rem; } }

/* Карточка: опоры для пересказа и сравнение с Java/Kotlin */
.card-anchors { margin: 12px 0; }
.anchor-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; padding: 0; }
.anchor-list li { padding: 3px 10px; border: 1px solid rgba(56, 189, 248, 0.5); border-radius: 999px; background: rgba(56, 189, 248, 0.08); font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.82rem; overflow-wrap: anywhere; }
.card-anchors .muted-text { font-size: 0.82rem; }
.jvm-box { margin: 12px 0; padding: 12px 14px; border-left: 3px solid #a855f7; background: rgba(168, 85, 247, 0.07); border-radius: 6px; overflow-wrap: anywhere; }
.jvm-box p { margin-top: 4px; }
.short-answer .first-sentence { color: var(--text); font-weight: 700; }
/* Озвучка: «🔊 Слушать» и голос рядом с английским текстом. */
.short-answer-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.tts { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; vertical-align: middle; }
p + .tts { margin-top: 6px; }
.short-answer > .tts { margin-left: 4px; }
.tts .btn { min-height: 36px; padding: 4px 10px; font-size: 0.8rem; }
.tts-play[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.tts-voice { color: var(--muted); }
.tts-none { margin-left: 8px; font-size: 0.8rem; color: var(--muted); }
.tts-status:empty { display: none; }
.tts-status { flex-basis: 100%; font-size: 0.8rem; color: var(--amber); }

/* Карточка: вопрос → опоры → ответ; самооценка в три уровня */
.card-anchors-wrap { margin: 4px 0 12px; }
.card-anchors-wrap .card-anchors { margin: 0; padding: 10px 12px; border: 1px dashed rgba(56, 189, 248, 0.5); border-radius: 10px; }
/* Фокус сюда ставит клавиша H: рамка видна при клавиатурном фокусе, при щелчке мышью — нет */
.card-anchors-wrap .card-anchors:focus { outline: none; }
.card-anchors-wrap .card-anchors:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.hint-btn { display: inline-flex; align-items: center; gap: 8px; }
.kbd { padding: 0 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.75rem; color: var(--muted); }
.card-more, .jvm-box { margin: 12px 0; }
.card-more > summary, .jvm-box > summary { cursor: pointer; padding: 6px 0; color: var(--accent); font-weight: 600; }
.card-more[open] > summary { margin-bottom: 8px; }
.jvm-box > summary { color: #c4b5fd; }
.grade-criteria { width: 100%; margin: 0 0 6px; font-size: 0.82rem; color: var(--muted); }
.grade-signin { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.grade-signin.hidden { display: none; }
@media (max-width: 640px) {
  .card-grades { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* В потоке после ответа (крупный текст): кнопки оценки — по одной в строку, слова не рвутся */
  .card-controls.controls-compact .card-grades { grid-template-columns: minmax(0, 1fr); }
  .kbd { display: none; }
}
.card-grades.hidden, .grade-criteria.hidden { display: none; }
/* «← Назад», «Далее →»: стрелка и подпись в одной обёртке <span> — один элемент inline-flex, обычный пробел и перенос по нему */

/* Карточки по схеме: длинные вопросы — столбиком */
.diagram-cards { flex-direction: column; align-items: flex-start; gap: 0; margin-top: 18px; }
.diagram-cards a { padding: 6px 0; }

/* Reference project block in the knowledge base */
.wiki-project { margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; background: var(--surface); overflow-wrap: anywhere; }
.wiki-project h3 { margin: 0 0 8px; font-size: 1.05rem; }
.wiki-project h4 { margin: 14px 0 6px; font-size: 0.95rem; }
.wiki-project p { margin: 0 0 8px; }
.wiki-project ol { margin: 8px 0 0; padding-left: 20px; }
.wiki-project li { margin: 4px 0; }
