
@import url('../fonts/fonts.css');   /* локальные шрифты (без внешних CDN) */


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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Golos Text', sans-serif;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;          /* iOS Safari: учитываем панели браузера, чтобы низ не прятался */
  height: var(--vvh, 100dvh);   /* + учитываем клавиатуру (visualViewport) */
  width: 100vw;
}

/* Лёгкое бумажное зерно поверх всего — объединяет арт и интерфейс */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

#game-container {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  height: var(--vvh, 100dvh);
  position: fixed;          /* прижимаем к видимой области (top ставит JS по visualViewport.offsetTop) */
  top: 0; left: 0;
  overflow: hidden;
}

/* Дневной свет: тёплая стена + мягкий свет из окна слева-сверху */
#bg-layer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 18% -10%, rgba(255,253,247,0.9) 0%, rgba(255,253,247,0) 55%),
    radial-gradient(ellipse 70% 55% at 88% 8%, rgba(233,217,190,0.5) 0%, rgba(233,217,190,0) 60%),
    linear-gradient(180deg, #FAF6EE 0%, #F3EDE1 62%, #EBE2D1 100%);
  transition: opacity 0.8s ease;
}

#character-layer {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 220px;
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 5;
}

#character-layer.visible {
  opacity: 1;
}

/* Арт остаётся на месте — меняется только «рамка»: фото-карточка на столе HR */
#character-img {
  max-height: 65vh;
  max-width: 50vw;
  object-fit: contain;
  border-radius: 14px;
  border: 5px solid rgba(255,255,255,0.9);
  box-shadow: 0 18px 44px rgba(74,56,30,0.20), 0 5px 14px rgba(74,56,30,0.12);
}

#dialogue-box {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 200px;
  background: rgba(253,251,247,0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 34px rgba(74,56,30,0.10);
  padding: 20px 40px 30px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  transition: opacity 0.4s ease;
}

#speaker-name {
  font-family: 'Literata', serif;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

#speaker-name:not(:empty)::before {
  content: '';
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: var(--terra);
  flex-shrink: 0;
}

#dialogue-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  font-weight: 400;
  min-height: 60px;
  max-width: 800px;
  white-space: pre-line;        /* переносы строк из текста сохраняются */
}

#dialogue-text .cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--terra);
  margin-left: 2px;
  animation: blink 0.8s infinite;
  vertical-align: text-bottom;
}
/* Ремарка *действие* — курсив, приглушённо */
#dialogue-text em { font-style: italic; color: var(--ink-soft); }
#game-container.scene #dialogue-text em { color: #D2BE9F; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ===== РЕЖИМ СЦЕНЫ (полноэкранная визуальная новелла) ===== */
#game-container.scene #bg-layer {
  background-color: #14100c;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
#game-container.scene #character-layer { display: none; }
/* Плашка-«полоска» над низом: тёплая тёмная, скруглённая, со структурой имя+текст */
#game-container.scene #dialogue-box {
  left: 50%; right: auto; transform: translateX(-50%);
  width: min(94vw, 1040px);
  bottom: 3.2vh;
  min-height: 104px;
  background: rgba(26, 20, 15, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(243, 217, 184, 0.16);
  border-radius: 16px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.42);
  padding: 18px 34px 22px;
  justify-content: center;
}
#game-container.scene #speaker-name { color: #E58A4B; margin-bottom: 10px; }
#game-container.scene #speaker-name:not(:empty)::before { background: #E58A4B; }
#game-container.scene #dialogue-text {
  color: #F3ECE1; max-width: none; min-height: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
#game-container.scene #dialogue-text .cursor { background: #E58A4B; }
/* индикатор — в правом нижнем углу плашки */
#game-container.scene #continue-indicator { bottom: 14px; right: 30px; color: rgba(243,236,225,0.6); }

/* Кнопки выбора в VN-режиме — в стиле диалоговой плашки, ниже по экрану */
#game-container.scene #choices-container {
  bottom: 6vh;
  width: min(94vw, 1040px);
  max-width: none;
  gap: 12px;
}
#game-container.scene .choice-btn {
  background: rgba(26, 20, 15, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(243, 217, 184, 0.16);
  border-left: 1px solid rgba(243, 217, 184, 0.16);
  color: #F3ECE1;
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.42);
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  padding: 16px 28px;
}
#game-container.scene .choice-btn:hover {
  background: rgba(46, 36, 27, 0.86);
  border-color: rgba(243, 217, 184, 0.30);
  border-left-color: #E58A4B;
  transform: translateX(4px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
@media (max-width: 768px) {
  #game-container.scene #dialogue-box { bottom: 2.2vh; padding: 14px 18px 18px; min-height: 84px; }
  #game-container.scene #dialogue-text { font-size: 0.98rem; }
  #game-container.scene #continue-indicator { bottom: 10px; right: 16px; }
}

/* ===== ВЫБОР ПОЛА (когда имя унисекс) ===== */
#gender-pick { display: none; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; }
#gender-pick.visible { display: flex; }
#gender-pick-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: rgba(58,63,71,0.55);
}
#gender-pick-btns { display: flex; gap: 12px; }
.gender-btn {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.5); border-radius: 11px;
  padding: 11px 22px; font-family: 'Golos Text', sans-serif; font-size: 0.95rem;
  color: var(--ink); cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.1s ease;
}
.gender-btn:hover { background: rgba(255,255,255,0.7); border-color: rgba(58,78,126,0.4); }
.gender-btn:active { transform: scale(0.99); }

#continue-indicator {
  position: absolute;
  bottom: 12px;
  right: 40px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 1px;
  animation: pulse 2s infinite;
  display: none;
}

#continue-indicator.visible {
  display: block;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

#choices-container {
  position: absolute;
  bottom: 220px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
  width: 90%;
  max-width: 600px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#choices-container.visible {
  opacity: 1;
  pointer-events: all;
}

.choice-btn {
  background: var(--paper-high);
  border: 1px solid var(--line);
  border-left: 3px solid var(--navy);
  color: var(--ink);
  padding: 14px 24px;
  border-radius: 10px;
  font-family: 'Golos Text', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.22s ease;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.choice-btn:hover {
  border-color: var(--navy);
  border-left-color: var(--terra);
  transform: translateX(6px);
  box-shadow: var(--shadow-warm);
}

#title-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  transition: opacity 1s ease;
}
/* Размытая подложка того же фото — заполняет края на мобилке (letterbox), даёт атмосферу */
#title-blur {
  position: absolute; inset: 0;
  background: #14100c url("../scenes/0.webp?v=3") center/cover no-repeat;
  filter: blur(26px) brightness(0.55); transform: scale(1.1);
}
#title-bg {
  position: absolute; inset: 0;
  background: url("../scenes/0.webp?v=3") center/cover no-repeat;
}
#title-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20,16,12,0.18) 0%, rgba(20,16,12,0) 28%, rgba(20,16,12,0.12) 52%, rgba(20,16,12,0.74) 100%);
}

/* ===== Фаза 1: нарратив ===== */
#title-intro {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 0 20px 6vh; cursor: pointer;
}
#title-plate {
  position: relative;
  width: min(94vw, 1040px);
  background: rgba(26, 20, 15, 0.78);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid rgba(243, 217, 184, 0.16);
  border-radius: 16px; box-shadow: 0 14px 44px rgba(0,0,0,0.42);
  padding: 24px 34px 32px; text-align: left;
}
#title-text {
  color: #F3ECE1; font-size: 1.05rem; line-height: 1.7;
  min-height: 3.4em; text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
#title-text .cursor {
  display: inline-block; width: 2px; height: 1.1em; background: #E58A4B;
  margin-left: 2px; vertical-align: text-bottom; animation: blink 0.8s infinite;
}
/* Подсказка «продолжить» — в правом нижнем углу плашки; видна, когда текст допечатан */
#title-tap-hint {
  position: absolute; right: 30px; bottom: 12px;
  color: rgba(243,236,225,0.6);
  font-size: 13px; letter-spacing: 0.08em;
  opacity: 0; transition: opacity 0.3s ease;
}
#title-tap-hint.show { opacity: 1; animation: tapPulse 1.9s ease-in-out infinite; }
@keyframes tapPulse { 0%,100%{ opacity: 0.45; transform: translateY(0); } 50%{ opacity: 1; transform: translateY(3px); } }

/* ===== Фаза 2: разблокировка (имя + возраст) ===== */
#title-unlock {
  position: absolute; inset: 0; z-index: 3;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
#title-screen.unlocked #title-intro { display: none; }
#title-screen.unlocked #title-unlock { display: flex; animation: unlockIn 0.42s cubic-bezier(.2,.7,.3,1); }
@keyframes unlockIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ===== Гласморфизм: карточка разблокировки ===== */
#unlock-card {
  background: rgba(250,250,252,0.62);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
  backdrop-filter: blur(22px) saturate(135%);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 28px; padding: 30px 26px 26px;
  width: min(400px, 92vw); text-align: center;
  box-shadow: 0 22px 60px -24px rgba(20,24,34,0.45);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
#unlock-lock {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 4px 12px -6px rgba(20,24,34,0.2);
  display: flex; align-items: center; justify-content: center; margin-bottom: 2px;
}
#unlock-lock svg { width: 24px; height: 24px; stroke: var(--navy); }
#unlock-caption {
  font-size: 0.92rem; font-weight: 500; color: #3a3f47;
  line-height: 1.4; max-width: 252px;
}
#unlock-fields { display: flex; gap: 10px; width: 100%; margin-top: 2px; }

#name-input, #age-input {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 13px;
  padding: 13px 18px;
  color: var(--ink);
  font-family: 'Golos Text', sans-serif;
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
#name-input { flex: 1; width: auto; min-width: 0; }
#age-input { width: 104px; flex-shrink: 0; }
#age-input::-webkit-outer-spin-button, #age-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#age-input { -moz-appearance: textfield; }
#name-input:focus, #age-input:focus {
  background: rgba(255,255,255,0.72);
  border-color: rgba(58,78,126,0.45);
  box-shadow: 0 0 0 3px rgba(58,78,126,0.16);
}
#name-input::placeholder, #age-input::placeholder { color: rgba(60,66,74,0.45); }

#name-error {
  font-size: 0.8rem; color: #c0392b; letter-spacing: 0.2px; display: none;
}
#name-error.visible { display: block; }

#start-btn {
  width: 100%; margin-top: 4px;
  background: var(--navy);
  border: none;
  color: #fff;
  padding: 15px 40px;
  border-radius: 14px;
  font-family: 'Golos Text', sans-serif;
  font-size: 1.02rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 16px -8px rgba(44,60,99,0.5);
  transition: opacity 0.18s ease, transform 0.1s ease;
}
#start-btn:hover { opacity: 0.92; }
#start-btn:active { opacity: 0.85; transform: scale(0.99); }

/* Смена сцены — «моргание» дневным светом вместо чёрного */
#fade-overlay {
  position: absolute;
  inset: 0;
  background: var(--paper);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#fade-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ===== CHAT ===== */
#chat-container {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 30;
  background: #14100c;
  overflow: hidden;
}

#chat-container.visible { display: block; }

/* Чат живёт внутри экрана планшета (tablet-stage/tablet-screen) */
/* Планшет для чата крупнее — ленте нужно больше высоты */
#chat-container .tablet-stage { --sw: min(64vw, 118vh); }
#chat-container .tablet-screen { padding: 0; overflow: hidden; }

#chat-box {
  background: var(--paper-high);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 650px;
  height: 62vh;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-self: center;
  box-shadow: var(--shadow-warm);
}
/* ...но когда он внутри планшета — занимает весь экран, без своей рамки */
#chat-container .tablet-screen #chat-box {
  width: 100%; height: 100%; max-width: none; min-height: 0;
  background: transparent; border: none; border-radius: 0; box-shadow: none;
  padding: 3.2% 4.4%;
}

#chat-title {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
#chat-hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
#chat-hint b { color: var(--navy); font-weight: 600; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-right: 6px;
  margin-bottom: 10px;
}

/* Невидимый скролл: лента прокручивается, но полосы и трека нет */
#chat-messages { scrollbar-width: none; -ms-overflow-style: none; }
#chat-messages::-webkit-scrollbar { width: 0; height: 0; }

.chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; }

.chat-msg-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: var(--ink-faint);
  margin-bottom: 4px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chat-msg-bubble {
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.chat-msg.user .chat-msg-bubble {
  background: var(--navy);
  border: 1px solid var(--navy);
  color: #F4F1EA;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-msg-bubble {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

#chat-typing {
  align-self: flex-start;
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  color: var(--ink-faint);
  font-size: 0.82rem;
  display: none;
  margin-bottom: 12px;
  animation: pulse 1.5s infinite;
}

#chat-typing.visible { display: block; }

#chat-input-row {
  display: flex;
  align-items: flex-end;   /* кнопка держится у низа, поле растёт вверх */
  gap: 8px;
  margin-bottom: 6px;
}

#chat-input {
  flex: 1;
  background: var(--paper-high);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--ink);
  font-family: 'Golos Text', sans-serif;
  font-size: 0.95rem;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  height: 42px;            /* стартовая; растёт по содержимому (chatAutoGrow), дальше внутренний скролл */
  overflow-y: auto;
}

#chat-input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-tint); }

#chat-send {
  background: var(--navy);
  border: 1px solid var(--navy);
  color: #FDFBF7;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: 'Golos Text', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

#chat-send:hover:not(:disabled) { background: var(--navy-deep); }
#chat-send:disabled { opacity: 0.35; cursor: not-allowed; }

#chat-finish {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--ink-soft);
  padding: 8px 20px;
  border-radius: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.74rem;
  cursor: pointer;
  transition: all 0.25s ease;
  width: 100%;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: none;
}

#chat-finish.visible {
  display: block;
}

#chat-finish:hover {
  color: var(--terra);
  border-color: var(--terra);
  background: var(--terra-tint);
}

#chat-confirm {
  padding: 10px 0 2px;
  border-top: 1px solid var(--line-soft);
}
#chat-confirm-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}
#chat-confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}
#chat-confirm-btns .exp-btn { flex: 1; padding: 10px 16px; font-size: 0.85rem; }
#chat-confirm-no {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}
#chat-confirm-no:hover {
  background: var(--paper-dim);
  color: var(--ink);
}

/* Блок синопсиса в чате */
.chat-idea-ref {
  align-self: stretch;
  background: var(--terra-tint);
  border: 1px solid rgba(190,110,61,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.chat-idea-ref-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: var(--terra);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 5px;
}
.chat-idea-ref-text {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Markdown внутри пузырей */
.chat-msg-bubble p { margin: 0 0 8px; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble strong { font-weight: 600; }
.chat-msg-bubble em { font-style: italic; }
.chat-msg-bubble ul, .chat-msg-bubble ol { padding-left: 18px; margin: 6px 0; }
.chat-msg-bubble li { margin-bottom: 4px; }
.chat-msg-bubble hr { border: none; border-top: 1px solid var(--line-soft); margin: 10px 0; }
.chat-msg-bubble code { background: rgba(74,56,30,0.08); padding: 1px 5px; border-radius: 3px; font-size: 0.85em; }
.chat-msg-bubble pre { background: rgba(74,56,30,0.06); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
.chat-msg-bubble pre code { background: none; padding: 0; }

@media (max-width: 768px) {
  /* Фото — позиция прежняя, компактнее рамка */
  #character-img { max-height: 48vh; max-width: 88vw; border-width: 4px; border-radius: 12px; }
  #character-layer { padding-bottom: 195px; }

  /* Диалог – фиксированная высота, длинный текст скроллится */
  #dialogue-box {
    padding: 12px 18px 22px;
    height: 185px;
    min-height: unset;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #dialogue-text { font-size: 0.95rem; line-height: 1.6; }
  #speaker-name { font-size: 0.9rem; margin-bottom: 5px; }
  #continue-indicator { right: 18px; bottom: 8px; }

  /* Варианты – всегда над диалогом, удобные тач-цели */
  #choices-container { bottom: 193px; width: 92%; max-width: none; }
  .choice-btn { padding: 13px 16px; font-size: 0.9rem; min-height: 48px; }

  /* Панели */
  .exp-card { padding: 22px 16px; }

  #title-plate { padding: 18px 20px 30px; }
  #title-text { font-size: 0.98rem; }
  #title-tap-hint { right: 18px; bottom: 10px; font-size: 12px; }
  /* На узком экране показываем всю сцену (кофе, стол), а не зум в телефон;
     края заполняет размытая подложка #title-blur — атмосфера кафе сохраняется. */
  #title-bg { background-size: contain; background-position: center 34%; }
  #unlock-fields { flex-direction: column; }
  #age-input { width: 100%; }
  #name-input, #age-input { font-size: 1rem; }   /* ≥16px: iOS не зумит поле */
  #chat-box { height: 85vh; padding: 16px; }
  #chat-input { font-size: 1rem; min-height: 48px; padding: 12px 14px; } /* ≥16px: iOS не зумит; растёт по тексту */
  #chat-input::placeholder { font-size: 0.9rem; }
}

/* ===== EXPERIMENT PANELS ===== */
.exp-panel {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: flex-start;
  align-items: flex-start;
  z-index: 30;
  background: rgba(245,240,232,0.97);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 32px 20px 60px;
}
.exp-panel.visible { display: flex; }

/* Карточка — лист анкеты на столе */
.exp-card {
  background: var(--paper-high);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  box-shadow: var(--shadow-warm);
  position: relative;
}
/* Терракотовое «ребро скоросшивателя» слева */
.exp-card::before {
  content: '';
  position: absolute;
  left: 0; top: 22px; bottom: 22px;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--terra) 0%, var(--navy) 100%);
  opacity: 0.55;
}
@media (max-width: 768px) {
  .exp-panel { flex-direction: column; align-items: center; padding: 16px 12px 40px; }
  .exp-card { margin-top: auto; margin-bottom: auto; }
}
.exp-card h2 {
  font-family: 'Literata', serif;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}
.exp-card h3 { color: var(--ink); font-size: 0.95rem; margin-bottom: 8px; }
.exp-card .exp-step-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem; font-weight: 500; color: var(--terra);
  letter-spacing: 0.22em; text-transform: uppercase; margin-bottom: 10px;
}
.exp-card .exp-subtitle {
  font-size: 0.9rem; color: var(--ink-soft);
  line-height: 1.65; margin-bottom: 18px;
}
.exp-progress-wrap {
  background: var(--paper-dim); border-radius: 4px;
  height: 5px; margin-bottom: 22px; overflow: hidden;
}
.exp-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--terra), var(--navy));
  border-radius: 4px; transition: width 0.4s ease;
}

.exp-input {
  width: 100%; background: var(--paper-high);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 13px; font-size: 0.9rem; font-family: 'Golos Text', sans-serif;
  color: var(--ink); outline: none; transition: border-color 0.2s;
}
.exp-input:focus { border-color: var(--navy); }

.exp-btn {
  background: var(--navy); border: 1px solid var(--navy);
  color: #FDFBF7; padding: 13px 34px; border-radius: 10px;
  font-family: 'Golos Text', sans-serif; font-size: 0.93rem; font-weight: 600;
  cursor: pointer; transition: all 0.25s ease; letter-spacing: 0.04em;
  box-shadow: 0 6px 16px rgba(58,78,126,0.24);
}
.exp-btn:hover { background: var(--navy-deep); transform: translateY(-1px); }
.exp-btn:disabled { transform: none; box-shadow: none; }
.exp-btn-row { display: flex; justify-content: center; margin-top: 20px; }

.exp-stub {
  background: var(--paper); border: 1px dashed var(--line);
  border-radius: 10px; padding: 30px 20px; text-align: center;
  color: var(--ink-faint); font-size: 0.9rem; line-height: 1.6; margin-bottom: 18px;
}

/* ===== ФИНАЛЬНЫЙ ЭКРАН СЕССИИ (реплика Екатерины + бонус + шеринг) ===== */
.fin-dialogue { text-align: center; margin-bottom: 28px; }
.fin-sprite {
  width: 100%; max-width: 460px; border-radius: 12px;
  display: block; margin: 0 auto 18px; box-shadow: var(--shadow-soft);
}
.fin-speaker {
  font-family: 'Literata', serif; font-weight: 700; font-size: 0.9rem;
  color: var(--navy); letter-spacing: 0.08em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.fin-speaker::before {
  content: ''; width: 22px; height: 3px; border-radius: 2px;
  background: var(--terra); flex-shrink: 0;
}
.fin-text {
  font-family: 'Golos Text', sans-serif; font-size: 1.06rem; line-height: 1.7;
  color: var(--ink); max-width: 540px; margin: 0 auto;
}

/* Бонус — заглушка (наполнение см. bonusCard() в app.js) */
.fin-bonus {
  background: var(--paper); border: 1.5px dashed var(--terra);
  border-radius: 14px; padding: 28px 24px; text-align: center; margin-bottom: 34px;
}
.fin-bonus-title {
  font-family: 'Literata', serif; font-size: 1.3rem; font-weight: 700;
  color: var(--ink); margin-bottom: 10px;
}
.fin-bonus-text {
  font-family: 'Golos Text', sans-serif; font-size: 0.95rem; color: var(--ink-soft);
  line-height: 1.6; max-width: 380px; margin: 0 auto;
}

/* Шеринг */
.fin-share { margin-bottom: 28px; }
.fin-share-title {
  font-family: 'Literata', serif; font-size: 1.12rem; font-weight: 700;
  color: var(--ink); text-align: center; margin-bottom: 16px;
}
.fin-share-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.fin-share-btn {
  background: var(--paper-high); border: none; color: var(--ink);
  padding: 12px 20px; border-radius: 12px;
  font-family: 'Golos Text', sans-serif; font-size: 0.92rem; font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  gap: 9px; box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease; -webkit-tap-highlight-color: transparent;
}
.fin-share-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-warm); }
.fin-share-btn:active { transform: translateY(0); box-shadow: var(--shadow-soft); }
.fin-ic { width: 19px; height: 19px; flex-shrink: 0; display: block; }

.fin-note {
  font-family: 'Golos Text', sans-serif; font-size: 0.8rem; line-height: 1.55;
  color: var(--ink-faint); text-align: center; max-width: 500px; margin: 0 auto;
}

/* ===== ИСХОДНАЯ ПОЗИЦИЯ: карточки-альтернативы ===== */
.pos-question {
  font-family: 'Literata', serif; font-size: 1.28rem; font-weight: 600;
  line-height: 1.4; color: var(--ink); margin: 6px 0 18px;
}
.pos-cards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.pos-card {
  text-align: left; width: 100%;
  background: var(--paper-high); border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--ink); font-family: 'Golos Text', sans-serif; font-size: 0.98rem;
  line-height: 1.4; padding: 15px 17px; cursor: pointer; transition: all 0.15s ease;
}
.pos-card:hover { border-color: var(--navy); background: var(--navy-tint); }
.pos-card-own { border-style: dashed; color: var(--ink-soft); font-style: italic; margin-top: 4px; }
.pos-card.selected {
  border-color: var(--navy); background: var(--navy-tint); font-weight: 500;
  box-shadow: 0 3px 12px rgba(58,78,126,0.18);
}
.pos-card:focus-visible { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-tint); }
.pos-why-label {
  display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 4px;
}
.pos-why {
  display: block; width: 100%; margin-top: 8px; resize: vertical;
  background: var(--paper-high); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 14px; font-family: 'Golos Text', sans-serif; font-size: 0.95rem;
  color: var(--ink); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.pos-why:focus { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-tint); }

/* ===== МЕТОДИКА: пошаговый вопрос с кружками выбора ===== */
.scale-step {
  margin: 6px 0 4px;
  padding: 22px 0 8px;
  border-top: 1px solid var(--line-soft);
  min-height: 200px;
}
.scale-qmeta {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.7rem;
  color: var(--terra-strong); letter-spacing: 0.1em; margin-bottom: 12px;
}
.scale-question {
  font-family: 'Literata', serif; font-size: 1.18rem; font-weight: 500;
  line-height: 1.45; color: var(--ink); margin-bottom: 30px;
}

/* Ряд кружков */
.scale-circles { display: flex; justify-content: center; gap: 10px; }
.scale-c {
  flex: 1; max-width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  background: none; border: none; cursor: pointer; padding: 4px 2px;
  font-family: 'Golos Text', sans-serif;
}
/* Числовая шкала (антропоморфизация): компактный ряд, подписи над крайними кружками */
.scale-scale.numeric { max-width: 360px; margin: 0 auto; }
.scale-scale.numeric .scale-circles { justify-content: space-between; gap: 4px; }
.scale-scale.numeric .scale-c { flex: 0 0 auto; max-width: none; }
.scale-c-dot {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--paper-high);
  transition: all 0.15s ease;
  display: flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.9rem; color: var(--ink-soft);
}
.scale-c:hover .scale-c-dot { border-color: var(--navy); background: var(--navy-tint); color: var(--navy); }
.scale-c.active .scale-c-dot {
  border-color: var(--navy); background: var(--navy); color: #FDFBF7; font-weight: 600;
  box-shadow: 0 0 0 4px var(--navy-tint), 0 4px 12px rgba(58,78,126,0.35);
}
.scale-c-label { font-size: 0.78rem; line-height: 1.25; color: var(--ink-soft); text-align: center; }
.scale-c.active .scale-c-label { color: var(--navy); font-weight: 600; }
/* Клавиатурный фокус на кружке — заметная обводка */
.scale-c:focus-visible { outline: none; }
.scale-c:focus-visible .scale-c-dot { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-tint); }
/* Вопрос получает фокус программно (для анонса скринридером) — без видимой рамки */
#scale-q:focus { outline: none; }

/* Подписи крайних точек шкалы (антропоморфизация) — в два ряда, узкие, над крайними кружками */
.scale-ends {
  display: flex; justify-content: space-between; margin: 0 0 10px;
}
.scale-ends span {
  font-size: 0.7rem; color: var(--ink-soft); max-width: 84px;
  line-height: 1.2; text-align: center;
}
.scale-ends span:first-child { text-align: left; }
.scale-ends span:last-child { text-align: right; }

.exp-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ===== ИСТОРИЯ БОБРОВ (картинка + подпись в планшете) ===== */
/* Планшет лежит горизонтально — картинка слева, текст справа; на телефоне колонкой (ниже, в медиазапросе) */
.story-row { display: flex; align-items: center; gap: 18px; }
.story-img {
  width: 52%; flex-shrink: 0; border-radius: 12px; display: block;
  box-shadow: 0 6px 18px rgba(74,56,30,0.16);
}
.story-side { flex: 1; min-width: 0; }
.story-text { font-size: 0.95rem; line-height: 1.65; color: var(--ink); margin-bottom: 14px; }
.story-dots { display: flex; gap: 6px; margin-bottom: 14px; }
.story-dots i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--line); display: block;
  transition: background 0.2s ease, transform 0.2s ease;
}
.story-dots i.on { background: var(--navy); transform: scale(1.25); }

/* ===== ЦИФРОВОЙ РЯД НАОБОРОТ (проба рабочей памяти) ===== */
.ds-head {
  font-family: 'Literata', serif; font-size: 1.2rem; font-weight: 700;
  color: var(--ink); margin-bottom: 10px;
}
.ds-meta {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--terra-strong); margin-bottom: 12px;
}
.ds-ex { font-family: 'IBM Plex Mono', monospace; font-weight: 600; color: var(--navy); white-space: nowrap; letter-spacing: 0.25em; }
/* Площадка предъявления: высота фиксирована — цифры не «дёргают» вёрстку */
.ds-stage { display: flex; align-items: center; justify-content: center; height: 128px; margin-bottom: 8px; }
.ds-digit {
  font-family: 'IBM Plex Mono', monospace; font-size: 4.4rem; font-weight: 600;
  color: var(--ink); line-height: 1; opacity: 0;
}
.ds-digit.on { opacity: 1; }
.ds-hint, .ds-prompt { font-size: 0.9rem; color: var(--ink-soft); text-align: center; margin-bottom: 14px; }
.ds-prompt b { color: var(--ink); }
.ds-boxes { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.ds-box {
  width: 46px; height: 56px; border: 2px solid var(--line); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; background: var(--paper-high);
  font-family: 'IBM Plex Mono', monospace; font-size: 1.6rem; font-weight: 600; color: var(--ink);
}
.ds-box.filled { border-color: var(--navy); background: var(--navy-tint); }
/* Экранная клавиатура: системную не зовём — на телефоне она закрывает планшет */
.ds-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 330px; margin: 0 auto; }
.ds-key {
  padding: 12px 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper-high); color: var(--ink);
  font-family: 'IBM Plex Mono', monospace; font-size: 1.1rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease;
}
.ds-key:hover { border-color: var(--navy); background: var(--navy-tint); }
.ds-key:active { transform: translateY(1px); }
.ds-key:focus-visible { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-tint); }
/* «Стереть» — во всю ширину под цифрами: крупная цель для пальца, ряды не рвутся */
.ds-key-back {
  grid-column: 1 / -1; color: var(--ink-soft);
  font-family: 'Golos Text', sans-serif; font-size: 0.85rem; font-weight: 500; letter-spacing: 0.02em;
}
.ds-feedback { font-family: 'Literata', serif; font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; }
.ds-feedback.ok { color: var(--navy); }
.ds-feedback.no { color: var(--terra-strong); }
/* Отладочный «пропустить» — намеренно неприметный */
.ds-skip { text-align: center; margin-top: 10px; }
.ds-skip button {
  background: none; border: none; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.7rem; color: var(--ink-faint);
}

/* ===== ОПРОСНИК «В ПЛАНШЕТЕ» ===== */
.tablet-panel { align-items: center; justify-content: center; padding: 0; overflow: hidden; }
/* Сцена во весь экран: размытая подложка + крупный планшет + белый экран по центру */
.tablet-stage {
  --sw: min(56vw, 108vh);            /* ширина экрана планшета (приближение) */
  position: absolute; inset: 0; overflow: hidden;
}
/* Размытая версия того же фото — мягко заполняет края, без резкого контраста */
.tablet-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scale(1.12);
  filter: blur(30px) brightness(0.92);
}
/* Чёткое фото планшета, приближенное (экран = --sw, по замеру картинки) */
.tablet-photo {
  position: absolute;
  width: calc(var(--sw) * 1.677);
  left: calc(50% - var(--sw) * 0.838);
  top:  calc(50% - var(--sw) * 0.465);
}
/* Белая область экрана планшета (замерено: left 20.2% top 15.5% w 59.6% h 67.5%, AR 1.57) */
.tablet-screen {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: var(--sw); height: calc(var(--sw) / 1.57);
  display: flex; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2% 3%;
  container-type: inline-size;       /* размеры контента масштабируем от ширины экрана */
}
.tablet-screen::-webkit-scrollbar { width: 4px; }
.tablet-screen::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.tablet-screen-inner { margin: auto 0; width: 100%; }

/* Контент масштабируется от ширины экрана планшета (cqw) */
.tablet-screen .exp-subtitle { font-size: 2.5cqw; margin-bottom: 2%; line-height: 1.4; }
.tablet-screen .exp-progress-wrap { height: 0.7cqw; margin-bottom: 5%; }
.tablet-screen .scale-step { border: none; padding: 0; min-height: 0; margin: 0 0 3%; }
.tablet-screen .scale-qmeta { font-size: 2.2cqw; margin-bottom: 3%; }
.tablet-screen .scale-question { font-size: 3.4cqw; margin-bottom: 6%; line-height: 1.4; }
.tablet-screen .scale-c-dot { width: 6cqw; height: 6cqw; font-size: 2.7cqw; border-width: 2px; }
.tablet-screen .scale-c.active .scale-c-dot { box-shadow: 0 0 0 3px var(--navy-tint); }
.tablet-screen .scale-c-label { font-size: 2.2cqw; }
.tablet-screen .scale-ends span { font-size: 2.2cqw; max-width: 20cqw; }
.tablet-screen .scale-scale.numeric { max-width: 66cqw; }

/* Карточки исходной позиции внутри планшета */
#position-content .tablet-screen .exp-progress-wrap,
#positionout-content .tablet-screen .exp-progress-wrap { margin-bottom: 3%; }
#positionout-content .tablet-screen .exp-subtitle { margin-bottom: 1.5%; font-size: 2.2cqw; }
/* Повторный экран: карточек больше (свои + цели ИИ) — компактнее, чтобы влезли */
#positionout-content .tablet-screen .pos-question { margin-bottom: 2.4%; }
#positionout-content .tablet-screen .pos-cards { gap: 4px; margin-bottom: 2.2%; }
#positionout-content .tablet-screen .pos-card { padding: 1.9% 3.1%; font-size: 2.55cqw; border-radius: 2cqw; }
#positionout-content .tablet-screen .pos-card-own { margin-top: 1%; }
#positionout-content .tablet-screen .exp-btn-row { margin-top: 1%; }
.tablet-screen .pos-question { font-size: 3.1cqw; margin: 0 0 2.8%; }
.tablet-screen .pos-cards { gap: 4px; margin-bottom: 2.8%; }
.tablet-screen .pos-card { font-size: 2.62cqw; padding: 2.1% 3.2%; border-radius: 2.2cqw; border-width: 1.5px; }
.tablet-screen .pos-why-label { font-size: 2.2cqw; }
.tablet-screen .pos-why { font-size: 2.35cqw; padding: 1.5% 2.2%; border-radius: 1.8cqw; margin-top: 1.2%; }
.tablet-screen .exp-btn-row { margin-top: 1.8%; }
.tablet-screen .exp-btn { font-size: 2.5cqw; padding: 1.9% 6%; border-radius: 2.2cqw; }

/* История бобров внутри планшета */
.tablet-screen .story-row { gap: 3.4cqw; }
.tablet-screen .story-text { font-size: 2.7cqw; margin-bottom: 3.4%; }
.tablet-screen .story-img { border-radius: 2cqw; }
.tablet-screen .story-dots { gap: 1.2cqw; margin-bottom: 3.4%; }
.tablet-screen .story-dots i { width: 1.5cqw; height: 1.5cqw; }
.tablet-screen .story-side .exp-btn-row { margin-top: 0; justify-content: flex-start; }

/* Цифровой ряд наоборот внутри планшета */
.tablet-screen .ds-head { font-size: 3.4cqw; margin-bottom: 2%; }
.tablet-screen .ds-meta { font-size: 2.1cqw; margin-bottom: 2%; }
.tablet-screen .ds-stage { height: 20cqw; margin-bottom: 1%; }
.tablet-screen .ds-digit { font-size: 13cqw; }
.tablet-screen .ds-hint, .tablet-screen .ds-prompt { font-size: 2.5cqw; margin-bottom: 2.5%; }
.tablet-screen .ds-boxes { gap: 1.6cqw; margin-bottom: 2.8%; }
.tablet-screen .ds-box { width: 7.6cqw; height: 9.4cqw; font-size: 4.2cqw; border-radius: 1.8cqw; }
.tablet-screen .ds-pad { max-width: 54cqw; gap: 1.3cqw; }
.tablet-screen .ds-key { font-size: 2.9cqw; padding: 1.5% 0; border-radius: 1.6cqw; }
.tablet-screen .ds-key-back { font-size: 2.3cqw; }
.tablet-screen .ds-feedback { font-size: 3.6cqw; }
.tablet-screen .ds-skip button { font-size: 1.9cqw; }

/* Фолбэк для браузеров без container-query-единиц (cqw): масштабируем от --sw через calc */
@supports not (width: 1cqw) {
  .tablet-screen .exp-subtitle { font-size: calc(var(--sw) * 0.025); }
  .tablet-screen .scale-qmeta { font-size: calc(var(--sw) * 0.022); }
  .tablet-screen .scale-question { font-size: calc(var(--sw) * 0.034); }
  .tablet-screen .scale-c-dot { width: calc(var(--sw) * 0.06); height: calc(var(--sw) * 0.06); font-size: calc(var(--sw) * 0.027); }
  .tablet-screen .scale-c-label { font-size: calc(var(--sw) * 0.022); }
  .tablet-screen .scale-ends span { font-size: calc(var(--sw) * 0.022); max-width: calc(var(--sw) * 0.2); }
  .tablet-screen .scale-scale.numeric { max-width: calc(var(--sw) * 0.66); }
  .tablet-screen .pos-question { font-size: calc(var(--sw) * 0.032); }
  .tablet-screen .pos-card { font-size: calc(var(--sw) * 0.025); }
  .tablet-screen .pos-why-label { font-size: calc(var(--sw) * 0.023); }
  .tablet-screen .pos-why { font-size: calc(var(--sw) * 0.024); }
  .tablet-screen .exp-btn { font-size: calc(var(--sw) * 0.026); }
  .tablet-screen .ds-head { font-size: calc(var(--sw) * 0.034); }
  .tablet-screen .ds-meta { font-size: calc(var(--sw) * 0.021); }
  .tablet-screen .ds-stage { height: calc(var(--sw) * 0.2); }
  .tablet-screen .ds-digit { font-size: calc(var(--sw) * 0.13); }
  .tablet-screen .ds-hint, .tablet-screen .ds-prompt { font-size: calc(var(--sw) * 0.025); }
  .tablet-screen .ds-box { width: calc(var(--sw) * 0.076); height: calc(var(--sw) * 0.094); font-size: calc(var(--sw) * 0.042); }
  .tablet-screen .ds-pad { max-width: calc(var(--sw) * 0.54); }
  .tablet-screen .ds-key { font-size: calc(var(--sw) * 0.029); }
  .tablet-screen .ds-feedback { font-size: calc(var(--sw) * 0.036); }
}

/* Узкие экраны: планшет не влезает — прячем фото, экран становится обычной карточкой */
@media (max-width: 820px) {
  .tablet-panel { background: var(--paper); padding: 20px 12px; overflow-y: auto; align-items: flex-start; }
  .tablet-stage { position: static; inset: auto; overflow: visible; display: flex; justify-content: center; }
  .tablet-photo, .tablet-bg { display: none; }
  /* Чат на узких экранах — на всю видимую высоту; поле ввода остаётся над клавиатурой */
  #chat-container { background: var(--paper); overflow: hidden; }
  #chat-container .tablet-stage { width: 100%; height: 100%; align-items: stretch; }
  #chat-container .tablet-screen { padding: 14px; overflow: hidden; height: 100%; max-width: none;
    background: transparent; border: none; box-shadow: none; border-radius: 0; margin: 0; }
  #chat-container .tablet-screen #chat-box { height: 100%; min-height: 0; padding: 0; }
  #chat-hint { display: none; }                    /* на мобилке освобождаем место под чат */
  #chat-send { width: 48px; min-width: 48px; height: 48px; padding: 0; font-size: 0; border-radius: 12px; flex-shrink: 0; }
  #chat-send::before { content: '↑'; font-size: 1.5rem; line-height: 1; }
  .tablet-screen {
    position: static; left: auto; top: auto; transform: none;
    width: 100%; max-width: 620px; height: auto; margin: auto;
    container-type: normal; padding: 30px 20px;
    background: var(--paper-high); border: 1px solid var(--line);
    border-radius: 18px; box-shadow: var(--shadow-warm);
  }
  .tablet-screen .exp-subtitle { font-size: 1rem; margin-bottom: 22px; }
  .tablet-screen .exp-progress-wrap { height: 6px; margin-bottom: 24px; }
  .tablet-screen .scale-qmeta { font-size: 0.72rem; margin-bottom: 12px; }
  .tablet-screen .scale-question { font-size: 1.2rem; margin-bottom: 26px; }
  .tablet-screen .scale-c-dot { width: 34px; height: 34px; font-size: 0.95rem; }
  .tablet-screen .scale-c-label { font-size: 0.74rem; }
  .tablet-screen .scale-ends span { font-size: 0.72rem; max-width: 84px; }
  .tablet-screen .scale-scale.numeric { max-width: 340px; }
  .tablet-screen .pos-question { font-size: 1.5rem; margin: 8px 0 22px; line-height: 1.28; }
  .tablet-screen .pos-cards { gap: 12px; margin-bottom: 24px; }
  .tablet-screen .pos-card { font-size: 1.08rem; padding: 17px 18px; border-radius: 13px; }
  .tablet-screen .pos-why-label { font-size: 0.92rem; }
  .tablet-screen .pos-why { font-size: 16px; padding: 13px 15px; border-radius: 11px; }   /* ≥16px: iOS не зумит */
  .tablet-screen .exp-btn { font-size: 1.08rem; padding: 16px 26px; border-radius: 12px; }
  /* Ширина карточки не должна прыгать: на экране предъявления контент — одна цифра,
     а #digitspan-content — flex-элемент панели и сжался бы по содержимому */
  #digitspan-content, #digitspan-content .tablet-stage,
  #story-content, #story-content .tablet-stage { width: 100%; }
  /* История бобров: на телефоне картинка сверху, текст под ней */
  .tablet-screen .story-row { flex-direction: column; gap: 16px; align-items: stretch; }
  .tablet-screen .story-img { width: 100%; }
  .tablet-screen .story-text { font-size: 1rem; }
  .tablet-screen .story-dots { justify-content: center; }
  .tablet-screen .story-side .exp-btn-row { justify-content: center; }
  /* Цифровой ряд: на узком экране container-type снят, cqw мерялись бы от вьюпорта — задаём в px/rem */
  .tablet-screen .ds-head { font-size: 1.3rem; margin-bottom: 12px; }
  .tablet-screen .ds-meta { font-size: 0.72rem; margin-bottom: 14px; }
  .tablet-screen .ds-stage { height: 120px; margin-bottom: 12px; }
  .tablet-screen .ds-digit { font-size: 4.2rem; }
  .tablet-screen .ds-hint, .tablet-screen .ds-prompt { font-size: 1rem; margin-bottom: 20px; }
  .tablet-screen .ds-boxes { gap: 10px; margin-bottom: 22px; }
  .tablet-screen .ds-box { width: 52px; height: 62px; font-size: 1.7rem; border-radius: 12px; }
  .tablet-screen .ds-pad { max-width: 330px; gap: 8px; }
  .tablet-screen .ds-key { font-size: 1.25rem; padding: 14px 0; border-radius: 12px; }
  .tablet-screen .ds-key-back { font-size: 0.95rem; padding: 12px 0; }
  .tablet-screen .ds-feedback { font-size: 1.3rem; }
  .tablet-screen .ds-skip button { font-size: 0.72rem; }
}

.exp-sd-block-title { font-family: 'Literata', serif; font-size: 1rem; font-weight: 600; margin: 22px 0 3px; color: var(--navy); }
.exp-sd-block-subtitle { font-size: 0.78rem; color: var(--ink-faint); margin-bottom: 12px; }
.exp-sd-row { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.exp-sd-label-left { width: 130px; text-align: right; font-size: 0.82rem; color: var(--ink-soft); flex-shrink: 0; }
.exp-sd-label-right { width: 130px; text-align: left; font-size: 0.82rem; color: var(--ink-soft); flex-shrink: 0; }
.exp-sd-scale { display: flex; gap: 5px; flex: 1; justify-content: center; }
.exp-sd-circle {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line);
  cursor: pointer; transition: all 0.15s; background: var(--paper-high);
}
.exp-sd-circle:hover { border-color: var(--navy); background: var(--navy-tint); }
.exp-sd-circle.active { background: var(--navy); border-color: var(--navy); box-shadow: 0 3px 10px rgba(58,78,126,0.3); }

.exp-share-box {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; margin-bottom: 20px; text-align: left;
}
.exp-share-box h3 { font-size: 0.92rem; margin-bottom: 8px; }
.exp-share-box p { font-size: 0.83rem; color: var(--ink-soft); margin-bottom: 12px; line-height: 1.5; }
.exp-link-row { display: flex; gap: 8px; align-items: stretch; }

/* Блок итогового синопсиса в SD-панели */
.sd-synopsis-block {
  background: var(--terra-tint);
  border: 1px solid rgba(190,110,61,0.25);
  border-left: 3px solid var(--terra);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 22px;
}
.sd-synopsis-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: var(--terra);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 7px;
}
.sd-synopsis-text {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.65;
}

@media (max-width: 600px) {
  .exp-card { padding: 20px 14px; }
  .exp-card::before { top: 16px; bottom: 16px; }
  /* Методика (пошагово): компактнее кружки и подписи, вопрос крупный */
  .scale-question { font-size: 1.08rem; margin-bottom: 24px; }
  .scale-circles { gap: 4px; }
  .scale-c { gap: 7px; }
  .scale-c-dot { width: 30px; height: 30px; }
  .scale-c-label { font-size: 0.68rem; }
  .scale-ends span { font-size: 0.66rem; }
  /* SD: пары в две строки, крупные круги */
  .exp-sd-row { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 6px; margin-bottom: 18px; }
  .exp-sd-label-left { grid-column: 1; grid-row: 1; text-align: left; width: auto; }
  .exp-sd-label-right { grid-column: 2; grid-row: 1; text-align: right; width: auto; }
  .exp-sd-scale { grid-column: 1 / 3; grid-row: 2; gap: 7px; }
  .exp-sd-circle { width: 38px; height: 38px; }
  .exp-btn { width: 100%; padding: 14px 20px; }
  .exp-link-row { flex-direction: column; }
}

/* ===== DEV-НАВИГАЦИЯ ПО ЭКРАНАМ (localhost или секретный токен ?dbg= + пароль на /dev/) ===== */
#dev-nav {
  position: fixed; top: 0; left: 0; bottom: 0; width: 216px;
  background: rgba(46,40,32,0.96); border-right: 1px solid rgba(190,110,61,0.4);
  z-index: 9999; display: none; flex-direction: column;
  font-family: 'Golos Text', sans-serif;
  transition: transform 0.25s ease; box-shadow: 2px 0 16px rgba(46,40,32,0.35);
}
#dev-nav.collapsed { transform: translateX(-100%); }
/* Переключатель модели чата (отладка) */
#dev-model-pick { padding: 9px 10px 10px; border-bottom: 1px solid rgba(245,240,232,0.12); }
.dev-model-label { font-family: 'IBM Plex Mono', monospace; font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(245,240,232,0.5); margin-bottom: 6px; }
.dev-model-btns { display: flex; gap: 5px; }
.dev-model-btns button { flex: 1; padding: 6px 3px; font-size: 0.66rem; font-family: 'Golos Text', sans-serif; color: #F5F0E8; background: rgba(245,240,232,0.08); border: 1px solid rgba(245,240,232,0.18); border-radius: 7px; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.dev-model-btns button:hover { background: rgba(190,110,61,0.22); }
.dev-model-btns button.active { background: rgba(190,110,61,0.4); border-color: #BE6E3D; color: #fff; }
#dev-nav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 12px 14px; border-bottom: 1px solid rgba(245,240,232,0.12);
}
#dev-nav-head span {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(245,240,232,0.55);
}
/* Тоггл торчит наружу справа — виден и когда панель полностью спрятана */
#dev-nav-toggle {
  position: absolute; right: -38px; top: 10px;
  background: rgba(46,40,32,0.92); border: 1px solid rgba(245,240,232,0.3); color: #F5F0E8;
  width: 30px; height: 30px; border-radius: 0 8px 8px 0; cursor: pointer;
  font-size: 0.95rem; line-height: 1; flex-shrink: 0;
}
#dev-nav-toggle:hover { background: rgba(46,40,32,1); }
/* Поле поиска по карточкам */
#dev-nav-search-wrap { padding: 8px 10px; flex-shrink: 0; }
#dev-nav-search {
  width: 100%; box-sizing: border-box;
  background: rgba(245,240,232,0.07); border: 1px solid rgba(245,240,232,0.16);
  border-radius: 8px; color: #F5F0E8; font-family: 'Golos Text', sans-serif;
  font-size: 0.76rem; padding: 8px 10px; outline: none; transition: border-color 0.15s;
}
#dev-nav-search::placeholder { color: rgba(245,240,232,0.35); }
#dev-nav-search:focus { border-color: rgba(190,110,61,0.6); }

/* Список сцен занимает всю высоту и скроллится; полоса прокрутки невидима */
#dev-nav-list {
  display: flex; flex-direction: column; gap: 5px; padding: 12px 10px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  scrollbar-width: none;              /* Firefox */
  -ms-overflow-style: none;           /* старый Edge */
}
#dev-nav-list::-webkit-scrollbar { width: 0; height: 0; }   /* WebKit: невидимый скролл */
#dev-nav-list button {
  text-align: left; background: rgba(245,240,232,0.06); border: 1px solid rgba(245,240,232,0.14);
  color: #E8E0D2; padding: 8px 10px; border-radius: 8px; font-size: 0.78rem; cursor: pointer;
  font-family: 'Golos Text', sans-serif; transition: all 0.15s; line-height: 1.3;
  display: flex; align-items: flex-start; gap: 7px; width: 100%;
}
/* Номер страницы/подстраницы */
#dev-nav-list .npage {
  flex-shrink: 0; font-family: 'IBM Plex Mono', monospace; font-size: 0.6rem; font-weight: 500;
  background: rgba(245,240,232,0.1); color: rgba(245,240,232,0.72);
  border-radius: 5px; padding: 2px 5px; min-width: 22px; text-align: center;
}
#dev-nav-list .nested .npage { background: rgba(190,110,61,0.28); color: #F3D6C1; }
#dev-nav-list button.active .npage { background: rgba(255,255,255,0.25); color: #fff; }
#dev-nav-list .ntxt { flex: 1; min-width: 0; }
#dev-nav-list button:hover { background: rgba(190,110,61,0.22); border-color: rgba(190,110,61,0.55); color: #fff; }
#dev-nav-list button.active { background: rgba(190,110,61,0.35); border-color: #BE6E3D; color: #fff; }
/* Вложенные ветки выбора */
#dev-nav-list button.nested {
  margin-left: 12px; width: calc(100% - 12px); font-size: 0.72rem;
  background: rgba(245,240,232,0.03); border-color: rgba(245,240,232,0.09);
  border-left: 2px solid rgba(190,110,61,0.45); border-radius: 0 8px 8px 0;
  color: rgba(232,224,210,0.85);
}
/* Технический id узла и метка ветвления */
#dev-nav-list .nid {
  display: block; margin-top: 2px;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.56rem;
  color: rgba(245,240,232,0.38); letter-spacing: 0.02em;
}
#dev-nav-list .dev-branch {
  font-style: normal; font-family: 'IBM Plex Mono', monospace;
  font-size: 0.56rem; color: #BE6E3D; margin-left: 6px; white-space: nowrap;
}
.dev-nav-sep {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.58rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: rgba(245,240,232,0.35);
  padding: 10px 4px 3px; position: sticky; top: 0;
  background: rgba(46,40,32,0.96);
}
#dev-nav-note {
  padding: 8px 12px 12px; font-size: 0.65rem;
  color: rgba(245,240,232,0.32); line-height: 1.4; border-top: 1px solid rgba(245,240,232,0.1);
}
