/* ===== Сказочный домик — аудиосказки на ночь ===== */
:root {
  --bg: #17153a;
  --bg-2: #1f1c4a;
  --card: #26225a;
  --card-hover: #2e2a69;
  --line: rgba(255,255,255,.09);
  --ink: #f1efff;
  --muted: #a9a4d0;
  --amber: #f5b04a;
  --amber-ink: #3a2400;
  --radius: 20px;
  --player-h: 88px;
  --max: 1120px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1.5px 1.5px at 8% 12%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 30%, #fff7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 41% 8%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 22%, #fff6 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 10%, #fffa 50%, transparent 51%),
    radial-gradient(1px 1px at 91% 34%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 40%, #fff5 50%, transparent 51%),
    linear-gradient(180deg, #110f2c 0, var(--bg) 480px);
  background-repeat: no-repeat;
  background-color: var(--bg);
  min-height: 100vh;
  padding-bottom: calc(var(--player-h) + 20px);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: block; }
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ===== Шапка ===== */
.header { padding: 18px 0 6px; }
.header__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo__mark { width: 40px; height: 40px; }
.logo__text { font-family: "Comfortaa", sans-serif; font-weight: 700; font-size: 23px; white-space: nowrap; }
.logo__text span { color: var(--amber); }

.icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); cursor: pointer;
  font-weight: 700; font-size: 15px;
}
.icon-btn:hover { background: var(--card-hover); }
.icon-btn.is-on { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }

/* ===== Приветствие ===== */
.hero { padding: 36px 0 26px; text-align: center; }
.hero h1 { font-family: "Comfortaa", sans-serif; font-size: 36px; line-height: 1.2; margin: 0 0 10px; }
.hero p { color: var(--muted); margin: 0 auto 24px; max-width: 560px; }
.hero__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 26px; border-radius: 99px; border: 0; cursor: pointer;
  font-weight: 800; font-size: 18px;
}
.btn--main { background: var(--amber); color: var(--amber-ink); box-shadow: 0 8px 30px rgba(245,176,74,.35); }
.btn--main:hover { filter: brightness(1.06); }
.btn--ghost { background: var(--card); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--card-hover); }
.btn small { font-weight: 700; opacity: .75; font-size: 14px; }

/* ===== Подборки ===== */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); cursor: pointer; font-weight: 700;
}
.chip:hover { background: var(--card-hover); }
.chip.is-active { background: var(--ink); color: var(--bg); }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 14px; }
.list-head h2 { margin: 0; font-size: 22px; }
.list-head .muted { color: var(--muted); font-size: 15px; }

/* ===== Карточки сказок ===== */
.stories { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.story {
  position: relative; text-align: left; cursor: pointer; padding: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: transform .15s ease, background .15s ease;
}
.story:hover { transform: translateY(-3px); background: var(--card-hover); }
.story__img { position: relative; height: 140px; display: grid; place-items: center; font-size: 64px; }
.story__play {
  position: absolute; right: 12px; bottom: -22px;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--amber); color: var(--amber-ink);
  display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.story__body { padding: 14px 16px 16px; }
.story__title { font-weight: 800; font-size: 17px; line-height: 1.3; padding-right: 44px; }
.story__meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.story.is-current { outline: 2px solid var(--amber); }

/* «Эквалайзер» на играющей сказке */
.eq { display: none; gap: 3px; align-items: flex-end; height: 18px; }
.eq i { width: 4px; background: currentColor; border-radius: 2px; animation: eq 1s infinite ease-in-out; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }
.story.is-playing .eq { display: flex; }
.story.is-playing .ico-play { display: none; }

/* Мягкие «ночные» обложки */
.bg-1 { background: linear-gradient(135deg, #f7c98b, #e9935f); }
.bg-2 { background: linear-gradient(135deg, #8fb4f4, #5b6fd6); }
.bg-3 { background: linear-gradient(135deg, #9fdcab, #4f9f84); }
.bg-4 { background: linear-gradient(135deg, #f5a3b3, #c4607d); }
.bg-5 { background: linear-gradient(135deg, #b8a3f5, #6d55c9); }
.bg-6 { background: linear-gradient(135deg, #ffe08a, #f0a845); }

.about { margin-top: 40px; padding: 24px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); }
.about h2 { color: var(--ink); margin: 0 0 8px; font-size: 20px; }
.about p { margin: 0 0 10px; } .about p:last-child { margin: 0; }

.footer { color: var(--muted); font-size: 14px; text-align: center; padding: 30px 0 10px; }

/* ===== Нижняя панель плеера ===== */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--player-h);
  background: rgba(17,15,44,.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  transform: translateY(110%); transition: transform .25s ease;
}
.player.is-visible { transform: none; }
.player__progress { position: absolute; top: -2px; left: 0; right: 0; height: 4px; background: var(--line); }
.player__progress div { height: 100%; width: 0; background: var(--amber); }
.player__inner { height: 100%; display: flex; align-items: center; gap: 14px; }
.player__info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.player__cover { flex: 0 0 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 30px; }
.player__title { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player__sub { color: var(--muted); font-size: 14px; white-space: nowrap; }
.player__controls { display: flex; align-items: center; gap: 6px; }

.ctrl { width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.ctrl:hover { background: var(--card); }
.ctrl--big { width: 58px; height: 58px; background: var(--amber); color: var(--amber-ink); }
.ctrl--big:hover { background: var(--amber); filter: brightness(1.06); }
.ctrl--xl { width: 84px; height: 84px; }
.timer-badge { font-size: 13px; font-weight: 800; color: var(--amber); min-width: 44px; text-align: center; }

/* ===== Полноэкранный плеер ===== */
.now {
  position: fixed; inset: 0; z-index: 40;
  background: linear-gradient(180deg, #0f0d29, #1c1950);
  overflow-y: auto;
  display: none;
}
.now.is-open { display: block; }
.now__inner { max-width: 560px; margin: 0 auto; padding: 18px 20px 40px; text-align: center; }
.now__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.now__cover { width: min(280px, 70vw); aspect-ratio: 1; margin: 16px auto 22px; border-radius: 32px; display: grid; place-items: center; font-size: 120px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.now__title { font-family: "Comfortaa", sans-serif; font-size: 28px; margin: 0 0 4px; }
.now__sub { color: var(--muted); margin: 0 0 22px; }

.seek { width: 100%; accent-color: var(--amber); height: 6px; cursor: pointer; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin-top: 4px; }
.now__controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0 26px; }
.now__controls .ctrl { width: 54px; height: 54px; }
.now__controls .ctrl--xl { width: 84px; height: 84px; }

.opts { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: left; margin-bottom: 14px; }
.opts h3 { margin: 0 0 10px; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.opts h3 span { color: var(--amber); font-size: 15px; }
.opts__row { display: flex; flex-wrap: wrap; gap: 8px; }
.opts .chip { height: 38px; padding: 0 14px; font-size: 15px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; }
.switch input { width: 46px; height: 26px; accent-color: var(--amber); cursor: pointer; }
.switch small { display: block; color: var(--muted); font-weight: 400; }

.now__text { text-align: left; color: #d9d6f3; font-size: 18px; line-height: 1.75; }
.now__text p { margin: 0 0 1em; white-space: pre-line; } /* pre-line — стихи показываются по строчкам */
.note { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* ===== Режим «тёмный экран» ===== */
.blackout {
  position: fixed; inset: 0; z-index: 50; background: #000; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 10px;
  color: #3a3760; font-size: 15px; cursor: pointer; user-select: none;
}
.blackout.is-on { display: flex; }
.blackout .moon { font-size: 40px; opacity: .25; }

/* ===== Мобильные ===== */
@media (max-width: 640px) {
  :root { --player-h: 76px; }
  body { font-size: 16px; }
  .hero h1 { font-size: 27px; }
  .stories { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .story__img { height: 110px; font-size: 50px; }
  .story__title { font-size: 15px; padding-right: 0; }
  .story__play { width: 40px; height: 40px; bottom: -18px; right: 10px; }
  .story__body { padding: 12px 12px 14px; }
  .player__cover { flex-basis: 48px; height: 48px; font-size: 26px; }
  .player .hide-sm { display: none; }
  .ctrl--big { width: 52px; height: 52px; }
  .icon-btn .label { display: none; }
  .logo__text { font-size: 20px; }
}

/* ===== Шапка: кнопки справа ===== */
.header__actions { display: flex; gap: 8px; align-items: center; }

/* ===== Поиск ===== */
.search {
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 16px; margin: 0 0 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 99px; color: var(--muted);
}
.search:focus-within { border-color: var(--amber); color: var(--ink); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; color: var(--ink); font: inherit; font-size: 17px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: invert(1) opacity(.6); }
.chip small { opacity: .7; font-weight: 800; margin-left: 2px; }

/* ===== Карточка: избранное ===== */
.story:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.fav {
  position: absolute; top: 10px; left: 10px;
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: rgba(17,15,44,.45); color: #fff;
}
.fav svg { fill: none; stroke: currentColor; stroke-width: 2; }
.fav.is-on { color: #ff6b8a; background: rgba(255,255,255,.9); }
.fav.is-on svg { fill: currentColor; }
.fav:hover { transform: scale(1.08); }
.offline-mark { color: var(--amber); }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 20px; background: var(--bg-2); border-radius: var(--radius); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--sm { height: 44px; padding: 0 18px; font-size: 15px; }

/* ===== Плеер: кнопки действий ===== */
.now__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: -8px 0 22px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px; border-radius: 99px; cursor: pointer;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--ink);
  font-weight: 700; font-size: 14px;
}
.pill:hover { background: rgba(255,255,255,.12); }
.pill svg { flex: 0 0 auto; }
#favBtn svg { fill: none; stroke: currentColor; stroke-width: 2; }
#favBtn.is-on { color: #ff6b8a; }
#favBtn.is-on svg { fill: currentColor; }
#dlBtn.is-on { color: var(--amber); }

/* ===== Всплывающее сообщение ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--player-h) + 16px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); font-weight: 700;
  padding: 12px 18px; border-radius: 14px; transition: all .2s ease; max-width: 90vw; text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ===== Подсказка установки (iPhone) ===== */
.sheet { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.sheet[hidden] { display: none !important; }
.sheet__box { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; max-width: 460px; width: 100%; }
.sheet__box h3 { margin: 0 0 10px; }
.sheet__box ol { margin: 0 0 16px; padding-left: 20px; color: var(--muted); }
.sheet__box li { margin-bottom: 6px; }

/* ===== Список всех сказок (для поиска Яндекса/Google) ===== */
.all-tales { margin-top: 28px; }
.all-tales h2 { font-size: 20px; margin: 0 0 12px; }
.all-tales ul { list-style: none; padding: 0; margin: 0; columns: 2 220px; column-gap: 24px; }
.all-tales li { margin: 0 0 8px; break-inside: avoid; }
.all-tales a { color: var(--muted); }
.all-tales a:hover { color: var(--amber); }

/* ===== Страница отдельной сказки ===== */
.tale { max-width: 720px; margin: 0 auto; padding: 10px 0 40px; }
.crumbs { color: var(--muted); font-size: 14px; margin: 6px 0 18px; }
.crumbs a { color: var(--amber); font-weight: 700; }
.tale__cover { width: min(240px, 60vw); aspect-ratio: 1; margin: 0 auto 18px; border-radius: 28px; display: grid; place-items: center; font-size: 104px; box-shadow: 0 16px 50px rgba(0,0,0,.4); }
.tale h1 { font-family: "Comfortaa", sans-serif; text-align: center; font-size: 30px; margin: 0 0 6px; }
.tale__meta { text-align: center; color: var(--muted); margin: 0 0 20px; }
.tale__listen { display: flex; justify-content: center; margin: 0 0 24px; }
.tale__tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 26px; }
.tale__tags .chip { height: 36px; font-size: 14px; cursor: default; }
.tale__text { font-size: 18px; line-height: 1.75; color: #d9d6f3; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.tale__text p { margin: 0 0 1em; white-space: pre-line; }
.tale__more { margin-top: 30px; }
.tale__more h2 { font-size: 20px; }
.tale__more .stories { margin-top: 12px; }
.tale__more a.story { display: block; color: inherit; }
@media (max-width: 640px) {
  .header__actions .icon-btn { padding: 0 11px; }
  .tale h1 { font-size: 24px; }
  .tale__text { font-size: 17px; padding: 18px; }
}
