/* AskACIM, "Celestial Midnight". A dark, immersive default with warm parchment kept for reading the teachings.
   Gold is an accent, never decoration for its own sake. Every colour below comes from these tokens. */
:root {
  color-scheme: dark;

  /* Celestial Midnight palette (the official foundation) */
  --color-midnight: #101728;
  --color-deep-midnight: #0B1020;
  --color-mystic-plum: #28233D;
  --color-antique-gold: #C2A46C;
  --color-soft-gold: #D9BD88;
  --color-parchment: #E8DFCE;
  --color-soft-light: #D9C6AF;
  --color-dusk: #777F91;
  --color-moonlight: #F4EFE6;
  --color-shadow: #191D2A;
  /* Gold ink: antique gold darkened until it holds 4.5:1 on parchment (decorative gold fails there). */
  --color-gold-ink: #7D6234;
  /* Amadeus: the brightest point of its mark only. Warm light, never pure white. Not for backgrounds or text. */
  --color-luminous: #FFF3D6;

  /* Signature gradients */
  --grad-celestial-depth: linear-gradient(180deg, var(--color-deep-midnight), var(--color-mystic-plum));
  --grad-golden-revelation: linear-gradient(135deg, var(--color-mystic-plum), var(--color-antique-gold));
  --grad-ethereal-light: linear-gradient(165deg, var(--color-soft-light), var(--color-parchment));
  --grad-midnight-veil: linear-gradient(180deg, var(--color-midnight), transparent);

  /* Legacy names still used by the deck art and the Thomas scroll */
  --c-gold: var(--color-antique-gold);
  --c-gold-ink: var(--color-gold-ink);

  /* Semantic: dark, the primary experience */
  --bg-page: var(--color-midnight);
  --bg-raised: var(--color-mystic-plum);
  --bg-hover: color-mix(in srgb, var(--color-mystic-plum) 86%, var(--color-moonlight));
  --bg-inverse: var(--color-antique-gold);      /* primary buttons */
  --text-primary: var(--color-moonlight);
  --text-soft: color-mix(in srgb, var(--color-moonlight) 80%, var(--color-dusk));
  --text-secondary: color-mix(in srgb, var(--color-dusk) 72%, var(--color-moonlight)); /* dusk, lifted to hold 4.5:1 */
  --text-inverse: var(--color-midnight);
  --text-reference: var(--color-antique-gold);
  --text-link-hover: var(--color-soft-gold);
  --text-action: var(--color-soft-gold);
  --border-subtle: color-mix(in srgb, var(--color-antique-gold) 20%, var(--color-midnight));
  --border-strong: color-mix(in srgb, var(--color-antique-gold) 48%, var(--color-midnight));
  --accent-line: var(--color-antique-gold);
  --focus-ring: var(--color-soft-gold);
  --state-error: #E08A7A;
  --primary-hover: var(--color-soft-gold);
  --heading: var(--color-moonlight);
  --card-bg: var(--color-mystic-plum);
  --card-ink: var(--color-parchment);

  /* Deck families (decorative bands and washes only) */
  --deck-mind: #66727C;
  --deck-shift: #B77D68;
  --deck-guidance: #7D8B7B;
  --deck-remembrance: #718A95;

  /* Type */
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --t-display: clamp(2.5rem, 1.6rem + 3.9vw, 4rem);
  --t-h1: clamp(2rem, 1.4rem + 2.6vw, 3rem);
  --t-h2: clamp(1.625rem, 1.2rem + 1.7vw, 2.25rem);
  --t-h3: clamp(1.3125rem, 1.1rem + 0.9vw, 1.625rem);
  --t-lead: clamp(1.1875rem, 1.05rem + 0.55vw, 1.375rem);
  --t-body-serif: clamp(1.0625rem, 1rem + 0.2vw, 1.125rem);
  --t-body: 1rem;
  --t-small: 0.875rem;
  --t-label: 0.8125rem;
  --t-micro: 0.75rem;
  --measure: 68ch;

  /* Spacing, radius, elevation, motion */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;
  --r-sm: 4px; --r-md: 8px; --r-lg: 14px; --r-pill: 999px;
  --e-1: 0 1px 0 rgba(11, 16, 32, .5);
  --e-2: 0 1px 2px rgba(11, 16, 32, .5), 0 8px 24px rgba(11, 16, 32, .45);
  --e-3: 0 2px 4px rgba(11, 16, 32, .55), 0 16px 40px rgba(11, 16, 32, .55);
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --ease-in-out: cubic-bezier(.45, 0, .25, 1);
  --d-fast: 120ms; --d-base: 200ms; --d-slow: 400ms; --d-flip: 600ms;
}

/* Light, the reading mode: parchment ground, midnight ink, plum headings. Its own balance, not an inversion. */
:root[data-theme="light"],
.reading-surface, body.page-deck .card-dialog, .oracle-result {
  color-scheme: light;
  --bg-page: var(--color-parchment);
  --bg-raised: var(--color-soft-light);
  --bg-hover: color-mix(in srgb, var(--color-soft-light) 80%, var(--color-parchment));
  --bg-inverse: var(--color-midnight);
  --text-primary: var(--color-midnight);
  --text-soft: color-mix(in srgb, var(--color-midnight) 82%, var(--color-parchment));
  --text-secondary: color-mix(in srgb, var(--color-dusk) 55%, var(--color-midnight));
  --text-inverse: var(--color-moonlight);
  --text-reference: var(--color-gold-ink);
  --text-link-hover: var(--color-mystic-plum);
  --text-action: var(--color-mystic-plum);
  --border-subtle: color-mix(in srgb, var(--color-antique-gold) 40%, var(--color-parchment));
  --border-strong: color-mix(in srgb, var(--color-gold-ink) 55%, var(--color-parchment));
  --accent-line: var(--color-antique-gold);
  --focus-ring: var(--color-mystic-plum);
  --state-error: #9A3B2E;
  --primary-hover: var(--color-mystic-plum);
  --heading: var(--color-mystic-plum);
  --e-1: 0 1px 0 rgba(16, 23, 40, .08);
  --e-2: 0 1px 2px rgba(16, 23, 40, .1), 0 8px 24px rgba(16, 23, 40, .1);
  --e-3: 0 2px 4px rgba(16, 23, 40, .12), 0 16px 40px rgba(16, 23, 40, .16);
}

@media (prefers-reduced-motion: reduce) {
  :root { --d-fast: 0ms; --d-base: 0ms; --d-slow: 0ms; --d-flip: 200ms; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
body.page-deck { display: block; height: auto; min-height: 100%; }

:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Small-caps labels: margin labels, family names, "You" */
.eyebrow, .label-bot, .who, .fam-name, .slot-label, .dlg-slot, .dlg-label {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--t-label);
  line-height: 1.3;
  letter-spacing: .06em;
  font-variant-caps: all-small-caps;
  color: var(--text-secondary);
}

/* Header and wordmark */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  min-height: 64px; padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-subtle); background: var(--bg-page);
}
.wordmark {
  font-family: var(--font-serif); font-size: 1.75rem; line-height: 1;
  color: var(--text-primary); text-decoration: none; letter-spacing: -0.01em; white-space: nowrap;
}
.wordmark:hover { color: var(--text-link-hover); }
.wm-ask { font-style: italic; }
.wm-acim { font-variant-caps: small-caps; letter-spacing: .06em; font-weight: 500; }
.wordmark .logo { display: block; height: 88px; width: auto; }
/* The logo's wordmark is cream, so on midnight it needs only a soft shadow; on the light parchment page a thin dark outline keeps it legible. */
.wordmark .logo { filter: drop-shadow(0 2px 10px rgba(11, 16, 32, .6)); }
:root[data-theme="light"] .wordmark .logo { filter: drop-shadow(0 0 1px rgba(40, 30, 20, .9)) drop-shadow(0 1px 4px rgba(40, 30, 20, .45)); }
.nav { display: flex; align-items: center; gap: var(--s-5); }
.nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: 15px; font-weight: 600; color: var(--text-primary); text-decoration: none;
  border-bottom: 1px solid transparent;
}
.nav a:hover { color: var(--text-link-hover); }
.nav a[aria-current="page"] { border-bottom-color: var(--accent-line); }
/* The language link sits after the page links, a step quieter than them. */
.nav a.lang { font-weight: 500; color: var(--text-secondary); }
.nav a.lang:hover { color: var(--text-link-hover); }
/* Page links carry a small line icon in the link color. Amadeus shows its own mark instead. */
.nav a[data-icon] { gap: 7px; }
.nav a[data-icon]::before {
  content: ""; flex: none; width: 17px; height: 17px; background: currentColor; opacity: .8;
  -webkit-mask: var(--nav-icon) center / contain no-repeat; mask: var(--nav-icon) center / contain no-repeat;
  transition: opacity .2s;
}
.nav a[data-icon]:hover::before, .nav a[data-icon][aria-current="page"]::before { opacity: 1; }
.nav a[data-icon="ask"] { --nav-icon: url("/icons/nav-ask.svg"); }
.nav a[data-icon="deck"] { --nav-icon: url("/icons/nav-deck.svg"); }
.nav a[data-icon="thomas"]::before {
  content: "📜"; display: inline-flex; align-items: center; justify-content: center; opacity: 1;
  background: none; -webkit-mask: none; mask: none;
  font-size: 15px; line-height: 1; letter-spacing: 0; text-transform: none;
}
.nav a[data-icon="workbook"] { --nav-icon: url("/icons/nav-workbook.svg"); }
.nav a[data-icon="library"] { --nav-icon: url("/icons/nav-library.svg"); }
.nav a[data-icon="videos"] { --nav-icon: url("/icons/nav-videos.svg"); }
.nav a[data-icon="amadeus"]::before {
  width: 20px; height: 20px; border-radius: 50%; opacity: 1;
  background: url("/amadeus-mark-48.png") center / cover no-repeat;
  -webkit-mask: none; mask: none;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-soft-gold) 30%, transparent);
}

.quiet {
  background: none; border: 0; color: var(--text-secondary); cursor: pointer;
  font: 500 15px/1 var(--font-sans); min-height: 44px; padding: 0 var(--s-2);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em;
}
.quiet:hover { color: var(--text-primary); }

/* Conversation */
#chat { flex: 1; overflow-y: auto; padding: var(--s-5) var(--s-5) var(--s-6); }
.toolbar { display: flex; justify-content: flex-end; max-width: 680px; margin: 0 auto var(--s-2); }
.wrap { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s-6); }

.welcome { margin: var(--s-6) 0 var(--s-5); }
.greet {
  margin: var(--s-2) 0 0; font-family: var(--font-serif); font-weight: 400;
  font-size: var(--t-display); line-height: 1.1; letter-spacing: -0.01em; text-wrap: balance;
}
.hint {
  margin: var(--s-4) 0 var(--s-6); max-width: 36ch;
  font-family: var(--font-serif); font-size: var(--t-lead); line-height: 1.5;
}
.chips-label { margin: 0 0 var(--s-3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  background: transparent; color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  padding: var(--s-2) var(--s-4); min-height: 44px;
  font: 400 15px/1.3 var(--font-sans); text-align: left; cursor: pointer;
}
.chip:hover { background: var(--bg-hover); }

.noscript { max-width: 520px; margin: var(--s-7) auto; }
.noscript h2 { font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h3); margin: 0 0 var(--s-3); }
.noscript p { color: var(--text-secondary); }

.msg { display: flex; --bubble-max: min(100%, 41.25rem); } /* one width for both voices */
.msg.user { flex-direction: row; }
.msg.bot { flex-direction: column; }

/* User message: a labelled sans block, no bubble shape, left rule */
.stack { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: var(--s-1); }
.who { padding-left: 2px; }
.msg.user .bubble {
  max-width: var(--bubble-max); background: var(--bg-raised); color: var(--text-primary);
  border-left: 2px solid var(--border-strong); border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4); font-family: var(--font-sans); font-size: var(--t-body);
  line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}

/* Assistant answer: written on a sheet of papyrus in black ink, opened by a gold ornament rule.
   The sheet keeps its warm tone in both themes, so the ink is always the dark ink of the page. */
.msg.bot .bubble {
  max-width: var(--bubble-max);
  padding: var(--s-5) var(--s-5) var(--s-6);
  font-family: var(--font-serif); font-size: var(--t-body-serif);
  line-height: 1.6; color: var(--text-primary); white-space: pre-wrap; word-wrap: break-word;
  background:
    radial-gradient(ellipse at 18% 10%, color-mix(in srgb, var(--color-moonlight) 55%, transparent), transparent 55%),
    var(--grad-ethereal-light);
  border-radius: 3px 12px 5px 10px / 10px 4px 12px 5px;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--color-antique-gold) 45%, transparent),
    0 1px 2px rgba(11, 16, 32, .3),
    0 10px 26px -12px rgba(11, 16, 32, .7);
}
/* A reply is a reading surface: parchment ground, midnight ink. */
.msg.bot .bubble:not(.error) {
  color-scheme: light;
  --bg-page: var(--color-parchment); --bg-raised: var(--color-soft-light);
  --text-primary: var(--color-midnight); --text-secondary: color-mix(in srgb, var(--color-dusk) 55%, var(--color-midnight));
  --text-reference: var(--color-gold-ink); --text-link-hover: var(--color-mystic-plum); --heading: var(--color-mystic-plum);
  --border-strong: color-mix(in srgb, var(--color-gold-ink) 55%, var(--color-parchment));
}
.msg.bot .bubble::before {
  content: ""; display: block; width: 32px; height: 1px;
  background: var(--accent-line); margin-bottom: var(--s-4);
}
.msg.bot .bubble.error {
  font-family: var(--font-sans); font-size: var(--t-body); color: var(--state-error);
  background: none; box-shadow: none; padding: 0; border-radius: 0;
}
.msg.bot .bubble.error::before { display: none; }
.label-bot { margin: var(--s-3) 0 0; }
/* Sits on top of the papyrus sheet that holds each reply. */
.voice {
  display: flex; align-items: center; gap: var(--s-2);
  margin: 0 0 var(--s-2); font-family: var(--font-sans); font-weight: 600; font-size: var(--t-label);
  letter-spacing: .06em; font-variant-caps: all-small-caps; color: var(--text-secondary);
}

/* Amadeus mark: abstract light on a midnight roundel (see docs/brand/AMADEUS.md). Decorative; the name carries the meaning.
   It only moves while Amadeus is working or on the welcome, slowly, and never under reduced motion. */
.amadeus-mark { display: inline-block; flex: none; border-radius: 50%; vertical-align: middle; }
.amadeus-mark--sm { width: 24px; height: 24px; }
.amadeus-mark--lg {
  width: 52px; height: 52px;
  filter: drop-shadow(0 0 22px color-mix(in srgb, var(--color-luminous) 20%, transparent));
  animation: amadeus-breathe 6s ease-in-out infinite;
}
.msg.bot.thinking .amadeus-mark--sm { animation: amadeus-breathe 3s ease-in-out infinite; }
@keyframes amadeus-breathe { 0%, 100% { opacity: .82; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .amadeus-mark { animation: none !important; } }

.typing { display: inline-flex; align-items: center; gap: var(--s-2); font-family: var(--font-sans); font-size: var(--t-small); color: var(--text-secondary); white-space: normal; }
/* While the answer is prepared, the library book turns its pages (book-scene.js); the label sits under it. */
.waiting { display: grid; gap: var(--s-2); justify-items: center; }
.waiting-book { position: relative; width: 100%; height: 220px; }
.book-scene { position: relative; width: 100%; height: 100%; }
.book-scene canvas { display: block; }
.waiting .typing-label { font-family: var(--font-sans); font-size: var(--t-small); color: var(--text-secondary); }
.dots { display: inline-flex; gap: 5px; }
.dots span {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-secondary); opacity: .4; animation: blink 1.2s infinite;
}
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* The gold pen tip that travels with the ink while a line is being written; it is removed when the answer is complete. */
.nib {
  display: inline-block; width: 2px; height: 1.15em; margin-left: 2px; border-radius: 1px;
  background: linear-gradient(var(--c-gold), var(--c-gold-ink));
  vertical-align: -0.2em; transform: rotate(-14deg);
  animation: nib-pulse 1.1s ease-in-out infinite;
}
@keyframes nib-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* Composer */
footer.composer {
  border-top: 1px solid var(--border-subtle); background: var(--bg-page);
  padding: var(--s-3) var(--s-5) var(--s-3);
}
#captcha-box { max-width: 680px; margin: 0 auto var(--s-2); display: flex; justify-content: center; }
#captcha-box[hidden] { display: none; }
form#ask { position: relative; max-width: 680px; margin: 0 auto; display: flex; align-items: flex-end; }
textarea {
  flex: 1; resize: none; min-height: 56px; max-height: 160px;
  padding: 15px 64px 15px var(--s-5); border: 1px solid var(--border-strong); border-radius: 28px;
  background: var(--bg-raised); color: var(--text-primary); box-shadow: var(--e-1);
  font: 400 16px/1.5 var(--font-sans); overflow-y: hidden;
}
textarea::placeholder { color: var(--text-secondary); opacity: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-color: var(--text-primary); }
/* A small round send button sits inside the field, at the right edge, level with its last line. */
#send {
  position: absolute; right: 6px; bottom: 6px; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--bg-inverse); color: var(--text-inverse);
  transition: background var(--d-base) var(--ease-out), box-shadow var(--d-base) var(--ease-out);
}
#send:hover { background: var(--primary-hover); }
#send:active { box-shadow: 0 0 16px -2px color-mix(in srgb, var(--color-soft-gold) 55%, transparent); }
#send:disabled { cursor: not-allowed; background: color-mix(in srgb, var(--color-dusk) 28%, var(--bg-page)); color: var(--color-dusk); box-shadow: none; }
.note {
  max-width: 680px; margin: var(--s-2) auto 0; color: var(--text-secondary);
  font-size: var(--t-micro); line-height: 1.4;
}

/* ---------- Deck page ---------- */

/* Compact header and intro, so the cards are the main item. */
body.page-deck .top { min-height: 56px; padding: var(--s-2) var(--s-5); }
body.page-deck .wordmark { font-size: 1.5rem; }
body.page-deck .wordmark .logo { height: 56px; }
.deck-main { max-width: 960px; margin: 0 auto; padding: var(--s-4) var(--s-5) var(--s-9); }
.deck-intro { max-width: 40rem; }
.deck-intro h1 {
  margin: var(--s-1) 0 var(--s-1); font-family: var(--font-serif); font-weight: 500;
  font-size: var(--t-h2); line-height: 1.15; letter-spacing: -0.01em;
}
.deck-intro .clarify { margin: 0; color: var(--text-soft); font-size: var(--t-small); }
.deck-intro .about { margin-top: var(--s-2); }
.deck-intro .about summary {
  display: inline-flex; align-items: center; min-height: 44px; cursor: pointer;
  font-size: var(--t-small); font-weight: 600; color: var(--text-primary); list-style: none;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em;
}
.deck-intro .about summary::-webkit-details-marker { display: none; }
.deck-intro .about summary::after { content: "Show"; margin-left: var(--s-2); font-weight: 400; color: var(--text-secondary); }
.deck-intro .about[open] summary::after { content: "Hide"; }
.deck-intro .about summary:lang(es)::after { content: "Mostrar"; }
.deck-intro .about[open] summary:lang(es)::after { content: "Ocultar"; }
.deck-intro .about .lead { margin: var(--s-2) 0 0; font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.6; max-width: var(--measure); }

/* The hand */
.hand-stage { display: flex; flex-direction: column; align-items: center; gap: var(--s-4); margin-top: var(--s-5); }
.hand {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 3vw, 32px); width: 100%;
}
.hand-col { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); min-width: 0; }
.slot-label { margin: 0; text-align: center; text-wrap: balance; color: var(--text-soft); }

/* Each card is a button once it can be opened. Hover lifts it, and the press is reversed when released. */
button.dcard {
  appearance: none; display: block; width: 100%; margin: 0; padding: 0; border: 0;
  background: none; font: inherit; color: inherit; cursor: default;
  position: relative; aspect-ratio: 7 / 10; perspective: 1200px; border-radius: var(--r-lg);
  -webkit-tap-highlight-color: transparent;
}
.dcard-inner {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform var(--d-flip) var(--ease-out);
}
.dcard.is-up .dcard-inner { transform: rotateY(180deg); }
.side {
  position: absolute; inset: 0; overflow: hidden; border-radius: var(--r-lg);
  background: var(--bg-raised); box-shadow: var(--e-2);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: box-shadow var(--d-base) var(--ease-out);
}
/* The art is 2:3 and the card 7:10; filling keeps the frame whole (a 5% stretch is not visible). */
.side-back img { display: block; width: 100%; height: 100%; object-fit: fill; }
.side-front {
  transform: rotateY(180deg); display: flex; flex-direction: column;
  padding: 0 clamp(10px, 2.4vw, 18px) clamp(12px, 2.6vw, 18px);
  border-top: 5px solid var(--fam, var(--border-strong));
}
.side-front { background: var(--card-bg); color: var(--card-ink); }
.side-front .fam-name, .side-front .card-id { color: color-mix(in srgb, var(--card-ink) 72%, var(--card-bg)); }
.side-front.has-svg { padding: 0; border-top: 0; background: var(--color-parchment); color: var(--color-midnight); }
.face-svg, .face-svg svg { display: block; width: 100%; height: 100%; }
.fam-mind { --fam: var(--deck-mind); }
.fam-shift { --fam: var(--deck-shift); }
.fam-guidance { --fam: var(--deck-guidance); }
.fam-remembrance { --fam: var(--deck-remembrance); }
.face-top {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 6px;
  padding: 8px 0 6px; border-bottom: 1px solid var(--border-subtle);
}
.face-top .fam-name { font-size: 0.6875rem; letter-spacing: .04em; }
.card-id { margin-left: auto; font-size: 0.6875rem; color: var(--text-secondary); letter-spacing: .04em; font-variant-numeric: lining-nums tabular-nums; }
.art {
  flex: 1; min-height: 0; margin: 10px 0; border-radius: var(--r-sm); overflow: hidden;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--fam, var(--border-strong)) 14%, var(--bg-page));
  color: var(--c-gold);
}
.art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.art .mark { width: 34%; height: auto; opacity: .8; }
.card-title {
  margin: 0; font-family: var(--font-serif); font-weight: 500; text-align: center; color: var(--card-ink);
  font-size: clamp(1.05rem, 0.8rem + 1vw, 1.5rem); line-height: 1.15; text-wrap: balance;
}

/* Only revealed cards respond to the pointer. */
button.dcard.is-ready { cursor: pointer; transition: transform var(--d-base) var(--ease-out); }
button.dcard.is-ready:active { transform: translateY(-2px) scale(1.01); }
button.dcard.is-ready:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 4px; }
@media (hover: hover) {
  button.dcard.is-ready:hover { transform: translateY(-6px) scale(1.025); }
  button.dcard.is-ready:hover .side { box-shadow: var(--e-3), 0 0 0 1px var(--color-soft-gold), 0 0 22px -6px color-mix(in srgb, var(--color-soft-gold) 45%, transparent); }
}
button.dcard.is-ready:focus-visible .side { box-shadow: var(--e-3), 0 0 0 2px var(--color-soft-gold); }

/* One gentle pass while the cards are shuffled: each column drifts a little, then settles. Not a loop. */
.hand.is-shuffling .dcard {
  animation: shuffle 2s var(--ease-in-out) both;
}
@keyframes shuffle {
  0%   { transform: none; }
  35%  { transform: translate(calc(var(--sx, 1) * -14px), -6px) rotate(calc(var(--sx, 1) * -2.5deg)); }
  70%  { transform: translate(calc(var(--sx, 1) * 10px), 4px) rotate(calc(var(--sx, 1) * 1.5deg)); }
  100% { transform: none; }
}

.status { margin: 0; min-height: 2.2em; text-align: center; color: var(--text-soft); font-size: var(--t-small); max-width: 36rem; }

/* The hint after the draw: bold, in the action colour, with a pointer, so it reads as something to click. */
.cta {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2); margin: 0;
  font-size: var(--t-body); font-weight: 700; color: var(--text-action);
}
.cta-icon { width: 20px; height: 20px; flex: 0 0 auto; fill: currentColor; }
/* The hint sits above the cards and keeps its line before the draw, so the cards do not jump when it appears. */
.cta[hidden] { display: flex; visibility: hidden; }
/* Once the hand is drawn the cards name themselves and the reading follows them; the line stays for screen readers. */
.hand-stage:has(.cta:not([hidden])) .status { position: absolute; width: 1px; height: 1px; min-height: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

/* The breathing instructions rise over the middle of the hand, hold, then dissolve away before the next one. */
.hand-wrap { position: relative; width: 100%; max-width: 880px; }
.breath {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: flex; align-items: center; justify-content: center; padding: var(--s-4);
  /* A light veil over the cards, so the words read without a box around them. */
  background: color-mix(in srgb, var(--bg-page) 72%, transparent);
  opacity: 0; filter: blur(4px); transform: translateY(4px);
  transition: opacity 700ms var(--ease-in-out), filter 700ms var(--ease-in-out), transform 700ms var(--ease-in-out);
}
.breath.is-on { opacity: 1; filter: none; transform: none; }
.breath-text {
  margin: 0; max-width: 20rem; text-align: center; text-wrap: balance;
  font-family: var(--font-serif); font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); line-height: 1.3; color: var(--text-primary);
}

.hand-actions { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.btn {
  min-height: 48px; padding: 0 var(--s-5); border-radius: var(--r-md); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  font: 600 16px/1 var(--font-sans); color: var(--color-moonlight);
  background: var(--color-mystic-plum); border: 1px solid var(--border-strong);
  transition: background var(--d-base) var(--ease-out), border-color var(--d-base) var(--ease-out), box-shadow var(--d-base) var(--ease-out);
}
.btn:hover { border-color: var(--color-soft-gold); }
.btn:active { box-shadow: 0 0 18px -4px color-mix(in srgb, var(--color-soft-gold) 55%, transparent); }
.btn.primary { background: var(--color-antique-gold); color: var(--color-midnight); border-color: transparent; }
.btn.primary:hover { background: var(--color-soft-gold); border-color: transparent; }
.btn:disabled, .btn:disabled:hover {
  cursor: not-allowed; background: color-mix(in srgb, var(--color-dusk) 22%, var(--color-midnight));
  color: var(--color-dusk); border-color: transparent; box-shadow: none;
}

/* Reflection panel for one card */
.card-dialog {
  border: 0; border-radius: var(--r-lg); padding: 0;
  width: min(580px, calc(100% - 32px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  background: var(--bg-page); color: var(--text-primary); box-shadow: var(--e-3); overflow-y: auto;
}
.card-dialog::backdrop { background: color-mix(in srgb, var(--color-deep-midnight) 70%, transparent); }
.card-dialog[open] { animation: dlg-in var(--d-base) var(--ease-out); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.dlg { padding: var(--s-6); border-top: 5px solid var(--fam, var(--border-strong)); }
.dlg-top { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: var(--s-2); }
.dlg-slot { margin: 0; }
.dlg-meta { margin: 0; color: var(--text-soft); font-size: var(--t-small); font-variant-numeric: lining-nums; }
.dlg-art {
  display: block; width: min(100%, 200px); height: auto; margin: var(--s-4) auto 0;
  border-radius: var(--r-sm); box-shadow: var(--e-2);
}
.dlg-title {
  margin: var(--s-4) 0 var(--s-2); font-family: var(--font-serif); font-weight: 500;
  font-size: var(--t-h2); line-height: 1.15;
}
.dlg-title:focus { outline: none; }
.dlg-headline { margin: 0 0 var(--s-2); font-family: var(--font-serif); font-style: italic; font-size: var(--t-lead); line-height: 1.4; }
.dlg-summary { margin: 0; color: var(--text-soft); font-size: var(--t-body); }
.dlg-block { margin-top: var(--s-5); }
.dlg-label { margin: 0 0 var(--s-2); }
.dlg-text { margin: 0; font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.6; max-width: var(--measure); }
.dlg-question {
  margin: 0; padding-left: var(--s-4); border-left: 2px solid var(--accent-line);
  font-family: var(--font-serif); font-style: italic; font-size: var(--t-lead); line-height: 1.5; max-width: var(--measure);
}
.dlg-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }

.site-foot {
  max-width: 960px; margin: 0 auto; padding: var(--s-7) var(--s-5) var(--s-8);
  border-top: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: var(--t-small);
}
.site-foot p { margin: 0 0 var(--s-3); max-width: 60ch; }
.site-foot a { color: var(--text-primary); }
.site-foot a:hover { color: var(--text-link-hover); }

/* Cookie notice (shown once, above the page) and cookie policy page */
.note a, .cookie-notice a, .policy a { color: var(--text-primary); }
.note a:hover, .cookie-notice a:hover, .policy a:hover { color: var(--text-link-hover); }

.cookie-notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-raised); color: var(--text-soft); font-size: var(--t-small); line-height: 1.5;
}
.cookie-notice p { margin: 0; max-width: 62ch; flex: 1 1 320px; }
.cookie-accept {
  min-height: 44px; min-width: 96px; padding: 0 var(--s-5); border: 0; border-radius: var(--r-md);
  background: var(--bg-inverse); color: var(--text-inverse); cursor: pointer;
  font: 600 15px/1 var(--font-sans);
}
.cookie-accept:hover { background: var(--primary-hover); }

.policy { max-width: 680px; margin: 0 auto; padding: var(--s-6) var(--s-5) var(--s-8); }
.policy h1 {
  margin: var(--s-1) 0 var(--s-2); font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(2rem, 1.6rem + 2vw, 2.5rem); line-height: 1.15; text-wrap: balance;
}
.policy h2 {
  margin: var(--s-6) 0 var(--s-2); font-family: var(--font-serif); font-weight: 500;
  font-size: 1.375rem; line-height: 1.3;
}
.policy p, .policy li {
  font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.6; color: var(--text-soft);
}
.policy p { margin: 0 0 var(--s-3); }
.policy ul { margin: 0 0 var(--s-3); padding-left: var(--s-5); }
.policy code {
  font-family: ui-monospace, Consolas, monospace; font-size: .85em;
  background: var(--bg-raised); padding: 1px 5px; border-radius: var(--r-sm);
}
.policy-updated { margin: 0 0 var(--s-5); color: var(--text-secondary); font-size: var(--t-small); }
.policy-table { width: 100%; border-collapse: collapse; margin: var(--s-3) 0 var(--s-4); font-size: var(--t-small); }
.policy-table th, .policy-table td {
  text-align: left; vertical-align: top; padding: var(--s-3); border-bottom: 1px solid var(--border-subtle);
}
.policy-table thead th { color: var(--text-secondary); font-weight: 600; font-size: var(--t-label); letter-spacing: .04em; }
.policy-table tbody th { font-weight: 600; white-space: nowrap; }
.policy-table tbody th code { font-size: .9em; }
.policy-back { margin-top: var(--s-7); }

@media (max-width: 480px) {
  .cookie-notice { padding: var(--s-3) var(--s-4); }
  .policy { padding: var(--s-5) var(--s-4) var(--s-7); }
  .policy-table thead { display: none; }
  .policy-table, .policy-table tbody, .policy-table tr, .policy-table th, .policy-table td { display: block; width: 100%; }
  .policy-table tr { padding: var(--s-3) 0; border-bottom: 1px solid var(--border-subtle); }
  .policy-table th, .policy-table td { border: 0; padding: 2px 0; }
  .policy-table td::before { content: attr(data-label); display: block; color: var(--text-secondary); font-size: var(--t-micro); }
}

@media (max-width: 480px) {
  .top { padding: var(--s-2) var(--s-4); }
  #chat { padding: var(--s-4); }
  footer.composer { padding: var(--s-3) var(--s-4); }
  .wordmark { font-size: 1.5rem; }
  .wordmark .logo { height: 72px; }
  body.page-deck .wordmark .logo { height: 48px; }
  .nav { gap: var(--s-4); }
  .msg.bot .bubble { font-size: 1.0625rem; padding: var(--s-4) var(--s-4) var(--s-5); }
  .deck-main { padding: var(--s-3) var(--s-4) var(--s-8); }
  .hand { gap: 12px; }
  .slot-label { font-size: 0.6875rem; }
  .dlg { padding: var(--s-5); }
  .site-foot { padding: var(--s-6) var(--s-4); }
}

@media (prefers-reduced-motion: reduce) {
  .dcard-inner { transition-duration: 200ms; }
  .hand.is-shuffling .dcard { animation: none; }
  .dots span { animation: none; opacity: .6; }
  .nib { animation: none; }
  .breath { transition-duration: 200ms; filter: none; transform: none; }
}

/* ---------- Home: immersive landing ----------
   A fixed full-bleed scene (late sun through a window onto plaster) sits behind everything. It never scrolls.
   The header, conversation and composer float above it with no solid bars. Replies keep their papyrus sheets.
   Other pages (Deck, Cookies) keep the plain paper look. */
html { background: var(--bg-page); }
.scene { display: none; }
body:is(.page-home, .page-deck) { background: transparent; }
body:is(.page-home, .page-deck) .scene {
  display: block; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  /* Celestial Depth, a little light arriving from the upper right, and a very faint sacred-geometry ring set. */
  background:
    radial-gradient(ellipse 55% 40% at 74% 8%, color-mix(in srgb, var(--color-soft-gold) 15%, transparent), transparent 72%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-400 -400 800 800' fill='none' stroke='%23C2A46C' stroke-opacity='.1' stroke-width='1'%3E%3Ccircle r='120'/%3E%3Ccircle r='240'/%3E%3Ccircle r='360'/%3E%3Ccircle cx='120' r='120'/%3E%3Ccircle cx='-120' r='120'/%3E%3Ccircle cy='104' cx='60' r='120'/%3E%3Ccircle cy='104' cx='-60' r='120'/%3E%3Ccircle cy='-104' cx='60' r='120'/%3E%3Ccircle cy='-104' cx='-60' r='120'/%3E%3C/svg%3E") 50% 28% / min(120vmin, 1100px) no-repeat,
    url("/art/deck-altar-still-life-midnight.png") center / cover no-repeat,
    var(--grad-celestial-depth);
  opacity: 1;
  animation: scene-in 1.4s var(--ease-out) both;
}
:root[data-theme="light"] body:is(.page-home, .page-deck) .scene {
  background: radial-gradient(ellipse 60% 40% at 74% 8%, color-mix(in srgb, var(--color-soft-gold) 22%, transparent), transparent 72%), var(--grad-ethereal-light);
}
/* A soft scrim keeps text legible at the top and bottom edges, where the header and composer sit. */
body:is(.page-home, .page-deck) .scene::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--bg-page) 22%, transparent) 0,
    transparent 20%, transparent 70%,
    color-mix(in srgb, var(--bg-page) 30%, transparent) 100%);
}
@keyframes scene-in { from { opacity: 0; } to { opacity: 1; } }

/* Header: no bar, no rule. The logo and a few quiet links. */
body:is(.page-home, .page-deck) .top {
  background: transparent; border-bottom: 0;
  padding: var(--s-4) clamp(20px, 4vw, 56px);
}
body:is(.page-home, .page-deck) .wordmark .logo { height: 108px; }
body:is(.page-home, .page-deck) .nav { gap: var(--s-6); }
body:is(.page-home, .page-deck) .nav a {
  font-size: 0.8125rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
}
body:is(.page-home, .page-deck) .nav a.lang { font-weight: 500; color: var(--text-soft); }

/* The conversation floats on the scene. With only the welcome showing, it sits in the vertical middle. */
body.page-home #chat {
  display: flex; flex-direction: column; background: transparent;
  padding: 0 clamp(20px, 4vw, 56px) var(--s-6);
}
body.page-home .toolbar { width: 100%; max-width: 760px; margin: 0 auto var(--s-2); }
body.page-home .wrap { width: 100%; max-width: 760px; }
body.page-home #chat:has(#welcome) .toolbar { display: none; }
body.page-home #chat:has(#welcome) .wrap { margin-block: auto; }
body.page-home .quiet { color: var(--text-soft); }

/* Editorial hero type */
body.page-home .welcome { margin: var(--s-4) 0 var(--s-6); }
body.page-home .welcome > .eyebrow:not(.chips-label) {
  display: flex; align-items: center; gap: var(--s-3);
  color: var(--text-soft); letter-spacing: .18em;
}
body.page-home .welcome > .eyebrow:not(.chips-label)::before {
  content: ""; width: 40px; height: 1px; background: var(--accent-line);
}
body.page-home .welcome > .eyebrow:has(.amadeus-mark)::before { display: none; }
body.page-home .greet {
  margin: var(--s-5) 0 0; max-width: 13em;
  font-size: clamp(2.5rem, 1.1rem + 4.2vw, 4rem); line-height: 1.04; letter-spacing: -0.02em;
}
body.page-home .hint { margin: var(--s-4) 0 var(--s-6); max-width: 36em; color: var(--text-soft); }
body.page-home .chips-label { color: var(--text-soft); }
body.page-home .chip {
  background: color-mix(in srgb, var(--bg-page) 50%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-color: color-mix(in srgb, var(--text-primary) 24%, transparent);
}
body.page-home .chip:hover { background: color-mix(in srgb, var(--bg-page) 88%, transparent); }

/* Messages on the scene */
body.page-home .msg.user .bubble {
  background: color-mix(in srgb, var(--bg-page) 70%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
body.page-home .voice, body.page-home .label-bot, body.page-home .who { color: var(--text-soft); }

/* Composer: a frosted field, no bar */
body.page-home footer.composer { background: transparent; border-top: 0; padding-top: var(--s-2); }
body.page-home textarea {
  background: color-mix(in srgb, var(--bg-page) 72%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.1); backdrop-filter: blur(16px) saturate(1.1);
  border-color: color-mix(in srgb, var(--text-primary) 26%, transparent);
  box-shadow: var(--e-2);
}
body.page-home .note { color: var(--text-soft); }

@media (max-width: 480px) {
  body:is(.page-home, .page-deck) .wordmark .logo { height: 56px; }
  body:is(.page-home, .page-deck) .nav { gap: var(--s-4); }
  body.page-home #chat { padding: 0 var(--s-4) var(--s-4); }
  body.page-home .welcome { margin: var(--s-5) 0 var(--s-4); }
  body.page-home .hint { margin-bottom: var(--s-5); }
}
@media (prefers-reduced-motion: reduce) {
  body:is(.page-home, .page-deck) .scene { animation: none; }
}

/* The cookie notice joins the scene as a frosted strip. */
body:is(.page-home, .page-deck) .cookie-notice {
  background: color-mix(in srgb, var(--bg-raised) 78%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 0; margin: 0 clamp(12px, 3vw, 40px); border-radius: var(--r-md);
}

/* Deck and cookie pages share the scene and header with the home page. Long prose gets a frosted sheet. */
body.page-deck .top { min-height: 64px; padding: var(--s-4) clamp(20px, 4vw, 56px); }
body.page-deck .wordmark .logo { height: 108px; }
body.page-deck .policy {
  margin-top: var(--s-4); margin-bottom: var(--s-8); padding: var(--s-6);
  background: color-mix(in srgb, var(--bg-page) 78%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-radius: var(--r-lg);
}
body.page-deck .site-foot { border-top-color: color-mix(in srgb, var(--text-primary) 18%, transparent); }
@media (max-width: 480px) {
  body.page-deck .top { padding: var(--s-2) var(--s-4); }
  body.page-deck .wordmark .logo { height: 56px; }
  body.page-deck .policy { padding: var(--s-5) var(--s-4); }
}

/* Card reflection panel: a frosted sheet over the scene, like the other panels. */
body.page-deck .card-dialog {
  background: var(--grad-ethereal-light);
  border: 1px solid color-mix(in srgb, var(--color-antique-gold) 50%, transparent);
}
body.page-deck .card-dialog::backdrop {
  background: color-mix(in srgb, var(--color-deep-midnight) 72%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.dlg-title, .oracle-result .oracle-heading { color: var(--heading); }
.card-dialog .btn.primary { background: var(--color-mystic-plum); color: var(--color-moonlight); }
.card-dialog .btn.primary:hover { background: var(--color-midnight); }
.card-dialog .btn:not(.primary) { background: transparent; color: var(--color-midnight); }

/* Saying of the day (Pursah's Gospel of Thomas), at the top of the home page. */
.daily { margin: 0 0 var(--s-6); max-width: 34em; }
.daily .eyebrow { margin: 0 0 var(--s-2); color: var(--text-soft); }
.daily blockquote {
  margin: 0; padding-left: var(--s-4); border-left: 2px solid var(--accent-line);
  font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.55; color: var(--text-primary);
}
.daily figcaption { margin: var(--s-2) 0 0 calc(var(--s-4) + 2px); font-size: var(--t-small); color: var(--text-soft); }

/* ---------- The oracle: a reading of the hand, under the cards on the deck page ---------- */
.hand-panel {
  margin-top: var(--s-4); padding: var(--s-6) var(--s-5);
  background: color-mix(in srgb, var(--color-mystic-plum) 58%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--color-antique-gold) 24%, transparent); border-radius: var(--r-lg);
}
.hand-panel .hand-stage { margin-top: 0; }
.hand-panel > .hand-actions { margin-top: var(--s-5); }
.oracle-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.hand-actions:not(:has(button)) { display: none; }
.oracle {
  max-width: 44rem; margin: var(--s-6) auto 0; padding-top: var(--s-6);
  border-top: 1px solid color-mix(in srgb, var(--color-antique-gold) 24%, transparent);
}
.oracle[hidden], .oracle-result[hidden] { display: none; }
/* Once the reading is asked for, the introduction steps aside so the answer sits right under the cards. A new hand brings it back. */
.oracle:has(> .oracle-result:not([hidden])) > :is(.eyebrow, .oracle-heading, .oracle-lead) { display: none; }
.oracle-result:empty { display: none; }
.oracle .eyebrow { margin: 0 0 var(--s-2); color: var(--text-soft); }
.oracle-heading { margin: 0 0 var(--s-2); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h2); line-height: 1.15; }
.oracle-lead { margin: 0 0 var(--s-5); color: var(--text-soft); max-width: var(--measure); }
.oracle-form { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3); }
.oracle-ask { font-weight: 600; font-size: var(--t-body); }
.oracle-ask span { font-weight: 400; color: var(--text-secondary); margin-left: var(--s-2); }
.hand-intent { display: flex; flex-direction: column; gap: var(--s-3); max-width: 44rem; margin: 0 auto var(--s-5); }
.oracle-form textarea, .hand-intent textarea {
  width: 100%; resize: vertical; min-height: 4.5em; padding: var(--s-3) var(--s-4);
  font: 400 var(--t-body) / 1.5 var(--font-sans); color: var(--text-primary);
  background: color-mix(in srgb, var(--bg-page) 72%, transparent);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
}
.oracle-form textarea::placeholder, .hand-intent textarea::placeholder { color: var(--text-secondary); }
.oracle-result {
  margin-bottom: var(--s-5); padding: var(--s-5); color: var(--text-primary);
  background: var(--grad-ethereal-light); border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-antique-gold) 45%, transparent), var(--e-2);
}
.oracle-result .oracle-saying blockquote, .oracle-result .oracle-intention { color: var(--color-mystic-plum); }
.oracle-label { margin: var(--s-5) 0 var(--s-2); font-weight: 600; font-size: var(--t-label); letter-spacing: .06em; font-variant-caps: all-small-caps; color: var(--text-secondary); }
.oracle-hand { margin: 0; font-weight: 600; max-width: var(--measure); }
.oracle-hand + .oracle-working { margin-top: var(--s-4); }
.oracle-intention {
  margin: 0; padding-left: var(--s-4); border-left: 2px solid var(--accent-line);
  font-family: var(--font-serif); font-style: italic; font-size: var(--t-lead); line-height: 1.5; max-width: var(--measure);
}
.oracle-text { margin: 0 0 var(--s-4); font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.65; max-width: var(--measure); }
.oracle-saying { margin: var(--s-5) 0 0; }
.oracle-saying .eyebrow { margin: 0 0 var(--s-2); }
.oracle-saying blockquote {
  margin: 0; padding-left: var(--s-4); border-left: 2px solid var(--accent-line);
  font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.55; max-width: var(--measure);
}
.oracle-result .label-bot { margin: var(--s-4) 0 0; }
.oracle-working { display: flex; align-items: center; gap: var(--s-3); margin: 0; color: var(--text-soft); }
.oracle-error { margin: 0; color: var(--state-error); }
@media (max-width: 480px) { .hand-panel { padding: var(--s-5) var(--s-3); } .oracle { padding-top: var(--s-5); margin-top: var(--s-5); } }

/* ---------- Pursah's Gospel of Thomas page: one long papyrus scroll, rolled at the top and the bottom ---------- */
.thomas-main { max-width: 50rem; margin: var(--s-4) auto var(--s-8); padding: 0 var(--s-6); }

/* The two rolls: a cylinder of rolled papyrus with wooden ends. They sit over the edges of the sheet. */
.scroll-roll {
  position: relative; z-index: 2; height: 40px; border-radius: 20px;
  background:
    repeating-linear-gradient(90deg, rgba(90, 60, 20, .07) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, #6E5026 0%, #B8935A 16%, #E4CC90 38%, #CDB074 58%, #9C7640 82%, #624520 100%);
  box-shadow: inset 0 0 0 1px rgba(90, 60, 20, .4), 0 8px 16px -6px rgba(60, 40, 10, .5);
}
.scroll-roll::before, .scroll-roll::after {
  content: ""; position: absolute; top: -6px; width: 20px; height: 52px; border-radius: 10px;
  background: linear-gradient(180deg, #4A3016, #A07440 30%, #7A5426 62%, #3F2A12);
  box-shadow: 0 3px 6px rgba(40, 25, 8, .45), inset 0 0 0 1px rgba(30, 18, 4, .35);
}
.scroll-roll::before { left: -12px; }
.scroll-roll::after { right: -12px; }
.scroll-roll.roll-top { margin-bottom: -14px; }
.scroll-roll.roll-bottom { margin-top: -14px; }

/* The sheet itself: the same papyrus as the replies on the home page, with the shade of the roll falling on it.
   It keeps its warm tone and dark ink in both themes. */
.scroll-sheet {
  position: relative; margin: 0 6px; padding: var(--s-7) clamp(24px, 6vw, 64px) var(--s-7);
  color: var(--color-midnight);
  background:
    linear-gradient(180deg, rgba(60, 40, 10, .30), transparent 46px),
    linear-gradient(0deg, rgba(60, 40, 10, .30), transparent 46px),
    linear-gradient(90deg, rgba(120, 84, 36, .16), transparent 7%, transparent 93%, rgba(120, 84, 36, .16)),
    radial-gradient(ellipse at 18% 6%, rgba(255, 250, 230, .65), transparent 50%),
    radial-gradient(ellipse at 88% 94%, rgba(120, 84, 36, .14), transparent 55%),
    repeating-linear-gradient(90deg, rgba(120, 84, 36, .03) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(0deg, rgba(110, 74, 30, .045) 0 2px, transparent 2px 13px),
    var(--grad-ethereal-light);
  box-shadow: inset 0 0 40px rgba(120, 84, 36, .2), 0 14px 30px -14px rgba(60, 40, 10, .5);
}
.scroll-sheet .eyebrow, .scroll-sheet .thomas-count { color: #6B5530; margin: 0 0 var(--s-2); }
.scroll-sheet h1 { margin: 0 0 var(--s-3); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h2); line-height: 1.15; color: var(--color-midnight); }
.thomas-intro { margin: 0 0 var(--s-5); font-family: var(--font-serif); font-style: italic; font-size: var(--t-lead); line-height: 1.5; color: #4A3D26; max-width: var(--measure); }
.scroll-sheet a { color: #5E4521; }
.thomas-tools {
  position: sticky; top: 0; z-index: 1; margin: 0 calc(var(--s-3) * -1); padding: var(--s-3);
  background: #EBDBB4; box-shadow: 0 6px 8px -6px rgba(60, 40, 10, .35);
  border-bottom: 1px solid rgba(125, 98, 52, .3);
}
.thomas-filter {
  width: 100%; min-height: 44px; padding: 0 var(--s-4);
  font: 400 var(--t-body) / 1.5 var(--font-sans); color: var(--color-midnight);
  background: rgba(255, 250, 235, .55); border: 1px solid rgba(125, 98, 52, .5); border-radius: var(--r-md);
}
.thomas-filter::placeholder { color: #6B5530; opacity: 1; }
.thomas-count { margin: var(--s-2) 0 0; font-size: var(--t-small); }
.thomas-list { list-style: none; margin: var(--s-2) 0 0; padding: 0; }
.thomas-item { margin: 0; padding: var(--s-5) 0; border-top: 1px solid rgba(125, 98, 52, .28); scroll-margin-top: 7rem; }
.thomas-item:first-child { border-top: 0; }
.thomas-item[hidden] { display: none; }
.thomas-item:target { background: rgba(168, 134, 78, .2); box-shadow: -12px 0 0 rgba(168, 134, 78, .2), 12px 0 0 rgba(168, 134, 78, .2); }
.thomas-num { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-3); margin: 0 0 var(--s-1); }
.thomas-num a {
  font-family: var(--font-serif); font-weight: 700; font-size: 1.75rem; line-height: 1.1;
  font-variant-numeric: lining-nums; color: #7D6234; text-decoration: none;
}
.thomas-num a:hover { color: #3F2F14; text-decoration: underline; }
.thomas-today { font-size: var(--t-micro); letter-spacing: .06em; text-transform: uppercase; color: #6B5530; border: 1px solid rgba(125, 98, 52, .55); border-radius: var(--r-pill); padding: 1px var(--s-3); }
.thomas-text { margin: 0; font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.65; color: var(--color-midnight); max-width: var(--measure); }
@media (max-width: 480px) {
  .thomas-main { padding: 0 var(--s-4); }
  .scroll-sheet { margin: 0 2px; padding: var(--s-6) var(--s-4); }
  .scroll-roll { height: 32px; border-radius: 16px; }
  .scroll-roll::before, .scroll-roll::after { height: 42px; width: 16px; top: -5px; }
  .scroll-roll::before { left: -8px; }
  .scroll-roll::after { right: -8px; }
}

/* Links on parchment are plum; gold ink on hover. */
.msg.bot .bubble a, .card-dialog a, .oracle-result a { color: var(--color-mystic-plum); text-underline-offset: .15em; }
.msg.bot .bubble a:hover, .card-dialog a:hover, .oracle-result a:hover { color: var(--color-gold-ink); }

/* The deck page leads with the cards. The Forgiveness Deck emblem sits small beside the title; on the first visit it
   opens the page full size, then settles into place (deck/intro.js). */
body.page-cards .wordmark .logo { height: 64px; }
body.page-cards .top { padding-top: var(--s-3); padding-bottom: var(--s-3); }
body.page-cards .deck-main { padding-top: var(--s-2); }
.deck-intro {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--s-5); row-gap: 2px;
  grid-template-areas: "logo title" "logo clarify" "logo about";
  align-items: center; align-content: center; max-width: 44rem; margin: 0 auto; text-align: left;
}
.deck-intro h1 {
  grid-area: title; margin: 0; color: var(--color-soft-gold); font-weight: 400; letter-spacing: .02em;
  font-size: var(--t-h3); line-height: 1.15;
}
.deck-intro .clarify { grid-area: clarify; }
.deck-intro .about { grid-area: about; margin-top: 0; }
.deck-intro .about .lead { text-align: left; }
.deck-logo {
  grid-area: logo; align-self: start; display: block; width: 104px; height: auto; margin: 0;
  -webkit-mask-image: radial-gradient(circle closest-side, #000 90%, transparent 100%);
  mask-image: radial-gradient(circle closest-side, #000 90%, transparent 100%);
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--color-soft-gold) 22%, transparent));
  view-transition-name: deck-logo;
}
body.page-cards .hand-panel { margin-top: var(--s-4); }

/* First visit: the emblem alone, centred on the night sky. A tap, a key, a scroll, or 2.6s settles it. */
.deck-intro-play body.page-cards .top { visibility: hidden; }
.deck-intro-play :is(.hand-panel, .site-foot, .cookie-notice, .deck-intro .about) { display: none; }
.deck-intro-play .deck-intro {
  min-height: calc(100svh - 160px); display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: var(--s-4); text-align: center;
}
.deck-intro-play .deck-intro h1 {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
}
.deck-intro-play .deck-logo { width: min(86vw, 460px); animation: deck-logo-in 1.4s var(--ease-out) both; }
.deck-intro-play .deck-intro .clarify { animation: deck-fade-in 1s .7s var(--ease-out) both; }
@keyframes deck-logo-in { from { opacity: 0; transform: scale(.94); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes deck-fade-in { from { opacity: 0; } to { opacity: 1; } }
::view-transition-group(deck-logo) { animation-duration: .9s; animation-timing-function: var(--ease-in-out); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .7s; }

@media (max-width: 480px) {
  body.page-cards .wordmark .logo { height: 48px; }
  .deck-intro { column-gap: var(--s-4); }
  .deck-logo { width: 72px; }
}

/* Sub-sections inside a policy (the cookies part of the privacy policy). */
.policy h3 {
  margin: var(--s-5) 0 var(--s-2); font-family: var(--font-serif); font-weight: 500;
  font-size: 1.1875rem; line-height: 1.3; color: var(--text-primary);
}
.policy h2[id] { scroll-margin-top: 5rem; }
.policy strong { color: var(--text-primary); font-weight: 600; }

/* Language switch: a small globe and the other language, in a quiet pill. */
.nav a.lang, body:is(.page-home, .page-deck) .nav a.lang {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px 6px 11px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-soft-gold) 35%, transparent);
  font-size: 13px; letter-spacing: .04em; line-height: 1;
  transition: border-color .2s, color .2s, background-color .2s;
}
.nav a.lang::before {
  content: ""; width: 15px; height: 15px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3Cpath d='M3 12h18'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3Cpath d='M3 12h18'/%3E%3C/svg%3E") center / contain no-repeat;
}
.nav a.lang:hover, .nav a.lang:focus-visible {
  border-color: var(--color-soft-gold);
  background: color-mix(in srgb, var(--color-soft-gold) 10%, transparent);
}

/* The Reading Room (/library/, /es/library/): a quiet, editorial catalog. Covers are the focus; surfaces and type follow DESIGN_SYSTEM. */
.lib-main { max-width: 1200px; margin: 0 auto; padding: var(--s-6) clamp(20px, 4vw, 48px) var(--s-8); }
.lib-hero { max-width: 46rem; padding-top: var(--s-7); }
.lib-hero h1 { margin: var(--s-2) 0 var(--s-4); font-family: var(--font-serif); font-weight: 400; font-size: var(--t-display); line-height: 1.1; letter-spacing: -0.01em; color: var(--heading); text-wrap: balance; }
.lib-lead { margin: 0 0 var(--s-4); font-family: var(--font-serif); font-size: var(--t-lead); line-height: 1.5; color: var(--text-body); max-width: var(--measure); }
.lib-independence { margin: 0; font-size: var(--t-small); line-height: 1.5; color: var(--text-body); max-width: var(--measure); }
.lib-hero .ornament { margin: var(--s-7) 0 0; }
.lib-section { padding: var(--s-8) 0 0; }
.lib-section h2 { margin: 0 0 var(--s-2); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h2); line-height: 1.2; color: var(--heading); text-wrap: balance; }
.lib-section-lead { margin: 0 0 var(--s-6); font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.6; color: var(--text-body); max-width: var(--measure); }
.lib-label { font-family: var(--font-sans); font-size: var(--t-label); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.lib-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-7) var(--s-5); }
.lib-grid--compact { margin-top: var(--s-4); }
@media (min-width: 560px) { .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .lib-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .lib-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.lib-book { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.lib-cover { position: relative; aspect-ratio: 2 / 3; width: 100%; max-width: 280px; margin: 0; border-radius: var(--r-sm); overflow: hidden; box-shadow: var(--e-2); background: var(--color-shadow); }
.lib-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lib-cover--typeset { display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center; padding: var(--s-6) var(--s-4); background: var(--color-mystic-plum); border: 1px solid var(--border-strong); }
.lib-cover--typeset::before, .lib-cover--typeset::after { content: ""; display: block; width: 48px; height: 1px; background: var(--accent-line); }
.lib-cover-title { font-family: var(--font-serif); font-size: clamp(1.25rem, 1rem + 0.8vw, 1.6rem); line-height: 1.2; color: var(--color-soft-gold); text-wrap: balance; }
.lib-cover-author { font-family: var(--font-sans); font-size: var(--t-label); letter-spacing: 0.06em; font-variant: small-caps; color: var(--color-soft-light); }
.lib-body { display: flex; flex-direction: column; gap: var(--s-2); }
.lib-body > * { margin: 0; }
.lib-body .lib-lang { font-family: var(--font-sans); font-size: var(--t-label); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.lib-title { font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h3); line-height: 1.25; color: var(--text-primary); text-wrap: balance; }
.lib-author { font-size: var(--t-small); color: var(--text-body); }
.lib-desc { font-family: var(--font-serif); font-size: 17px; line-height: 1.55; color: var(--text-body); text-wrap: pretty; }
.lib-original, .lib-source { font-size: var(--t-small); line-height: 1.45; color: var(--text-body); }
.lib-facts { display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-3); margin: var(--s-1) 0 0; font-size: var(--t-small); }
.lib-facts dt { color: var(--accent); }
.lib-facts dd { margin: 0; color: var(--text-primary); }
.lib-topics { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 0; margin: var(--s-1) 0 0; }
.lib-topics li { font-size: var(--t-small); line-height: 1.3; padding: 4px var(--s-3); border: 1px solid var(--border-subtle); border-radius: var(--r-pill); color: var(--text-body); }
.lib-actions { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3); margin-top: var(--s-2); }
.lib-buy { min-height: 44px; }

.lib-tools { display: grid; gap: var(--s-4); margin: 0 0 var(--s-6); }
.lib-search { width: 100%; max-width: 36rem; min-height: 48px; padding: 0 var(--s-4); border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--color-shadow); color: var(--text-primary); font: 400 16px/1.4 var(--font-sans); }
.lib-search::placeholder { color: var(--color-dusk); opacity: 1; }
.lib-search:focus-visible, .lib-chip:focus-visible, .lib-select select:focus-visible, .lib-clear:focus-visible, .lib-main a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.lib-search:focus { border-color: var(--color-antique-gold); }
.lib-filters { display: grid; gap: var(--s-4); }
.lib-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.lib-fieldset legend { margin-bottom: var(--s-2); padding: 0; }
.lib-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.lib-chip { min-height: 44px; padding: 0 var(--s-4); border-radius: var(--r-pill); border: 1px solid var(--border-subtle); background: transparent; color: var(--text-body); font: 500 15px/1.2 var(--font-sans); cursor: pointer; transition: background var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out); }
.lib-chip:hover { border-color: var(--color-antique-gold); color: var(--text-primary); }
.lib-chip[aria-pressed="true"] { background: var(--color-mystic-plum); border-color: var(--border-strong); color: var(--text-primary); }
.lib-selects { display: grid; gap: var(--s-3); }
@media (min-width: 560px) { .lib-selects { grid-template-columns: repeat(2, minmax(0, 16rem)); } }
.lib-select { display: grid; gap: var(--s-1); }
.lib-select select { min-height: 44px; padding: 0 var(--s-3); border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--color-shadow); color: var(--text-primary); font: 400 16px/1.2 var(--font-sans); }
.lib-clear { justify-self: start; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--text-body); font: 500 15px/1.2 var(--font-sans); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
.lib-clear:hover { color: var(--text-link-hover); }
.lib-count { margin: 0; font-size: var(--t-small); color: var(--text-body); }
.lib-empty { font-family: var(--font-serif); font-size: var(--t-body-serif); color: var(--text-body); }

.lib-paths { display: grid; gap: var(--s-6); }
@media (min-width: 900px) { .lib-paths { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); } }
.lib-path { border-top: 1px solid var(--border-subtle); padding-top: var(--s-4); }
.lib-path-title { margin: 0 0 var(--s-2); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h3); line-height: 1.3; color: var(--heading); }
.lib-path-intro { margin: 0 0 var(--s-4); font-size: var(--t-small); color: var(--text-body); }
.lib-path-list { margin: 0; padding-left: 1.2em; font-family: var(--font-serif); font-size: 17px; line-height: 1.55; color: var(--text-body); }
.lib-path-list li { margin-bottom: var(--s-3); }
.lib-path-book { color: var(--text-primary); font-weight: 500; }
.lib-path-why { display: block; font-size: var(--t-small); font-family: var(--font-sans); color: var(--text-body); }

.lib-authors { display: grid; gap: var(--s-7); }
.lib-author-section { border-top: 1px solid var(--border-subtle); padding-top: var(--s-5); }
.lib-author-name { margin: 0 0 var(--s-3); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h2); line-height: 1.2; color: var(--heading); }
.lib-author-bio { margin: 0 0 var(--s-3); font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.6; color: var(--text-body); max-width: var(--measure); }
.lib-author-rel { margin: 0 0 var(--s-3); font-size: var(--t-small); color: var(--text-body); max-width: var(--measure); }
.lib-author-site { color: var(--accent); font-size: var(--t-small); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.lib-subhead { margin: var(--s-6) 0 0; font-family: var(--font-sans); font-size: var(--t-label); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
.lib-grano .eyebrow { margin-bottom: var(--s-2); }
.lib-publisher-link { margin: 0 0 var(--s-6); }
.lib-publisher-link a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.lib-publisher-link a:hover { color: var(--text-link-hover); }
.page-library .site-foot p { margin: 0 0 var(--s-3); }


/* The primary source: A Course in Miracles itself. A pane of warm midnight glass: the scene shows through,
   and a gold light from the upper left plus a gold hairline set it apart from the interpretations below. */
.lib-primary {
  --text-primary: var(--color-moonlight);
  --text-body: color-mix(in srgb, var(--color-moonlight) 84%, var(--color-dusk));
  --text-secondary: color-mix(in srgb, var(--color-dusk) 60%, var(--color-moonlight));
  --heading: var(--color-soft-gold);
  --accent: var(--color-antique-gold);
  --border-subtle: color-mix(in srgb, var(--color-antique-gold) 26%, transparent);
  position: relative; isolation: isolate; overflow: hidden;
  margin: var(--s-8) 0 0; padding: var(--s-7) clamp(20px, 4vw, 48px);
  border-radius: var(--r-lg);
  border: 1px solid color-mix(in srgb, var(--color-antique-gold) 30%, transparent);
  background:
    radial-gradient(ellipse 60% 70% at 12% 0%, color-mix(in srgb, var(--color-soft-gold) 14%, transparent), transparent 70%),
    linear-gradient(160deg, color-mix(in srgb, var(--color-mystic-plum) 55%, transparent), color-mix(in srgb, var(--color-deep-midnight) 70%, transparent));
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  color: var(--text-body);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--color-soft-gold) 18%, transparent), 0 24px 60px rgba(11, 16, 32, .45);
}
/* A gold hairline across the top edge, brightest at the centre. */
.lib-primary::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px; z-index: -1;
  background: linear-gradient(90deg, transparent, var(--color-soft-gold) 50%, transparent);
  opacity: .7;
}
.lib-primary .lib-cover--course { box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-antique-gold) 35%, transparent), 0 18px 48px rgba(11, 16, 32, .6), 0 0 80px color-mix(in srgb, var(--color-soft-gold) 12%, transparent); }
.lib-primary-grid { display: grid; gap: var(--s-6); align-items: start; }
@media (min-width: 900px) { .lib-primary-grid { grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: var(--s-7); } }
.lib-primary .lib-cover--course { max-width: 300px; }
.lib-cover--course { background: var(--color-midnight); border-color: var(--color-antique-gold); }
.lib-cover--course .lib-cover-title { color: var(--color-soft-gold); font-size: clamp(1.4rem, 1.1rem + 1vw, 2rem); }
.lib-cover--course .lib-cover-author { color: var(--color-soft-light); }
.lib-primary-label { margin: 0 0 var(--s-2); font-family: var(--font-sans); font-size: var(--t-label); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.lib-primary-title { margin: 0 0 var(--s-3); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h1); line-height: 1.15; color: var(--heading); text-wrap: balance; }
.lib-primary-lead { margin: 0 0 var(--s-3); font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.6; color: var(--text-body); max-width: var(--measure); }
.lib-primary-pub { margin: 0 0 var(--s-6); font-size: var(--t-small); color: var(--text-secondary); }
.lib-primary-sub { margin: var(--s-5) 0 var(--s-3); font-family: var(--font-sans); font-size: var(--t-label); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.lib-parts { list-style: none; margin: 0; padding: 0; counter-reset: part; display: grid; gap: var(--s-3); }
@media (min-width: 700px) { .lib-parts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lib-part { counter-increment: part; padding: var(--s-3) 0 0 var(--s-6); border-top: 1px solid var(--border-subtle); position: relative; }
.lib-part::before { content: counter(part) "."; position: absolute; left: 0; top: var(--s-3); font-family: var(--font-serif); color: var(--accent); font-size: var(--t-body-serif); }
.lib-part-name { margin: 0 0 var(--s-1); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h3); line-height: 1.25; color: var(--text-primary); }
.lib-part-desc { margin: 0; font-size: var(--t-small); line-height: 1.5; color: var(--text-body); }
.lib-primary-links { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
@media (min-width: 560px) { .lib-primary-links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lib-primary-link { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 48px; padding: 0 var(--s-5); border-radius: var(--r-md); border: 1px solid color-mix(in srgb, var(--color-antique-gold) 34%, transparent); background: color-mix(in srgb, var(--color-deep-midnight) 45%, transparent); color: var(--color-moonlight); font: 600 16px/1.3 var(--font-sans); text-decoration: none; transition: border-color var(--d-base) var(--ease-out), background var(--d-base) var(--ease-out); }
.lib-primary-link::after { content: "→"; color: var(--color-soft-gold); }
.lib-primary-link:hover { border-color: var(--color-soft-gold); background: color-mix(in srgb, var(--color-antique-gold) 14%, transparent); color: var(--color-moonlight); }
.lib-primary-link::after { transition: transform var(--d-base) var(--ease-out); }
.lib-primary-link:hover::after { transform: translateX(3px); }
.lib-primary-note { margin: var(--s-6) 0 0; font-size: var(--t-small); line-height: 1.5; color: var(--text-secondary); max-width: var(--measure); }

/* Five header links (with the Spanish label) need two rows on a phone. Wrapping keeps the language switch in view. */
@media (max-width: 560px) {
  body.page-library .top { flex-wrap: wrap; row-gap: var(--s-2); }
  body.page-library .nav { flex-wrap: wrap; justify-content: flex-end; column-gap: var(--s-3); row-gap: 4px; }
  body.page-library .nav a { font-size: 14px; letter-spacing: 0.02em; }
}


/* Phones: the five header links do not fit beside the logo. The logo and the language pill share the first row,
   and the page links spread across a second. */
@media (max-width: 480px) {
  .top { position: relative; flex-wrap: wrap; row-gap: 0; }
  .nav, body:is(.page-home, .page-deck) .nav { flex: 1 0 100%; justify-content: space-between; gap: var(--s-2); }
  body:is(.page-home, .page-deck) .nav a { letter-spacing: .1em; }
  .nav a.lang, body:is(.page-home, .page-deck) .nav a.lang {
    position: absolute; top: var(--s-3); right: var(--s-4); min-height: 0; letter-spacing: .04em;
  }
}

/* Home page opening on phones: say what the page is first (headline, starters), then the saying of the day. The question
   box stays at the bottom; the disclaimer scrolls with the opening, and the human check waits until there is something
   to send, so the headline keeps the screen. Once a conversation starts, the box and its note look as usual. */
.welcome-note { display: none; }
@media (max-width: 600px) {
  body.page-home .wordmark .logo { height: 48px; }
  body.page-home .welcome { display: flex; flex-direction: column; align-items: flex-start; margin: var(--s-2) 0 0; }
  body.page-home #chat:has(#welcome) .wrap { margin-block: 0; }
  body.page-home .greet { margin-top: var(--s-3); font-size: 2rem; line-height: 1.1; }
  .amadeus-mark--lg { width: 44px; height: 44px; }
  body.page-home .hint { margin: var(--s-3) 0 var(--s-5); font-size: 1.0625rem; }
  body.page-home .daily { order: 1; margin: var(--s-7) 0 0; }
  body.page-home .welcome-note { display: block; order: 2; margin: var(--s-6) 0 0; }
  body.page-home:has(#welcome) footer.composer .note { display: none; }
  body.page-home:has(#welcome) footer.composer:has(#q:placeholder-shown) #captcha-box { display: none; }
}

/* Support: the quiet "help keep it free" line under an answer or a reading, and the support page's gift button. */
.support-note { margin: var(--s-3) 0 0; color: var(--text-soft); font-size: var(--t-small); }
.support-note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.support-note a:hover { color: var(--text-link-hover); }
.support-action { margin: var(--s-5) 0 var(--s-5); }

/* ---------- The Workbook (/workbook/): a tree of the 365 lessons on the left, the lesson on a papyrus sheet ---------- */
.wb-layout {
  display: grid; grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: var(--s-6); align-items: start;
  max-width: 1200px; margin: var(--s-4) auto var(--s-8); padding: 0 clamp(16px, 3vw, 40px);
}
.wb-side {
  position: sticky; top: var(--s-4); display: flex; flex-direction: column; gap: var(--s-4);
  max-height: calc(100vh - var(--s-6)); padding: var(--s-4);
  background: color-mix(in srgb, var(--color-deep-midnight) 80%, transparent);
  border: 1px solid var(--border-subtle); border-radius: var(--r-lg); box-shadow: var(--e-2);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.wb-today {
  display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); text-decoration: none;
  color: var(--text-primary); border: 1px solid var(--border-strong);
  background: linear-gradient(135deg, var(--color-mystic-plum), color-mix(in srgb, var(--color-antique-gold) 26%, var(--color-mystic-plum)));
  transition: border-color var(--d-base), box-shadow var(--d-base);
}
.wb-today:hover, .wb-today:focus-visible { border-color: var(--color-soft-gold); box-shadow: 0 0 20px -6px color-mix(in srgb, var(--color-soft-gold) 60%, transparent); }
.wb-today .eyebrow { margin: 0; color: var(--color-soft-gold); }
.wb-today-num { font-family: var(--font-serif); font-size: 1.375rem; line-height: 1.2; }
.wb-today-title { font-family: var(--font-serif); font-style: italic; font-size: var(--t-small); line-height: 1.4; color: var(--text-soft); }
/* The visitor's saved lesson sits above the lesson of the day, with a gold edge to tell the two apart. */
.wb-mine-box { border: 1px solid var(--color-soft-gold); border-radius: var(--r-md); background: var(--color-mystic-plum); }
.wb-mine-box[hidden] { display: none; }
.wb-today.wb-mine { border-color: transparent; background: transparent; }
.wb-mine-stop {
  display: block; min-height: 36px; margin: 0 0 0 auto; padding: 0 var(--s-4); cursor: pointer; background: none; border: 0;
  font: 400 var(--t-micro) / 1 var(--font-sans); color: var(--text-soft); text-decoration: underline;
}
.wb-mine-stop:hover, .wb-mine-stop:focus-visible { color: var(--color-soft-gold); }
.wb-toggle { display: none; }
.wb-tree-panel { display: flex; flex-direction: column; gap: var(--s-2); min-height: 0; flex: 1; }
.wb-side-title { margin: 0; font-family: var(--font-serif); font-weight: 500; font-size: 1.25rem; color: var(--heading); }
.wb-filter {
  width: 100%; min-height: 40px; padding: 0 var(--s-3);
  font: 400 var(--t-small) / 1.5 var(--font-sans); color: var(--text-primary);
  background: color-mix(in srgb, var(--color-midnight) 70%, transparent);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
}
.wb-filter::placeholder { color: var(--text-secondary); opacity: 1; }
.wb-filter-count { margin: 0; font-size: var(--t-micro); color: var(--text-secondary); }
.wb-filter-count:empty { display: none; }
.wb-tree {
  flex: 1; min-height: 0; overflow-y: auto; margin: 0 calc(var(--s-2) * -1); padding: 0 var(--s-2) var(--s-2);
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.wb-tree-list { list-style: none; margin: 0; padding: 0; }
.wb-tree-list .wb-tree-list { margin-left: var(--s-3); padding-left: var(--s-2); border-left: 1px solid var(--border-subtle); }
.wb-group > summary {
  display: flex; align-items: baseline; gap: var(--s-2); min-height: 36px; padding: var(--s-2);
  cursor: pointer; list-style: none; border-radius: var(--r-sm); color: var(--text-primary);
}
.wb-group > summary::-webkit-details-marker { display: none; }
.wb-group > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin-right: 2px; transform: translateY(-1px) rotate(-45deg);
  border-right: 1.5px solid var(--color-antique-gold); border-bottom: 1.5px solid var(--color-antique-gold);
  transition: transform var(--d-fast);
}
.wb-group[open] > summary::before { transform: translateY(-3px) rotate(45deg); }
.wb-group > summary:hover { background: color-mix(in srgb, var(--color-soft-gold) 8%, transparent); }
.wb-group-name { flex: 1; font-size: var(--t-small); font-weight: 600; }
.wb-depth-0 > summary .wb-group-name { font-family: var(--font-serif); font-size: 1.0625rem; font-weight: 500; color: var(--color-soft-gold); }
.wb-group-span { font-size: var(--t-micro); color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wb-leaf {
  display: flex; gap: var(--s-2); align-items: baseline; padding: 5px var(--s-2); border-radius: var(--r-sm);
  color: var(--text-soft); text-decoration: none; font-size: var(--t-small); line-height: 1.35;
  border-left: 2px solid transparent;
}
.wb-leaf:hover { color: var(--text-primary); background: color-mix(in srgb, var(--color-soft-gold) 8%, transparent); }
.wb-leaf-num { flex: none; min-width: 2.4em; font-variant-numeric: tabular-nums; color: var(--color-antique-gold); font-weight: 600; }
.wb-leaf-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wb-leaf-section { font-style: italic; }
.wb-leaf[aria-current="page"] { color: var(--text-primary); background: color-mix(in srgb, var(--color-antique-gold) 16%, transparent); border-left-color: var(--color-soft-gold); }
.wb-leaf.is-today .wb-leaf-num::after { content: "•"; margin-left: 3px; color: var(--color-soft-gold); }
.wb-leaf.is-mine { box-shadow: inset 0 0 0 1px var(--color-antique-gold); }

.wb-main { min-width: 0; }
.wb-sheet h1 { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-3); outline: none; }
.wb-sheet h1 .thomas-today { font-family: var(--font-sans); font-weight: 400; }
.wb-title {
  margin: 0 0 var(--s-5); font-family: var(--font-serif); font-style: italic; font-size: var(--t-lead); line-height: 1.45;
  color: #3F2F14; max-width: var(--measure); text-wrap: balance;
}
.wb-instruction { margin: calc(var(--s-3) * -1) 0 var(--s-5); font-size: var(--t-small); color: #6B5530; }
/* Spanish Workbook: an entry not translated yet, shown in English below this note. */
.wb-notice { margin: 0 0 var(--s-5); padding: var(--s-3) var(--s-4); font-size: var(--t-small); font-style: italic; color: #6B5530; border-left: 2px solid rgba(125, 98, 52, .55); background: rgba(125, 98, 52, .06); max-width: var(--measure); }
.wb-body + .wb-notice { margin: var(--s-5) 0 0; }
/* The Workbook is a wide two-column page, so its footer text uses the footer's full width instead of the 60ch column. */
.page-workbook .site-foot p { max-width: none; }
.wb-body { max-width: var(--measure); }
/* The lesson player, shown above the text of an entry that has a recording: a night-blue card on the papyrus sheet. */
.wb-player {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--s-4); row-gap: var(--s-2);
  max-width: var(--measure); margin: 0 0 var(--s-6); padding: var(--s-4) var(--s-4) var(--s-2);
  font-family: var(--font-sans); font-size: var(--t-small); color: #EDE3CB;
  background: radial-gradient(120% 160% at 0% 0%, #22304F 0%, var(--color-midnight) 62%);
  border: 1px solid rgba(217, 189, 136, .45); border-radius: 18px; box-shadow: 0 10px 26px rgba(16, 23, 40, .22);
}
.wb-player[hidden] { display: none; }
.wb-play {
  display: grid; place-items: center; width: 56px; height: 56px; padding: 0; cursor: pointer;
  color: var(--color-midnight); background: linear-gradient(150deg, #EBD6A8, var(--color-antique-gold));
  border: 0; border-radius: 50%; box-shadow: 0 0 0 5px rgba(217, 189, 136, .16); transition: box-shadow .2s, filter .2s;
}
.wb-play:hover { filter: brightness(1.07); box-shadow: 0 0 0 7px rgba(217, 189, 136, .24); }
.wb-play svg { width: 28px; height: 28px; fill: currentColor; }
.wb-player-track { min-width: 0; }
.wb-player-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: var(--s-3); }
.wb-player-title { font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.3; color: #F8EFD8; }
.wb-time { margin-left: auto; font-size: var(--t-micro); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--color-soft-gold); }
/* A thin track with a gold fill up to --wb-progress, which player.js sets; the control itself stays 44px tall. */
.wb-seek {
  display: block; width: 100%; height: 44px; margin: 0; cursor: pointer; background: transparent; appearance: none; -webkit-appearance: none;
}
.wb-seek::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--color-soft-gold) var(--wb-progress, 0%), rgba(237, 227, 203, .22) var(--wb-progress, 0%));
}
.wb-seek::-webkit-slider-thumb {
  width: 16px; height: 16px; margin-top: -5px; background: #F8EFD8; border: 0; border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(217, 189, 136, .28); -webkit-appearance: none;
}
.wb-seek::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(237, 227, 203, .22); }
.wb-seek::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--color-soft-gold); }
.wb-seek::-moz-range-thumb { width: 16px; height: 16px; background: #F8EFD8; border: 0; border-radius: 50%; box-shadow: 0 0 0 4px rgba(217, 189, 136, .28); }
.wb-player-foot {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: var(--s-4);
  border-top: 1px solid rgba(217, 189, 136, .22); padding-top: var(--s-1);
}
.wb-music { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; cursor: pointer; }
.wb-switch {
  flex: none; width: 38px; height: 22px; margin: 0; cursor: pointer; appearance: none; -webkit-appearance: none;
  border: 1px solid rgba(217, 189, 136, .6); border-radius: 11px;
  background: radial-gradient(circle closest-side, #EDE3CB 90%, transparent) left 2px center / 16px 16px no-repeat rgba(237, 227, 203, .14);
  transition: background-position .2s, background-color .2s;
}
.wb-switch:checked {
  background-image: radial-gradient(circle closest-side, var(--color-midnight) 90%, transparent);
  background-position: right 2px center; background-color: var(--color-soft-gold);
}
.wb-voice-note { padding: var(--s-2) 0; font-size: var(--t-micro); font-style: italic; color: #C9BD9F; }
.wb-voice-note.wb-error { font-style: normal; color: #FFC9B8; }
.wb-play:focus-visible, .wb-seek:focus-visible, .wb-switch:focus-visible { outline: 2px solid #F8EFD8; outline-offset: 3px; }
@media (forced-colors: active) {
  .wb-switch { appearance: auto; -webkit-appearance: auto; width: 20px; height: 20px; }
  .wb-seek { appearance: auto; -webkit-appearance: auto; }
  .wb-play { border: 1px solid ButtonText; }
}
@media (prefers-reduced-motion: reduce) {
  .wb-play, .wb-switch { transition: none; }
}
.wb-p, .wb-idea, .wb-verse {
  position: relative; margin: 0 0 var(--s-4);
  font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.7; color: var(--color-midnight);
}
/* Paragraph numbers sit in the margin, as in a printed edition. */
.wb-pn {
  position: absolute; left: -2.6em; top: .35em; width: 2em; text-align: right;
  font-family: var(--font-sans); font-size: var(--t-micro); font-style: normal; font-weight: 400;
  font-variant-numeric: tabular-nums; color: #7D6234;
  -webkit-user-select: none; user-select: none; /* left out of a copied or shared selection */
}
.wb-verse { margin-left: var(--s-5); padding-left: var(--s-4); border-left: 2px solid rgba(125, 98, 52, .45); font-style: italic; }
.wb-verse .wb-pn { left: calc(-2.6em - var(--s-5) - var(--s-4)); }
.wb-idea { margin-top: var(--s-5); font-weight: 600; color: #3F2F14; }
.wb-ref { font-family: var(--font-sans); font-size: var(--t-small); color: #7D6234; }
/* The visitor's place (progress.js), beside the lesson's heading: make this my lesson, or mark it completed.
   It drops under the heading when there is no room next to it. */
.wb-head { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: var(--s-5); max-width: var(--measure); margin-bottom: var(--s-3); }
.wb-head h1 { margin: 0; min-height: 44px; align-content: center; }
/* The control takes the rest of the row, so a message under the switch does not move it. */
.wb-progress { display: flex; flex: 1 1 20rem; flex-wrap: wrap; align-items: center; column-gap: var(--s-4); outline: none; }
.wb-progress[hidden] { display: none; }
.wb-progress-text { margin: 0; font-size: var(--t-small); color: #3F2F14; }
/* After "Mark completed" (or a failed save) the message has its own line. */
.wb-progress-message { flex-basis: 100%; }
.wb-progress .wb-ask { margin: 0; border: 0; cursor: pointer; }
.wb-progress-link { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--t-small); }
/* The "Completed" switch (the player's .wb-switch, recoloured for papyrus) in a pill that turns night blue when on. */
.wb-done {
  display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 0 var(--s-4) 0 var(--s-3); cursor: pointer;
  font: 600 var(--t-small) / 1 var(--font-sans); color: #3F2F14;
  background: rgba(255, 250, 236, .55); border: 1px solid rgba(125, 98, 52, .55); border-radius: var(--r-pill);
  box-shadow: 0 2px 8px rgba(63, 47, 20, .12); transition: background-color .25s, color .25s, border-color .25s, box-shadow .25s;
}
.wb-done:hover { border-color: #6B5530; box-shadow: 0 3px 12px rgba(63, 47, 20, .2); }
.wb-done:has(:checked) { color: #F8EFD8; background: var(--color-midnight); border-color: var(--color-antique-gold); }
.wb-done .wb-switch {
  width: 44px; height: 24px; border-color: #7D6234; border-radius: 12px;
  background: radial-gradient(circle closest-side, #7D6234 90%, transparent) left 2px center / 18px 18px no-repeat rgba(125, 98, 52, .16);
  transition: background-position .25s, background-color .25s;
}
.wb-done .wb-switch:checked {
  background-image: radial-gradient(circle closest-side, var(--color-midnight) 90%, transparent);
  background-position: right 2px center; background-color: var(--color-soft-gold); border-color: var(--color-soft-gold);
}
.wb-done .wb-switch:focus-visible { outline-color: #6B5530; }
@media (forced-colors: active) {
  .wb-done .wb-switch { width: 20px; height: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .wb-done, .wb-done .wb-switch { transition: none; }
}
.wb-pager {
  display: flex; justify-content: space-between; gap: var(--s-4);
  margin-top: var(--s-7); padding-top: var(--s-5); border-top: 1px solid rgba(125, 98, 52, .3);
}
.wb-pager a { display: grid; gap: 2px; min-height: 44px; text-decoration: none; color: #3F2F14; }
.wb-pager a:hover .wb-pager-label { text-decoration: underline; }
.wb-next { margin-left: auto; text-align: right; }
.wb-pager-dir { font-size: var(--t-micro); letter-spacing: .08em; text-transform: uppercase; color: #6B5530; }
.wb-pager-label { font-family: var(--font-serif); font-size: 1.0625rem; }

/* A lesson page (/workbook/lesson-N/): a plain-words explanation and a video commentary under the lesson text. */
.wb-guide, .wb-video { max-width: var(--measure); margin-top: var(--s-7); padding-top: var(--s-5); border-top: 1px solid rgba(125, 98, 52, .3); }
.wb-guide h2, .wb-video h2 { margin: 0 0 var(--s-4); font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h3); line-height: 1.25; color: var(--color-midnight); }
.wb-guide h3 { margin: var(--s-5) 0 var(--s-2); font-family: var(--font-sans); font-size: var(--t-micro); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #6B5530; }
.wb-guide p { margin: 0 0 var(--s-4); font-family: var(--font-serif); font-size: var(--t-body-serif); line-height: 1.7; color: var(--color-midnight); }
.wb-guide .wb-guide-note, .wb-video .wb-video-note { font-family: var(--font-sans); font-size: var(--t-micro); line-height: 1.5; font-style: italic; color: #6B5530; }
.wb-ask {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-5); margin: var(--s-2) 0 var(--s-4);
  font: 600 var(--t-small) / 1 var(--font-sans); color: #F3EBDD; text-decoration: none;
  background: var(--color-midnight); border-radius: var(--r-pill);
}
.scroll-sheet a.wb-ask { color: #F3EBDD; }
.wb-ask:hover, .wb-ask:focus-visible { background: #2A2440; }
.wb-video-frame { position: relative; aspect-ratio: 16 / 9; max-width: 640px; }
.wb-video-frame .vid-card-play, .wb-video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--r-sm); }
.wb-video-frame .vid-thumb { height: 100%; aspect-ratio: auto; }
.wb-video-meta { margin: var(--s-3) 0 var(--s-2); font-size: var(--t-small); color: #3F2F14; }
.wb-video-more { margin: 0 0 var(--s-3); font-size: var(--t-small); color: #3F2F14; }

/* Narrow screens: one column, and the tree folds into a button above the lesson. */
@media (max-width: 899px) {
  .wb-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); padding: 0 var(--s-4); }
  .wb-side { position: static; max-height: none; padding: var(--s-3); gap: var(--s-3); }
  .wb-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 var(--s-4);
    font: 600 var(--t-small) / 1 var(--font-sans); color: var(--text-primary); cursor: pointer;
    background: transparent; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  }
  .wb-toggle::after {
    content: ""; width: 7px; height: 7px; transform: translateY(-2px) rotate(45deg);
    border-right: 1.5px solid var(--color-antique-gold); border-bottom: 1.5px solid var(--color-antique-gold);
  }
  .wb-toggle[aria-expanded="true"]::after { transform: translateY(2px) rotate(-135deg); }
  .wb-tree-panel { display: none; }
  .wb-tree-panel.is-open { display: flex; }
  .wb-tree { max-height: 60vh; }
  .wb-side-title { display: none; }
}
@media (max-width: 700px) {
  .wb-pn, .wb-verse .wb-pn { position: static; display: inline; width: auto; margin-right: var(--s-2); }
  .wb-verse { margin-left: var(--s-2); }
}
@media (max-width: 480px) {
  .wb-layout { padding: 0 var(--s-2); }
}

/* ---- Video library (/videos/, /es/videos/) ---------------------------------------------------------------------- */
.vid-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: var(--s-7) var(--s-5); }
@media (min-width: 560px) { .vid-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .vid-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.vid-card { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.vid-card-play { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--r-sm); }
.vid-card-play:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.vid-thumb { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--r-sm); background: var(--color-shadow); box-shadow: var(--e-2); }
.vid-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform var(--d-fast) var(--ease-out), filter var(--d-fast) var(--ease-out); }
.vid-card-play:hover .vid-thumb img, .vid-card-play:focus-visible .vid-thumb img { transform: scale(1.03); filter: brightness(1.08); }
.vid-play-icon {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(11, 16, 32, .72); border: 1px solid var(--color-soft-gold);
  transition: background var(--d-fast) var(--ease-out);
}
.vid-play-icon::after {
  content: ""; position: absolute; left: 22px; top: 17px;
  border-style: solid; border-width: 11px 0 11px 17px; border-color: transparent transparent transparent var(--color-soft-gold);
}
.vid-card-play:hover .vid-play-icon { background: rgba(11, 16, 32, .9); }
.vid-duration {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 4px;
  background: rgba(11, 16, 32, .85); color: #F3EBDD; font: 600 12px/1.4 var(--font-sans); letter-spacing: .02em; font-variant-numeric: tabular-nums;
}
.vid-card-body { display: flex; flex-direction: column; gap: var(--s-1); }
.vid-card-body > * { margin: 0; }
.vid-category { font-family: var(--font-sans); font-size: var(--t-label); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.vid-title { font-family: var(--font-serif); font-weight: 500; font-size: var(--t-h3); line-height: 1.25; color: var(--text-primary); text-wrap: balance; overflow-wrap: anywhere; }
.vid-teacher { font-size: var(--t-small); color: var(--text-primary); }
.vid-meta { font-size: var(--t-small); color: var(--text-body); }
.vid-level { font-weight: 600; }
.vid-note { margin-top: var(--s-1) !important; font-family: var(--font-serif); font-size: 17px; line-height: 1.55; color: var(--text-body); text-wrap: pretty; }

.vid-stage { display: grid; gap: var(--s-5); margin: var(--s-7) 0 0; padding: var(--s-5); border: 1px solid var(--border-strong); border-radius: var(--r-md); background: color-mix(in srgb, var(--color-shadow) 85%, transparent); box-shadow: var(--e-2); scroll-margin-top: var(--s-5); }
.vid-stage[hidden] { display: none; }
@media (min-width: 1000px) { .vid-stage { grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); align-items: start; } }
.vid-screen { aspect-ratio: 16 / 9; width: 100%; border-radius: var(--r-sm); overflow: hidden; background: #000; }
.vid-frame { display: block; width: 100%; height: 100%; border: 0; }
.vid-now { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.vid-now > * { margin: 0; }
.vid-now-title { font-family: var(--font-serif); font-weight: 500; font-size: clamp(1.375rem, 1.1rem + 0.8vw, 1.75rem); line-height: 1.2; color: var(--heading); text-wrap: balance; overflow-wrap: anywhere; }
.vid-now-title:focus { outline: none; }
.vid-now-teacher { font-size: var(--t-small); color: var(--text-primary); font-weight: 600; }
.vid-now-note { font-family: var(--font-serif); font-size: 17px; line-height: 1.55; color: var(--text-body); }
.vid-now-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5); margin-top: var(--s-2) !important; }
.vid-now-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 600; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.vid-now-link:hover { color: var(--text-link-hover); }
.vid-now-link:focus-visible, .vid-stage .lib-clear:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
@media (max-width: 480px) { .vid-stage { padding: var(--s-3); } }
@media (prefers-reduced-motion: reduce) { .vid-thumb img { transition: none; } .vid-card-play:hover .vid-thumb img { transform: none; } }
/* The video grid is as wide as the page, so its footer lines up with the grid and uses that full width. */
.page-videos .site-foot { max-width: 1200px; padding-left: clamp(20px, 4vw, 48px); padding-right: clamp(20px, 4vw, 48px); }
.page-videos .site-foot p { max-width: none; }

/* Header links at narrower widths. Seven page links and the language pill fit on one row at full size only on wide
   screens, so the links first tighten, then put the icon above a small label, then show the icon alone (the label
   stays for screen readers). */
@media (max-width: 1240px) {
  body .top .nav { gap: var(--s-4); }
  body .top .nav a[data-icon] { letter-spacing: .06em; }
}
@media (max-width: 1040px) {
  body .top .nav { gap: var(--s-3); }
  body .top .nav a[data-icon] { flex-direction: column; justify-content: center; gap: 3px; font-size: 11px; letter-spacing: .05em; }
  body .top .nav a[data-icon]::before { width: 19px; height: 19px; }
  body .top .nav a[data-icon="thomas"]::before { font-size: 17px; }
  body .top .nav a[data-icon="amadeus"]::before { width: 21px; height: 21px; }
}
@media (max-width: 760px) {
  body .top .nav a[data-icon] { min-width: 36px; }
  body .top .nav a[data-icon] .nav-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  body .top .nav a[data-icon]::before { width: 21px; height: 21px; }
  body .top .nav a[data-icon="thomas"]::before { font-size: 19px; }
  body .top .nav a[data-icon="amadeus"]::before { width: 23px; height: 23px; }
}
