:root {
  --night: #1d2440;
  --night-2: #283157;
  --moon: #f6d98b;
  --cream: #fbf6ec;
  --paper: #fffdf8;
  --ink: #2a2a33;
  --muted: #6b6a75;
  --accent: #e4875d;
  --accent-dark: #c96c43;
  --line: #ece4d4;
  --radius: 18px;
  --max: 680px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.6;
}

a { color: var(--accent-dark); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 90% at 80% 0%, var(--night-2) 0%, var(--night) 60%);
  color: #fff;
  padding: 28px 0 72px;
}
.hero::before {
  /* stars */
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 70%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 15%, #fffa 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 55%, #fff7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 80%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 42% 40%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 85%, #fff7 50%, transparent 51%);
  pointer-events: none;
}
.moon {
  position: absolute;
  top: 40px; right: max(60px, 8%);
  width: 150px; height: 150px;
  border-radius: 50%;
  background: transparent;
  /* crescent: an offset moon-coloured shadow; the transparent disc is the cut-out */
  box-shadow: 38px 18px 0 0 var(--moon);
  opacity: .95;
  pointer-events: none;
}
.hero .wrap { position: relative; z-index: 1; }

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 18px; letter-spacing: .2px;
  color: #fff; text-decoration: none;
}
.brand .zh { font-family: "Noto Serif TC", serif; font-weight: 600; opacity: .8; }

.hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(34px, 7vw, 50px);
  line-height: 1.1;
  margin: 56px 0 18px;
  max-width: 15ch;
}
.hero .sub { font-size: 19px; color: #dfe2f2; max-width: 34ch; margin: 0 0 28px; }

/* ---------- Signup form ---------- */
.signup { display: flex; gap: 10px; flex-wrap: wrap; max-width: 520px; }
.signup input[type=email] {
  flex: 1 1 240px;
  min-width: 0;
  font: inherit; font-size: 17px;
  padding: 14px 18px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: #fff; color: var(--ink);
}
.signup input[type=email]:focus { outline: none; border-color: var(--moon); }
.btn {
  flex: 0 0 auto;
  font: inherit; font-weight: 800; font-size: 17px;
  padding: 14px 22px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--accent-dark); }
.fine { font-size: 14px; color: #b9bdd6; margin: 12px 0 0; }

/* ---------- Sections ---------- */
section { padding: 56px 0; }
section + section { border-top: 1px solid var(--line); }
h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(26px, 5vw, 32px);
  line-height: 1.2;
  margin: 0 0 16px;
}
.lead { font-size: 19px; }

.features { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 14px; }
.features li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 16px 62px;
  position: relative;
}
.features li .ico {
  position: absolute; left: 16px; top: 14px;
  width: 34px; height: 34px; border-radius: 50%;
  background: #fbe7d8; display: grid; place-items: center; font-size: 18px;
}
.features b { display: block; }
.features span.desc { color: var(--muted); font-size: 16px; }

/* Sample card */
.sample {
  display: block;
  background: var(--night);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px;
  text-decoration: none;
  margin-top: 20px;
}
.sample .zh { font-family: "Noto Serif TC", serif; font-size: 28px; font-weight: 600; }
.sample .jp { color: var(--moon); font-size: 15px; margin: 2px 0 10px; }
.sample .en { color: #dfe2f2; }
.sample .go { display: inline-block; margin-top: 16px; font-weight: 800; color: var(--moon); }
.sample:hover .go { text-decoration: underline; }

/* FAQ */
details {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
summary { font-weight: 800; cursor: pointer; }
details p { margin: 10px 0 0; color: var(--muted); }

/* Bottom CTA */
.cta-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
}
.cta-box .signup { margin: 18px auto 0; justify-content: center; }
.cta-box .signup input[type=email] { border-color: var(--line); }
.cta-box .fine { color: var(--muted); }

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

/* ---------- Story page ---------- */
.story-head { padding: 28px 0 48px; }
.story-head h1 {
  font-family: "Noto Serif TC", serif;
  font-size: clamp(34px, 8vw, 46px);
  margin: 40px 0 4px;
  font-weight: 600;
}
.story-head .en-title { font-family: "Fraunces", Georgia, serif; font-size: 22px; color: #dfe2f2; margin: 0; }

.audio-box {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 32px 0 8px;
}
.audio-box audio { width: 100%; }
.audio-box p { margin: 0; color: var(--muted); font-size: 15px; }
.audio-box .audio-label { margin-bottom: 10px; color: var(--ink); font-weight: 700; }

/* Per-line speaker buttons (added by story.js once audio exists) */
.line.has-audio { position: relative; padding-left: 52px; }
.say {
  position: absolute; left: 0; top: 22px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--accent-dark);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.say:hover { border-color: var(--accent); }
.say.playing { background: var(--accent); border-color: var(--accent); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #e4875d33; } }

.legend { font-size: 14px; color: var(--muted); margin: 12px 0 24px; }
.legend span { margin-right: 12px; }

.line { padding: 18px 0; border-bottom: 1px dashed var(--line); }
.line:last-child { border-bottom: 0; }
.line .zh { font-family: "Noto Serif TC", serif; font-size: 26px; line-height: 1.5; font-weight: 600; }
.line .jp { color: var(--accent-dark); font-size: 16px; letter-spacing: .2px; }
.line .en { color: var(--muted); font-style: italic; font-size: 16px; }

.words { width: 100%; border-collapse: collapse; font-size: 16px; margin-top: 12px; }
.words th, .words td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.words th { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.words .zh { font-family: "Noto Serif TC", serif; font-size: 20px; font-weight: 600; white-space: nowrap; }
.words .jp { color: var(--accent-dark); white-space: nowrap; }

.tip {
  background: #fbe7d8; border-radius: var(--radius); padding: 18px 20px; margin-top: 28px;
}
.tip b { display: block; margin-bottom: 4px; }

@media (max-width: 520px) {
  body { font-size: 17px; }
  .moon { width: 110px; height: 110px; right: -10px; top: -30px; box-shadow: 26px 14px 0 0 var(--moon); }
  .story-head h1 { margin-top: 56px; }
  .btn { width: 100%; }
  .words .hide-sm { display: none; }
}

/* Woman / Man voice toggle */
.audio-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.audio-box .audio-head .audio-label { margin: 0; }
.voice-toggle { display: inline-flex; background: var(--cream); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.voice-toggle button {
  font: inherit; font-size: 15px; font-weight: 700;
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.voice-toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }
