/* ==========================================================================
   starstory.studio — тема «Мягкое облако»
   Накатывается ПОВЕРХ существующей вёрстки public/index.html.
   Разметку и JS менять не нужно: файл переопределяет переменные и классы,
   которые уже есть в проекте.

   Подключение — последней строкой в <head> index.html:
     <link rel="stylesheet" href="/assets/theme.css">
   (положить файл в public/assets/theme.css)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@400..700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400..700;1,8..60,400&display=swap');

:root {
  --primary: #6A5AB8;
  --primary-hover: #5A4DA0;
  --primary-light: #EDEAF8;
  --primary-border: #DFDCEC;
  --bg: #F7F6FC;
  --card-bg: #FFFFFF;
  --text: #2C2740;
  --text-muted: #5A5473;
  --text-hint: #6B6488;
  --border: #DFDCEC;
  --danger: #B33927;
  --danger-bg: #FDF2F0;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --font-ui: 'Comfortaa', sans-serif;
  --font-display: 'Source Serif 4', Georgia, serif;
  --shadow-btn: 0 12px 24px -12px rgba(90, 77, 168, .55);
  --shadow-card: 0 18px 40px -28px rgba(44, 39, 64, .35);
}

/* --- база ---------------------------------------------------------------- */
html {
  overflow-x: hidden;
  max-width: 100vw;
  box-sizing: border-box;
}
body {
  font-family: var(--font-ui) !important;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  max-width: 100vw;
  box-sizing: border-box;
}
.wrap, header.top { max-width: 1180px; margin: 0 auto; width: 100%; box-sizing: border-box; }

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.6rem;
  line-height: 1.1;
  letter-spacing: -.015em;
}
h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.6rem;
  color: var(--text);
  letter-spacing: -.01em;
}
.sub { color: var(--text-muted); font-size: 1.05rem; }
.hint { color: var(--text-hint); }

/* --- шапка --------------------------------------------------------------- */
.brand { font-family: var(--font-ui); font-weight: 700; color: var(--text); }
.lang-switcher { background: var(--primary-light); border-radius: 999px; }
.lang-btn { font-family: var(--font-ui); font-weight: 700; border-radius: 999px; }
.lang-btn.active { background: #fff; color: var(--text); }
.gift-badge {
  background: var(--primary-light);
  border: 0;
  color: #4A4270;
  border-radius: 999px;
  font-weight: 700;
}

/* --- карточки и поля ----------------------------------------------------- */
.card {
  background: var(--card-bg);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
label { font-family: var(--font-ui); font-weight: 700; color: var(--text-muted); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), select, textarea {
  font-family: var(--font-ui);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(106, 90, 184, .16);
  outline: 0;
}
::placeholder { color: #A9A2CC; }

/* --- кнопки -------------------------------------------------------------- */
button, .btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
button:hover, .btn:hover { background: var(--primary-hover); color: #fff; }
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn--ghost {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--text);
  box-shadow: none;
}
button.ghost:hover, .btn--ghost:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
button.mini, .btn.mini {
  padding: 7px 16px;
  font-size: 0.84rem;
  border-radius: 999px;
}
button:disabled, .btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}

/* --- загрузка фото ------------------------------------------------------- */
.dropzone {
  background: #fff;
  border: 2px dashed #D5CFEE;
  border-radius: var(--radius-lg);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.dropzone-title { color: var(--text); font-weight: 700; }
.dropzone-sub, .photo-count-badge { color: var(--text-muted); }
.thumb-card { border-radius: 18px; border: 1px solid var(--border); }
.thumb-card.main { border: 2.5px solid var(--primary); }
.thumb-card.main .thumb-badge { background: var(--primary); }
.thumb-badge { border-radius: 999px; font-family: var(--font-ui); font-weight: 700; }

/* --- сетка стилей -------------------------------------------------------- */
.styles-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.style-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}
.style-card:hover { border-color: #C9C1EC; box-shadow: var(--shadow-card); }
.style-card.selected { border: 2.5px solid var(--primary); box-shadow: none; }
.style-card-info { background: #fff; }
.style-card.selected .style-card-info { background: var(--primary-light); }
.style-card-name { font-family: var(--font-ui); font-weight: 700; color: var(--text); }
.btn-sample-book {
  background: var(--primary-light);
  color: #4A4270;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: none;
}
.btn-sample-book:hover { background: #DDD7F2; }
.gender-toggle-btn {
  background: var(--primary-light);
  color: var(--text-muted);
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: none;
}
.gender-toggle-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(44,39,64,.16); }
.mini-gender-btn { border-radius: 999px; }
.mini-gender-btn.active { background: var(--primary); color: #fff; }
.style-card-check { background: var(--primary); }
.style-card-custom-preview { background: var(--primary-light); color: #6B6488; }

/* --- шаги и прогресс (Stepper) ----------------------------------------------------- */
.progress-stepper {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 12px !important;
  position: static !important;
}
.step-node {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-direction: row !important;
}
.step-circle {
  width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  background: var(--primary-light) !important;
  color: var(--text-hint) !important;
  font-family: var(--font-ui) !important;
  font-weight: 700 !important;
  font-size: 11px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}
.step-node.active .step-circle { background: var(--primary) !important; color: #fff !important; }
.step-node.done .step-circle { background: #5E9E7E !important; color: #fff !important; }
.step-label { font-family: var(--font-ui) !important; font-weight: 600 !important; font-size: 13px !important; color: #7B759B !important; white-space: nowrap !important; }
.step-node.active .step-label { color: var(--text) !important; font-weight: 600 !important; }
.step-line {
  width: 40px !important;
  height: 2px !important;
  background: #E4E0F2 !important;
  flex: none !important;
  margin: 0 !important;
}
.step-line.active { background: var(--primary) !important; }
.progress-bar-wrap { background: var(--primary-light); border-radius: 999px; }
.progress-bar-fill { background: var(--primary); border-radius: 999px; }
.progress-status-text { font-family: var(--font-ui); color: var(--text-muted); font-weight: 600; }

/* --- Сетка шага 1 (две колонки) --- */
.step-cols-grid {
  display: grid !important;
  grid-template-columns: 1.55fr 1fr !important;
  gap: 28px !important;
  align-items: start !important;
  margin-top: 24px !important;
}
.step-left-col {
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}
.step-right-col {
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
}
.right-step-card {
  margin-bottom: 0 !important;
  padding: 22px 24px !important;
  border-radius: 20px !important;
  background: #FFFFFF !important;
  border: 0 !important;
}

/* --- Строка инпутов --- */
.row {
  display: flex !important;
  gap: 14px !important;
  align-items: flex-end !important;
  width: 100% !important;
}
.row > div {
  min-width: 0 !important;
}

/* --- Единый белый холст приложения --- */
.app-canvas {
  background: #F7F6FC !important;
  border: 1px solid #DFDCEC !important;
  border-radius: 20px !important;
  box-shadow: none !important;
  padding: 36px !important;
  margin: 16px auto 40px !important;
  max-width: 1180px !important;
  width: 100% !important;
}

.hidden {
  display: none !important;
}

/* --- Переключатели плашками (Pill Selectors) --- */
.pill-selector {
  display: inline-flex;
  background: var(--primary-light);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.pill-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: none;
  margin: 0;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}
.pill-btn.active {
  background: #FFFFFF;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(44, 39, 64, 0.12);
}
.pill-btn.primary-active.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(106, 90, 184, 0.35);
}

/* --- Переключатель Toggle Switch --- */
.switch-label {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  cursor: pointer;
}
.switch-label input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background-color: #DFDCEC;
  border-radius: 28px;
  transition: .25s ease;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  border-radius: 50%;
  transition: .25s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
input:checked + .switch-slider {
  background-color: var(--primary);
}
input:checked + .switch-slider:before {
  transform: translateX(22px);
}

/* --- Карточки тем (Шаг 2) --- */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.theme-card-pill {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1.5px solid var(--border);
  background: #FFFFFF;
  cursor: pointer;
  transition: all 0.18s ease;
}
.theme-card-pill:hover {
  border-color: #C4B9F0;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -6px rgba(106, 90, 184, 0.15);
}
.theme-card-pill.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}
.theme-card-pill b {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--text);
}
.theme-card-pill span {
  font-size: 0.78rem;
  color: var(--text-hint);
  line-height: 1.35;
  display: block;
}

/* --- Тёмный экран генерации --- */
/* Экран генерации в прототипе — сам себе рамка: снимаем внешнюю сиреневую. */
.app-canvas:has(> #view-create > #progress:not(.hidden)) {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

.gen-dark-container {
  background: #2C2740;
  border-radius: 20px;
  padding: 52px 40px;
  color: #F7F6FC;
  text-align: center;
  box-shadow: none;
}
.gen-dark-stages {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 32px 0 28px;
}
.gen-dark-stage {
  padding: 20px;
  border-radius: 18px;
  background: rgba(55, 49, 80, .5);
  border: 1px solid #443C63;
  text-align: left;
  transition: all 0.25s ease;
}
.gen-dark-stage.active {
  border-color: #A999F0 !important;
  background: rgba(75, 62, 125, .65) !important;
  box-shadow: 0 0 24px -2px rgba(138, 119, 226, 0.55), inset 0 0 16px rgba(138, 119, 226, 0.2) !important;
  animation: pulseStageActive 2.2s infinite ease-in-out;
}
@keyframes pulseStageActive {
  0%, 100% { transform: scale(1); border-color: #8A77E2; }
  50% { transform: scale(1.02); border-color: #C5B8FB; box-shadow: 0 0 32px rgba(138, 119, 226, 0.75); }
}
@keyframes bounceStageIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes floatSparkle {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.85; }
  50% { transform: translateY(-5px) scale(1.1); opacity: 1; }
}
.progress-bar-fill {
  position: relative;
  background: linear-gradient(90deg, #8A77E2 0%, #E2DCF8 50%, #8A77E2 100%) !important;
  background-size: 200% 100% !important;
  animation: genBarShimmer 2.2s infinite linear;
  box-shadow: 0 0 16px rgba(138, 119, 226, 0.7);
  border-radius: 999px;
  transition: width 0.4s ease;
  overflow: hidden;
}
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-100%);
  animation: genBarGlint 1.8s infinite linear;
}
@keyframes genBarGlint {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes genBarShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.live-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 2px;
  vertical-align: baseline;
}
.live-dots span {
  display: inline-block;
  font-weight: 800;
  animation: liveDotBlink 1.4s infinite both;
  color: inherit;
}
.live-dots span:nth-child(2) { animation-delay: 0.22s; }
.live-dots span:nth-child(3) { animation-delay: 0.44s; }
@keyframes liveDotBlink {
  0%, 80%, 100% { opacity: 0.2; transform: translateY(0) scale(0.85); }
  40% { opacity: 1; transform: translateY(-2px) scale(1.2); }
}
.gen-dark-stage.active b { color: #C4B9F0; }
.gen-dark-stage.done { border-color: #4A4270; }
.gen-dark-stage.done b {
  color: #A9E0C6;
}
.gen-dark-stage b {
  font-size: 0.95rem;
  display: block;
  margin-bottom: 4px;
  color: #6E6795;
}
.gen-dark-stage span {
  font-size: 0.8rem;
  color: #6E6795;
}
.gen-dark-stage.active span, .gen-dark-stage.done span { color: #9A94BE; }

/* --- Аккордеон FAQ --- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.faq-item {
  background: #FFFFFF;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s ease;
}
.faq-question {
  padding: 18px 22px;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: var(--text);
  user-select: none;
}
.faq-question:hover {
  color: var(--primary);
}
.faq-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}
.faq-item.open .faq-icon {
  transform: rotate(45deg);
  background: var(--primary);
  color: #FFFFFF;
}
.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 22px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}
.faq-item.open .faq-answer {
  max-height: 300px;
  padding: 0 22px 20px;
}

/* --- Анимации появления (Scroll / Fade) --- */
.animate-fade-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

.card-interactive {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -15px rgba(44, 39, 64, 0.15);
}

/* --- Сплит-модалка авторизации --- */
.two-col-modal {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: #FFFFFF;
  border-radius: 28px;
  overflow: hidden;
  max-width: 860px;
  width: 95%;
  margin: auto;
  box-shadow: 0 30px 80px -20px rgba(44, 39, 64, 0.4);
}
.modal-auth-left {
  padding: 36px 36px 28px;
}
.modal-auth-right {
  background: #5B4DA8;
  color: #FFFFFF;
  padding: 44px 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.modal-auth-right h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.25;
  color: #FFFFFF;
  margin-bottom: 14px;
}
.modal-auth-right p {
  color: #DDD7F6;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* --- Разворот готовой книги (Book Spread Viewer) --- */
.book-spread-wrap {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 28px;
  background: #FAF9FE;
  border: 1px solid #EDEAF8;
  border-radius: 24px;
  padding: 32px;
  margin: 24px 0 16px;
  align-items: center;
}
.spread-img-box {
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 35px -15px rgba(44, 39, 64, 0.2);
  background: #EDEAF8;
}
.spread-img-box img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}
.spread-text-card {
  background: #FFFFFF;
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 14px 35px -20px rgba(44, 39, 64, 0.1);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.spread-text-content {
  font-family: var(--font-display);
  font-size: 1.45rem;
  line-height: 1.7;
  color: var(--text);
}
.spread-page-num {
  font-size: 0.85rem;
  color: var(--text-hint);
  font-family: var(--font-ui);
  font-weight: 600;
  margin-top: 20px;
}

/* --- Адаптивность для планшетов и мобильных (<= 768px) --- */
@media (max-width: 768px) {
  .step-cols-grid, .themes-grid, .gen-dark-stages {
    grid-template-columns: 1fr !important;
  }
  .two-col-modal {
    grid-template-columns: 1fr !important;
    width: 95% !important;
    max-width: 440px !important;
    border-radius: 20px !important;
  }
  .modal-auth-right {
    display: none !important;
  }
  .modal-auth-left {
    padding: 24px 18px !important;
  }
  .app-canvas {
    padding: 20px 14px !important;
    border-radius: 18px !important;
    margin: 12px 0 24px !important;
  }
  .book-spread-wrap {
    grid-template-columns: 1fr !important;
    padding: 16px !important;
    gap: 16px !important;
    border-radius: 18px !important;
    margin: 12px 0 !important;
  }
  .spread-text-card {
    padding: 20px 16px !important;
    min-height: auto !important;
    border-radius: 16px !important;
  }
  .spread-text-content {
    font-size: 1.15rem !important;
    line-height: 1.6 !important;
  }
  .wrap {
    padding: 0 14px !important;
  }
}

/* --- Мобильная оптимизация под узкие экраны (<= 480px / 360-390px) --- */
@media (max-width: 480px) {
  .app-canvas {
    padding: 16px 10px !important;
    border-radius: 16px !important;
  }
  .wrap {
    padding: 0 10px !important;
  }
  /* Исключение авто-зума на iOS при фокусе в инпуты */
  input, select, textarea {
    font-size: 16px !important;
  }
  /* Оптимизация тач-взаимодействия и быстрый тап без 300ms delay */
  button, a.btn, .pill-btn, .lang-btn, [role="button"] {
    touch-action: manipulation;
  }
  .two-col-modal {
    width: 96% !important;
    margin: 10px auto !important;
    border-radius: 18px !important;
  }
  .modal-auth-left {
    padding: 20px 14px !important;
  }
}
.spread-pager {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.spread-thumb-item {
  width: 44px;
  height: 52px;
  border-radius: 12px;
  border: 1.5px solid #DFDCEC;
  background: #FFFFFF;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.18s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spread-thumb-item.active {
  border: 2.5px solid var(--primary);
  box-shadow: 0 4px 12px rgba(106, 90, 184, 0.35);
  transform: translateY(-2px);
}
.spread-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Сетка библиотеки книг (Книжная полка) --- */
.mybooks-grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 28px;
  align-items: stretch;
}

/* --- Карточка книги (Hardcover Book) --- */
.book-card-item {
  background: #FFFFFF;
  border-radius: 16px 20px 20px 16px;
  overflow: hidden;
  border: 1.5px solid #DFDCEC;
  box-shadow: 0 12px 28px -10px rgba(44, 39, 64, 0.16), 0 2px 6px rgba(44, 39, 64, 0.05);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}

.book-card-item:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 24px 48px -12px rgba(44, 39, 64, 0.28), 0 4px 14px rgba(106, 90, 184, 0.18);
}

/* Обложка в портретном формате 3:4 с эффектом твердого переплета и корешка */
.book-card-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #EDEAF8;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid #EDEAF8;
}

.book-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.book-card-item:hover .book-card-cover img {
  transform: scale(1.04);
}

/* Корешок твердого переплета (книжная фаска и перегиб слева) */
.book-card-cover::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 28px;
  background: linear-gradient(90deg, 
    rgba(0, 0, 0, 0.35) 0%, 
    rgba(0, 0, 0, 0.12) 6%, 
    rgba(255, 255, 255, 0.35) 12%, 
    rgba(255, 255, 255, 0.1) 18%, 
    rgba(0, 0, 0, 0.12) 24%, 
    transparent 100%);
  pointer-events: none;
  z-index: 3;
}

/* Золотистая/глянцевая окантовка обложки */
.book-card-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  pointer-events: none;
  z-index: 2;
}

.book-card-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #FFFFFF;
  flex: 1;
  justify-content: space-between;
}

.book-card-body b {
  font-size: 1rem;
  font-family: var(--font-ui);
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
  line-height: 1.35;
  margin: 0;
}

.book-card-body span {
  font-size: 0.82rem;
  color: var(--text-hint);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.draft-card-item {
  border: 2px dashed #C9C1EC;
  background: #FAF9FE;
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 240px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.draft-card-item:hover {
  border-color: var(--primary);
  background: #FFFFFF;
  transform: translateY(-4px);
}

/* --- Карточки персонажей в профиле и сайдбаре --- */
.child-badge {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 12px !important;
  border-radius: 14px !important;
  border: 1.5px solid #EDEAF8 !important;
  background: #FFFFFF !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
  position: relative !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  color: var(--text) !important;
}
.child-badge:hover {
  border-color: #C4B9F0 !important;
  background: #FAF9FE !important;
}
.child-badge.selected {
  border-color: var(--primary) !important;
  background: #EDEAF8 !important;
  box-shadow: 0 2px 8px rgba(106, 90, 184, 0.2) !important;
}
.child-badge-avatar {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block !important;
  border: 1.5px solid #DFDCEC !important;
}
.child-badge-delete {
  margin-left: auto !important;
  color: #A9A2CC !important;
  padding: 2px 6px !important;
  border-radius: 50% !important;
  font-size: 0.85rem !important;
  cursor: pointer !important;
}
.child-badge-delete:hover {
  color: var(--danger) !important;
  background: #FDF2F0 !important;
}




/* --- восстановлено из дизайн-пакета handoff3/theme.css (FIXES-1) --------- */
/* Ожидающие страницы: изображение уже есть, но ещё размыто */
.blur-target.blurred { filter: blur(10px) saturate(.75); }
.blur-overlay-box { background: rgba(44, 39, 64, .55); border-radius: var(--radius-md); }
.blur-overlay-title { font-family: var(--font-ui); font-weight: 700; color: #fff; }
.blur-spinner-circle { border-top-color: #C4B9F0; }

/* --- модалки, вкладки, книги --------------------------------------------- */
.modal { background: rgba(44, 39, 64, .7); }
.modal .box, .sample-modal-box {
  background: var(--bg);
  border: 0;
  border-radius: 24px;
  box-shadow: 0 30px 70px -30px rgba(44, 39, 64, .6);
}
.sample-modal-header { border-bottom: 1px solid var(--border); }
.sample-modal-title { font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; }
.sample-modal-frame { background: var(--primary-light); border-radius: var(--radius-md); }
.tabs button { background: var(--primary-light); color: var(--text-muted); box-shadow: none; }
.tabs button.act { background: var(--primary); color: #fff; }
.bookcard { border: 0; border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-card); overflow: hidden; }
.bookcard .t { font-family: var(--font-ui); font-weight: 700; }
.bookcard .d { color: var(--text-hint); }
.userchip { background: var(--primary-light); border-radius: 999px; color: #4A4270; font-weight: 700; }
.savebox { background: var(--primary-light); border-radius: var(--radius-md); }
.toy-card, .child-badge { border-radius: 18px; border: 1px solid var(--border); background: #fff; }
.child-badge.selected { border: 2px solid var(--primary); background: var(--primary-light); }
a.dl, a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* --- текст книги: чтение по слогам --------------------------------------- */
.book-text, .syllable-text {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.75;
  color: #38325A;
}

/* --- Волшебный лоадер ожидания генерации сюжета --- */
.outline-magic-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  padding: 30px 16px;
  width: 100%;
  box-sizing: border-box;
}
.outline-magic-loader.hidden {
  display: none !important;
}
.magic-loader-card {
  background: linear-gradient(135deg, #2D2256 0%, #3D2C78 50%, #201740 100%);
  color: #FFFFFF;
  border: 1.5px solid rgba(222, 216, 246, 0.3);
  border-radius: 28px;
  padding: 42px 28px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px -12px rgba(44, 34, 85, 0.5);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.magic-sparkle-anim {
  font-size: 2.2rem;
  animation: floatSparkle 2s ease-in-out infinite;
  margin-bottom: 4px;
}
.magic-book-pulse {
  font-size: 3.2rem;
  margin-bottom: 16px;
  display: inline-block;
  animation: pulseBook 2s infinite ease-in-out;
}
@keyframes pulseBook {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(-3deg); }
}
.magic-loader-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 10px;
  color: #FFFFFF;
}
.magic-loader-sub {
  color: #D3CCF0;
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 24px;
}
.magic-loader-progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
  position: relative;
}
.magic-loader-progress-shimmer {
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, #8A77E2 0%, #F5F2FF 50%, #8A77E2 100%);
  border-radius: 999px;
  animation: magicShimmer 1.8s infinite ease-in-out;
}
@keyframes magicShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.magic-status-ticker {
  font-size: 0.88rem;
  color: #E2DCF8;
  font-weight: 600;
  min-height: 22px;
  transition: opacity 0.2s ease;
}

/* --- Анимация перегенерации иллюстрации в приложении --- */
.regen-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 4px 6px;
}
.regen-anim-container {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.regen-anim-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(106, 90, 184, 0.4);
  animation: regen-pulse-ring 2.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
.regen-anim-pulse-ring.delay-1 {
  animation-delay: 0.75s;
}
.regen-anim-pulse-ring.delay-2 {
  animation-delay: 1.5s;
}
.regen-anim-badge {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C6BC8 0%, #5746A2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(106, 90, 184, 0.35);
  position: relative;
  z-index: 2;
  animation: regen-float-icon 2.4s ease-in-out infinite;
}
.regen-anim-icon {
  font-size: 1.7rem;
  display: inline-block;
  animation: regen-brush-wiggle 1.8s ease-in-out infinite;
}
.regen-sparkle {
  position: absolute;
  font-size: 1.1rem;
  z-index: 3;
  pointer-events: none;
}
.regen-sparkle.s1 {
  top: -4px;
  right: 6px;
  animation: regen-sparkle-float 2.2s ease-in-out infinite;
}
.regen-sparkle.s2 {
  bottom: 2px;
  left: 4px;
  animation: regen-sparkle-float 2.5s ease-in-out infinite 0.6s;
}
.regen-sparkle.s3 {
  top: 14px;
  left: -8px;
  font-size: 0.9rem;
  animation: regen-sparkle-float 2.8s ease-in-out infinite 1.2s;
}
@keyframes regen-pulse-ring {
  0% { transform: scale(0.65); opacity: 0.9; }
  50% { opacity: 0.5; }
  100% { transform: scale(1.45); opacity: 0; }
}
@keyframes regen-float-icon {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.03); }
}
@keyframes regen-brush-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(12deg); }
}
@keyframes regen-sparkle-float {
  0%, 100% { transform: scale(0.7) translateY(0); opacity: 0.3; }
  50% { transform: scale(1.15) translateY(-6px); opacity: 1; }
}
.regen-loading-title {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text, #2C2740);
  margin-bottom: 6px;
}
.regen-loading-step {
  font-size: 0.88rem;
  color: #625C7E;
  min-height: 24px;
  line-height: 1.4;
  margin-bottom: 16px;
  transition: opacity 0.3s ease;
}
.regen-progress-track {
  width: 100%;
  height: 8px;
  background: #EDE8F5;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.regen-progress-bar {
  height: 100%;
  width: 8%;
  background: linear-gradient(90deg, #6A5AB8, #8E7CDE, #6A5AB8);
  background-size: 200% 100%;
  border-radius: 999px;
  animation: regen-shimmer 1.8s linear infinite;
  transition: width 0.35s ease-out;
}
@keyframes regen-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.regen-progress-meta {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 0.78rem;
  color: #8C84A6;
  font-weight: 600;
}

/* --- Profile modal navigation tabs (segmented control) --- */
.profile-nav-tabs {
  display: flex;
  background: #F0EDF8;
  padding: 5px;
  border-radius: 16px;
  border: 1px solid #DFD9F2;
  box-shadow: inset 0 2px 4px rgba(44, 39, 64, 0.04);
  margin-bottom: 24px;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  -webkit-overflow-scrolling: touch;
}
.profile-nav-tabs::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.profile-nav-tab {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, #716982);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  user-select: none;
  text-align: center;
}

.profile-nav-tab:hover {
  color: var(--text, #2D2538);
  background: rgba(255, 255, 255, 0.65);
}

.profile-nav-tab.act {
  background: #FFFFFF !important;
  color: var(--primary, #6A5AB8) !important;
  border-color: rgba(106, 90, 184, 0.16) !important;
  box-shadow: 0 4px 14px -2px rgba(106, 90, 184, 0.18), 0 2px 4px rgba(44, 39, 64, 0.05) !important;
}

.profile-nav-tabs .tab-text-short {
  display: none;
}
.profile-nav-tabs .tab-text-full {
  display: inline;
}

@media (max-width: 720px) {
  .profile-nav-tabs .tab-text-full {
    display: none;
  }
  .profile-nav-tabs .tab-text-short {
    display: inline;
  }
  .profile-nav-tab {
    padding: 8px 6px;
    font-size: 0.88rem;
    gap: 4px;
  }
}

