:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #283b33;
  background: #f7f5ec;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 290px;
  min-height: 100vh;
  min-height: 100svh;
  background: linear-gradient(180deg, #f1f7ef 0%, #f7f5ec 48%, #fbf7ed 100%);
}
button, input { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }
.app-shell {
  max-width: 960px;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 16px;
}
.brand { color: #587467; font-size: 15px; font-weight: 700; letter-spacing: .08em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.parent-toggle, .narration-toggle, .library-back, .parent-panel button, .manual-controls button {
  border: 1px solid #d5e2d8;
  border-radius: 999px;
  background: #f9fcf8;
  color: #47695b;
  cursor: pointer;
}
.parent-toggle, .narration-toggle, .library-back { min-height: 42px; padding: 8px 16px; font-size: 14px; }
.library-back { font-weight: 700; }
.narration-toggle[aria-pressed="true"] { background: #e2eee4; border-color: #b9d1bf; color: #2d5940; font-weight: 700; }
.library-intro { text-align: center; padding: 10px 0 25px; }
.eyebrow { margin: 0 0 8px; color: #7b927e; font-size: 14px; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(27px, 4.8vw, 38px); line-height: 1.35; letter-spacing: .04em; }
.library-intro > p:last-child { margin: 12px 0 0; color: #5f7869; font-size: 18px; }
.story-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.loading-message { grid-column: 1 / -1; text-align: center; color: #6d8573; }
.story-card {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 0;
  border: 1px solid #e0eadd;
  border-radius: 23px;
  background: #fffdf5;
  color: inherit;
  text-align: left;
  box-shadow: 0 11px 28px rgb(52 81 66 / 10%);
  cursor: pointer;
}
.story-card img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.story-card-copy { display: block; padding: 17px 20px 19px; }
.story-card-title { display: block; font-size: clamp(22px, 2.9vw, 28px); font-weight: 700; }
.story-card-subtitle { display: block; margin-top: 4px; color: #60786a; font-size: 15px; line-height: 1.5; }
.preview-entry { display: block; width: fit-content; margin: 20px auto 0; padding: 10px 16px; border: 1px solid #d5e2d8; border-radius: 999px; background: #f9fcf8; color: #47695b; text-decoration: none; font-size: 14px; }
.preview-entry:focus-visible { outline: 3px solid #739b83; outline-offset: 3px; }
.player { min-height: calc(100svh - 82px); touch-action: pan-x; }
.story-enter-up { animation: story-enter-up .2s ease-out; }
.story-enter-down { animation: story-enter-down .2s ease-out; }
@keyframes story-enter-up {
  from { opacity: .6; transform: translateY(25px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes story-enter-down {
  from { opacity: .6; transform: translateY(-25px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .story-enter-up, .story-enter-down { animation: none; }
}
.picture {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  max-height: min(60svh, 600px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  background: #dce9dc;
  box-shadow: 0 12px 34px rgb(52 81 66 / 12%);
  cursor: pointer;
}
.picture:disabled { cursor: default; }
.picture img { display: block; width: 100%; height: 100%; object-fit: contain; background: #e9efe4; user-select: none; -webkit-user-drag: none; }
.picture-control {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(18 39 30 / 13%);
  pointer-events: none;
}
.picture-control-icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgb(255 253 246 / 94%);
  box-shadow: 0 5px 25px rgb(25 50 37 / 18%);
}
.picture-control-icon svg { width: 39px; height: 39px; fill: #345545; }
.manual-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 14px; }
.manual-controls button { min-height: 50px; padding: 8px 16px; font-size: 17px; font-weight: 700; }
.manual-controls button:disabled { opacity: .43; cursor: default; }
.manual-position { min-width: 68px; color: #60786a; text-align: center; font-size: 16px; }
.reading-card { min-height: 160px; padding: 22px 12px 18px; text-align: center; }
.story-text { max-width: 790px; margin: 14px auto 0; font-size: clamp(19px, 3.5vw, 25px); line-height: 1.75; }
.parent-panel {
  position: fixed;
  z-index: 10;
  top: calc(env(safe-area-inset-top) + 66px);
  right: max(18px, calc((100vw - 960px) / 2 + 18px));
  width: min(340px, calc(100vw - 36px));
  padding: 20px;
  border: 1px solid #dbe8da;
  border-radius: 20px;
  background: #fffdf5;
  box-shadow: 0 15px 48px rgb(32 60 43 / 18%);
}
.parent-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.parent-panel h2 { margin: 0; font-size: 18px; }
.parent-panel-head button { min-height: 38px; padding: 6px 14px; }
.volume-control { display: grid; gap: 12px; margin: 22px 0; font-size: 16px; }
.volume-control input { width: 100%; accent-color: #668d74; }
.panel-button { width: 100%; min-height: 46px; padding: 8px 15px; }
.story-card:focus-visible, .picture:focus-visible, .parent-toggle:focus-visible,
.narration-toggle:focus-visible, .library-back:focus-visible, .manual-controls button:focus-visible,
.parent-panel button:focus-visible, .volume-control input:focus-visible { outline: 3px solid #739b83; outline-offset: 3px; }
@media (max-width: 600px) {
  .app-shell { padding-inline: 12px; }
  .topbar { margin-bottom: 4px; }
  .library-intro { padding: 2px 0 18px; }
  .story-grid { grid-template-columns: 1fr; gap: 13px; max-width: 440px; margin: 0 auto; }
  .story-card { border-radius: 18px; }
  .story-card img { aspect-ratio: 2.15 / 1; }
  .story-card-copy { padding: 11px 15px 13px; }
  .story-card-subtitle { font-size: 13px; }
  .picture { border-radius: 17px; max-height: 57svh; }
  .picture.mobile-portrait { aspect-ratio: 4 / 5; max-height: 63svh; }
  .picture.mobile-portrait img { object-fit: cover; }
  .library-back { padding-inline: 12px; }
  .reading-card { padding: 18px 8px 14px; }
  .manual-controls { gap: 6px; margin-top: 10px; }
  .manual-controls button { padding: 8px 10px; font-size: 16px; }
  .manual-position { min-width: 58px; font-size: 14px; }
}
@media (max-height: 680px) and (orientation: landscape) {
  .picture { max-height: 54svh; }
  .reading-card { min-height: 0; padding-top: 11px; }
  .story-text { margin-top: 6px; }
}
