:root {
  --paper: #fff8e9;
  --surface: #fffdf7;
  --ink: #25332d;
  --muted: #6d776f;
  --green: #2e6b57;
  --green-dark: #1f4d3e;
  --orange: #f39a54;
  --yellow: #ffd36a;
  --line: rgba(37, 51, 45, 0.1);
  --shadow: 0 14px 34px rgba(61, 74, 58, 0.12);
  --radius: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, rgba(255, 211, 106, .35), transparent 28rem),
    linear-gradient(180deg, var(--paper), #f8f2e6);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(46,107,87,.28); outline-offset: 3px; }

.app-shell { min-height: 100vh; padding-bottom: calc(110px + var(--safe-bottom)); }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 10px max(18px, calc((100vw - 1080px) / 2));
  background: rgba(255, 248, 233, .9);
  border-bottom: 1px solid rgba(37,51,45,.06);
  backdrop-filter: blur(16px);
}
.brand { display: flex; gap: 10px; align-items: center; border: 0; background: transparent; padding: 0; text-align: left; cursor: pointer; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 16px 16px 16px 6px; background: var(--green); color: #fff; font-weight: 900; box-shadow: 0 8px 18px rgba(46,107,87,.24); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .05em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 26px; cursor: pointer; }

.search-panel { position: sticky; z-index: 19; top: 72px; display: flex; gap: 10px; padding: 10px 18px; background: rgba(255,248,233,.96); }
.search-box { display: flex; flex: 1; gap: 8px; align-items: center; min-width: 0; padding: 0 16px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.search-box input { width: 100%; height: 48px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.text-button { border: 0; background: transparent; color: var(--green); font-weight: 700; cursor: pointer; }

main { width: min(100%, 1080px); margin: 0 auto; padding: 18px; }
.hero { position: relative; overflow: hidden; min-height: 340px; padding: 34px 28px; border-radius: 34px; color: #fffdf4; background: linear-gradient(135deg, #225947, #377a62); box-shadow: var(--shadow); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero::before { width: 260px; height: 260px; right: -70px; top: -100px; }
.hero::after { width: 170px; height: 170px; right: 90px; bottom: -110px; }
.eyebrow { margin: 0 0 12px; color: var(--yellow); font-size: 13px; font-weight: 800; letter-spacing: .15em; }
.hero h1 { max-width: 600px; margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(38px, 7vw, 66px); line-height: 1.08; letter-spacing: -.03em; }
.hero-copy { max-width: 540px; margin: 16px 0 24px; color: rgba(255,255,255,.78); line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.primary-button, .secondary-button { min-height: 48px; padding: 0 20px; border-radius: 16px; font-weight: 800; cursor: pointer; }
.primary-button { border: 0; background: var(--yellow); color: #314238; box-shadow: 0 8px 16px rgba(20,50,40,.2); }
.secondary-button { border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.1); color: #fff; }
.hero-visual { position: absolute; right: clamp(12px, 4vw, 50px); top: 60px; display: grid; place-items: center; width: 180px; height: 180px; border-radius: 50% 50% 44% 56%; background: #ffd36a; font-size: 90px; transform: rotate(5deg); box-shadow: inset 0 -18px 0 rgba(231,139,67,.15); }

.section { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.section-heading h2 { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: 28px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.section-heading button { border: 0; background: transparent; color: var(--green); font-weight: 800; cursor: pointer; }

.continue-card { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.72); cursor: pointer; box-shadow: 0 8px 24px rgba(61,74,58,.06); }
.continue-card .cover { flex: 0 0 72px; height: 72px; }
.continue-copy { flex: 1; min-width: 0; }
.continue-copy strong, .continue-copy span { display: block; }
.continue-copy span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.continue-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: white; }

.age-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.age-card { position: relative; overflow: hidden; min-height: 130px; padding: 20px; border: 0; border-radius: 24px; text-align: left; cursor: pointer; }
.age-card strong, .age-card span { display: block; }
.age-card strong { font-size: 21px; }
.age-card span { margin-top: 5px; color: rgba(37,51,45,.68); font-size: 13px; }
.age-card b { position: absolute; right: 12px; bottom: -12px; font-size: 60px; transform: rotate(-8deg); }
.age-card:nth-child(1) { background: #f8d9b8; }
.age-card:nth-child(2) { background: #cbe8d6; }
.age-card:nth-child(3) { background: #d8dcf1; }

.story-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.story-card { overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.8); box-shadow: 0 10px 28px rgba(61,74,58,.07); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.story-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.cover { position: relative; display: grid; place-items: center; aspect-ratio: 1.35; overflow: hidden; font-size: 55px; }
.cover::after { content: ""; position: absolute; width: 100px; height: 100px; right: -30px; top: -30px; border-radius: 50%; background: rgba(255,255,255,.28); pointer-events: none; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover img + span { display: none; }
.cover.sun { background: #f6c862; }
.cover.ocean { background: #9dd9df; }
.cover.plum { background: #d5b6d8; }
.cover.peach { background: #f5b79e; }
.cover.forest { background: #a7cfb6; }
.cover.night { background: #9ba7cf; }
.cover.grass { background: #c8dea0; }
.story-body { padding: 15px; }
.story-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.story-body h3 { margin: 8px 0 6px; font-size: 18px; }
.story-body p { display: -webkit-box; overflow: hidden; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.story-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.tag { padding: 5px 8px; border-radius: 99px; background: #eef4ef; color: var(--green); font-size: 11px; font-weight: 700; }
.favorite-button { border: 0; background: transparent; font-size: 22px; cursor: pointer; }
.favorite-button.active { color: #e36e62; }

.category-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.category-row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.7); cursor: pointer; }
.chip.active { border-color: var(--green); background: var(--green); color: #fff; }

.page-header { padding: 16px 0 12px; }
.page-header h1 { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: 38px; }
.page-header p { margin: 8px 0 0; color: var(--muted); }
.empty { padding: 50px 20px; border: 1px dashed rgba(37,51,45,.2); border-radius: 24px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 8px; color: var(--ink); font-size: 40px; }

.detail { display: grid; grid-template-columns: 340px 1fr; gap: 32px; align-items: start; }
.detail-cover { position: sticky; top: 96px; }
.detail-cover .cover { border-radius: 32px; aspect-ratio: 1; font-size: 120px; box-shadow: var(--shadow); }
.back-button { margin-bottom: 14px; border: 0; background: transparent; color: var(--green); font-weight: 800; cursor: pointer; }
.detail-copy { padding-top: 42px; }
.detail-copy h1 { margin: 12px 0 10px; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(38px, 6vw, 60px); }
.detail-copy .summary { color: var(--muted); font-size: 16px; line-height: 1.8; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0; }
.detail-actions .secondary-button { border-color: var(--line); background: #fff; color: var(--ink); }
.story-text { padding: 24px; border-radius: 24px; background: rgba(255,255,255,.7); line-height: 2; }
.question-card { margin-top: 16px; padding: 22px; border-radius: 24px; background: #f6d9b8; }
.question-card small { color: #8c5d37; font-weight: 800; letter-spacing: .08em; }
.question-card p { margin: 10px 0 0; font-size: 19px; font-weight: 800; }
.speed-row { display: flex; gap: 8px; margin-top: 16px; }
.speed-row button { min-width: 52px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.speed-row button.active { background: var(--green); color: #fff; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card { padding: 22px; border-radius: 24px; background: rgba(255,255,255,.76); border: 1px solid var(--line); }
.stat-card b { display: block; font-family: "STKaiti", "KaiTi", serif; font-size: 38px; color: var(--green); }
.stat-card span { color: var(--muted); font-size: 13px; }
.map-card { position: relative; overflow: hidden; min-height: 260px; padding: 24px; border-radius: 28px; background: #d9e8cc; }
.map-card::before { content: ""; position: absolute; inset: 20px; border: 3px dashed rgba(46,107,87,.28); border-radius: 45% 55% 48% 52%; transform: rotate(-4deg); }
.map-points { position: relative; z-index: 1; display: flex; justify-content: space-around; align-items: center; min-height: 200px; }
.map-point { display: grid; gap: 6px; justify-items: center; color: var(--muted); font-size: 12px; }
.map-point b { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.7); filter: grayscale(1); opacity: .6; font-size: 25px; }
.map-point.done b { background: var(--yellow); filter: none; opacity: 1; box-shadow: 0 8px 16px rgba(61,74,58,.14); }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: calc(14px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); width: min(calc(100% - 28px), 480px); transform: translateX(-50%); padding: 7px; border: 1px solid rgba(255,255,255,.7); border-radius: 22px; background: rgba(255,255,255,.92); box-shadow: 0 16px 38px rgba(48,60,52,.18); backdrop-filter: blur(18px); }
.nav-item { display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 5px; border: 0; border-radius: 16px; background: transparent; color: var(--muted); cursor: pointer; }
.nav-item span { font-size: 21px; }
.nav-item small { font-size: 10px; }
.nav-item.active { background: #e5f0e8; color: var(--green); }

.player { position: fixed; z-index: 25; left: 50%; bottom: calc(89px + var(--safe-bottom)); display: flex; align-items: center; gap: 9px; width: min(calc(100% - 28px), 720px); transform: translateX(-50%); padding: 10px 12px; border-radius: 22px; background: #203f34; color: white; box-shadow: 0 18px 35px rgba(32,63,52,.3); }
.player-progress { position: absolute; left: 16px; right: 16px; top: 0; height: 3px; background: rgba(255,255,255,.12); }
.player-progress span { display: block; width: 0; height: 100%; background: var(--yellow); transition: width .2s linear; }
.mini-cover { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border: 0; border-radius: 14px; background: var(--yellow); font-size: 24px; cursor: pointer; }
.player-copy { flex: 1; min-width: 0; }
.player-copy strong, .player-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-copy strong { font-size: 14px; }
.player-copy small { margin-top: 3px; color: rgba(255,255,255,.62); font-size: 10px; }
.player-control { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: white; font-size: 22px; cursor: pointer; }
.player-control.primary { background: var(--yellow); color: var(--ink); font-size: 14px; }

.audio-fallback { position: fixed; z-index: 45; left: 50%; bottom: calc(152px + var(--safe-bottom)); display: grid; gap: 6px; width: min(calc(100% - 28px), 520px); transform: translateX(-50%); padding: 12px 14px; border-radius: 18px; background: #fff8e9; color: var(--ink); box-shadow: 0 16px 36px rgba(32,63,52,.24); }
.audio-fallback[hidden] { display: none; }
.audio-fallback strong { font-size: 14px; }
.audio-fallback small { color: var(--muted); font-size: 11px; }
.audio-fallback audio { width: 100%; height: 40px; }

.toast { position: fixed; z-index: 50; left: 50%; top: 88px; max-width: calc(100% - 36px); transform: translate(-50%, -15px); padding: 10px 16px; border-radius: 99px; background: #243c33; color: white; opacity: 0; pointer-events: none; transition: .2s ease; font-size: 13px; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 820px) {
  .story-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { min-height: 400px; }
  .hero-visual { top: auto; bottom: 22px; width: 130px; height: 130px; font-size: 66px; }
  .hero-copy { max-width: 70%; }
  .detail { grid-template-columns: 1fr; gap: 0; }
  .detail-cover { position: static; }
  .detail-cover .cover { max-height: 330px; aspect-ratio: 1.45; }
  .detail-copy { padding-top: 12px; }
}

@media (max-width: 520px) {
  main { padding: 14px; }
  .topbar { padding-inline: 16px; }
  .hero { min-height: 430px; padding: 28px 22px; border-radius: 28px; }
  .hero h1 { font-size: 43px; }
  .hero-copy { max-width: 100%; padding-right: 0; }
  .hero-visual { right: 20px; bottom: 20px; width: 110px; height: 110px; font-size: 56px; }
  .hero-actions { max-width: 190px; }
  .age-grid { grid-template-columns: 1fr; }
  .age-card { min-height: 95px; }
  .story-grid { gap: 10px; }
  .story-body { padding: 12px; }
  .story-body h3 { font-size: 16px; }
  .cover { font-size: 44px; }
  .stats-grid { grid-template-columns: 1fr; }
  .player-copy { max-width: 105px; }
  .player-control { flex-basis: 30px; }
  .map-points { gap: 6px; }
  .map-point b { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
