/* Lumby: локальные шрифты (замена Google Fonts, убран 05.12.2026) */
@font-face{font-family:'Dancing Script';src:url('/static/fonts/DancingScript-Regular.ttf') format('truetype');font-weight:400;font-style:normal;font-display:swap;}
@font-face{font-family:'Dancing Script';src:url('/static/fonts/DancingScript-Bold.ttf') format('truetype');font-weight:700;font-style:normal;font-display:swap;}
@font-face{font-family:'Comfortaa';src:url('/static/fonts/Comfortaa-Regular.ttf') format('truetype');font-weight:400;font-style:normal;font-display:swap;}
@font-face{font-family:'Comfortaa';src:url('/static/fonts/Comfortaa-Medium.ttf') format('truetype');font-weight:500;font-style:normal;font-display:swap;}
@font-face{font-family:'Comfortaa';src:url('/static/fonts/Comfortaa-SemiBold.ttf') format('truetype');font-weight:600;font-style:normal;font-display:swap;}
@font-face{font-family:'Comfortaa';src:url('/static/fonts/Comfortaa-Bold.ttf') format('truetype');font-weight:700;font-style:normal;font-display:swap;}

/* ═══════════════════════════════════════════════════════
   LUMBY — Волшебные сказки на ночь
   Cosmic Dark Design System
═══════════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────────────────── */
:root {
  --bg:           #110F14;
  --card:         #1a1828;
  --card2:        #201e30;
  --primary:      #E59A52;
  --primary-lt:   #F5B971;
  --secondary:    #7CA982;
  --text:         #F4ECE1;
  --text-muted:   #9A8F88;
  --border:       rgba(229,154,82,0.18);
  --border-soft:  rgba(255,255,255,0.06);
  --nav-h:        70px;
  --radius:       18px;
  --radius-sm:    12px;
  --tr:           0.2s ease;
  /* iOS safe-area: отступы под вырез, кнопку-индиктор и нижнюю полосу */
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}


/* ── Android tap-highlight fix ──────────────────────── */
.chip,
.chip-sm,
.mood-chip,
.child-chip,
.btn-tired,
.advanced-toggle,
.series-card,
.tale-card,
.icon-btn,
button {
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none;
  outline: none;
}

html { height: 100%; }

body {
  height: 100%;
  font-family: 'Comfortaa', cursive;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  display: flex;
  justify-content: center;
}

/* ── App Shell ───────────────────────────────────────── */
#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  /* iOS: не подрезать контент под вырезом/Dynamic Island сверху */
  padding-top: var(--sa-top);
}

#stars-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── Screens ─────────────────────────────────────────── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--sa-bottom));
  z-index: 1;
  overflow: hidden;
  display: none;
}

.screen.active {
  display: block;
}

.scroll-area {
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 16px;
}
/* Скрываем скроллбар визуально, но оставляем функциональность */
.scroll-area::-webkit-scrollbar { width: 0; height: 0; }
.scroll-area { scrollbar-width: none; }

/* ── Logo ────────────────────────────────────────────── */
.home-header {
  text-align: center;
  padding: 28px 0 16px;
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.logo-text {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: 46px;
  color: #FFD966;
  display: inline-block;
  text-shadow:
    0 0 8px  rgba(255,217,102,0.9),
    0 0 22px rgba(255,217,102,0.55),
    0 0 55px rgba(255,217,102,0.25);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%,100% {
    text-shadow:
      0 0 8px  rgba(255,217,102,0.9),
      0 0 22px rgba(255,217,102,0.55),
      0 0 55px rgba(255,217,102,0.25);
  }
  50% {
    text-shadow:
      0 0 14px rgba(255,217,102,1),
      0 0 38px rgba(255,217,102,0.75),
      0 0 90px rgba(255,217,102,0.4);
  }
}

.logo-moon {
  font-size: 18px;
  animation: moonWobble 4s ease-in-out infinite;
}
@keyframes moonWobble {
  0%,100% { transform: rotate(-10deg) scale(1); }
  50%      { transform: rotate(10deg)  scale(1.15); }
}

.logo-sub {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.4px;
  margin-top: 4px;
}

/* ── Stats Banner ────────────────────────────────────── */
.stats-banner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.stat-cell {
  flex: 1;
  text-align: center;
  position: relative;
}

.stat-sep {
  width: 1px;
  height: 46px;
  background: var(--border);
  flex-shrink: 0;
}

.stat-num {
  display: block;
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.stat-lbl {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-fire {
  display: block;
  font-size: 16px;
  margin-top: 3px;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  color: #fff;
  font-family: 'Comfortaa', cursive;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  box-shadow: 0 6px 24px rgba(229,154,82,0.42);
  transition: transform var(--tr), box-shadow var(--tr);
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 3px 12px rgba(229,154,82,0.3);
}

.btn-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 60%, transparent 70%);
  background-size: 200% 100%;
  background-position: -100% 0;
  animation: btnShine 2.5s ease-in-out infinite 1s;
}
@keyframes btnShine {
  0%   { background-position: -100% 0; }
  60%  { background-position: 200%  0; }
  100% { background-position: 200%  0; }
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--secondary);
  color: var(--secondary);
  border-radius: var(--radius);
  padding: 12px 24px;
  font-family: 'Comfortaa', cursive;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--tr);
}
.btn-outline:active {
  transform: scale(0.97);
  background: rgba(124,169,130,0.1);
}

/* ── Section Row ─────────────────────────────────────── */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
}
.section-link {
  font-size: 13px;
  color: var(--primary-lt);
  cursor: pointer;
}

/* ── Tale Cards ──────────────────────────────────────── */
.tales-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.tale-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform var(--tr), background var(--tr);
}
.tale-card:active {
  transform: scale(0.98);
  background: var(--card2);
}

.tale-emoji { font-size: 26px; flex-shrink: 0; }
.tale-info  { flex: 1; min-width: 0; }
.tale-name  {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.tale-meta  { font-size: 11px; color: var(--text-muted); }

.tale-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}
.tale-badge.calm    { background: rgba(229,154,82,0.18); color: var(--primary-lt); }
.tale-badge.fun     { background: rgba(124,169,130,0.18);  color: var(--secondary); }
.tale-badge.brave   { background: rgba(74,222,128,0.18);  color: #4ade80; }
.tale-badge.magic   { background: rgba(248,196,113,0.18); color: #f8c471; }

/* ── Quote ───────────────────────────────────────────── */
.quote-card {
  background: linear-gradient(135deg, rgba(229,154,82,0.12), rgba(245,185,113,0.05));
  border: 1px solid rgba(229,154,82,0.25);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.quote-star { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.quote-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.65;
  font-style: italic;
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  padding: 22px 0 16px;
}
.page-title {
  display: block;
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Form ────────────────────────────────────────────── */
.form-block {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Comfortaa', cursive;
  font-size: 15px;
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(229,154,82,0.15);
}

/* ── Chips ───────────────────────────────────────────── */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips-row.small { gap: 7px; }

.chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-family: 'Comfortaa', cursive;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--tr);
}
.chip:active { transform: scale(0.94); }
.chip.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 12px rgba(229,154,82,0.4);
}

.chip-sm {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(229,154,82,0.08);
  color: var(--text-muted);
  font-family: 'Comfortaa', cursive;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--tr);
}
.chip-sm:active { transform: scale(0.94); }
.chip-sm.active {
  background: rgba(229,154,82,0.28);
  border-color: var(--primary);
  color: var(--primary-lt);
}

/* ── Mood Grid ───────────────────────────────────────── */
.mood-chip {
  padding: 13px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-family: 'Comfortaa', cursive;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--tr);
}
.mood-chip:active { transform: scale(0.96); }
.mood-chip.active {
  background: linear-gradient(135deg, rgba(229,154,82,0.22), rgba(245,185,113,0.12));
  border-color: var(--primary);
  color: var(--primary-lt);
}

/* ── Accordion ───────────────────────────────────────── */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.acc-item {
  background: var(--card);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--tr);
}
.acc-item.open {
  border-color: var(--primary);
}

.acc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  cursor: pointer;
  user-select: none;
  transition: background var(--tr);
}
.acc-head:active { background: rgba(229,154,82,0.07); }

.acc-emoji { font-size: 17px; flex-shrink: 0; }
.acc-title {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.acc-arrow {
  font-size: 18px;
  color: var(--text-muted);
  display: inline-block;
  transition: transform 0.28s ease;
}
.acc-item.open .acc-arrow { transform: rotate(90deg); }

.acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s ease;
}
.acc-item.open .acc-body { max-height: 300px; }

.acc-body .chips-row {
  padding: 2px 15px 14px;
}

/* ── Slider ──────────────────────────────────────────── */
.slider-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.range-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  box-shadow: 0 2px 10px rgba(229,154,82,0.55);
  cursor: pointer;
}

.slider-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-lt);
  white-space: nowrap;
  min-width: 64px;
  text-align: right;
}

/* ── Preview ─────────────────────────────────────────── */
.preview-card {
  background: linear-gradient(135deg, rgba(229,154,82,0.1), rgba(124,169,130,0.06));
  border: 1px dashed rgba(229,154,82,0.38);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 0;
}
.preview-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary-lt);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 8px;
}
.preview-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}

/* ── Stats 4-grid ────────────────────────────────────── */
.stats-4grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat4-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  overflow: hidden;
}
.stat4-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(229,154,82,0.07), transparent);
}
.stat4-icon {
  font-size: 20px;
  margin-bottom: 2px;
}
.stat4-num {
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}
.stat4-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Bar Chart ───────────────────────────────────────── */
.chart-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.chart-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
}
.chart-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bars-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 5px;
  height: 96px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 3px;
}
.bar-val {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.4s 0.5s;
}
.bar-val.vis { opacity: 1; }

.bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, var(--primary), var(--primary-lt));
  height: 0;
  transition: height 0.75s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}
.bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 35%;
  background: rgba(255,255,255,0.14);
  border-radius: 4px 4px 0 0;
}
.bar.today {
  background: linear-gradient(to top, #e8954a, var(--secondary));
}

.bars-days {
  display: flex;
  justify-content: space-between;
  padding-top: 7px;
  border-top: 1px solid var(--border-soft);
  margin-top: 2px;
}
.bars-days span {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
}

/* ── Themes List ─────────────────────────────────────── */
.themes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.theme-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.theme-ico  { font-size: 17px; flex-shrink: 0; }
.theme-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  min-width: 128px;
  flex-shrink: 0;
}
.theme-track {
  flex: 1;
  height: 6px;
  background: var(--card);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.theme-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-lt));
  border-radius: 3px;
  width: 0;
  transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.theme-cnt {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-lt);
  min-width: 18px;
  text-align: right;
}

/* ── Achievements ────────────────────────────────────── */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 20px;
}
.ach-card {
  background: var(--card);
  border: 1.5px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px 8px 12px;
  text-align: center;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}
.ach-card.unlocked {
  border-color: rgba(232,149,74,0.5);
  background: linear-gradient(160deg, rgba(232,180,80,0.12), rgba(229,154,82,0.08));
  box-shadow: 0 0 18px rgba(232,180,80,0.15), inset 0 1px 0 rgba(255,255,255,0.05);
}
.ach-card.unlocked .ach-icon {
  filter: drop-shadow(0 0 6px rgba(232,180,80,0.5));
}
.ach-card.unlocked .ach-name {
  color: var(--secondary);
}
.ach-card.unlocked::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9px;
  color: var(--secondary);
  font-weight: 700;
}
.ach-card.locked {
  opacity: 0.4;
  filter: grayscale(0.8) brightness(0.7);
}
.ach-card.locked .ach-icon {
  font-size: 26px;
  filter: blur(0.5px);
}
.ach-icon { font-size: 28px; margin-bottom: 8px; display: block; }
.ach-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.35;
}
.ach-progress {
  margin-top: 6px;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.ach-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), #f5d278);
  border-radius: 2px;
  transition: width 1s ease;
}


/* ── Series episodes list ───────────────────────────── */
.series-episodes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.series-episode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--tr);
}
.series-episode:active {
  background: rgba(229,154,82,0.1);
}
.series-ep-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-lt);
  min-width: 20px;
}
.series-ep-title {
  font-size: 13px;
  color: var(--text);
}
/* ── Achievement sub-counter ────────────────────────── */
.ach-sub {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Profile Card ────────────────────────────────────── */
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.child-avatar {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(229,154,82,0.45);
}

.profile-info { flex: 1; }
.profile-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 3px;
}
.profile-meta { font-size: 12px; color: var(--text-muted); }

.edit-btn {
  background: rgba(229,154,82,0.14);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: all var(--tr);
}
.edit-btn:active { transform: scale(0.94); }

/* ── Settings Block ──────────────────────────────────── */
.settings-block {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.settings-block-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 13px;
}

/* ── Toggle Switch ───────────────────────────────────── */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.toggle-info { flex: 1; }
.toggle-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}
.toggle-desc { font-size: 11px; color: var(--text-muted); }

.tog {
  position: relative;
  width: 48px; height: 26px;
  display: inline-block;
  flex-shrink: 0;
  cursor: pointer;
}
.tog input { opacity: 0; width: 0; height: 0; }
.tog-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.08);
  border-radius: 13px;
  transition: background 0.3s;
}
.tog-track::before {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.3s;
}
.tog input:checked + .tog-track {
  background: var(--primary);
}
.tog input:checked + .tog-track::before {
  left: calc(100% - 23px);
  background: #fff;
}

/* ── App Info ────────────────────────────────────────── */
.app-info {
  text-align: center;
  padding: 20px 0 10px;
}
.app-logo-sm {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: 30px;
  color: #FFD966;
  text-shadow: 0 0 18px rgba(255,217,102,0.55);
  margin-bottom: 6px;
}
.app-ver { font-size: 12px; color: var(--text-muted); }

/* ── Contact Buttons ─────────────────────────────────── */
.contact-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}
.contact-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Comfortaa', cursive;
  font-size: 13px;
  font-weight: 700;
  transition: transform var(--tr), opacity var(--tr);
}
.contact-btn:active { transform: scale(0.96); }
.contact-btn.tg {
  background: linear-gradient(135deg, #2baadf, #1a8fc0);
  color: #fff;
  box-shadow: 0 4px 16px rgba(43,170,223,0.35);
}
.contact-btn.email {
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

/* ── FAQ ─────────────────────────────────────────────── */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.faq-item {
  background: var(--card);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--tr);
}
.faq-item.open { border-color: var(--primary); }

.faq-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 15px;
  cursor: pointer;
  gap: 10px;
}
.faq-head:active { background: rgba(229,154,82,0.06); }

.faq-q {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}
.faq-arrow {
  font-size: 18px;
  color: var(--text-muted);
  display: inline-block;
  transition: transform 0.28s ease;
  flex-shrink: 0;
}
.faq-item.open .faq-arrow { transform: rotate(90deg); }

.faq-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s ease;
}
.faq-item.open .faq-body { max-height: 200px; }
.faq-body p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.65;
  padding: 0 15px 14px;
}

/* ── Rate Card ───────────────────────────────────────── */
.rate-card {
  background: linear-gradient(135deg, rgba(124,169,130,0.12), rgba(124,169,130,0.04));
  border: 1px solid rgba(124,169,130,0.28);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  margin-bottom: 20px;
}
.rate-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}
.rate-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 16px;
}

/* ── Bottom Navigation ───────────────────────────────── */
.bottom-nav {
  position: absolute;
  bottom: var(--sa-bottom); left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(22, 20, 36, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px 0;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  flex: 1;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--tr);
  min-width: 0;
}
.nav-item:active { transform: scale(0.9); }

.nav-ico {
  width: 22px; height: 22px;
  transition: filter var(--tr), transform var(--tr);
  flex-shrink: 0;
}
.nav-lbl {
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

.nav-item.active {
  color: var(--primary-lt);
}
.nav-item.active .nav-ico {
  filter: drop-shadow(0 0 6px rgba(245,185,113,0.75));
  transform: translateY(-1px);
}

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: absolute;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  visibility: hidden;
  background: rgba(229,154,82,0.95);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 11px 22px;
  border-radius: 30px;
  font-family: 'Comfortaa', cursive;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 500;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(229,154,82,0.45);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.3s;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0s;
}

/* ── Loading Overlay ─────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,14,23,0.94);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.loading-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.loading-box { text-align: center; }
.loading-logo {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: 54px;
  color: #FFD966;
  text-shadow:
    0 0 14px rgba(255,217,102,1),
    0 0 38px rgba(255,217,102,0.65),
    0 0 90px rgba(255,217,102,0.35);
  animation: logoPulse 1.4s ease-in-out infinite;
  margin-bottom: 18px;
}
.loading-msg {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 20px;
}
.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.loading-dots span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--primary);
  animation: dotPop 1.3s ease-in-out infinite;
}
.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
  background: var(--primary-lt);
}
.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
  background: var(--secondary);
}
@keyframes dotPop {
  0%,80%,100% { transform: scale(0.75); opacity: 0.45; }
  40%          { transform: scale(1.25); opacity: 1; }
}

/* ── Kill Telegram injected blue button blob ── */
#telegram-bottom-button,
.tg-btn-main,
[class*="tg-bottom"],
[id*="telegram-button"] {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ── Кнопка "Я устал" ── */
.btn-tired {
  width: 100%;
  background: linear-gradient(135deg, #7CA982, #e8904a);
  box-shadow: 0 8px 32px rgba(124,169,130,0.45);
  border-radius: 20px;
  padding: 20px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  transition: transform var(--tr), box-shadow var(--tr);
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
.btn-tired:active {
  transform: scale(0.97);
  box-shadow: 0 4px 16px rgba(124,169,130,0.3);
}
.tired-left { display: flex; align-items: center; gap: 14px; }
.tired-moon { font-size: 32px; flex-shrink: 0; }
.tired-texts { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.tired-title { font-family: 'Comfortaa', cursive; font-size: 18px; font-weight: 700; color: #fff; }
.tired-sub   { font-family: 'Comfortaa', cursive; font-size: 12px; color: rgba(255,255,255,0.72); }
.tired-arrow { font-size: 28px; color: #fff; font-weight: 700; flex-shrink: 0; }

/* ── Возраст — free input ── */
.age-input-wrap { position: relative; display: flex; align-items: center; }
.age-free-input { padding-right: 52px !important; -moz-appearance: textfield; }
.age-free-input::-webkit-outer-spin-button,
.age-free-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.age-input-suffix {
  position: absolute; right: 16px;
  font-size: 14px; font-weight: 700;
  color: var(--text-muted); pointer-events: none;
}

/* ── Footer logo ── */
.screen-footer {
  text-align: center;
  padding: 24px 0 8px;
  margin-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.footer-logo {
  font-family: 'Dancing Script', cursive;
  font-weight: 700; font-size: 28px;
  color: #FFD966;
  text-shadow: 0 0 14px rgba(255,217,102,0.55);
  margin-bottom: 4px;
}
.footer-ver { font-size: 11px; color: var(--text-muted); }

/* ── Use system (Apple-style) emoji font ── */
.emoji, .nav-ico-emoji {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.contact-btn svg {
  flex-shrink: 0;
}

/* ════════════════════════════════════════
   KILL ALL TELEGRAM INJECTED UI ELEMENTS
════════════════════════════════════════ */
iframe[src*="telegram"],
div[class*="tgme"],
div[id*="telegram"],
#telegram-bottom-button,
.tgme_widget,
[class^="tgme"],
[class*="bottom-button"],
[style*="position: fixed"][style*="bottom: 0"],
[style*="position:fixed"][style*="bottom:0"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  overflow: hidden !important;
}

.contact-btn svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: block;
}

/* ════════════════════════════════════════
   TWEMOJI — crisp emoji images
════════════════════════════════════════ */
img.emoji {
  height: 1em;
  width: 1em;
  margin: 0 0.05em 0 0.1em;
  vertical-align: -0.1em;
  display: inline-block;
}
.nav-lbl img.emoji { height: 0.9em; width: 0.9em; }
.tired-moon img.emoji { height: 32px; width: 32px; }
.tale-emoji img.emoji { height: 26px; width: 26px; }
.stat-fire img.emoji { height: 16px; width: 16px; }
.acc-emoji img.emoji { height: 17px; width: 17px; }
.quote-star img.emoji { height: 18px; width: 18px; }
.ach-icon img.emoji  { height: 26px; width: 26px; }
.stat4-icon img.emoji { height: 20px; width: 20px; }

/* ════════════════════════════════════════
   НОВЫЕ ПОЛЯ ФОРМЫ СОЗДАНИЯ СКАЗКИ
════════════════════════════════════════ */
.form-label-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
  opacity: 0.75;
}

.hidden {
  display: none !important;
}
.pet-block, .sibling-block {
  animation: fadeSlideIn 0.22s ease;
}
@keyframes fadeSlideIn {
  from { opacity:0; transform:translateY(-6px); }
  to   { opacity:1; transform:translateY(0); }
}

#setting-chips .chip-sm.active,
#event-chips .chip-sm.active,
#companion-chips .chip-sm.active,
#antagonist-chips .chip-sm.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#moral-accordion .chip-sm.active {
  background: rgba(255, 217, 102, 0.18);
  border-color: #FFD966;
  color: #FFD966;
}

#duration-chips {
  display: flex;
  gap: 8px;
}
#duration-chips .chip {
  flex: 1;
  text-align: center;
  justify-content: center;
  font-size: 12px;
  padding: 10px 6px;
}

#language-chips .chip {
  flex: 1;
  text-align: center;
  justify-content: center;
}

.pet-block .form-input,
.sibling-block .form-input {
  background: rgba(255,255,255,0.04);
}

/* ════════════ ТОНКИЕ НАСТРОЙКИ ════════════ */
.advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--tr), border-color var(--tr);
  -webkit-tap-highlight-color: transparent;
}
.advanced-toggle:active { background: rgba(229,154,82,0.08); }
.advanced-toggle-left { display: flex; align-items: center; gap: 10px; }
.advanced-toggle-icon { font-size: 18px; }
.advanced-toggle-title { font-family: 'Comfortaa', cursive; font-weight: 700; font-size: 14px; color: var(--text); }
.advanced-toggle-hint { font-size: 11px; color: var(--text-muted); }
.advanced-toggle-arrow {
  font-size: 20px; color: var(--text-muted);
  transition: transform 0.25s ease;
  display: inline-block;
}
.advanced-body {
  margin-top: 2px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeSlideIn 0.22s ease;
}
.advanced-section {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.advanced-section:last-child { border-bottom: none; }

/* ════════════ CUSTOM INPUT BLOCK ════════════ */
.custom-input-block {
  animation: fadeSlideIn 0.2s ease;
}

/* ════════════ MORAL TEXTAREA ════════════ */
.moral-textarea {
  width: 100%;
  resize: none;
  min-height: 72px;
  line-height: 1.5;
  box-sizing: border-box;
}

/* ── Mood grid: 2 cols × 3 rows ── */
.mood-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.mood-chip {
  font-size: 13px;
  padding: 12px 10px;
  text-align: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ════════════════════════════════════════
   STORY READER OVERLAY
════════════════════════════════════════ */
.story-reader-overlay {
  position: absolute; inset: 0;
  background: rgba(15,14,23,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 900;
  display: flex; align-items: flex-end;
  opacity: 0; transition: opacity 0.3s ease;
}
.story-reader-overlay.show { opacity: 1; }

.story-reader-box {
  width: 100%; max-height: 92dvh;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}

.story-reader-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}

/* Updated for new reader layout */
.story-reader-title {
  font-size: 16px; font-weight: 700; color: var(--text);

  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.reader-close-btn {
  background: rgba(255,255,255,0.08); border: none;
  border-radius: 8px; padding: 8px 12px;
  color: var(--text-muted); font-size: 14px; cursor: pointer;
  font-family: 'Comfortaa', cursive; transition: background var(--tr);
}
.reader-close-btn:active { background: rgba(255,255,255,0.15); }

.reader-like-btn {
  background: transparent; border: none;
  font-size: 20px; cursor: pointer; padding: 6px 8px; border-radius: 8px;
  transition: transform var(--tr);
}
.reader-like-btn:active { transform: scale(1.3); }

.reader-continue-btn {
  background: rgba(108,99,255,0.2);
  border: 1px solid rgba(108,99,255,0.4);
  border-radius: 8px; padding: 7px 11px;
  color: var(--accent); font-size: 13px; font-weight: 700;
  font-family: 'Comfortaa', cursive; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: background var(--tr);
}
.reader-continue-btn:active { background: rgba(108,99,255,0.4); }

.story-reader-body {
  overflow-y: auto; padding: 18px 18px 32px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; flex: 1;
}
.story-reader-body::-webkit-scrollbar { display: none; }
.story-reader-body p {
  font-size: 15px; line-height: 1.75; color: var(--text); margin-bottom: 14px;
}

.tale-like-btn {
  background: transparent; border: none; font-size: 18px;
  cursor: pointer; padding: 4px 6px; border-radius: 8px; flex-shrink: 0;
  transition: transform var(--tr);
}
.tale-like-btn:active { transform: scale(1.3); }

.series-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  background: rgba(108,99,255,0.2); color: var(--accent);
  border: 1px solid rgba(108,99,255,0.35);
  border-radius: 6px; padding: 1px 6px; margin-left: 6px;
  vertical-align: middle;
}

/* ════════════════════════════════════════
   SERIES MODAL
════════════════════════════════════════ */
.series-modal-overlay {
  position: absolute; inset: 0;
  background: rgba(15,14,23,0.85);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.28s ease; padding: 24px;
}
.series-modal-overlay.show { opacity: 1; }

.series-modal-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px 22px 22px;
  width: 100%; max-width: 340px;
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 10px;
}

.series-modal-emoji { font-size: 40px; line-height: 1; }
.series-modal-title { font-size: 18px; font-weight: 700; color: var(--text); }
.series-modal-sub { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.series-modal-btns {
  display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 6px;
}

.series-btn-yes {
  background: var(--accent-gradient); border: none; border-radius: 12px;
  padding: 14px; color: #fff; font-size: 15px; font-weight: 700;
  font-family: 'Comfortaa', cursive; cursor: pointer; width: 100%;
}

.series-btn-no {
  background: rgba(255,255,255,0.07); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px; color: var(--text); font-size: 14px;
  font-family: 'Comfortaa', cursive; cursor: pointer; width: 100%;
}

.series-btn-skip {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 13px; cursor: pointer; padding: 6px;
  font-family: 'Comfortaa', cursive;
}

/* ════════════════════════════════════════
   PROFILE MODAL — скролл на мобиле
   Фикс: кнопки Сохранить/Удалить
   больше не уходят за экран
════════════════════════════════════════ */
#profile-modal .series-modal-box {
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#profile-modal .series-modal-box::-webkit-scrollbar { display: none; }

/* ════════════════════════════════════════
   SERIES CARDS (главная)
════════════════════════════════════════ */
.series-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  cursor: pointer; transition: border-color var(--tr), transform var(--tr);
}
.series-card:active { transform: scale(0.98); border-color: var(--accent); }

.series-card-emoji { font-size: 28px; flex-shrink: 0; }

.series-card-info { flex: 1; overflow: hidden; }

.series-card-name {
  font-size: 14px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.series-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.series-card-btn {
  background: rgba(108,99,255,0.18);
  border: 1px solid rgba(108,99,255,0.35);
  border-radius: 10px; padding: 8px 12px;
  color: var(--accent); font-size: 12px; font-weight: 700;
  font-family: 'Comfortaa', cursive; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: background var(--tr);
}
.series-card-btn:active { background: rgba(108,99,255,0.35); }

/* ════════════════════════════════════════
   READER REDESIGN — flexbox header
════════════════════════════════════════ */
.reader-back-btn {
  background: rgba(255,255,255,0.08); border: none;
  border-radius: 10px; padding: 8px;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background var(--tr);
}
.reader-back-btn:active { background: rgba(255,255,255,0.15); }
.reader-back-btn svg { display: block; }

.reader-header-text {
  flex: 1; min-width: 0; padding: 0 10px;
}

.reader-header-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}

/* Liked state for like buttons */
.tale-like-btn.liked,
.reader-like-btn.liked {
  animation: likePopReader 0.35s ease;
  filter: drop-shadow(0 0 6px rgba(255, 80, 100, 0.6));
}

@keyframes likePopReader {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.story-reader-meta {
  font-size: 12px; color: var(--text-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Reader close X button (styled like edit-btn) ──── */
.reader-close-x {
  background: rgba(229,154,82,0.14);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 15px; font-weight: 600;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--tr);
  font-family: 'Comfortaa', cursive;
  line-height: 1;
}
.reader-close-x:active { transform: scale(0.94); background: rgba(229,154,82,0.25); }
