/* Layout: contents page = one column of big tappable rows; reader = sticky control bar, one page at a time (photos on top, big tappable words below), page-turn buttons underneath. */
:root {
  --bg: #e9f5f4;          /* suds */
  --surface: #ffffff;
  --ink: #17304a;         /* deep tub blue */
  --muted: #5d7488;
  --line: #cfe3e2;
  --accent: #0f7c86;      /* tub teal */
  --accent-ink: #ffffff;
  --sun: #ffd23f;         /* highlighter: the word being read */
  --sun-ink: #2a2100;
  --done: #0f7c86;        /* words already read */
  --row-on: #fff8dc;
  --shade: rgba(10, 24, 36, .92);
  --display: "Baloo 2", ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
  --body: "Andika", ui-rounded, "Century Gothic", "Avenir Next", "Segoe UI", sans-serif;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1f2b; --surface: #17303f; --ink: #eaf4f6; --muted: #9db4c2; --line: #27485a;
    --accent: #4fc3cc; --accent-ink: #06262b; --sun: #ffd23f; --sun-ink: #2a2100;
    --done: #7fd9e0; --row-on: #223d4c; --shade: rgba(3, 10, 16, .95); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
button, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; }

/* ---------- contents ---------- */
.home { max-width: 720px; margin: 0 auto; padding-block: 28px 40px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); display: flex; flex-direction: column; gap: 22px; }
.home-head { display: flex; flex-direction: column; gap: 4px; }
.home h1 { font-family: var(--display); font-weight: 700; font-size: clamp(32px, 8vw, 48px); line-height: 1.1; margin: 0; text-wrap: balance; }
.sub { margin: 0; color: var(--muted); font-size: 16px; }
.sections { display: flex; flex-direction: column; gap: 26px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section h2 { font-family: var(--display); font-weight: 700; font-size: clamp(22px, 5.5vw, 28px); margin: 0; }
.section ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
a.item { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 2px solid transparent; border-radius: 22px; padding: 14px 16px; color: inherit; text-decoration: none; }
a.item:hover, a.item:active { border-color: var(--accent); }
.num { flex: none; width: 60px; height: 60px; border-radius: 50%; background: var(--sun); color: var(--sun-ink); display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 22px; overflow: hidden; }
.num.cover { border-radius: 12px; width: 54px; height: 72px; background: var(--line); }
.num.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.name { font-size: clamp(22px, 5.6vw, 30px); line-height: 1.2; font-weight: 700; }
.meta { color: var(--muted); font-size: 14.5px; }
.go { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.go svg { width: 20px; height: 20px; fill: currentColor; }
.oops { max-width: 720px; margin: 40px auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); font-size: 18px; }
.oops a { color: var(--accent); font-weight: 700; }

/* ---------- reader bar ---------- */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); border-bottom: 2px solid var(--line); padding-block: 10px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.bar-in { max-width: 900px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.back { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; }
.back svg { width: 22px; height: 22px; fill: currentColor; }
.all { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-weight: 700; font-size: 18px; padding: 8px 20px 8px 14px; min-height: 48px; }
.all svg, .play svg, .nav svg, .pagebtn svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.speeds { display: flex; flex: 1 1 300px; min-width: 0; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; }
.speeds button { flex: 1 1 0; min-width: 0; border: 0; background: transparent; border-radius: 10px; padding: 4px 2px; min-height: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; color: var(--muted); }
.speeds button b { font-family: var(--display); font-size: 17px; color: var(--ink); }
.speeds button span { font-size: 11.5px; }
.speeds button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.speeds button[aria-pressed="true"] b { color: var(--accent-ink); }

/* ---------- reader body ---------- */
.read { max-width: 900px; margin: 0 auto; padding-block: 18px 40px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.head-t { min-width: 0; }
.note { color: var(--muted); font-size: 15px; margin: 0; }
.read h1 { font-family: var(--display); font-weight: 700; font-size: clamp(28px, 6.5vw, 44px); line-height: 1.1; margin: 0; text-wrap: balance; }
.count { font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--muted); font-variant-numeric: tabular-nums; }

.stage { overflow: hidden; }
.page { display: flex; flex-direction: column; gap: 14px; }
.page.in-next { animation: inNext .32s ease-out; }
.page.in-prev { animation: inPrev .32s ease-out; }
@keyframes inNext { from { transform: translateX(14%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes inPrev { from { transform: translateX(-14%); opacity: 0; } to { transform: none; opacity: 1; } }
.pics { display: flex; gap: 6px; justify-content: center; background: var(--surface); border-radius: 22px; padding: 8px; touch-action: pan-y pinch-zoom; }
.pic { flex: 1 1 0; min-width: 0; max-width: 520px; border: 0; padding: 0; background: transparent; border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; }
.pic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pics.one .pic { max-width: min(520px, 75%); }

.para { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-radius: 22px; padding: 10px; }
.sent { display: flex; align-items: flex-start; gap: 12px; padding: 8px 10px; border-radius: 14px; }
.sent.on { background: var(--row-on); }
.play { --fs: clamp(24px, 5.6vw, 36px); flex: none; width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--accent); display: grid; place-items: center; margin-top: calc((var(--fs) * 1.45 - 46px) / 2); }
.sent.on .play { background: var(--accent); color: var(--accent-ink); }
.sent p { margin: 0; min-width: 0; flex: 1; font-size: clamp(24px, 5.6vw, 36px); line-height: 1.45; letter-spacing: .01em; word-spacing: .12em; }
.lesson .play { --fs: clamp(26px, 6.2vw, 40px); }
.lesson .sent p { font-size: clamp(26px, 6.2vw, 40px); line-height: 1.5; }
.w { display: inline-block; padding: 0 .12em; margin: 0 -.02em; border-radius: .22em; cursor: pointer; transition: background-color .08s, color .15s; }
.w.done { color: var(--done); }
.w.on { background: var(--sun); color: var(--sun-ink); }
.pagebtn { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--accent); background: transparent; color: var(--accent); border-radius: 999px; font-family: var(--display); font-weight: 700; font-size: 16px; padding: 6px 16px 6px 10px; min-height: 44px; margin: 4px 10px 6px; }

.navrow { display: flex; align-items: center; gap: 12px; }
.nav { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 56px; border-radius: 18px; border: 2px solid var(--line); background: var(--surface); font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--ink); }
.nav.next { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.nav:disabled { opacity: .35; cursor: default; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.dots button { width: 14px; height: 14px; padding: 0; border-radius: 50%; border: 2px solid var(--accent); background: transparent; }
.dots button[aria-current="true"] { background: var(--accent); }

.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--muted); font-size: 14px; }
.foot label { font-weight: 700; }
.foot select { flex: 1 1 200px; min-width: 0; max-width: 100%; min-height: 40px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); padding: 4px 8px; }
.tip { margin: 0; flex-basis: 100%; }
.warn { background: var(--sun); color: var(--sun-ink); border-radius: 14px; padding: 12px 14px; margin: 0; }

.lb { position: fixed; inset: 0; z-index: 20; background: var(--shade); overflow: auto; padding-top: calc(64px + env(safe-area-inset-top, 0px)); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.lb img { display: block; width: 100%; max-width: 1100px; height: auto; margin: 0 auto; }
.lb-x { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--surface); color: var(--ink); font-size: 26px; line-height: 1; display: grid; place-items: center; }
@media (prefers-reduced-motion: reduce) { .w { transition: none; } .page.in-next, .page.in-prev { animation: none; } }
