.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
}
.logo { font-weight: 700; font-size: 18px; color: var(--primary); }
.logo span { font-size: 10px; background: var(--primary); color: white; padding: 2px 6px; border-radius: 4px; margin-left: 4px; vertical-align: middle; }
.deck-select {
  flex: 1; max-width: 200px;
  padding: 6px 10px; font-size: 14px;
  background: var(--surface-2); border-radius: 20px;
}
.streak-badge {
  display: flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white; padding: 4px 10px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
}
.docs-links {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex; flex-wrap: wrap; gap: 16px;
  font-size: 13px;
}
.docs-links a {
  color: var(--text-muted);
  text-decoration: none;
}
.docs-links a:hover { color: var(--primary); text-decoration: underline; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: background 0.2s, transform 0.15s;
}
.icon-btn:hover { background: var(--surface-2); transform: scale(1.1); }

.dashboard {
  background: var(--surface);
  padding: 12px 16px;
  display: flex; gap: 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.stat-card {
  flex: 1; min-width: 110px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-value { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* M6.4 Stage 10 (UX Review) — guided "what to do next" panel (Medicine Student Home, but plain
   generic classes so any module's own Student Portal wiring can reuse this without duplicating CSS,
   same convention as .dashboard/.stat-card above). */
.quick-actions { margin-top: 20px; }
.quick-action-primary { width: 100%; justify-content: center; font-size: 1.05em; padding: 14px; }
.quick-actions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.quick-actions-grid .btn { width: 100%; justify-content: center; }

.toolbar {
  display: flex; gap: 8px; padding: 12px 16px;
  overflow-x: auto; white-space: nowrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.toolbar::-webkit-scrollbar { display: none; }
.btn {
  padding: 8px 14px; border-radius: 20px;
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.btn:hover { background: var(--border); }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; }

.screen { display: none; padding: 16px; }
.screen.active { display: block; }

.card-wrap {
  perspective: 1200px;
  max-width: 500px; margin: 20px auto;
  min-height: 320px;
}
.card {
  position: relative; width: 100%; height: 320px;
  transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}
.card.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  overflow: auto;
}
.card-back { transform: rotateY(180deg); }
.card-word { font-size: 36px; font-weight: 700; margin-bottom: 8px; }
.card-transcript { color: var(--text-muted); font-size: 16px; margin-bottom: 12px; }
.card-pos { display: inline-block; background: var(--surface-2); padding: 3px 10px; border-radius: 10px; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.card-level { display: inline-block; background: var(--primary); color: white; padding: 3px 10px; border-radius: 10px; font-size: 12px; margin-left: 6px; }
.card-translation { font-size: 24px; margin-bottom: 12px; }
.card-example { font-size: 15px; color: var(--text-muted); font-style: italic; line-height: 1.5; padding: 10px; background: var(--surface-2); border-radius: var(--radius-sm); max-width: 100%; }
.card-example b { color: var(--primary); font-style: normal; }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.tag { background: var(--surface-2); padding: 2px 8px; border-radius: 10px; font-size: 11px; color: var(--text-muted); }

/* M2.3.1 — статус SRS (getProgressStatus(), не новое вычисление, только отображение) */
.srs-status-badge {
  position: absolute; top: 12px; left: 12px;
  background: var(--surface-2); color: var(--text-muted);
  padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600;
}

/* M2.3.1 — прогресс дня против dailyGoal (настройка уже существовала, только не отображалась) */
.study-progress-bar { max-width: 500px; margin: 0 auto 12px; }
.study-progress-text { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; text-align: center; }
.study-progress-track { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.study-progress-fill { height: 100%; background: var(--success); transition: width 0.4s ease; }

/* M2.3.2 — переключатель режима обучения (только способ ответа, SRS не затрагивает) */
.mode-switcher {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  max-width: 500px; margin: 0 auto 16px;
}
.mode-btn {
  padding: 6px 12px; border-radius: 20px; font-size: 13px;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid transparent;
  transition: background 0.2s, color 0.2s;
}
.mode-btn:hover { border-color: var(--primary); }
.mode-btn.active { background: var(--primary); color: white; }

/* M2.3.2 — Typing mode: поле ввода перевода */
.typing-mode {
  display: flex; gap: 8px; max-width: 500px; margin: 16px auto; padding: 0 4px;
}
.typing-mode input {
  flex: 1; padding: 10px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}

/* M2.3.2 — обратная связь по ответу (Typing/Multiple Choice), рендерится на обороте карточки */
.answer-feedback { margin-bottom: 12px; font-weight: 600; }
.answer-feedback.correct { color: var(--success); }
.answer-feedback.wrong { color: var(--danger); }
.answer-typed { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-top: 4px; }
.answer-diff { font-family: monospace; font-size: 20px; letter-spacing: 2px; margin-top: 6px; }
.diff-match { color: var(--success); }
.diff-miss { color: var(--danger); text-decoration: underline; }

.speak-btn {
  position: absolute; top: 12px; right: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s;
}
.speak-btn:hover { transform: scale(1.15); background: var(--border); }
.edit-btn {
  position: absolute; top: 12px; left: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); font-size: 18px;
  transition: transform 0.2s;
}
.edit-btn:hover { transform: scale(1.15); background: var(--border); }

.srs-buttons {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; max-width: 500px; margin: 16px auto;
}
.srs-btn {
  padding: 14px 8px; border-radius: var(--radius-sm);
  color: white; font-weight: 600; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.srs-btn small { font-size: 10px; opacity: 0.85; font-weight: 400; }
.srs-again { background: var(--danger); }
.srs-hard { background: var(--warning); }
.srs-good { background: var(--success); }
.srs-easy { background: var(--info); }

.nav-row {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 500px; margin: 10px auto;
  color: var(--text-muted); font-size: 14px;
}
.nav-btn {
  padding: 8px 16px; background: var(--surface);
  border-radius: 20px; border: 1px solid var(--border);
  font-size: 14px;
  transition: all 0.2s;
}
.nav-btn:hover { background: var(--border); transform: translateY(-2px); }

.empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 60px; margin-bottom: 16px; opacity: 0.5; }
.empty-text { font-size: 16px; margin-bottom: 20px; }

.search-bar {
  position: sticky; top: 60px; z-index: 10;
  background: var(--bg); padding: 8px 0;
}
.filter-row {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 0;
}
.filter-row::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; white-space: nowrap;
  transition: all 0.25s;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }
.word-list { display: flex; flex-direction: column; gap: 8px; }
.word-item {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 12px; display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border);
  cursor: pointer; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.word-item:hover { transform: translateY(-2px) scale(1.01); border-color: var(--primary); box-shadow: var(--shadow); }
.word-main { flex: 1; min-width: 0; }
.word-main .w { font-weight: 600; font-size: 16px; }
.word-main .t { color: var(--text-muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-status {
  padding: 3px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.status-new { background: #dbeafe; color: #1e40af; }
.status-learning { background: #fef3c7; color: #92400e; }
.status-learned { background: #d1fae5; color: #065f46; }
.status-due { background: #fee2e2; color: #991b1b; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
  animation: fadeIn 0.3s;
}
.modal-bg.active { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; padding: 20px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

.preview-summary {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.preview-summary .stat-card { flex: 1; min-width: 100px; }
.badge-duplicate {
  font-size: 11px; font-weight: 600; color: var(--warning);
  border: 1px solid var(--warning); border-radius: 20px;
  padding: 1px 8px; margin-left: 6px;
}

.verify-list { max-height: 400px; overflow-y: auto; }
.verify-item {
  padding: 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  background: var(--surface-2);
}
.verify-item.warn { border-color: var(--warning); background: #fef3c7; }
[data-theme="dark"] .verify-item.warn { background: #422006; }
.verify-item.duplicate { opacity: 0.7; }
.verify-item input, .verify-item textarea {
  margin-top: 6px; font-size: 13px; padding: 6px 8px;
}
.verify-item .row { display: flex; gap: 6px; }
.verify-item .row > * { flex: 1; }

.test-wrap { max-width: 500px; margin: 0 auto; text-align: center; }
.test-question { font-size: 28px; font-weight: 700; margin: 20px 0; }
.test-options { display: flex; flex-direction: column; gap: 8px; }
.test-option {
  padding: 14px; background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  text-align: left; font-size: 16px;
  transition: all 0.2s;
}
.test-option:hover { border-color: var(--primary); transform: translateX(4px); }
.test-option.correct { background: var(--success); color: white; border-color: var(--success); }
.test-option.wrong { background: var(--danger); color: white; border-color: var(--danger); }
.test-option.active { border-color: var(--primary); background: var(--surface-2); }

/* M3.1.5 (Generic Exam UI) — тот же визуальный принцип, что .study-progress-bar/.today-progress-bar
   (M2.3.1/M2.4.1), отдельные классы, чтобы не матчить сразу несколько прогресс-баров на странице. */
.exam-progress-bar { max-width: 500px; margin: 0 auto 12px; }
.exam-progress-text { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; text-align: center; }
.exam-progress-track { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.exam-progress-fill { height: 100%; background: var(--primary); transition: width 0.4s ease; }
.exam-timer { text-align: center; font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
/* M3.1.6 (Integrate Exam UI) — плавный переход между вопросами, тот же keyframe fadeIn, что уже
   использует .modal-bg.active (animations.css) — не новый визуальный язык. */
.exam-fade-in { animation: fadeIn 0.3s; }

/* M3.2 (Exam Builder) — форма конструктора экзамена внутри Modal Service. Секции — вложенные
   карточки того же уровня, что .stat-card/.word-item (surface-2 фон, radius-sm), не новый язык. */
.exam-builder-heading { margin: 16px 0 8px; font-size: 15px; }
.exam-builder-heading:first-child { margin-top: 0; }
.exam-builder-section {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 10px;
}
.exam-builder-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.exam-builder-preview-options { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.setting-label { font-weight: 500; }
.setting-desc { font-size: 12px; color: var(--text-muted); }
.toggle {
  width: 44px; height: 24px; background: var(--border);
  border-radius: 12px; position: relative; cursor: pointer;
  transition: background 0.2s;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; top: 2px; left: 2px;
  transition: left 0.2s;
}
.toggle.on::after { left: 22px; }

.heatmap {
  display: grid; grid-template-columns: repeat(26, 1fr);
  gap: 3px; margin-top: 10px;
}
.heatmap-cell {
  aspect-ratio: 1; background: var(--surface-2);
  border-radius: 2px;
  transition: transform 0.2s, background 0.3s;
}
.heatmap-cell:hover { transform: scale(1.3); z-index: 2; }
.heat-1 { background: #c6e48b; }
.heat-2 { background: #7bc96f; }
.heat-3 { background: #239a3b; }
.heat-4 { background: #196127; }
[data-theme="dark"] .heat-1 { background: #0e4429; }
[data-theme="dark"] .heat-2 { background: #006d32; }
[data-theme="dark"] .heat-3 { background: #26a641; }
[data-theme="dark"] .heat-4 { background: #39d353; }

.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 20px; border-radius: 20px;
  font-size: 14px; z-index: 200;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.kbd {
  display: inline-block; padding: 2px 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; font-size: 11px; font-family: monospace;
  margin: 0 2px;
}

/* M2.3.1 — видимый фокус для управления с клавиатуры (раньше не было ни одного правила для
   button:focus, значит Tab-навигация была визуально неотличима от отсутствия фокуса вовсе). */
.btn:focus-visible,
.srs-btn:focus-visible,
.nav-btn:focus-visible,
.icon-btn:focus-visible,
.speak-btn:focus-visible,
.test-option:focus-visible,
.card:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.study-hints { text-align: center; font-size: 12px; color: var(--text-muted); margin: 10px auto; max-width: 500px; }

/* M2.4.1 — Learning Analytics Dashboard: только визуализация уже существующих Progress/StatsCache
   вычислений (LEARNING_ANALYTICS_ARCHITECTURE.md), никакой новой логики здесь. */

/* Dashboard Today (§3) — тот же визуальный стиль, что .study-progress-bar (studyScreen.js), но
   отдельные классы (не переиспользует их буквально) — хедер, не #studyContent, полная ширина
   вместо узкой центрированной колонки, и это ДРУГОЙ DOM-узел (виден вне экрана Учить тоже). */
.today-progress-bar { margin: 0 16px 12px; }
.today-progress-text { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; text-align: center; }
.today-progress-track { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.today-progress-fill { height: 100%; background: var(--success); transition: width 0.4s ease; }

/* Study Screen — мастерство/следующее повторение/повторения на карточке (§4) */
.srs-meta {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin: 30px 0 10px; font-size: 12px; color: var(--text-muted);
}
.srs-meta-item { white-space: nowrap; }

/* Decks Screen — статистика по колоде (§7) */
.deck-stats {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
  margin-top: 8px;
}
.deck-stat-item { white-space: nowrap; }
.word-item .deck-stats + .study-progress-track { margin-top: 6px; }

/* Statistics Screen — сложные/лёгкие/недавно изученные слова (§6) */
.rank-heading { margin: 20px 0 8px; }
.rank-list .word-item { cursor: default; }
.rank-list .word-item:hover { transform: none; box-shadow: none; border-color: var(--border); }

