/* ========== ЦВЕТОВАЯ СХЕМА ========== */
:root {
  --primary: #0891d2;
  --accent: #38bdf8;
  --accent-dark: #0ea5e9;
  --scaffold: #f6f9fc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;

  --gradient-primary: linear-gradient(135deg, #0891d2 0%, #38bdf8 100%);
  --gradient-dark: linear-gradient(135deg, #020617 0%, #020617 100%);

  --shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);

  /* Дополнительные переменные для тонкой настройки (не ломают существующие стили) */
  --content-max: 960px;
  --radius-card: 18px;
  --radius-control: 14px;
  --tap: 44px;
}

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

html, body {
  height: 100%;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--scaffold);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ========== ОБЩИЕ КОМПОНЕНТЫ ========== */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.btn {
  min-height: var(--tap);
  padding: 12px 20px;
  border-radius: var(--radius-control);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #0369a1;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover {
  background: rgba(56,189,248,.08);
}

.btn-icon {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.35);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 14px;
  transition: all 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.15);
}

.title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state-icon {
  font-size: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ========== НАВИГАЦИЯ ========== */
.app-bar {
  background: #f8fafc;
  color: var(--text);
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  display: flex;
  position: sticky;
  top: 0;
  z-index: 900;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.app-bar-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  text-align: center;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Иконки в app-bar */
.app-bar .btn-icon {
  background: transparent;
  border: none;
  color: var(--text);
  width: var(--tap);
  height: var(--tap);
}

.app-bar .btn-icon:hover {
  transform: none;
  background: rgba(2, 6, 23, 0.04);
}

/* ========== ГЛАВНАЯ СТРАНИЦА ========== */
.home-page {
  min-height: 100vh;
  background: var(--gradient-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.home-logo {
  width: 200px;
  height: 200px;
  margin-bottom: 32px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

.home-title {
  color: white;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.home-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  margin-bottom: 48px;
  text-align: center;
}

/* ========== СПИСОК СПЕЦИАЛИЗАЦИЙ ========== */
.specializations-page {
  padding: 24px 16px;
}

.search-box {
  position: relative;
  margin-bottom: 24px;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  line-height: 1;
  font-size: 16px;
  pointer-events: none;
}

.search-input {
  padding-left: 46px;
}

.education-level-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.education-level-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.education-level-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.education-level-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.specialization-item {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
}

.specialization-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.specialization-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.specialization-count {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Универсальные элементы “строчного списка” (иконка + контент + шеврон) */
.list-item-icon {
  width: 46px;
  height: 46px;
  border-radius: 18px;
  background: rgba(56, 189, 248, 0.14);
  color: #0369a1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 20px;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-chevron {
  color: rgba(15, 23, 42, 0.35);
  font-size: 24px;
  line-height: 1;
  padding-left: 8px;
}

/* ========== ВЫБОР ЭТАПА ========== */
.stage-selection-page {
  padding: 24px 16px;
}

.stage-header {
  background: var(--gradient-primary);
  color: white;
  padding: 18px;
  border-radius: var(--radius-card);
  margin: 12px 0 16px;
  box-shadow: var(--shadow);
}

.stage-header-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.stage-header-subtitle {
  font-size: 14px;
  opacity: 0.9;
}

.stage-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stage-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stage-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.stage-content {
  flex: 1;
}

.stage-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.stage-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* ========== ПАНЕЛЬ ДЕЙСТВИЙ (ПЕРВЫЙ ЭТАП) ========== */
.action-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.action-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 18px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.action-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.action-icon {
  width: 56px;
  height: 56px;
  border-radius: 22px;
  background: rgba(56, 189, 248, 0.14);
  color: #0369a1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex: 0 0 auto;
  margin: 0;
}

.action-content {
  flex: 1;
  min-width: 0;
}

.action-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.action-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* ========== ТЕСТ ========== */
.quiz-page {
  padding: 24px 16px;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.quiz-progress {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
}

.question-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(230, 237, 245, 0.9);
}

.question-text {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.6;
}

.answers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-item {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-control);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: start;
  gap: 12px;
}

.answer-item:hover {
  border-color: var(--accent);
  background: #F5FAFF;
}

.answer-item.selected {
  border-color: var(--primary);
  background: #E1F0FF;
}

.answer-item.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.answer-item.incorrect {
  border-color: var(--error);
  background: var(--error-bg);
}

.answer-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
}

.answer-item.selected .answer-checkbox {
  border-color: var(--primary);
  background: var(--primary);
}

.answer-item.selected .answer-checkbox::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
}

.answer-item.correct .answer-checkbox {
  border-color: var(--success);
  background: var(--success);
}

.answer-item.correct .answer-checkbox::after {
  content: '✓';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.answer-text {
  flex: 1;
  font-size: 16px;
  line-height: 1.5;
}

.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-next {
  min-width: 200px;
}

/* Для ситуационных задач: одна центральная кнопка */
.quiz-footer--center {
  justify-content: center;
}

.quiz-footer--center .btn-next {
  min-width: 260px;
  width: min(360px, 100%);
}

/* ========== ИЗБРАННОЕ (КНОПКА-СЕРДЦЕ) ========== */
.favorite-btn {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  flex: 0 0 auto;
}

.favorite-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 130, 194, 0.35);
}

.favorite-btn--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.favorite-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Чтобы отключённые кнопки выглядели корректно */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ========== СИТУАЦИОННЫЕ ЗАДАЧИ ========== */
.tasks-list-page {
  padding: 24px 16px;
}

.task-item {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.task-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.task-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.task-condition-page {
  padding: 24px 16px;
}

.condition-content {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.condition-section {
  margin-bottom: 24px;
}

.condition-section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary);
}

.condition-section-content {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
}

.situational-quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-condition {
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: 20px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ========== РЕЗУЛЬТАТЫ ========== */
.results-page {
  padding: 24px 16px;
}

.results-header {
  text-align: center;
  margin-bottom: 18px;
}

/* .results-title больше не используется (заголовок есть в app-bar) */

.results-stats {
  font-size: 14px;
  color: var(--text-muted);
}

.results-question {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.results-question-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.results-answer {
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: start;
  gap: 12px;
}

.results-answer.correct {
  background: var(--success-bg);
  border: 2px solid var(--success);
}

.results-answer.incorrect {
  background: var(--error-bg);
  border: 2px solid var(--error);
}

.results-answer.selected {
  background: #E1F0FF;
  border: 2px solid var(--primary);
}

.justification-btn {
  margin-top: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
}

.justification-text {
  margin-top: 8px;
  padding: 12px;
  background: #F5FAFF;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.diagnosis-section {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  margin-top: 32px;
  box-shadow: var(--shadow);
}

.diagnosis-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary);
}

.diagnosis-content {
  font-size: 16px;
  line-height: 1.6;
}

/* ========== МОДАЛЬНОЕ ОКНО ========== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: 28px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.auth-modal {
  max-width: 520px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.auth-tab {
  flex: 1;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  font-weight: 700;
  cursor: pointer;
}

.auth-tab--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.auth-pane {
  display: block;
}

.auth-field {
  margin: 10px 0 12px;
}

.auth-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.35;
}

.auth-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 10px 0;
  font-size: 13px;
  color: var(--text);
}

.auth-check input {
  margin-top: 3px;
}

.auth-alert {
  padding: 12px 14px;
  border-radius: 14px;
  margin: 10px 0 12px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.03);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.auth-alert--error {
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.06);
}

.auth-alert--success {
  border-color: rgba(22, 163, 74, 0.25);
  background: rgba(22, 163, 74, 0.06);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .card {
    padding: 16px;
    border-radius: 20px;
  }

  .action-panel {
    grid-template-columns: 1fr;
  }

  .quiz-header {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-footer {
    flex-direction: column;
  }

  .btn-next {
    width: 100%;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .btn-icon {
    padding: 10px;
  }

  .home-title {
    font-size: 24px;
  }

  .home-subtitle {
    font-size: 16px;
  }
}

/* ========== УЛУЧШЕНИЯ UX / ACCESSIBILITY ========== */
:focus-visible {
  outline: 3px solid rgba(0, 185, 255, 0.35);
  outline-offset: 2px;
  border-radius: 12px;
}

.btn, .btn-icon, .answer-item, .specialization-item, .stage-card, .action-card, .task-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========== СКРЫТЫЕ ЭЛЕМЕНТЫ ========== */
.hidden {
  display: none !important;
}

/* ========== DESIGN TUNING (НЕ УДАЛЯЕТ СУЩЕСТВУЮЩЕЕ) ========== */
/* Цель: сделать интерфейс ближе к UWorld/AMBOSS: компактнее, чище, с понятной иерархией */

/* Центрирование контента и адекватная ширина на desktop */
.container {
  max-width: var(--content-max);
}

/* Шапка: меньше высоты, аккуратнее, без ощущения “баннера” */
.app-bar {
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  gap: 12px;
}

.app-bar-title {
  font-size: 18px;
  font-weight: 700;
}

/* Кнопки: одинаковая высота тач-зоны и более “приложенческий” вид */
.btn {
  min-height: var(--tap);
  border-radius: var(--radius-control);
}

.btn-icon {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
}

/* Карточки: чуть меньше радиус и более предсказуемый ритм */
.card {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

/* Списки (направления/этапы/блоки): меньше “пухлости”, больше плотности */
.education-level-card,
.specialization-item,
.stage-card,
.task-item {
  border-radius: var(--radius-card);
  padding: 18px 18px;
  margin-bottom: 12px;
}

/* Скрываем “размазанные” отступы страниц и возвращаем контент в один ритм */
.specializations-page,
.stage-selection-page,
.quiz-page,
.tasks-list-page,
.task-condition-page,
.results-page {
  padding: 16px 12px;
}

/* Заголовки и подписи: более спокойная типографика */
.title {
  font-size: 22px;
  line-height: 1.25;
}

.subtitle {
  line-height: 1.4;
}

/* Stage header: меньше высоты, меньше ощущения “второй шапки” */
.stage-header {
  padding: 18px;
  border-radius: var(--radius-card);
  margin: 12px 0 14px;
}

.stage-header-title {
  font-size: 18px;
  margin-bottom: 6px;
}

.stage-header-subtitle {
  font-size: 13px;
}

/* Панель действий: делает карточки более “app-like” */
.action-panel {
  gap: 14px;
  margin-top: 16px;
}

.action-card {
  border-radius: var(--radius-card);
  padding: 22px 18px;
}

.action-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
}

/* Вопросы: уменьшаем визуальный шум (рамки и фон), сохраняя состояния */
.question-card {
  border-radius: var(--radius-card);
}

.question-text {
  font-size: 17px;
  margin-bottom: 16px;
}

/* Ответы: тоньше рамка, меньше “пластика”, лучше читаемость */
.answer-item {
  border-width: 1.5px;
  border-radius: var(--radius-control);
  padding: 14px 14px;
}

.answer-checkbox {
  width: 20px;
  height: 20px;
  border-width: 1.5px;
}

/* Footer: на больших экранах пусть не “прыгает” */
.quiz-footer {
  margin-top: 16px;
}

/* Модалка: чуть современнее и легче */
.modal-content {
  border-radius: var(--radius-card);
}

/* Мобильная: ещё компактнее, чтобы помещалось больше контента */
@media (max-width: 768px) {
  .container {
    max-width: 100%;
  }

  .education-level-card,
  .specialization-item,
  .stage-card,
  .task-item {
    padding: 16px 14px;
  }

  .question-card {
    padding: 18px;
  }

  .answer-item {
    padding: 12px 12px;
  }
}

/* Большие экраны: уменьшаем “пустыню” по бокам и улучшаем восприятие */
@media (min-width: 1100px) {
  .container {
    padding: 18px 16px;
  }

  .specializations-page,
  .stage-selection-page,
  .quiz-page,
  .tasks-list-page,
  .task-condition-page,
  .results-page {
    padding: 18px 16px;
  }
}

/* =========================================================
   DESIGN UPGRADE — HOME PAGE (НЕ ЛОМАЕТ СУЩЕСТВУЮЩЕЕ)
========================================================= */

.home-page {
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(255,255,255,0.25), transparent 60%),
    var(--gradient-primary);
}

.home-logo {
  font-size: 72px;
  width: 180px;
  height: 180px;
  border-radius: 48px;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.home-logo img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 24px 48px rgba(2, 6, 23, 0.28));
}

.home-title {
  max-width: 720px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.home-subtitle {
  max-width: 560px;
  line-height: 1.5;
}

.home-page .btn-primary {
  font-size: 17px;
  padding: 14px 32px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 18px 40px rgba(15, 23, 42, 0.25);
}

.home-page .btn-primary:hover {
  transform: translateY(-2px);
}

/* ============================================================================
   FLUTTER THEME (WEB) — EXPERIMENTAL OVERRIDES
   ============================================================================ */

/* Переменные из Flutter-версии (оставляем и старые переменные тоже — для совместимости) */
:root {
  --color-primary: #0082C2;
  --color-home-page-bg: #1193C9;
  --color-icon-launcher-bg: #1193C9;

  --color-light-accent: #00B9FF;
  --color-light-scaffold: #F2F7FB;
  --color-light-surface: #FFFFFF;
  --color-light-input-fill: #F5FAFF;
  --color-light-gradient-start: #E8F1FF;
  --color-light-gradient-end: #FDFEFF;
  --color-light-gradient-button-start: #0087CC;
  --color-light-gradient-button-end: #00C2FF;
  --color-light-gradient-brand-start: #0087CC;
  --color-light-gradient-brand-end: #00C2FF;

  --color-dark-accent: #4DD0E1;
  --color-dark-scaffold: #030B16;
  --color-dark-surface: #0F2034;
  --color-dark-input-fill: #142842;
  --color-dark-gradient-start: #010914;
  --color-dark-gradient-end: #071A30;
  --color-dark-gradient-button-start: #032B4F;
  --color-dark-gradient-button-end: #06193A;
  --color-dark-gradient-brand-start: #032B4F;
  --color-dark-gradient-brand-end: #06193A;

  --color-white: #FFFFFF;
  --color-black: #000000;
  --color-green: #00FF00;
  --color-red: #FF0000;

  --opacity-white-light: 0.2;
  --opacity-white-dark: 0.08;
  --opacity-black-light: 0.18;
  --opacity-black-dark: 0.45;
  --opacity-black-card: 0.06;
  --opacity-primary: 0.12;

  --radius-small: 8px;
  --radius-medium: 18px;
  --radius-large: 20px;
  --radius-card: 24px;
  --radius-button: 28px;
  --radius-brand: 32px;
  --radius-large-card: 36px;
  --radius-badge: 40px;
  --radius-circle: 50px;

  --padding-xs: 4px;
  --padding-small: 8px;
  --padding-medium: 12px;
  --padding-large: 16px;
  --padding-xl: 20px;
  --padding-xxl: 24px;
  --padding-xxxl: 32px;
  --padding-huge: 48px;
  --padding-giant: 64px;
  --padding-button-horizontal: 32px;
  --padding-button-vertical: 18px;
  --padding-card: 24px;
  --padding-card-large: 32px;
  --padding-brand-card: 32px;
  --padding-input: 12px; /* отсутствовало в исходном блоке */

  --font-size-xs: 12px;
  --font-size-small: 14px;
  --font-size-medium: 16px;
  --font-size-large: 18px;
  --font-size-xl: 20px;
  --font-size-xxl: 22px;
  --font-size-xxxl: 28px;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semi-bold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.0;
  --line-height-normal: 1.2;
  --line-height-relaxed: 1.3;
  --line-height-loose: 1.5;

  --letter-spacing-tight: -0.5px;
  --letter-spacing-normal: 0px;
  --letter-spacing-wide: 0.5px;

  --icon-size-small: 16px;
  --icon-size-medium: 20px;
  --icon-size-large: 24px;
  --icon-size-xl: 28px;
  --icon-size-xxl: 32px;
  --icon-size-xxxl: 40px;

  --font-family: 'Manrope', sans-serif;

  --height-app-bar: 50px;
  --height-progress-bar: 8px;
  --height-button: 48px;

  --width-logo: 140px;
  --width-max-content: 1200px;
  --width-max-button: 400px;

  --border-width-thin: 1px;
  --border-width-medium: 1.5px;
  --border-width-thick: 1.6px;
  --border-width-extra-thick: 1.8px;

  /* RGB-версии для rgba(...) */
  --color-primary-rgb: 0, 130, 194;
  --color-light-accent-rgb: 0, 185, 255;
  --color-dark-accent-rgb: 77, 208, 225;
}

/* Светлая тема по умолчанию (так как мы выставили data-theme="light" на <html>) */
[data-theme="light"] {
  --color-accent: var(--color-light-accent);
  --color-accent-rgb: var(--color-light-accent-rgb);
  --color-scaffold: var(--color-light-scaffold);
  --color-surface: var(--color-light-surface);
  --color-input-fill: var(--color-light-input-fill);
  --gradient-start: var(--color-light-gradient-start);
  --gradient-end: var(--color-light-gradient-end);
  --gradient-button-start: var(--color-light-gradient-button-start);
  --gradient-button-end: var(--color-light-gradient-button-end);
  --gradient-brand-start: var(--color-light-gradient-brand-start);
  --gradient-brand-end: var(--color-light-gradient-brand-end);
  --opacity-white: var(--opacity-white-light);
  --opacity-black: var(--opacity-black-light);
}

[data-theme="dark"] {
  --color-accent: var(--color-dark-accent);
  --color-accent-rgb: var(--color-dark-accent-rgb);
  --color-scaffold: var(--color-dark-scaffold);
  --color-surface: var(--color-dark-surface);
  --color-input-fill: var(--color-dark-input-fill);
  --gradient-start: var(--color-dark-gradient-start);
  --gradient-end: var(--color-dark-gradient-end);
  --gradient-button-start: var(--color-dark-gradient-button-start);
  --gradient-button-end: var(--color-dark-gradient-button-end);
  --gradient-brand-start: var(--color-dark-gradient-brand-start);
  --gradient-brand-end: var(--color-dark-gradient-brand-end);
  --opacity-white: var(--opacity-white-dark);
  --opacity-black: var(--opacity-black-dark);
}

/* Маппинг “старых” переменных проекта на новые (чтобы остальная CSS-верстка работала) */
:root {
  --primary: var(--color-primary);
  --accent: var(--color-accent);
  --accent-dark: var(--color-accent);
  --scaffold: var(--color-scaffold);
  --surface: var(--color-surface);
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --gradient-primary: linear-gradient(to bottom right, var(--gradient-button-start), var(--gradient-button-end));
  --shadow: 0 12px 24px rgba(0, 0, 0, var(--opacity-black-card));
  --shadow-lg: 0 28px 36px rgba(0, 0, 0, var(--opacity-black));
  --content-max: var(--width-max-content);
  --radius-card: var(--radius-card);
  --radius-control: var(--radius-medium);
  --tap: var(--height-button);
}

/* Базовая типографика/фон */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-medium);
  line-height: var(--line-height-normal);
  color: var(--color-black);
  background-color: var(--color-scaffold);
}

/* Контейнер */
.container {
  max-width: var(--width-max-content);
  margin: 0 auto;
  padding: 0 var(--padding-large);
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--padding-button-vertical) var(--padding-button-horizontal);
  font-size: var(--font-size-medium);
  font-weight: var(--font-weight-semi-bold);
  border-radius: var(--radius-large);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: var(--height-button);
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-white);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Совместимость: в проекте используется btn-outline */
.btn-outline,
.btn-outlined {
  background-color: transparent;
  color: var(--color-accent);
  border: var(--border-width-thick) solid var(--color-accent);
}

.btn-outline:hover,
.btn-outlined:hover {
  background-color: var(--color-accent);
  color: var(--color-white);
}

/* Инпут */
.input {
  width: 100%;
  padding: var(--padding-input) var(--padding-large);
  font-size: var(--font-size-medium);
  background-color: var(--color-input-fill);
  border: var(--border-width-thin) solid rgba(var(--color-accent-rgb), 0.3);
  border-radius: var(--radius-medium);
  transition: all 0.2s ease;
}

.input:focus {
  outline: none;
  border-color: var(--color-accent);
  border-width: var(--border-width-extra-thick);
}

.input::placeholder {
  color: rgba(0, 0, 0, 0.5);
}

/* Поиск: фикс перекрытия иконки и плейсхолдера (Flutter overrides перетирают padding) */
.search-box {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: rgba(0, 0, 0, 0.55);
  font-size: 18px;
}

.input.search-input {
  padding-left: 56px;
}

/* Карточки */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  box-shadow: 0 12px 24px rgba(0, 0, 0, var(--opacity-black-card));
}

/* App bar (как в приложении на скрине: светлая) */
.app-bar {
  height: var(--height-app-bar);
  background-color: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--padding-large);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.app-bar-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  text-align: center;
  flex: 1;
}

/* Прогресс-бар (на будущее, под экраны блоков) */
.progress-bar {
  width: 100%;
  height: var(--height-progress-bar);
  background-color: rgba(var(--color-primary-rgb), var(--opacity-primary));
  border-radius: var(--radius-small);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--color-primary);
  transition: width 0.3s ease;
}

/* ============================================================================
   STAGE SELECTION (как на скрине) — specialization card + progress
   ============================================================================ */

.stage-header--brand {
  border-radius: var(--radius-large-card);
  background: linear-gradient(to bottom right, var(--gradient-brand-start), var(--gradient-brand-end));
  border: var(--border-width-medium) solid rgba(255, 255, 255, var(--opacity-white));
  box-shadow: 0 28px 36px rgba(0, 0, 0, var(--opacity-black));
  color: var(--color-white);
}

.stage-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.stage-header-kicker {
  opacity: 0.9;
  font-size: var(--font-size-small);
}

.icon-action {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.stage-header-title {
  font-size: 24px;
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-tight);
  margin-bottom: 14px;
}

.stage-header-progress {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-brand);
  padding: 14px 16px;
}

.stage-header-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.stage-header-progress-icon {
  width: 44px;
  height: 44px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.stage-header--brand .stage-header-subtitle {
  opacity: 0.92;
  font-size: var(--font-size-medium);
  margin: 0;
}

.stage-header--brand .progress-bar {
  background-color: rgba(255, 255, 255, 0.18);
  height: 6px;
}

.stage-header--brand .progress-bar-fill {
  background-color: rgba(255, 255, 255, 0.92);
}

/* Stage cards under header: make them look like mobile list cards */
.stage-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px;
}

/* Адаптив из Flutter блока */
@media (max-width: 768px) {
  :root {
    --padding-button-horizontal: 24px;
    --padding-button-vertical: 14px;
    --font-size-xl: 18px;
    --font-size-xxl: 20px;
  }

  .container {
    padding: 0 var(--padding-medium);
  }
}

@media (max-width: 480px) {
  :root {
    --padding-button-horizontal: 16px;
    --padding-button-vertical: 12px;
    --font-size-medium: 14px;
    --font-size-large: 16px;
  }
}

/* ========== КНОПКА ПОМОЩИ В АККРЕДИТАЦИИ ========== */
.help-button-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
}

.help-button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform .15s ease, box-shadow .15s ease;
  min-height: var(--tap);
}

.help-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(8, 145, 210, 0.3);
}

.help-button-icon {
  font-size: 20px;
}

.help-button-text {
  white-space: nowrap;
}

@media (max-width: 768px) {
  .help-button-container {
    bottom: 15px;
    right: 15px;
  }
  
  .help-button {
    padding: 12px 20px;
    font-size: 14px;
  }
  
  .help-button-text {
    display: none;
  }
  
  .help-button-icon {
    font-size: 24px;
  }
}

/* ============================================================================
   DESKTOP → MOBILE-LIKE LAYOUT (узкая колонка как “приложение”)
   ============================================================================ */

@media (min-width: 900px) {
  body {
    background:
      radial-gradient(900px 500px at 50% -200px, rgba(0, 130, 194, 0.10), transparent 60%),
      var(--color-scaffold);
  }

  /* Все экраны, кроме главного, делаем как “мобильное приложение” по центру */
  [id$="Page"]:not(#homePage) {
    max-width: 920px;
    margin: 18px auto;
    border-radius: var(--radius-large-card);
    background: var(--color-scaffold);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.10);
  }

  [id$="Page"]:not(#homePage) .app-bar {
    border-top-left-radius: var(--radius-large-card);
    border-top-right-radius: var(--radius-large-card);
  }

  /* Контент внутри колонкой, но без избыточных полей */
  [id$="Page"]:not(#homePage) .container {
    padding-left: 14px;
    padding-right: 14px;
    max-width: 100%;
  }
}
