:root {
  --bg: #fdf6ec;
  --surface: #fff8f0;
  --text: #1a1209;
  --text2: #6b5535;
  --accent: #c5892a;
  --accent-light: #fff3dc;
  --border: #e8d5b7;
  --highlight-bg: #fffbea;
  --highlight-border: #c5892a;
}
[data-theme="dark"] {
  --bg: #120e08;
  --surface: #1e1710;
  --text: #f0e2c8;
  --text2: #b89060;
  --accent: #d4a050;
  --accent-light: #271e10;
  --border: #3a2e1c;
  --highlight-bg: #2a2010;
  --highlight-border: #d4a050;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: Georgia, 'Times New Roman', serif; background: var(--bg); color: var(--text); min-height: 100vh; transition: background .3s, color .3s; }
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── GATE ── */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 40% 40%, #1a3020 0%, #0c1a10 60%, #080f0a 100%);
}
.gate-box {
  width: min(360px, 90vw);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 22px;
  padding: 2.8rem 2.4rem;
  text-align: center;
  backdrop-filter: blur(12px);
}
.gate-icon { font-size: 3.6rem; line-height: 1; margin-bottom: .9rem; }
.gate-box h1 { color: #f0e2c8; font-size: 1.75rem; letter-spacing: .04em; margin-bottom: .25rem; }
.gate-series { color: rgba(240,226,200,.5); font-size: .88rem; font-style: italic; letter-spacing: .1em; margin-bottom: 2rem; }
.gate-box input {
  width: 100%;
  padding: .82rem 1.1rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: rgba(255,255,255,.07);
  color: #f0e2c8;
  font-size: 1.05rem;
  font-family: Georgia, serif;
  outline: none;
  text-align: center;
  letter-spacing: .12em;
  margin-bottom: .9rem;
  transition: border-color .2s;
}
.gate-box input::placeholder { color: rgba(240,226,200,.35); letter-spacing: 0; }
.gate-box input:focus { border-color: rgba(212,160,80,.5); }
.gate-btn {
  width: 100%;
  padding: .88rem;
  background: #c5892a;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-family: Georgia, serif;
  letter-spacing: .05em;
  transition: background .2s, transform .1s;
}
.gate-btn:hover { background: #a8721e; }
.gate-btn:active { transform: scale(.98); }
.gate-err { color: #ff9090; font-size: .88rem; margin-top: .7rem; min-height: 1.2em; }

/* ── SITE HEADER ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
.site-logo { font-size: 1.2rem; font-weight: bold; color: var(--accent); letter-spacing: .04em; }
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .38rem .75rem;
  font-size: .95rem;
  color: var(--text);
  transition: background .15s;
}
.icon-btn:hover { background: var(--accent-light); }

/* ── HOME ── */
.home-wrap { max-width: 740px; margin: 0 auto; padding: 2.2rem 1.4rem 5rem; }
.series-banner {
  text-align: center;
  font-size: 1rem;
  font-style: italic;
  color: var(--text2);
  letter-spacing: .12em;
  margin-bottom: 2.4rem;
}
.volumes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.1rem; }
.vol-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.6rem 1.4rem 1.2rem;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.vol-card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,.14); border-color: var(--accent); }
.vol-num { font-size: 2.6rem; font-weight: bold; color: var(--accent); line-height: 1; margin-bottom: .4rem; }
.vol-title { font-size: 1rem; font-weight: bold; margin-bottom: .25rem; }
.vol-subtitle { font-size: .83rem; font-style: italic; color: var(--text2); line-height: 1.45; flex: 1; margin-bottom: 1rem; }
.vol-cta { font-size: .78rem; color: var(--accent); letter-spacing: .05em; }

/* ── READER HEADER ── */
.reader-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .7rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
.reader-vol-name { flex: 1; font-size: .92rem; font-weight: bold; color: var(--accent); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── BOOK CONTENT ── */
.book-wrap { max-width: 100%; margin: 0 auto; padding: 1.8rem 1rem 9rem; }

.book-wrap h2.week-title { font-size: 1.7rem; font-weight: bold; line-height: 1.3; margin-bottom: .3rem; color: var(--text); }
.book-wrap p.week-theme { font-size: .93rem; font-style: italic; color: var(--text2); margin-bottom: 2rem; line-height: 1.65; }
.book-wrap h3.day {
  font-size: .95rem;
  font-weight: bold;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 2.8rem;
  margin-bottom: .5rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.book-wrap h4.story { font-size: 1.08rem; font-weight: bold; margin: 1.2rem 0 .7rem; color: var(--text); }
.book-wrap p { margin: 0 0 .75em; line-height: 1.92; font-size: 1rem; text-align: justify; color: var(--text); }
.book-wrap .bed {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 10px 10px 0;
  padding: .75rem 1rem;
  margin: 1.2rem 0 .7rem;
}
.book-wrap .bed p { margin: 0; font-size: .93rem; }
.book-wrap .story-break { text-align: center; color: var(--border); font-size: 1.3rem; letter-spacing: .45em; margin: 1.2rem 0; user-select: none; }
.book-wrap hr { border: none; border-top: 1px solid var(--border); margin: 2.2rem 0; }

/* TTS highlight */
.tts-active {
  background: var(--highlight-bg) !important;
  outline: 2px solid var(--highlight-border);
  outline-offset: 3px;
  border-radius: 4px;
}

/* clickable segments */
[data-seg]:hover { background: var(--accent-light); border-radius: 4px; cursor: pointer; }

/* ── TTS BAR ── */
.tts-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
  padding: .65rem 1rem .75rem;
  z-index: 300;
}
.tts-inner {
  max-width: 660px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: nowrap;
}
.tts-play {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.tts-play:hover { background: #a8721e; }
.tts-play:active { transform: scale(.94); }
.tts-stop {
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .4rem .7rem;
  font-size: 1rem;
  color: var(--text2);
  flex-shrink: 0;
}
.tts-stop:hover { background: var(--accent-light); }
.tts-skip {
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .4rem .6rem;
  font-size: .95rem;
  color: var(--text2);
  flex-shrink: 0;
}
.tts-skip:hover { background: var(--accent-light); }
.tts-speeds { display: flex; gap: .3rem; margin-left: auto; }
.spd {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .28rem .48rem;
  font-size: .74rem;
  color: var(--text2);
  font-family: system-ui, sans-serif;
  transition: background .12s;
}
.spd:hover { background: var(--accent-light); }
.spd.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tts-progress {
  font-size: .75rem;
  color: var(--text2);
  font-family: system-ui, sans-serif;
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}
.voice-sel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .3rem .45rem;
  color: var(--text);
  font-size: .75rem;
  font-family: system-ui, sans-serif;
  max-width: 100px;
  flex-shrink: 1;
}

@media (max-width: 480px) {
  .tts-progress { display: none; }
  .voice-sel { display: none; }
  .spd { padding: .28rem .38rem; font-size: .7rem; }
}

/* ── Landscape: full-width text, minimal margins ── */
@media (orientation: landscape) {
  .book-wrap {
    max-width: 100%;
    padding-left: 1.2rem;
    padding-right: 1.2rem;
  }
  .book-wrap p {
    font-size: 1rem;
    line-height: 1.82;
  }
  .audio-inner {
    max-width: 100%;
    padding: 0 1rem;
  }
  .reader-header {
    padding: .45rem 1rem;
  }
}
