:root {
  --bg: #f8f3e6; --sheet: #fffdf6; --ink: #2f2a25; --muted: #7a7064; --line: #e6dcc4;
  --green: #2f6a49; --green-soft: #e7f1ea; --gold: #b0893e; --hl: #fff1c4;
  --f: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  --size: 1.125rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1c19; --sheet: #26251f; --ink: #ece6da; --muted: #b0a796; --line: #3c3a33; --green: #8cc7a3; --green-soft: #26372c; --gold: #d8b46a; --hl: #4a4022; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--f); padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); padding-bottom: 40px; }
.bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 8px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); max-width: 780px; margin: 0 auto; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--sheet); }
.seg button { font: inherit; font-size: .9rem; border: 0; background: none; color: var(--ink); padding: 6px 14px; min-height: 40px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--green); color: var(--sheet); font-weight: 700; }
.seg .l { font-size: 1.05rem; } .seg .xl { font-size: 1.25rem; }
.font { font-size: .9rem; display: inline-flex; gap: 6px; align-items: center; }
.font select { font: inherit; padding: 6px 8px; border-radius: 10px; border: 2px solid var(--line); background: var(--sheet); color: var(--ink); min-height: 40px; }
.main { font: inherit; font-weight: 700; border: 0; border-radius: 999px; padding: 8px 20px; min-height: 44px; background: var(--green); color: var(--sheet); cursor: pointer; }
.hint { color: var(--muted); font-size: .85rem; }
button:focus-visible, select:focus-visible, .text p:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.text { max-width: 780px; margin: 16px auto 0; background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 24px clamp(14px, 4vw, 36px); font-size: var(--size); line-height: 2.1; }
.text.ruby-off rt { display: none; }
.text.ruby-off { line-height: 1.95; }
rt { font-size: .5em; color: var(--muted); }
.ph { display: inline-block; }
.text h1 { font-size: 1.3em; line-height: 1.8; margin: 0 0 .8em; }
.text h2 { font-size: 1.15em; color: var(--green); margin: 1.6em 0 .6em; padding-inline-start: .5em; border-inline-start: 5px solid var(--green); }
.text p { margin: 0 0 1em; border-radius: 8px; }
.text p.voice { cursor: pointer; }
.text .reading { background: var(--hl); box-shadow: 0 0 0 6px var(--hl); }
.text .summary { background: var(--green-soft); padding: .2em .6em; margin: 0; }
.text .summary + .summary { margin-top: 0; }
.text .summary:last-of-type { margin-bottom: 1.2em; }
.text a { color: var(--green); font-weight: 700; }
/* 縦書き：右から左へ読む。横にスクロール */
.text.tate { writing-mode: vertical-rl; width: 100%; max-width: 780px; height: min(78vh, 760px); overflow-x: auto; overflow-y: hidden; line-height: 2.2; }
.text.tate h2 { border-inline-start: 0; border-block-start: 0; padding-inline-start: 0; border-inline-start: 5px solid var(--green); margin: 0 1.6em 0 .6em; }
.text.tate p { margin: 0 0 0 1em; }
.text.tate .num { text-combine-upright: all; }
.foot { max-width: 780px; margin: 16px auto 0; color: var(--muted); font-size: .85rem; text-align: center; }
.foot a { color: var(--green); }
/* 読み方をえらぶ（3つのページ共通） */
.ways { max-width: 780px; margin: 10px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ways a { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: 6px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--sheet); color: var(--ink); text-decoration: none; font-size: .92rem; line-height: 1.6; }
.ways a[aria-current="page"] { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 700; }
/* 声・動画のページ */
.mbox { max-width: 780px; margin: 16px auto 0; background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 20px clamp(14px, 4vw, 32px); line-height: 2; }
.mbox h1 { font-size: 1.3rem; margin: 0 0 .4em; color: var(--green); }
.mbox .lead { margin: 0 0 1em; }
.mbox audio { width: 100%; }
.mbox video { display: block; width: 100%; max-width: 100%; height: auto; border-radius: 10px; background: #000; }
.ch-title { font-size: 1rem; margin: 1.2em 0 .4em; }
.chapters { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.chapters button { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; font: inherit; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; min-height: 48px; cursor: pointer; line-height: 1.5; }
.chapters .tm { font-variant-numeric: tabular-nums; color: var(--green); font-weight: 700; min-width: 3.2em; }
body.media rt { font-size: .5em; }
.loading { margin: .6em 0 0; color: var(--green); font-weight: 700; }
.chapters button[aria-current="true"] { border-color: var(--green); background: var(--green-soft); font-weight: 700; }
