/* VirtualMe — site.css
   Editorial, warm-minimal design system. One source of truth.
   No frameworks. Custom properties + mobile-first.
*/

:root {
  /* — color (warm paper, deep ink, oxidized brass) — */
  --paper:        #f6f1e7;        /* off-white, warm */
  --paper-2:      #efe7d6;        /* slightly deeper paper */
  --card:         #fbf7ee;        /* card surface, lighter than paper */
  --ink:          #1d1a14;        /* deep warm ink */
  --ink-2:        #2c2820;        /* secondary ink */
  --muted:        #6b6354;        /* muted text */
  --faint:        #a89f8c;        /* faint metadata */
  --rule:         #d9cfb9;        /* hairline rules */
  --rule-2:       #c8bea4;        /* heavier rule */
  --link:         #6a4a18;        /* readable brass link */
  --accent:       #8a6a1f;        /* dusty brass / oxidized */
  --accent-soft:  #b8964a;
  --highlight:    #f4e9c8;        /* paper highlight (selection-ish) */
  --ok:           #4a6a3a;
  --warn:         #8a6a1f;
  --danger:       #8a3a2a;
  --danger-soft:  #f3d9cf;        /* faded brick — error flash bg */

  /* — type scale — */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Hoefler Text", Georgia, serif;
  --sans:  -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono:  "iA Writer Mono", "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --t-display: 2.625rem;  /* 42 */
  --t-h1:      1.875rem;  /* 30 */
  --t-h2:      1.375rem;  /* 22 */
  --t-h3:      1.125rem;  /* 18 */
  --t-body:    1.0625rem; /* 17 */
  --t-small:   0.9375rem; /* 15 */
  --t-micro:   0.75rem;   /* 12 — eyebrows */

  /* — spacing (4px base, geometric-ish) — */
  --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;

  /* — radii — */
  --r-s: 4px;
  --r-m: 8px;
  --r-l: 14px;

  /* — shadows (subtle) — */
  --shadow-card: 0 1px 0 rgba(29,26,20,0.04), 0 1px 2px rgba(29,26,20,0.05);
  --shadow-modal: 0 10px 32px -12px rgba(29,26,20,0.18), 0 2px 6px rgba(29,26,20,0.06);

  /* — focus — */
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);
}

/* Iter 147: light-mode defaults for the iter-142/143/146 token set.
   MUST be defined BEFORE the dark-mode @media block — same-specificity
   cascade means later rules win, so the light-mode block winning over
   the dark-mode block defeats `prefers-color-scheme`. Dark-mode
   override is in the @media block below. */
:root {
  --pending-fg:       #b06f1c;
  --pending-bg:       #faf2e1;
  --pending-edge:     #e8d3a8;
  --pending-sub:      #8a5a18;
  --pending-sha-bg:   rgba(176,111,28,0.10);

  --action-fg:        currentColor;
  --action-bg:        rgba(255,255,255,0.55);
  --action-bg-hover:  rgba(255,255,255,0.85);

  /* Iter 165: token-kind chip palette. Pre-iter-165 these were
     hardcoded hex inline on each <span> in me.html, which meant the
     same warm-cream backgrounds rendered in dark mode too — too
     bright against the dark-paper page. Centralized here with light
     defaults + a dark override below so prefers-color-scheme works. */
  --chip-read-bg:     #e7efe2;  /* soft sage */
  --chip-read-fg:     #2d4f1d;
  --chip-write-bg:    #f1e6d4;  /* brass */
  --chip-write-fg:    #6a4a18;
  --chip-session-bg:  #e9e4f0;  /* muted indigo */
  --chip-session-fg:  #3a2c5e;
  --chip-confirm-bg:  #efeee7;  /* neutral */
  --chip-confirm-fg:  #6b6354;
  --chip-publish-bg:  #f4e9c8;  /* soft amber */
  --chip-publish-fg:  #6a4a18;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:    #1a1814;
    --paper-2:  #211e18;
    --card:     #221f19;
    --ink:      #ece4d2;
    --ink-2:    #d6cdb7;
    --muted:    #978d77;
    --faint:    #6a6354;
    --rule:     #2f2b22;
    --rule-2:   #3a352a;
    --link:     #c9a55a;
    --accent:   #c9a55a;
    --accent-soft: #8a6a1f;
    --highlight:#3a3221;
    --shadow-card: 0 1px 0 rgba(0,0,0,0.4);
    --shadow-modal: 0 18px 48px -16px rgba(0,0,0,0.6);
    --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);

    /* Dark-mode override for the iter-142/143/146 surfaces.
       Light-mode hardcoded warm-cream/warm-orange clashed on dark;
       state-banner action button was a light pill on dark with
       dark text → invisible. Pending stays warm-amber across modes;
       dark mode uses deep amber + warm cream. */
    --pending-fg:       #e8c885;
    --pending-bg:       #2c2418;
    --pending-edge:     #4a3a1f;
    --pending-sub:      #c4a87c;
    --pending-sha-bg:   rgba(232,200,133,0.12);

    --action-fg:        var(--ink);
    --action-bg:        rgba(255,255,255,0.18);
    --action-bg-hover:  rgba(255,255,255,0.28);

    /* Iter 165 dark-mode token-kind chip palette. Hue-shifted to keep
       a faint sense of category (green/sage = read, brass = write,
       indigo = session) while staying inside the dark-paper warm
       neutrals — chip stays readable against `--paper` and doesn't
       glow against the page. */
    --chip-read-bg:     #1f2a1c;
    --chip-read-fg:     #b8d6a4;
    --chip-write-bg:    #2c2418;
    --chip-write-fg:    #e8c885;
    --chip-session-bg:  #20202c;
    --chip-session-fg:  #b3a9d4;
    --chip-confirm-bg:  #25241e;
    --chip-confirm-fg:  #b8b09e;
    --chip-publish-bg:  #2c2418;
    --chip-publish-fg:  #e8c885;
  }
}

/* Iter 165: token-kind chip classes. Use `.chip .chip--<kind>` on a
   span in /me's tokens list and the iter-162 "your AIs" panel. Color
   pairs come from the `--chip-<kind>-{bg,fg}` custom properties so
   light + dark modes render distinct, readable chips without inline
   hex. .chip extends the existing .badge typography rules. */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill, 999px);
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
  vertical-align: middle;
}
.chip--read    { background: var(--chip-read-bg);    color: var(--chip-read-fg); }
.chip--write   { background: var(--chip-write-bg);   color: var(--chip-write-fg); }
.chip--session { background: var(--chip-session-bg); color: var(--chip-session-fg); }
.chip--confirm { background: var(--chip-confirm-bg); color: var(--chip-confirm-fg); }
.chip--publish { background: var(--chip-publish-bg); color: var(--chip-publish-fg); }

/* — base — */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--t-body);
  line-height: 1.55;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  hyphens: manual;
  -webkit-hyphens: manual;
}

/* Prose-only auto-hyphenation. UI chrome (row__title, row__meta, button
   labels, agent intents) keeps hard-only hyphens — auto-hyphenation
   on short fragments breaks compounds like "immutable-ledger" into
   "im-mutable-ledger" which reads as a typo. */
.page--prose, article, .body {
  hyphens: auto;
  -webkit-hyphens: auto;
}

::selection { background: var(--highlight); color: var(--ink); }

/* — typography primitives — */
.serif { font-family: var(--serif); }
.sans  { font-family: var(--sans); }
.mono  { font-family: var(--mono); font-feature-settings: "liga" 0; }

h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.005em; }
.display { font-family: var(--serif); font-size: var(--t-display); line-height: 1.08; letter-spacing: -0.018em; font-weight: 500; text-wrap: balance; }
.h1 { font-family: var(--serif); font-size: var(--t-h1); line-height: 1.18; letter-spacing: -0.012em; font-weight: 500; text-wrap: balance; }
.h2 { font-family: var(--serif); font-size: var(--t-h2); line-height: 1.25; font-weight: 500; }
.h3 { font-family: var(--sans);  font-size: var(--t-h3); line-height: 1.35; font-weight: 600; letter-spacing: -0.005em; }
.body { font-family: var(--serif); font-size: var(--t-body); line-height: 1.65; }
.small { font-family: var(--sans); font-size: var(--t-small); line-height: 1.5; color: var(--muted); }
.micro { font-family: var(--sans); font-size: var(--t-micro); line-height: 1.4; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

p { margin: 0 0 1em; text-wrap: pretty; }
em, i { font-style: italic; }
strong, b { font-weight: 600; }
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 0.5px; text-underline-offset: 3px; text-decoration-color: var(--rule-2); }
a:hover { text-decoration-color: var(--link); }
a:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 2px; }

hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s-6) 0; }

/* — eyebrow label — */
.eyebrow {
  font-family: var(--sans);
  font-size: var(--t-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* — buttons — */
.btn {
  font-family: var(--sans);
  font-size: var(--t-small);
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 12px 18px;
  border-radius: var(--r-m);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn--primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn--primary:hover { background: var(--ink-2); }
.btn--primary:active { transform: translateY(0.5px); }
.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-2);
}
.btn--secondary:hover { border-color: var(--ink); }
.btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 8px 10px;
}
.btn--ghost:hover { color: var(--ink); }
.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--rule-2);
}
.btn--danger:hover { border-color: var(--danger); }
.btn--lg { padding: 16px 24px; font-size: var(--t-body); border-radius: var(--r-m); }
/* Iter 194: small variant for the granular-revoke button row in
   /me's "your AIs" panel where 3 buttons need to fit per row. */
.btn--sm { padding: 6px 10px; font-size: var(--t-micro); }
.btn--block { display: flex; width: 100%; }

/* — forms — */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.label {
  font-family: var(--sans); font-size: var(--t-micro);
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.input {
  font-family: var(--sans);
  font-size: var(--t-body);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  padding: 12px 14px;
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138,106,31,0.15); }
.input::placeholder { color: var(--faint); }
.input--code {
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  text-align: center;
  padding-right: 0; /* compensate letter-spacing */
}
.help { font-family: var(--sans); font-size: var(--t-small); color: var(--muted); }
.error { font-family: var(--sans); font-size: var(--t-small); color: var(--danger); }

/* — card — */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-l);
  padding: var(--s-5);
  box-shadow: var(--shadow-card);
}

/* — chips/badges — */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans);
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
}
.badge--public { color: var(--accent); border-color: var(--accent-soft); }
.badge--private { color: var(--muted); }
/* Iter 142: pending = AI proposed, owner hasn't approved yet. Warm
   orange to read as "review needed", not error. The public render
   does NOT show this content; it stays past published_sha until the
   owner approves. */
.badge--pending {
  color: var(--pending-fg);
  border-color: var(--pending-edge);
  background: var(--pending-bg);
}

/* Iter 142: state banner above the article. Bigger than the header
   chip — the user's first visual signal of "what state is this page
   in" when they open it in studio. Uses a left-border accent so the
   state reads at a glance even on warm-paper backgrounds. */
.state-banner {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-m);
  border: 1px solid var(--rule);
  border-left-width: 4px;
  font-size: var(--t-small);
  margin-bottom: var(--s-5);
  background: rgba(0,0,0,0.025);
}
.state-banner__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; opacity: 0.7;
  flex: 0 0 auto;
}
.state-banner__label {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--t-micro);
}
.state-banner__hint {
  color: var(--muted);
  font-weight: 400;
}
.state-banner--public {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(107,142,58,0.08);
}
.state-banner--private {
  color: var(--ink-2);
  border-left-color: var(--ink-2);
  background: rgba(0,0,0,0.035);
}
.state-banner--pending {
  color: var(--pending-fg);
  border-left-color: var(--pending-fg);
  background: var(--pending-bg);
}
.state-banner code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  color: inherit;
}
/* Iter 143: inline action button on the state banner — approve→ on
   pending, make public→ / make private→ on approved. Inherits the
   banner's color slot so the affordance reads as part of the state
   strip, not a generic CTA. */
.state-banner__action {
  display: inline-block;
  font: inherit;
  color: var(--action-fg);
  background: var(--action-bg);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 12px;
  margin-left: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.92em;
  white-space: nowrap;
}
.state-banner__action:hover { background: var(--action-bg-hover); }
.state-banner__action:disabled { opacity: 0.55; cursor: progress; }

/* Iter 151 (#43): per-page rollback panel — shown inline below the
   state banner when the user clicks `history ↶`. Lists earlier
   commits that touched this page; each row has a `restore →`
   button. Uses the same warm-paper card treatment as state-banner. */
.page-history {
  margin: 0 0 var(--s-5) 0;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--paper-2);
}
.page-history__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--rule);
}
.page-history__title {
  font-family: var(--sans);
  font-size: var(--t-small);
  color: var(--ink);
  font-weight: 500;
}
.page-history__list { display: flex; flex-direction: column; gap: var(--s-2); }
.page-history__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--rule);
}
.page-history__row:last-child { border-bottom: 0; }
.page-history__meta {
  font-family: var(--sans);
  font-size: var(--t-small);
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 0;
}
.page-history__subject {
  font-family: var(--sans);
  font-size: var(--t-micro);
  color: var(--ink-2);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.page-history__loading {
  font-family: var(--sans); font-size: var(--t-small);
  color: var(--muted); padding: var(--s-3) 0;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }

/* Iter 143: shared state-dot used in /me eyebrow rows so the section
   header carries the same visual signal as the banner on /u/<slug>.
   Inline-block + margin so it sits next to text without breaking flow. */
.state-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: currentColor;
}
.state-dot--pending  { background: var(--pending-fg); }
.state-dot--approved { background: var(--accent); }

/* Iter 143: /me PENDING card — single bordered container so the
   summary head + per-row list line up cleanly. Replaces the prior
   stack of disjointed `.row` blocks with one card whose internal
   dividers sit flush with the edges (fixes the "ugly edges + button
   overflow" the operator flagged). Warm-orange treatment matches
   `state-banner--pending` and `badge--pending`. */
.pending-card {
  border: 1px solid var(--pending-edge);
  border-left-width: 4px;
  border-left-color: var(--pending-fg);
  border-radius: var(--r-m);
  background: var(--pending-bg);
  overflow: hidden;
}
.pending-card__head {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--pending-edge);
}
.pending-card__head-text { flex: 1 1 auto; min-width: 0; }
.pending-card__title {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--ink);
  font-size: 0.98rem;
}
.pending-card__sub {
  font-family: var(--sans);
  font-size: var(--t-small);
  color: var(--pending-sub);
  margin-top: 2px;
}
.pending-card__approve { flex: 0 0 auto; white-space: nowrap; }
.pending-card__list { padding: 0 var(--s-5); }

.pending-row {
  display: flex; align-items: flex-start; gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--pending-edge);
}
.pending-row:last-child { border-bottom: 0; }
.pending-row__main { flex: 1 1 auto; min-width: 0; }
.pending-row__title {
  display: flex; align-items: baseline; gap: 6px;
  flex-wrap: wrap;
  font-family: var(--sans);
  color: var(--ink);
}
.pending-row__ops    { color: var(--pending-fg); font-weight: 600; }
.pending-row__agent  { color: var(--muted); font-weight: 400; }
.pending-row__sha {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--pending-sha-bg);
  padding: 1px 6px;
  border-radius: 4px;
}
.pending-row__intent {
  font-family: var(--sans);
  font-size: var(--t-small);
  color: var(--muted);
  font-style: italic;
  margin-top: 4px;
  word-break: break-word;
}
.pending-row__paths {
  font-family: var(--sans);
  font-size: var(--t-small);
  color: var(--muted);
  margin-top: 4px;
  overflow-wrap: break-word;
}
.pending-row__path { font-size: 0.78rem; color: var(--pending-sub); }

/* Iter 149 (#36): per-row token chips. Tap the live one to revoke
   the AI's write token. Live = pill button with subtle hover lift;
   revoked = static muted strikethrough-ish label. Sized to sit
   inline with the row title without competing with the sha chip. */
.pending-row__token-revoke,
.pending-row__token {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono);
  font-size: 0.74rem;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.pending-row__token-revoke {
  border: 1px solid var(--pending-edge);
  background: transparent;
  color: var(--pending-sub);
  cursor: pointer;
}
.pending-row__token-revoke:hover {
  background: var(--pending-sha-bg);
  color: var(--pending-fg);
  border-color: var(--pending-fg);
}
.pending-row__token--revoked {
  color: var(--muted);
  background: var(--pending-sha-bg);
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}
.pending-row__side {
  display: flex; align-items: center; gap: var(--s-3);
  flex: 0 0 auto;
  white-space: nowrap;
}
.pending-row__ts {
  font-family: var(--sans);
  font-size: var(--t-micro);
  color: var(--muted);
}

@media (max-width: 640px) {
  .pending-card__head { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .pending-card__approve { width: 100%; }
  .pending-row { flex-direction: column; gap: var(--s-2); }
  .pending-row__side { justify-content: space-between; }
}

/* — header pattern — */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-5) var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.brand {
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
}
.brand .dot-mark {
  display: inline-block;
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 9px;
  vertical-align: 1px;
}
.site-header nav { display: flex; gap: var(--s-5); align-items: center; }
.site-header nav a { font-family: var(--sans); font-size: var(--t-small); color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--ink); }

/* — footer pattern — */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: var(--s-7) var(--s-5);
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--t-small);
  display: flex; justify-content: space-between; gap: var(--s-4);
  flex-wrap: wrap;
}
.site-footer a { color: var(--muted); }

/* — page container — */
.page { max-width: 720px; margin: 0 auto; padding: var(--s-5); }
.page--prose { max-width: 640px; }
.page--wide  { max-width: 980px; }

/* — prose (long-form reading) — */
.prose { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.65; color: var(--ink); }
.prose h1 { font-size: var(--t-display); line-height: 1.1; margin: 0 0 var(--s-3); letter-spacing: -0.018em; }
.prose h2 { font-size: 1.5rem; margin: var(--s-7) 0 var(--s-3); }
.prose h3 { font-family: var(--sans); font-size: var(--t-h3); margin: var(--s-5) 0 var(--s-2); font-weight: 600; }
.prose p  { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.2em; margin: 0 0 1em; }
.prose li { margin-bottom: 0.35em; }
.prose blockquote {
  margin: var(--s-5) 0;
  padding-left: var(--s-4);
  border-left: 2px solid var(--rule-2);
  color: var(--ink-2);
  font-style: italic;
}
.prose code {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--paper-2);
  padding: 0.1em 0.35em;
  border-radius: var(--r-s);
}
.prose pre {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  padding: var(--s-4);
  overflow-x: auto;
  line-height: 1.5;
}
.prose pre code { background: transparent; padding: 0; }
.prose a { color: var(--link); }
.prose a.wikilink { text-decoration-style: dashed; text-decoration-color: var(--accent-soft); }
.prose hr { margin: var(--s-7) 0; }
.prose .frontmatter { color: var(--muted); font-family: var(--sans); font-size: var(--t-small); margin-bottom: var(--s-6); }

/* — diff blocks (approval) — */
.diff {
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--card);
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.55;
}
.diff__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: var(--t-small);
  color: var(--ink-2);
}
.diff__path { color: var(--ink); }
.diff__kind { color: var(--muted); font-size: var(--t-micro); letter-spacing: 0.1em; text-transform: uppercase; }
.diff__body { padding: var(--s-3) var(--s-4); white-space: pre-wrap; color: var(--ink-2); }
.diff__line--add { color: var(--ok); }
.diff__line--ctx { color: var(--muted); }

/* — list rows (audit, tokens) — */
.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--rule);
  gap: var(--s-4);
}
.row:last-child { border-bottom: 0; }
.row__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row__title { font-family: var(--sans); font-weight: 500; color: var(--ink); }
.row__meta { font-family: var(--sans); font-size: var(--t-small); color: var(--muted); }
.row__actions { display: flex; gap: var(--s-2); flex-shrink: 0; }

/* — empty state — */
.empty {
  text-align: center;
  padding: var(--s-9) var(--s-5);
  color: var(--muted);
}
.empty__mark {
  width: 28px; height: 28px;
  border: 1px solid var(--rule-2);
  border-radius: 50%;
  margin: 0 auto var(--s-4);
}
.empty p { font-family: var(--serif); font-size: var(--t-h3); color: var(--ink-2); font-style: italic; }

/* — helpers — */
.stack-1 > * + * { margin-top: var(--s-1); }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.stack-5 > * + * { margin-top: var(--s-5); }
.stack-6 > * + * { margin-top: var(--s-6); }
.stack-7 > * + * { margin-top: var(--s-7); }
.row-3 { display: flex; gap: var(--s-3); align-items: center; }
.row-4 { display: flex; gap: var(--s-4); align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); }
.text-muted { color: var(--muted); }
.text-faint { color: var(--faint); }
.text-center { text-align: center; }
.kbd {
  font-family: var(--mono); font-size: 0.78rem;
  border: 1px solid var(--rule-2); border-radius: 4px;
  padding: 1px 5px; color: var(--ink-2);
  background: var(--paper-2);
}

/* — modal (replaces system confirm) — */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(29, 26, 20, 0.45);
  backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
  z-index: 9999; padding: var(--s-4);
  animation: modal-fade 120ms ease-out;
}
.modal-backdrop.show { display: flex; }
.modal-card {
  background: var(--card); color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-l);
  padding: var(--s-6);
  max-width: 440px; width: 100%;
  box-shadow: var(--shadow-modal);
  animation: modal-rise 160ms ease-out;
}
.modal-card h3 {
  font-family: var(--serif); font-size: var(--t-h2);
  font-weight: 500; margin: 0 0 var(--s-3); letter-spacing: -0.01em;
}
.modal-card p {
  font-family: var(--sans); font-size: var(--t-body);
  color: var(--ink-2); margin: 0 0 var(--s-5); line-height: 1.5;
}
.modal-actions {
  display: flex; gap: var(--s-3); justify-content: flex-end;
  /* Iter 202: when an action picker has 3+ choices the row can run
     out of width on the modal card. Wrap onto a second line rather
     than squishing labels together. */
  flex-wrap: wrap;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* — mobile (≤720px) — header wraps cleanly, footer stacks, rows stay inline — */
@media (max-width: 720px) {
  .site-header {
    flex-wrap: wrap; gap: var(--s-2) var(--s-3);
    padding: var(--s-3) var(--s-4);
  }
  .site-header nav { gap: var(--s-3); flex-wrap: wrap; }
  .site-header nav a { font-size: var(--t-small); }
  .brand { font-size: 1rem; }
  .site-footer { flex-direction: column; align-items: flex-start; gap: var(--s-2); padding: var(--s-5) var(--s-4); }
  .page { padding: var(--s-4); }
  .between { flex-wrap: wrap; }
  /* Rows stay single-line: title shrinks/wraps, actions stay anchored right */
  .row { gap: var(--s-3); padding: var(--s-3) 0; }
  .row__main { min-width: 0; flex: 1; }
  .row__title { word-break: break-word; }
  .row__actions { flex-shrink: 0; }
  .badge { white-space: nowrap; }
  /* Tighten section-to-section spacing on small screens */
  .stack-7 > * + * { margin-top: var(--s-5); }
  .stack-6 > * + * { margin-top: var(--s-4); }
}

/* — extra-small (≤480px) — tighten button paddings, badge sizing — */
@media (max-width: 480px) {
  .site-header { padding: var(--s-3) var(--s-3); }
  .site-header nav { width: 100%; justify-content: flex-start; }
  .row__actions .btn { padding: 8px 12px; font-size: var(--t-micro); }
  .badge { font-size: 0.65rem; padding: 2px 6px; letter-spacing: 0.06em; }
  .input--code { font-size: 1.25rem; letter-spacing: 0.4em; }
}

/* Iter 192 a11y: skip-to-main link. Visible only when focused via
   keyboard Tab. Lets keyboard users bypass the site-header nav and
   land directly in <main>. Standard practice — required by WCAG for
   any page with repeated navigation chrome. Use position: absolute
   off-screen by default, then snap into view on :focus. */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 8px;
  background: var(--accent);
  color: var(--paper);
  padding: 8px 16px;
  border-radius: var(--r-m);
  font-family: var(--sans);
  font-size: var(--t-small);
  font-weight: 600;
  text-decoration: none;
  z-index: 10000;
  transition: top 120ms ease;
}
.skip-to-main:focus {
  top: 8px;
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Iter 188 a11y: respect prefers-reduced-motion. Some users have
   vestibular disorders or motion sensitivities triggered by
   transitions and animations; the OS/browser setting
   `prefers-reduced-motion: reduce` is how they signal that. We
   nullify all CSS-level motion (transitions + keyframe animations)
   when the setting is on. Layout stays the same; the modal still
   appears, just without the rise + fade. !important is intentional —
   inline `style="transition: ..."` declarations in templates would
   otherwise override these. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
