/* Golf: first round to business round. Palette from a yardage book and a scorecard:
   scorecard paper, pencil ink, fairway green for structure, mown-stripe tint behind diagrams,
   and scorecard red (the under-par color on a leaderboard) as the one accent.
   Sand and water appear only where they mean bunkers and penalty areas. */
:root {
  --paper: #F6F7F2;
  --ink: #17221B;
  --ink-soft: #4C5A50;
  --rule: #DDE3D8;
  --tint: #DCEAD3;
  --tint-2: #CBDFC0;
  --deep: #1F5B34;
  --accent: #B3261E;
  --bad: #C8102E;
  --good: #1F7A3E;
  --hi: #F2C300;
  --white: #FFFFFF;
  --sand: #E7D6A8;
  --water: #9CC7DE;
  --rough: #9DBF85;
  --green: #7DB663;
  --body: "Barlow", system-ui, sans-serif;
  --head: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --measure: 66ch;
  --r-lg: 18px;
  --r-sm: 10px;
}
html[data-size="1"] { font-size: 112.5%; }
html[data-size="2"] { font-size: 125%; }
body.legible { --body: "Atkinson Hyperlegible", system-ui, sans-serif; --head: "Atkinson Hyperlegible", system-ui, sans-serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1.125rem/1.6 var(--body); }
img, svg { display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button { font: inherit; color: inherit; cursor: pointer; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: .5rem; z-index: 50; background: var(--white); padding: .5rem 1rem; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 60px; padding: 0 clamp(1rem, 3vw, 2rem); background: rgba(246,247,242,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; font: 700 1.3rem/1 var(--head); }
.bar-nav { display: flex; align-items: center; gap: .25rem; }
.bar-link { background: none; border: 0; padding: .45rem .75rem; border-radius: 999px; color: var(--ink); text-decoration: none; font: 600 1rem/1 var(--body); }
.bar-link:hover, .bar-link[aria-current="page"] { background: var(--tint); color: var(--ink); }
.bar-aa { font-family: var(--head); font-size: 1.1rem; }
.brand { white-space: nowrap; }
@media (max-width: 430px) { .brand-rest { display: none; } .bar-link { padding: .45rem .6rem; } }
@media (max-width: 400px) { .brand-word { display: none; } .topbar { gap: .5rem; } .bar-link { padding: .45rem .5rem; } }

/* ---------- sheets (chapters, options) ---------- */
.sheet { border: 0; padding: 1.25rem 1.25rem 1.5rem; width: min(560px, 100%); max-height: 86vh; border-radius: var(--r-lg);
  background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(23,34,27,.28); }
.sheet::backdrop { background: rgba(23,34,27,.42); }
@media (max-width: 640px) {
  .sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.sheet-head h2 { margin: 0; font: 700 1.6rem/1.1 var(--head); }
.sheet-close { background: var(--tint); border: 0; border-radius: 999px; padding: .4rem .9rem; font-weight: 600; }
.opt { display: flex; flex-direction: column; gap: .4rem; margin-top: 1rem; }
.opt > span { font-weight: 600; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--tint); border-radius: 999px; width: fit-content; }
.seg button { border: 0; background: transparent; padding: .4rem .9rem; border-radius: 999px; font-size: .95rem; }
.seg button[aria-pressed="true"] { background: var(--white); box-shadow: 0 1px 3px rgba(23,34,27,.18); font-weight: 600; }

/* ---------- table of contents ---------- */
.toc { list-style: none; margin: 0; padding: 0; }
.toc a { display: grid; grid-template-columns: 2rem 1fr auto; align-items: baseline; gap: .25rem; padding: .55rem .5rem; border-radius: var(--r-sm);
  color: var(--ink); text-decoration: none; line-height: 1.3; }
.toc a:hover { background: var(--tint); }
.toc a[aria-current="page"] { background: var(--white); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.toc-n { font: 700 1rem/1 var(--head); color: var(--accent); }
.done .toc-done::after, .done .cl-done::after { content: "Read"; font-size: .78rem; font-weight: 600; color: var(--good); }
.offline-status { font-size: .9rem; color: var(--ink-soft); margin: 1rem 0 0; padding-left: .75rem; border-left: 3px solid var(--good); }
.offline-status.is-offline { border-left-color: var(--hi); }

/* ---------- page shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; max-width: 1240px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem); }
.side { display: none; }
@media (min-width: 1080px) {
  .shell { grid-template-columns: 250px minmax(0, 1fr); gap: 3.5rem; }
  .shell-wide { grid-template-columns: 1fr; }
  .side { display: block; position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow: auto; padding: 1.5rem 0; }
}
main { min-width: 0; padding-bottom: 3rem; }

/* ---------- type ---------- */
h1 { font: 700 clamp(2.6rem, 8vw, 4rem)/1 var(--head); letter-spacing: -.01em; margin: 0 0 .9rem; }
h2 { font: 700 1.85rem/1.1 var(--head); margin: 2.6rem 0 .8rem; }
.lede { font-size: 1.25rem; line-height: 1.5; color: var(--ink-soft); max-width: 44ch; margin: 0; }
p, li { max-width: var(--measure); }
.ch-head { padding: 2.2rem 0 1.5rem; }
.ch-num { margin: 0 0 .6rem; font: 600 1rem/1 var(--head); color: var(--accent); letter-spacing: .02em; }
.ch-meta { margin: .9rem 0 0; font-size: .95rem; color: var(--ink-soft); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: .6rem 1.3rem; border-radius: 999px;
  border: 2px solid var(--ink); background: transparent; color: var(--ink); text-decoration: none; font: 600 1.05rem/1.2 var(--body); }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--deep); border-color: var(--deep); color: var(--white); }

/* ---------- stage: where every animation lives ---------- */
.stage { position: relative; border-radius: var(--r-lg); padding: clamp(.75rem, 2.5vw, 1.5rem); margin: 0 0 2rem;
  background-color: var(--tint);
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.32) 0 46px, rgba(255,255,255,0) 46px 92px); }
.stage-title { margin: 0 0 .5rem; font: 700 1.15rem/1 var(--head); color: var(--deep); }
.stage-tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 .75rem; background: rgba(255,255,255,.55); border-radius: 999px; width: fit-content; max-width: 100%; overflow-x: auto; }
.stage-tabs button { border: 0; background: transparent; padding: .45rem 1rem; border-radius: 999px; font-weight: 600; white-space: nowrap; color: var(--deep); }
.stage-tabs button[aria-selected="true"] { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(23,34,27,.18); }
.diagram { margin: 0; }
.diagram svg { width: 100%; max-width: 520px; height: auto; margin: 0 auto; }
.diagram figcaption { text-align: center; font-size: .92rem; color: var(--ink-soft); margin: .6rem auto 0; max-width: 56ch; }
.readout { text-align: center; margin: .7rem auto 0; min-height: 3.2em; max-width: 52ch; font-size: 1.02rem; }

/* ---------- in short ---------- */
.in-short { background: var(--white); border-radius: var(--r-lg); padding: 1.25rem 1.5rem; margin: 0 0 1rem; box-shadow: inset 0 0 0 1px var(--rule); }
.in-short h2 { margin: 0 0 .5rem; font-size: 1.35rem; }
.in-short ul { margin: 0; padding-left: 1.2rem; }
.in-short li { margin: .3rem 0; }
.in-short li::marker { color: var(--accent); }

/* ---------- prose and accordions ---------- */
.prose > h2 { scroll-margin-top: 80px; }
.prose details { border-top: 1px solid var(--rule); }
.prose details:last-of-type { border-bottom: 1px solid var(--rule); }
.prose summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem .25rem; font: 600 1.12rem/1.35 var(--body); }
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after { content: ""; flex: none; width: 10px; height: 10px; border-right: 2.5px solid var(--deep); border-bottom: 2.5px solid var(--deep);
  transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
.prose details[open] > summary::after { transform: rotate(-135deg) translateY(-3px); }
.prose details > :not(summary) { margin-left: .25rem; margin-right: .25rem; }
.prose details > :last-child { margin-bottom: 1.25rem; }
.prose ol, .prose ul { padding-left: 1.3rem; }
.prose li { margin-bottom: .45rem; }
.prose summary label { cursor: pointer; display: flex; align-items: center; gap: .6rem; }
.prose input[type="checkbox"] { width: 1.2rem; height: 1.2rem; accent-color: var(--good); }
.checks { list-style: none; padding-left: 0 !important; }
.checks label { display: flex; gap: .6rem; align-items: flex-start; }
.checks input { margin-top: .3rem; flex: none; }
.callout { background: var(--white); border-radius: var(--r-sm); padding: .9rem 1.1rem; box-shadow: inset 0 0 0 1px var(--rule); }
.note { color: var(--ink-soft); font-size: 1rem; background: rgba(220,234,211,.55); padding: .75rem 1rem; border-radius: var(--r-sm); }
.note.warn { background: #FBE9EC; color: var(--ink); }
.ten { padding-left: 1.4rem; }
.ten li { margin-bottom: 1rem; }
.ten li::marker { font: 700 1.1rem var(--head); color: var(--accent); }
.print-row { margin-top: 2rem; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; margin: .5rem 0 1rem; display: block; overflow-x: auto; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font: 600 1rem var(--head); color: var(--ink-soft); }

/* ---------- flashcards ---------- */
.flash { background: var(--white); border-radius: var(--r-lg); padding: 1.5rem; box-shadow: inset 0 0 0 1px var(--rule); }
.flash-count { color: var(--ink-soft); font-size: .92rem; margin: 0 0 .4rem; }
.flash-q { font: 700 1.6rem/1.2 var(--head); margin: 0 0 1rem; }
.flash-a { background: var(--tint); padding: .9rem 1.1rem; border-radius: var(--r-sm); }
.flash-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.flash-btns button { border: 2px solid var(--ink); background: transparent; border-radius: 999px; padding: .5rem 1.1rem; font-weight: 600; }
.flash-btns button:hover { background: var(--ink); color: var(--paper); }

/* ---------- pager ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.pager a { display: flex; flex-direction: column; gap: .2rem; text-decoration: none; color: var(--ink); font: 700 1.35rem/1.15 var(--head); padding: .75rem 0; }
.pager a span { font: 500 .9rem var(--body); color: var(--ink-soft); }
.pager a:hover { color: var(--accent); }
.pager-next { text-align: right; align-items: flex-end; }

/* ---------- home ---------- */
.hero { display: grid; gap: 1.5rem; padding: 2.2rem 0 1rem; align-items: center; }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 3rem; padding-top: 3.5rem; } }
.hero h1 { font-size: clamp(3.2rem, 11vw, 6rem); line-height: .92; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.75rem; }
.hero-stage { margin: 0; }
.resume { margin-top: 1.25rem; font-size: 1rem; }
.home-chapters h2 { font-size: 2.2rem; }
.chapter-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.chapter-list a { display: grid; grid-template-columns: 96px 2.2rem minmax(0, 1fr) auto; gap: .9rem; align-items: center;
  padding: .9rem .25rem; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.chapter-list a:hover { background: var(--white); }
.thumb { width: 96px; height: 66px; object-fit: cover; border-radius: var(--r-sm); background: var(--tint); }
.thumb.icon { padding: 6px 14px; }
.cl-n { font: 700 1.6rem/1 var(--head); color: var(--accent); text-align: right; }
.cl-text { display: flex; flex-direction: column; gap: .15rem; }
.cl-t { font: 700 1.35rem/1.1 var(--head); }
.cl-s { font-size: .98rem; color: var(--ink-soft); line-height: 1.35; }
.cl-a { font-size: .85rem; font-weight: 600; color: var(--deep); }
@media (max-width: 560px) {
  .chapter-list a { grid-template-columns: 72px minmax(0, 1fr) auto; }
  .thumb { width: 72px; height: 54px; }
  .cl-n { display: none; }
}

/* ---------- gallery ---------- */
.gallery { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem 1.25rem; }
.gallery a { display: flex; flex-direction: column; gap: .3rem; color: var(--ink); text-decoration: none; }
.gallery img, .gal-blank { width: 100%; height: auto; aspect-ratio: 16 / 11; object-fit: cover; border-radius: var(--r-lg); background: var(--tint); margin-bottom: .4rem; }
.gal-t { font: 700 1.4rem/1.1 var(--head); }
.gal-d { font-size: 1rem; color: var(--ink-soft); line-height: 1.4; }
.gal-c { font-size: .88rem; font-weight: 600; color: var(--accent); }
.gallery a:hover .gal-t { color: var(--accent); }

/* ---------- footer ---------- */
.foot { max-width: 1240px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 3rem; border-top: 1px solid var(--rule); color: var(--ink-soft); font-size: .92rem; }
.signout button { border: 1px solid var(--rule); background: var(--white); border-radius: 999px; padding: .35rem .9rem; font-size: .85rem; color: var(--ink-soft); }
/* ---------- shared diagram pieces ---------- */
.svg-label { fill: var(--ink); font: 600 14px var(--body); }
.svg-small { fill: var(--ink-soft); font: 12px var(--body); }
.svg-red { fill: var(--bad); }
.svg-green { fill: var(--good); }
.svg-num-light { fill: #fff; font: 700 20px var(--head); }

/* ---------- diagram controls on the stage ---------- */
.anim-ctrl { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: .8rem 0 0; }
.anim-ctrl button { border: 0; background: rgba(255,255,255,.72); color: var(--deep); border-radius: 999px; padding: .5rem 1rem; font-weight: 600; font-size: .92rem; }
.anim-ctrl button:hover { background: var(--white); }
.anim-ctrl button[aria-pressed="true"] { background: var(--deep); color: var(--white); }
.stage .anim svg { max-width: 540px; }

/* ---------- hero without an animation ---------- */
@media (min-width: 900px) { .hero.hero-solo { grid-template-columns: minmax(0, 1fr); } }

/* ---------- golf diagrams: turf, sand, water, stakes ---------- */
:root { --fair: #A9CF8B; --putt: #C3E4A4; --fringe-c: #95C27A; --sky: #EAF3F7; }
html[data-theme="night"] { --fair: #3F6A39; --putt: #4E8248; --fringe-c: #36592F; --sky: #15232B; }
.g-rough { fill: var(--rough); }
.g-fairway { fill: none; stroke: var(--fair); stroke-width: 74; stroke-linecap: round; }
.g-fairstrip { fill: var(--fair); }
.g-fringe { fill: var(--fringe-c); }
.g-putting { fill: var(--putt); }
.g-bunker { fill: var(--sand); stroke: rgba(0,0,0,.12); }
.g-water { fill: var(--water); }
.g-ob { fill: rgba(255,255,255,.28); }
.g-tee { fill: var(--fair); stroke: var(--white); stroke-width: 1.5; }
.g-teemark { fill: var(--white); stroke: var(--ink); }
.g-stakes rect { stroke: var(--ink); stroke-width: .8; }
.g-stakes.red rect { fill: var(--bad); }
.g-stakes.yellow rect { fill: var(--hi); }
.g-stakes.white rect { fill: #fff; }
.g-cup { fill: #17221B; }
.g-pole { stroke: var(--ink); stroke-width: 1.6; }
.g-pennant { fill: var(--accent); }
.g-ball { fill: #fff; stroke: #17221B; stroke-width: 1.2; }
.g-shadow { fill: rgba(0,0,0,.22); }
.g-ballg.p1 .g-ball { fill: #B3261E; } .g-ballg.p2 .g-ball { fill: #2B4C7E; } .g-ballg.p3 .g-ball { fill: #D98200; } .g-ballg.p4 .g-ball { fill: #fff; }
.g-ballg.drop .g-ball { fill: var(--hi); }
.g-leader { stroke: var(--ink); stroke-width: 1; opacity: .55; }
.g-lab { font-size: 12.5px; paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.g-target { stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 5 6; opacity: .55; }
.g-pred { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 2 5; opacity: .5; }
.g-trail { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.g-face { stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
.g-patharrow line, .g-patharrow path { stroke: #2B4C7E; stroke-width: 2.5; fill: none; stroke-linecap: round; }
.g-sky { fill: var(--sky); }
.g-yardline { stroke: var(--ink); stroke-width: 1.2; opacity: .5; }
.g-loftpath { fill: none; stroke: var(--ink); stroke-width: 1.4; opacity: .22; stroke-dasharray: 3 4; }
.g-loftpath.on { stroke: var(--accent); opacity: 1; stroke-width: 2.6; stroke-dasharray: none; }
.g-best { fill: none; stroke: var(--hi); stroke-width: 3; }
.g-x path { stroke: var(--ink); stroke-width: 2.4; }
.g-optline { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
.g-optline.faint { opacity: .45; }
.g-optband { stroke: var(--hi); stroke-width: 10; stroke-linecap: round; opacity: .75; }
.g-dropzone { fill: rgba(242,195,0,.28); stroke: var(--hi); stroke-width: 2; }
.g-lateral { fill: rgba(242,195,0,.32); stroke: var(--hi); stroke-width: 2; }
.g-lateral.off { fill: rgba(200,16,46,.12); stroke: var(--bad); stroke-dasharray: 4 4; }
.g-slope path { fill: none; stroke: var(--deep); stroke-width: 2.4; opacity: .55; }
.g-hole { fill: #17221B; }
.g-aim { stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 4 5; opacity: .6; }
.g-putline { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 2 4; }
.g-putline.faint { opacity: .4; }
.g-marker { fill: var(--hi); stroke: var(--ink); }
.g-spot circle { stroke-width: 2.5; }
.g-spot.bad circle { fill: rgba(200,16,46,.2); stroke: var(--bad); }
.g-spot.good circle { fill: rgba(31,122,62,.2); stroke: var(--good); }
.g-walk { fill: none; stroke-width: 2.5; stroke-dasharray: 6 5; }
.g-walk.bad { stroke: var(--bad); opacity: .7; }
.g-walk.good { stroke: var(--good); }
.g-person { fill: #2B4C7E; stroke: #fff; stroke-width: 2; }
.g-ctl { display: flex; flex-wrap: wrap; gap: .4rem 1rem; justify-content: center; margin-top: .6rem; }
.g-ctl label { display: flex; align-items: center; gap: .5rem; font-size: .92rem; color: var(--ink-soft); }
.g-ctl input[type="range"] { width: 150px; accent-color: var(--deep); }
.anim-ctrl .ctl-label { font-size: .85rem; color: var(--ink-soft); font-weight: 600; margin-left: .4rem; }

/* ---------- handicap calculator ---------- */
.hc { background: var(--white); border-radius: var(--r-lg); padding: 1rem 1.1rem; }
.hc-in { display: grid; gap: .6rem; }
.hc-in label { display: grid; grid-template-columns: 9rem 1fr 3.2rem; align-items: center; gap: .6rem; font-size: .95rem; }
.hc-in input { width: 100%; accent-color: var(--deep); }
.hc-in output { font-weight: 700; text-align: right; }
.hc-out { margin: 1rem 0 .5rem; display: flex; flex-direction: column; gap: .2rem; }
.hc-out strong { font: 700 1.8rem/1.1 var(--head); color: var(--accent); }
.hc-out span { font-size: .92rem; color: var(--ink-soft); }
.hc-card table { font-size: .85rem; display: block; overflow-x: auto; white-space: nowrap; }
.hc-card th, .hc-card td { padding: .3rem .4rem; text-align: center; }
.hc-card th { text-align: left; }
.hc-dots { color: var(--accent); letter-spacing: -.1em; }

/* ---------- night mode: the twilight round. Dark turf, dimmed scorecard, same meanings for red, sand and water. ---------- */
html[data-theme="night"] {
  color-scheme: dark;
  --paper: #0F1813;
  --ink: #E1EAE2;
  --ink-soft: #A2B3A6;
  --rule: #24352A;
  --tint: #16261C;
  --tint-2: #1E3426;
  --deep: #8FD3A4;
  --accent: #FF7A6E;
  --bad: #FF5C70;
  --good: #5FD58A;
  --hi: #FFD23F;
  --white: #17241B;
  --sand: #6B5F3E;
  --water: #2C5268;
  --rough: #3A5A33;
  --green: #4F7F43;
}
html[data-theme="night"] .topbar { background: rgba(15,24,19,.94); }
html[data-theme="night"] .sheet { box-shadow: 0 20px 60px rgba(0,0,0,.6); }
html[data-theme="night"] .sheet::backdrop { background: rgba(0,0,0,.6); }
html[data-theme="night"] .stage { background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.04) 0 46px, rgba(255,255,255,0) 46px 92px); }
html[data-theme="night"] .stage-tabs { background: rgba(0,0,0,.25); }
html[data-theme="night"] .anim-ctrl button { background: rgba(255,255,255,.08); }
html[data-theme="night"] .anim-ctrl button:hover { background: rgba(255,255,255,.16); }
html[data-theme="night"] .anim-ctrl button[aria-pressed="true"] { background: var(--deep); color: var(--paper); }
html[data-theme="night"] .note { background: rgba(143,211,164,.1); }
html[data-theme="night"] .note.warn { background: rgba(255,92,112,.14); }
html[data-theme="night"] .thumb, html[data-theme="night"] .gallery img { filter: brightness(.82); }

/* ---------- brand mark and the twilight toggle (moon rises over the flag) ---------- */
.bi-pole { stroke: var(--ink); stroke-width: 1.6; } .bi-flag { fill: var(--accent); } .bi-cup { fill: var(--deep); }
.bar-theme { display: inline-flex; align-items: center; padding: .3rem .55rem; }
.bar-theme svg { width: 24px; height: 24px; }
.tw-pole { stroke: var(--ink); stroke-width: 1.6; } .tw-flag { fill: var(--accent); } .tw-ground { fill: var(--deep); }
.tw-moon { fill: var(--hi); opacity: 0; transform: translateY(5px); }
html[data-theme="night"] .tw-moon { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) { .tw-moon { transition: opacity .3s, transform .4s; } }

@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: sheet-in .22s ease-out; }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(16px); } }
  .flash-q.pop, .flash-a:not([hidden]) { animation: pop .3s ease-out both; }
  @keyframes pop { from { opacity: 0; transform: translateY(6px); } }
  :root { interpolate-size: allow-keywords; }
  .prose details::details-content { transition: height .28s ease, content-visibility .28s allow-discrete; height: 0; overflow: clip; }
  .prose details[open]::details-content { height: auto; }
}

@media print {
  .topbar, .side, .foot, .pager, .anim-ctrl, .stage-tabs, .skip, .print-row, .watch, .flash { display: none !important; }
  body { background: #fff; font-size: 10.5pt; }
  .shell { display: block; padding: 0; }
  .stage { background: none; padding: 0; }
  .prose details { break-inside: avoid; }
  .prose summary::after { display: none; }
}
