/* ==========================================================================
   Yohaku × Owl — Garden sheet, designer-skills tokens
   Product: a paper margin (desk + spine + catalog + four bands + slip).
   Owl applied: 8pt, one copper hold, register marks, lamp/night.

   Tokens
   ------
   Color: paper ink + copper lamp. Copper is reserved for the one CTA.
   Type: Fraunces (display) + Figtree (UI) + Noto Sans JP (余白). Perfect fourth.
   Space: 8pt only — 8 / 16 / 24 / 32 / 48 / 64.
   Icons: 24 grid, 1.5 stroke, square caps.
   Marks: register corners ⌜ ⌝ ⊕ ⌞ ⌟ — not 速他価手在, not v r w h e.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Global tokens
   -------------------------------------------------------------------------- */
:root {
  --ink-50: #f1f2f6;
  --ink-100: #e2e4ec;
  --ink-200: #c4c8d4;
  --ink-300: #9aa1b4;
  --ink-400: #737b91;
  --ink-500: #5a6278;
  --ink-600: #464d61;
  --ink-700: #353a4b;
  --ink-800: #242836;
  --ink-900: #171a24;
  --ink-950: #0b0d14;

  --cu-50: #fbf4ea;
  --cu-100: #f3e4cc;
  --cu-200: #e4c89a;
  --cu-300: #d4ab6e;
  --cu-400: #c4924a;
  --cu-500: #a87638;
  --cu-600: #8a5e2c;
  --cu-700: #6c4923;
  --cu-800: #4e341a;
  --cu-900: #352412;
  --cu-950: #1f150a;

  --i-50: #e8eef6;
  --i-100: #cdd8ea;
  --i-200: #9bb2d4;
  --i-300: #6e8fb8;
  --i-600: #2c4663;
  --i-800: #1a2738;

  --s-50: #e8f3ef;
  --s-200: #9ac8b6;
  --s-300: #6aac93;
  --s-600: #285848;
  --s-800: #163128;

  --w-50: #f7f0e4;
  --w-200: #d8b87c;
  --w-300: #c49648;
  --w-600: #684b1e;
  --w-800: #382910;

  --d-50: #f6eaea;
  --d-200: #d09aa2;
  --d-600: #5e2c32;
  --d-800: #34191c;

  --viz-velocity: #7ba3c9;
  --viz-outreach: #c9a06a;
  --viz-worth: #9b8ec4;
  --viz-agency: #6ba89a;
  --viz-existential: #c4847a;
  --viz-neutral: #8a90a4;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-sans: "Figtree", ui-sans-serif, system-ui, sans-serif;
  --font-jp: "Noto Sans JP", "Hiragino Sans", sans-serif;
  --font-mono: ui-monospace, "IBM Plex Mono", monospace;
  --fs-caption: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-body: 1rem;
  --fs-sub: 1.3125rem;
  --fs-h3: 1.5rem;
  --fs-h2: 2rem;
  --fs-h1: 3rem;
  --lh-tight: 1.2;
  --lh-body: 1.5;
  --lh-read: 1.75;
  --track-tight: -0.03em;
  --track-wide: 0.08em;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;

  --sheet: 520px;
  --gutter: 24px;
  --page-margin: 32px;

  --radius-sm: 2px;
  --focus-ring: 2px;
  --icon-size: 24px;
  --icon-stroke: 1.5px;

  --duration-instant: 50ms;
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-moderate: 300ms;
  --duration-slow: 400ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --z-nav: 80;
  --z-tooltip: 20;
  --z-scrim: 90;
  --z-drawer: 95;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 1ms;
    --duration-fast: 1ms;
    --duration-normal: 1ms;
    --duration-moderate: 1ms;
    --duration-slow: 1ms;
  }
}

/* --------------------------------------------------------------------------
   2. Semantic aliases — lamp (paper, default)
   Never #fff, never #000. Copper is the only warm fill.
   -------------------------------------------------------------------------- */
:root,
:root[data-theme="lamp"] {
  color-scheme: light;

  --bg: #E8E4D8;
  --surface-1: #F1EDE4;
  --surface-2: #F7F3EA;
  --surface-3: #E2DDD0;

  --text: var(--ink-900);
  --text-secondary: var(--ink-600);
  --text-tertiary: #3d4454;

  --border: rgba(23, 26, 36, 0.12);
  --border-strong: rgba(23, 26, 36, 0.2);
  --rule: rgba(23, 26, 36, 0.1);

  --action-bg: var(--cu-700);
  --action-fg: var(--cu-50);
  --action-hover: var(--cu-600);
  --focus: var(--cu-600);

  --ok-bg: var(--s-50);
  --ok-fg: var(--s-800);
  --ok-border: var(--s-200);

  --warn-bg: var(--w-50);
  --warn-fg: var(--w-800);
  --warn-border: var(--w-200);

  --err-bg: var(--d-50);
  --err-fg: var(--d-800);
  --err-border: var(--d-200);

  --scrim: rgba(11, 13, 20, 0.36);
  --field-well: #EDE8DC;
  --crop-ink: rgba(23, 26, 36, 0.28);
}

:root[data-theme="night"] {
  color-scheme: dark;

  --bg: var(--ink-950);
  --surface-1: var(--ink-900);
  --surface-2: var(--ink-800);
  --surface-3: var(--ink-700);

  --text: var(--ink-100);
  --text-secondary: #b8bdc8;
  --text-tertiary: #969cad;

  --border: rgba(226, 228, 236, 0.1);
  --border-strong: rgba(226, 228, 236, 0.18);
  --rule: rgba(226, 228, 236, 0.08);

  --action-bg: var(--cu-300);
  --action-fg: var(--cu-950);
  --action-hover: var(--cu-200);
  --focus: var(--cu-300);

  --ok-bg: #13241e;
  --ok-fg: #b3d4c6;
  --ok-border: #2a4e42;

  --warn-bg: #241c10;
  --warn-fg: #e2c48a;
  --warn-border: #5e4a20;

  --err-bg: #241416;
  --err-fg: #e0b4ba;
  --err-border: #5e3036;

  --scrim: rgba(6, 7, 10, 0.64);
  --field-well: #10131a;
  --crop-ink: rgba(226, 228, 236, 0.28);
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { background: var(--bg); }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -48px;
  z-index: 100;
  padding: var(--space-1) var(--space-2);
  background: var(--action-bg);
  color: var(--action-fg);
  font-family: var(--font-sans);
  text-decoration: none;
}

.skip-link:focus { top: var(--space-2); }

body.skin-garden-owl {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  text-wrap: pretty;
  transition:
    background-color var(--duration-moderate) var(--ease-standard),
    color var(--duration-moderate) var(--ease-standard);
}

body.skin-garden-owl :focus-visible {
  outline: var(--focus-ring) solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: var(--action-bg);
  color: var(--action-fg);
}

a { color: inherit; text-decoration: none; }

button, textarea, input {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  display: block;
  flex-shrink: 0;
}

.icon-xl { width: 48px; height: 48px; }

[lang="ja"] { font-family: var(--font-jp); }

/* --------------------------------------------------------------------------
   4. Folio nav — ground, not chrome
   -------------------------------------------------------------------------- */
.folio-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-4) var(--page-margin) 0;
  background: transparent;
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
}

.folio-nav a {
  color: var(--text-tertiary);
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
}

.folio-nav a:hover { color: var(--text); }

.folio-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--cu-400);
}

.folio-nav .theme-toggle { margin-left: 0; }

/* --------------------------------------------------------------------------
   5. Desk — emptiness around a single sheet (figure-ground)
   -------------------------------------------------------------------------- */
.desk {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  width: 100%;
  padding: var(--space-6) var(--page-margin);
}

.spine {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 48px;
  padding-top: var(--space-5);
  margin-right: var(--space-4);
  flex-shrink: 0;
  gap: var(--space-4);
}

.spine-mark {
  color: var(--text);
  width: 24px;
  height: 24px;
}

.spine-word {
  margin: 0;
  writing-mode: vertical-rl;
  font-size: var(--fs-sm);
  letter-spacing: 0.32em;
  color: var(--text);
}

.spine-sku {
  margin: 0;
  writing-mode: vertical-rl;
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.sheet {
  position: relative;
  width: min(var(--sheet), 100%);
  padding: var(--space-5) 0 0;
}

/* Print crop marks — the only ornament */
.crop {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.crop::before,
.crop::after {
  content: "";
  position: absolute;
  background: var(--crop-ink);
}

.crop::before { width: 16px; height: 1px; }
.crop::after { width: 1px; height: 16px; }

.crop-tl { top: 0; left: -24px; }
.crop-tl::before { top: 0; right: 0; }
.crop-tl::after { top: 0; right: 0; }

.crop-tr { top: 0; right: -24px; }
.crop-tr::before { top: 0; left: 0; }
.crop-tr::after { top: 0; left: 0; }

.crop-bl { bottom: 0; left: -24px; }
.crop-bl::before { bottom: 0; right: 0; }
.crop-bl::after { bottom: 0; right: 0; }

.crop-br { bottom: 0; right: -24px; }
.crop-br::before { bottom: 0; left: 0; }
.crop-br::after { bottom: 0; left: 0; }

/* --------------------------------------------------------------------------
   6. Type + mast — hierarchy
   -------------------------------------------------------------------------- */
.word-latin {
  margin: 0 0 var(--space-1);
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

h1 {
  margin: 0;
  font-family: var(--font-jp);
  font-size: var(--fs-h1);
  font-weight: var(--fw-regular);
  letter-spacing: 0.18em;
  line-height: var(--lh-tight);
}

.lede {
  margin: var(--space-4) 0 0;
  max-width: 36ch;
  color: var(--text-secondary);
  font-size: var(--fs-body);
  line-height: var(--lh-read);
}

.mast { padding-bottom: var(--space-6); }

.mast-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-5);
  padding-top: var(--space-2);
  border-top: 1px solid var(--rule);
}

.badge,
#statusBadge {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: 0;
  border: 0;
  background: none;
}

.mast-meta .btn-quiet { margin-left: auto; }

/* --------------------------------------------------------------------------
   7. Bands — proximity: header tight to content, 64 between bands
   -------------------------------------------------------------------------- */
.band {
  padding: var(--space-6) 0 0;
  border-top: 1px solid var(--rule);
}

.band-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  margin-bottom: var(--space-3);
}

.num {
  font-family: var(--font-jp);
  font-size: var(--fs-sm);
  color: var(--text);
}

.band-name {
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.meta,
#historyLinkStatus,
#safetyIndicator {
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

#historyLinkStatus { margin-left: auto; }

.aside {
  margin: 0 0 var(--space-3);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
}

/* --------------------------------------------------------------------------
   8. Catalog — similarity: one row language; proximity: 16 within, 48 after
   -------------------------------------------------------------------------- */
.catalog {
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
}

.catalog li + li { border-top: 1px solid var(--rule); }

.catalog-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) 0;
  border: 0;
  background: none;
  text-align: left;
}

.catalog-item:hover,
.catalog-item:focus-visible { color: var(--text); }

.sku {
  flex: 0 0 56px;
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.catalog-name {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  letter-spacing: 0;
}

/* --------------------------------------------------------------------------
   9. Field + compose
   -------------------------------------------------------------------------- */
.field-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

textarea#thoughtInput {
  display: block;
  width: 100%;
  min-height: 168px;
  margin: 0;
  padding: var(--space-1) 0 var(--space-2);
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: var(--font-display);
  font-optical-sizing: auto;
  line-height: var(--lh-read);
  resize: vertical;
  outline: none;
}

textarea#thoughtInput::placeholder { color: var(--text-tertiary); }

textarea#thoughtInput:focus { border-bottom-color: var(--text); }

.compose-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.hint {
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   10. Controls — Von Restorff: one filled hold; all else quiet
   -------------------------------------------------------------------------- */
.btn-primary,
#btnProcess {
  appearance: none;
  border: 0;
  background: var(--action-bg);
  color: var(--action-fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 48px;
  box-shadow: none;
}

.btn-primary:hover:not(:disabled),
#btnProcess:hover:not(:disabled) { background: var(--action-hover); }

.btn-primary:disabled,
#btnProcess:disabled,
#btnProcess.is-busy {
  opacity: 0.72;
  cursor: wait;
}

.btn-quiet,
.filter-btn,
.btn-audio,
.drawer-head button,
.drawer-footer button {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 40px;
  box-shadow: none;
}

.btn-quiet:hover,
.filter-btn:hover,
.drawer-head button:hover,
.drawer-footer button:hover {
  background: var(--surface-2);
}

.btn-quiet > *,
.filter-btn > *,
.btn-primary > *,
#btnProcess > * { pointer-events: none; }

/* --------------------------------------------------------------------------
   11. Loading — pipeline hidden until JS; one lamp, not a generic bar
   -------------------------------------------------------------------------- */
#pipelineProgress,
.pipeline-progress {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--field-well);
  border: 1px solid var(--border);
}

#pipelineProgress[style*="flex"] { display: flex; }

.listen-lamp {
  height: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.listen-lamp span {
  display: block;
  height: 100%;
  width: 8%;
  background: var(--cu-400);
  animation: listen-advance 3.2s var(--ease-standard) forwards;
}

.listen-beats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.listen-beats li {
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding-top: var(--space-1);
  border-top: 2px solid var(--border-strong);
}

#pipelineStepText {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

@keyframes listen-advance {
  0%   { width: 8%; }
  32%  { width: 36%; }
  68%  { width: 68%; }
  100% { width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .listen-lamp span { animation: none; width: 68%; }
}

/* --------------------------------------------------------------------------
   12. Safety
   -------------------------------------------------------------------------- */
#safetyBanner,
.safety-banner { display: none; }

.safety-banner.caution,
#safetyBanner.caution {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  margin: 0;
  border-top: 1px solid var(--warn-border);
  border-bottom: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.safety-banner.safe-badge {
  display: inline;
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--ok-fg);
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  padding: var(--space-1);
  font-weight: var(--fw-medium);
}

.safety-alert {
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--warn-fg);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: var(--space-1);
}

#safetyIndicator { min-height: 0; }

/* --------------------------------------------------------------------------
   13. Field toolbar + canvas (common region)
   -------------------------------------------------------------------------- */
.field-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.canvas-filters,
.canvas-controls,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.filter-btn { border-color: transparent; padding-inline: var(--space-1); }

.filter-btn .tick,
.filter-btn .icon { color: var(--viz-neutral); }

.filter-btn .tick {
  display: block;
  width: 8px;
  height: 8px;
  background: var(--viz-neutral);
}

.filter-btn[data-family="velocity"] .icon { color: var(--viz-velocity); }
.filter-btn[data-family="outreach"] .icon { color: var(--viz-outreach); }
.filter-btn[data-family="worth"] .icon { color: var(--viz-worth); }
.filter-btn[data-family="agency"] .icon { color: var(--viz-agency); }
.filter-btn[data-family="existential"] .icon { color: var(--viz-existential); }

.filter-btn.active {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

#canvasWrapper,
.canvas-wrapper {
  position: relative;
  width: 100%;
  min-height: 420px;
  height: 48vh;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--field-well);
  border-radius: 0;
  box-shadow: none;
}

#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.field-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  text-align: center;
  color: var(--text-tertiary);
  pointer-events: none;
}

.field-empty[hidden] { display: none; }

.field-empty p {
  margin: 0;
  max-width: 36em;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
}

#canvasTooltip,
.canvas-tooltip {
  display: none;
  position: absolute;
  z-index: var(--z-tooltip);
  max-width: 260px;
  padding: var(--space-2);
  pointer-events: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  box-shadow: none;
}

#tooltipTitle {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
}

#tooltipTitle .tooltip-mark {
  margin-right: var(--space-1);
  color: var(--text-secondary);
}

#tooltipMeta {
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
}

#tooltipSnippet {
  margin-top: var(--space-1);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

#graphHud,
.graph-hud {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   14. Return / reverse — bands, not cards
   -------------------------------------------------------------------------- */
.card {
  background: none;
  border-radius: 0;
  box-shadow: none;
}

.card-body {
  margin: 0 0 var(--space-3);
  min-height: 96px;
  color: var(--text);
  font-family: var(--font-display);
  line-height: var(--lh-read);
}

.placeholder-text { color: var(--text-tertiary); font-style: italic; }

.btn-audio.loading,
.btn-audio.playing,
#btnAudioSpeak.loading,
#btnAudioSpeak.playing { border-color: var(--text); }

#audioBtnIcon {
  display: inline-flex;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   15. History as a paper slip — figure over scrim
   -------------------------------------------------------------------------- */
#historyBackdrop,
.history-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: var(--z-scrim);
}

#historyBackdrop.open,
.history-backdrop.open { display: block; }

#historyDrawer,
.history-drawer {
  position: fixed;
  top: 12vh;
  left: 50%;
  width: min(340px, calc(100% - 48px));
  margin-left: calc(min(340px, 100% - 48px) / -2);
  height: auto;
  max-height: 76vh;
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  box-shadow: none;
  transform: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--duration-slow) var(--ease-standard),
    visibility var(--duration-slow) var(--ease-standard);
}

#historyDrawer.open,
.history-drawer.open {
  transform: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.history-drawer .crop-tl { top: -1px; left: -24px; }
.history-drawer .crop-tr { top: -1px; right: -24px; }
.history-drawer .crop-bl { bottom: -1px; left: -24px; }
.history-drawer .crop-br { bottom: -1px; right: -24px; }

.drawer-head,
.drawer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.drawer-head { border-bottom: 1px solid var(--rule); }

.slip-kicker {
  flex: 1 0 100%;
  margin: 0 0 var(--space-1);
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.drawer-head strong {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.drawer-footer {
  border-top: 1px solid var(--rule);
  padding: var(--space-2) var(--space-4) var(--space-4);
}

#drawerList,
.drawer-list {
  flex: 1;
  overflow: auto;
  padding: 0 var(--space-4);
}

.history-empty {
  padding: var(--space-5) 0;
  color: var(--text-tertiary);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
}

.history-item {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}

.history-item:hover { background: var(--surface-2); }

.history-item-top {
  display: flex;
  justify-content: space-between;
  gap: var(--space-1);
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.history-item-preview {
  margin-top: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
}

.history-item-del {
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0 0 0 var(--space-1);
}

/* --------------------------------------------------------------------------
   16. Colophon
   -------------------------------------------------------------------------- */
.colophon {
  width: min(calc(var(--sheet) + 80px), calc(100% - 64px));
  margin: 0 auto;
  padding: 0 0 var(--space-6);
  border-top: 1px solid var(--rule);
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.colophon p { margin: var(--space-2) 0 0; }

@media (max-width: 720px) {
  :root {
    --page-margin: 16px;
    --fs-h1: 2rem;
  }

  .desk {
    flex-direction: column;
    padding: var(--space-5) var(--page-margin) var(--space-6);
  }

  .spine {
    flex-direction: row;
    align-items: center;
    width: 100%;
    margin: 0 0 var(--space-4);
    padding: 0;
    gap: var(--space-2);
  }

  .spine-word,
  .spine-sku {
    writing-mode: horizontal-tb;
    letter-spacing: 0.12em;
  }

  .sheet { padding-top: var(--space-4); }

  .crop-tl,
  .crop-bl,
  .history-drawer .crop-tl,
  .history-drawer .crop-bl { left: 0; }

  .crop-tr,
  .crop-br,
  .history-drawer .crop-tr,
  .history-drawer .crop-br { right: 0; }

  .mast { padding-bottom: var(--space-5); }
  .band { padding-top: var(--space-5); }
  .mast-meta .btn-quiet { margin-left: 0; }

  .folio-nav {
    justify-content: flex-start;
    padding: var(--space-3) var(--page-margin) 0;
  }

  .folio-nav .theme-toggle {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .colophon { width: calc(100% - 32px); }
}
