/* ─────────────────────────────────────────────────────────────────
   DESIGN SYSTEM
   Виртуальный пациент — академический стиль для медобразования
   ─────────────────────────────────────────────────────────────── */

:root {
  /* ── Цвета: тёмно-синяя академическая палитра ─────────────── */
  --color-bg:           #fafaf7;          /* мягкий cream вместо чисто белого */
  --color-surface:      #ffffff;
  --color-surface-2:    #f4f6f8;          /* фон для секций */
  --color-border:       #e5e7eb;
  --color-border-strong:#d0d7de;

  --color-text:         #1f2937;          /* чарcoal вместо чёрного */
  --color-text-muted:   #6b7280;
  --color-text-subtle:  #9ca3af;

  --color-primary:      #156082;          /* deep teal-blue (Microsoft Academic) */
  --color-primary-hover:#0F9ED5;
  --color-primary-soft: #e8f0f5;

  --color-accent:       #b45309;          /* warm amber для важных уведомлений */

  --color-success:      #166534;
  --color-success-bg:   #dcfce7;
  --color-warning:      #b45309;
  --color-warning-bg:   #fef3c7;
  --color-danger:       #991b1b;
  --color-danger-bg:    #fee2e2;

  --color-brand-accent: #5fe0c8;

  /* ── Типографика ──────────────────────────────────────────── */
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", "Menlo", Consolas, monospace;
  --font-serif: "Charter", "Georgia", "Times New Roman", serif;

  /* шкала размеров (на основе 16px, modular ratio 1.125) */
  --fs-xs:    0.75rem;  /* 12 — captions, meta */
  --fs-sm:    0.875rem; /* 14 — body small */
  --fs-base:  1rem;     /* 16 — body */
  --fs-md:    1.125rem; /* 18 — section text */
  --fs-lg:    1.25rem;  /* 20 — h3 */
  --fs-xl:    1.5rem;   /* 24 — h2 */
  --fs-2xl:   1.875rem; /* 30 — h1 */

  --lh-tight: 1.25;
  --lh-base:  1.5;
  --lh-relaxed:1.625;

  /* ── Spacing scale (4px base) ─────────────────────────────── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* ── Скругления ───────────────────────────────────────────── */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-pill: 999px;

  /* ── Тени (мягкие, академические — без heavy drop shadow) ─── */
  --shadow-xs: 0 1px 2px rgba(31,41,55,0.04);
  --shadow-sm: 0 1px 3px rgba(31,41,55,0.07), 0 1px 2px rgba(31,41,55,0.04);
  --shadow-md: 0 4px 8px rgba(31,41,55,0.08), 0 2px 4px rgba(31,41,55,0.04);
  --shadow-lg: 0 10px 20px rgba(31,41,55,0.10), 0 4px 8px rgba(31,41,55,0.06);

  /* ── Transition ───────────────────────────────────────────── */
  --t-fast:   120ms ease;
  --t-base:   200ms ease;

  /* ── z-index scale ────────────────────────────────────────── */
  --z-dropdown: 50;
  --z-modal: 100;
  --z-toast: 200;

  /* ── Breakpoints — для документации/JS reference (в media queries использовать literal values) */
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
}

/* ─────────────────────────────────────────────────────────────────
   RESET + BASE
   ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button { font: inherit; cursor: pointer; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }

/* ─────────────────────────────────────────────────────────────────
   ШАПКА
   ─────────────────────────────────────────────────────────────── */
header {
  background: var(--color-primary);
  color: white;
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.header-title { flex: 1; min-width: 0; }
header h1 {
  margin: 0 0 2px 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}
#patient-info {
  font-size: var(--fs-sm);
  /* Iter 4 TASK-022: opacity lift для AA contrast на dark teal header */
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
#session-timer {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: rgba(255,255,255,0.12);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-md);
  letter-spacing: 0.02em;
}
.header-toggle-debug {
  font-size: var(--fs-xs);
  /* Iter 4 TASK-022: opacity lift для AA contrast */
  color: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  cursor: pointer;
  user-select: none;
}
.header-toggle-debug input { margin: 0; cursor: pointer; }
#settings-button {
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  font-size: 20px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
}
#settings-button:hover { background: rgba(255,255,255,0.24); }

/* ─────────────────────────────────────────────────────────────────
   ОСНОВНАЯ СЕТКА — «КИНОЭКРАН»
   ─────────────────────────────────────────────────────────────── */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ── Stage: 4:3 «экран» с аватаром + диалог-оверлеем внизу ─── */
.stage {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 4 / 3;
  background: #0E2841;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
#avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* TASK-029: cabinet background через DOM image (cover-fit вместо Three.js stretch) */
.cabinet-stage {
  position: relative;
  width: 100%;
  height: 100%;
}
.cabinet-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  pointer-events: none;
}
.cabinet-stage > canvas#avatar {
  position: relative;
  z-index: 1;
}
.cabinet-fg {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  object-fit: contain;
  object-position: bottom center;
  z-index: 2;
  pointer-events: none;
}

/* ── Полупрозрачный диалог-оверлей внизу сцены ─── */
.dialog-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  /* Iter 2 TASK-006: усилен gradient (0.95/0.85/0.6) — guarantees ≥4.5:1 contrast для белого текста */
  background: linear-gradient(to top,
    rgba(8, 18, 32, 0.95) 0%,
    rgba(8, 18, 32, 0.85) 50%,
    rgba(8, 18, 32, 0.6) 85%,
    rgba(8, 18, 32, 0) 100%);
  padding: var(--sp-7) var(--sp-5) var(--sp-4);
  pointer-events: auto;
  z-index: 1;
  /* Frosted-glass для очень светлых сцен — graceful fallback на gradient */
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

#transcript {
  max-height: 110px;        /* ~2-3 строки видны, остальное скроллится */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  scroll-behavior: smooth;
  /* Кастомный скроллбар поверх тёмного фона */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}
#transcript::-webkit-scrollbar { width: 4px; }
#transcript::-webkit-scrollbar-track { background: transparent; }
#transcript::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}

/* ── Реплики поверх сцены — белый текст, без фона ─── */
.bubble {
  background: none;
  color: rgba(255,255,255,0.96);
  padding: 0;
  border: none;
  border-radius: 0;
  max-width: 100%;
  line-height: 1.45;
  font-size: var(--fs-md);
  word-wrap: break-word;
  /* Iter 2 TASK-006: усиленный text-shadow + outline для самых светлых сцен */
  text-shadow: 0 1px 6px rgba(0,0,0,0.8), 0 0 1px rgba(0,0,0,0.5);
}
.bubble.patient::before {
  content: "Пациент: ";
  font-weight: 700;
  letter-spacing: 0.01em;
}
.bubble.student {
  padding-left: var(--sp-6);
}
.bubble.student::before {
  content: "Врач: ";
  font-weight: 700;
  color: rgba(180, 220, 255, 1);  /* slight cyan tint to differentiate */
  letter-spacing: 0.01em;
}

/* Role labels localized off <html lang> (set per locale by i18n.js).
   The Russian rules above are the default; these override per locale. */
html[lang="en"] .bubble.patient::before { content: "Patient: "; }
html[lang="en"] .bubble.student::before { content: "Doctor: "; }
html[lang="tr"] .bubble.patient::before { content: "Hasta: "; }
html[lang="tr"] .bubble.student::before { content: "Doktor: "; }
html[lang="kk"] .bubble.patient::before { content: "Науқас: "; }
html[lang="kk"] .bubble.student::before { content: "Дәрігер: "; }
html[lang="es"] .bubble.patient::before { content: "Paciente: "; }
html[lang="es"] .bubble.student::before { content: "Médico: "; }

/* ── Control bar под сценой ─── */
.control-bar {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
/* TASK-04: технические метаданные скрыты по умолчанию */
.bubble-meta {
  display: none;
  font-size: var(--fs-xs);
  margin-top: var(--sp-2);
  opacity: 0.7;
  font-family: var(--font-mono);
}
.bubble-icon {
  font-size: var(--fs-xs);
  opacity: 0.6;
  margin-right: var(--sp-1);
}
body.debug .bubble-meta { display: block; }

/* ── Контролы ввода ─── */
#controls {
  display: flex;
  gap: var(--sp-2);
}
#ptt-button {
  flex: 1;
  background: var(--color-primary);
  color: white;
  border: none;
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-lg);
  font-size: var(--fs-md);
  font-weight: 600;
  user-select: none;
  transition: background var(--t-fast), transform 50ms ease;
  min-height: 56px;     /* mobile-friendly tap target */
}
#ptt-button:hover:not(:disabled) { background: var(--color-primary-hover); }
#ptt-button.recording {
  background: var(--color-danger);
  transform: scale(0.98);
}
#ptt-button:disabled {
  background: var(--color-border-strong);
  color: var(--color-text-muted);
  cursor: not-allowed;
}
/* ── TASK-02: Текстовый ввод ─── */
.input-mode-toggle {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  user-select: none;
  padding: var(--sp-1);
}
.input-mode-toggle:hover { color: var(--color-primary); }

#text-input-container {
  display: none;
  flex-direction: column;
  gap: var(--sp-2);
}
body.text-input-mode #text-input-container { display: flex; }
body.text-input-mode #controls { display: none; }
body.text-input-mode .ptt-only { display: none; }

#text-input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-base);
  font-family: var(--font-sans);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  resize: vertical;
  min-height: 76px;
  background: var(--color-surface);
}
#text-input-send {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-base);
  font-weight: 600;
  align-self: flex-end;
}
#text-input-send:hover:not(:disabled) { background: var(--color-primary-hover); }
#text-input-send:disabled {
  background: var(--color-border-strong);
  cursor: not-allowed;
}

/* ── TASK-06: индикатор подсказки при ASR-сбое ─── */
#asr-hint {
  font-size: var(--fs-sm);
  color: var(--color-warning);
  text-align: center;
  padding: var(--sp-2);
  display: none;
}
#asr-hint.visible { display: block; }

/* ── Унифицированный pipeline-статус ─── */
/* Заменяет 6 разных текстовых состояний одной визуальной моделью:
   pipeline (mic → asr → llm → tts) + цветная полоса прогресса.
   Активная стадия подсвечивается, выполненные — тушатся. Цвет полосы
   меняется в зависимости от стадии (нейтрал/синий/фиолетовый/зелёный/красный). */
#status-bar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--t-base);
}
.status-stages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  flex-wrap: nowrap;
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
}
.status-stage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  white-space: nowrap;
  /* Iter 2 TASK-007: pending выглядит «ready», не disabled (0.5 → 0.75) */
  opacity: 0.75;
  color: var(--color-text);
  transition: opacity var(--t-base), background var(--t-base), color var(--t-base);
}
.status-stage-icon { font-size: 13px; }
.status-stage-label {
  font-size: 11px;
  font-weight: 500;
}
.status-arrow {
  font-size: 11px;
  color: var(--color-border-strong);
  opacity: 0.6;
  transition: color var(--t-base), opacity var(--t-base);
}

/* Iter 2 TASK-007 (fix): стрелки между завершёнными шагами зелёные.
 * Используем data-arrow-id вместо nth-of-type (mixed-tag siblings ломают nth) */
#status-bar[data-stage="asr"]      .status-arrow[data-arrow-id="mic-asr"],
#status-bar[data-stage="cleanup"]  .status-arrow[data-arrow-id="mic-asr"],
#status-bar[data-stage="llm"]      .status-arrow[data-arrow-id="mic-asr"],
#status-bar[data-stage="llm"]      .status-arrow[data-arrow-id="asr-llm"],
#status-bar[data-stage="tts"]      .status-arrow[data-arrow-id="mic-asr"],
#status-bar[data-stage="tts"]      .status-arrow[data-arrow-id="asr-llm"],
#status-bar[data-stage="tts"]      .status-arrow[data-arrow-id="llm-tts"],
#status-bar[data-stage="speaking"] .status-arrow[data-arrow-id="mic-asr"],
#status-bar[data-stage="speaking"] .status-arrow[data-arrow-id="asr-llm"],
#status-bar[data-stage="speaking"] .status-arrow[data-arrow-id="llm-tts"] {
  color: var(--color-success);
  opacity: 1;
}

/* Active stage */
.status-stage.active {
  opacity: 1;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
  animation: status-pulse 1.4s ease-in-out infinite;
}
@keyframes status-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.status-stage.done {
  opacity: 0.85;
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* Iter 2 TASK-007: ✓ checkmark для done состояний (явный visual cue) */
.status-stage.done::after,
#status-bar[data-stage="asr"]      .status-stage[data-stage-id="mic"]::after,
#status-bar[data-stage="cleanup"]  .status-stage[data-stage-id="mic"]::after,
#status-bar[data-stage="llm"]      .status-stage[data-stage-id="mic"]::after,
#status-bar[data-stage="llm"]      .status-stage[data-stage-id="asr"]::after,
#status-bar[data-stage="tts"]      .status-stage[data-stage-id="mic"]::after,
#status-bar[data-stage="tts"]      .status-stage[data-stage-id="asr"]::after,
#status-bar[data-stage="tts"]      .status-stage[data-stage-id="llm"]::after,
#status-bar[data-stage="speaking"] .status-stage[data-stage-id="mic"]::after,
#status-bar[data-stage="speaking"] .status-stage[data-stage-id="asr"]::after,
#status-bar[data-stage="speaking"] .status-stage[data-stage-id="llm"]::after {
  content: " ✓";
  font-weight: 700;
  margin-left: 2px;
}

/* Iter 2 TASK-008: wrap для label + progress bar */
.status-progress-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.status-progress-label {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  min-width: 130px;
  text-align: right;
  transition: color var(--t-base);
}
/* Active stage — accent цвет label */
#status-bar[data-stage="mic"]      .status-progress-label,
#status-bar[data-stage="asr"]      .status-progress-label,
#status-bar[data-stage="cleanup"]  .status-progress-label,
#status-bar[data-stage="llm"]      .status-progress-label,
#status-bar[data-stage="tts"]      .status-progress-label {
  color: var(--color-primary);
  font-weight: 500;
}
#status-bar[data-stage="speaking"] .status-progress-label {
  color: var(--color-success);
  font-weight: 500;
}
/* Iter 2 followup: report/error label matches progress-fill colors (visual coherence) */
#status-bar[data-stage="report"]    .status-progress-label {
  color: var(--color-warning);
  font-weight: 500;
}
#status-bar[data-stage="error"]     .status-progress-label {
  color: var(--color-danger);
  font-weight: 600;
}

/* Полоса прогресса */
.status-progress {
  flex: 1;
  height: 3px;
  background: var(--color-surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.status-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.4s ease, background 0.3s ease;
}

/* Цветовая схема по стадиям */
#status-bar[data-stage="idle"]      .status-progress-fill { width: 0%;   background: var(--color-border-strong); }
#status-bar[data-stage="connecting"] .status-progress-fill { width: 8%;  background: var(--color-text-subtle); }
#status-bar[data-stage="mic"]       .status-progress-fill { width: 12%;  background: var(--color-danger); }
#status-bar[data-stage="asr"]       .status-progress-fill { width: 30%;  background: var(--color-primary); }
#status-bar[data-stage="cleanup"]   .status-progress-fill { width: 45%;  background: var(--color-primary); }
#status-bar[data-stage="llm"]       .status-progress-fill { width: 65%;  background: #6b46c1; }
#status-bar[data-stage="tts"]       .status-progress-fill { width: 85%;  background: #0F9ED5; }
#status-bar[data-stage="speaking"]  .status-progress-fill { width: 100%; background: var(--color-success); }
#status-bar[data-stage="report"]    .status-progress-fill { width: 60%;  background: var(--color-warning); animation: status-shimmer 1.6s linear infinite; }
#status-bar[data-stage="error"]     .status-progress-fill { width: 100%; background: var(--color-danger); }

/* Активная стадия pipeline — подсветка по data-stage */
#status-bar[data-stage="mic"]       .status-stage[data-stage-id="mic"],
#status-bar[data-stage="asr"]       .status-stage[data-stage-id="asr"],
#status-bar[data-stage="cleanup"]   .status-stage[data-stage-id="asr"],
#status-bar[data-stage="llm"]       .status-stage[data-stage-id="llm"],
#status-bar[data-stage="tts"]       .status-stage[data-stage-id="tts"],
#status-bar[data-stage="speaking"]  .status-stage[data-stage-id="tts"] {
  opacity: 1;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
  animation: status-pulse 1.4s ease-in-out infinite;
}

/* Каскад «выполнено» — стадии левее активной */
#status-bar[data-stage="asr"]      .status-stage[data-stage-id="mic"],
#status-bar[data-stage="cleanup"]  .status-stage[data-stage-id="mic"],
#status-bar[data-stage="llm"]      .status-stage[data-stage-id="mic"],
#status-bar[data-stage="llm"]      .status-stage[data-stage-id="asr"],
#status-bar[data-stage="tts"]      .status-stage[data-stage-id="mic"],
#status-bar[data-stage="tts"]      .status-stage[data-stage-id="asr"],
#status-bar[data-stage="tts"]      .status-stage[data-stage-id="llm"],
#status-bar[data-stage="speaking"] .status-stage[data-stage-id="mic"],
#status-bar[data-stage="speaking"] .status-stage[data-stage-id="asr"],
#status-bar[data-stage="speaking"] .status-stage[data-stage-id="llm"] {
  opacity: 0.85;
  background: var(--color-success-bg);
  color: var(--color-success);
  animation: none;
}

@keyframes status-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(0); }
}

#status-bar[data-stage="error"] {
  border-color: var(--color-danger);
}
#status-bar.report-mode .status-stages { display: none; }

#status {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  text-align: center;
  min-height: 1.2em;
}
#status-bar[data-stage="error"] #status { color: var(--color-danger); }
#status-bar[data-stage="speaking"] #status { color: var(--color-success); }

/* Mobile: прячем подписи стадий, оставляем только иконки + полосу */
@media (max-width: 600px) {
  .status-stage-label { display: none; }
  .status-stage { padding: 4px 6px; }
  .status-arrow { font-size: 10px; }
}
#timings {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  font-family: var(--font-mono);
  text-align: center;
}
/* TASK-04: timings скрыты без debug-режима */
body:not(.debug) #timings { display: none; }

/* ── TASK-07: Блок «Отчёт готов» ─── */
#report-summary {
  background: var(--color-success-bg);
  border-left: 4px solid var(--color-success);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  margin-top: var(--sp-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}
#report-summary[hidden] { display: none; }
#report-summary .rubric-chip {
  background: rgba(255,255,255,0.7);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--color-success);
}
#report-summary .rubric-chip b { font-size: var(--fs-base); }
#report-summary a.open-report {
  margin-left: auto;
  background: var(--color-success);
  color: white;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-sm);
}
#report-summary a.open-report:hover {
  background: #14532d;
  color: white;
}
.report-progress {
  background: var(--color-primary-soft);
  border-left: 3px solid var(--color-primary);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--color-primary);
  margin-top: var(--sp-2);
}

/* ─────────────────────────────────────────────────────────────────
   FOOTER
   ─────────────────────────────────────────────────────────────── */
footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--sp-5) var(--sp-5) var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}
footer summary { cursor: pointer; user-select: none; }
footer ul { padding-left: var(--sp-5); }

/* ─────────────────────────────────────────────────────────────────
   МОДАЛЬНОЕ ОКНО (settings + reset confirmation)
   ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 30, 50, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  animation: fadeIn 150ms ease;
}
.modal-overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 200ms ease;
}
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-card.confirm { max-width: 440px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
}
.modal-header h2 {
  margin: 0;
  font-size: var(--fs-lg);
  color: var(--color-primary);
  font-weight: 600;
}
.modal-header button.modal-close {
  background: none; border: none;
  font-size: var(--fs-md);
  color: var(--color-text-muted);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
}
.modal-header button.modal-close:hover { background: var(--color-surface-2); }
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.modal-body {
  padding: var(--sp-4) var(--sp-5);
  overflow-y: auto;
  flex: 1;
}
.modal-body p { margin: 0 0 var(--sp-3) 0; }

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  gap: var(--sp-3);
}

/* ── Settings — секции ─── */
.settings-section {
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--color-border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section h3 {
  margin: 0 0 var(--sp-1) 0;
  font-size: var(--fs-sm);
  color: var(--color-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.settings-section .section-desc {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--sp-3);
  line-height: var(--lh-relaxed);
}
.field-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-2);
}
.field-label {
  font-size: var(--fs-sm);
  color: var(--color-text);
}
.field-input input,
.field-input select {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  background: var(--color-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field-input input:focus,
.field-input select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(21,96,130,0.12);
}
/* Iter 4 TASK-020: keyboard focus более явный (поверх box-shadow) */
.field-input input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.field-input select:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.field-hint {
  grid-column: 2;
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  margin-top: var(--sp-1);
}

#settings-status {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  flex: 1;
}
#settings-status.success { color: var(--color-success); }
#settings-status.error   { color: var(--color-danger); }

/* ── Группы настроек (credentials / routing) ─── */
.settings-group-header {
  margin: var(--sp-5) 0 var(--sp-3) 0;
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--color-primary);
}
.settings-group-header:first-child { margin-top: 0; }
.settings-group-header h2 {
  margin: 0 0 var(--sp-1) 0;
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.settings-group-header p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* ── Подвал секции (Сохранить + Тест + статус) ─── */
.section-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
}

/* Кнопка «Сохранить раздел» */
.btn-save-section {
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  font-family: inherit;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--t-fast);
}
.btn-save-section:hover   { opacity: 0.85; }
.btn-save-section:disabled { opacity: 0.5; cursor: default; }

/* Кнопка «Тест» */
.btn-test {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  font-family: inherit;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.btn-test:hover   { border-color: var(--color-primary); color: var(--color-primary); }
.btn-test:disabled { opacity: 0.5; cursor: default; }

/* Статус-лейбл внутри подвала секции */
.section-status {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.section-status.ok      { color: var(--color-success); }
.section-status.warn    { color: var(--color-warning, #b45309); }
.section-status.fail    { color: var(--color-danger); }
.section-status.testing { color: var(--color-text-muted); font-style: italic; }

/* ── Кнопки ─── */
.btn-primary,
.btn-secondary,
.btn-danger {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: background var(--t-fast), border-color var(--t-fast);
  min-height: 36px;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-primary:disabled {
  background: var(--color-border-strong);
  color: var(--color-text-muted);
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover { background: var(--color-surface-2); }
.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-danger:hover:not(:disabled) { background: #7f1d1d; }

/* ── Avatar library chips (settings) ─── */
.avatar-library {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.avatar-chip {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--t-fast);
  font-family: inherit;
}
.avatar-chip.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.avatar-chip:hover:not(.active) { background: var(--color-primary-soft); }

.avatar-upload-btn {
  display: inline-block;
  font-size: var(--fs-xs);
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-surface);
  border: 1px dashed var(--color-primary);
  color: var(--color-primary);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.avatar-upload-btn input { display: none; }

/* ─── Picker сценариев (стартовый экран) ─── */
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-2);
}
@media (max-width: 600px) {
  .picker-grid { grid-template-columns: 1fr; gap: var(--sp-3); }
}
.picker-loading,
.picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--sp-7);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

/* ─── Баннер активной сессии в picker ─── */
.picker-active-banner {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  margin: 0 0 var(--sp-4) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
/* hidden-атрибут должен побеждать display:flex выше (как .modal-overlay[hidden]
   / #report-view[hidden]) — иначе JS-гейтинг `banner.hidden = …` не действует
   и баннер показывается всегда, даже до старта кейса. */
.picker-active-banner[hidden] { display: none; }
.picker-active-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 240px;
  min-width: 0;
}
.picker-active-text strong {
  font-size: var(--fs-md);
  color: #92400e;
}
.picker-active-text span {
  font-size: var(--fs-xs);
  color: #78350f;
}
.picker-active-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.picker-active-actions .btn-primary {
  background: var(--color-success);
  border-color: var(--color-success);
}
.picker-active-actions .btn-primary:hover {
  background: var(--color-success-hover, #1f6e3a);
}

/* ─── Language bar в picker (i18n) ─── */
.picker-language-bar {
  /* Iter 3 TASK-012: унифицированный светло-серый фон для всех 3 step blocks */
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  margin: 0 0 var(--sp-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.picker-language-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: #0c4a6e;
}
.picker-language-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.picker-language-options .lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1.5px solid #bae6fd;
  border-radius: 999px;
  background: white;
  cursor: pointer;
  font-size: var(--fs-sm);
  transition: all 150ms ease;
  user-select: none;
}
.picker-language-options .lang-chip:hover {
  border-color: #0284c7;
  background: #f0f9ff;
}
.picker-language-options .lang-chip.active {
  background: #0284c7;
  border-color: #0284c7;
  color: white;
  font-weight: 600;
}
.picker-language-options .lang-chip input { display: none; }
.picker-language-options .lang-chip .flag { font-size: 18px; }
.picker-language-help {
  font-size: var(--fs-xs);
  color: #075985;
  line-height: 1.4;
}

/* ─── Mode bar (PTT / Continuous) — рядом с language bar ────── */
.picker-mode-bar {
  /* Iter 3 TASK-012: единый bg со step 1 */
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  margin: 0 0 var(--sp-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.picker-mode-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: #78350f;
}
.picker-mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.picker-mode-options .mode-chip {
  padding: 6px 14px;
  border: 1.5px solid #fde68a;
  border-radius: 999px;
  background: white;
  cursor: pointer;
  font-size: var(--fs-sm);
  transition: all 150ms ease;
  user-select: none;
}
.picker-mode-options .mode-chip:hover {
  border-color: #d97706;
  background: #fffbeb;
}
.picker-mode-options .mode-chip.active {
  background: #d97706;
  border-color: #d97706;
  color: white;
  font-weight: 600;
}
.picker-mode-options .mode-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: white;
}
.picker-mode-options .mode-chip.active:disabled {
  background: #d97706;
  border-color: #d97706;
  color: white;
  opacity: 0.7;
  cursor: not-allowed;
}
.picker-mode-help {
  font-size: var(--fs-xs);
  color: #78350f;
  line-height: 1.4;
}

/* ─── Toolbar фильтров (search + category + specialty) ──────── */
.picker-filters {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
}
.picker-search {
  width: 100%;
  padding: 10px 14px;
  font-size: var(--fs-sm);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
}
.picker-search:focus {
  outline: none;
  border-color: #156082;
  box-shadow: 0 0 0 3px rgba(21, 96, 130, 0.15);
}
/* Iter 4 TASK-020: keyboard focus more visible */
.picker-search:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.picker-filter-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
}
.picker-filter-label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  min-width: 110px;
}
.picker-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.picker-chip {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: white;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease;
}
.picker-chip:hover { background: #f1f5f9; }
.picker-chip.active {
  background: #156082;
  border-color: #156082;
  color: white;
}
/* Iter 3 TASK-014: styled native select — pill-match с category chips */
.picker-select {
  padding: 6px 32px 6px 12px;  /* extra right padding для arrow */
  border: 1.5px solid var(--color-border);
  background-color: var(--color-surface);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color var(--t-base);
}
.picker-select:hover {
  border-color: var(--color-primary);
}
.picker-select:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.picker-filter-stats {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  justify-content: space-between;
}
.picker-stats-text { font-style: italic; }
.picker-link-btn {
  background: none; border: none;
  color: #156082;
  font-size: var(--fs-xs);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.picker-link-btn:hover { color: #0f4566; }

/* Метки на карточках (категория, специальность, ключевики) */
.picker-card .pills {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 6px;
}
.picker-card .pill {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  white-space: nowrap;
}
.picker-card .pill.cat {
  background: #fef3c7;
  color: #78350f;
  font-weight: 600;
}
.picker-card .pill.spec {
  background: #dbeafe;
  color: #1e40af;
}
.picker-card .pill.kw {
  background: #f1f5f9;
  color: #475569;
}
.picker-card .pill.kw mark {
  background: #fde047;
  color: inherit;
  padding: 0 1px;
}

.picker-card {
  cursor: pointer;
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 0;
  background: linear-gradient(135deg, #ffffff 0%, #fafaf7 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  /* объёмная многослойная тень */
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 4px 8px rgba(15, 23, 42, 0.06),
    0 8px 16px rgba(15, 23, 42, 0.04);
  transition:
    transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 150ms ease;
}
.picker-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-hover));
  opacity: 0; transition: opacity 200ms ease;
}
.picker-card:hover {
  transform: translateY(-6px) scale(1.01);
  border-color: var(--color-primary);
  box-shadow:
    0 2px 4px rgba(21, 96, 130, 0.08),
    0 8px 16px rgba(21, 96, 130, 0.10),
    0 16px 32px rgba(21, 96, 130, 0.10),
    0 24px 48px rgba(21, 96, 130, 0.08);
}
.picker-card:hover::before { opacity: 1; }
.picker-card:active { transform: translateY(-2px) scale(0.998); }

@media (max-width: 600px) {
  .picker-card { grid-template-columns: 100px 1fr; }
}

/* Левая колонка — аватар */
.picker-card .thumb-wrap {
  position: relative;
  width: 168px; height: 100%;
  min-height: 200px;
  background: linear-gradient(135deg, #0E2841 0%, #156082 100%);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.5);
  font-size: 48px;
  overflow: hidden;
}
@media (max-width: 600px) {
  .picker-card .thumb-wrap { width: 100px; min-height: 160px; font-size: 36px; }
}
.picker-card .thumb-wrap::after {
  /* тонкий внутренний вертикальный разделитель */
  content: "";
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.08), transparent);
}
.picker-card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* Правая колонка — текст */
.picker-card .info {
  padding: var(--sp-4) var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-2);
  min-width: 0;
}
@media (max-width: 600px) {
  .picker-card .info { padding: var(--sp-3); }
}
.picker-card .info .head-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--sp-2);
}
.picker-card .info .name {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.picker-card .info .age {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  background: var(--color-surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.picker-card .info .occupation {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  margin-top: -4px;
}
.picker-card .info .chief {
  font-size: var(--fs-sm);
  color: var(--color-text);
  line-height: 1.4;
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-primary-soft);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
}
.picker-card .info .chief b {
  color: var(--color-primary);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}
.picker-card .info .meta {
  display: flex; gap: var(--sp-2);
  margin-top: auto;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--color-border);
  font-size: 11px;
  color: var(--color-text-subtle);
  align-items: center;
}
.picker-card .info .start-cue {
  margin-left: auto;
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--fs-xs);
  opacity: 0; transition: opacity 200ms ease, transform 200ms ease;
  transform: translateX(-4px);
}
.picker-card:hover .info .start-cue {
  opacity: 1;
  transform: translateX(0);
}

/* ─────────────────────────────────────────────────────────────────
   MOBILE / TABLET
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  main {
    padding: var(--sp-3);
    gap: var(--sp-3);
  }
  /* На планшете оставляем 4:3 — просто меньше */
  .stage { max-width: 100%; }
  #transcript { max-height: 90px; }
  .bubble { font-size: var(--fs-base); }
}

@media (max-width: 600px) {
  /* Шапка тоньше на телефоне */
  header { padding: var(--sp-3) var(--sp-4); }
  header h1 { font-size: var(--fs-base); }
  #patient-info { font-size: var(--fs-xs); }
  #session-timer { font-size: var(--fs-xs); padding: var(--sp-1) var(--sp-2); }
  .header-toggle-debug { display: none; }  /* debug toggle прячем — есть в settings */
  #settings-button { width: 36px; height: 36px; font-size: 18px; }

  /* На телефоне портретная сцена 3:4 — иначе аватар совсем мелкий */
  .stage { aspect-ratio: 3 / 4; }
  .dialog-overlay { padding: var(--sp-5) var(--sp-3) var(--sp-3); }
  #transcript { max-height: 80px; }
  .bubble { font-size: var(--fs-sm); }

  /* PTT кнопка ещё больше для пальца */
  #ptt-button {
    font-size: var(--fs-base);
    min-height: 64px;
  }

  /* Bubble на полную ширину */
  .bubble { max-width: 92%; font-size: var(--fs-sm); }

  /* Modals — почти полный экран */
  .modal-overlay { padding: var(--sp-2); }
  .modal-card { max-height: 95vh; }
  .field-row {
    grid-template-columns: 1fr;
    gap: var(--sp-1);
  }
  .field-hint { grid-column: 1; }
}

/* ─────────────────────────────────────────────────────────────────
   LOGIN — magic-link auth (shown when /api/auth/me returns 401)
   ─────────────────────────────────────────────────────────────── */
.login-card { max-width: 460px; }
.login-intro {
  margin: 0 0 var(--sp-3) 0;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}
.login-field {
  display: block;
  margin-bottom: var(--sp-3);
}
.login-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--sp-1);
}
.login-field input {
  width: 100%;
  padding: var(--sp-3);
  font-size: var(--fs-base);
  font-family: var(--font-sans);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.login-field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(21,96,130,0.12);
}
/* Iter 4 TASK-020: keyboard focus more visible */
.login-field input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
#login-submit {
  width: 100%;
  padding: var(--sp-3);
  font-size: var(--fs-base);
  margin-top: var(--sp-2);
}
.login-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-left: 3px solid var(--color-danger);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
}
.login-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-left: 3px solid var(--color-success);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  text-align: center;
}
.login-success h3 {
  margin: 0 0 var(--sp-2) 0;
  color: var(--color-success);
  font-size: var(--fs-md);
}
.login-success p { margin: 0 0 var(--sp-2) 0; }
.login-success .login-tip {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: var(--sp-2);
}
.login-link {
  background: none;
  border: none;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.login-link:hover { color: var(--color-primary-hover); }

/* ─── User chip в шапке (после успешного login) ─── */
#user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  /* No translucent pill: the prominent .btn-results now leads this group,
     so a competing background looked crowded. Email + logout sit beside it. */
  background: none;
  padding: 0;
  font-size: var(--fs-xs);
  max-width: 320px;
}
.user-chip-email {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#user-chip-logout {
  background: rgba(0,0,0,0.18);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
}
#user-chip-logout:hover { background: rgba(0,0,0,0.32); }

@media (max-width: 600px) {
  #user-chip { max-width: 130px; }
}

/* ─────────────────────────────────────────────────────────────────
   BRIEFING — «doorway info» перед входом в кабинет (OSCE-style)
   ─────────────────────────────────────────────────────────────── */
.briefing-card { max-width: 640px; }
.briefing-icon { display: inline-block; margin-right: var(--sp-1); font-size: 22px; }
.briefing-intro {
  margin: 0 0 var(--sp-4) 0;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}
.briefing-patient {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-4);
  padding: var(--sp-3);
  background: linear-gradient(135deg, var(--color-surface-2) 0%, #ffffff 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}
.briefing-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #0E2841 0%, var(--color-primary) 100%);
  color: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  overflow: hidden;
  flex-shrink: 0;
}
.briefing-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.briefing-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.briefing-meta {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.briefing-occupation {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  margin-top: 4px;
}

.briefing-section {
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-3);
}
.briefing-section-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: var(--sp-1);
}
.briefing-complaint {
  background: var(--color-primary-soft);
  border-left: 3px solid var(--color-primary);
}
.briefing-complaint .briefing-section-label { color: var(--color-primary); }
.briefing-task {
  background: var(--color-warning-bg);
  border-left: 3px solid var(--color-warning);
}
.briefing-task .briefing-section-label { color: var(--color-warning); }
.briefing-task ul {
  margin: 0;
  padding-left: var(--sp-5);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}
.briefing-task li { margin: 2px 0; }

.briefing-tip {
  margin: var(--sp-3) 0 0 0;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  line-height: var(--lh-relaxed);
}

.briefing-countdown {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  flex: 1;
  text-align: left;
}
.briefing-countdown b {
  color: var(--color-primary);
  font-size: var(--fs-sm);
}
.briefing-countdown.expiring b { color: var(--color-danger); }
.briefing-countdown.hidden { visibility: hidden; }

@media (max-width: 520px) {
  .briefing-patient {
    grid-template-columns: 60px 1fr;
  }
  .briefing-avatar { width: 60px; height: 60px; font-size: 24px; }
  .briefing-name { font-size: var(--fs-base); }
}

/* ─────────────────────────────────────────────────────────────────
   DEBRIEF — confidence Likert + focus chips
   ─────────────────────────────────────────────────────────────── */
.debrief-fieldset {
  margin: 0 0 var(--sp-4) 0;
  padding: var(--sp-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}
.debrief-fieldset legend {
  padding: 0 var(--sp-2);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--color-text);
}

.confidence-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.conf-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--sp-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  user-select: none;
}
.conf-option:hover { background: var(--color-primary-soft); }
.conf-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.conf-option:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 2px rgba(21,96,130,0.18);
  transform: translateY(-1px);
}
/* Iter 4 TASK-023: PEARLS Likert keyboard focus visible state */
.conf-option:focus-within {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.conf-option .conf-emoji { font-size: 24px; line-height: 1; }
.conf-option .conf-text { font-size: 11px; color: var(--color-text-muted); text-align: center; }

@media (max-width: 520px) {
  .confidence-scale { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .conf-option { padding: 6px 2px; }
  .conf-option .conf-emoji { font-size: 20px; }
  .conf-option .conf-text { font-size: 10px; }
}

.focus-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.focus-chip-input {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.focus-chip-input input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.focus-chip-input span {
  display: inline-block;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: var(--fs-xs);
  color: var(--color-text);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.focus-chip-input:hover span { background: var(--color-primary-soft); }
.focus-chip-input input:checked + span {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────
   INLINE-ОТЧЁТ — поверх всей страницы (full-viewport iframe)
   ─────────────────────────────────────────────────────────────── */
#report-view {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}
#report-view[hidden] { display: none; }

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.report-toolbar .report-toolbar-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1;
  text-align: center;
  opacity: 0.9;
}
.report-toolbar .btn-secondary {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
}
.report-toolbar .btn-secondary:hover { background: rgba(255,255,255,0.26); }
.report-toolbar .btn-primary {
  background: white;
  color: var(--color-primary);
}
.report-toolbar .btn-primary:hover { background: rgba(255,255,255,0.92); }
.report-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
/* Prominent «Мои результаты» button — high-contrast accent so it stands out
   from the back/PDF actions, in the report toolbar and the top nav alike. */
.btn-results {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill, 999px);
  background: var(--color-accent, #f59e0b);
  color: #fff;
  font-size: var(--fs-sm, 14px);
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 150ms ease, transform 100ms ease, box-shadow 150ms ease;
  white-space: nowrap;
}
.btn-results:hover {
  background: var(--color-accent-hover, #d97706);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.15));
}
.btn-results:active { transform: translateY(0); }
.btn-results:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
/* In the report toolbar (blue bg) the accent already contrasts; keep it. */
.report-toolbar .btn-results { box-shadow: 0 1px 4px rgba(0,0,0,0.25); }

#report-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

@media print {
  /* Когда пользователь нажмёт «Сохранить PDF», печатаем содержимое iframe.
     Сама внешняя обёртка (toolbar + остальное) скрывается на всякий случай. */
  body > *:not(#report-view) { display: none !important; }
  #report-view { position: static; }
  .report-toolbar { display: none !important; }
  #report-iframe { height: auto; }
}

/* ─────────────────────────────────────────────────────────────────
   ACCESSIBILITY
   ─────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

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

/* ═══════════════════════════════════════════════════════════════════
   ГЛАВНАЯ СТРАНИЦА: Двухколоночный layout (stage слева, dark sidebar
   справа). Перекрывает свойства main/.control-bar выше.
   Только на главной странице (body без класса admin-app/studio).
   ═══════════════════════════════════════════════════════════════════ */

body:not(.admin-app):not(.studio) main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  padding: 0;
  max-width: none;
  align-items: stretch;
  /* Высота — от хедера до низа экрана */
  height: calc(100vh - 64px);
}

body:not(.admin-app):not(.studio) .stage {
  width: 100%;
  max-width: none;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}

/* ── Правая dark-панель ────────────────────────────────────────── */
body:not(.admin-app):not(.studio) .control-bar {
  background: #0e1822;
  color: #e0e8f0;
  border-left: 1px solid #2a3444;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  /* Сбрасываем светлые фоновые свойства из старых стилей */
  border-radius: 0;
  box-shadow: none;
  max-width: none;
  margin: 0;
}

/* ── Compact status: horizontal dot-stepper + one line + bar ──── */
body:not(.admin-app):not(.studio) #status-bar {
  background: #1a2332;
  border: 1px solid #2a3444;
  border-radius: 10px;
  padding: 12px 14px;
  color: #c0cfdc;
  gap: 8px;
}
body:not(.admin-app):not(.studio) .status-stages {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  color: #6c7d8e;
}
body:not(.admin-app):not(.studio) .status-stage {
  width: 9px; height: 9px; padding: 0; gap: 0;
  border-radius: 50%;
  background: #2a3444;        /* pending dot — visible on dark */
  border: none; overflow: hidden; flex: 0 0 auto;
  white-space: normal;
}
body:not(.admin-app):not(.studio) .status-stage-icon,
body:not(.admin-app):not(.studio) .status-stage-label { display: none; }
body:not(.admin-app):not(.studio) .status-arrow { display: none; }
body:not(.admin-app):not(.studio) .status-text {
  color: #c0cfdc; margin-top: 2px; padding-top: 0; border-top: none; font-size: 12.5px;
}
body:not(.admin-app):not(.studio) .status-progress-label { display: none; }
body:not(.admin-app):not(.studio) .status-progress { background: #243245; margin-top: 0; }

/* ── PTT и ввод на dark-панели ────────────────────────────────── */
body:not(.admin-app):not(.studio) #controls {
  flex-direction: column;
  gap: 8px;
}
body:not(.admin-app):not(.studio) #ptt-button {
  background: #2563eb;
  color: #fff;
  border: none;
  font-size: 14px;
  padding: 14px;
  width: 100%;
  border-radius: 10px;
}
body:not(.admin-app):not(.studio) #ptt-button:hover:not(:disabled) {
  background: #1e4fc7;
}
body:not(.admin-app):not(.studio) #ptt-button.recording {
  background: #dc2626;
}
/* ── Текстовый ввод на dark-панели ────────────────────────────── */
body:not(.admin-app):not(.studio) #text-input {
  background: #1a2332;
  color: #e0e8f0;
  border: 1px solid #2a3444;
  border-radius: 10px;
  font-size: 13px;
  min-height: 76px;
}
body:not(.admin-app):not(.studio) #text-input::placeholder { color: #6c7d8e; }
body:not(.admin-app):not(.studio) #text-input-send {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px;
}
body:not(.admin-app):not(.studio) #text-input-send:hover { background: #1e4fc7; }

body:not(.admin-app):not(.studio) .input-mode-toggle {
  color: #6c7d8e;
  font-size: 11px;
  text-decoration: none;
  border-top: 1px dashed #2a3444;
  padding-top: 10px;
}
body:not(.admin-app):not(.studio) .input-mode-toggle:hover { color: #4a90e2; }

body:not(.admin-app):not(.studio) #asr-hint {
  color: #f59e0b;
  font-size: 12px;
}

body:not(.admin-app):not(.studio) #timings {
  color: #6c7d8e;
  font-size: 11px;
  font-family: var(--font-mono);
}
body:not(.admin-app):not(.studio) #report-summary {
  background: #1a3a2a;
  color: #a0e0c0;
  border: 1px solid #2a5a3a;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
}

/* ── Session control group — pinned bottom, set apart ─────────── */
body:not(.admin-app):not(.studio) #session-group {
  margin-top: auto;
  border: 1px solid #2a3444; border-radius: 10px;
  padding: 11px; display: flex; flex-direction: column; gap: 8px;
  background: #0b131c;
}
body:not(.admin-app):not(.studio) .session-group-label {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #6c7d8e;
}
body:not(.admin-app):not(.studio) .session-group-row { display: flex; gap: 8px; }
body:not(.admin-app):not(.studio) .session-group-row > button {
  flex: 1; background: #1a2332; border: 1px solid #2a3444; color: #c0cfdc;
  border-radius: 9px; padding: 9px; font-size: 13px; cursor: pointer;
}
body:not(.admin-app):not(.studio) .session-group-row > button:hover { background: #243245; }
body:not(.admin-app):not(.studio) .session-group-row > button:disabled { opacity: .55; cursor: not-allowed; }
body:not(.admin-app):not(.studio) #session-group .session-end-btn {
  width: 100%; background: #16361f; border: 1px solid #2f6b3f; color: #9be7b4;
  border-radius: 9px; padding: 11px; font-weight: 600; font-size: 13px; cursor: pointer;
}
body:not(.admin-app):not(.studio) #session-group .session-end-btn:hover {
  background: #1c4527; color: #b6f0c8;
}
body:not(.admin-app):not(.studio) #session-group .session-end-btn:disabled {
  opacity: .55; cursor: not-allowed;
}

/* ── Case file «Досье» — сворачиваемая панель НАД #session-group ──
   Объективные данные кейса во время сессии (labs/imaging/pathology/other).
   Раньше жила в шапке (height:64px) и обрезалась; теперь в правой колонке.
   Палитра — как у #session-group (тёмная панель). display задаётся только
   через :not([hidden]), иначе id-специфичность переборола бы [hidden]. */
body:not(.admin-app):not(.studio) #case-file-toggle {
  width: 100%; align-items: center; gap: 8px; text-align: left;
  background: #1a2332; border: 1px solid #2a3444; color: #c0cfdc;
  border-radius: 9px; padding: 9px 11px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
body:not(.admin-app):not(.studio) #case-file-toggle:not([hidden]) { display: flex; }
body:not(.admin-app):not(.studio) #case-file-toggle:hover { background: #243245; }
body:not(.admin-app):not(.studio) #case-file-toggle .case-file-toggle-label {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
}
/* Бейдж-счётчик: яркий cyan-pill. margin-left:auto прижимает бейдж+шеврон
   вправо. Светлый бейдж на тёмной кнопке (8.1:1) — заметный сигнал «есть данные». */
body:not(.admin-app):not(.studio) #case-file-toggle .case-file-count {
  margin-left: auto;
  background: #7cc4dd; color: #0b131c;
  font-size: 10px; font-weight: 700; line-height: 1;
  border-radius: 999px; padding: 2px 6px; min-width: 8px; text-align: center;
}
body:not(.admin-app):not(.studio) #case-file-toggle .case-file-chevron {
  color: #6c7d8e; font-size: 11px;
  transition: transform .15s ease;
}
body:not(.admin-app):not(.studio) #case-file-toggle[aria-expanded="true"] .case-file-chevron {
  transform: rotate(180deg);
}
/* Видимый фокус для клавиатуры — тот же cyan-акцент, что бейдж и лейблы. */
body:not(.admin-app):not(.studio) #case-file-toggle:focus-visible {
  outline: 2px solid #7cc4dd; outline-offset: 2px;
}
body:not(.admin-app):not(.studio) #case-file-panel.case-file {
  margin-top: 8px;
  border: 1px solid #2a3444; border-radius: 10px;
  background: #0b131c; padding: 11px;
  max-height: 38vh; overflow-y: auto;
  font-size: 12.5px; line-height: 1.5; color: #c0cfdc;
}
/* В кнопке-тоггле уже есть «📋 Досье» — внутренний заголовок панели прячем,
   чтобы не дублировать (в брифинге #briefing-case-file он остаётся виден). */
body:not(.admin-app):not(.studio) #case-file-panel .case-file-title { display: none; }
body:not(.admin-app):not(.studio) #case-file-panel .case-file-section { margin-top: 10px; }
body:not(.admin-app):not(.studio) #case-file-panel .case-file-section:first-of-type { margin-top: 0; }
body:not(.admin-app):not(.studio) #case-file-panel .case-file-label {
  /* cyan #7cc4dd (из бренд-тиала #156082): отделяет лейблы от текста тела и
     НЕ конфликтует с зелёным primary-action «Завершить и получить отчёт». */
  font-size: 11px; font-weight: 600; color: #7cc4dd; margin-bottom: 2px;
}
body:not(.admin-app):not(.studio) #case-file-panel .case-file-text {
  white-space: pre-wrap; color: #c0cfdc;
}
/* Мобайл: комфортная зона нажатия ≥44px (на десктопе ~36px, как session-кнопки). */
@media (max-width: 900px) {
  body:not(.admin-app):not(.studio) #case-file-toggle { min-height: 44px; }
}

/* ── Mobile (≤768px): «Досье» — компактная 📋-иконка в шапке рядом с ☰;
   панель — выпадающий список под шапкой. JS _moveCaseFileToHeader переносит
   toggle+panel в <header> (у .control-bar есть transform — нельзя; у <header>
   нет — можно). ВАЖНО: display НЕ задаём на bare-#case-file-toggle, иначе
   id-специфичность переборола бы [hidden] (visibility держит :not([hidden])
   выше). Иконка зеркалит #mobile-menu-btn (38×38, та же подложка). */
@media (max-width: 768px) {
  body:not(.admin-app):not(.studio) header { position: relative; }

  body:not(.admin-app):not(.studio) #case-file-toggle {
    width: 38px; height: 38px; min-height: 38px;
    flex: 0 0 auto; position: relative;
    align-items: center; justify-content: center;
    gap: 0; padding: 0;
    background: rgba(255,255,255,0.15); border: none; border-radius: 8px;
    color: #fff; font-size: 18px; font-weight: 400;
  }
  body:not(.admin-app):not(.studio) #case-file-toggle:hover { background: rgba(255,255,255,0.28); }
  body:not(.admin-app):not(.studio) #case-file-toggle .case-file-toggle-label { gap: 0; }
  body:not(.admin-app):not(.studio) #case-file-toggle .case-file-toggle-label span { display: none; }
  body:not(.admin-app):not(.studio) #case-file-toggle .case-file-chevron { display: none; }
  /* Бейдж — угловой счётчик (notification-dot), а не inline-pill. */
  body:not(.admin-app):not(.studio) #case-file-toggle .case-file-count {
    position: absolute; top: -3px; right: -3px; margin-left: 0;
    font-size: 9px; line-height: 1.5; padding: 0 4px; min-width: 7px;
    box-shadow: 0 0 0 2px var(--color-primary);  /* отбивка от тиала шапки */
  }

  /* Панель — выпадающий список под шапкой (absolute к position:relative header). */
  body:not(.admin-app):not(.studio) #case-file-panel.case-file {
    position: absolute; top: 100%; left: 8px; right: 8px;
    margin-top: 6px; max-height: 70vh; z-index: 1500;
    box-shadow: 0 14px 36px rgba(0,0,0,0.55);
  }
}

/* ── Header чуть мельче и без settings-button (он удалён) ─────── */
body:not(.admin-app):not(.studio) header {
  height: 64px;
  padding: 0 18px;
}

/* ── Mobile: возврат к колоночному layout ─────────────────────── */
@media (max-width: 900px) {
  body:not(.admin-app):not(.studio) main {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 64px);
  }
  body:not(.admin-app):not(.studio) .stage {
    aspect-ratio: 4/3;
    height: auto;
  }
  body:not(.admin-app):not(.studio) .control-bar {
    border-left: none;
    border-top: 1px solid #2a3444;
  }
}


/* ─── Picker steps (1. Language → 2. Mode → 3. Case) ─── */
/* Числовой бейдж шага слева от каждого блока — визуально подчёркивает,
   что выбор языка / режима — отдельные шаги ДО выбора кейса. */
.picker-step {
  position: relative;
  padding-left: 56px !important;  /* место под цифру */
}
.picker-step-num {
  position: absolute;
  left: var(--sp-3);
  top: var(--sp-3);
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.picker-step-body { display: flex; flex-direction: column; gap: var(--sp-2); }
.picker-step-header {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-4) 0 var(--sp-2) 0;
  padding-left: 0;
}
.picker-step-header .picker-step-num {
  position: static;
}
.picker-step-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--color-text);
}


/* ════════════════════════════════════════════════════════════════════
   MOBILE SESSION UI (≤ 768px)
   ════════════════════════════════════════════════════════════════════
   Desktop UX не трогаем. На мобиле перестраиваем так, чтобы
   ОДНОВРЕМЕННО на экране были:
     • аватар (основная область)
     • компактная строка статуса
     • большая sticky PTT-кнопка снизу
   Всё остальное (режим, камера, текст, звуки, сбросить, сменить,
   завершить сессию) уезжает в bottom-sheet drawer, открываемый
   нажатием на бургер ☰ в шапке.
   ──────────────────────────────────────────────────────────────────── */

/* По умолчанию hamburger и backdrop ВЫКЛЮЧЕНЫ — desktop их не видит. */
#mobile-menu-btn,
#mobile-drawer-backdrop { display: none; }

/* M2: Mobile coach panel — hidden on desktop, shown only inside ≤600px query */
#mobile-coach-panel { display: none; }

/* FIX2: Avatar stage hidden by default; revealed only when a session (or its
   loading phase) is active. Prevents the 3D primitive + cabinet from showing
   through the semi-transparent scenario picker. */
#stage { display: none; }
body.session-active #stage { display: block; }

/* ════════════════════════════════════════════════════════════════════
   IDLE-ЛЕНДИНГ — «пустой кабинет + парящая кнопка Выбрать кейс».
   Заменяет прежний пустой экран голой .control-bar (выглядел «мобильно»),
   который появлялся после Esc по пикеру на старте. Виден только когда юзер
   авторизован (body.app-ready) И нет активной сессии. Пикер (z-modal:100) и
   отчёт (#report-view, fixed z-80) ложатся ПОВЕРХ — лендинг в обычном потоке.
   ════════════════════════════════════════════════════════════════════ */
#idle-landing { display: none; }

/* Видим только: авторизован + нет сессии. Заполняет всю рабочую область main:
   на desktop — обе колонки грида; на mobile — растёт как flex-ребёнок. */
body.app-ready:not(.session-active) #idle-landing {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 1;
}
/* Скрываем сессионную панель до инициализации приложения — иначе она мигает
   до того как boot-cover перекроет экран (display:flex по умолчанию в .control-bar). */
body:not(.app-ready) .control-bar,
body:not(.app-ready) #mobile-coach-panel { display: none; }

/* В idle сессионные панели не нужны — прячем, чтобы кабинет с кнопкой занимал
   весь экран, а не делил грид/flex с пустой панелью. */
body.app-ready:not(.session-active) .control-bar,
body.app-ready:not(.session-active) #mobile-coach-panel { display: none; }

.idle-landing {
  position: relative;
  isolation: isolate;            /* внутренние z-index не «протекают» к пикеру */
  width: 100%;
  flex: 1 1 auto;                /* mobile: тянемся на всю высоту main-колонки */
  min-height: 60vh;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* CSS-фолбэк фона: тёплый «кабинет от лампы» — если defaultBackgroundUrl не
     задан или фото не загрузилось, экран всё равно выглядит цельно. */
  background: radial-gradient(120% 90% at 50% 8%, #1b3a52 0%, #12283b 45%, #0c1b26 100%);
}
.idle-landing__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  /* Чуть «успокаиваем» фото, чтобы парящая кнопка читалась как единственный фокус. */
  filter: saturate(0.92) brightness(0.82);
}
/* Нет src → не показываем «битую картинку», виден фолбэк-градиент контейнера. */
.idle-landing__bg:not([src]),
.idle-landing__bg[src=""] { display: none; }

/* Виньетка для контраста кнопки поверх любого фото кабинета. */
.idle-landing__scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(80% 70% at 50% 52%, rgba(8,18,32,0.10) 0%, rgba(8,18,32,0.52) 70%, rgba(8,18,32,0.78) 100%),
    linear-gradient(to top, rgba(8,18,32,0.55) 0%, rgba(8,18,32,0) 40%);
}
.idle-landing__cta {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
  padding: var(--sp-4);
}
.idle-landing__hint {
  margin: 0;
  max-width: 30ch;
  color: rgba(233,242,250,0.92);
  font-size: clamp(15px, 1.4vw, 18px);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 10px rgba(0,0,0,0.6), 0 0 1px rgba(0,0,0,0.5);
}

/* Парящая кнопка: teal→cyan (#156082 шапки × #38bdf8 обложки), мягкое свечение,
   лёгкое «дыхание» и сонар-пульс (отголосок ЭКГ с обложки — кабинет «жив»). */
.idle-pick-btn {
  position: relative;
  z-index: 0;                    /* свой stacking-контекст для ::before-пульса */
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 20px 40px;
  border: 1px solid rgba(120,200,240,0.55);
  border-radius: 999px;
  font-family: inherit;
  font-size: clamp(18px, 1.8vw, 24px);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f3fbff;
  cursor: pointer;
  background: linear-gradient(135deg, #1f6f99 0%, #156082 45%, #0f4a66 100%);
  box-shadow:
    0 18px 50px -12px rgba(20,110,150,0.75),
    0 0 0 6px rgba(56,189,248,0.10),
    inset 0 1px 0 rgba(255,255,255,0.25);
  animation: idleFloat 4.5s ease-in-out infinite;
  transition: transform 220ms cubic-bezier(0.22,1,0.36,1),
              box-shadow 220ms ease, border-color 220ms ease;
}
.idle-pick-btn::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid rgba(56,189,248,0.60);
  z-index: -1;
  pointer-events: none;
  animation: idlePing 2.8s cubic-bezier(0.22,1,0.36,1) infinite;
}
.idle-pick-btn:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(160,225,255,0.9);
  animation-play-state: paused;  /* «дыхание» не конфликтует с hover-подъёмом */
  box-shadow:
    0 26px 62px -10px rgba(30,130,180,0.9),
    0 0 0 8px rgba(56,189,248,0.16),
    inset 0 1px 0 rgba(255,255,255,0.35);
}
.idle-pick-btn:active { transform: translateY(-1px) scale(0.99); }
.idle-pick-btn:focus-visible {
  outline: 3px solid #7fd4ff;
  outline-offset: 4px;
  animation-play-state: paused;
}
.idle-pick-btn__arrow {
  font-size: 1.05em;
  line-height: 1;
  transition: transform 220ms cubic-bezier(0.22,1,0.36,1);
}
.idle-pick-btn:hover .idle-pick-btn__arrow { transform: translateX(5px); }

@keyframes idleFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@keyframes idlePing {
  0%   { opacity: 0.55; transform: scale(1); }
  70%  { opacity: 0;    transform: scale(1.28); }
  100% { opacity: 0;    transform: scale(1.28); }
}
/* Reduced-motion: гасим парение/пульс (как у boot-cover). */
@media (prefers-reduced-motion: reduce) {
  .idle-pick-btn { animation: none; }
  .idle-pick-btn::before { animation: none; opacity: 0; }
}

@media (max-width: 768px) {

  /* ── 1. Шапка: компактная + кнопка ☰ ──────────────────────── */
  body:not(.admin-app):not(.studio) header {
    padding: 8px 12px;
    min-height: 48px;
    gap: 8px;
  }
  .header-title h1 { font-size: 15px; line-height: 1.2; }
  #patient-info { font-size: 11px; }

  /* Прячем второстепенные header-actions — они уезжают в drawer
     через JS (см. _initMobileDrawer в app.js). Видимыми оставляем
     только таймер + user-chip (выход).
     ПРИМЕЧАНИЕ: НЕ используем display:none — JS перемещает элементы
     внутрь .mobile-drawer-extras, там они должны быть видимы. */
  .header-actions { gap: 6px; }
  /* Если элемент остался в header (на случай если JS ещё не отработал
     или mobile-drawer-extras не существует) — скрываем визуально. */
  .header-actions > #lang-switcher {
    display: none;
  }

  /* Когда move'нуты в drawer — выглядят как полноценные строки меню */
  .mobile-drawer-extras {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
  }
  .mobile-drawer-extras #lang-switcher,
  .mobile-drawer-extras #change-scenario-button {
    display: block !important;
    width: 100%;
    padding: 12px 14px;
    background: #f8fafc !important;
    color: var(--color-text, #1e293b) !important;
    border: 1px solid var(--color-border, #e2e8f0) !important;
    border-radius: 8px !important;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
  }

  /* Iter 4 TASK-028: user-chip styling в mobile drawer */
  .mobile-drawer-extras #user-chip {
    display: flex !important;
    flex-wrap: wrap;            /* запас: длинные элементы переносятся, а не налезают */
    width: 100%;
    max-width: none !important;
    padding: 12px 14px;
    background: #f8fafc;
    color: var(--color-text, #1e293b);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
  }
  .mobile-drawer-extras #user-chip .user-chip-email,
  .mobile-drawer-extras #user-chip #user-chip-email {
    flex: 1;
    font-size: 14px;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-drawer-extras #user-chip-logout {
    flex-shrink: 0;
  }
  .header-actions > #session-timer {
    font-size: 12px;
    padding: 4px 6px;
  }
  #user-chip { max-width: 100px; }
  .user-chip-email { font-size: 11px; max-width: 70px;
                     overflow: hidden; text-overflow: ellipsis; }

  /* Hamburger ☰ — справа от title, перед actions */
  #mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    margin-left: auto;       /* отжимает actions вправо */
    margin-right: 4px;
    border: none;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--t-fast);
  }
  #mobile-menu-btn:hover,
  #mobile-menu-btn[aria-expanded="true"] {
    background: rgba(255,255,255,0.28);
  }
  /* CSS-only 3-line hamburger icon */
  .mobile-menu-icon,
  .mobile-menu-icon::before,
  .mobile-menu-icon::after {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }
  .mobile-menu-icon { position: relative; }
  .mobile-menu-icon::before,
  .mobile-menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
  }
  .mobile-menu-icon::before { top: -6px; }
  .mobile-menu-icon::after  { top:  6px; }
  /* Когда drawer открыт — превращаем в крестик */
  #mobile-menu-btn[aria-expanded="true"] .mobile-menu-icon {
    background: transparent;
  }
  #mobile-menu-btn[aria-expanded="true"] .mobile-menu-icon::before {
    top: 0; transform: rotate(45deg);
  }
  #mobile-menu-btn[aria-expanded="true"] .mobile-menu-icon::after {
    top: 0; transform: rotate(-45deg);
  }

  /* ── 2. Сцена: аватар во всю ширину, компактная высота ──── */
  body:not(.admin-app):not(.studio) main {
    padding: 8px 0 0 0;  /* PTT is now a side FAB (fixed, right-center), so no bottom reserve — panel fills to the very bottom */
    /* FIX1: stretch session column to fill the viewport below the 64px header,
       so #mobile-coach-panel (flex:1) can grow to fill remaining space.
       main is the app-shell GRID by default — switch it to a flex column on
       mobile so flex-grow on the panel actually works. */
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 64px);
    box-sizing: border-box;
  }
  .stage {
    aspect-ratio: 1 / 1;     /* квадратный кроп для портретной ориентации */
    max-width: 100vw;
    margin: 0;
    border-radius: 0;
  }
  /* Диалог-overlay поверх аватара компактнее */
  .dialog-overlay {
    max-height: 40%;
    padding: 8px 10px;
  }
  .dialog-overlay #transcript .bubble {
    font-size: 13px;
    padding: 6px 10px;
  }

  /* ── 3. Status-bar: только текущий этап + полоса прогресса ── */
  #status-bar {
    margin: 0 12px;
    padding: 6px 10px;
    border-radius: 8px;
  }
  /* Прячем 4 этапа со стрелочками — для мобилы перегружено */
  #status-bar .status-stages { display: none; }
  /* Текст статуса и progress bar остаются */
  #status-bar .status-text {
    font-size: 13px;
    padding: 0;
    text-align: center;
    margin: 0;
  }

  /* ── 4. PTT/Continuous: круглый FAB справа на середине экрана ───
     Большой target для большого пальца (правша). На середине высоты —
     удобно дотянуться, поверх центра туловища аватара (груди) —
     визуально согласуется с «говорю с этим человеком».
     Размер 84px = WCAG 2.5.5 (минимум 44px, рекомендуется 48+).

     ВАЖНО: PTT-кнопка переносится через JS из .control-bar (drawer)
     в #mobile-floating-controls — иначе её position:fixed
     позиционируется относительно drawer'а из-за его transform, и
     она «уезжает» вместе со sheet'ом.

     ⚠ СПЕЦИФИЧНОСТЬ: десктоп-правила имеют селектор
     body:not(.admin-app):not(.studio) #ptt-button (специфичность 0,3,1),
     поэтому в этой media-query МЫ ОБЯЗАНЫ использовать тот же префикс,
     иначе наши rules не перебьют десктопные width:100%/padding:14px. */
  #mobile-floating-controls {
    position: static;
  }
  body:not(.admin-app):not(.studio) #ptt-button {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    z-index: 50;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    /* Скрываем текстовый лейбл на mobile через font-size: 0 —
       text content (даже после i18n) станет невидимым, а ::before
       сохранит свой явный font-size 36px. */
    font-size: 0;
    line-height: 0;
    padding: 0;
    margin: 0;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
    transition: transform 0.1s, box-shadow 0.1s;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Inherit color/border от desktop-правила — там background #2563eb */
  }
  body:not(.admin-app):not(.studio) #ptt-button::before {
    content: "🎙";
    font-size: 36px;
    line-height: 1;
    display: block;
  }
  /* active state: PTT удерживается → визуально «нажат» */
  body:not(.admin-app):not(.studio) #ptt-button:active,
  body:not(.admin-app):not(.studio) #ptt-button.recording {
    transform: translateY(-50%) scale(0.92);
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.6);
    background: #dc2626;
  }
  body:not(.admin-app):not(.studio) #ptt-button:active::before,
  body:not(.admin-app):not(.studio) #ptt-button.recording::before {
    content: "⏺";
  }

  /* Continuous-button — те же rules с поднятой специфичностью */
  body:not(.admin-app):not(.studio) #continuous-button:not([hidden]) {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    z-index: 50;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    font-size: 0;
    line-height: 0;
    padding: 0;
    margin: 0;
    box-shadow: 0 8px 24px rgba(22, 163, 74, 0.45);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  body:not(.admin-app):not(.studio) #continuous-button::before {
    content: "▶";
    font-size: 32px;
    line-height: 1;
    display: block;
    color: white;
  }
  body:not(.admin-app):not(.studio) #continuous-button[data-state="listening"]::before { content: "🎙"; }
  body:not(.admin-app):not(.studio) #continuous-button[data-state="paused"]::before    { content: "⏸"; }

  /* КРИТИЧНО: #controls сам по себе НЕ display:none — иначе дочерние
     position:fixed элементы (PTT, continuous) тоже не отрисуются.
     Делаем контейнер «прозрачным» — нулевая высота, без флекс-флоу.
     После _moveFABsToFloating() кнопки переехали отсюда, но даже если
     не отработал JS — overflow:visible не клипает их.
     Специфичность как у строки 1840 (body:not()#controls). */
  body:not(.admin-app):not(.studio) #controls {
    display: block;
    height: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    overflow: visible;
    gap: 0;       /* перебиваем gap: 8px от desktop-правила */
  }

  /* ── 5. Control-bar превращается в bottom-sheet drawer ── */
  .control-bar {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    max-height: 82vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--color-surface, white);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.22);
    padding: 20px 16px 28px;
    z-index: 90;
    transform: translateY(102%);   /* спрятан по умолчанию */
    transition: transform 0.28s cubic-bezier(.4,.0,.2,1);
    /* Drag-handle сверху */
  }
  .control-bar::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #cbd5e1;
  }
  body.mobile-drawer-open .control-bar {
    transform: translateY(0);
  }

  /* Backdrop за drawer'ом */
  #mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 80;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
  }
  body.mobile-drawer-open #mobile-drawer-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  /* Внутри drawer: текстовый ввод сам по себе hidden до клика —
     остаётся так. Mode-toggle, ambient, end-session — видны вертикально. */
  #text-input-container {
    margin-top: 12px;
  }
  #input-mode-toggle {
    display: block;
    margin-top: 14px;
    padding: 12px;
    text-align: center;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
  }
  /* Если показывается status-bar в drawer — тоже компактно */
  body.mobile-drawer-open #status-bar {
    /* остаётся как было */
  }

  /* Прячем технические блоки на mobile (отчёт-summary, hints, timings) */
  #report-summary,
  #asr-hint,
  #timings {
    /* отображаются только если активны — не трогаем visibility */
  }

  /* ── 6. PEARLS-debrief modal: занимает весь экран ─────────── */
  #debrief-modal .modal-card {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    margin: 0;
  }
}


/* ══════════════════════════════════════════════════════════════════
   M5: Mobile bottom-sheet declutter + reorder (≤ 600px)
   ══════════════════════════════════════════════════════════════════
   Lang-switcher is locked at session start → dead weight in-session.
   Reorder: progress bar → text-input toggle → session group.
   Desktop (> 600px) is UNCHANGED — all rules are media-guarded.
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  /* ── 1. Hide the in-session lang-switcher from the drawer ──────
     Also hide the whole .mobile-drawer-extras strip (it only contained
     lang-switcher + user-chip email/logout — both irrelevant in-session).
     #user-chip-results ("Мои результаты") is moved by JS into
     #session-group, so the extras block becomes empty anyway. */
  .mobile-drawer-extras {
    display: none !important;
  }

  /* ── 2. Reorder .control-bar flex children on mobile ──────────
     .control-bar is already display:flex; flex-direction:column.
     Assign explicit order to pin the three visible sections.
     Items without an explicit order: default 0, so they sort
     before order:1 — give them a high order to push to the bottom. */
  #status-bar          { order: 1; }
  #input-mode-toggle   { order: 2; }
  #session-group       { order: 3; }

  /* Push everything else that's not hidden below the session group */
  #controls,
  #text-input-container,
  #asr-hint,
  #timings,
  #report-summary      { order: 10; }

  /* ── 3. Style #user-chip-results inside #session-group ────────
     JS moves this link out of #user-chip into the session group.
     Make it look like the secondary session buttons (Заново / Вернуться). */
  #session-group #user-chip-results {
    display: block;
    width: 100%;
    padding: 9px;
    font-size: 13px;
    text-align: center;
    background: #1a2332;
    border: 1px solid #2a3444;
    border-radius: 9px;
    color: #c0cfdc;
    text-decoration: none;
    box-sizing: border-box;
    cursor: pointer;
  }
  #session-group #user-chip-results:hover {
    background: #243245;
    color: #e2eaf3;
  }

  /* ── M2: Mobile coach hint panel ──────────────────────────────
     Fills the empty bottom area below the stage, above the FAB.
     On desktop this element is display:none (see global rule above).
     On mobile it becomes a dark-blue bar showing the latest hint. */
  #mobile-coach-panel {
    display: flex;
    flex: 1 1 auto;   /* FIX1: grow to fill remaining height in main column */
    align-items: center;
    justify-content: center;
    background: #0E2841;
    color: #fff;
    padding: 14px 16px;
    min-height: 22vh;  /* floor so it's never invisibly thin */
    border-top: 4px solid transparent;
    text-align: center;
    font-size: 15px;
    line-height: 1.4;
    box-sizing: border-box;
    width: 100%;
  }
  #mobile-coach-panel.is-empty .mobile-coach-panel__hint { opacity: .4; }
  /* Band accent colours — match coach-bubble--<band> colours */
  #mobile-coach-panel.band-ambient  { border-top-color: #2196F3; }
  #mobile-coach-panel.band-active   { border-top-color: #ff9800; }
  #mobile-coach-panel.band-critical { border-top-color: #f44336; }
}

/* ──────────────────────────────────────────────────────────────────
   Подробный mobile (≤ 480px) — очень узкие экраны
   ────────────────────────────────────────────────────────────────── */
/* Trigger toast container: на mobile опускаем ниже шапки чтобы не
   перекрывал «Виртуальный пациент» / таймер / hamburger. */
@media (max-width: 768px) {
  #trigger-toasts {
    top: 60px !important;
    right: 8px !important;
    left: 8px !important;
    max-width: none !important;
  }
}

@media (max-width: 480px) {
  .header-title h1 { font-size: 13px; }
  #patient-info { display: none; }   /* совсем не помещается */
  body:not(.admin-app):not(.studio) #ptt-button,
  body:not(.admin-app):not(.studio) #continuous-button:not([hidden]) {
    width: 76px;
    height: 76px;
  }
  body:not(.admin-app):not(.studio) #ptt-button::before { font-size: 32px; }
  body:not(.admin-app):not(.studio) #continuous-button::before { font-size: 28px; }
}


/* ──────────────────────────────────────────────────────────────────
   Landscape phone (низкий viewport) — даём аватар горизонтально
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  body:not(.admin-app):not(.studio) main {
    padding: 4px 0 12px 0;
  }
  .stage { aspect-ratio: 16 / 9; }
  /* В landscape сделаем FAB чуть меньше и поднимем выше */
  body:not(.admin-app):not(.studio) #ptt-button,
  body:not(.admin-app):not(.studio) #continuous-button:not([hidden]) {
    width: 64px;
    height: 64px;
    top: 50%;
    right: 16px;
  }
  body:not(.admin-app):not(.studio) #ptt-button::before { font-size: 26px; }
  body:not(.admin-app):not(.studio) #continuous-button::before { font-size: 22px; }
}

/* Utility: aggressive break для технических строк (UUID, slug, email) */
.break-anywhere {
    overflow-wrap: anywhere;
    word-break: break-word;   /* fallback для старых браузеров */
}

/* Iter 3 TASK-013: destructive button variant для разрушительных действий */
.btn-destructive {
  border: 1.5px solid var(--color-danger);
  color: var(--color-danger);
  background: transparent;
  font-weight: 500;
  transition: background var(--t-base), color var(--t-base);
}
.btn-destructive:hover,
.btn-destructive:focus-visible {
  background: var(--color-danger);
  color: white;
}

/* Iter 3 TASK-013: custom confirm modal — reusable */
.modal-confirm {
  max-width: 420px;
  padding: var(--sp-6);
}
.modal-confirm h3 {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-lg);
}
.modal-confirm p {
  margin: 0 0 var(--sp-5);
  color: var(--color-text);
  line-height: 1.5;
  white-space: pre-line;
}
.modal-confirm .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

/* Iter 3 TASK-015: visible linear progress bar для briefing 30s timer.
   До этой задачи был только text countdown ("Автостарт через 30 с") —
   пользователь не видел сколько осталось визуально. Полоса заполняется
   слева направо (fill shrinks с 100% → 0%), цвет меняется на пороге:
   primary >10s → warning 10-5s → danger ≤5s. */
.briefing-progress-track {
  flex-basis: 100%;
  width: 100%;
  height: 4px;
  background: var(--color-surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: var(--sp-2);
  order: 99;
}
.briefing-progress-fill {
  height: 100%;
  width: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 1s linear, background var(--t-base);
}
.briefing-progress-fill.warning {
  background: var(--color-warning);
}
.briefing-progress-fill.danger {
  background: var(--color-danger);
}

/* Iter 4 TASK-027: InlineAlert reusable component */
.inline-alert {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: var(--fs-sm);
  line-height: 1.4;
  margin: var(--sp-3) 0;
}
.inline-alert-icon {
  font-size: 1.2em;
  flex-shrink: 0;
}
.inline-alert-message {
  flex: 1;
}
.inline-alert-action {
  flex-shrink: 0;
  padding: 4px 12px;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-base), color var(--t-base);
}
.inline-alert-action:hover,
.inline-alert-action:focus-visible {
  background: currentColor;
  color: white;
}
/* Variants */
.inline-alert-info {
  background: rgba(21,96,130,0.08);
  border-left-color: var(--color-primary);
  color: var(--color-primary);
}
.inline-alert-warning {
  background: var(--color-warning-bg);
  border-left-color: var(--color-warning);
  color: var(--color-warning);
}
.inline-alert-error {
  background: var(--color-danger-bg);
  border-left-color: var(--color-danger);
  color: var(--color-danger);
}

/* ── ClinTalk wordmark (header H1) ─────────────────────────────── */
.brand-mark { display: inline-flex; align-items: flex-start; font-weight: 800; letter-spacing: .2px; }
.brand-mark .brand-clin { font-weight: 600; }
.brand-mark .brand-talk { color: var(--color-brand-accent); font-weight: 800; }
.brand-mark .brand-ai { font-size: .5em; vertical-align: super; color: var(--color-brand-accent); font-weight: 800; margin-left: 1px; }
a.site-home-logo { text-decoration: none; color: inherit; opacity: .85; transition: opacity .15s; flex-shrink: 0; }
a.site-home-logo:hover { opacity: 1; }

/* Language selector is hidden during an active session (it is disabled on
   session_started and re-enabled at report-ready — ride that lock). */
#lang-switcher:disabled { display: none; }

/* ── Stage loading splash (style C: cabinet skeleton + shimmer) ── */
.stage-loader {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 50% 30%, #16324a 0%, #0c1722 70%);
  overflow: hidden;
}
.stage-loader[hidden] { display: none; }
.stage-loader-skeleton {
  position: absolute; inset: 0; opacity: .7;
  background:
    linear-gradient(#1b2c3e,#1b2c3e) 0 0/100% 38% no-repeat,
    linear-gradient(#22384e,#22384e) 18% 60%/26% 40% no-repeat,
    linear-gradient(#22384e,#22384e) 56% 55%/30% 45% no-repeat;
}
.stage-loader-sweep {
  position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.10) 50%, transparent 70%);
  animation: stage-loader-sweep 1.6s ease-in-out infinite;
}
@keyframes stage-loader-sweep { to { transform: translateX(100%); } }
.stage-loader-bar {
  position: absolute; left: 24px; right: 24px; bottom: 20px; height: 4px;
  border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden;
}
.stage-loader-bar::after {
  content: ""; position: absolute; top: 0; left: -40%; height: 100%; width: 40%;
  border-radius: 3px; background: var(--color-brand-accent);
  animation: stage-loader-bar 1.4s ease-in-out infinite;
}
@keyframes stage-loader-bar { to { left: 100%; } }
.stage-loader-caption {
  position: absolute; bottom: 8px; width: 100%; text-align: center;
  font-size: 12px; color: #acc4d6; z-index: 2;
}
@media (prefers-reduced-motion: reduce) {
  .stage-loader-sweep, .stage-loader-bar::after { animation: none; }
}
/* Picker pre-flight session settings (light modal) */
.picker-setting-row { display: flex; align-items: center; gap: 8px; margin-top: 7px; cursor: pointer; font-size: var(--fs-sm); }
.picker-setting-row input { cursor: pointer; }

/* ─── B+D T10: режим сессии (Обучение / Экзамен) ─────────────────── */
.picker-mode-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.picker-mode-row .picker-mode-label {
  font-weight: 600;
}
.picker-mode-toggle {
  display: inline-flex;
  border-radius: 0.375rem;
  overflow: hidden;
  border: 1px solid #ccc;
}
.picker-mode-btn {
  padding: 0.25rem 0.75rem;
  background: #f5f5f5;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 150ms, color 150ms;
}
.picker-mode-btn.active {
  background: #2c5282;
  color: white;
}
.picker-mode-hint {
  color: #666;
  font-size: 0.85rem;
}
/* Обратный отсчёт: предупреждения на таймере */
#session-timer.timer-warning {
  color: #d54;
  font-weight: bold;
}
#session-timer.timer-expired {
  color: #c00;
}
/* Блокировка ввода по истечении времени */
.exam-timed-out .input-area,
.exam-timed-out [data-i18n="ui.btn.ptt_hold"] {
  pointer-events: none;
  opacity: 0.5;
}

/* ════════════════════════════════════════════════════════════════
   C2 — Ambient UI for Coach Hints
   See docs/superpowers/specs/2026-05-27-c2-ambient-ui-design.md §3-§4
   ════════════════════════════════════════════════════════════════ */

/* ── Bubble host (inside #stage) ── */
.coach-bubble-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.coach-bubble-host[hidden] { display: none; }

/* ── Bubble ── */
.coach-bubble {
  position: absolute;
  top: 20px;
  right: 20px;
  max-width: var(--coach-bubble-maxw, 280px);
  background: white;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-size: var(--coach-bubble-fs, 14px);
  line-height: 1.4;
  transform: translateY(-12px);
  opacity: 0;
  transition: transform 220ms ease-out, opacity 200ms ease-out;
  z-index: 200;
  pointer-events: auto;
  font-family: inherit;
  color: #1a1a1a;
}
.coach-bubble--visible {
  transform: translateY(0);
  opacity: 1;
}

.coach-bubble-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #555;
  font-weight: 600;
}
.coach-bubble-icon { font-size: 14px; }
.coach-bubble-label {
  flex: 1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.coach-bubble-dismiss {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 14px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: -10px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 4px;
}
.coach-bubble-dismiss:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.05);
}
.coach-bubble-dismiss:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}
.coach-bubble-message {
  font-size: 14px;
  line-height: 1.4;
  color: #1a1a1a;
}
.coach-bubble-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgba(33, 150, 243, 0.5);
  transform-origin: left center;
  transform: scaleX(1);
  transition-property: transform;
  transition-timing-function: linear;
  border-radius: 0 0 14px 14px;
}

/* Band variants */
.coach-bubble--ambient  { border-left: 3px solid var(--coach-color-ambient, #2196F3); }
.coach-bubble--ambient .coach-bubble-label  { color: #1565c0; }

.coach-bubble--active   { border-left: 3px solid var(--coach-color-active, #ff9800); }
.coach-bubble--active .coach-bubble-label   { color: #e65100; }
.coach-bubble--active .coach-bubble-progress { background: rgba(255, 152, 0, 0.5); }

.coach-bubble--critical {
  border-left: 3px solid var(--coach-color-critical, #f44336);
  box-shadow: 0 4px 18px rgba(244, 67, 54, 0.30);
  animation: coach-pulse 1.4s ease-in-out 1;
}
.coach-bubble--critical .coach-bubble-label { color: #b71c1c; }
.coach-bubble--critical .coach-bubble-progress { background: rgba(244, 67, 54, 0.6); }

@keyframes coach-pulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(244, 67, 54, 0.30); }
  50%      { box-shadow: 0 6px 24px rgba(244, 67, 54, 0.55); }
}

/* ── History toggle button (floating) ── */
.coach-history-toggle {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2196F3;
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
}
.coach-history-toggle[hidden] { display: none; }
.coach-history-toggle:hover { background: #1976D2; }
.coach-history-toggle:focus-visible {
  outline: 3px solid rgba(33, 150, 243, 0.5);
  outline-offset: 2px;
}
.coach-history-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff5722;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border: 2px solid white;
  box-sizing: content-box;
}
.coach-history-count[hidden] { display: none; }

/* ── History panel ── */
.coach-history {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 320px;
  max-width: 90vw;
  background: white;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
  z-index: 250;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 240ms ease-out;
  font-family: inherit;
}
.coach-history[hidden] { display: none; }
.coach-history[data-open="true"] { transform: translateX(0); }

.coach-history-head {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #e0e0e0;
}
.coach-history-head h2 {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1565c0;
}
.coach-history-close {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 16px;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: -10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.coach-history-close:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.05);
}
.coach-history-close:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 1px;
}

.coach-history-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 8px 0;
  list-style: none;
}

.coach-history-entry {
  padding: 10px 16px;
  border-bottom: 1px solid #f0f0f0;
  border-left: 3px solid transparent;
}
.coach-history-entry--ambient  { border-left-color: #2196F3; }
.coach-history-entry--active   { border-left-color: #ff9800; }
.coach-history-entry--critical { border-left-color: #f44336; }

.coach-history-entry-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  color: #555;
}
.coach-history-entry-icon { font-size: 13px; }
.coach-history-entry-label {
  flex: 1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.coach-history-entry-time {
  font-variant-numeric: tabular-nums;
  color: #666;
}
.coach-history-entry-message {
  font-size: 13px;
  line-height: 1.4;
  color: #1a1a1a;
}

.coach-history-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

/* ── Picker coach toggle (in mode-row) ── */
.picker-coach-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  user-select: none;
}
.picker-coach-toggle[hidden] { display: none; }
.picker-coach-toggle input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  width: 16px;
  height: 16px;
}
.picker-coach-toggle:hover { color: #1565c0; }

/* ── Mobile responsive ── */
@media (max-width: 640px) {
  .coach-history { width: 100vw; }
  .coach-history-toggle {
    bottom: 70px;
    right: 12px;
    width: 44px;
    height: 44px;
  }
  .coach-bubble {
    max-width: calc(100vw - 40px);
  }
}

/* ── prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  .coach-bubble { transition: opacity 0ms; transform: none; }
  .coach-bubble--critical { animation: none; }
  .coach-history { transition: transform 0ms; }
  .coach-bubble-progress { display: none; }
}

/* ════════════════════════════════════════════════════════════════
   C6 — Tutor Feedback Loop
   See docs/superpowers/specs/2026-05-27-c6-tutor-feedback-design.md §5
   ════════════════════════════════════════════════════════════════ */

/* ── Session list badge ── */
.coach-review-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  line-height: 1.4;
}
.coach-review-badge--done    { background: #e8f5e9; color: #1b5e20; }
.coach-review-badge--partial { background: #fff3e0; color: #e65100; }

/* ── Coach activity section ── */
.coach-feedback-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}
.coach-feedback-section[hidden] { display: none; }
.coach-feedback-section > h2 {
  font-size: 18px;
  font-weight: 600;
  color: #1565c0;
  margin: 0 0 12px 0;
}

.coach-feedback-empty {
  color: #888;
  font-size: 14px;
  padding: 16px;
  text-align: center;
  font-style: italic;
}
.coach-feedback-empty[hidden] { display: none; }

.coach-feedback-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Per-entry item ── */
.coach-feedback-item {
  background: #fafafa;
  border-radius: 8px;
  padding: 12px 16px;
  border-left: 3px solid #e0e0e0;
}

.coach-feedback-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
}
.coach-feedback-item-icon { font-size: 16px; }
.coach-feedback-item-category {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.coach-feedback-item-band {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
}
.coach-feedback-item-band--ambient  { background: #e3f2fd; color: #1565c0; }
.coach-feedback-item-band--active   { background: #fff3e0; color: #e65100; }
.coach-feedback-item-band--critical { background: #ffebee; color: #b71c1c; }

.coach-feedback-item-time {
  margin-left: auto;
  color: #999;
  font-variant-numeric: tabular-nums;
}

.coach-feedback-item-message {
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a1a;
  margin: 0 0 8px 0;
  padding-left: 12px;
  border-left: 2px solid #2196F3;
  font-style: italic;
}

.coach-feedback-item-context {
  margin-bottom: 8px;
  font-size: 12px;
}
.coach-feedback-item-context > summary {
  cursor: pointer;
  color: #1565c0;
  user-select: none;
}
.coach-feedback-item-reasoning {
  margin-top: 6px;
  padding: 8px;
  background: #f0f4f7;
  border-radius: 4px;
  font-size: 12px;
  color: #555;
}

/* ── Feedback controls ── */
.coach-feedback-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.coach-feedback-btn {
  min-width: 44px;
  min-height: 44px;
  border: 2px solid #e0e0e0;
  background: white;
  color: #555;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms, border-color 150ms, transform 80ms;
}
.coach-feedback-btn:hover {
  background: #f5f5f5;
  border-color: #b0b0b0;
}
.coach-feedback-btn:active { transform: scale(0.95); }
.coach-feedback-btn:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}
.coach-feedback-btn--active {
  background: #e8f5e9;
  border-color: #43a047;
  color: #2e7d32;
}
.coach-feedback-btn--not-helpful.coach-feedback-btn--active {
  background: #ffebee;
  border-color: #e53935;
  color: #c62828;
}
.coach-feedback-btn--unclear.coach-feedback-btn--active {
  background: #fff3e0;
  border-color: #fb8c00;
  color: #e65100;
}
.coach-feedback-btn--inactive {
  opacity: 0.4;
}

.coach-feedback-clear {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 16px;
  border-radius: 4px;
}
.coach-feedback-clear:hover { background: rgba(0,0,0,0.05); color: #333; }
.coach-feedback-clear:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 1px;
}
.coach-feedback-clear[hidden] { display: none; }

.coach-feedback-comment {
  flex: 1 1 200px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.coach-feedback-comment[hidden] { display: none; }
.coach-feedback-comment:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 1px;
  border-color: transparent;
}

.coach-feedback-status {
  font-size: 12px;
  color: #666;
  font-style: italic;
}
.coach-feedback-status[hidden] { display: none; }

/* ── Mobile responsive ── */
@media (max-width: 640px) {
  .coach-feedback-controls { flex-wrap: wrap; }
  .coach-feedback-comment { width: 100%; }
}

/* ── prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  .coach-feedback-btn { transition: none; }
}

/* ═══════════════════════════════════════════════════════
   Tutorial / Onboarding  —  Option Б: CSS-hole spotlight + bottom card
   ═══════════════════════════════════════════════════════ */

/* ── Overlay with radial-gradient "hole" ── */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  background: radial-gradient(
    ellipse var(--tutorial-spot-w, 1px) var(--tutorial-spot-h, 1px)
    at var(--tutorial-spot-x, 50%) var(--tutorial-spot-y, 50%),
    transparent 100%,
    rgba(0, 0, 0, 0.72) calc(100% + 2px)
  );
  opacity: 0;
  transition: opacity 0.3s ease, background 0.35s ease;
}
#tutorial-overlay.active            { opacity: 1; }
#tutorial-overlay.tutorial-no-spot  {
  background: rgba(0, 0, 0, 0.65);
  transition: opacity 0.3s ease;
}

/* ── Floating card 560px. Positioned via translateY (% = own height) so the
   top↔bottom flip animates smoothly when a target sits in the bottom half. ── */
#tutorial-card {
  position: fixed;
  top: 0;
  left: 50%;
  /* default: bottom — own-height-aware translate keeps a 20px gap */
  transform: translateX(-50%) translateY(calc(100vh - 100% - 20px));
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  width: 560px;
  max-width: calc(100vw - 32px);
  z-index: 201;
  display: flex;
  flex-direction: row;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  pointer-events: auto;
}

/* hidden обязан перебивать display:flex (id-специфичность), иначе card.hidden
   не скрывает карточку → не закрывается по «Завершить»/✕ и перекрывает кнопки. */
#tutorial-card[hidden] { display: none; }

/* target в нижней половине → карточка наверх (не перекрывает кнопки внизу) */
#tutorial-card.tutorial-card--top {
  transform: translateX(-50%) translateY(20px);
}

/* ── Mentor column (left): inline SVG, no WebGL ── */
#tutorial-card-avatar {
  width: 132px;
  flex-shrink: 0;
  background: var(--color-surface-2);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#tutorial-mentor {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#tutorial-mentor svg {
  width: 100%;
  height: auto;
  max-height: 188px;
  display: block;
}

/* лёгкое «дыхание» в покое */
#tutorial-mentor-svg {
  animation: mentor-breathe 4s ease-in-out infinite;
}
@keyframes mentor-breathe {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

/* губы открываются/закрываются пока играет TTS.
   fill-box + center: масштаб вокруг центра bbox самого рта (иначе при view-box
   origin scaleY пивотит по неверной точке и рот «летает» по лицу). */
#mentor-mouth {
  transform-box: fill-box;
  transform-origin: center;
}
#tutorial-mentor-svg.speaking #mentor-mouth {
  animation: mentor-talk 0.26s ease-in-out infinite;
}
@keyframes mentor-talk {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(1.7); }
}

/* Session phase: patient avatar IS already on screen — hide card's mentor col */
#tutorial-card.session-phase #tutorial-card-avatar { display: none; }

/* ── Content column (right) ── */
#tutorial-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-5);
  min-width: 0;
  position: relative;
}

.tutorial-skip-btn {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}
.tutorial-skip-btn:hover { color: var(--color-text); }

#tutorial-step-text {
  margin: 0 28px 0 0;
  padding-top: var(--sp-1);
  line-height: 1.6;
  color: var(--color-text);
  font-size: 15px;
  flex: 1;
}

#tutorial-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-4);
  gap: var(--sp-3);
}

#tutorial-progress {
  font-size: 12px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.tutorial-nav { display: flex; gap: var(--sp-2); }

.btn-sm {
  padding: 5px 14px;
  font-size: 13px;
}

/* ── Highlight ring on targeted element ── */
.tutorial-highlight {
  outline: 3px solid var(--color-primary);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
  animation: tutorial-pulse 1.6s ease-in-out infinite;
}

@keyframes tutorial-pulse {
  0%, 100% { outline-color: var(--color-primary); outline-offset: 4px; }
  50%       { outline-color: var(--color-primary-hover); outline-offset: 7px; }
}

/* Демо-отчёт в туре: поднимаем #report-view (обычно z80) над модалкой
   дебрифинга (z100), но ниже карточки тура (z201), чтобы пример был виден
   чисто, а не за размытым backdrop модалки. */
#report-view.tutorial-demo-active { z-index: 150; }

/* ── Вкладка «Расскажи мне как учиться» — на всех страницах у правого края.
   writing-mode: vertical-rl + rotate(180deg) → текст снизу вверх (начало внизу),
   бокс прижат к правому краю и по центру. Скрыта на экране активной сессии. ── */
.howto-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  white-space: nowrap;          /* одна вертикальная строка, без переноса на колонки */
  z-index: 60;
  background: #0284c7;
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 16px 10px;
  border-radius: 0 10px 10px 0;
  box-shadow: -2px 0 10px rgba(2, 132, 199, 0.35);
  cursor: pointer;
  transition: background 150ms ease;
}
.howto-tab:hover { background: #0369a1; }
body.session-active .howto-tab { display: none; }   /* прячем во время сессии */
@media (prefers-reduced-motion: reduce) { .howto-tab { transition: none; } }

/* Поповер-меню вкладки: «Пройти тур» / «Справка». Появляется слева от таба. */
.howto-menu {
  position: fixed;
  right: 48px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 61;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e4ea);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.howto-menu[hidden] { display: none; }
.howto-menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; text-decoration: none;
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--color-text, #1a2332);
  padding: 13px 18px;
  border-bottom: 1px solid var(--color-border-light, #f0f0f0);
}
.howto-menu-item:last-child { border-bottom: none; }
.howto-menu-item:hover { background: var(--color-hover, #f0f4fa); color: var(--color-primary, #156082); }
body.session-active .howto-menu { display: none; }

/* ── Справка как модальный оверлей (help-overlay.js) ── */
.help-modal-overlay {
  position: fixed; inset: 0; z-index: 240;
  background: rgba(15, 30, 50, 0.55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: help-modal-fade 0.2s ease;
}
.help-modal-overlay[hidden] { display: none; }
@keyframes help-modal-fade { from { opacity: 0; } to { opacity: 1; } }
.help-modal {
  position: relative; width: 100%; max-width: 740px; max-height: 88vh;
  background: var(--color-bg, #f5f7fa);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  animation: help-modal-rise 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes help-modal-rise { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.help-modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-surface, #fff); border: 1px solid var(--color-border, #e0e4ea);
  color: var(--color-text-muted, #6c7d8e); font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.help-modal-close:hover { background: var(--color-hover, #f0f4fa); color: var(--color-text, #1a2332); }
.help-modal-scroll { max-height: 88vh; overflow-y: auto; padding: 36px 32px 40px; }
.help-modal-scroll h1 { font-size: 22px; font-weight: 700; margin: 0 0 12px 0; padding-right: 36px; }

/* Контент справки (используется и на /help, и в оверлее) */
.help-modal-scroll .help-intro {
  font-size: 15px; color: var(--color-text-muted, #6c7d8e); line-height: 1.65;
  margin: 0 0 24px 0; padding: 16px 20px; background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e4ea); border-radius: 8px;
}
.help-tour-cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: #0284c7; color: #fff; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; padding: 12px 20px; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(2,132,199,0.3); margin: 0 0 28px 0;
  transition: background 150ms ease, transform 150ms ease;
}
.help-tour-cta::before { content: "🎓"; font-size: 16px; }
.help-tour-cta:hover { background: #0369a1; transform: translateY(-1px); }
.help-stages-title { font-size: 18px; font-weight: 700; margin: 0 0 6px 0; }
.help-stages-hint { font-size: 13px; color: var(--color-text-muted, #6c7d8e); margin: 0 0 16px 0; }
.help-stages { list-style: none; margin: 0 0 28px 0; padding: 0; }
.help-stage, .help-ref {
  background: var(--color-surface, #fff); border: 1px solid var(--color-border, #e0e4ea);
  border-radius: 10px; margin-bottom: 10px; overflow: hidden;
}
.help-ref.teacher { background: var(--color-bg-subtle, #f0f4fa); }
.help-ref.teacher .help-collapse-title { color: var(--color-primary, #2563eb); }
.help-collapse-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 16px 18px; font-family: inherit; color: var(--color-text, #1a2332);
}
.help-collapse-head:hover { background: var(--color-hover, #f6f9fc); }
.help-stage-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--color-primary, #156082); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.help-collapse-title { flex: 1; font-size: 15px; font-weight: 600; }
.help-chevron { flex-shrink: 0; color: var(--color-text-muted, #9bb0c5); font-size: 12px; transition: transform 180ms ease; }
.help-collapse-head[aria-expanded="true"] .help-chevron { transform: rotate(90deg); }
.help-collapse-body { padding: 0 18px 18px 56px; }
.help-collapse-body.ref { padding-left: 18px; }
.help-collapse-body p { font-size: 14px; line-height: 1.65; margin: 0 0 10px 0; }
.help-collapse-body .lbl {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-primary, #156082); margin: 12px 0 2px 0;
}
.help-collapse-body ul { margin: 4px 0 0 0; padding: 0; list-style: none; }
.help-collapse-body li {
  font-size: 14px; line-height: 1.6; padding: 5px 0 5px 18px; position: relative;
  border-bottom: 1px solid var(--color-border-light, #f0f0f0);
}
.help-collapse-body li:last-child { border-bottom: none; }
.help-collapse-body li::before { content: "—"; position: absolute; left: 0; color: var(--color-text-muted, #9bb0c5); }
.help-stage-link { display: inline-block; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--color-primary, #156082); text-decoration: none; }
.help-stage-link:hover { text-decoration: underline; }
@media (max-width: 600px) {
  .help-modal-scroll { padding: 28px 18px 32px; }
  .help-collapse-body { padding-left: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .help-modal-overlay, .help-modal { animation: none; }
}

/* ── Confetti layer ── */
#tutorial-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 202;
  overflow: hidden;
}
.tutorial-confetti-piece {
  position: absolute;
  top: -10px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ── Mobile: bottom sheet (flush) with same top/bottom flip ── */
@media (max-width: 600px) {
  #tutorial-card {
    flex-direction: row;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateX(-50%) translateY(calc(100vh - 100%));
  }
  #tutorial-card.tutorial-card--top {
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    transform: translateX(-50%) translateY(0);
  }
  #tutorial-card-avatar { width: 96px; }
  #tutorial-mentor svg  { max-height: 150px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .tutorial-highlight      { animation: none; }
  #tutorial-overlay        { transition: none; }
  #tutorial-card           { transition: none; }
  .tutorial-confetti-piece { animation: none; }
  #tutorial-mentor-svg     { animation: none; }
  #tutorial-mentor-svg.speaking #mentor-mouth { animation: none; }
}

/* ─ Communication guide cards ─ */
/* Карточный пошаговый урок «Начало коммуникации» (/didactics).
   Стеклянный скин под хаб: glass-поверхности + блюр-орбы.
   Светлая/тёмная темы синхронизированы со всем приложением через
   localStorage-ключ "vp_hub_theme" (как хаб и профиль). База = тёмная;
   светлая — оверрайд под классом .profile-light на <html> (тот же класс,
   что и страница профиля). Default = OS (head-скрипт в didactics.html).
   Все токены и атмосфера scoped к body.didactics-page — глобальные
   --color-* и другие страницы не трогаем. */

/* ── Тема-токены гайда: тёмная база (нет класса .profile-light = тёмная) ── */
body.didactics-page {
  --cg-page-bg:
    radial-gradient(120% 80% at 50% -10%, rgba(56,189,248,.10), transparent 60%),
    radial-gradient(90% 60% at 85% 110%, rgba(99,102,241,.08), transparent 60%),
    #050d1a;
  --cg-text:#e2e8f0; --cg-text-muted:#94a3b8;
  --cg-glass-bg:rgba(125,170,225,.06); --cg-glass-bd:rgba(125,211,252,.16); --cg-glass-bd-soft:rgba(125,211,252,.14);
  --cg-glass-shadow:inset 0 1px 1px rgba(199,211,234,.14), inset 0 28px 56px rgba(56,189,248,.05), 0 24px 40px rgba(5,6,15,.5);
  --cg-accent:#38bdf8; --cg-accent-contrast:#04253a;
  --cg-progress-track:rgba(125,211,252,.14);
  --cg-choice-bg:rgba(125,170,225,.05); --cg-choice-sel-bg:rgba(56,189,248,.16);
  --cg-patient-bg:rgba(125,170,225,.09); --cg-badge-bg:rgba(56,189,248,.12);
  --cg-orb-opacity:.45; --cg-orb-1:rgba(56,189,248,.38); --cg-orb-2:rgba(99,102,241,.32); --cg-orb-3:rgba(45,212,191,.26); --cg-grid:rgba(125,211,252,.05);
  --cg-fb2-bg:rgba(34,197,94,.15); --cg-fb2-bd:rgba(34,197,94,.32);
  --cg-fb1-bg:rgba(245,158,11,.15); --cg-fb1-bd:rgba(245,158,11,.32);
  --cg-fb0-bg:rgba(239,68,68,.16);  --cg-fb0-bd:rgba(239,68,68,.34);
  --cg-sign-2:#5be39a; --cg-sign-1:#fcd34d; --cg-sign-0:#fca5a5;
}
/* Светлая тема — оверрайд под общим классом .profile-light на <html>
   (тот же ключ vp_hub_theme и тот же класс, что у страницы профиля). */
html.profile-light body.didactics-page {
  --cg-page-bg:
    radial-gradient(120% 80% at 50% -10%, rgba(56,189,248,.20), transparent 60%),
    radial-gradient(90% 60% at 85% 110%, rgba(99,102,241,.14), transparent 60%),
    #eaf1fb;
  --cg-text:#16263a; --cg-text-muted:#51637a;
  --cg-glass-bg:rgba(255,255,255,.58); --cg-glass-bd:rgba(255,255,255,.75); --cg-glass-bd-soft:rgba(120,150,190,.24);
  --cg-glass-shadow:0 12px 32px rgba(30,58,90,.10), inset 0 1px 1px rgba(255,255,255,.7);
  --cg-accent:#0284c7; --cg-accent-contrast:#ffffff;
  --cg-progress-track:rgba(20,45,75,.12);
  --cg-choice-bg:rgba(255,255,255,.52); --cg-choice-sel-bg:rgba(2,132,199,.13);
  --cg-patient-bg:rgba(255,255,255,.5); --cg-badge-bg:rgba(2,132,199,.10);
  --cg-orb-opacity:.55; --cg-orb-1:rgba(56,189,248,.45); --cg-orb-2:rgba(99,102,241,.34); --cg-orb-3:rgba(45,212,191,.30); --cg-grid:rgba(70,110,160,.06);
  --cg-fb2-bg:rgba(16,185,129,.13); --cg-fb2-bd:rgba(16,185,129,.32);
  --cg-fb1-bg:rgba(245,158,11,.14); --cg-fb1-bd:rgba(245,158,11,.34);
  --cg-fb0-bg:rgba(239,68,68,.12);  --cg-fb0-bd:rgba(239,68,68,.32);
  --cg-sign-2:#0a8f5b; --cg-sign-1:#b9760a; --cg-sign-0:#cf3636;
}

/* ── Атмосфера: блюр-орбы + сетка (fixed под контентом) ── */
.cg-atmos{ position:fixed; inset:0; z-index:0; pointer-events:none; overflow:hidden; }
.cg-orb{ position:absolute; border-radius:50%; -webkit-filter:blur(64px); filter:blur(64px); opacity:var(--cg-orb-opacity); }
.cg-orb-1{ width:46vw;height:46vw;left:-8vw;top:-6vw; background:radial-gradient(circle, var(--cg-orb-1), transparent 68%); animation:land-float-a 24s ease-in-out infinite; }
.cg-orb-2{ width:40vw;height:40vw;right:-6vw;top:24vh; background:radial-gradient(circle, var(--cg-orb-2), transparent 68%); animation:land-float-b 28s ease-in-out infinite; }
.cg-orb-3{ width:34vw;height:34vw;left:16vw;bottom:-10vw; background:radial-gradient(circle, var(--cg-orb-3), transparent 68%); animation:land-float-a 32s ease-in-out infinite reverse; }
.cg-grid{ position:absolute; inset:0; background-image:linear-gradient(var(--cg-grid) 1px,transparent 1px),linear-gradient(90deg,var(--cg-grid) 1px,transparent 1px); background-size:64px 64px; -webkit-mask:radial-gradient(ellipse 75% 70% at 50% 35%,#000 20%,transparent 78%); mask:radial-gradient(ellipse 75% 70% at 50% 35%,#000 20%,transparent 78%); }
@media (prefers-reduced-motion: reduce){ .cg-orb{ animation:none; } }

.cg-root {
  display: flex;
  justify-content: center;
}
.cg-wizard {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Хром: шаг-лейбл, закрытие, прогресс-бар */
.cg-chrome {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cg-chrome-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cg-step-label,
.cg-close {
  font-size: 13px;
  color: var(--cg-text-muted);
}
.cg-close {
  text-decoration: none;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
}
.cg-close:hover { color: var(--cg-text); }
.cg-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--cg-progress-track);
  overflow: hidden;
}
.cg-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--cg-accent);
  transition: width .3s ease;
}

/* Карточка — стеклянная поверхность */
.cg-card {
  background: var(--cg-glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
  backdrop-filter: blur(18px) saturate(125%);
  border: 1px solid var(--cg-glass-bd);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--cg-glass-shadow);
  color: var(--cg-text);
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* enter-анимация */
  opacity: 0;
  transform: translateY(8px);
}
.cg-card.is-in {
  opacity: 1;
  transform: none;
  transition: opacity .2s, transform .2s;
}
.cg-card:focus { outline: none; }

.cg-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--cg-text);
}
.cg-intro {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--cg-text-muted);
}

/* Обзор: список 6 навыков */
.cg-overview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cg-overview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--cg-text);
}
.cg-overview-row.is-done .cg-overview-title { color: var(--cg-text-muted); }
.cg-overview-mark {
  width: 16px;
  color: var(--cg-sign-2);
  font-weight: 700;
}
.cg-skill-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--color-primary, #2563eb);
}

/* Концепт: бейдж модели + Зачем/Как */
.cg-model-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--cg-badge-bg);
  color: var(--cg-accent);
}
.cg-concept { display: flex; flex-direction: column; gap: 4px; }
.cg-concept-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--cg-accent);
}
.cg-concept-body {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--cg-text);
}

/* Реплика пациента */
.cg-patient-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.cg-avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--cg-glass-bg);
  border: 1px solid var(--cg-glass-bd-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.cg-patient {
  background: var(--cg-patient-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--cg-glass-bd-soft);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--cg-text);
}
.cg-reply-label {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--cg-text-muted);
}

/* Варианты ответа */
.cg-choices { display: flex; flex-direction: column; gap: 10px; }
.cg-choice {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 52px;
  padding: 14px 16px;
  border: 1.5px solid var(--cg-glass-bd-soft);
  border-radius: 14px;
  background: var(--cg-choice-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--cg-text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cg-choice:hover:not([disabled]) { border-color: var(--cg-accent); }
.cg-choice.is-selected {
  border-width: 2px;
  border-color: var(--cg-accent);
  background: var(--cg-choice-sel-bg);
}
.cg-choice[disabled] { cursor: default; }

/* Разбор */
.cg-feedback {
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cg-feedback.score-2 { background: var(--cg-fb2-bg); border: 1px solid var(--cg-fb2-bd); }
.cg-feedback.score-1 { background: var(--cg-fb1-bg); border: 1px solid var(--cg-fb1-bd); }
.cg-feedback.score-0 { background: var(--cg-fb0-bg); border: 1px solid var(--cg-fb0-bd); }
.cg-outcome { font-weight: 700; font-size: 14.5px; line-height: 1.45; color: var(--cg-text); }
.cg-debrief { font-size: 13.5px; line-height: 1.55; color: var(--cg-text); }

/* Управление под разбором */
.cg-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Кнопки */
.cg-primary {
  align-self: flex-start;
  min-height: 48px;
  padding: 12px 22px;
  border: none;
  border-radius: 999px;
  background: var(--cg-accent);
  color: var(--cg-accent-contrast);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease;
}
.cg-primary:hover:not([disabled]) { filter: brightness(1.06); }
.cg-primary[disabled] { opacity: .5; cursor: default; }
.cg-cta { text-decoration: none; display: inline-flex; align-items: center; }
.cg-ghost {
  background: transparent;
  border: none;
  color: var(--cg-accent);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
}

/* Профиль навыков (финал) */
.cg-profile { display: flex; flex-direction: column; gap: 8px; }
.cg-profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--cg-text);
  padding: 8px 12px;
  border-radius: 12px;
}
.cg-profile-row.score-2 { background: var(--cg-fb2-bg); }
.cg-profile-row.score-1 { background: var(--cg-fb1-bg); }
.cg-profile-row.score-0 { background: var(--cg-fb0-bg); }
.cg-profile-sign { width: 18px; font-weight: 700; text-align: center; }
.cg-profile-row.score-2 .cg-profile-sign { color: var(--cg-sign-2); }
.cg-profile-row.score-1 .cg-profile-sign { color: var(--cg-sign-1); }
.cg-profile-row.score-0 .cg-profile-sign { color: var(--cg-sign-0); }
.cg-profile-title { flex: 1; }

/* Ошибка монтирования */
.cg-error { font-size: 14.5px; color: var(--cg-text-muted); }

/* Фокус */
.cg-choice:focus-visible,
.cg-primary:focus-visible,
.cg-ghost:focus-visible,
.cg-close:focus-visible {
  outline: 3px solid var(--cg-accent);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .cg-card { padding: 18px; }
  .cg-primary,
  .cg-choice { width: 100%; }
  .cg-primary { align-self: stretch; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .cg-card.is-in { transition: none; }
  .cg-progress-fill { transition: none; }
}

/* ── Public landing (guest) ─────────────────────────────────── */
/* Glassmorphism direction (ref-lock: Authkit midnight-glass + Vapi EQ band +
   Dimension orbs). Cyan stays the only strong accent (ClinTalk brand). */
.landing-root { position: fixed; inset: 0; overflow-y: auto; z-index: 9000;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(56,189,248,.10), transparent 60%),
    radial-gradient(90% 60% at 85% 110%, rgba(99,102,241,.08), transparent 60%),
    #050d1a;
  color: #e2e8f0; font-family: 'Outfit', system-ui, sans-serif;
  --glass-bg: rgba(56,189,248,.045);
  --glass-bd: rgba(125,211,252,.14);
  --glass-shadow: inset 0 1px 1px rgba(199,211,234,.14), inset 0 28px 56px rgba(56,189,248,.05), 0 24px 40px rgba(5,6,15,.5);
  scroll-behavior: smooth;
}
/* ── Atmosphere: parallax orbs + faint grid (fixed within the landing) ── */
.landing-atmos { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.landing-orb { position: absolute; border-radius: 50%; filter: blur(64px); opacity: .55;
  will-change: transform; }
.landing-orb--1 { width: 46vw; height: 46vw; left: -8vw; top: -6vw;
  background: radial-gradient(circle, rgba(56,189,248,.45), transparent 68%); }
.landing-orb--2 { width: 38vw; height: 38vw; right: -6vw; top: 28vh;
  background: radial-gradient(circle, rgba(99,102,241,.40), transparent 68%); }
.landing-orb--3 { width: 34vw; height: 34vw; left: 18vw; bottom: -10vw;
  background: radial-gradient(circle, rgba(45,212,191,.30), transparent 68%); }
.landing-grid { position: absolute; inset: 0;
  background-image: linear-gradient(rgba(125,211,252,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,211,252,.05) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 75% 70% at 50% 35%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 35%, #000 20%, transparent 78%); }
@keyframes land-float-a { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(3vw,4vh) scale(1.06); } }
@keyframes land-float-b { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-3vw,-3vh) scale(1.08); } }
.landing-orb--1 { animation: land-float-a 22s ease-in-out infinite; }
.landing-orb--2 { animation: land-float-b 26s ease-in-out infinite; }
.landing-orb--3 { animation: land-float-a 30s ease-in-out infinite reverse; }

/* ── Floating glass nav ── */
.landing-nav { position: sticky; top: 16px; z-index: 5; margin: 16px auto 0; width: max-content;
  display: flex; align-items: center; gap: 20px; padding: 8px 10px 8px 20px;
  border-radius: 999px; background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(14px) saturate(120%); -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: var(--glass-shadow); }
.landing-nav__mark { font-weight: 700; letter-spacing: -.02em; color: #f0f9ff; font-size: 16px; }
.landing-nav__mark .brand-talk, .landing-nav__mark sup { color: #38bdf8; }
.landing-nav__cta { font-size: 13px; padding: 8px 18px; }

/* ── Sections + scroll reveal ── */
.landing-hero { position: relative; z-index: 1; min-height: 86vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; }
.landing-how, .landing-guide, .landing-cats, .landing-login {
  position: relative; z-index: 1; max-width: 960px; margin: 0 auto; padding: 56px 24px; }
[data-reveal] { opacity: 0; transform: translateY(30px) scale(.985);
  transition: opacity .7s cubic-bezier(.22,1,.36,1), transform .7s cubic-bezier(.22,1,.36,1);
  transition-delay: var(--rd, 0s); }
[data-reveal].is-visible { opacity: 1; transform: none; }

/* ── Hero ── */
.landing-eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 22px;
  padding: 6px 14px; border-radius: 999px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: #7dd3fc; background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.landing-eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #38bdf8;
  box-shadow: 0 0 10px 2px rgba(56,189,248,.8); animation: land-pulse 2.4s ease-in-out infinite; }
@keyframes land-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.landing-wordmark { font-size: clamp(48px, 9vw, 88px); margin: 0 0 14px; color: #f0f9ff;
  font-weight: 700; letter-spacing: -.03em; line-height: 1; text-wrap: balance; }
.landing-wordmark .brand-talk { background: linear-gradient(180deg,#7dd3fc,#38bdf8 60%,#0ea5e9);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.landing-wordmark .brand-ai { font-size: .34em; vertical-align: super; color: #38bdf8; -webkit-text-fill-color: #38bdf8; }
.landing-tagline { font-size: clamp(17px, 3vw, 24px); color: #cbe7fb; margin: 0 auto 30px; max-width: 580px;
  line-height: 1.5; text-wrap: balance; }
.landing-hero-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.landing-btn { position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 30px; border-radius: 999px; font-size: 14px; font-weight: 500; letter-spacing: .01em;
  text-decoration: none; cursor: pointer; color: #e8f4fd; overflow: hidden;
  background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(12px) saturate(120%); -webkit-backdrop-filter: blur(12px) saturate(120%);
  box-shadow: inset 0 1px 1px rgba(186,214,247,.10);
  transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s, border-color .25s, background .25s; }
.landing-btn:hover { transform: translateY(-2px);
  box-shadow: inset 0 1px 1px rgba(186,214,247,.18), 0 0 28px rgba(56,189,248,.25); border-color: rgba(125,211,252,.4); }
.landing-btn--primary { color: #061018; font-weight: 600;
  background: linear-gradient(180deg,#9ce0ff,#38bdf8); border-color: rgba(125,211,252,.6);
  box-shadow: 0 6px 20px rgba(56,189,248,.30), inset 0 1px 1px rgba(255,255,255,.5); }
.landing-btn--primary:hover { box-shadow: 0 10px 32px rgba(56,189,248,.5), inset 0 1px 1px rgba(255,255,255,.6); }
/* sheen sweep on primary */
.landing-btn--primary::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
  transform: translateX(-120%); }
.landing-btn--primary:hover::after { transform: translateX(120%); transition: transform .7s ease; }

/* ── Section headings ── */
.landing-how h2, .landing-guide h2, .landing-cats h2, .landing-login h2 {
  text-align: center; color: #f0f9ff; margin: 0 0 36px; font-size: clamp(24px,4vw,36px);
  font-weight: 600; letter-spacing: -.02em; text-wrap: balance; }

/* ── Shared glass card ── */
.landing-step, .landing-cat, .landing-login form, .landing-guide__card {
  background: var(--glass-bg); border: 1px solid var(--glass-bd); border-radius: 16px;
  backdrop-filter: blur(16px) saturate(120%); -webkit-backdrop-filter: blur(16px) saturate(120%);
  box-shadow: var(--glass-shadow); }

/* ── How it works (legacy step cards — kept for backward compat, not rendered) ── */
.landing-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 20px; }
.landing-step { padding: 26px; transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s, border-color .3s; }
.landing-step:hover { transform: translateY(-4px); border-color: rgba(125,211,252,.32);
  box-shadow: var(--glass-shadow), 0 0 30px rgba(56,189,248,.16); }
.landing-step-n { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center;
  border-radius: 12px; font-weight: 700; font-size: 18px; color: #061018;
  background: linear-gradient(180deg,#9ce0ff,#38bdf8); box-shadow: 0 4px 16px rgba(56,189,248,.35); }
.landing-step h3 { color: #f0f9ff; margin: 16px 0 8px; font-size: 18px; font-weight: 600; }
.landing-step p { color: rgba(203,231,251,.62); font-size: 14px; line-height: 1.65; margin: 0; }

/* ── How it works — glass card-buttons (Task 1) ── */
.landing-how--wide { max-width: 100%; padding-left: 40px; padding-right: 40px; }
.landing-how-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.landing-how-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 22px 24px; border-radius: 16px; text-decoration: none;
  background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(16px) saturate(120%); -webkit-backdrop-filter: blur(16px) saturate(120%);
  box-shadow: var(--glass-shadow);
  color: #cbe7fb; font-size: 15px; font-weight: 500;
  transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s, border-color .25s, background .25s;
}
.landing-how-card:hover {
  transform: translateY(-4px);
  border-color: rgba(125,211,252,.36);
  box-shadow: var(--glass-shadow), 0 0 28px rgba(56,189,248,.18);
}
.landing-how-card__label { flex: 1 1 auto; }
.landing-how-card__arrow {
  flex-shrink: 0; font-size: 18px; color: #38bdf8;
  transition: transform .2s cubic-bezier(.22,1,.36,1);
}
.landing-how-card:hover .landing-how-card__arrow { transform: translateX(4px); }
@media (max-width: 768px) {
  .landing-how--wide { padding-left: 16px; padding-right: 16px; }
  .landing-how-cards { grid-template-columns: 1fr; }
}

/* ── Voice EQ band (Vapi-borrowed motif) ── */
.landing-eqband { position: relative; z-index: 1; max-width: 960px; margin: 8px auto; padding: 0 24px; }
.landing-eqband__inner { display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 22px; border-radius: 18px; background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(16px) saturate(120%); -webkit-backdrop-filter: blur(16px) saturate(120%);
  box-shadow: var(--glass-shadow); }
.landing-eqband canvas { width: 100%; height: 72px; display: block; }
.landing-eqband__cap { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: #7dd3fc; }

/* ── Guide ── */
.landing-guide { text-align: center; }
.landing-guide__card { max-width: 640px; margin: 0 auto; padding: 36px 28px; }
.landing-guide p { color: rgba(203,231,251,.62); margin: 0 0 22px; }

/* ── Categories ── */
.landing-cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 16px; }
.landing-cat { padding: 24px; text-align: center; color: #cbe7fb; font-weight: 500;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s, border-color .3s; }
.landing-cat:hover { transform: translateY(-3px); border-color: rgba(125,211,252,.3);
  box-shadow: var(--glass-shadow), 0 0 26px rgba(56,189,248,.14); }
.landing-cats-locked { text-align: center; color: #7dd3fc; margin-top: 22px; font-size: 14px; }

/* ── Login ── */
.landing-login { max-width: 460px; }
.landing-login form { display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.landing-login input { padding: 13px 16px; border-radius: 10px; border: 1px solid rgba(125,211,252,.16);
  background: rgba(5,13,26,.6); color: #eaf6ff; font-size: 15px; transition: border-color .2s, box-shadow .2s; }
.landing-login input::placeholder { color: #6b8197; }
.landing-login input:focus { outline: none; border-color: rgba(56,189,248,.55);
  box-shadow: 0 0 0 3px rgba(56,189,248,.14); }
.landing-login .login-error { color: #fca5a5; }
.landing-login .login-success { text-align: center; color: #cbe7fb; }

@media (prefers-reduced-motion: reduce) {
  .landing-orb, .landing-eyebrow::before { animation: none !important; }
  [data-reveal] { opacity: 1 !important; transform: none !important; transition: none !important; }
  .landing-root { scroll-behavior: auto; }
}

/* The global "Расскажи мне как учиться" tab (#howto-tab, z-60) is covered by the
   hub overlay (#hub-root, z-8500). Lift the tab + its menu above the hub while the
   hub is shown so the affordance is reachable there (as on /profile). */
body:has(#hub-root:not([hidden])) #howto-tab,
body:has(#hub-root:not([hidden])) #howto-menu { z-index: 8600; }

/* ── Authenticated Hub (bento glass command center) ─────────── */
.hub-root {
  position: fixed; inset: 0; overflow-y: auto; z-index: 8500;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(56,189,248,.10), transparent 60%),
    radial-gradient(90% 60% at 85% 110%, rgba(99,102,241,.08), transparent 60%),
    #050d1a;
  color: #e2e8f0; font-family: 'Outfit', system-ui, sans-serif;
  --glass-bg: rgba(56,189,248,.045);
  --glass-bd: rgba(125,211,252,.14);
  --glass-shadow: inset 0 1px 1px rgba(199,211,234,.14), inset 0 28px 56px rgba(56,189,248,.05), 0 24px 40px rgba(5,6,15,.5);
}

/* atmosphere */
.hub-atmos { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.hub-orb { position: absolute; border-radius: 50%; filter: blur(64px); opacity: .45; will-change: transform; }
.hub-orb--1 { width: 50vw; height: 50vw; left: -10vw; top: -8vw;
  background: radial-gradient(circle, rgba(56,189,248,.38), transparent 68%);
  animation: land-float-a 24s ease-in-out infinite; }
.hub-orb--2 { width: 40vw; height: 40vw; right: -8vw; bottom: -6vw;
  background: radial-gradient(circle, rgba(99,102,241,.32), transparent 68%);
  animation: land-float-b 30s ease-in-out infinite; }
.hub-grid { position: absolute; inset: 0;
  background-image: linear-gradient(rgba(125,211,252,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,211,252,.04) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 75% at 50% 40%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 40%, #000 20%, transparent 78%); }
@media (prefers-reduced-motion: reduce) {
  .hub-orb { animation: none; }
}

/* sticky glass nav */
.hub-nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px; margin: 0;
  background: rgba(5,13,26,.72);
  border-bottom: 1px solid var(--glass-bd);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.hub-nav__mark { font-weight: 700; letter-spacing: -.02em; color: #f0f9ff; font-size: 17px; text-decoration: none; }
.hub-nav__mark .brand-talk { color: #38bdf8; }
.hub-nav__mark sup { color: #38bdf8; font-size: .4em; vertical-align: super; }
.hub-nav__actions { display: flex; align-items: center; gap: 10px; }
.hub-nav__link {
  display: inline-flex; align-items: center;
  padding: 7px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: #cbe7fb; text-decoration: none; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.hub-nav__link:hover { border-color: rgba(125,211,252,.35); transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(56,189,248,.2); }

/* bento grid */
.hub-bento {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px 48px;
}

/* glass tile base */
.hub-tile {
  background: var(--glass-bg);
  border: 1px solid var(--glass-bd);
  border-radius: 18px;
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  box-shadow: var(--glass-shadow);
  padding: 22px 24px;
  transition: border-color .3s, box-shadow .3s, transform .3s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}
.hub-tile:hover {
  border-color: rgba(125,211,252,.28);
  box-shadow: var(--glass-shadow), 0 0 28px rgba(56,189,248,.12);
}
.hub-tile__label {
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: #7dd3fc; margin: 0 0 14px; font-weight: 600;
}
.hub-tile__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.hub-tile__head .hub-tile__label { margin: 0; }
.hub-tile__link { font-size: 12px; font-weight: 600; color: #38bdf8; text-decoration: none;
  white-space: nowrap; transition: color .15s; }
.hub-tile__link:hover { color: #7dd3fc; }
.hub-root--light .hub-tile__link { color: #0ea5e9; }
.hub-root--light .hub-tile__link:hover { color: #0369a1; }

/* tile sizing */
.hub-tile--hero   { grid-column: span 8; }
.hub-tile--action { grid-column: span 4; }
.hub-tile--radar  { grid-column: span 7; }
.hub-tile--trend  { grid-column: span 5; display: flex; flex-direction: column; }
.hub-tile--commit { grid-column: span 6; }
.hub-tile--cohort { grid-column: span 6; }
.hub-tile--recent { grid-column: span 12; }
.hub-tile--learn  { grid-column: span 12; }

/* hero tile */
.hub-hero-name {
  font-size: clamp(20px, 3vw, 30px); font-weight: 700; color: #f0f9ff;
  margin: 0 0 16px; letter-spacing: -.02em;
}
.hub-metrics { display: flex; flex-wrap: wrap; gap: 10px; }
.hub-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: rgba(56,189,248,.08); border: 1px solid rgba(125,211,252,.22);
  color: #cbe7fb;
}
.hub-pill strong { color: #38bdf8; }

/* action tile */
.hub-tile--action {
  display: flex; flex-direction: column; justify-content: center; gap: 14px;
}
.hub-action-title { font-size: 15px; font-weight: 600; color: #f0f9ff; margin: 0; }
.hub-action-sub { font-size: 13px; color: rgba(203,231,251,.62); margin: 0; line-height: 1.4; }
.hub-action-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.hub-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--glass-bd); color: #cbe7fb;
  background: var(--glass-bg); backdrop-filter: blur(8px);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  text-align: center;
}
.hub-btn:hover { transform: translateY(-2px); border-color: rgba(125,211,252,.35);
  box-shadow: 0 6px 20px rgba(56,189,248,.2); }
.hub-btn--primary {
  color: #061018; font-weight: 600;
  background: linear-gradient(180deg,#9ce0ff,#38bdf8);
  border-color: rgba(125,211,252,.6);
  box-shadow: 0 4px 16px rgba(56,189,248,.28), inset 0 1px 1px rgba(255,255,255,.45);
}
.hub-btn--primary:hover { box-shadow: 0 8px 28px rgba(56,189,248,.45), inset 0 1px 1px rgba(255,255,255,.55); }

/* radar tile */
.hub-radar-canvas { width: 100%; display: block; }
.hub-radar-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px;
}
.hub-radar-legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: rgba(203,231,251,.72);
}
.hub-radar-legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #38bdf8; flex-shrink: 0;
}
/* clickable legend = frosted-glass pill (kills the default <button> white chrome) */
.hub-radar-legend-btn {
  padding: 6px 12px; border-radius: 999px; font: inherit; line-height: 1.2; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-bd);
  -webkit-backdrop-filter: blur(10px) saturate(120%); backdrop-filter: blur(10px) saturate(120%);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.hub-radar-legend-btn:hover {
  border-color: rgba(125,211,252,.4); box-shadow: 0 0 16px rgba(56,189,248,.16); transform: translateY(-1px);
}
.hub-radar-legend-btn:focus-visible { outline: 2px solid rgba(56,189,248,.6); outline-offset: 2px; }
/* Phase 2 S6: off-radar safety chip (D1/BBN/IPC) + click drill-down dialog */
/* Task 3: frosted-glass amber capsule */
.hub-radar-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  padding: 5px 12px; font-size: 12px; color: #fbbf24;
  border: 1px solid rgba(251,191,36,.35); border-radius: 999px;
  background: rgba(251,191,36,.07);
  backdrop-filter: blur(12px) saturate(130%); -webkit-backdrop-filter: blur(12px) saturate(130%);
  box-shadow: inset 0 1px 1px rgba(253,230,138,.12), 0 0 14px rgba(251,191,36,.08);
}
.hub-radar-chip[hidden] { display: none; }
.hub-root--light .hub-radar-chip {
  background: rgba(251,191,36,.10);
  border-color: rgba(180,83,9,.22);
  color: #92400e;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.5), 0 0 12px rgba(251,191,36,.06);
}
.hub-radar-drill {
  position: fixed; z-index: 8700; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  max-width: 340px; width: calc(100% - 32px);
  padding: 16px 18px; border-radius: 14px;
  background: #0b1220; color: #e2e8f0;
  border: 1px solid rgba(125,211,252,.22);
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.hub-root--light .hub-radar-drill { background: #f8fafc; color: #0f172a; border-color: rgba(15,23,42,.12); }
.hub-radar-drill-close {
  background: none; border: none; cursor: pointer; font-size: 20px;
  line-height: 1; color: inherit; opacity: .6; padding: 0 4px;
}
.hub-radar-drill-close:hover { opacity: 1; }
.hub-drill-items { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.hub-drill-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px;
  background: rgba(56,189,248,.05); border: 1px solid rgba(125,211,252,.12); font-size: 13px; }
.hub-root--light .hub-drill-item { background: rgba(2,132,199,.06); border-color: rgba(15,23,42,.10); }
.hub-drill-item-pct { flex-shrink: 0; font-weight: 700; color: #fca5a5; min-width: 34px; }
.hub-root--light .hub-drill-item-pct { color: #dc2626; }
.hub-drill-item-body { display: flex; flex-direction: column; gap: 3px; }
.hub-drill-item-rat { color: rgba(203,231,251,.6); font-size: 12px; line-height: 1.45; }
.hub-root--light .hub-drill-item-rat { color: #64748b; }

/* trend tile */
.hub-trend-canvas { width: 100%; display: block; flex: 1 1 auto; min-height: 170px; }
.hub-trend-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin: 0 0 12px; }
.hub-trend-stat { font-size: 13px; color: rgba(203,231,251,.6); display: inline-flex; align-items: baseline; gap: 4px; }
.hub-trend-stat--main { font-size: 26px; font-weight: 700; color: #f0f9ff; letter-spacing: -.02em; }
.hub-trend-delta { font-size: 13px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.hub-trend-delta--up { color: #6ee7b7; background: rgba(52,211,153,.14); }
.hub-trend-delta--down { color: #fca5a5; background: rgba(248,113,113,.13); }
.hub-trend-delta--flat { color: rgba(203,231,251,.6); background: rgba(125,211,252,.10); }

/* commitment tile */
#hub-commit-body { font-size: 14px; color: #cbe7fb; line-height: 1.55; }
.hub-commit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column;
  gap: 10px; max-height: 230px; overflow-y: auto; }
.hub-commit-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 10px; background: rgba(56,189,248,.03);
  border: 1px solid rgba(125,211,252,.08); }
.hub-commit-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.hub-commit-date { font-size: 11px; color: rgba(203,231,251,.45); white-space: nowrap; }
.hub-commit-text { color: #f0f9ff; font-weight: 500; margin: 0; flex: 1 1 auto; }
.hub-commit-status { font-size: 12px; padding: 3px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; }
.hub-commit-status--done { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.28); color: #6ee7b7; }
.hub-commit-status--pending { background: rgba(251,191,36,.10); border: 1px solid rgba(251,191,36,.25); color: #fde68a; }
.hub-commit-empty { color: rgba(203,231,251,.45); font-style: italic; font-size: 13px; }

/* ── Commitment glass card (Task 2) ── */
.hub-commit-item { display: flex; align-items: flex-start; }
.hub-commit-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  width: 100%; padding: 12px 16px; border-radius: 12px;
  background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  transition: transform .22s cubic-bezier(.22,1,.36,1), border-color .22s, box-shadow .22s;
  text-decoration: none; color: inherit;
}
.hub-commit-card--static { cursor: default; }
.hub-commit-item--linked .hub-commit-card:hover {
  transform: translateY(-2px);
  border-color: rgba(125,211,252,.28);
  box-shadow: var(--glass-shadow), 0 0 18px rgba(56,189,248,.12);
}

/* ── Hub how-cards tile (Task 1) ── */
.hub-tile--how { grid-column: span 12; }
.hub-how-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 10px;
}
.hub-how-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border-radius: 12px; text-decoration: none;
  background: var(--glass-bg); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  color: #cbe7fb; font-size: 14px; font-weight: 500;
  transition: transform .22s cubic-bezier(.22,1,.36,1), border-color .22s, box-shadow .22s;
}
.hub-how-card:hover {
  transform: translateY(-3px);
  border-color: rgba(125,211,252,.3);
  box-shadow: var(--glass-shadow), 0 0 22px rgba(56,189,248,.14);
}
.hub-how-card__label { flex: 1 1 auto; }
.hub-how-card__arrow {
  flex-shrink: 0; font-size: 16px; color: #38bdf8;
  transition: transform .2s cubic-bezier(.22,1,.36,1);
}
.hub-how-card:hover .hub-how-card__arrow { transform: translateX(3px); }

/* cohort tile */
.hub-cohort-body { display: flex; flex-direction: column; gap: 10px; }
.hub-cohort-row { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; }
.hub-cohort-label { font-size: 11px; color: rgba(203,231,251,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-cohort-bars { display: flex; flex-direction: column; gap: 3px; }
.hub-cohort-bar-wrap { display: flex; align-items: center; gap: 6px; }
.hub-cohort-bar-track { flex: 1; height: 6px; border-radius: 3px; background: rgba(125,211,252,.1); overflow: hidden; }
.hub-cohort-bar-fill { height: 100%; border-radius: 3px; transition: width .5s cubic-bezier(.22,1,.36,1); }
.hub-cohort-bar-fill--you { background: linear-gradient(90deg,#38bdf8,#7dd3fc); }
.hub-cohort-bar-fill--cohort { background: rgba(125,211,252,.28); }
.hub-cohort-bar-pct { font-size: 11px; color: rgba(203,231,251,.55); width: 28px; text-align: right; flex-shrink: 0; }
.hub-cohort-you-label, .hub-cohort-cohort-label { font-size: 10px; color: rgba(125,211,252,.6); letter-spacing: .1em; }

/* recent sessions tile */
.hub-recent-list { display: flex; flex-direction: column; gap: 6px; }
.hub-recent-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: 10px;
  background: rgba(56,189,248,.025); border: 1px solid rgba(125,211,252,.08);
  text-decoration: none; color: #cbe7fb; font-size: 13px;
  transition: border-color .2s, background .2s;
}
.hub-recent-row:hover { border-color: rgba(125,211,252,.22); background: rgba(56,189,248,.06); }
.hub-recent-badge {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.hub-recent-badge--green { background: rgba(52,211,153,.15); }
.hub-recent-badge--yellow { background: rgba(251,191,36,.13); }
.hub-recent-badge--red { background: rgba(248,113,113,.12); }
.hub-recent-badge--gray { background: rgba(148,163,184,.12); color: #94a3b8; }
.hub-recent-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-recent-pct { font-size: 12px; font-weight: 600; color: rgba(203,231,251,.7); flex-shrink: 0; }
.hub-recent-date { font-size: 11px; color: rgba(203,231,251,.45); flex-shrink: 0; }
.hub-recent-empty { color: rgba(203,231,251,.45); font-style: italic; font-size: 13px; }

/* learning tile */
.hub-guide-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-radius: 12px; text-decoration: none;
  background: rgba(56,189,248,.06); border: 1px solid rgba(125,211,252,.14);
  color: #cbe7fb; margin-bottom: 20px;
  transition: border-color .2s, background .2s;
}
.hub-guide-link:hover { border-color: rgba(125,211,252,.28); background: rgba(56,189,248,.10); }
.hub-guide-cta { color: #38bdf8; font-size: 13px; font-weight: 500; }
.hub-cats-title { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: #7dd3fc; margin: 0 0 12px; font-weight: 600; }
.hub-cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; }
.hub-cat {
  padding: 18px 20px; border-radius: 12px; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-bd);
  color: #cbe7fb; font-weight: 500; font-size: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: border-color .25s, transform .25s, box-shadow .25s;
  text-align: center;
}
.hub-cat:hover { border-color: rgba(125,211,252,.32); transform: translateY(-3px);
  box-shadow: var(--glass-shadow), 0 0 24px rgba(56,189,248,.14); }

/* loading / error states */
.hub-loading { color: rgba(203,231,251,.45); font-style: italic; font-size: 14px; }

/* mobile collapse */
@media (max-width: 768px) {
  .hub-tile--hero, .hub-tile--action,
  .hub-tile--radar, .hub-tile--trend,
  .hub-tile--commit, .hub-tile--cohort,
  .hub-tile--recent, .hub-tile--learn { grid-column: span 12; }
  .hub-bento { gap: 12px; padding: 0 12px 36px; }
  .hub-nav { padding: 8px 16px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .hub-tile--hero { grid-column: span 7; }
  .hub-tile--action { grid-column: span 5; }
  .hub-tile--radar { grid-column: span 12; }
  .hub-tile--trend { grid-column: span 12; }
  .hub-tile--commit { grid-column: span 6; }
  .hub-tile--cohort { grid-column: span 6; }
}

/* ===== HUB LIGHT THEME ===== */
.hub-root--light {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(14,165,233,.10), transparent 60%),
    radial-gradient(90% 60% at 85% 110%, rgba(99,102,241,.06), transparent 60%),
    #eef3f8;
  color: #1f2937;
  --glass-bg: rgba(255,255,255,.72);
  --glass-bd: rgba(15,23,42,.08);
  --glass-shadow: 0 1px 1px rgba(255,255,255,.6) inset, 0 10px 28px rgba(15,23,42,.08);
}

/* Nav bar in light mode */
.hub-root--light .hub-nav {
  background: rgba(238,243,248,.88);
  border-bottom-color: rgba(15,23,42,.08);
}
.hub-root--light .hub-nav__mark { color: #0f172a; }
.hub-root--light .hub-nav__mark .brand-talk { color: #0369a1; }
.hub-root--light .hub-nav__mark sup { color: #0369a1; }
.hub-root--light .hub-nav__link {
  color: #0f172a;
  background: rgba(255,255,255,.6);
  border-color: rgba(15,23,42,.12);
}
.hub-root--light .hub-nav__link:hover {
  border-color: rgba(3,105,161,.35);
  box-shadow: 0 4px 16px rgba(14,165,233,.15);
}

/* Toggle button sizing (no text padding) */
.hub-theme-toggle {
  padding: 7px 11px;
  font-size: 15px;
  line-height: 1;
}

/* Orbs — dim in light */
.hub-root--light .hub-orb { opacity: .18; }

/* Grid */
.hub-root--light .hub-grid {
  background-image:
    linear-gradient(rgba(15,23,42,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,23,42,.04) 1px, transparent 1px);
}

/* Tile base override: lighter glass */
.hub-root--light .hub-tile {
  box-shadow: 0 1px 1px rgba(255,255,255,.6) inset, 0 10px 28px rgba(15,23,42,.08);
}
.hub-root--light .hub-tile:hover {
  box-shadow: 0 2px 2px rgba(255,255,255,.7) inset, 0 16px 36px rgba(15,23,42,.12);
}

/* Tile labels */
.hub-root--light .hub-tile__label { color: #0369a1; }

/* Hero */
.hub-root--light .hub-hero-name { color: #0f172a; }

/* Pills */
.hub-root--light .hub-pill {
  background: rgba(14,165,233,.10);
  border-color: rgba(3,105,161,.18);
  color: #0369a1;
}
.hub-root--light .hub-pill strong { color: #0369a1; }

/* Action tile */
.hub-root--light .hub-action-title { color: #0f172a; }
.hub-root--light .hub-action-sub { color: #475569; }
.hub-root--light .hub-btn {
  color: #1f2937;
  border-color: rgba(15,23,42,.12);
  background: rgba(255,255,255,.7);
}
.hub-root--light .hub-btn:hover {
  border-color: rgba(3,105,161,.3);
  box-shadow: 0 6px 20px rgba(14,165,233,.15);
}
.hub-root--light .hub-btn--primary {
  color: #ffffff;
  background: linear-gradient(180deg, #38bdf8, #0ea5e9);
  border-color: rgba(3,105,161,.5);
  box-shadow: 0 4px 16px rgba(14,165,233,.25), inset 0 1px 1px rgba(255,255,255,.35);
}
.hub-root--light .hub-btn--primary:hover {
  box-shadow: 0 8px 28px rgba(14,165,233,.40), inset 0 1px 1px rgba(255,255,255,.45);
}

/* Trend stats */
.hub-root--light .hub-trend-stat { color: #475569; }
.hub-root--light .hub-trend-stat--main { color: #0f172a; }
.hub-root--light .hub-trend-delta--up { color: #047857; background: rgba(16,185,129,.13); }
.hub-root--light .hub-trend-delta--down { color: #b91c1c; background: rgba(239,68,68,.10); }
.hub-root--light .hub-trend-delta--flat { color: #475569; background: rgba(14,165,233,.08); }

/* Commitment tile */
/* Light theme: how-cards + commitment cards */
.hub-root--light .hub-how-card { color: #0f172a; }
.hub-root--light .hub-how-card:hover { border-color: rgba(14,165,233,.3); box-shadow: var(--glass-shadow), 0 0 18px rgba(14,165,233,.10); }
.hub-root--light .hub-how-card__arrow { color: #0ea5e9; }
.hub-root--light .hub-commit-card { color: #0f172a; }
.hub-root--light .hub-commit-item--linked .hub-commit-card:hover { border-color: rgba(14,165,233,.28); box-shadow: var(--glass-shadow), 0 0 14px rgba(14,165,233,.10); }
/* Light landing how-cards */
.landing-how-card { }  /* inherits --glass vars set by landing root */
.hub-root--light #hub-commit-body { color: #1f2937; }
.hub-root--light .hub-commit-text { color: #0f172a; }
.hub-root--light .hub-commit-date { color: #64748b; }
.hub-root--light .hub-commit-empty { color: #64748b; }
.hub-root--light .hub-commit-status--done {
  background: rgba(16,185,129,.10);
  border-color: rgba(16,185,129,.25);
  color: #047857;
}
.hub-root--light .hub-commit-status--pending {
  background: rgba(251,191,36,.08);
  border-color: rgba(251,191,36,.22);
  color: #92400e;
}

/* Cohort tile */
.hub-root--light .hub-cohort-label { color: #475569; }
.hub-root--light .hub-cohort-bar-track { background: rgba(15,23,42,.07); }
.hub-root--light .hub-cohort-bar-fill--you { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
.hub-root--light .hub-cohort-bar-fill--cohort { background: rgba(14,165,233,.22); }
.hub-root--light .hub-cohort-bar-pct { color: #475569; }
.hub-root--light .hub-cohort-you-label,
.hub-root--light .hub-cohort-cohort-label { color: #0369a1; }

/* Recent sessions */
.hub-root--light .hub-recent-row { color: #1f2937; border-color: rgba(15,23,42,.07); background: rgba(255,255,255,.5); }
.hub-root--light .hub-recent-row:hover { border-color: rgba(14,165,233,.3); background: rgba(14,165,233,.05); }
.hub-root--light .hub-recent-title { color: #0f172a; }
.hub-root--light .hub-recent-pct { color: #1f2937; }
.hub-root--light .hub-recent-date { color: #64748b; }
.hub-root--light .hub-recent-empty { color: #64748b; }
.hub-root--light .hub-recent-badge--green { background: rgba(16,185,129,.15); }
.hub-root--light .hub-recent-badge--yellow { background: rgba(251,191,36,.15); }
.hub-root--light .hub-recent-badge--red { background: rgba(239,68,68,.13); }
.hub-root--light .hub-recent-badge--gray { background: rgba(100,116,139,.12); color: #475569; }

/* Learning tile */
.hub-root--light .hub-guide-link { color: #0f172a; border-color: rgba(15,23,42,.08); background: rgba(255,255,255,.55); }
.hub-root--light .hub-guide-link:hover { border-color: rgba(14,165,233,.3); background: rgba(14,165,233,.06); }
.hub-root--light .hub-guide-cta { color: #0369a1; }
.hub-root--light .hub-cats-title { color: #0369a1; }
.hub-root--light .hub-cat {
  color: #1f2937;
  border-color: rgba(15,23,42,.08);
  background: rgba(255,255,255,.55);
}
.hub-root--light .hub-cat:hover { border-color: rgba(14,165,233,.3); }

/* Loading / empty states */
.hub-root--light .hub-loading { color: #64748b; }

/* Radar legend */
.hub-root--light .hub-radar-legend-item { color: #1f2937; }
.hub-root--light .hub-radar-legend-dot { background: #0ea5e9; }

/* ── Profile commitment glass cards (Task 2 — profile.js, both themes) ── */
.commitment-item { list-style: none; }
.commitment-item__card {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  padding: 12px 16px; border-radius: 12px;
  background: rgba(56,189,248,.04); border: 1px solid rgba(125,211,252,.12);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: inherit; text-decoration: none;
  transition: transform .22s cubic-bezier(.22,1,.36,1), border-color .22s, box-shadow .22s;
}
.commitment-item__card--linked:hover {
  transform: translateY(-2px);
  border-color: rgba(125,211,252,.28);
  box-shadow: 0 4px 20px rgba(56,189,248,.10);
}
.commitment-item__card--static { cursor: default; }

/* Profile light theme */
html.profile-light .commitment-item__card {
  background: rgba(14,165,233,.05); border-color: rgba(15,23,42,.09);
}
html.profile-light .commitment-item__card--linked:hover {
  border-color: rgba(14,165,233,.28);
  box-shadow: 0 4px 16px rgba(14,165,233,.08);
}

/* hub-how-cards mobile */
@media (max-width: 768px) {
  .hub-how-cards { grid-template-columns: 1fr; }
}

