/* =============================================================
   MERIDIAN — Design tokens + base styles
   Type: Playfair Display (display) / IBM Plex Sans (UI) / IBM Plex Mono (data)
   ============================================================= */

:root {
  --font-display: 'Playfair Display', 'Times New Roman', serif;
  --font-ui: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-base: 14.5px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 36px;
  --fs-4xl: 48px;
  --fs-5xl: 64px;

  --lh-tight: 1.15;
  --lh-snug: 1.32;
  --lh-normal: 1.55;
  --lh-relaxed: 1.7;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 56px;
  --sp-10: 72px;
  --sp-12: 96px;

  --radius-xs: 1px;
  --radius-sm: 2px;
  --radius-md: 3px;
  --radius-lg: 4px;

  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --dur-fast: 150ms;
  --dur: 220ms;
  --dur-slow: 320ms;

  --content-max: 780px;
  --sidebar-w: 264px;
  --sidebar-collapsed-w: 56px;
}

/* ============== THEME B — INK & LINEN (default light) ============== */
[data-theme="ink"] {
  --bg: #F4F1EC;
  --bg-elev: #FFFFFF;
  --bg-sunken: #ECE8E1;
  --bg-hover: rgba(20, 18, 14, 0.04);
  --bg-active: rgba(20, 18, 14, 0.07);
  --surface-card: #FFFFFF;
  --border: #DCD6CB;
  --border-strong: #B8B0A2;
  --hairline: rgba(20, 18, 14, 0.10);

  --text: #14120E;
  --text-secondary: #5A5448;
  --text-tertiary: #8C8576;
  --text-inverse: #F4F1EC;

  --accent: #1B2A4E;        /* deep navy */
  --accent-hover: #243663;
  --accent-soft: rgba(27, 42, 78, 0.08);
  --accent-text: #FFFFFF;

  --danger: #7A1F1F;
  --warn: #8A6212;
  --success: #2D5A3D;

  --shadow-sm: 0 1px 2px rgba(20,18,14,0.04), 0 0 0 0.5px rgba(20,18,14,0.05);
  --shadow-md: 0 4px 16px -8px rgba(20,18,14,0.12), 0 0 0 0.5px rgba(20,18,14,0.06);
  --shadow-lg: 0 24px 48px -24px rgba(20,18,14,0.18), 0 0 0 0.5px rgba(20,18,14,0.08);

  --texture-opacity: 0.5;
}

/* ============== THEME A — SLATE NIGHT (cool dark) ============== */
[data-theme="slate"] {
  --bg: #0E1219;
  --bg-elev: #161D28;
  --bg-sunken: #0A0D13;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);
  --surface-card: #161D28;
  --border: #232C3B;
  --border-strong: #2F3B4E;
  --hairline: rgba(255, 255, 255, 0.08);

  --text: #E8ECF2;
  --text-secondary: #95A0B3;
  --text-tertiary: #5C6677;
  --text-inverse: #0E1219;

  --accent: #6FB1B0;        /* muted teal */
  --accent-hover: #88C3C2;
  --accent-soft: rgba(111, 177, 176, 0.12);
  --accent-text: #0E1219;

  --danger: #C97D7D;
  --warn: #D4B26B;
  --success: #7DB890;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-md: 0 4px 16px -8px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-lg: 0 24px 48px -24px rgba(0,0,0,0.7), 0 0 0 0.5px rgba(255,255,255,0.06);

  --texture-opacity: 0.4;
}

/* ============== THEME C — GRAPHITE (true neutral dark) ============== */
[data-theme="graphite"] {
  --bg: #111111;
  --bg-elev: #1C1C1C;
  --bg-sunken: #0A0A0A;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);
  --surface-card: #1C1C1C;
  --border: #292929;
  --border-strong: #3A3A3A;
  --hairline: rgba(255, 255, 255, 0.08);

  --text: #F5F5F5;
  --text-secondary: #A0A0A0;
  --text-tertiary: #6A6A6A;
  --text-inverse: #111111;

  --accent: #FFFFFF;
  --accent-hover: #FFFFFF;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --accent-text: #111111;

  --danger: #C97D7D;
  --warn: #C9A87D;
  --success: #8AB89A;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-md: 0 4px 16px -8px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-lg: 0 24px 48px -24px rgba(0,0,0,0.8), 0 0 0 0.5px rgba(255,255,255,0.06);

  --texture-opacity: 0.35;
}

/* ============== THEME D — PARCHMENT (warm institutional) ============== */
[data-theme="parchment"] {
  --bg: #F0EDE6;
  --bg-elev: #FDFAF6;
  --bg-sunken: #E6E2D8;
  --bg-hover: rgba(60, 28, 22, 0.04);
  --bg-active: rgba(60, 28, 22, 0.07);
  --surface-card: #FDFAF6;
  --border: #DCD3BF;
  --border-strong: #B5A88C;
  --hairline: rgba(60, 28, 22, 0.10);

  --text: #2A1F12;
  --text-secondary: #6B5A42;
  --text-tertiary: #9A8B6E;
  --text-inverse: #FDFAF6;

  --accent: #6B1F2A;        /* deep burgundy */
  --accent-hover: #802630;
  --accent-soft: rgba(107, 31, 42, 0.08);
  --accent-text: #FDFAF6;

  --danger: #6B1F2A;
  --warn: #8A6212;
  --success: #3D5A2D;

  --shadow-sm: 0 1px 2px rgba(60,28,22,0.05), 0 0 0 0.5px rgba(60,28,22,0.06);
  --shadow-md: 0 4px 16px -8px rgba(60,28,22,0.14), 0 0 0 0.5px rgba(60,28,22,0.07);
  --shadow-lg: 0 24px 48px -24px rgba(60,28,22,0.20), 0 0 0 0.5px rgba(60,28,22,0.09);

  --texture-opacity: 0.55;
}

/* ============== THEME E — TREASURY (central-bank green, light) ============== */
[data-theme="treasury"] {
  --bg: #EEF0EA;
  --bg-elev: #FBFCF8;
  --bg-sunken: #E4E8DE;
  --bg-hover: rgba(18, 32, 24, 0.04);
  --bg-active: rgba(18, 32, 24, 0.07);
  --surface-card: #FBFCF8;
  --border: #D2D8C9;
  --border-strong: #AAB39C;
  --hairline: rgba(18, 32, 24, 0.10);

  --text: #15201A;
  --text-secondary: #4C594A;
  --text-tertiary: #828D77;
  --text-inverse: #FBFCF8;

  --accent: #1F4D38;
  --accent-hover: #2A6149;
  --accent-soft: rgba(31, 77, 56, 0.09);
  --accent-text: #FBFCF8;

  --danger: #7A2A1F;
  --warn: #8A6212;
  --success: #1F4D38;

  --shadow-sm: 0 1px 2px rgba(18,32,24,0.05), 0 0 0 0.5px rgba(18,32,24,0.06);
  --shadow-md: 0 4px 16px -8px rgba(18,32,24,0.13), 0 0 0 0.5px rgba(18,32,24,0.07);
  --shadow-lg: 0 24px 48px -24px rgba(18,32,24,0.20), 0 0 0 0.5px rgba(18,32,24,0.09);

  --texture-opacity: 0.5;
}

/* ============== THEME F — SANDSTONE & INK (official gazette, light) ============== */
[data-theme="sandstone"] {
  --bg: #ECE7DB;
  --bg-elev: #F7F3EA;
  --bg-sunken: #E1DACA;
  --bg-hover: rgba(30, 27, 22, 0.04);
  --bg-active: rgba(30, 27, 22, 0.07);
  --surface-card: #F7F3EA;
  --border: #D6CDB8;
  --border-strong: #B0A488;
  --hairline: rgba(30, 27, 22, 0.10);

  --text: #1E1B16;
  --text-secondary: #5C5444;
  --text-tertiary: #948A72;
  --text-inverse: #F7F3EA;

  --accent: #2A3D5C;
  --accent-hover: #354c73;
  --accent-soft: rgba(42, 61, 92, 0.09);
  --accent-text: #F7F3EA;

  --danger: #7A2420;
  --warn: #8A6212;
  --success: #3A5236;

  --shadow-sm: 0 1px 2px rgba(30,27,22,0.05), 0 0 0 0.5px rgba(30,27,22,0.06);
  --shadow-md: 0 4px 16px -8px rgba(30,27,22,0.14), 0 0 0 0.5px rgba(30,27,22,0.07);
  --shadow-lg: 0 24px 48px -24px rgba(30,27,22,0.21), 0 0 0 0.5px rgba(30,27,22,0.09);

  --texture-opacity: 0.55;
}

/* ============== THEME G — GLACIER (audit clean-room, cool light) ============== */
[data-theme="glacier"] {
  --bg: #EDF0F2;
  --bg-elev: #FFFFFF;
  --bg-sunken: #E2E7EB;
  --bg-hover: rgba(20, 24, 28, 0.04);
  --bg-active: rgba(20, 24, 28, 0.07);
  --surface-card: #FFFFFF;
  --border: #D2DADF;
  --border-strong: #A8B4BD;
  --hairline: rgba(20, 24, 28, 0.10);

  --text: #14181C;
  --text-secondary: #4E5961;
  --text-tertiary: #84919A;
  --text-inverse: #FFFFFF;

  --accent: #356070;
  --accent-hover: #41768A;
  --accent-soft: rgba(53, 96, 112, 0.10);
  --accent-text: #FFFFFF;

  --danger: #8A2D2D;
  --warn: #8A6212;
  --success: #2D6E5E;

  --shadow-sm: 0 1px 2px rgba(20,24,28,0.05), 0 0 0 0.5px rgba(20,24,28,0.06);
  --shadow-md: 0 4px 16px -8px rgba(20,24,28,0.12), 0 0 0 0.5px rgba(20,24,28,0.06);
  --shadow-lg: 0 24px 48px -24px rgba(20,24,28,0.18), 0 0 0 0.5px rgba(20,24,28,0.08);

  --texture-opacity: 0.45;
}

/* ============== THEME H — BOURSE (exchange prestige, navy + brass, dark) ============== */
[data-theme="bourse"] {
  --bg: #11161F;
  --bg-elev: #19202D;
  --bg-sunken: #0C1018;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);
  --surface-card: #19202D;
  --border: #262F3F;
  --border-strong: #364254;
  --hairline: rgba(255, 255, 255, 0.08);

  --text: #ECE7DC;
  --text-secondary: #9AA0AE;
  --text-tertiary: #626A7A;
  --text-inverse: #11161F;

  --accent: #C9A24B;
  --accent-hover: #DBB663;
  --accent-soft: rgba(201, 162, 75, 0.13);
  --accent-text: #11161F;

  --danger: #C97D7D;
  --warn: #D4B26B;
  --success: #8FB99A;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-md: 0 4px 16px -8px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-lg: 0 24px 48px -24px rgba(0,0,0,0.7), 0 0 0 0.5px rgba(255,255,255,0.06);

  --texture-opacity: 0.4;
}

/* ============== THEME I — CARBON & AMBER (surveillance terminal, dark) ============== */
[data-theme="carbon"] {
  --bg: #0D0E0C;
  --bg-elev: #161814;
  --bg-sunken: #080906;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);
  --surface-card: #161814;
  --border: #24261F;
  --border-strong: #353830;
  --hairline: rgba(255, 255, 255, 0.07);

  --text: #E6E4DA;
  --text-secondary: #9B9A8C;
  --text-tertiary: #61604F;
  --text-inverse: #0D0E0C;

  --accent: #D08A2E;
  --accent-hover: #E29B3C;
  --accent-soft: rgba(208, 138, 46, 0.13);
  --accent-text: #0D0E0C;

  --danger: #C96A52;
  --warn: #D4A24B;
  --success: #8FB36B;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-md: 0 4px 16px -8px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-lg: 0 24px 48px -24px rgba(0,0,0,0.8), 0 0 0 0.5px rgba(255,255,255,0.06);

  --texture-opacity: 0.38;
}

/* ============== THEME J — PRUSSIAN / BLUEPRINT (systems & architecture, dark) ============== */
[data-theme="prussian"] {
  --bg: #0C1418;
  --bg-elev: #122029;
  --bg-sunken: #070E12;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);
  --surface-card: #122029;
  --border: #1E303B;
  --border-strong: #2C4350;
  --hairline: rgba(255, 255, 255, 0.08);

  --text: #DCE6EA;
  --text-secondary: #8FA1AB;
  --text-tertiary: #566873;
  --text-inverse: #0C1418;

  --accent: #4F97AE;
  --accent-hover: #61AAC1;
  --accent-soft: rgba(79, 151, 174, 0.13);
  --accent-text: #0C1418;

  --danger: #C97D7D;
  --warn: #C9A87D;
  --success: #7DB89E;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.45), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-md: 0 4px 16px -8px rgba(0,0,0,0.55), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-lg: 0 24px 48px -24px rgba(0,0,0,0.75), 0 0 0 0.5px rgba(255,255,255,0.06);

  --texture-opacity: 0.42;
}

/* High contrast mode adjustments */
[data-contrast="high"] {
  --border: var(--text-secondary);
  --hairline: var(--text-secondary);
  --text-secondary: var(--text);
  --text-tertiary: var(--text-secondary);
}

/* Reduce motion */
[data-motion="reduced"] *, [data-motion="reduced"] *::before, [data-motion="reduced"] *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

/* Font size steps */
[data-fontsize="comfortable"] { --fs-base: 15.5px; --fs-md: 17px; --fs-lg: 19px; }
[data-fontsize="large"] { --fs-base: 16.5px; --fs-md: 18px; --fs-lg: 20px; --fs-xl: 24px; }

/* ============== RESET & BASE ============== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "ss01", "cv05";
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

::selection { background: var(--accent); color: var(--accent-text); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }

/* ============== TYPOGRAPHY ============== */
.display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
  color: var(--text);
}
.mono {
  font-family: var(--font-mono);
  font-feature-settings: "zero", "ss01";
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 500;
}
.smallcaps {
  font-family: var(--font-ui);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ============== TEXTURES & PATTERNS ============== */
.bg-grid {
  background-image:
    linear-gradient(to right, var(--hairline) 1px, transparent 1px),
    linear-gradient(to bottom, var(--hairline) 1px, transparent 1px);
  background-size: 48px 48px;
}
.bg-dotgrid {
  background-image: radial-gradient(circle, var(--hairline) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ============== SHARED COMPONENTS ============== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-secondary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: rgba(122, 31, 31, 0.06); border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 14px 28px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Inputs */
.input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--text-tertiary); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.field { margin-bottom: 18px; }

/* Tags / chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip-active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip-button { cursor: pointer; transition: all var(--dur) var(--ease); }
.chip-button:hover:not(.chip-active) { border-color: var(--border-strong); color: var(--text); }
.chip-jurisdiction { color: var(--text); }

/* Cards */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.card-elev {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Callout — editorial style: indented vertical rule + small caps label */
.callout {
  margin: 24px 0;
  padding: 4px 0 4px 28px;
  border-left: 2px solid var(--text-tertiary);
}
.callout .callout-label {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  display: block;
}
.callout p {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
}
.callout p + p { margin-top: 10px; }
.callout-definition { border-left-color: var(--text-secondary); }
.callout-regulatory { border-left-color: var(--accent); }
.callout-regulatory .callout-label { color: var(--accent); }
.callout-caution { border-left-color: var(--danger); }
.callout-caution .callout-label { color: var(--danger); }

/* Tables */
.dtable { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.dtable th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.dtable td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  vertical-align: top;
}
.dtable tbody tr:nth-child(even) { background: var(--bg-sunken); }
.dtable tbody tr:hover { background: var(--bg-hover); }

/* Code block */
.codeblock {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text);
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre;
  margin: 24px 0;
}
.codeblock .c-key { color: var(--accent); }
.codeblock .c-comment { color: var(--text-tertiary); font-style: italic; }
.codeblock .c-num { color: var(--warn); }

/* Tooltip */
.tt-wrap { position: relative; display: inline-block; }
.tooltip {
  position: absolute;
  z-index: 50;
  min-width: 200px;
  max-width: 280px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.tooltip.show { opacity: 1; }
.tooltip .tt-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
  display: block;
  font-weight: 500;
}

/* Progress */
.progress-track {
  width: 100%;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}
.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
}
.progress-pill::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Logo */
.logo-mark {
  position: relative;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--text);
  display: inline-block;
  flex-shrink: 0;
}
.logo-mark::before {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--text);
}
.logo-mark::after {
  content: '';
  position: absolute;
  left: -3px; right: -3px;
  top: 50%;
  height: 1px;
  background: var(--text);
  transform: translateY(-50%);
}
.logo-wordmark {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
}
.logo-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Top nav */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav-left { display: flex; align-items: center; gap: 14px; }
.topnav-right { display: flex; align-items: center; gap: 18px; }
.topnav-link {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  cursor: pointer;
}
.topnav-link:hover { color: var(--text); }
.topnav-link.active { color: var(--text); border-bottom-color: var(--accent); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

/* Reading progress bar (top edge) */
.reading-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--accent);
  z-index: 100;
  transition: width 80ms linear;
}

/* Page-jumper-aware page wrapper */
.page-wrap { min-height: 100vh; }

/* Animated entry */
@keyframes meridian-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: meridian-in var(--dur-slow) var(--ease) both;
}
.fade-in-stagger > * {
  animation: meridian-in 380ms var(--ease) both;
}
.fade-in-stagger > *:nth-child(1) { animation-delay: 0ms; }
.fade-in-stagger > *:nth-child(2) { animation-delay: 60ms; }
.fade-in-stagger > *:nth-child(3) { animation-delay: 120ms; }
.fade-in-stagger > *:nth-child(4) { animation-delay: 180ms; }
.fade-in-stagger > *:nth-child(5) { animation-delay: 240ms; }
.fade-in-stagger > *:nth-child(6) { animation-delay: 300ms; }
.fade-in-stagger > *:nth-child(7) { animation-delay: 360ms; }
.fade-in-stagger > *:nth-child(8) { animation-delay: 420ms; }

/* Scrollbar — subtle */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border: 2px solid var(--bg); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Page jumper toolbar (custom, not Tweaks) */
.page-jumper {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.page-jumper button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  border-radius: var(--radius-xs);
  transition: all var(--dur) var(--ease);
}
.page-jumper button:hover { color: var(--text); background: var(--bg-hover); }
.page-jumper button.active { color: var(--accent-text); background: var(--accent); }

/* Pretty defaults */
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; }

/* Utility */
.hstack { display: flex; align-items: center; }
.vstack { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.gap-8 { gap: 40px; }
.flex-1 { flex: 1; }
.muted { color: var(--text-secondary); }
.dim { color: var(--text-tertiary); }
.right { text-align: right; }
