:root {
      color-scheme: light;
      --page: #faf8f3;
      --panel: #f1eee6;
      --paper: #fffdf8;
      --ink: #252b24;
      --muted: #535b51;
      --line: #d9d8cd;
      --accent: #315746;
      --accent-ink: #fffdf8;
      --hero: #203d32;
      --hero-ink: #fcf4e2;
      --hero-secondary: #d7e2cc;
      --reading-size: 1.25rem;
    }

    :root[data-theme="dark"] {
      color-scheme: dark;
      --page: #191e1b;
      --panel: #222a24;
      --paper: #202722;
      --ink: #f0ebdf;
      --muted: #b9c1b1;
      --line: #414d43;
      --accent: #a8d0b5;
      --accent-ink: #152b20;
      --hero: #233f34;
    }

    @media (prefers-color-scheme: dark) {
      :root[data-theme="system"] {
        color-scheme: dark;
        --page: #191e1b;
        --panel: #222a24;
        --paper: #202722;
        --ink: #f0ebdf;
        --muted: #b9c1b1;
        --line: #414d43;
        --accent: #a8d0b5;
        --accent-ink: #152b20;
        --hero: #233f34;
      }
    }

    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    body { margin: 0; background: var(--page); color: var(--ink); font: 1rem/1.55 system-ui, sans-serif; }
    a { color: var(--accent); text-underline-offset: .2em; }
    a:hover { text-decoration-thickness: 2px; }
    button, select { font: inherit; color: inherit; }
    :focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
    .skip { position: fixed; top: .4rem; left: .5rem; z-index: 5; padding: .5rem; background: var(--paper); transform: translateY(-150%); }
    .skip:focus { transform: translateY(0); }
    .wrap { width: min(100% - 2rem, 70rem); margin-inline: auto; }
    .reader-settings { position: fixed; top: max(.75rem, env(safe-area-inset-top)); right: max(.75rem, env(safe-area-inset-right)); z-index: 4; }
    .reader-settings summary { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; list-style: none; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--ink); cursor: pointer; box-shadow: 0 2px 10px #0001; }
    .reader-settings summary::-webkit-details-marker { display: none; }
    .reader-settings[open] summary { margin-left: auto; background: var(--panel); }
    .settings-panel { position: absolute; right: 0; top: calc(100% + .5rem); width: min(18rem, calc(100vw - 1.5rem)); padding: 1rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--paper); box-shadow: 0 8px 30px #0002; }
    .settings-panel > strong { display: block; margin-bottom: .85rem; }
    .settings-panel > a { display: inline-block; margin-top: 1rem; }
    .settings-panel .progress-label { margin-top: 1rem; }
    .controls, .size-group { display: flex; align-items: center; }
    .controls { gap: .65rem; }
    .size-group { border: 1px solid var(--line); border-radius: .45rem; }
    button, select { background: var(--paper); min-height: 2.65rem; min-width: 2.65rem; cursor: pointer; }
    button { border: 0; border-radius: .4rem; font-weight: 650; }
    button + button { border-left: 1px solid var(--line); border-top-left-radius: 0; border-bottom-left-radius: 0; }
    button:hover, select:hover { background: var(--panel); }
    button:disabled { opacity: .48; cursor: default; }
    select { border: 1px solid var(--line); border-radius: .45rem; font-size: .9rem; padding: 0 1rem 0 .6rem; }
    progress { margin-top: .4rem; display: block; appearance: none; width: 100%; height: 3px; border: 0; background: transparent; }
    progress::-webkit-progress-bar { background: transparent; }
    progress::-webkit-progress-value { background: var(--accent); }
    progress::-moz-progress-bar { background: var(--accent); }
    .layout { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 49rem); gap: clamp(1.5rem, 5vw, 4.75rem); align-items: start; padding-block: 2.65rem 4rem; }
    .sidebar { position: sticky; top: 1.5rem; font-size: .925rem; }
    .back { display: inline-block; margin-bottom: 1.85rem; font-weight: 650; }
    .sidebar h2 { margin: 0 0 .6rem; font-size: .95rem; }
    .sidebar ol { list-style: none; padding: 0; margin: 0 0 1.35rem; }
    .sidebar li a { display: block; border-left: 2px solid var(--line); padding: .38rem .7rem; color: var(--muted); text-decoration: none; }
    .sidebar li a:hover, .sidebar li a[aria-current="location"] { color: var(--accent); background: var(--panel); border-color: var(--accent); }
    .progress-label { margin: 0; font-size: .85rem; color: var(--muted); }
    .hero { padding: clamp(1.75rem, 5vw, 3.9rem); border-radius: .85rem; background: var(--hero); color: var(--hero-ink); }
    .hero p { margin: 0; }
    .hero .series { color: var(--hero-secondary); font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
    h1, .story h2, .lesson h2 { font-family: Georgia, serif; }
    h1 { margin: .7rem 0 1rem; max-width: 15ch; font-size: clamp(2.3rem, 6vw, 4.5rem); letter-spacing: -.04em; line-height: 1.02; font-weight: normal; }
    .hero .byline { color: var(--hero-secondary); font-size: .92rem; }
    .story-tools { margin: 1rem 0 2.25rem; padding: .7rem 0; display: flex; gap: .55rem 1rem; flex-wrap: wrap; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); font-size: .9rem; }
    .story-tools .level { color: var(--muted); }
    .story-tools a, .lesson a { font-weight: 650; }
    .story { max-width: 39em; margin-inline: auto; font: var(--reading-size)/1.72 Georgia, serif; }
    .story section { margin-block: 0 2.3em; }
    .story h2 { font-size: 1.48em; line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.025em; font-weight: normal; }
    .story :is(h2, p), article { scroll-margin-top: 1.5rem; }
    .story p { margin: 0 0 .85em; overflow-wrap: anywhere; }
    .lesson { margin-top: 2.5rem; border: 1px solid var(--line); border-radius: .7rem; padding: 1.4rem; background: var(--panel); }
    .lesson h2 { margin: 0; font-size: 1.45rem; }
    .lesson p { margin: .3rem 0 .75rem; color: var(--muted); }
    @media (max-width: 48rem) {
      .layout { display: block; padding-top: 1.25rem; }
      .sidebar { display: none; }
    }
    @media (max-width: 24rem) {
      .wrap { width: calc(100% - 1.5rem); }
      .controls { gap: .35rem; }
      button { min-width: 2.2rem; }
      select { padding-inline: .35rem; }
    }
.preview-notice { padding: .65rem 1rem; background: #fff1b8; color: #252b24; text-align: center; }
.story-tools .browse-stories { display: none; }
@media (max-width: 48rem) { .story-tools .browse-stories { display: inline; } }
