/* ==========================================================================
   Glossa Apps — "The Margin"
   --------------------------------------------------------------------------
   The company is named for the note written in the margin of a book, so the
   page is set like one: a narrow apparatus rail carrying running heads and
   marginal glosses, beside a bounded text column.

   Type has three jobs, mirroring the app's own contract:
     Prata        — display. Titles only. (Chosen to echo the logotype: wide
                    set, near-circular bowls, high contrast, soft terminals,
                    and the same broad open-loop g. One roman weight, no italic.)
     Literata     — text. Everything meant to be read.
     IBM Plex Mono— apparatus. Labels, captions, controls.

   Colour is the product's colour: warm paper, the logotype's navy ink, and the
   blue of the mark as the signal. The signal means action, current, or progress — never
   decoration.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Paper — the app's own reader tones */
  --paper:        #FAF6EF;   /* AppTheme.paper (light) */
  --paper-warm:   #F4E8D6;   /* ReaderSettings "Warm" paper tone */
  --paper-sunken: #F3ECE0;   /* AppTheme.paperSunken */
  --paper-white:  #FBFAF7;   /* ReaderSettings "White" paper tone */

  /* Ink */
  --ink:    #1A2B44;   /* the logotype's own navy */
  --ink-2:  #45536D;
  --ink-3:  #5A6780;

  /* Signal */
  --accent:       #2562C5;
  --accent-lift:  #3369C9;
  --accent-wash:  rgba(37, 98, 197, 0.10);
  --accent-sel:   rgba(37, 98, 197, 0.20);  /* EPUBSelectionBackground */

  /* Rules */
  --rule:      #D8CEBE;      /* AppTheme.hairline (light) */
  --rule-soft: rgba(28, 27, 24, 0.10);

  /* Type */
  --display: "Prata", "Hoefler Text", Georgia, serif;
  --read:    "Literata", "Iowan Old Style", Georgia, serif;
  --label:   "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Measure */
  --gutter:   clamp(1.35rem, 5vw, 3rem);
  --rail-w:   12.5rem;
  --rail-gap: clamp(1.5rem, 3.6vw, 3.25rem);
  --text-w:   40rem;
  --wide-extra: clamp(3rem, 11vw, 15rem);

  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --ease-firm: cubic-bezier(0.32, 0.72, 0, 1);
  --header-h:  58px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--read);
  font-size: 1.0625rem;
  line-height: 1.72;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-sel); }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ==========================================================================
   1. The spread — apparatus rail + text column
   ========================================================================== */

.spread {
  display: grid;
  grid-template-columns:
    [bleed-start] minmax(var(--gutter), 1fr)
    [rail-start]  minmax(0, var(--rail-w))
    [rail-end text-start] minmax(0, var(--text-w))
    [text-end]    minmax(0, var(--wide-extra))
    [wide-end]    minmax(var(--gutter), 1fr)
    [bleed-end];
  column-gap: var(--rail-gap);
  row-gap: 0;
  align-items: start;
}
.spread > *        { grid-column: text; }
.spread > .rail    { grid-column: rail; }
.spread > .wide    { grid-column: text-start / wide-end; }
.spread > .bleed   { grid-column: bleed; }

/* Sections are leaves of a book: each opens on a rule. */
.leaf {
  padding-block: clamp(3.5rem, 7vw, 5.75rem);
  scroll-margin-top: calc(var(--header-h) + 8px);
  position: relative;
}
.leaf + .leaf { border-top: 1px solid var(--rule-soft); }

.leaf--sunken { background: var(--paper-sunken); border-top-color: var(--rule); }

.leaf--warm { background: var(--paper-warm); border-top-color: var(--rule); }

/* ==========================================================================
   2. Type
   ========================================================================== */

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.004em;
  text-wrap: balance;
  font-synthesis: none;
}
/* Prata ships one roman weight and no italic, so emphasis in the display voice
   is carried by the accent colour, not by a slope. Setting it explicitly keeps
   the browser from faking an oblique. */
h1 em, h2 em, h3 em { font-style: normal; color: var(--accent); }

/* Prata sets about 40% wider than the face this replaced, so the ceiling, the
   fluid step and the floor are all trimmed to keep the hero at two lines. */
.title-hero {
  font-size: clamp(1.95rem, 4vw, 3.2rem);
  line-height: 1.14;
  letter-spacing: -0.01em;
  font-weight: 400;
  max-width: 24ch;
}
h2, .title-leaf {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
  line-height: 1.16;
  letter-spacing: -0.014em;
  max-width: 26ch;
}
/* A product wordmark: larger than a leaf title, smaller than the hero line. */
.title-product {
  font-family: var(--display);
  font-size: clamp(2rem, 3.2vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.012em;
}
h3 {
  font-size: clamp(1.2rem, 1.6vw, 1.4rem);
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.label-head {
  font-family: var(--label);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.prose { color: var(--ink-2); }
.prose p + p { margin-top: 1.05em; }
.prose p { text-wrap: pretty; }
.prose em { font-style: italic; color: var(--ink); }
.prose strong { font-weight: 600; color: var(--ink); }

.lede {
  font-size: clamp(1.1rem, 1.35vw, 1.25rem);
  line-height: 1.55;
  color: var(--ink);
  text-wrap: pretty;
}
.lede + .lede { margin-top: 0.75em; }

.pull {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.3rem, 1.9vw, 1.6rem);
  line-height: 1.3;
  letter-spacing: -0.008em;
  color: var(--ink);
  text-wrap: balance;
  font-synthesis: none;
}
/* The tagline already carries the accent colour; it stays roman. */
.pull em { font-style: normal; }

/* Apparatus voice */
.kicker, figcaption, .meta, .btn, .nav a, .chip {
  font-family: var(--label);
  font-feature-settings: "ss01";
}

.kicker {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ==========================================================================
   3. The rail — marginal glosses
   ========================================================================== */

.rail { position: sticky; top: calc(var(--header-h) + 2.25rem); }

/* A gloss: the marginal note the company is named after. */
.gloss {
  margin-top: 1.9rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--accent);
  font-size: 0.86rem;
  line-height: 1.62;
  color: var(--ink-2);
  font-style: italic;
}
.gloss b {
  display: block;
  font-family: var(--label);
  font-style: normal;
  font-weight: 500;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.rule-mark {
  display: block;
  width: 2rem;
  height: 2px;
  background: var(--accent);
  margin-bottom: 1.5rem;
}

.divider {
  height: 1px;
  background: var(--rule);
  border: 0;
  margin-block: clamp(2.5rem, 5vw, 3.75rem);
}

/* ==========================================================================
   4. Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--rule-soft);
  transition: background-color 0.45s var(--ease), border-color 0.45s var(--ease);
}
.nav {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-inline: var(--gutter);
}
.nav-brand { display: flex; align-items: center; flex: none; }
.nav-brand img { height: 26px; width: auto; }

/* Running head — the page tells you where in the book you are. */
.running-head {
  flex: 1;
  min-width: 0;
  font-family: var(--label);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 1.1rem;
  border-left: 1px solid var(--rule);
  transition: opacity 0.4s var(--ease);
}
.running-head[data-empty="true"] { opacity: 0; }

.nav ul {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2.4vw, 1.9rem);
  flex: none;
}
.nav a {
  transition: color 0.45s var(--ease);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding-block: 0.4rem;
  position: relative;
  transition: color 0.3s var(--ease);
}
.nav a::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease-firm);
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after { transform: scaleX(1); }

/* ==========================================================================
   5. Controls
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.78rem 1.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: 2px;
  white-space: nowrap;
  transition: background 0.3s var(--ease), color 0.3s var(--ease),
              border-color 0.3s var(--ease), transform 0.3s var(--ease-firm);
}
.btn-primary { background: var(--accent); color: #F4F8FE; }
.btn-primary:hover { background: var(--accent-lift); transform: translateY(-1px); }
.btn-ghost { border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0.5px); }

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.link {
  color: var(--accent);
  font-family: var(--label);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}
.link[aria-disabled="true"] {
  color: var(--ink-3);
  border-bottom-style: dotted;
  cursor: default;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.34rem 0.7rem;
}
.chip::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.chip--flat::before { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ==========================================================================
   6. Figures
   ========================================================================== */

figure { margin: 0; }

/* Plate on the left, caption held in the space beside it. */
.figure--side {
  --fig-w: 21rem;
  display: grid;
  grid-template-columns: minmax(0, var(--fig-w)) minmax(0, 1fr);
  gap: clamp(1.5rem, 3.5vw, 3rem);
  align-items: end;
}
.figure--side > figcaption { margin-top: 0; }
figcaption {
  margin-top: 1.1rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--rule);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.055em;
  line-height: 1.6;
  color: var(--ink-3);
  max-width: 34rem;
}
figcaption b {
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 0.5rem;
}

/* ==========================================================================
   7. Hero
   ========================================================================== */

.hero { padding-top: clamp(3rem, 6vw, 4.5rem); padding-bottom: clamp(3rem, 6vw, 4.5rem); }
.hero .actions { margin-top: 2.25rem; }
.hero .lede { margin-top: 1.5rem; max-width: 34rem; }

/* The wordmark standing over the hero line, set to the text column's left edge. */
.hero-mark {
  display: block;
  height: clamp(2.2rem, 4.5vw, 3rem);
  width: auto;
  margin-bottom: clamp(1.75rem, 3vw, 2.5rem);
}

/* The etymology, set as a real dictionary entry */
.entry {
  border-top: 2px solid var(--ink);
  padding-top: 0.9rem;
}
.entry-word {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: 0;
}
.entry-phon {
  font-family: var(--label);
  font-size: 0.78rem;
  color: var(--ink-3);
  margin-top: 0.35rem;
  letter-spacing: 0.04em;
}
.entry-pos {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ink-3);
  margin-top: 0.7rem;
}
.entry-sense {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--ink-2);
  margin-top: 0.2rem;
  display: flex;
  gap: 0.5rem;
}
.entry-sense i { font-style: normal; color: var(--accent); font-family: var(--label); font-size: 0.72rem; padding-top: 0.15em; }

/* ==========================================================================
   8. Editorial blocks
   ========================================================================== */

/* Numbered index list — used for steps, features, principles */
.index { margin-top: clamp(2rem, 4vw, 3rem); }
.index > li {
  display: grid;
  grid-template-columns: 3.1rem 1fr;
  gap: 0 1.1rem;
  padding-block: 1.55rem;
  border-top: 1px solid var(--rule);
}
.index > li:last-child { border-bottom: 1px solid var(--rule); }
.index .n {
  font-family: var(--label);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--accent);
  padding-top: 0.4em;
}
.index h3,
.index .sub-title {
  font-size: clamp(1.08rem, 1.3vw, 1.2rem);
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin-bottom: 0.4rem;
}
.index p { font-size: 0.96rem; line-height: 1.62; color: var(--ink-2); }

/* Two-column index for long feature runs */
.index--two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(2rem, 4vw, 3.5rem);
}
.index--two > li:last-child { border-bottom: none; }
.index--two > li:nth-last-child(-n+2) { border-bottom: 1px solid var(--rule); }

/* Colophon */
.colophon-lead { margin-top: clamp(2rem, 4vw, 2.75rem); }
.colophon-lead > p:last-child {
  margin-top: 0.7rem;
  font-size: 0.92rem;
  color: var(--ink-3);
}
.colophon-lead .label-head { margin-bottom: 0.7rem; }
.closing-note {
  max-width: 34rem;
  margin-top: clamp(2.25rem, 4vw, 3rem);
  padding-top: clamp(1.75rem, 3vw, 2.25rem);
  border-top: 1px solid var(--rule);
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--ink-2);
}
/* The address is one unbreakable token, so the fluid step is steep enough to
   keep it on a single line down to 320px rather than letting it break mid-word. */
.contact-email {
  font-family: var(--display);
  font-size: clamp(1.15rem, 5.4vw, 1.75rem);
  font-weight: 400;
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.55s var(--ease-firm), color 0.35s var(--ease);
}
.contact-email:hover { color: var(--accent); background-size: 100% 1px; }

/* The bare g mark. It is taller than it is wide, so the height is set and the
   width follows the artwork rather than being forced into a square. */
.about-mark { height: 40px; width: auto; margin-bottom: 1.4rem; }

/* ==========================================================================
   9. Footer
   ========================================================================== */

/* The legal identity lives here and nowhere else: quiet, at the foot of the
   last leaf, the way an imprint line is set. */
.site-footer {
  background: var(--paper);
  border-top: 1px solid var(--rule);
  color: var(--ink-3);
  padding-block: 2rem;
  font-family: var(--label);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
}
.footer-inner {
  grid-column: rail-start / text-end;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem 2.5rem;
  flex-wrap: wrap;
}
.footer-inner nav { display: flex; gap: 1.5rem; align-items: center; }
/* The imprint recedes by hierarchy — small, spaced, on its own line — rather
   than by being washed out, so it stays legible where it has to be. */
.imprint {
  flex-basis: 100%;
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: 0.9;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule-soft);
}
.site-footer a { transition: color 0.3s var(--ease); }
.site-footer a:hover { color: var(--ink); }
.site-footer a[aria-disabled="true"] { cursor: default; opacity: 0.6; }

/* ==========================================================================
   9a. Weaver public documents
   ========================================================================== */
.skip-link {
  position: fixed; z-index: 100; left: var(--gutter); top: -5rem;
  background: var(--ink); color: var(--paper-white); padding: .65rem .85rem;
  font-family: var(--label); font-size: .7rem; letter-spacing: .08em;
}
.skip-link:focus { top: .75rem; }
.legal-header .running-head { opacity: 1; }
.legal-header .nav ul { gap: clamp(.7rem, 1.6vw, 1.25rem); }
.legal-header .nav a[aria-current="page"] { color: var(--accent); }
.legal-header .nav a[aria-current="page"]::after { transform: scaleX(1); }
.legal-page { padding-block: clamp(3rem, 7vw, 5.25rem); }
.legal-layout { display: grid; grid-template-columns: minmax(10rem, 13rem) minmax(0, 43rem); gap: clamp(2rem, 5vw, 5rem); align-items: start; max-width: 68rem; margin: 0 auto; padding-inline: var(--gutter); }
.legal-rail { position: sticky; top: calc(var(--header-h) + 2rem); }
.legal-rail p { font-family: var(--label); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .8rem; }
.legal-toc { border-left: 1px solid var(--rule); padding-left: .85rem; }
.legal-toc a { display: block; color: var(--ink-2); font-family: var(--label); font-size: .67rem; line-height: 1.45; padding: .3rem 0; transition: color .2s var(--ease), transform .2s var(--ease); }
.legal-toc a:hover { color: var(--accent); transform: translateX(2px); }
.legal-document { min-width: 0; }
.legal-document > header { padding-bottom: 2rem; border-bottom: 1px solid var(--rule); margin-bottom: 2.5rem; }
.legal-document h1 { font-size: clamp(2.25rem, 5vw, 3.45rem); line-height: 1.08; max-width: 16ch; }
.legal-document h2 { margin-top: 2.8rem; font-size: clamp(1.35rem, 2.8vw, 1.85rem); scroll-margin-top: calc(var(--header-h) + 1rem); }
.legal-document h3 { margin-top: 1.65rem; }
.legal-document p, .legal-document li { color: var(--ink-2); max-width: 68ch; }
.legal-document p + p { margin-top: 1rem; }
.legal-document ul, .legal-document ol { list-style: disc; padding-left: 1.25rem; margin-top: 1rem; }
.legal-document ol { list-style: decimal; }
.legal-document li + li { margin-top: .5rem; }
.legal-document a:not(.btn) { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.legal-document a:not(.btn):hover { color: var(--ink); }
.legal-meta { font-family: var(--label); font-size: .68rem; letter-spacing: .1em; color: var(--ink-3); text-transform: uppercase; margin-top: 1.2rem; }
.legal-callout { border-left: 2px solid var(--accent); background: var(--accent-wash); padding: 1rem 1.1rem; margin: 1.6rem 0; }
.legal-callout p { color: var(--ink); }
.legal-table-wrap { overflow-x: auto; margin: 1.35rem 0; border: 1px solid var(--rule); }
.legal-table { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: .94rem; }
.legal-table th, .legal-table td { vertical-align: top; text-align: left; padding: .8rem .9rem; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.legal-table th { background: var(--paper-sunken); font-family: var(--label); font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink); }
.legal-table tr:last-child td { border-bottom: 0; }
.legal-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.5rem; }
.legal-footer { margin-top: 0; }
@media (max-width: 840px) {
  .legal-layout { grid-template-columns: 1fr; }
  .legal-rail { position: static; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
  .legal-toc { columns: 2; column-gap: 1.5rem; }
  .legal-toc a { break-inside: avoid; }
}
@media (max-width: 620px) {
  .legal-rail { display: none; }
  .legal-document > header { margin-bottom: 2rem; }
  .legal-table { font-size: .88rem; }
}

/* ==========================================================================
   10. Device figures — faithful reconstructions of the shipped iOS UI
   --------------------------------------------------------------------------
   Every label, control order and colour below is taken from the app:
   AppTheme.swift, LMIntent.swift, AssistantSheet.swift and the reader chrome.
   ========================================================================== */

.plate {
  --plate-paper: #FAF6EF;
  --plate-ink: #1A2B44;
  --plate-ink-2: #4A5871;
  --plate-ink-3: #566379;
  --plate-accent: #2562C5;
  --plate-rule: #D8CEBE;
  --plate-sunken: #F3ECE0;
  position: relative;
  background: var(--plate-paper);
  color: var(--plate-ink);
  border-radius: 30px;
  border: 1px solid var(--rule);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 34px 70px -34px rgba(28, 27, 24, 0.42),
    0 4px 14px -8px rgba(28, 27, 24, 0.2);
  overflow: hidden;
  isolation: isolate;
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  container-type: inline-size;
}
.plate--dark {
  --plate-paper: #131824;
  --plate-ink: #EBEFF6;
  --plate-ink-2: #AEBAD0;
  --plate-ink-3: #8C99B2;
  --plate-accent: #8AB0EC;
  --plate-rule: #39445A;
  --plate-sunken: #1A2130;
  border-color: #3A445C;
  box-shadow:
    0 1px 0 rgba(235, 239, 246, 0.06) inset,
    0 0 0 1px rgba(235, 239, 246, 0.05),
    0 44px 80px -30px rgba(0, 0, 0, 0.9);
}

.plate-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.4rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--plate-ink);
}
.plate-status i { font-style: normal; display: flex; gap: 0.3rem; align-items: center; opacity: 0.85; }
.plate-status i s { text-decoration: none; width: 15px; height: 8px; border: 1.2px solid currentColor; border-radius: 2.5px; display: block; position: relative; }
.plate-status i s::after { content: ""; position: absolute; inset: 1.3px; background: currentColor; border-radius: 1px; }
.plate-status i u { text-decoration: none; width: 12px; height: 9px; background:
  conic-gradient(from -90deg at 50% 100%, currentColor 0 90deg, transparent 0);
  clip-path: polygon(0 100%, 50% 0, 100% 100%); display: block; opacity: 0.9; }

/* --- Floating capsule chrome (EPUBReaderChrome) --- */
.pill-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem;
}
.pill {
  background: var(--plate-sunken);
  border: 1px solid color-mix(in srgb, var(--plate-rule) 70%, transparent);
  border-radius: 999px;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0 0.7rem;
  font-size: 0.68rem;
  color: var(--plate-ink);
  box-shadow: 0 5px 14px -10px rgba(0, 0, 0, 0.5);
}
.pill--grow { flex: 1; min-width: 0; }
.pill--title {
  font-family: "Literata", Georgia, serif;
  font-size: 0.74rem;
  letter-spacing: 0.005em;
  padding-inline: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 28px;
  text-align: center;
}
.gl { display: block; width: 13px; height: 13px; color: var(--plate-ink); opacity: 0.9; }

/* --- EPUB page --- */
.epub-page {
  padding: 0.35rem 1.15rem 0.5rem;
  font-family: "Literata", Georgia, serif;
  font-size: 0.79rem;
  line-height: 1.72;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  color: var(--plate-ink);
  position: relative;
}
.epub-page p + p { text-indent: 1.2em; }

.sel {
  background: var(--accent-sel);
  border-radius: 2px;
  padding-inline: 1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  position: relative;
}
.plate--dark .sel { background: rgba(138, 176, 236, 0.22); }
.sel::before, .sel::after {
  content: "";
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--plate-accent);
}
.sel::before { left: -3px; top: -6px; }
.sel::after  { right: -3px; bottom: -6px; }

/* --- Native edit menu (SmartSelectionMenu order) --- */
.edit-menu {
  position: absolute;
  top: var(--menu-top, 7.35rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  background: #333B4D;
  color: #EBEFF6;
  border-radius: 11px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.65);
  font-size: 0.7rem;
  overflow: hidden;
  white-space: nowrap;
  z-index: 3;
}
.plate--dark .edit-menu { background: #414C63; }
.edit-menu span {
  padding: 0.55rem 0.72rem;
  display: flex;
  align-items: center;
  gap: 0.34rem;
  border-right: 1px solid rgba(235, 239, 246, 0.16);
}
.edit-menu span:last-child { border-right: none; padding-inline: 0.6rem; opacity: 0.75; }
.edit-menu .gl { color: #EBEFF6; width: 11px; height: 11px; }

/* --- Bottom chrome --- */
.epub-foot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem 0.75rem;
}
.slider {
  flex: 1;
  min-width: 0;
  background: var(--plate-sunken);
  border: 1px solid color-mix(in srgb, var(--plate-rule) 70%, transparent);
  border-radius: 16px;
  padding: 0.4rem 0.75rem 0.3rem;
  box-shadow: 0 5px 14px -10px rgba(0, 0, 0, 0.5);
}
.slider-track {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--plate-ink) 16%, transparent);
  position: relative;
}
.slider-track::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 17%;
  background: var(--plate-accent);
  border-radius: 2px;
}
.slider-track::after {
  content: "";
  position: absolute;
  left: 17%;
  top: 50%;
  width: 19px; height: 11px;
  transform: translate(-50%, -50%);
  background: var(--plate-paper);
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.slider-label {
  display: block;
  text-align: center;
  font-size: 0.6rem;
  color: var(--plate-ink-3);
  margin-top: 0.6rem;
  letter-spacing: 0.02em;
}

/* --- Assistant sheet (AssistantSheet.swift) --- */
.veil { position: absolute; inset: 0; background: var(--plate-paper); opacity: 0.55; z-index: 2; }
.sheet {
  position: relative;
  z-index: 3;
  margin-top: -1px;
  background: color-mix(in srgb, var(--plate-sunken) 92%, var(--plate-paper));
  border-top: 1px solid color-mix(in srgb, var(--plate-rule) 60%, transparent);
  border-radius: 22px 22px 0 0;
  padding: 0.5rem 1.15rem 1.15rem;
  box-shadow: 0 -18px 40px -26px rgba(0, 0, 0, 0.45);
}
.sheet-grab {
  width: 34px; height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--plate-ink) 26%, transparent);
  margin: 0 auto 0.7rem;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--plate-accent);
}
.sheet-head .gl { color: var(--plate-accent); width: 12px; height: 12px; }
.sheet-term {
  font-family: "Literata", Georgia, serif;
  font-size: 1.12rem;
  line-height: 1.25;
  margin-top: 0.45rem;
  color: var(--plate-ink);
}
.sheet-rule { height: 1px; background: color-mix(in srgb, var(--plate-rule) 75%, transparent); margin: 0.7rem 0 0.75rem; }
.sheet-body {
  font-family: "Literata", Georgia, serif;
  font-size: 0.79rem;
  line-height: 1.66;
  color: var(--plate-ink);
}
.sheet-body em { font-style: italic; }
.sheet-section {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid color-mix(in srgb, var(--plate-rule) 75%, transparent);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--plate-ink-2);
}
.sheet-section .gl { color: var(--plate-ink-2); width: 11px; height: 11px; }
.sheet-entry { margin-top: 0.55rem; }
.sheet-entry b {
  font-family: "Literata", Georgia, serif;
  font-weight: 400;
  font-size: 0.92rem;
  color: var(--plate-ink);
  display: block;
}
.sheet-entry i { font-style: italic; font-size: 0.68rem; color: var(--plate-ink-2); display: block; margin-top: 0.15rem; }
.sheet-entry ol { margin-top: 0.3rem; }
.sheet-entry li { font-size: 0.72rem; line-height: 1.55; color: var(--plate-ink); display: flex; gap: 0.4rem; }
.sheet-entry li s { text-decoration: none; color: var(--plate-ink-3); }
.sheet-credit {
  margin-top: 0.85rem;
  font-size: 0.6rem;
  line-height: 1.6;
  color: var(--plate-ink-3);
}
.sheet-credit u { text-decoration: none; color: var(--plate-accent); display: block; margin-top: 0.15rem; }

/* ==========================================================================
   11. Motion
   ========================================================================== */

.js-motion [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}
.js-motion [data-reveal].is-visible { opacity: 1; transform: none; }

.js-motion .stage .sel { background: transparent; transition: background-color 0.75s var(--ease-firm) 0.25s; }
.js-motion .stage .sel::before,
.js-motion .stage .sel::after { opacity: 0; transition: opacity 0.4s var(--ease) 0.85s; }
.js-motion .stage .edit-menu { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.97); transition: opacity 0.5s var(--ease) 1s, transform 0.5s var(--ease) 1s; }
.js-motion .stage.is-live .sel { background: var(--accent-sel); }
.js-motion .stage.is-live .sel::before,
.js-motion .stage.is-live .sel::after { opacity: 1; }
.js-motion .stage.is-live .edit-menu { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

.js-motion .stage-sheet .sheet { opacity: 0; transform: translateY(22px); transition: opacity 0.7s var(--ease) 0.15s, transform 0.7s var(--ease-firm) 0.15s; }
.js-motion .stage-sheet .veil { opacity: 0; transition: opacity 0.7s var(--ease); }
.js-motion .stage-sheet.is-live .sheet { opacity: 1; transform: none; }
.js-motion .stage-sheet.is-live .veil { opacity: 0.55; }

/* ==========================================================================
   12. Responsive
   ========================================================================== */

@container (max-width: 300px) {
  .epub-page { font-size: 0.72rem; }
  .edit-menu { font-size: 0.62rem; }
}

@media (max-width: 1080px) {
  :root { --rail-w: 9.5rem; --text-w: 36rem; }
  .index--two { grid-template-columns: 1fr; }
  .index--two > li:nth-last-child(-n+2) { border-bottom: none; }
  .index--two > li:last-child { border-bottom: 1px solid var(--rule); }
}

@media (max-width: 900px) {
  .spread {
    grid-template-columns:
      [bleed-start] var(--gutter)
      [rail-start text-start] minmax(0, 1fr)
      [rail-end text-end wide-end] var(--gutter)
      [bleed-end];
  }
  .figure--side { grid-template-columns: 1fr; align-items: start; }
  .figure--side .plate { max-width: var(--fig-w); }
  .figure--side > figcaption { margin-top: 1.1rem; }
  .spread > .rail {
    grid-column: text;
    position: static;
    margin-bottom: 1.75rem;
  }
  .spread > .wide { grid-column: text; }
  .footer-inner { grid-column: text; }
  .gloss { margin-top: 1.1rem; }
  .running-head { display: none; }
}

@media (max-width: 620px) {
  body { font-size: 1rem; }
  .stage { --menu-top: 8rem; }
  .nav ul { gap: 0.85rem; }
  .nav a { font-size: 0.62rem; letter-spacing: 0.1em; }
  .nav-brand img { height: 20px; }
  .index > li { grid-template-columns: 2.3rem 1fr; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .footer-inner nav { flex-wrap: wrap; gap: 1rem; }
}

/* ==========================================================================
   13. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
  .js-motion [data-reveal] { opacity: 1; transform: none; }
  .js-motion .stage .sel { background: var(--accent-sel); }
  .js-motion .stage .sel::before,
  .js-motion .stage .sel::after { opacity: 1; }
  .js-motion .stage .edit-menu { opacity: 1; transform: translateX(-50%); }
  .js-motion .stage-sheet .sheet { opacity: 1; transform: none; }
  .js-motion .stage-sheet .veil { opacity: 0.55; }
}
