:root {
  color-scheme: light;
  --forest: #103f2e;
  --forest-2: #1a5c42;
  --banana: #ffd84f;
  --banana-deep: #efb90d;
  --cream: #fffdf2;
  --ink: #17342b;
  --muted: #63756d;
  --card: rgba(255, 255, 255, 0.94);
  --shadow: 0 24px 70px rgba(14, 58, 42, 0.2);
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; min-height: 100%; }

body {
  min-height: 100dvh;
  overflow: hidden;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255,216,79,.58), transparent 22rem),
    linear-gradient(145deg, #dff7ef, #f7ffe9 48%, #d9f3e8);
}

button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.reader-shell {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr) 104px;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.topbar, .controls {
  display: grid;
  align-items: center;
}

.topbar {
  grid-template-columns: minmax(210px, .7fr) minmax(230px, 1.2fr) minmax(210px, .7fr);
  gap: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.banana-mark {
  display: grid; place-items: center; width: 50px; height: 50px;
  border-radius: 16px; background: var(--forest); font-size: 28px;
  box-shadow: 0 8px 20px rgba(16,63,46,.2);
}
.brand div { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 1.08rem; letter-spacing: .16em; }
.brand span:last-child { margin-top: 5px; color: var(--muted); font-weight: 650; }

.progress-wrap { display: flex; align-items: center; gap: 13px; color: var(--forest); font-weight: 800; }
.progress-track { height: 12px; flex: 1; border-radius: 999px; background: rgba(16,63,46,.12); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 8.33%; background: linear-gradient(90deg, var(--banana), #ffba18); border-radius: inherit; transition: width .35s ease; }
.progress-wrap span { min-width: 62px; }

.icon-button, .nav-button, .round-button, .play-button {
  border: 0; cursor: pointer; touch-action: manipulation;
}
.icon-button {
  justify-self: end; display: flex; align-items: center; gap: 9px;
  min-height: 48px; padding: 0 17px; border-radius: 14px;
  color: var(--forest); background: rgba(255,255,255,.7); font-weight: 800;
}
.icon-button svg, .nav-button svg, .round-button svg, .play-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.reading-stage {
  min-height: 0;
  max-height: min(68dvh, 720px);
  align-self: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 16px;
}

.picture-panel {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  align-self: center;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 30px;
  background: #c8ebda;
  box-shadow: var(--shadow);
}
.picture-panel::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 -45px 55px rgba(16,63,46,.12); pointer-events: none; }
.picture-panel img { width: 100%; height: 100%; object-fit: contain; display: block; transition: opacity .22s ease, transform .7s ease; }
.picture-panel img.changing { opacity: .2; transform: scale(1.025); }
.picture-panel figcaption {
  position: absolute; left: 22px; bottom: 22px; z-index: 2;
  max-width: calc(100% - 44px); padding: 11px 16px;
  border-radius: 999px; color: white; background: rgba(16,63,46,.84);
  font-weight: 750; backdrop-filter: blur(12px);
}

.caption-panel {
  min-height: 0;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  display: flex; flex-direction: column;
  padding: clamp(20px, 2.2vw, 34px);
  overflow: hidden;
  border-radius: 30px;
  box-shadow: var(--shadow);
  background:
    linear-gradient(rgba(255,255,255,.92), rgba(255,255,255,.97)),
    radial-gradient(circle at 100% 0, rgba(255,216,79,.45), transparent 50%);
}

.caption-heading { display: block; }
.eyebrow { display: block; margin-bottom: 8px; color: #2c7b59; font-size: .82rem; font-weight: 900; letter-spacing: .18em; }
h1 { margin: 0; max-width: 640px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.3rem, 2vw, 2rem); line-height: 1.15; color: var(--forest); }
.read-caption {
  flex: 1; display: flex; align-content: center; align-items: center; flex-wrap: wrap;
  gap: .08em .22em; margin: 12px 0 8px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: clamp(1.9rem, 3.35vw, 3.4rem);
  line-height: 1.26;
  font-weight: 760;
  letter-spacing: -.025em;
}
.read-caption.medium { font-size: clamp(1.75rem, 2.9vw, 3rem); }
.read-caption.long { font-size: clamp(1.55rem, 2.48vw, 2.58rem); }
.word { position: relative; display: inline-block; padding: .03em .06em .08em; border-radius: .18em; transition: color .12s ease, background .12s ease, transform .12s ease; }
.word.active { color: #12382a; background: var(--banana); box-shadow: 0 .13em 0 var(--banana-deep); transform: translateY(-.04em); }
.word.learn { cursor: help; text-decoration: underline dotted #318564 3px; text-underline-offset: .16em; }

.word-helper { align-self: flex-start; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px; border-radius: 14px; background: #e9f8ef; color: var(--forest); }
.word-helper span { padding: 3px 9px; border-radius: 8px; background: var(--banana); font-weight: 900; }
.word-helper strong { font-size: 1rem; }
.tap-hint { margin: 10px 0 0; color: var(--muted); font-size: .88rem; font-weight: 650; }

.controls {
  grid-template-columns: 1fr auto 1fr;
  gap: 22px;
  padding: 8px 8px 0;
}
.nav-button {
  display: inline-flex; align-items: center; gap: 7px; justify-self: start;
  min-height: 56px; padding: 0 20px; border-radius: 17px;
  color: var(--forest); background: rgba(255,255,255,.78); font-weight: 850;
  box-shadow: 0 7px 22px rgba(16,63,46,.08);
}
.nav-button.next { justify-self: end; background: var(--forest); color: white; }
.nav-button:disabled { opacity: .35; cursor: default; }
.play-cluster { display: flex; align-items: center; gap: 13px; }
.round-button { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; color: var(--forest); background: white; box-shadow: 0 7px 22px rgba(16,63,46,.1); }
.play-button { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 150px; height: 68px; padding: 0 25px; border-radius: 24px; color: var(--forest); background: var(--banana); font-size: 1.18rem; font-weight: 900; box-shadow: 0 12px 30px rgba(239,185,13,.3); }
.play-button .pause-icon { display: none; }
.play-button.playing .play-icon { display: none; }
.play-button.playing .pause-icon { display: block; }
.speed-control { display: flex; align-items: center; gap: 8px; padding: 8px 9px 8px 13px; border-radius: 15px; background: rgba(255,255,255,.75); color: var(--muted); font-size: .82rem; font-weight: 800; }
.speed-control select { border: 0; outline: 0; color: var(--forest); background: transparent; font-weight: 850; }

.toast { position: fixed; left: 50%; bottom: 126px; z-index: 20; transform: translate(-50%, 18px); padding: 10px 16px; border-radius: 12px; background: rgba(16,63,46,.94); color: white; opacity: 0; pointer-events: none; transition: .2s ease; font-weight: 750; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px), (orientation: portrait) {
  body { overflow-x: hidden; overflow-y: auto; }
  .reader-shell { min-height: 100dvh; height: auto; grid-template-rows: auto minmax(0, 1fr) auto; padding: 12px; }
  .topbar { grid-template-columns: 1fr auto; }
  .progress-wrap { grid-row: 2; grid-column: 1 / -1; }
  .icon-button span { display: none; }
  .reading-stage { max-height: none; grid-template-columns: 1fr; grid-template-rows: auto auto; gap: 12px; }
  .picture-panel { aspect-ratio: 3 / 2; border-radius: 26px; }
  .caption-panel { min-height: 350px; aspect-ratio: auto; padding: 24px; }
  .read-caption { font-size: clamp(2rem, 7.8vw, 3.5rem); min-height: 270px; }
  .read-caption.medium { font-size: clamp(1.8rem, 6.8vw, 3.1rem); }
  .read-caption.long { font-size: clamp(1.65rem, 5.8vw, 2.75rem); }
  .controls { position: sticky; bottom: 0; z-index: 10; grid-template-columns: auto 1fr auto; gap: 8px; padding: 10px; border-radius: 24px; background: rgba(235,248,240,.94); backdrop-filter: blur(12px); }
  .nav-button { padding: 0 14px; }
  .nav-button span { display: none; }
  .play-cluster { justify-content: center; }
  .speed-control { display: none; }
  .play-button { min-width: 132px; }
}

@media (max-height: 650px) and (orientation: landscape) {
  .reader-shell { grid-template-rows: 54px minmax(0, 1fr) 76px; gap: 10px; padding: 10px 16px; }
  .banana-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 23px; }
  .brand span:last-child, .icon-button span { display: none; }
  .reading-stage { border-radius: 25px; }
  .caption-panel { padding: 24px 34px; }
  .play-button { height: 58px; border-radius: 19px; }
  .tap-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
