/* readode reader prototype. These variables are the night-field template (handwritten verse in chalk cream and gold);
   templates.js overrides them per story. Colours come from design-system/tokens.css (yellow, yellow-pale, pink). */
:root {
  --night: #06123a;
  --ink: #fdf3c4;
  --gold: #ffd24a;
  --pale: #faed8f;
  --pink: #fd48f2;
  --accent: var(--gold);
  --font-body: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --font-title: var(--font-body);
  --ui: "MD Nichrome", "Helvetica Neue", Arial, system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  /* text */
  --body-weight: 500; --body-lh: 1.14; --hang: 0.9em; --gap-em: 0.62; --justify: center;
  --title-weight: 700; --title-style: normal; --title-scale: 1.45; --title-lh: 1;
  --sheet-top: 13%; --sheet-bottom: 26%;
  --cover-size: 16.5cqw; --cover-lh: 0.92; --by-size: 9.2cqw; --end-size: 17cqw; --cover-top: 15%;
  /* surfaces and controls */
  --btn-bg: var(--pink); --btn-fg: #000; --btn2-bg: var(--pale);
  --chip-bg: rgba(6, 18, 58, 0.55); --bar-bg: rgba(253, 243, 196, 0.14); --bar-fill: var(--pink);
  --text-shadow: 0 1px 14px rgba(2, 8, 40, 0.6);
  --scrim: linear-gradient(to bottom, rgba(3, 8, 34, 0.5), rgba(3, 8, 34, 0) 20%), rgba(3, 8, 34, 0.1);
  --stage-bg: #0b0b0f; /* neutral until a template says otherwise: nothing may flash before the real look is known */
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #0b0b0f; color: var(--ink); -webkit-tap-highlight-color: transparent; }
@media (max-width: 599px) { html, body { background: var(--stage-bg); } } /* on a phone the stage fills the screen, so the page wears its colour from the first paint */
body { display: grid; place-items: center; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- stage: a 9:16 window; fills a phone, stays a phone-shaped column on desktop */
.stage {
  position: relative; overflow: hidden; background: var(--stage-bg); container-type: size;
  height: 100vh; height: 100dvh; width: min(100vw, calc(100dvh * 9 / 16));
  opacity: 0; transition: opacity 0.6s var(--ease-out); /* revealed once the text and the background are both ready */
}
.stage.shown { opacity: 1; }
@media (min-width: 600px) { .stage { border-radius: 22px; height: min(100dvh, 960px); width: min(100vw, calc(min(100dvh, 960px) * 9 / 16)); } }
.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%; opacity: 0; transition: opacity 0.9s var(--ease-out); }
.bg.on { opacity: 1; } /* faded in when its first frame is drawn, never popped in */
/* --stage-bg is also what shows if the background cannot load */
.scrim { position: absolute; inset: 0; pointer-events: none; background: var(--scrim); }

/* the cover that flew in from the front page holds the screen, the same size as the stage, until the reader is ready */
.splash { display: none; position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%, -50%); height: 100vh; height: 100dvh; width: min(100vw, calc(100dvh * 9 / 16)); background: #0b0b0f center / cover no-repeat; pointer-events: none; transition: opacity 0.7s var(--ease-out); }
.splash.on { display: block; }
.splash.gone { opacity: 0; }
@media (min-width: 600px) { .splash { border-radius: 22px; height: min(100dvh, 960px); width: min(100vw, calc(min(100dvh, 960px) * 9 / 16)); } }

/* ---- HUD: loading-style progress, rolling counter, sound */
.bar { position: absolute; z-index: 6; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 3px; background: var(--bar-bg); }
.bar i { display: block; height: 100%; background: var(--bar-fill); transform-origin: 0 50%; transform: scaleX(0); will-change: transform; transition: background 0.4s; }
.hud { position: absolute; z-index: 5; inset: 0 0 auto 0; display: flex; justify-content: space-between; align-items: flex-start; padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px 0 20px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.count { display: flex; align-items: center; gap: 7px; font: 700 22px/1 var(--ui); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; transition: color 0.4s; background: var(--count-bg, transparent); padding: 6px 12px; margin: -6px -12px; border-radius: 1rem; }
.odo { display: inline-block; height: 1.2em; overflow: hidden; }
.odo .col { display: flex; flex-direction: column; transform: translateY(calc(var(--v, 0) * -1.2em)); transition: transform 0.75s cubic-bezier(0.3, 1.35, 0.5, 1); }
.odo i { display: block; height: 1.2em; line-height: 1.2; font-style: normal; }
.of { font-size: 13px; font-weight: 500; opacity: 0.6; }
.hud-right { display: flex; gap: 8px; }
.sound { width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: var(--chip-bg); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); cursor: pointer; transition: transform 0.15s var(--ease-out); }
.sound:active { transform: scale(0.94); }
.back { text-decoration: none; }
.framed .back { display: none; } /* inside the studio preview there is nowhere to go back to */
.sound { position: relative; }
.sound.loading { opacity: 0.6; }
/* a ring pulses on the speaker until sound has really started, so it is clear one tap is needed */
.sound.invite::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--bar-fill); animation: ring 1.8s var(--ease-out) infinite; pointer-events: none; }
@keyframes ring { from { transform: scale(0.85); opacity: 0.9; } to { transform: scale(1.4); opacity: 0; } }
.sound svg { display: block; margin: auto; }
/* the text-animation button has no "off" icon in the set, so a slash is drawn over it */
#anim[aria-pressed="false"] svg { opacity: 0.55; }
#anim[aria-pressed="false"]::before { content: ""; position: absolute; left: 24%; right: 24%; top: 50%; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(-45deg); pointer-events: none; }
.stage.complete .count { color: var(--accent); }
.stage.complete .bar i { background: var(--accent); }

/* ---- pages: one native scroll-snap column, one screen per page */
.pages { position: absolute; inset: 0; z-index: 2; overflow-y: auto; overflow-x: hidden; scroll-snap-type: y mandatory; overscroll-behavior: none; scrollbar-width: none; touch-action: pan-y; outline: none; opacity: 0; transition: opacity 0.5s; }
.pages::-webkit-scrollbar { display: none; }
.stage.ready .pages { opacity: 1; }
.page { position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; contain: layout paint style; }
.sheet, .cover-in, .end-in { will-change: opacity, transform; }
/* text animation off: everything is simply there. (Set by the creator's default, the reader's own toggle, or the system setting.) */
.no-anim .ln { -webkit-mask: none; mask: none; animation: none !important; transform: none; }
.no-anim .rule path { animation: none !important; stroke-dashoffset: 0; }

/* poem text: the sky above the horizon is the writing surface; the bottom quarter stays clear for the figure */
.sheet { position: absolute; left: 9%; right: 8%; top: var(--sheet-top); bottom: var(--sheet-bottom); display: flex; flex-direction: column; justify-content: var(--justify); font-family: var(--font-body); font-weight: var(--body-weight); color: var(--ink); text-shadow: var(--text-shadow); }
.flow { --lh: var(--body-lh); line-height: var(--lh); }
.stz { margin-top: calc(var(--gap, 0) * var(--gap-em) * 1em); }
.src { margin: 0; }
.src:not(.split) { padding-left: var(--hang); text-indent: calc(-1 * var(--hang)); } /* measuring mode: hanging indent for wrapped lines */
.sheet.measure { visibility: hidden; pointer-events: none; }
.note { font: 500 clamp(11px, 3.2cqw, 13px)/1.2 var(--ui); letter-spacing: 0.02em; opacity: 0.7; margin: 0 0 1.1em; }
.title, .cover h1, .end h2 { text-transform: var(--title-transform, none); }
.title { font-family: var(--font-title); font-size: calc(var(--title-scale) * 1em); font-weight: var(--title-weight); font-style: var(--title-style); color: var(--accent); line-height: var(--title-lh); margin: 0; }
.title .ln { transform-origin: 0 70%; }
.rule { display: block; width: min(62%, 11em); height: 0.3em; margin: 0.12em 0 0.42em; overflow: visible; }
.rule path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; }
.page.on .rule path { animation: draw 0.7s var(--ease-out) var(--rd, 0.6s) both; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* one visual line = one pen stroke: a soft-edged mask wipes it in left to right */
.ln { display: block; white-space: nowrap; padding: 0.08em 0.15em 0.1em 0; margin: -0.08em 0 -0.1em; transform: rotate(var(--r, 0deg)); transform-origin: 0 60%;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 33.3%, transparent 41%); mask-image: linear-gradient(90deg, #000 0, #000 33.3%, transparent 41%);
  -webkit-mask-size: 300% 100%; mask-size: 300% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0; mask-position: 100% 0; }
.ln.cont { padding-left: var(--hang); }
/* in poem flow the padding is paid for out of the line height, so a split paragraph is exactly as tall as the measured one
   (adjacent negative margins would collapse and add a few px per line) */
.title { --lh: var(--title-lh); }
.note { --lh: 1.2; }
.flow .ln { margin: 0; line-height: calc(var(--lh) * 1em - 0.18em); }
.page.on .ln { animation: write var(--w, 1s) linear var(--d, 0s) both; }
.page.done .ln, .page.done .rule path { animation-duration: 0.01s; animation-delay: 0s; }
.page.on .ln.written { -webkit-mask: none; mask: none; animation: none; }
@keyframes write {
  from { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  to { -webkit-mask-position: 0 0; mask-position: 0 0; }
}

/* cover and end */
.cover-in, .end-in { position: absolute; left: 9%; right: 9%; top: var(--cover-top); display: flex; flex-direction: column; align-items: flex-start; font-family: var(--font-body); font-weight: var(--body-weight); text-shadow: var(--text-shadow); }
.cover-in > *, .end-in > * { max-width: 100%; }
.kicker .ln, .by .ln { white-space: normal; } /* long names wrap; a single unbreakable word is shrunk by the fitter in reader.js */
.title, .cover h1, .end h2 { font-stretch: var(--title-stretch, normal); }
.kicker { font: 500 clamp(11px, 3.4cqw, 14px)/1 var(--ui); font-size: calc(clamp(11px, 3.4cqw, 14px) * var(--fit, 1)); letter-spacing: 0.03em; color: var(--ink); opacity: 0.8; margin: 0 0 0.9em; }
.cover h1 { margin: 0; font-family: var(--font-title); font-size: calc(var(--cover-size) * var(--fit, 1) * var(--fit-all, 1)); line-height: var(--cover-lh); font-weight: var(--title-weight); font-style: var(--title-style); color: var(--accent); }
.cover .rule { width: min(72%, 12em); font-size: calc(var(--cover-size) * var(--fit-all, 1)); margin-top: 0.02em; }
.by { margin: 0.1em 0 0; font-size: calc(var(--by-size) * var(--fit, 1) * var(--fit-all, 1)); color: var(--ink); }
.btn { margin-top: clamp(28px, 7cqh, 56px); min-height: 48px; padding: 0 28px; border: 0; border-radius: 1rem; background: var(--btn-bg); color: var(--btn-fg); font: 700 16px/1 var(--ui); cursor: pointer; transition: transform 0.15s var(--ease-out); display: inline-flex; align-items: center; text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn.secondary { background: var(--btn2-bg); color: var(--btn2-fg, var(--btn-fg)); }
.btn.secondary + .btn { margin-top: 12px; }
.link { margin-top: 18px; color: var(--ink); font: 500 14px/1.3 var(--ui); text-decoration: underline; text-underline-offset: 3px; opacity: 0.85; }
.hint { margin: 14px 0 0; font: 500 13px/1.4 var(--ui); color: var(--ink); opacity: 0.72; display: flex; align-items: center; gap: 8px; }
.hint svg { animation: nudge 1.8s var(--ease-out) infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(2px); } 50% { transform: translateY(-4px); } }
.end h2 { margin: 0; font-family: var(--font-title); font-size: calc(var(--end-size) * var(--fit, 1) * var(--fit-all, 1)); line-height: 0.95; font-weight: var(--title-weight); font-style: var(--title-style); color: var(--accent); }
.end .rule { font-size: calc(var(--end-size) * var(--fit-all, 1)); }

@media (prefers-reduced-motion: reduce) {
  .stage, .bg { transition: none; }
  .ln { -webkit-mask: none; mask: none; transform: none; }
  .page.on .ln, .page.on .rule path { animation: none; }
  .rule path { stroke-dashoffset: 0; }
  .odo .col, .hint svg { transition: none; animation: none; }
  .sound.invite::after { animation: none; opacity: 0.8; inset: -3px; }
}

/* status toasts and the sound help sheet: the same glass look on every template */
.toasts { position: fixed; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 60; display: grid; place-items: center; pointer-events: none; padding: 0 14px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: min(92vw, 460px); padding: 12px 14px 12px 18px; border-radius: 18px; color: #fff; font: 600 14px/1.35 var(--ui, system-ui); background: rgba(14, 14, 18, 0.78); border: 1px solid rgba(255, 255, 255, 0.22); -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.toast.warn { border-color: rgba(255, 199, 198, 0.7); }
.toast-act, .btn-s { min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; background: #fff; color: #000; font: 700 13px/1 var(--ui, system-ui); cursor: pointer; white-space: nowrap; }
.btn-s.ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.toast-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; animation: tspin 0.8s linear infinite; flex: none; }
@keyframes tspin { to { transform: rotate(360deg); } }
.help-back { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.55); display: grid; align-items: end; justify-items: center; }
.help-sheet { width: min(100%, 520px); max-height: 88dvh; overflow: auto; padding: 24px 22px max(24px, env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; color: #fff; font: 500 15px/1.5 var(--ui, system-ui); background: rgba(16, 16, 20, 0.94); border: 1px solid rgba(255, 255, 255, 0.18); }
.help-sheet h2 { margin: 0 0 6px; font: 800 24px/1.1 var(--ui, system-ui); }
.help-now { margin: 0 0 12px; color: #ffc7c6; font-weight: 700; }
.help-sheet ol { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 8px; }
.help-result { min-height: 1.4em; margin: 0 0 12px; color: #d1c9ff; font-weight: 600; }
.help-row { display: flex; flex-wrap: wrap; gap: 10px; }
.sound[data-state="blocked"], .sound[data-state="error"] { color: #ffc7c6; }
@media (prefers-reduced-motion: reduce) { .toast-spin { animation-duration: 2.4s; } }

/* text animations chosen in the look library (looks.js): 'write' above is the pen stroke; these replace its mask wipe.
   They use the individual translate/scale properties so they never fight the line's own rotate(var(--r)). */
:is(.ta-rise, .ta-fade, .ta-blur, .ta-slide, .ta-zoom, .ta-type, .ta-drop) .ln { -webkit-mask: none; mask: none; }
:is(.ta-rise, .ta-fade, .ta-blur, .ta-slide, .ta-zoom, .ta-type, .ta-drop) .page:not(.on):not(.done) .ln { opacity: 0; }
.ta-rise .page.on .ln { animation: lnRise 0.8s var(--ease-out) var(--d, 0s) both; }
.ta-fade .page.on .ln { animation: lnFade 1s ease-out var(--d, 0s) both; }
.ta-blur .page.on .ln { animation: lnBlur 1s var(--ease-out) var(--d, 0s) both; }
.ta-slide .page.on .ln { animation: lnSlide 0.75s var(--ease-out) var(--d, 0s) both; }
.ta-zoom .page.on .ln { animation: lnZoom 0.9s var(--ease-out) var(--d, 0s) both; }
.ta-type .page.on .ln { animation: lnType var(--w, 1s) steps(26, end) var(--d, 0s) both; }
.ta-drop .page.on .ln { animation: lnDrop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) var(--d, 0s) both; }
:is(.ta-rise, .ta-fade, .ta-blur, .ta-slide, .ta-zoom, .ta-type, .ta-drop) .page.done .ln { animation-duration: 0.01s; animation-delay: 0s; }
:is(.ta-rise, .ta-fade, .ta-blur, .ta-slide, .ta-zoom, .ta-type, .ta-drop) .page.on .ln.written { animation: none; opacity: 1; translate: none; scale: none; filter: none; clip-path: none; }
@keyframes lnRise { from { opacity: 0; translate: 0 0.55em; } to { opacity: 1; translate: 0 0; } }
@keyframes lnFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lnBlur { from { opacity: 0; filter: blur(0.35em); } to { opacity: 1; filter: blur(0); } }
@keyframes lnSlide { from { opacity: 0; translate: -1.2em 0; } to { opacity: 1; translate: 0 0; } }
@keyframes lnZoom { from { opacity: 0; scale: 1.12; } to { opacity: 1; scale: 1; } }
@keyframes lnType { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes lnDrop { from { opacity: 0; translate: 0 -0.7em; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { :is(.ta-rise, .ta-fade, .ta-blur, .ta-slide, .ta-zoom, .ta-type, .ta-drop) .page.on .ln { animation-duration: 0.01s; animation-delay: 0s; } }

/* words preloader: a curved wipe over the reader while the book opens */
.pre { position: fixed; inset: 0; z-index: 300; pointer-events: all; }
.pre svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pre-word { position: absolute; left: 0; right: 0; top: 50%; margin: 0; transform: translateY(-50%); text-align: center; padding: 0 6vw; font-size: clamp(2.6rem, 14vw, 6rem); line-height: 1; font-weight: 700; opacity: 0; will-change: transform, opacity; }

/* scroll reveal: words dim until their page scrolls in (opacity is set per word from reader.js) */
.ta-scroll .ln { -webkit-mask: none; mask: none; }
.ta-scroll .w { transition: opacity 0.18s linear; }
/* the text-effect menu */
.revmenu { position: absolute; z-index: 40; right: 12px; top: calc(env(safe-area-inset-top, 0px) + 64px); display: grid; gap: 2px; padding: 6px; border-radius: 20px; background: rgba(14, 14, 18, 0.82); border: 1px solid rgba(255, 255, 255, 0.18); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4); }
.revmenu[hidden] { display: none; }
.revmenu.pillnav { border-radius: 20px; }
.revmenu > .pn { justify-content: flex-start; min-width: 190px; border-radius: 14px; --pn-fill: #fff; font-size: 0.92rem; }
.revmenu > .pn[aria-checked="true"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* the HUD controls as a pill nav, in the story's own colours */
.hud-right.pillnav { --pn-fg: var(--ink); --pn-hover: var(--btn-fg, #111); --pn-fill: var(--accent); background: var(--chip-bg); gap: 2px; padding: 3px; }
.hud-right.pillnav > .pn { min-width: 44px; min-height: 44px; padding: 0; background: transparent !important; }
.hud-right.pillnav > .pn.sound { width: 44px; height: 44px; border-radius: 50%; }
.revmenu { --pn-fg: var(--ink, #fff); --pn-hover: var(--btn-fg, #111); --pn-fill: var(--accent, #fff); }
.revmenu > .pn { color: var(--ink, #fff) !important; }
.revmenu.pillnav { display: grid; }
.revmenu.pillnav[hidden] { display: none; }

/* jump cut and glitch text animations (used by the Nu-Brutalism and Cyberdelia directions, and available to every writer) */
:is(.ta-cut, .ta-glitch) .ln { -webkit-mask: none; mask: none; }
:is(.ta-cut, .ta-glitch) .page:not(.on):not(.done) .ln { opacity: 0; }
.ta-cut .page.on .ln { animation: lnCut 0.01s steps(1, end) var(--d, 0s) both; }
.ta-glitch .page.on .ln { animation: lnGlitch 0.7s steps(1, end) var(--d, 0s) both; }
:is(.ta-cut, .ta-glitch) .page.done .ln { animation-duration: 0.01s; animation-delay: 0s; }
:is(.ta-cut, .ta-glitch) .page.on .ln.written { animation: none; opacity: 1; translate: none; clip-path: none; filter: none; }
@keyframes lnCut { from { opacity: 0; } to { opacity: 1; } }
@keyframes lnGlitch { 0% { opacity: 0; } 15% { opacity: 1; translate: -7px 0; clip-path: inset(0 0 55% 0); } 30% { opacity: 0.4; translate: 6px 0; clip-path: inset(40% 0 0 0); } 45% { opacity: 1; translate: -3px 0; clip-path: inset(0); } 60% { opacity: 0.7; translate: 2px 0; } 100% { opacity: 1; translate: 0 0; clip-path: inset(0); } }
@media (prefers-reduced-motion: reduce) { :is(.ta-cut, .ta-glitch) .page.on .ln { animation-duration: 0.01s; animation-delay: 0s; } }

/* ---------- the menu: one button that fans the reader's options out along a quarter circle (see ui/radial.js) */
.hud-right.rmenu { position: relative; display: block; width: 44px; height: 44px; gap: 0; }
.rm-main { position: relative; z-index: 3; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22); transition: transform 0.25s var(--ease-out), box-shadow 0.25s; }
.rm-main .ic { position: absolute; inset: 0; display: grid; place-items: center; transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s; }
.rm-main .ic-close { opacity: 0; transform: rotate(-90deg) scale(0.4); }
.rmenu.is-open .rm-main .ic-open { opacity: 0; transform: rotate(90deg) scale(0.4); }
.rmenu.is-open .rm-main .ic-close { opacity: 1; transform: none; }
@media (hover: hover) { .rm-main:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3); } }
.rm-main:active { transform: scale(0.92); }
.rm-items { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.rm-items > * { position: absolute; right: 0; top: 0; margin: 0; opacity: 0; visibility: hidden; pointer-events: none; transform: translate(0, 0) scale(0.3);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) calc(var(--ri, 0) * 22ms), opacity 0.18s ease calc(var(--ri, 0) * 22ms), visibility 0s linear calc(0.3s + var(--ri, 0) * 22ms); }
.rmenu.is-open .rm-items > * { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(var(--dx), var(--dy)) scale(1);
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) calc(var(--i, 0) * 45ms), opacity 0.22s ease calc(var(--i, 0) * 45ms), visibility 0s; }
.rmenu.is-open .rm-items > :is(:hover, :focus-visible) { transform: translate(var(--dx), var(--dy)) scale(1.14); transition-delay: 0s; transition-duration: 0.25s; }
.rmenu.is-open .rm-items > :active { transform: translate(var(--dx), var(--dy)) scale(0.94); }
.rm-items > [data-label]::before { content: attr(data-label); position: absolute; right: calc(100% + 8px); top: 50%; transform: translate(6px, -50%); padding: 6px 11px; border-radius: 999px; font: 600 0.74rem/1 var(--ui); white-space: nowrap; background: var(--chip-bg); color: var(--ink); opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.3s var(--ease-out); }
.rm-items > [data-label]:is(:hover, :focus-visible)::before { opacity: 1; transform: translate(0, -50%); }
.rm-puffs { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.rm-puffs i { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px; border-radius: 50%; opacity: 0; filter: blur(5px); background: radial-gradient(circle, color-mix(in srgb, var(--accent, #fff) 55%, transparent), transparent 70%); }
.rm-puffs i:nth-child(1) { --px: -70px; --py: 6px; --k: 0; } .rm-puffs i:nth-child(2) { --px: -62px; --py: 36px; --k: 1; } .rm-puffs i:nth-child(3) { --px: -44px; --py: 62px; --k: 2; } .rm-puffs i:nth-child(4) { --px: -20px; --py: 78px; --k: 3; }
.rm-puffs i:nth-child(5) { --px: -2px; --py: 86px; --k: 4; } .rm-puffs i:nth-child(6) { --px: -36px; --py: 30px; --k: 2; } .rm-puffs i:nth-child(7) { --px: -16px; --py: 40px; --k: 3; }
.rmenu.puff .rm-puffs i { animation: rmPuff 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--k) * 45ms); }
@keyframes rmPuff { from { opacity: 0; transform: translate(0, 0) scale(0.3); } 28% { opacity: 0.85; } to { opacity: 0; transform: translate(var(--px), var(--py)) scale(2.4); } }
.rm-backdrop { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 0.35s; background: radial-gradient(130% 80% at 100% 0%, color-mix(in srgb, var(--stage-bg, #000) 72%, transparent), transparent 64%); }
.rm-backdrop.on { opacity: 1; pointer-events: auto; }
.rm-badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent, #fff); color: var(--btn-fg, #111); font: 800 0.68rem/18px var(--ui); text-align: center; box-sizing: border-box; animation: rmBadge 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.rm-badge[hidden] { display: none; }
@keyframes rmBadge { from { transform: scale(0.2); } to { transform: scale(1); } }
.rm-dot { position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent, #fff); box-shadow: 0 0 0 2px var(--chip-bg, #000); animation: rmBadge 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.rm-tip { position: absolute; right: 0; top: calc(var(--rm-r, 120px) + 38px); z-index: 3; width: max-content; max-width: min(240px, 70vw); padding: 9px 14px; border-radius: 14px; font: 600 0.8rem/1.3 var(--ui); text-align: right; background: var(--chip-bg); color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); opacity: 0; transform: translateY(-6px) scale(0.96); transform-origin: 100% 0; pointer-events: none; transition: opacity 0.3s, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
.rmenu.intro .rm-tip { opacity: 1; transform: none; transition-delay: 0.5s; }
.rmenu.intro.is-open .rm-items > * { animation: rmPing 1.5s ease-out infinite; animation-delay: calc(var(--i, 0) * 140ms + 0.7s); }
@keyframes rmPing { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #fff) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 12px transparent; } }
@media (prefers-reduced-motion: reduce) {
  .rm-items > *, .rmenu.is-open .rm-items > *, .rm-main .ic, .rm-tip, .rm-backdrop { transition-duration: 0.01s !important; transition-delay: 0s !important; }
  .rmenu.puff .rm-puffs i, .rmenu.intro.is-open .rm-items > *, .rm-badge, .rm-dot { animation: none; }
}

/* a design direction can restyle the menu and the comments sheet through these variables (--rm-radius, --rm-border, --rm-shadow, --cs-radius, --chip-radius) */
.rmenu .sound { border-radius: var(--rm-radius, 50%); border: var(--rm-border, 0); box-shadow: var(--rm-shadow, none); }
.rmenu .rm-main { box-shadow: var(--rm-shadow, 0 4px 16px rgba(0, 0, 0, 0.22)); }
.rm-tip { border-radius: var(--chip-radius, 14px); border: var(--rm-border, 0); }
.rm-badge { border-radius: var(--rm-badge-radius, 9px); }

/* links in the reader move too (the shared defaults in ui/tokens.css are not loaded here) */
:where(a) { transition: color 0.2s, opacity 0.2s, scale 0.2s var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)); }
:where(a):active { scale: 0.96; }
:where(a, button, textarea):focus-visible { outline: 2px solid color-mix(in srgb, var(--accent, #fff) 75%, transparent); outline-offset: 3px; }

/* ---------- the swipe cue on the cover: a small dot rises through a tiny track, over a quiet label. It is meant to be noticed only if you look for it. */
.swipe { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(18px, 4.5cqh, 38px)); z-index: 2; display: flex; justify-content: center; pointer-events: none; }
.swipe.gone { display: none; }
.swipe-in { display: grid; justify-items: center; gap: 7px; color: var(--ink); opacity: 0.62; animation: swIn 1.2s var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)) 1.6s both; }
.swipe-track { position: relative; width: 15px; height: 27px; box-sizing: border-box; border: 1.5px solid color-mix(in srgb, var(--ink) 50%, transparent); border-radius: var(--rm-radius, 999px); overflow: hidden; }
.swipe-track::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 1.5px; height: 12px; margin-left: -0.75px; border-radius: 2px; background: linear-gradient(to top, var(--accent), transparent); transform-origin: 50% 100%; animation: swTrail 2.8s cubic-bezier(0.45, 0, 0.2, 1) infinite; }
.swipe-dot { position: absolute; left: 50%; bottom: 4px; z-index: 1; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); animation: swDot 2.8s cubic-bezier(0.45, 0, 0.2, 1) infinite; }
.swipe-label { font: 600 0.58rem/1 var(--ui); letter-spacing: 0.16em; text-transform: uppercase; color: color-mix(in srgb, var(--ink) 80%, transparent); text-shadow: none; }
@keyframes swIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes swDot { 0% { transform: translateY(0) scale(0.5); opacity: 0; } 16% { transform: translateY(0) scale(1); opacity: 1; } 72% { transform: translateY(-13px) scale(1); opacity: 1; } 100% { transform: translateY(-15px) scale(0.4); opacity: 0; } }
@keyframes swTrail { 0%, 16% { transform: scaleY(0); opacity: 0; } 44% { opacity: 0.8; } 72% { transform: scaleY(1); opacity: 0.45; } 100% { transform: scaleY(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .swipe-in, .swipe-track::after, .swipe-dot { animation: none; } .swipe-dot { bottom: 11px; } .swipe-track::after { display: none; } }
