:root {
  --radius: 10px;
  --sidebar-w: 240px;
  --detail-w: 420px;
  --archie-fab-size: 3.25rem;
  --archie-fab-inset: 1.25rem;
  --archie-fab-gap: 0.75rem;
  /* Keep FAB / panel / toasts clear of the pinned .app-footer strip. */
  --app-footer-clearance: calc(2.75rem + env(safe-area-inset-bottom, 0px));
  --archie-anchor-bottom: calc(var(--archie-fab-inset) + var(--app-footer-clearance));
  font-family: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* ── Design tokens: foundational scales ──
     Additive framework layer. Use these tokens for new styles so spacing,
     type, radii, elevation and layering stay consistent. Documented live in
     Admin → Design system. */

  /* Type family — shared with public Info/Login feel */
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Outfit", "Source Sans 3", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* Spacing scale (4px base) */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4  */
  --space-2: 0.5rem;    /* 8  */
  --space-3: 0.75rem;   /* 12 */
  --space-4: 1rem;      /* 16 */
  --space-5: 1.5rem;    /* 24 */
  --space-6: 2rem;      /* 32 */
  --space-7: 3rem;      /* 48 */
  --space-8: 4rem;      /* 64 */

  /* Type scale */
  --text-xs: 0.7rem;
  --text-sm: 0.8rem;
  --text-base: 0.9rem;
  --text-md: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;

  /* Font weights */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Line heights */
  --leading-tight: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* Radius scale */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Border widths */
  --border-width: 1px;

  /* Elevation (shadows are also theme-tuned via --shadow-md/-lg) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.12);
  --shadow-focus: var(--focus-ring);

  /* Motion */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;

  /* Z-index scale */
  --z-base: 1;
  --z-sticky: 10;
  --z-detail: 100;
  --z-fab: 900;
  --z-overlay: 1000;
  --z-drawer: 1050;
  --z-modal: 1100;
  --z-toast: 1200;
  --sidebar-w-min: 180px;
  --sidebar-w-max: 420px;
}

/* Skip link (WCAG 2.4.1 Bypass Blocks) */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: var(--z-toast);
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: 8px; outline: 2px solid var(--text); outline-offset: 2px; }

/* Reduced motion (WCAG 2.2.2 / 2.3.3): neutralise decorative animation */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Theme modes ── */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --surface: #181c24;
  --surface2: #1f2530;
  --border: #2e3648;
  --text: #e8ecf4;
  --muted: #94a0b4;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #eab308;
  --on-accent: #fff;
  --hero-gradient-end: #a8c4f0;
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  --overlay: rgba(0, 0, 0, 0.6);
  --surface-overlay: rgba(15, 17, 23, 0.85);
  --filter-bg: rgba(255, 255, 255, 0.03);
  --meta-tag-bg: rgba(255, 255, 255, 0.06);
  --meta-tag-border: rgba(255, 255, 255, 0.1);
  --meta-order-border: rgba(255, 255, 255, 0.04);
  --pill-success-bg: rgba(34, 197, 94, 0.2);
  --pill-warn-bg: rgba(234, 179, 8, 0.2);
  --pill-success-text: var(--success);
  --pill-warn-text: var(--warn);
  --draft-bg: rgba(234, 179, 8, 0.15);
  --draft-border: rgba(234, 179, 8, 0.4);
  --draft-text: #f0d060;
  --error-bg: rgba(239, 68, 68, 0.12);
  --error-border: rgba(239, 68, 68, 0.35);
  --error-text: #fca5a5;
  --success-border: rgba(34, 197, 94, 0.35);
  --toast-success-bg: rgba(34, 197, 94, 0.1);
  --folder-border: rgba(96, 165, 250, 0.35);
  --focus-ring: 0 0 0 3px var(--accent-soft);
  --title-grad-pale: color-mix(in srgb, var(--accent) 46%, white 54%);
  --title-grad-soft: color-mix(in srgb, var(--accent) 70%, white 30%);
  --title-grad-luminous: color-mix(in srgb, var(--accent) 84%, white 16%);
  --title-grad-shadow: color-mix(in srgb, var(--accent-hover) 62%, var(--text) 38%);
  /* Contrast-safe accent for text on surfaces (WCAG 1.4.3). Lightened so even
     dark accents (e.g. wine-red) stay ≥4.5:1 on the dark surface. */
  --accent-readable: color-mix(in srgb, var(--accent) 60%, white);
  /* OpenAPI example/schema blocks — never accent-tinted (readability over brand) */
  --openapi-code-bg: var(--bg);
  --openapi-code-fg: var(--text);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #eef2f7;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #ca8a04;
  --on-accent: #fff;
  --hero-gradient-end: #0284c7;
  --shadow-md: 0 12px 36px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.1);
  --overlay: rgba(15, 23, 42, 0.42);
  --surface-overlay: rgba(255, 255, 255, 0.92);
  --filter-bg: rgba(15, 23, 42, 0.04);
  --meta-tag-bg: rgba(15, 23, 42, 0.05);
  --meta-tag-border: rgba(15, 23, 42, 0.12);
  --meta-order-border: rgba(15, 23, 42, 0.08);
  --pill-success-bg: rgba(22, 163, 74, 0.15);
  --pill-warn-bg: rgba(202, 138, 4, 0.15);
  --pill-success-text: #0a6b30;
  --pill-warn-text: #7a4f00;
  --draft-bg: rgba(202, 138, 4, 0.12);
  --draft-border: rgba(202, 138, 4, 0.35);
  --draft-text: #92400e;
  --error-bg: rgba(220, 38, 38, 0.1);
  --error-border: rgba(220, 38, 38, 0.3);
  --error-text: #b91c1c;
  --success-border: rgba(22, 163, 74, 0.3);
  --toast-success-bg: rgba(22, 163, 74, 0.1);
  --folder-border: rgba(59, 130, 246, 0.35);
  --focus-ring: 0 0 0 3px var(--accent-soft);
  --title-grad-pale: color-mix(in srgb, var(--accent) 36%, var(--text) 64%);
  --title-grad-soft: color-mix(in srgb, var(--accent) 56%, var(--text) 44%);
  --title-grad-luminous: color-mix(in srgb, var(--accent) 72%, white 28%);
  --title-grad-shadow: color-mix(in srgb, var(--accent-hover) 52%, var(--text) 48%);
  /* Darkened so even the brightest accents (cyber-yellow, neon-lime) stay ≥4.5:1
     on light surfaces and mid-grey chips. */
  --accent-readable: color-mix(in srgb, var(--accent) 38%, black);
  --openapi-code-bg: var(--bg);
  --openapi-code-fg: var(--text);
}

[data-theme="high-contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --surface2: #000000;
  --surface-elevated: #000000;
  --surface-hover: #000000;
  --input-bg: #000000;
  --border: #ffffff;
  --text: #ffffff;
  --muted: #ffff00;
  --danger: #ff4444;
  --success: #00ff00;
  --warn: #ffff00;
  --on-accent: #000000;
  --accent-text: #000000;
  --accent-readable: var(--accent);
  --hero-gradient-end: #ffff00;
  --shadow-md: none;
  --shadow-lg: none;
  --overlay: rgba(0, 0, 0, 0.92);
  --surface-overlay: #000000;
  --filter-bg: #000000;
  --meta-tag-bg: #000000;
  --meta-tag-border: #ffffff;
  --meta-order-border: #ffffff;
  --pill-success-bg: #000000;
  --pill-warn-bg: #000000;
  --pill-success-text: #00ff00;
  --pill-warn-text: #ffff00;
  --draft-bg: #000000;
  --draft-border: #ffff00;
  --draft-text: #ffff00;
  --error-bg: #000000;
  --error-border: #ff4444;
  --error-text: #ff6666;
  --success-border: #00ff00;
  --toast-success-bg: #000000;
  --folder-border: #ffffff;
  --warn-bg: #000000;
  --focus-ring: 0 0 0 3px #ffff00;
  --openapi-code-bg: #000000;
  --openapi-code-fg: #ffffff;
}

/* ── Accent presets (Slack-style) ── */
/* Accent soft tints follow selected accent in any mode */
[data-accent="slate"] { --accent: #64748b; --accent-hover: #475569; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="sage"] { --accent: #84a98c; --accent-hover: #6b9080; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="sand"] { --accent: #c4a77d; --accent-hover: #b8956a; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="blush"] { --accent: #d4a5a5; --accent-hover: #c48888; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="mist"] { --accent: #94a3b8; --accent-hover: #7891a8; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="charcoal"] { --accent: #52525b; --accent-hover: #404048; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="lavender-grey"] { --accent: #a9a4b4; --accent-hover: #8f8a9a; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="mint-frost"] { --accent: #9ecabb; --accent-hover: #7db5a5; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="dusty-rose"] { --accent: #c4a0a0; --accent-hover: #ad8585; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="blue"] { --accent: #3b82f6; --accent-hover: #2563eb; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="purple"] { --accent: #7c3aed; --accent-hover: #6d28d9; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="green"] { --accent: #22c55e; --accent-hover: #16a34a; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="teal"] { --accent: #14b8a6; --accent-hover: #0d9488; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="orange"] { --accent: #f97316; --accent-hover: #ea580c; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="pink"] { --accent: #ec4899; --accent-hover: #db2777; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="indigo"] { --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="forest"] { --accent: #15803d; --accent-hover: #166534; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="coral"] { --accent: #f43f5e; --accent-hover: #e11d48; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="amber"] { --accent: #f59e0b; --accent-hover: #d97706; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="crimson"] { --accent: #dc2626; --accent-hover: #b91c1c; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="gold"] { --accent: #eab308; --accent-hover: #ca8a04; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="sky"] { --accent: #0284c7; --accent-hover: #0369a1; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #fff; }
[data-accent="electric"] { --accent: #0ea5e9; --accent-hover: #0284c7; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="royal-purple"] { --accent: #6d28d9; --accent-hover: #5b21b6; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="emerald"] { --accent: #059669; --accent-hover: #047857; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="burnt-orange"] { --accent: #ea580c; --accent-hover: #c2410c; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="wine-red"] { --accent: #9f1239; --accent-hover: #881337; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="neon-lime"] { --accent: #ccff00; --accent-hover: #b8e600; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="hot-magenta"] { --accent: #ff00ff; --accent-hover: #e600e6; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="cyber-yellow"] { --accent: #ffff00; --accent-hover: #e6e600; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="acid-green"] { --accent: #39ff14; --accent-hover: #32e612; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="neon-orange"] { --accent: #ff6600; --accent-hover: #e55c00; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="fuchsia-burst"] { --accent: #ff10f0; --accent-hover: #e600d9; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="laser-red"] { --accent: #d10036; --accent-hover: #b0002e; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="electric-violet"] { --accent: #bf00ff; --accent-hover: #ab00e6; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-accent="toxic-green"] { --accent: #00ff41; --accent-hover: #00e63a; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="plasma-cyan"] { --accent: #00e5ff; --accent-hover: #00cce6; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }
[data-accent="solar-flare"] { --accent: #ffaa00; --accent-hover: #e69900; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); --on-accent: #141b28; }

/* High-contrast — preserve swatch tint for decoration; force readable yellow functional accent */
[data-theme="high-contrast"][data-accent="slate"] { --hc-accent: #64748b; }
[data-theme="high-contrast"][data-accent="sage"] { --hc-accent: #84a98c; }
[data-theme="high-contrast"][data-accent="sand"] { --hc-accent: #c4a77d; }
[data-theme="high-contrast"][data-accent="blush"] { --hc-accent: #d4a5a5; }
[data-theme="high-contrast"][data-accent="mist"] { --hc-accent: #94a3b8; }
[data-theme="high-contrast"][data-accent="charcoal"] { --hc-accent: #52525b; }
[data-theme="high-contrast"][data-accent="lavender-grey"] { --hc-accent: #a9a4b4; }
[data-theme="high-contrast"][data-accent="mint-frost"] { --hc-accent: #9ecabb; }
[data-theme="high-contrast"][data-accent="dusty-rose"] { --hc-accent: #c4a0a0; }
[data-theme="high-contrast"][data-accent="blue"] { --hc-accent: #3b82f6; }
[data-theme="high-contrast"][data-accent="purple"] { --hc-accent: #8b5cf6; }
[data-theme="high-contrast"][data-accent="green"] { --hc-accent: #22c55e; }
[data-theme="high-contrast"][data-accent="teal"] { --hc-accent: #14b8a6; }
[data-theme="high-contrast"][data-accent="orange"] { --hc-accent: #f97316; }
[data-theme="high-contrast"][data-accent="pink"] { --hc-accent: #ec4899; }
[data-theme="high-contrast"][data-accent="indigo"] { --hc-accent: #6366f1; }
[data-theme="high-contrast"][data-accent="forest"] { --hc-accent: #15803d; }
[data-theme="high-contrast"][data-accent="coral"] { --hc-accent: #f43f5e; }
[data-theme="high-contrast"][data-accent="amber"] { --hc-accent: #f59e0b; }
[data-theme="high-contrast"][data-accent="crimson"] { --hc-accent: #dc2626; }
[data-theme="high-contrast"][data-accent="gold"] { --hc-accent: #eab308; }
[data-theme="high-contrast"][data-accent="sky"] { --hc-accent: #38bdf8; }
[data-theme="high-contrast"][data-accent="electric"] { --hc-accent: #0ea5e9; }
[data-theme="high-contrast"][data-accent="royal-purple"] { --hc-accent: #6d28d9; }
[data-theme="high-contrast"][data-accent="emerald"] { --hc-accent: #059669; }
[data-theme="high-contrast"][data-accent="burnt-orange"] { --hc-accent: #ea580c; }
[data-theme="high-contrast"][data-accent="wine-red"] { --hc-accent: #9f1239; }
[data-theme="high-contrast"][data-accent="neon-lime"] { --hc-accent: #ccff00; }
[data-theme="high-contrast"][data-accent="hot-magenta"] { --hc-accent: #ff00ff; }
[data-theme="high-contrast"][data-accent="cyber-yellow"] { --hc-accent: #ffff00; }
[data-theme="high-contrast"][data-accent="acid-green"] { --hc-accent: #39ff14; }
[data-theme="high-contrast"][data-accent="neon-orange"] { --hc-accent: #ff6600; }
[data-theme="high-contrast"][data-accent="fuchsia-burst"] { --hc-accent: #ff10f0; }
[data-theme="high-contrast"][data-accent="laser-red"] { --hc-accent: #ff0040; }
[data-theme="high-contrast"][data-accent="electric-violet"] { --hc-accent: #bf00ff; }
[data-theme="high-contrast"][data-accent="toxic-green"] { --hc-accent: #00ff41; }
[data-theme="high-contrast"][data-accent="plasma-cyan"] { --hc-accent: #00e5ff; }
[data-theme="high-contrast"][data-accent="solar-flare"] { --hc-accent: #ffaa00; }
html[data-theme="high-contrast"][data-accent] {
  --accent: #ffff00;
  --accent-hover: #ffffff;
  --accent-soft: #000000;
  --on-accent: #000000;
  --accent-text: #000000;
}

/* Harmonious title gradient stops — single hue family from active accent */
html[data-accent] {
  --title-grad-core: var(--accent);
  --title-grad-rich: color-mix(in srgb, var(--accent) 52%, var(--accent-hover) 48%);
  --title-grad-deep: var(--accent-hover);
  --title-grad-shimmer: color-mix(in srgb, var(--accent) 82%, white 18%);
  --title-grad-flash: color-mix(in srgb, var(--accent) 52%, white 48%);
}

@keyframes heading-gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes home-title-gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes home-title-glow {
  0%, 100% {
    text-shadow:
      0 0 8px color-mix(in srgb, var(--accent) 32%, transparent),
      0 0 16px color-mix(in srgb, var(--accent) 16%, transparent);
  }
  50% {
    text-shadow:
      0 0 12px color-mix(in srgb, var(--accent) 48%, transparent),
      0 0 20px color-mix(in srgb, var(--accent) 24%, transparent);
  }
}

@keyframes home-title-sparkle-a {
  0%, 11%, 100% { opacity: 0; }
  12.5% { opacity: 1; }
  14% { opacity: 0.18; }
  15.5% { opacity: 0; }
  34% { opacity: 0; }
  35.5% { opacity: 0.85; }
  37% { opacity: 0; }
  62% { opacity: 0; }
  63.5% { opacity: 0.92; }
  65% { opacity: 0.2; }
  66.5% { opacity: 0; }
}

@keyframes home-title-sparkle-b {
  0%, 22%, 100% { opacity: 0; }
  23.5% { opacity: 0.9; }
  25% { opacity: 0; }
  48% { opacity: 0; }
  49.5% { opacity: 1; }
  51% { opacity: 0.2; }
  52.5% { opacity: 0; }
  78% { opacity: 0; }
  79.5% { opacity: 0.8; }
  81% { opacity: 0; }
}

/* Animated gradient on page titles — harmonious accent hue family only */
.view-header h1,
.home-title,
#detailMeta h1 {
  font-family: var(--font-display);
  color: var(--accent);
  background: linear-gradient(
    115deg,
    var(--title-grad-pale) 0%,
    var(--title-grad-soft) 18%,
    var(--title-grad-luminous) 36%,
    var(--title-grad-core) 50%,
    var(--title-grad-rich) 64%,
    var(--title-grad-deep) 80%,
    var(--title-grad-shadow) 100%
  );
  background-size: 260% 100%;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: heading-gradient-shift 5s ease-in-out infinite;
}

.home-title,
.status-brand-title {
  position: relative;
  display: inline-block;
  background: linear-gradient(
    115deg,
    var(--title-grad-pale) 0%,
    var(--title-grad-soft) 12%,
    var(--title-grad-luminous) 24%,
    var(--title-grad-shimmer) 38%,
    var(--title-grad-core) 50%,
    var(--title-grad-flash) 58%,
    var(--title-grad-rich) 68%,
    var(--title-grad-deep) 82%,
    var(--title-grad-pale) 100%
  );
  background-size: 300% 100%;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation:
    home-title-gradient-shift 7.5s ease-in-out infinite,
    home-title-glow 7.5s ease-in-out infinite;
}

.home-title::before,
.home-title::after,
.status-brand-title::before,
.status-brand-title::after {
  content: "";
  position: absolute;
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--title-grad-flash);
  pointer-events: none;
  opacity: 0;
}

.home-title::before,
.status-brand-title::before {
  top: 0.08em;
  left: -0.45em;
  box-shadow:
    0 0 8px 1.5px color-mix(in srgb, var(--title-grad-flash) 88%, transparent),
    0.42em 1.05em 6px 1px color-mix(in srgb, var(--title-grad-shimmer) 78%, transparent);
  animation: home-title-sparkle-a 9s ease-in-out infinite;
}

.home-title::after,
.status-brand-title::after {
  top: 0.18em;
  right: -0.35em;
  width: 3.5px;
  height: 3.5px;
  box-shadow:
    0 0 7px 1.5px color-mix(in srgb, var(--title-grad-shimmer) 85%, transparent),
    -0.9em 0.98em 6px 1px color-mix(in srgb, var(--title-grad-flash) 80%, transparent),
    -1.72em 0.4em 5px 1px color-mix(in srgb, var(--title-grad-luminous) 74%, transparent);
  animation: home-title-sparkle-b 10.5s ease-in-out infinite 1.4s;
}

@media (prefers-reduced-motion: reduce) {
  .view-header h1,
  .home-title,
  #detailMeta h1,
  .status-brand-title {
    animation: none;
    background-size: 100% 100%;
    text-shadow: none;
  }

  .home-title::before,
  .home-title::after,
  .status-brand-title::before,
  .status-brand-title::after {
    content: none;
  }
}

html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

[data-theme="high-contrast"] :focus-visible {
  outline: 3px solid #ffff00;
  outline-offset: 2px;
}

[data-theme="high-contrast"] .card,
[data-theme="high-contrast"] .sidebar,
[data-theme="high-contrast"] .toolbar,
[data-theme="high-contrast"] dialog,
[data-theme="high-contrast"] .btn,
[data-theme="high-contrast"] .tab,
[data-theme="high-contrast"] .home-cap-chip,
[data-theme="high-contrast"] .gov-card,
[data-theme="high-contrast"] .org-tree,
[data-theme="high-contrast"] .context-menu,
[data-theme="high-contrast"] .list-filters,
[data-theme="high-contrast"] .meta-field,
[data-theme="high-contrast"] .admin-row,
[data-theme="high-contrast"] .admin-login-card,
[data-theme="high-contrast"] .nav-item,
[data-theme="high-contrast"] .sidebar-stats,
[data-theme="high-contrast"] .sidebar-appearance,
[data-theme="high-contrast"] input,
[data-theme="high-contrast"] select,
[data-theme="high-contrast"] textarea,
[data-theme="high-contrast"] .archie-panel,
[data-theme="high-contrast"] .archie-fab,
[data-theme="high-contrast"] .archie-msg--assistant,
[data-theme="high-contrast"] .archie-cite,
[data-theme="high-contrast"] .archie-thoughts,
[data-theme="high-contrast"] .archie-pending-card,
[data-theme="high-contrast"] .toast,
[data-theme="high-contrast"] .error-banner,
[data-theme="high-contrast"] .site-notice-banner,
[data-theme="high-contrast"] .form-error,
[data-theme="high-contrast"] .detail-file-meta,
[data-theme="high-contrast"] .meta-tag,
[data-theme="high-contrast"] .pill,
[data-theme="high-contrast"] .import-dropzone,
[data-theme="high-contrast"] .icepanel-wrap,
[data-theme="high-contrast"] .ai-filter-input,
[data-theme="high-contrast"] .ai-log-pre,
[data-theme="high-contrast"] .theme-accent-swatch {
  border-width: 2px;
  border-style: solid;
}

[data-theme="high-contrast"] .view-header h1,
[data-theme="high-contrast"] .home-title,
[data-theme="high-contrast"] #detailMeta h1,
[data-theme="high-contrast"] .status-brand-title {
  background: none;
  -webkit-text-fill-color: #ffffff;
  color: #ffffff;
  animation: none;
  text-shadow: none;
}

[data-theme="high-contrast"] .home-title::before,
[data-theme="high-contrast"] .home-title::after,
[data-theme="high-contrast"] .status-brand-title::before,
[data-theme="high-contrast"] .status-brand-title::after {
  content: none;
}

[data-theme="high-contrast"] .ea-diamond-logo {
  color: var(--hc-accent, #ffff00);
  filter: none;
  animation: none;
}

[data-theme="high-contrast"] .nav-item {
  border-color: transparent;
}
[data-theme="high-contrast"] .nav-item:hover {
  background: #000000;
  color: #ffffff;
  box-shadow: inset 0 0 0 2px #ffffff;
}
[data-theme="high-contrast"] .nav-item.active {
  background: #000000;
  color: #ffff00;
  box-shadow: inset 0 0 0 2px #ffff00;
}
[data-theme="high-contrast"] .nav-admin {
  background: #000000;
  border: 2px solid #ffffff;
}
[data-theme="high-contrast"] .nav-admin.active {
  background: #ffff00;
  color: #000000;
  border-color: #ffff00;
}
[data-theme="high-contrast"] .nav-admin.active:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

[data-theme="high-contrast"] .btn.ghost {
  border: 2px solid #ffffff;
  color: #ffffff;
  background: #000000;
}
[data-theme="high-contrast"] .btn.ghost:hover {
  color: #000000;
  background: #ffffff;
  border-color: #ffffff;
}
[data-theme="high-contrast"] .btn.danger {
  color: #ff4444;
  border-color: #ff4444;
  background: #000000;
}
[data-theme="high-contrast"] .btn.approve {
  color: #00ff00;
  border-color: #00ff00;
  background: #000000;
}

[data-theme="high-contrast"] .card:hover,
[data-theme="high-contrast"] .gov-card:hover,
[data-theme="high-contrast"] .card.selected {
  border-color: var(--hc-accent, #ffff00);
  box-shadow: 0 0 0 2px var(--hc-accent, #ffff00);
  transform: none;
}

[data-theme="high-contrast"] .card .meta,
[data-theme="high-contrast"] .prose p,
[data-theme="high-contrast"] .prose ul,
[data-theme="high-contrast"] .prose ol,
[data-theme="high-contrast"] .view-header p,
[data-theme="high-contrast"] .brand small,
[data-theme="high-contrast"] .brand-sub,
[data-theme="high-contrast"] .brand-kicker {
  color: #ffff00;
}

[data-theme="high-contrast"] .prose th {
  background: #000000;
  color: #ffffff;
  border: 2px solid #ffffff;
}
[data-theme="high-contrast"] .prose td {
  border: 2px solid #ffffff;
  color: #ffffff;
}
[data-theme="high-contrast"] .prose code,
[data-theme="high-contrast"] .markdown code {
  background: #000000;
  border: 1px solid #ffffff;
  color: #ffff00;
}
[data-theme="high-contrast"] .prose a,
[data-theme="high-contrast"] .markdown a {
  color: #ffff00;
  text-decoration: underline;
  text-underline-offset: 2px;
}
[data-theme="high-contrast"] .prose a:hover,
[data-theme="high-contrast"] .markdown a:hover {
  color: #ffffff;
}

[data-theme="high-contrast"] .pill.active {
  color: #00ff00;
  border-color: #00ff00;
}
[data-theme="high-contrast"] .pill.draft {
  color: #ffff00;
  border-color: #ffff00;
}

[data-theme="high-contrast"] .theme-accent-swatch {
  border-color: #ffffff;
}
[data-theme="high-contrast"] .theme-accent-swatch.selected {
  border-color: #ffff00;
  box-shadow: 0 0 0 2px #000000, 0 0 0 4px #ffff00;
}
[data-theme="high-contrast"] .theme-accent-swatch.selected::after {
  color: #000000;
  text-shadow: none;
}
[data-theme="high-contrast"] .theme-accent-swatch.swatch-light.selected::after {
  color: #000000;
  text-shadow: none;
}

[data-theme="high-contrast"] .appearance-modes .theme-mode-btn[data-theme-mode="high-contrast"] {
  font-size: 0.68rem;
  line-height: 1.15;
  white-space: normal;
  padding: 0.35rem 0.3rem;
}

[data-theme="high-contrast"] .archie-panel,
[data-theme="high-contrast"] .archie-header,
[data-theme="high-contrast"] .archie-form,
[data-theme="high-contrast"] .archie-history {
  background: #000000;
}
[data-theme="high-contrast"] .archie-msg--user {
  background: #ffff00;
  color: #000000;
  border: 2px solid #ffff00;
}
[data-theme="high-contrast"] .archie-msg--assistant {
  background: #000000;
  color: #ffffff;
  border-color: #ffffff;
}
[data-theme="high-contrast"] .archie-msg--loading {
  background: #000000;
  border-color: #ffff00;
  box-shadow: none;
}
[data-theme="high-contrast"] .archie-cite {
  color: #ffff00;
  background: #000000;
}
[data-theme="high-contrast"] .archie-cite-id {
  opacity: 1;
  color: #ffffff;
}
[data-theme="high-contrast"] .archie-msg-body a.archie-inline-cite,
[data-theme="high-contrast"] .archie-msg-body a.archie-external-link {
  color: #ffff00;
}
[data-theme="high-contrast"] .archie-msg-body code {
  background: #000000;
  border: 1px solid #ffffff;
  color: #ffff00;
}
[data-theme="high-contrast"] .archie-thoughts {
  background: #000000;
  border-color: #ffffff;
}
[data-theme="high-contrast"] .archie-pending-card {
  background: #000000;
  border-color: #ffff00;
  color: #ffffff;
}
[data-theme="high-contrast"] .archie-status--warn {
  background: #000000;
  color: #ffff00;
  border-color: #ffff00;
}
[data-theme="high-contrast"] .archie-form textarea:focus {
  outline: 3px solid #ffff00;
  outline-offset: 2px;
}
[data-theme="high-contrast"] .archie-history-item.is-active {
  background: #000000;
  border-color: #ffff00;
  box-shadow: inset 0 0 0 2px #ffff00;
}
[data-theme="high-contrast"] .archie-history-item:hover {
  background: #000000;
  border-color: #ffffff;
}
[data-theme="high-contrast"] .archie-typing-shimmer {
  -webkit-text-fill-color: #ffff00;
  background: none;
  animation: none;
}
[data-theme="high-contrast"] .archie-fab {
  background: #000000;
  border-color: #ffffff;
  color: var(--hc-accent, #ffff00);
  box-shadow: none;
}

[data-theme="high-contrast"] .admin-login-card {
  box-shadow: none;
}
[data-theme="high-contrast"] .admin-login-lead,
[data-theme="high-contrast"] .admin-login-hint,
[data-theme="high-contrast"] .admin-login-footnote {
  color: #ffff00;
}
[data-theme="high-contrast"] .admin-lock-badge {
  background: #000000;
  box-shadow: none;
}

[data-theme="high-contrast"] .error-banner,
[data-theme="high-contrast"] .site-notice-banner,
[data-theme="high-contrast"] .form-error,
[data-theme="high-contrast"] .toast.error {
  background: #000000;
  color: #ff6666;
}
[data-theme="high-contrast"] .toast.success {
  background: #000000;
  color: #00ff00;
}

[data-theme="high-contrast"] .approval-card {
  border: 2px solid #ffffff;
  padding: 0.65rem;
  background: #000000;
}

@media (prefers-contrast: more) {
  :root:not([data-theme="high-contrast"]) {
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 65%, #ffff00 35%);
  }
  :root:not([data-theme="high-contrast"]) .btn,
  :root:not([data-theme="high-contrast"]) .tab,
  :root:not([data-theme="high-contrast"]) input,
  :root:not([data-theme="high-contrast"]) select,
  :root:not([data-theme="high-contrast"]) textarea {
    border-width: 2px;
  }
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

/* Viewport-locked shell: sidebar stays in view; only .main/.view scrolls on long pages.
   minmax(0, 1fr) is required so wide toolbar/detail content cannot expand the grid
   past the viewport (plain 1fr ≡ minmax(auto, 1fr) and clips under overflow:hidden). */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  align-self: stretch;
  height: 100%;
  max-height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  min-width: 0;
}
.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 0.75rem;
  /* Persistent, accent-coloured scrollbar so it's clear the nav scrolls */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.sidebar-body::-webkit-scrollbar { width: 10px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
  border: 2px solid var(--surface);
  background-clip: padding-box;
  min-height: 32px;
}
.sidebar-body::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }
.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Header brand standard: diamond + "EA Studio" + product-line subtitle.
   Used by Studio sidebar, Control Plane topbar, and mirrored on public surfaces. */
.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0 0.5rem;
  cursor: pointer;
  font-family: var(--font-display);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.brand-title {
  display: block;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}
.brand-sub,
.brand-kicker,
.brand small {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.2;
}

/* EA diamond logo — nav + home hero */
.ea-diamond-logo {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--accent);
  animation: ea-diamond-pulse 2.6s ease-in-out infinite;
}
.ea-diamond-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}
.ea-diamond-logo--sm {
  width: 1.65rem;
  height: 1.65rem;
}
.ea-diamond-logo--lg {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 0.85rem;
}
.ea-diamond-outer {
  opacity: 0.95;
}
.ea-diamond-inner {
  opacity: 0.88;
}

@keyframes ea-diamond-pulse {
  0%, 100% {
    transform: scale(1);
    filter:
      drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 55%, transparent))
      drop-shadow(0 0 12px color-mix(in srgb, var(--accent) 30%, transparent));
  }
  50% {
    transform: scale(1.08);
    filter:
      drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 75%, transparent))
      drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 45%, transparent))
      drop-shadow(0 0 36px color-mix(in srgb, var(--accent) 22%, transparent));
  }
}

@keyframes ea-diamond-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: no-preference) {
  .ea-diamond-logo:hover svg {
    animation: ea-diamond-spin 0.5s ease-in-out 1;
    transform-origin: center center;
  }
}

/* Logo easter egg (10 clicks in 10s): spin → flash → sparkle burst → reset */
.logo-egg {
  cursor: pointer;
  position: relative;
  transform-origin: center center;
}
@keyframes egg-spin {
  0% { transform: rotate(0) scale(1); }
  70% { transform: rotate(1080deg) scale(1.18); }
  100% { transform: rotate(1440deg) scale(1); }
}
.ea-diamond-logo.egg-spin {
  animation: egg-spin 1.2s cubic-bezier(0.45, 0.05, 0.3, 1) both;
}
@keyframes egg-flash {
  0% { transform: scale(1); filter: brightness(1); }
  25% { transform: scale(1.3); filter: brightness(3.2) drop-shadow(0 0 18px var(--accent)); }
  55% { transform: scale(0.92); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}
.ea-diamond-logo.egg-flash {
  animation: egg-flash 0.6s ease-out both;
}
.egg-sparkles {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 5;
}
.egg-sparkle {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  margin: -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px 2px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: egg-sparkle-fly 0.9s ease-out forwards;
}
.egg-sparkle:nth-child(3n) {
  background: color-mix(in srgb, var(--accent) 72%, white 28%);
  box-shadow: 0 0 7px 2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.egg-sparkle:nth-child(3n + 1) {
  background: color-mix(in srgb, var(--accent) 35%, white 65%);
  box-shadow: 0 0 7px 2px color-mix(in srgb, var(--accent) 40%, transparent);
}
@keyframes egg-sparkle-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ea-diamond-logo.egg-spin { animation: egg-flash 0.25s ease-out both; }
  .egg-sparkle { animation-duration: 0.4s; }
}

/* Branded loading indicator — gentle continuous spin (not the easter-egg celebration) */
.ea-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: var(--muted);
}
.ea-loader__diamond {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--accent);
  transform-origin: center center;
}
.ea-loader__diamond svg {
  display: block;
  width: 100%;
  height: 100%;
}
.ea-loader__diamond--xs { width: 1rem; height: 1rem; }
.ea-loader__diamond--sm { width: 1.35rem; height: 1.35rem; }
.ea-loader__diamond--lg { width: 2.75rem; height: 2.75rem; }
.ea-loader__label {
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--muted);
}
@media (prefers-reduced-motion: no-preference) {
  .ea-loader__diamond {
    animation: ea-loader-spin 1s linear infinite;
  }
}
@keyframes ea-loader-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.ea-loader--block {
  display: flex;
  width: 100%;
  padding: 1.25rem 0.5rem;
}
.ea-page-loader {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(2px);
  pointer-events: all;
}
.ea-page-loader.hidden {
  display: none;
}
.ea-page-loader .ea-loader {
  flex-direction: column;
  gap: 0.85rem;
}
.ea-page-loader .ea-loader__label {
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}
@media (prefers-reduced-motion: reduce) {
  .ea-loader__diamond {
    animation: none;
  }
  .ea-page-loader {
    backdrop-filter: none;
  }
}

/* Subtle cursor-following sparkle trail (app-wide) */
.cursor-sparkle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2147483000;
}
.cursor-sparkle {
  position: fixed;
  border-radius: 1px;
  background: var(--accent);
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 75%, transparent));
  opacity: 0.85;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: cursor-sparkle-fade 0.95s ease-out forwards;
  will-change: transform, opacity;
}
.cursor-sparkle--accent {
  background: color-mix(in srgb, var(--accent) 78%, white 22%);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 70%, transparent));
}
@keyframes cursor-sparkle-fade {
  0% { opacity: 0.9; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, calc(-50% + var(--dy, 10px))) scale(0.2) rotate(var(--rot, 0deg)); }
}
@media (prefers-reduced-motion: reduce) {
  .cursor-sparkle-layer { display: none; }
}

/* User setting: turn off all animation (Appearance → Motion) */
html.no-animations *,
html.no-animations *::before,
html.no-animations *::after {
  animation-duration: 0.001ms !important;
  animation-delay: 0ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  transition-delay: 0ms !important;
  scroll-behavior: auto !important;
}
html.no-animations .cursor-sparkle-layer { display: none; }

/* Appearance panel: animations toggle */
.appearance-anim-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}
.appearance-anim-row input { accent-color: var(--accent); cursor: pointer; }
.appearance-anim-hint { margin: 0.3rem 0 0; font-size: 0.72rem; color: var(--muted); line-height: 1.4; }

@media (prefers-reduced-motion: reduce) {
  .ea-diamond-logo {
    animation: none;
    filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 35%, transparent));
  }
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
}
.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.3;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

.nav-admin {
  margin-top: 0.45rem;
  position: relative;
  background: var(--surface2);
  color: var(--text);
}
.nav-admin::before {
  content: "";
  position: absolute;
  top: -0.3rem;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.nav-admin:hover {
  background: var(--bg);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
}
.nav-admin.active {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.nav-admin.active:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}
/* Invert the badge on the accent-filled active item so it doesn't blend in */
.nav-admin.active .nav-badge {
  background: var(--on-accent);
  color: var(--accent);
}

.sidebar-stats {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.75rem;
  background: var(--surface2);
  border-radius: var(--radius);
  line-height: 1.6;
}
.sidebar-auth {
  padding: 0 0 0.5rem;
}
.sidebar-signin .btn-block,
.sidebar-user .btn-block {
  width: 100%;
}
.login-modal-body label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}
.login-modal-body input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.login-modal-body input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#loginModal {
  width: min(400px, 92vw);
}
#loginModal .modal-footer {
  justify-content: stretch;
}
#loginModal .modal-footer .btn.primary {
  width: 100%;
}
.sidebar-user-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface2);
  border-radius: var(--radius);
}
.sidebar-user-details {
  margin: 0;
  padding: 0.55rem 0.65rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.sidebar-user-details[open] {
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
}
.sidebar-user-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.sidebar-user-summary::-webkit-details-marker { display: none; }
.sidebar-user-summary::marker { content: ""; display: none; }
.sidebar-user-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sidebar-user-summary .sidebar-user-identity {
  flex: 1;
  min-width: 0;
}
.sidebar-user-summary .appearance-toggle {
  flex-shrink: 0;
}
.sidebar-user-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}
.sidebar-user-details:not([open]) .sidebar-user-role--summary {
  display: none;
}
.sidebar-user-identity {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 0;
}
.sidebar-user-avatar {
  position: relative;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent-readable);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}
.sidebar-user-avatar--photo {
  background: var(--surface2);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  color: transparent;
}
.sidebar-user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
.sidebar-user-avatar::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--success);
  border: 1.5px solid var(--surface2);
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.sidebar-user-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 0.72rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.users-list { display: grid; gap: 0.75rem; }
.user-perm-sections {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem 0.75rem;
  margin: 0.5rem 0 0.75rem;
  min-width: 0;
}
.user-perm-sections .checkbox-row {
  min-width: 0;
  overflow-wrap: anywhere;
}
.user-perm-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  min-width: 0;
}
.user-perm-row > span {
  min-width: 0;
  flex: 0 1 7rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
@media (max-width: 640px) {
  .user-perm-sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 420px) {
  .user-perm-sections {
    grid-template-columns: minmax(0, 1fr);
  }
}
.checkbox-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.checkbox-row input { margin: 0; }

.sidebar-actor {
  padding: 0.75rem;
  background: var(--surface2);
  border-radius: var(--radius);
}
.sidebar-actor label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.sidebar-actor input {
  width: 100%;
  padding: 0.45rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font: inherit;
}
.sidebar-actor small { display: block; margin-top: 0.35rem; font-size: 0.72rem; color: var(--muted); line-height: 1.35; }
.sidebar-actor .req { color: var(--warn); }
.actor-line { margin-top: 0.2rem; font-style: italic; }

.sidebar-appearance {
  padding: 0;
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
}
.appearance-summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.appearance-summary::-webkit-details-marker { display: none; }
.appearance-summary::marker { content: ""; display: none; }
.appearance-summary:focus-visible {
  outline: none;
  box-shadow: inset var(--focus-ring);
  border-radius: var(--radius);
}
.appearance-heading {
  display: inline;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.appearance-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 3px;
  transition: background 0.15s ease, color 0.15s ease;
}
.appearance-toggle::before {
  content: "+";
  transform: translateY(-0.5px);
}
.sidebar-appearance[open] .appearance-toggle::before,
.adm-diagram-details[open] .appearance-toggle::before,
.home-engagement-details[open] .appearance-toggle::before,
.detail-refs-disclosure[open] .appearance-toggle::before,
.detail-refs-details[open] .appearance-toggle::before {
  content: "−";
}
.appearance-summary:hover .appearance-toggle {
  background: var(--accent-hover);
}
.appearance-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}
.sidebar-appearance[open] .appearance-body {
  grid-template-rows: 1fr;
}
.appearance-body-inner {
  overflow: hidden;
  padding: 0 0.75rem 0.75rem;
}
.sidebar-appearance[open] .appearance-body-inner {
  padding-top: 0.1rem;
}
.appearance-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.5rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.appearance-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0;
}
.appearance-modes .tab {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  text-align: center;
}
.theme-accent-groups {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.appearance-accent-group {
  display: block;
  font-size: 0.62rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.1rem;
}
.appearance-accent-group:first-child { margin-top: 0; }
.theme-accent-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.3rem;
}
.theme-accent-swatch {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--swatch-color);
  cursor: pointer;
  padding: 0;
  position: relative;
  justify-self: center;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.theme-accent-swatch:hover { transform: scale(1.06); border-color: var(--muted); }
.theme-accent-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--surface2);
}
.theme-accent-swatch.selected::after {
  content: "✓";
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.85);
}
.theme-accent-swatch.swatch-light.selected::after {
  color: #141b28;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.85);
}
.theme-accent-swatch:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-width: 0;
}
.toolbar input {
  flex: 1 1 10rem;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  font: inherit;
}

.view {
  display: none;
  padding: 1.25rem;
  overflow: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}
.view.active { display: block; }

/* Home */
#view-home.view.active {
  position: relative;
}
.home-hero {
  position: relative;
  text-align: center;
  max-width: 760px;
  margin: 0 auto 2rem;
  padding: var(--space-7) var(--space-4) var(--space-5);
  min-width: 0;
}
.home-hero-glow {
  pointer-events: none;
  position: absolute;
  inset: -20% -10% 20%;
  background:
    radial-gradient(ellipse 70% 55% at 50% 18%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 62%),
    radial-gradient(ellipse 50% 40% at 12% 70%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 55%),
    radial-gradient(ellipse 45% 35% at 88% 60%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 50%);
  animation: home-hero-glow-breathe 10s ease-in-out infinite;
}
.home-hero-inner {
  position: relative;
  z-index: var(--z-base);
  animation: home-hero-in 0.65s ease both;
}
.home-eyebrow {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-readable);
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
  padding-inline: 0.25rem;
}
.home-title {
  margin: 0 0 var(--space-3);
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.home-lead {
  margin: 0 auto var(--space-5);
  max-width: 38rem;
  color: var(--muted);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
}
.home-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 560px;
  margin: 0 auto var(--space-4);
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}
.home-search-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.home-search-icon { color: var(--muted); font-size: 1.1rem; }
.home-search {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-md);
  padding: var(--space-2) 0;
  min-width: 0;
}
.home-search:focus { outline: none; }
.home-stats {
  position: relative;
  z-index: var(--z-base);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  max-width: 100%;
  min-width: 0;
}
.home-stat {
  font-size: var(--text-sm);
  padding: 0.35rem 0.65rem;
  background: color-mix(in srgb, var(--surface2) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--muted);
  backdrop-filter: blur(6px);
  max-width: 100%;
}
.home-stat strong { color: var(--text); }
.home-section-title { font-size: var(--text-lg); margin: 0 0 var(--space-4); font-weight: var(--weight-semibold); }
.home-results-section { max-width: 1100px; margin: 0 auto 2rem; padding: 0 var(--space-4); }
.home-adm-dashboard {
  position: relative;
  z-index: var(--z-base);
  max-width: 52rem;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto 2rem;
  padding: 0 var(--space-5);
  text-align: left;
}
.home-guide {
  max-width: 52rem;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto 2rem;
  padding: 0 var(--space-5) var(--space-2);
  text-align: left;
  animation: home-guide-in 0.6s ease 0.12s both;
}
@keyframes home-hero-in {
  from { opacity: 0; transform: translateY(0.75rem); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes home-hero-glow-breathe {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}
@keyframes home-guide-in {
  from { opacity: 0; transform: translateY(0.6rem); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes home-cap-in {
  from { opacity: 0; transform: translateY(0.45rem); }
  to { opacity: 1; transform: translateY(0); }
}
.home-guide-header {
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}
.home-guide-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}
.home-guide-lead {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}
.home-guide-lead strong { color: var(--text); font-weight: var(--weight-semibold); }
.home-guide-subtitle {
  margin: 0 0 var(--space-4);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  color: var(--text);
}
.home-cap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0;
}
.home-cap-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  animation: home-cap-in 0.45s ease both;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.home-cap-card:nth-child(1) { animation-delay: 0.14s; }
.home-cap-card:nth-child(2) { animation-delay: 0.2s; }
.home-cap-card:nth-child(3) { animation-delay: 0.26s; }
.home-cap-card:nth-child(4) { animation-delay: 0.32s; }
.home-cap-card:nth-child(5) { animation-delay: 0.38s; }
.home-cap-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.home-cap-card--browse {
  grid-column: 1 / -1;
}
.home-cap-top {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  column-gap: 0.85rem;
  align-items: start;
}
.home-cap-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent-readable);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.home-cap-icon svg {
  display: block;
  width: 22px;
  height: 22px;
}
.home-cap-copy { min-width: 0; }
.home-cap-title {
  margin: 0 0 0.25rem;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
}
.home-cap-body {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.home-cap-body strong { color: var(--text); font-weight: var(--weight-semibold); }
.home-cap-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text);
}
.home-cap-dests,
.adm-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-start;
}
.adm-phase-detail .adm-chip-row {
  margin: 0 0 0.35rem;
}
.adm-phase-detail .meta {
  margin: 0.65rem 0 0.35rem;
}
.home-cap-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 2rem;
  font: inherit;
  font-size: var(--text-sm, 0.85rem);
  font-weight: var(--weight-medium, 500);
  line-height: 1.2;
  color: var(--text);
  background: color-mix(in srgb, var(--surface2) 80%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s;
  text-align: center;
  text-transform: none;
}
.home-cap-chip:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 75%, var(--surface));
  color: var(--accent-readable);
  transform: translateY(-1px);
}
.home-cap-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.home-cap-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: auto;
}
.home-cap-card > .home-cap-action {
  margin-top: auto;
  align-self: flex-start;
}
.app-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
  padding: 0.65rem 1.25rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.app-footer-credit {
  margin: 0;
  font-style: italic;
  min-width: 0;
  flex: 1 1 16rem;
}
.app-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  align-items: center;
}
.app-footer-nav a {
  color: var(--accent-readable);
  text-decoration: none;
  font-weight: var(--weight-medium, 500);
  font-style: normal;
}
.app-footer-nav a:hover {
  text-decoration: underline;
}
.app-footer-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
[data-theme="high-contrast"] .home-guide-header {
  background: transparent;
  border-left-width: 4px;
}
[data-theme="high-contrast"] .home-cap-icon {
  background: var(--accent);
  color: var(--on-accent);
}
[data-theme="high-contrast"] .home-cap-card,
[data-theme="high-contrast"] .home-cap-chip {
  box-shadow: none;
}
[data-theme="high-contrast"] .home-hero-glow,
[data-theme="high-contrast"] .home-stat {
  backdrop-filter: none;
}
[data-theme="high-contrast"] .home-hero-glow {
  opacity: 0.35;
  animation: none;
}
.no-animations .home-guide,
.no-animations .home-hero-inner,
.no-animations .home-cap-card,
.no-animations .home-hero-glow {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .home-guide,
  .home-hero-inner,
  .home-cap-card,
  .home-hero-glow {
    animation: none;
  }
}
@media (max-width: 700px) {
  .home-cap-grid {
    grid-template-columns: 1fr;
  }
  .home-cap-card--browse {
    grid-column: auto;
  }
}
.prose h1, .prose h2, .prose h3 { margin: 1.25rem 0 0.5rem; line-height: 1.3; }
.prose h1 { font-size: 1.35rem; }
.prose h2 { font-size: 1.15rem; border-bottom: 1px solid var(--border); padding-bottom: 0.35rem; }
.prose h3 { font-size: 1rem; }
.prose p { margin: 0.5rem 0; color: var(--muted); }
.prose a { color: var(--accent-readable); }
.prose code {
  background: var(--surface2);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.prose pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow: auto;
  font-size: 0.8rem;
}
.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 0.85rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.45rem 0.65rem; text-align: left; }
.prose th { background: var(--surface2); color: var(--text); }
.prose ul, .prose ol { margin: 0.5rem 0; padding-left: 1.25rem; color: var(--muted); }
.prose li { margin: 0.25rem 0; }

.view-header { margin-bottom: 1.25rem; }
.view-header h1 { margin: 0 0 0.35rem; font-size: 1.5rem; font-weight: 600; }
.view-header p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.view-header.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.section-intro {
  margin: 0 0 1rem;
  padding: 0.75rem 0.95rem;
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: 78ch;
}
.section-intro strong { color: var(--text); }
.section-intro .intro-why {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
}
.jargon,
abbr.jargon {
  text-decoration: underline dotted;
  text-underline-offset: 0.15em;
  cursor: help;
  color: var(--text);
  font-style: normal;
}
.jargon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Solution architecture document (Admin → Solution architecture) */
.arch-doc { max-width: 90ch; }
.arch-doc > blockquote {
  margin: 0.75rem 0;
  padding: 0.5rem 0.9rem;
  border-left: 3px solid var(--accent);
  background: var(--surface2);
  border-radius: 6px;
  color: var(--muted);
}
.arch-doc blockquote p { margin: 0.25rem 0; }
.arch-doc pre {
  /* Keep ASCII diagrams aligned and scrollable on narrow screens */
  line-height: 1.35;
  white-space: pre;
  max-width: 100%;
}
.arch-doc table { display: block; overflow-x: auto; }
.arch-doc h2 { margin-top: 2rem; }

/* Admin — centered sign-in gate */
#view-admin.view.active.admin-guest {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
#view-admin.view.active.admin-authed { display: block; }

.admin-login-gate {
  width: 100%;
  max-width: 420px;
  margin: auto;
}
.admin-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-md);
  padding: 2rem 2rem 1.75rem;
  text-align: center;
}
.admin-login-icon {
  position: relative;
  display: inline-flex;
  margin-bottom: 1.25rem;
}
.ea-diamond-logo--admin {
  width: 3rem;
  height: 3rem;
}
.admin-lock-badge {
  position: absolute;
  right: -0.35rem;
  bottom: -0.35rem;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0.2rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent-readable);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.admin-login-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}
.admin-login-lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.admin-login-form {
  text-align: left;
}
.admin-login-hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.45;
}
.admin-login-field {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.admin-login-field input {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.admin-login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.admin-login-footnote {
  margin: 0 0 1.25rem;
  font-size: 0.8rem;
  line-height: 1.45;
}
.admin-login-submit {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.admin-signed-header {
  align-items: center;
}
.admin-signed-header h1 { margin-bottom: 0.15rem; }

@media (max-width: 480px) {
  .admin-login-card {
    padding: 1.5rem 1.25rem 1.35rem;
  }
  .admin-login-title { font-size: 1.35rem; }
}

.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.admin-tabs {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-bottom: 1.25rem;
}
.admin-tab-group {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  column-gap: 0.85rem;
  row-gap: 0.4rem;
  align-items: start;
  padding: 0.65rem 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
.admin-tab-group:first-child {
  border-top: none;
  padding-top: 0;
}
.admin-tab-group-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0 0;
  line-height: 1.2;
}
.admin-tab-group-tabs {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.admin-tab-group + .admin-tab-group {
  padding-left: 0;
  margin-left: 0;
  border-left: none;
}
@media (max-width: 640px) {
  .admin-tab-group {
    grid-template-columns: 1fr;
    row-gap: 0.35rem;
  }
  .admin-tab-group-label {
    padding-top: 0;
  }
  .admin-tab-group-tabs {
    grid-column: 1;
  }
}
.tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 2rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: var(--weight-medium, 500);
  line-height: 1.2;
  text-align: center;
  text-transform: none;
  gap: 0.3rem;
}
.tab:hover { background: var(--surface); color: var(--text); border-color: var(--muted); }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tab.active:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

.icepanel-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: calc(100vh - 200px);
  min-height: 480px;
}
.icepanel-wrap iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.landscape-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.landscape-diagram-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.icepanel-open {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--surface-overlay);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  text-decoration: none;
  border: 1px solid var(--border);
  z-index: 1;
}
.icepanel-status {
  margin: 0.75rem 0 0;
  line-height: 1.45;
  max-width: 52rem;
}
.icepanel-status.icepanel-status--error {
  color: var(--danger);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card h3 { margin: 0 0 0.35rem; font-size: 0.95rem; line-height: 1.35; }
.card-open-btn {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.card-open-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.card-snippet {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .meta { font-size: 0.75rem; color: var(--muted); }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 1.35rem;
  font-size: 0.72rem;
  font-weight: var(--weight-medium, 500);
  line-height: 1.2;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-md, 8px);
  background: var(--surface2);
  border: 1px solid transparent;
  margin-right: 0.35rem;
  margin-top: 0.5rem;
  text-transform: none;
}
.pill.active { background: var(--pill-success-bg); color: var(--pill-success-text, var(--success)); }
.pill.draft { background: var(--pill-warn-bg); color: var(--pill-warn-text, var(--warn)); }

.detail-full {
  padding: 0 1.5rem 2rem;
  max-width: 960px;
  margin: 0 auto;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.detail-full.active { display: block; }
.editor-full { padding: 0 1.5rem 2.5rem; max-width: 1100px; margin: 0 auto; min-width: 0; width: 100%; box-sizing: border-box; }
.editor-full.active { display: block; }
.editor-page-header { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 0.75rem 1rem; }
.editor-page-title { margin: 0; font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; word-break: break-word; text-align: center; }
.editor-page-actions { justify-content: flex-end; }
.editor-page-body { padding: 0 0 1rem; min-width: 0; }
.editor-full .rich-md-editor, .editor-full .vditor { min-height: min(62vh, 640px); }
@media (max-width: 720px) {
  .editor-page-header { grid-template-columns: 1fr; }
  .editor-page-title { text-align: left; }
  .editor-page-actions { justify-content: flex-start; }
}
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  min-width: 0;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}
.detail-article {
  min-width: 0;
  max-width: 100%;
}
#detailMeta {
  min-width: 0;
  max-width: 100%;
}
.detail-article h1,
#detailMeta h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  line-height: 1.3;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.detail-pills { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.detail-body { font-size: 1rem; line-height: 1.65; }
.detail-path { font-size: 0.75rem; color: var(--muted); margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.hidden { display: none !important; }
.toolbar.hidden { display: none; }
.empty {
  color: var(--muted);
  padding: 2rem 1.5rem;
  text-align: center;
  width: 100%;
  max-width: 40rem;
  margin-inline: auto;
  line-height: 1.55;
  box-sizing: border-box;
}
.card-grid > .empty {
  grid-column: 1 / -1;
  justify-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 45vh;
}
.row { display: flex; align-items: center; gap: 0.5rem; }
.btn-row { display: flex; gap: 0.5rem; }
.btn-sm {
  min-height: 2rem;
  padding: 0.4rem 0.75rem;
  font-size: var(--text-sm, 0.85rem);
  border-radius: var(--radius-md, 8px);
}
.danger-text { color: var(--danger); }
.tag-row { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.tab-count { opacity: 0.7; font-size: 0.75em; }

.gov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.gov-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
  display: block;
}
.gov-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.gov-card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.gov-card p { margin: 0 0 1rem; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.gov-link { color: var(--accent-readable); font-size: 0.85rem; font-weight: 600; }

.cap-panel { margin-top: 0.5rem; }
.org-toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.org-tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.org-node { margin-bottom: 0.5rem; }
.org-node-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
  background: var(--surface2);
  border-radius: 8px;
}
.org-name, .org-role {
  flex: 1;
  min-width: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font: inherit;
}
.org-children { margin-left: 1.25rem; margin-top: 0.5rem; border-left: 2px solid var(--border); padding-left: 0.75rem; }

.person-card h3 { margin-bottom: 0.25rem; }

.card-folder { border-color: var(--folder-border); }
.card-folder:hover { border-color: var(--accent); }
.card-folder-row { display: flex; align-items: flex-start; gap: 0.5rem; }
.card-folder-row h3 { flex: 1; margin: 0 0 0.35rem; font-size: 0.95rem; line-height: 1.35; }
.folder-icon { font-size: 1.25rem; line-height: 1.2; flex-shrink: 0; }
.card-folder-info { margin-left: auto; flex-shrink: 0; padding: 0.15rem 0.45rem; }
.solutions-breadcrumb {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.15rem;
  margin: 0 0 0.65rem;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  overflow-x: auto;
  color: var(--muted);
  border: 1px dashed transparent;
  border-radius: 4px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.solutions-breadcrumb .breadcrumb-item {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.15rem;
}
.solutions-breadcrumb .breadcrumb-link {
  display: inline;
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 3px;
  transition: color 0.15s ease;
}
.solutions-breadcrumb .breadcrumb-link:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.solutions-breadcrumb .breadcrumb-sep {
  display: inline;
  color: var(--muted);
  opacity: 0.5;
  user-select: none;
  font-size: 0.85em;
  line-height: 1;
  pointer-events: none;
}
.solutions-breadcrumb .breadcrumb-current {
  display: inline;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}
.filter-check { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.filter-check input { margin: 0; }
.card-dragging { opacity: 0.45; }
.card-folder.drop-target-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
#solutionsBreadcrumb.drop-target-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.context-menu {
  position: fixed;
  z-index: 2000;
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem;
  box-shadow: var(--shadow-lg);
}
.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.context-menu button:hover { background: var(--surface2); }
.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-end;
  margin: 0.75rem 0 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--filter-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.list-filters label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.list-filters .filter-search { flex: 1 1 200px; min-width: 180px; }
.list-filters select,
.list-filters input[type="date"],
.list-filters input[type="search"] {
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  color: inherit;
  min-width: 110px;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.field-id.hidden { display: none; }

.meta-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0 0.25rem; align-items: center; }
.meta-tags.inline { display: inline-flex; margin: 0 0 0 0.35rem; }
.meta-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 1.35rem;
  font-size: 0.72rem;
  font-weight: var(--weight-medium, 500);
  line-height: 1.2;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-md, 8px);
  background: var(--meta-tag-bg);
  border: 1px solid var(--meta-tag-border);
  color: var(--muted);
  letter-spacing: 0.01em;
  text-transform: none;
}
.meta-tag-ref { font-family: ui-monospace, monospace; font-size: 0.68rem; }
.meta.mono { font-family: ui-monospace, monospace; font-size: 0.78rem; color: var(--muted); }

.card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.65rem; }

.btn-link {
  display: inline-block;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}
.detail-link-row { margin: 0.75rem 0 1rem; }

.draft-banner {
  background: var(--draft-bg);
  border: 1px solid var(--draft-border);
  color: var(--draft-text);
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.lock-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--draft-bg);
  border: 1px solid var(--draft-border);
  color: var(--draft-text);
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.lock-banner-text { flex: 1 1 auto; }
.lock-banner .btn { flex: 0 0 auto; }
.ds-lock-demo { margin-bottom: 0.75rem; }
.draft-note { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.5rem; }
.field-hint { color: var(--muted); font-size: 0.75rem; line-height: 1.4; font-weight: 400; opacity: 0.9; }

.auth-settings-form {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-fieldset {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-fieldset legend {
  padding: 0 0.35rem;
  font-weight: 600;
}
.auth-fieldset label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}
.auth-fieldset input[type="text"],
.auth-fieldset input[type="password"],
.auth-fieldset input:not([type]),
.auth-fieldset textarea {
  width: 100%;
}
/* Let flex rows share space instead of forcing stacked full-width inputs */
.auth-fieldset .row > input[type="text"],
.auth-fieldset .row > input[type="password"],
.auth-fieldset .row > input:not([type]) {
  width: auto;
  min-width: 0;
}
.radio-row,
.auth-fieldset .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.auth-settings-actions {
  gap: 0.75rem;
  flex-wrap: wrap;
}
.admin-pat-secret-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
}
.admin-pat-secret-label .password-field input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.admin-pat-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.admin-pat-revoked {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.admin-pat-revoked-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.admin-pat-revoked-summary::-webkit-details-marker { display: none; }
.admin-pat-revoked-summary::marker { content: ""; display: none; }
.admin-pat-revoked-body {
  padding: 0 0.85rem 0.35rem;
  border-top: 1px solid var(--border);
}
.admin-pat-revoked-body .admin-pat-row:last-child {
  border-bottom: none;
}

.metadata-editor { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1rem; }
.meta-editor-intro { margin-bottom: 0.25rem; }
.meta-field {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.meta-field-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.meta-field-head h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.meta-order-list { list-style: none; margin: 0; padding: 0; }
.meta-order-header,
.meta-order-item {
  display: grid;
  grid-template-columns: 2rem 1fr 1.2fr auto auto auto;
  gap: 0.5rem;
  align-items: center;
}
.meta-order-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0 0 0.35rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
}
.meta-order-item {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--meta-order-border);
}
.meta-order-item.meta-dragging { opacity: 0.45; }
.meta-drag {
  cursor: grab;
  color: var(--muted);
  text-align: center;
  user-select: none;
  font-size: 0.85rem;
}
.meta-order-item input {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  min-width: 0;
}
.meta-order-item .meta-slug { font-family: ui-monospace, monospace; font-size: 0.8rem; }
.meta-empty { padding: 0.5rem 0; list-style: none; }

.metadata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.metadata-grid textarea { min-height: 100px; width: 100%; font: inherit; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 0.5rem; }

.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}
.admin-sys-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}
.admin-sys-status {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  background: var(--surface2, var(--surface));
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.admin-sys-edit {
  font: inherit;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  background: var(--surface2, var(--surface));
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 6px;
  min-width: 200px;
}
.manage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.manage-toolbar > .checkbox-row { flex-basis: 100%; margin-bottom: 0.35rem; }
.manage-search { width: 100%; margin-bottom: 1rem; padding: 0.55rem 0.75rem; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; font: inherit; }

.analytics-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.analytics-range-btns { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.analytics-range.active { border-color: var(--accent); color: var(--accent-readable); }
.analytics-custom-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.analytics-custom-range .ai-filter-input {
  flex: 0 0 auto;
  width: auto;
  min-width: 9.5rem;
}
.analytics-range-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: center;
}
.analytics-dashboard { display: flex; flex-direction: column; gap: 1rem; }
.analytics-meta { margin: 0; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.65rem;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.metric-value {
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.2;
}
.metric-hint { margin-top: 0.3rem; font-size: 0.78rem; }
.analytics-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}
.analytics-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  min-width: 0;
}
.analytics-section--half { grid-column: span 1; }
.chart-block { min-width: 0; }
.chart-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0 0 0.55rem;
  color: var(--text);
}
.analytics-empty { margin: 0.25rem 0; }
.hbar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.hbar-item { min-width: 0; }
.hbar-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}
.hbar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.hbar-count { color: var(--muted); flex-shrink: 0; }
.hbar-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 999px;
  min-width: 2px;
}
.ts-chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.ts-label {
  font-size: 9px;
  fill: var(--muted);
}
.ts-label-y {
  font-size: 8px;
}
.ts-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}
.ts-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.ts-legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.ts-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
@media (max-width: 900px) {
  .analytics-charts { grid-template-columns: 1fr; }
  .analytics-section--half { grid-column: span 1; }
}

.audit-log { max-height: 60vh; overflow: auto; }
.audit-entry {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.audit-head { margin-bottom: 0.2rem; }

/* Live toasts stack in this fixed container (newest at the bottom, nearest the
   FAB). The container ignores pointer events so it never blocks the page; each
   toast re-enables them so it stays click-to-dismiss. */
.toast-stack {
  position: fixed;
  bottom: calc(var(--archie-anchor-bottom) + var(--archie-fab-size) + var(--archie-fab-gap));
  right: var(--archie-fab-inset);
  z-index: var(--z-toast, 1200);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  max-width: min(420px, calc(100vw - 2 * var(--archie-fab-inset)));
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.75rem 0.85rem 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  max-width: min(420px, calc(100vw - 2 * var(--archie-fab-inset)));
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.toast.error { border-color: var(--danger); background: var(--error-bg); color: var(--error-text); }
.toast.success { border-color: var(--success); background: var(--toast-success-bg); }
.toast-stack .toast { pointer-events: auto; cursor: pointer; }
.toast-message { overflow-wrap: anywhere; }
.toast-close {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  line-height: 1;
  padding: 0.15rem 0.25rem;
  border-radius: 6px;
}
.toast-close:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .toast-stack .toast { animation: toast-in 0.2s ease both; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background: var(--error-bg);
  border-bottom: 1px solid var(--error-border);
  color: var(--error-text);
  font-size: 0.9rem;
}
.error-banner.hidden { display: none; }

.site-notice-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid transparent;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.site-notice-banner.hidden { display: none; }
.site-notice-banner.theme-warning {
  background: var(--draft-bg);
  border-bottom-color: var(--draft-border);
  color: var(--draft-text);
}
.site-notice-banner.theme-issue {
  background: var(--error-bg);
  border-bottom-color: var(--error-border);
  color: var(--error-text);
}
.site-notice-banner.theme-notice {
  background: var(--toast-success-bg, rgba(34, 197, 94, 0.12));
  border-bottom-color: var(--success-border);
  color: var(--success);
}

.form-error {
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.85rem;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 8px;
  color: var(--error-text);
  font-size: 0.88rem;
  line-height: 1.45;
}
.form-error.hidden { display: none; }
.login-hint { margin: 0 0 0.85rem; font-size: 0.85rem; }

.event-entry { padding: 0.55rem 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.event-entry.error-entry { border-left: 3px solid var(--danger); padding-left: 0.65rem; }
.event-kind { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

.ai-log-filters { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.65rem; }
.ai-log-filter-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.ai-filter-input {
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  min-width: 7rem;
}
.ai-log-pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.ai-log-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  cursor: pointer;
  padding: 0.45rem 0.55rem;
}
.ai-log-preview {
  flex: 1 1 100%;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-log-detail { padding: 0.35rem 0.55rem 0.65rem; }
.ai-log-block { margin-top: 0.55rem; }
.ai-log-pre {
  margin: 0.35rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius);
  background: var(--surface-elevated, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 16rem;
  overflow: auto;
}
.ai-log-pre--sm { max-height: 10rem; font-size: 0.74rem; }
.ai-feedback-badges { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.ai-vote-pill--up { border-color: var(--success, #2a9d4b); color: var(--success, #2a9d4b); }
.ai-vote-pill--down { border-color: var(--danger, #d44); color: var(--danger, #d44); }
.ai-vote-pill--copy { border-color: var(--accent); color: var(--accent-readable); }
.ai-tool-list { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.ai-tool-item { margin-bottom: 0.45rem; }
.ai-cite-list { margin: 0.35rem 0 0; padding-left: 1.1rem; }

.ai-log-filters { margin-bottom: 0.75rem; }
.ai-log-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.ai-filter-input {
  flex: 1 1 140px;
  min-width: 120px;
  padding: 0.45rem 0.65rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
}
.ai-log-pager {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.ai-log-entry {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.ai-log-entry.error-entry { border-left: 3px solid var(--danger); padding-left: 0.65rem; }
.ai-log-summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem;
}
.ai-log-preview {
  flex: 1 1 100%;
  color: var(--muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-log-detail { padding: 0.55rem 0 0.25rem 0.35rem; }
.ai-log-block { margin-bottom: 0.65rem; }
.ai-log-block strong { display: block; margin-bottom: 0.25rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.ai-log-pre {
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.45;
  max-height: 280px;
  overflow: auto;
}
.ai-log-pre--sm { font-size: 0.75rem; max-height: 180px; }
.ai-tool-list { list-style: none; margin: 0; padding: 0; }
.ai-tool-item { padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.ai-tool-item:last-child { border-bottom: none; }
.ai-cite-list { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; }
.error-text { color: var(--danger); }

@media (max-width: 1100px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
}

/* Default: burger hidden on desktop. Must come BEFORE the md media query
   so the drawer toggle can override display inside @media (max-width: 700px). */
.mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.mobile-nav-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent-readable);
}
.mobile-nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.mobile-nav-icon { display: block; }
.mobile-nav-icon--close { display: none; }
.mobile-nav-toggle[aria-expanded="true"] .mobile-nav-icon--open { display: none; }
.mobile-nav-toggle[aria-expanded="true"] .mobile-nav-icon--close { display: block; }

.sidebar-backdrop {
  display: none;
}

.sidebar-resize {
  display: none;
}

@media (min-width: 701px) {
  .sidebar {
    position: relative;
  }
  .sidebar-resize {
    display: block;
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: var(--z-sticky);
    touch-action: none;
    background: transparent;
  }
  .sidebar-resize::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2.5rem;
    transform: translate(-50%, -50%);
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--border) 80%, var(--accent));
    opacity: 0;
    transition: opacity var(--transition-fast, 0.15s ease);
  }
  .sidebar-resize:hover::after,
  .sidebar-resize:focus-visible::after,
  body.sidebar-resizing .sidebar-resize::after {
    opacity: 1;
    background: var(--accent);
  }
  .sidebar-resize:focus-visible {
    outline: none;
  }
  body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
  }
  body.sidebar-resizing iframe {
    pointer-events: none;
  }
}

@media (max-width: 700px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-drawer);
    width: min(var(--sidebar-w), 88vw);
    max-width: 88vw;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
    /* Clear the fixed close control sitting over the drawer brand */
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    padding-right: 1rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(0.75rem + 2.5rem + 0.5rem + env(safe-area-inset-left, 0px));
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-resize { display: none; }
  .mobile-nav-toggle {
    display: flex;
    position: fixed;
    top: calc(0.75rem + env(safe-area-inset-top, 0px));
    left: calc(0.75rem + env(safe-area-inset-left, 0px));
    z-index: calc(var(--z-drawer) + 2);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: var(--overlay);
  }
  .sidebar-backdrop:not(.hidden) {
    display: block;
  }
  /* Clear the fixed burger over chrome that sits at the top of .main */
  .toolbar {
    padding-left: calc(3.5rem + env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }
  .site-notice-banner,
  .error-banner {
    padding-left: calc(3.5rem + env(safe-area-inset-left, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
  }
  .detail-header {
    padding-left: calc(2.25rem + env(safe-area-inset-left, 0px));
  }
  /* Detail hides the toolbar — keep Back/actions clear of the fixed burger */
  .main:has(#mainToolbar.hidden) .detail-header {
    padding-left: calc(3.5rem + env(safe-area-inset-left, 0px));
  }
  .main:has(#mainToolbar.hidden):not(:has(.site-notice-banner:not(.hidden))):not(:has(.error-banner:not(.hidden))) .detail-header {
    padding-top: calc(3.25rem + env(safe-area-inset-top, 0px));
  }
  .detail-full {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .view {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }
  .home-hero {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
  .home-search-wrap {
    flex-wrap: wrap;
    justify-content: stretch;
    padding: 0.35rem;
  }
  .home-search-wrap .btn {
    width: 100%;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .list-filters .filter-search {
    flex: 1 1 100%;
    min-width: 0;
  }
  .archie-fab {
    right: max(var(--archie-fab-inset), env(safe-area-inset-right, 0px));
    bottom: var(--archie-anchor-bottom);
  }
  .archie-panel {
    right: max(var(--archie-fab-inset), env(safe-area-inset-right, 0px));
    bottom: var(--archie-anchor-bottom);
  }
  body.mobile-nav-open {
    overflow: hidden;
  }
}

.no-animations .sidebar {
  transition: none;
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

.detail-refs {
  margin: 0.65rem 0;
  padding: 0.85rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
/* Match Appearance / ADM / Home disclosure chrome (+/− toggle, padded summary). */
.detail-refs.detail-refs-disclosure,
.detail-refs.detail-refs-details {
  margin: 0.65rem 0;
  padding: 0;
  background: var(--surface);
  box-shadow: none;
}
.detail-refs .detail-subheading,
.detail-diff .detail-subheading {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.detail-refs-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.5rem;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  min-width: 0;
}
.detail-refs-summary::-webkit-details-marker { display: none; }
.detail-refs-summary::marker { content: ""; display: none; }
.detail-refs-summary-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.detail-refs-summary-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}
.detail-refs-summary .appearance-toggle { margin-left: 0; }
.detail-refs-summary:hover .appearance-toggle { background: var(--accent-hover); }
.detail-refs-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}
.detail-refs-disclosure[open] > .detail-refs-summary .appearance-toggle::before,
.detail-refs-details[open] > .detail-refs-summary .appearance-toggle::before {
  content: "−";
}
.detail-refs-body {
  padding: 0.85rem 0.9rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.detail-refs-body > :first-child { margin-top: 0; }
.detail-refs-body > :last-child { margin-bottom: 0; }
.detail-refs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  min-width: 0;
}
.detail-refs-head .detail-subheading { margin: 0; }
.detail-refs-hint,
.links-empty-detail { margin: 0.5rem 0 0; }
.link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding-right: 0.2rem;
}
.link-chip-remove {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
}
.link-chip-remove:hover { color: var(--danger); background: var(--surface2); }

.links-editor-panel {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
}
.links-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.links-editor-head strong { display: block; font-size: 0.9rem; margin-bottom: 0; }
.links-editor-hint { margin: 0.15rem 0 0; font-size: 0.72rem; }
.links-count {
  flex-shrink: 0;
  font-size: 0.72rem;
  min-width: 1.5rem;
  text-align: center;
}
.link-chips-scroll {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 0.35rem;
  max-height: 108px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.45rem;
  margin-bottom: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.link-chips-scroll.is-empty {
  min-height: 2.25rem;
  align-items: center;
  justify-content: center;
}
.link-chips-scroll .links-empty { margin: 0; font-size: 0.78rem; }
.links-editor-panel .link-chip {
  flex: 0 0 auto;
  max-width: calc(100% - 0.5rem);
  padding-right: 0;
  overflow: hidden;
}
.links-editor-panel .link-chip-label {
  font-size: 0.76rem;
  color: var(--text);
  padding: 0.22rem 0.55rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.links-empty { margin: 0; }
.link-add-row { position: relative; display: flex; gap: 0.5rem; align-items: stretch; }
.link-add-row select {
  flex: 0 0 auto;
  min-width: 9rem;
  max-width: 12rem;
  padding: 0.55rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.link-add-row input {
  flex: 1;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.link-chip-type {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.75;
  margin-right: 0.25rem;
}
.impact-list, .gap-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}
.impact-list li, .gap-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border, rgba(127,127,127,0.2));
  font-size: 0.85rem;
}
.gap-analysis-panel { margin-top: 0.5rem; }
.viewpoints-panel { margin-top: 1.5rem; }
.viewpoints-list ul { list-style: none; padding: 0; }
.viewpoints-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border, rgba(127,127,127,0.2)); }
.link-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 20;
  max-height: 240px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}
.link-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.link-result:last-child { border-bottom: none; }
.link-result:hover { background: var(--accent-soft); }
.link-result-title { display: block; font-weight: 600; font-size: 0.9rem; }
.link-result-meta { display: block; font-size: 0.72rem; margin-top: 0.1rem; }
.link-results-empty { padding: 0.65rem 0.75rem; margin: 0; }

.detail-ref-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}
.detail-ref-group:last-child { margin-bottom: 0; }
.ref-link {
  appearance: none;
  background: var(--meta-tag-bg);
  border: 1px solid var(--meta-tag-border);
  color: var(--accent-readable);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  max-width: 100%;
  min-width: 0;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ref-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.detail-diff { margin: 1rem 0 1.25rem; }
.diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.diff-block {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.45;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.card-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}
.card-grid.compact .card {
  padding: 0.75rem;
}
.card-grid.compact .card h3 { font-size: 0.85rem; }

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bulk-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
.approval-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
}
.approval-check {
  display: inline-flex;
  flex-direction: row;
  align-items: flex-start;
  align-self: start;
  gap: 0;
  margin: 0;
  padding-top: 0.15rem;
  font-size: inherit;
  color: inherit;
  height: fit-content;
}
.approval-check input { margin: 0; flex-shrink: 0; }
.approval-card-body { min-width: 0; }

@media (max-width: 700px) {
  .diff-grid { grid-template-columns: 1fr; }
}
.markdown {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.markdown h1, .markdown h2, .markdown h3 { margin-top: 1.25rem; margin-bottom: 0.5rem; }
.markdown ul { padding-left: 1.25rem; }
.markdown code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }
.markdown pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.markdown table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.markdown a { color: var(--accent-readable); }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 2.25rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: var(--weight-medium, 500);
  line-height: 1.2;
  text-align: center;
  text-transform: none;
  gap: 0.35rem;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--error-border); }
.btn.danger:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }
.btn.danger:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--danger); }
.btn.danger:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.approve { color: var(--success); border-color: var(--success-border); }
.btn.approve:hover:not(:disabled) { color: var(--success); border-color: var(--success); }
.btn.approve:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--success); }
.btn.approve:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: none; border: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

.filter-row { margin-bottom: 1rem; }
.filter-row select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font: inherit;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(720px, 92vw);
  max-width: min(720px, 92vw);
  max-height: 90vh;
  overflow-x: hidden;
  box-sizing: border-box;
}
dialog > form {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  min-width: 0;
  overflow-x: hidden;
}
#view-editor form {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#view-editor .editor-page-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}
#view-editor .editor-page-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  margin-bottom: 1rem;
  flex-wrap: unset;
  justify-content: unset;
}
#view-editor #editorError:not(.hidden) {
  position: sticky;
  top: 4.5rem;
  z-index: 2;
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--danger-soft, color-mix(in srgb, var(--danger) 12%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: var(--radius-md);
}
.modal-body-label { margin-top: 0; }
.modal-body-label textarea { margin-top: 0.35rem; }
dialog::backdrop { background: var(--overlay); }
.modal-header, .modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  min-width: 0;
  gap: 0.75rem;
}
.modal-header h2,
.modal-footer {
  min-width: 0;
}
.modal-header h2 {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.modal-footer { border-bottom: none; border-top: 1px solid var(--border); justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.modal-footer-split { justify-content: space-between; align-items: center; }
.modal-footer-actions { display: flex; gap: 0.5rem; margin-left: auto; flex-wrap: wrap; }
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: auto;
}
.modal-body {
  padding: 1.25rem;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 60vh;
  min-width: 0;
  box-sizing: border-box;
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.form-grid > *,
.user-form-section-grid > * {
  min-width: 0;
}
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); }
/* Body editor host is a div (not label) so toolbar clicks are not redirected to Headings. */
div.modal-body-label.rich-md-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  grid-column: 1 / -1;
}
label.checkbox-row,
.user-perm-sections label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}
.user-perm-sections label.checkbox-row input {
  flex-shrink: 0;
  margin: 0;
}
label.full { grid-column: 1 / -1; }
/* Non-label .full children (avatar row, Entra hint, etc.) also span the section grid. */
.user-form-section-grid > .full {
  grid-column: 1 / -1;
}
.user-form-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}
.user-form-section:first-of-type,
#userFormError + .user-form-section {
  border-top: none;
  padding-top: 0;
}
.user-form-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
  min-width: 0;
}
.user-form-section input,
.user-form-section select,
.user-form-section textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.user-form-section input[readonly] {
  opacity: 0.85;
  cursor: default;
  background: color-mix(in srgb, var(--bg) 88%, var(--border));
}
.user-form-section input.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow-x: hidden;
  text-overflow: ellipsis;
}
.user-avatar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.user-avatar-preview {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
}

/* Self-service Edit profile (Gravatar) */
.profile-form {
  max-width: 36rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 2rem;
}
.profile-avatar-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  min-width: 0;
}
.profile-avatar-preview-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-avatar-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.profile-avatar-initials {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-readable);
}
.profile-avatar-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  min-width: 0;
}
.profile-field-hint {
  margin: -0.35rem 0 0;
}
.profile-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
@media (max-width: 560px) {
  .profile-avatar-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
#userAvatarMeta {
  min-width: 0;
  /* Prefer a single line when the row has room; break only if needed. */
  overflow-wrap: break-word;
}
#userEntraHint {
  margin: 0;
  line-height: 1.35;
}
@media (max-width: 560px) {
  .form-grid,
  .user-form-section-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}
/* Global focus-visible fallback (WCAG 2.4.7). Low specificity via :where() so
   components that define their own focus style (inputs above, etc.) still win. */
:where(button, a, [role="button"], [tabindex], summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}
.password-field input {
  width: 100%;
  padding-right: 2.5rem;
  box-sizing: border-box;
}
.password-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.password-toggle:hover {
  color: var(--text);
  background: var(--surface);
}
.password-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.password-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}
textarea { resize: vertical; min-height: 120px; }
.hidden-field { display: none !important; }

.pill.file-badge {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-readable);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.import-dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.import-dropzone.dragover,
.import-dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.import-dropzone-text { display: block; font-size: 0.95rem; color: var(--text); }
.import-dropzone-hint { display: block; margin-top: 0.35rem; }

.detail-file-meta {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.file-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}
.file-meta-grid .meta { display: block; margin-bottom: 0.15rem; }
.file-meta-actions { display: flex; align-items: center; }

.detail-file-viewer {
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.file-preview-pdf,
.file-preview-inline {
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: var(--surface);
  display: block;
}
.file-preview-wrap {
  padding: 0;
}
.file-preview-media {
  display: block;
  width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  background: #000;
}
.file-preview-note,
.file-preview-actions {
  padding: 0.65rem 1rem;
  margin: 0;
  border-top: 1px solid var(--border);
}
.file-preview-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  padding: 1rem;
}
.file-preview-html {
  padding: 1rem 1.25rem;
  max-height: 70vh;
  overflow: auto;
}
.file-preview-fallback {
  padding: 2rem 1.25rem;
  text-align: center;
}
.file-preview-fallback p { margin-bottom: 1rem; }
.ppt-preview p { margin: 0.35rem 0; }

/* Metadata explorer graph */
#view-explorer.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 0px);
  max-height: calc(100vh - 0px);
  padding-bottom: 0.75rem;
  overflow: hidden;
}
#view-explorer .view-header.row { flex-shrink: 0; margin-bottom: 0.75rem; }
.graph-toolbar { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.graph-explorer-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) 1fr;
  gap: 0.85rem;
  flex: 1;
  min-height: 0;
}
.graph-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  min-height: 0;
}
.graph-search-label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); }
.graph-search-label input {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.graph-filter-section { display: flex; flex-direction: column; gap: 0.4rem; }
.graph-filter-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.graph-type-filters,
.graph-edge-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 0.65rem;
}
.graph-filter-chip {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  line-height: 1.2;
  color: var(--text);
  cursor: pointer;
  padding: 0.15rem 0;
  min-width: 0;
}
.graph-filter-chip input[type="checkbox"] {
  accent-color: var(--accent);
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin: 0;
}
.graph-filter-chip.active { color: var(--text); }
.graph-filter-chip:not(.active) { opacity: 0.55; }
.graph-filter-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.graph-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}
.graph-legend-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.graph-selection {
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.graph-selection-title { margin: 0 0 0.35rem; font-size: 0.85rem; }
.graph-selection-name { margin: 0 0 0.25rem; font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.graph-sel-hint { margin: 0.35rem 0 0.65rem; line-height: 1.4; color: var(--warn); }
.graph-main {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.graph-container {
  flex: 1;
  min-height: 420px;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
@media (max-width: 900px) {
  .graph-explorer-layout { grid-template-columns: 1fr; }
  .graph-sidebar { max-height: 220px; }
  .graph-container { min-height: 360px; }
}

/* Archie EA assistant */
.ea-diamond-logo--fab { width: 28px; height: 28px; }
.ea-diamond-logo--xs { width: 22px; height: 22px; flex-shrink: 0; }

.archie-fab {
  position: fixed;
  right: var(--archie-fab-inset);
  bottom: var(--archie-anchor-bottom);
  z-index: 1050;
  width: var(--archie-fab-size);
  height: var(--archie-fab-size);
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-elevated, var(--surface));
  color: var(--accent-readable);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.archie-fab:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg, var(--shadow-md));
}
.archie-fab--open {
  opacity: 0;
  pointer-events: none;
}
/* Attention pulse: accent-coloured rings that expand & fade around the FAB */
.archie-fab::before,
.archie-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: archie-fab-pulse 2.2s ease-out infinite;
}
.archie-fab::after { animation-delay: 1.1s; }
.archie-fab:hover::before,
.archie-fab:hover::after,
.archie-fab--open::before,
.archie-fab--open::after {
  animation: none;
  box-shadow: none;
}
@keyframes archie-fab-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .archie-fab::before,
  .archie-fab::after { animation: none; box-shadow: none; }
}

.archie-panel {
  position: fixed;
  right: var(--archie-fab-inset);
  bottom: var(--archie-anchor-bottom);
  z-index: 1040;
  width: min(420px, calc(100vw - 2 * var(--archie-fab-inset)));
  max-height: min(560px, calc(100vh - 2rem - var(--app-footer-clearance)));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, var(--radius));
  background: var(--surface);
  box-shadow: var(--shadow-lg, var(--shadow-md));
  overflow: hidden;
  transition: width 0.2s ease, max-height 0.2s ease;
}
.archie-panel.hidden { display: none; }
.archie-panel--expanded {
  width: min(600px, calc(100vw - 2 * var(--archie-fab-inset)));
  max-height: min(720px, calc(100vh - 2rem - var(--app-footer-clearance)));
}
.archie-panel--expanded .archie-messages {
  min-height: 320px;
}

.archie-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-elevated, var(--surface));
}
.archie-header-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.archie-header-title strong { font-size: 0.95rem; }
.archie-header-title .meta {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}
.archie-header-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.archie-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  position: relative;
}

.archie-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.archie-history-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.archie-history-backdrop.hidden { display: none; }

.archie-status {
  padding: 0.5rem 0.85rem;
  font-size: 0.78rem;
  line-height: 1.35;
  border-bottom: 1px solid var(--border);
}
.archie-status--warn {
  background: var(--warn-bg, rgba(255, 180, 0, 0.12));
  color: var(--warn, #c90);
}

.archie-messages {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.archie-msg {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.45;
}
.archie-msg--user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-text, #fff);
}
.archie-msg--assistant {
  align-self: flex-start;
  background: var(--surface-elevated, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
}
.archie-msg--loading {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-elevated, rgba(255,255,255,0.04)));
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 10%, transparent);
}
.archie-typing {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.ea-diamond-logo--typing {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  animation: archie-typing-diamond-pulse 1.8s ease-in-out infinite;
}
.ea-diamond-logo--typing svg {
  width: 100%;
  height: 100%;
}
@keyframes archie-typing-diamond-pulse {
  0%, 100% {
    color: var(--accent);
    filter: drop-shadow(0 0 3px color-mix(in srgb, var(--accent) 40%, transparent));
    transform: scale(1);
  }
  50% {
    color: color-mix(in srgb, var(--accent) 65%, var(--success, #22c55e) 35%);
    filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 60%, transparent));
    transform: scale(1.08);
  }
}
.archie-typing-label {
  display: inline-flex;
  align-items: baseline;
  font-size: 0.82rem;
  line-height: 1.35;
}
.archie-typing-shimmer {
  background: linear-gradient(
    90deg,
    var(--muted) 0%,
    color-mix(in srgb, var(--accent) 55%, var(--text) 45%) 50%,
    var(--muted) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: archie-text-shimmer 2.2s ease-in-out infinite;
}
@keyframes archie-text-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.archie-typing-ellipsis span {
  display: inline-block;
  color: var(--accent);
  animation: archie-dot-bounce 1.4s ease-in-out infinite;
}
.archie-typing-ellipsis span:nth-child(2) { animation-delay: 0.2s; }
.archie-typing-ellipsis span:nth-child(3) { animation-delay: 0.4s; }
@keyframes archie-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-3px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .ea-diamond-logo--typing,
  .archie-typing-shimmer,
  .archie-typing-ellipsis span {
    animation: none;
  }
  .archie-typing-shimmer {
    -webkit-text-fill-color: var(--muted);
    background: none;
  }
  .archie-typing-ellipsis span { opacity: 0.85; }
}
.archie-msg-body p { margin: 0 0 0.4rem; }
.archie-msg-body p:last-child { margin-bottom: 0; }
.archie-msg-body h1,
.archie-msg-body h2,
.archie-msg-body h3,
.archie-msg-body h4,
.archie-msg-body h5,
.archie-msg-body h6 {
  font-size: 0.92em;
  font-weight: 650;
  line-height: 1.35;
  margin: 0.55rem 0 0.25rem;
}
.archie-msg-body h1:first-child,
.archie-msg-body h2:first-child,
.archie-msg-body h3:first-child,
.archie-msg-body h4:first-child,
.archie-msg-body h5:first-child,
.archie-msg-body h6:first-child {
  margin-top: 0;
}
.archie-msg-body ul,
.archie-msg-body ol {
  margin: 0.25rem 0 0.45rem;
  padding-left: 1.25rem;
}
.archie-msg-body li { margin: 0.15rem 0; }
.archie-msg-body li > ul,
.archie-msg-body li > ol { margin: 0.1rem 0; }
.archie-msg-body code {
  font-size: 0.8em;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: rgba(0,0,0,0.15);
}

.archie-cites {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.archie-cite {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent-readable);
  cursor: pointer;
  text-align: left;
  max-width: 14rem;
}
.archie-cite-title {
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}
.archie-cite-id {
  display: none;
}
.archie-cite:hover { border-color: var(--accent); }

.archie-cites-more {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.archie-cites-more-summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px dashed var(--border);
  user-select: none;
}
.archie-cites-more-summary::-webkit-details-marker { display: none; }
.archie-cites-more[open] .archie-cites-more-summary {
  border-style: solid;
  color: var(--accent-readable);
}
.archie-cites-more-list {
  display: contents;
}

.archie-stream-caret {
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 0.1em;
  vertical-align: text-bottom;
  background: var(--accent-readable);
  animation: archie-caret-blink 1s step-end infinite;
}
@keyframes archie-caret-blink {
  50% { opacity: 0; }
}
.archie-msg--streaming .archie-msg-body {
  min-height: 1.25em;
}

.archie-cite--external {
  text-decoration: none;
  border-style: dashed;
}
.archie-cite--external:hover { border-color: var(--accent); border-style: solid; }
.archie-external-icon {
  margin-left: 0.25rem;
  vertical-align: -0.05rem;
  opacity: 0.85;
}

.archie-msg-body a.archie-inline-cite {
  color: var(--accent-readable);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 2px;
  cursor: pointer;
}
.archie-msg-body a.archie-inline-cite:hover {
  text-decoration-color: var(--accent);
}
.archie-msg-body a.archie-external-link {
  color: var(--accent-readable);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 2px;
}
.archie-msg-body a.archie-external-link:hover {
  text-decoration-style: solid;
  text-decoration-color: var(--accent);
}

.archie-thoughts {
  margin-bottom: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%);
  overflow: hidden;
}
.archie-thoughts-summary {
  cursor: pointer;
  list-style: none;
  padding: 0.35rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}
.archie-thoughts-summary::-webkit-details-marker { display: none; }
.archie-thoughts[open] .archie-thoughts-summary {
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.archie-thought-list {
  margin: 0;
  padding: 0.35rem 0.55rem 0.45rem 0.35rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.archie-thought-step {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.74rem;
  line-height: 1.35;
}
.archie-thought-icon {
  flex: 0 0 auto;
  width: 1rem;
  height: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: 0.85;
}
.archie-thought-icon svg { display: block; }
.archie-thought-step--active .archie-thought-icon {
  color: var(--accent-readable);
  opacity: 1;
  animation: archie-thought-pulse 1.4s ease-in-out infinite;
}
.archie-thought-step--done .archie-thought-icon { color: var(--text); }
.archie-thought-step--error .archie-thought-icon { color: var(--danger, #d44); }
.archie-thought-step--pending .archie-thought-icon { color: var(--warn, #c90); }
@keyframes archie-thought-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .archie-thought-step--active .archie-thought-icon { animation: none; }
}
.archie-thought-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.archie-thought-label { color: var(--text); }
.archie-thought-detail {
  color: var(--muted);
  font-size: 0.68rem;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.archie-thought-step--error .archie-thought-detail {
  color: color-mix(in srgb, var(--danger, #d44) 75%, var(--muted));
}
.archie-thought-step--active .archie-thought-label {
  color: var(--accent-readable);
}
.archie-thought-step--pending .archie-thought-label {
  color: var(--warn, #c90);
}
.archie-thought-step--error .archie-thought-label {
  color: var(--danger, #d44);
}

.archie-typing--compact {
  justify-content: flex-start;
  padding: 0.15rem 0.55rem 0.35rem;
}
.archie-typing--compact .archie-typing-diamond {
  width: 1rem;
  height: 1rem;
}

/* Loading bubble with thought steps: diamond as a leading avatar, aligned
   with the "Working…" header, thought process laid out cleanly to its right. */
.archie-msg--loading-steps {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.6rem 0.65rem;
}
.archie-loading-avatar {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 0.15rem;
}
.archie-loading-content {
  flex: 1 1 auto;
  min-width: 0;
}
.archie-loading-content .archie-thoughts {
  margin-bottom: 0;
}

.archie-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}
.archie-msg-actions .archie-action {
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  min-height: 0;
  line-height: 1.3;
  opacity: 0.85;
}
.archie-msg-actions .archie-action:hover { opacity: 1; }
.archie-copy.is-copied {
  color: var(--success, #2a9d4b);
  border-color: color-mix(in srgb, var(--success, #2a9d4b) 45%, transparent);
  background: color-mix(in srgb, var(--success, #2a9d4b) 14%, transparent);
  opacity: 1;
}
.archie-vote.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.archie-vote--up.is-active { color: var(--success, #2a9d4b); }
.archie-vote--down.is-active { color: var(--danger, #d44); }

.archie-pending {
  padding: 0 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.archie-pending-card {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--warn, #c90);
  border-radius: var(--radius);
  background: var(--warn-bg, rgba(255, 180, 0, 0.08));
  font-size: 0.8rem;
}
.archie-pending-title { margin: 0; font-weight: 600; }
.archie-pending-desc { margin: 0.25rem 0 0.5rem; color: var(--muted); line-height: 1.35; }
.archie-pending-warn { margin: 0 0 0.45rem; color: var(--warn); font-size: 0.75rem; }
.archie-pending-actions { display: flex; gap: 0.4rem; }

.archie-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface-elevated, var(--surface));
}
.archie-input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-width: 0;
}
.archie-form textarea {
  flex: 1;
  min-height: 2.5rem;
  max-height: 6rem;
  resize: vertical;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg, var(--surface));
  color: var(--text);
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.btn-icon svg { display: block; }
.notification-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--danger, #dc2626);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
}
.connector-event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.35rem 0.75rem;
}
.skeleton {
  position: relative;
  overflow: hidden;
  min-height: 4rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface2) 82%, var(--border));
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 65%, transparent), transparent);
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  100% { transform: translateX(100%); }
}
[aria-busy="true"] {
  cursor: progress;
}
.archie-mic {
  flex-shrink: 0;
  align-self: flex-end;
  min-width: 2.25rem;
}
.archie-mic--active {
  color: var(--warn, #e6a700);
  border-color: var(--warn, #e6a700);
  box-shadow: 0 0 0 2px rgba(230, 167, 0, 0.25);
  animation: archie-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes archie-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(230, 167, 0, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(230, 167, 0, 0.35); }
}
.archie-mic:disabled { opacity: 0.45; cursor: not-allowed; }
.archie-listening {
  flex: 1 1 100%;
  font-size: 0.72rem;
  color: var(--warn, #e6a700);
  margin: -0.15rem 0 0;
}
.archie-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.archie-history {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface-elevated, var(--surface));
  overflow: hidden;
  transition: width 0.2s ease, opacity 0.2s ease;
}
.archie-history.hidden {
  display: none;
}
.archie-panel--expanded .archie-history {
  width: 240px;
}
.archie-history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem 0.4rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.archie-history-header strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.archie-history-header .meta {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}
.archie-history-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.45rem 0.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.archie-history-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.archie-history-row .archie-history-item {
  flex: 1;
  min-width: 0;
}
.archie-history-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 4px);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.archie-history-delete {
  flex-shrink: 0;
  align-self: center;
  margin-right: 0.15rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm, 4px);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.archie-history-row:hover .archie-history-delete,
.archie-history-row:focus-within .archie-history-delete {
  opacity: 1;
}
.archie-history-delete:hover {
  color: var(--danger, #e5534b);
  background: var(--surface-hover, rgba(255, 255, 255, 0.06));
}
.archie-history-delete:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.archie-history-item:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.04));
  border-color: var(--border);
}
.archie-history-item.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.archie-history-title {
  font-size: 0.82rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.archie-history-meta {
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.archie-history-empty {
  padding: 0.5rem 0.85rem 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}
.archie-header-actions #archieNewChat {
  font-size: 1.05rem;
  line-height: 1;
  padding-inline: 0.35rem;
}
.archie-header-actions #archieHistoryToggle.is-active {
  color: var(--accent-readable);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

@media (max-width: 480px) {
  .archie-panel--history-open .archie-history-backdrop:not(.hidden) {
    display: block;
  }
  .archie-panel--history-open .archie-history:not(.hidden) {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: min(240px, 82%);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35);
  }
}

/* EA Studio roadmap — Phases 1–12 */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
}
.nav-group { margin-bottom: 0.5rem; }
.nav-group-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text);
  padding: 0.5rem 0.75rem 0.3rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--border);
  cursor: pointer;
  list-style: none;
}
.nav-group:first-child .nav-group-label { border-top: none; margin-top: 0; }
.nav-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}
.nav-group[open] > .nav-group-label { color: var(--text); }
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { color: var(--accent-hover); }
.nav-group-label::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.65rem;
  transition: transform var(--transition-fast);
}
.nav-group[open] > .nav-group-label::before { transform: rotate(90deg); }
.view-readme-link {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--accent-readable);
  text-decoration: none;
}
.view-readme-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  min-height: 45vh;
}
.empty-state .empty { margin-bottom: 1rem; padding: 0; }
.home-stat-link { cursor: pointer; }
.home-stat-link:hover { color: var(--accent-readable); }
.home-facets {
  position: relative;
  z-index: var(--z-base);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
  justify-content: center;
}
.home-facets label { font-size: 0.8rem; color: var(--muted); }
.home-facets select { margin-left: 0.35rem; }
.home-results-section.is-loading {
  opacity: 0.78;
}
.offline-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3);
  border: 1px solid var(--draft-border);
  border-radius: var(--radius-md);
  background: var(--draft-bg);
  color: var(--draft-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.confirm-dialog {
  width: min(440px, calc(100vw - 2rem));
}
.confirm-dialog-body {
  margin: 0;
  color: var(--text);
  line-height: var(--leading-relaxed);
  white-space: pre-wrap;
}
.confirm-dialog-typed {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
  color: var(--muted);
}
.confirm-dialog-typed input {
  width: 100%;
}
.command-palette {
  width: min(640px, calc(100vw - 2rem));
}
.command-palette .modal-body {
  gap: var(--space-3);
}
.command-palette-input {
  width: 100%;
  font-size: var(--text-md);
}
.command-palette-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: min(420px, 60vh);
  overflow: auto;
}
.command-palette-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.command-palette-item:hover,
.command-palette-item:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.command-palette-item-title {
  font-weight: var(--weight-semibold);
}
.command-palette-item-meta {
  overflow-wrap: anywhere;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.card-compact { padding: 0.75rem; }
.detail-comments { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1rem; width: 100%; }
.detail-comments h3 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
}
.comment { margin-bottom: 0.75rem; }
.detail-comment-composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
  width: 100%;
  box-sizing: border-box;
}
.detail-comment-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 4.5rem;
  resize: vertical;
  padding: var(--space-2) var(--space-3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.detail-comment-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}
.metamodel-pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow: auto;
  max-height: 70vh;
  font-size: 0.8rem;
}
.keyboard-overlay .shortcut-list { list-style: none; padding: 0; }
.keyboard-overlay kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-family: inherit;
}
.reduced-motion .graph-container *,
.reduced-motion .vis-network * {
  transition: none !important;
  animation: none !important;
}
.manage-card-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.card-select-wrap { padding-top: 1rem; }
@media (max-width: 768px) {
  .home-facets { flex-direction: column; align-items: stretch; }
  .home-facets label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    width: 100%;
  }
  .home-facets select {
    margin-left: 0;
    width: 100%;
  }
}
.pill.in-review { background: #7c3aed33; color: #c4b5fd; border-color: #7c3aed55; }
.split-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; min-height: 12rem; }
.split-editor textarea { min-height: 12rem; }
.split-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; overflow: auto; max-height: 20rem; }

/* Markdown-preserving WYSIWYG (Vditor) */
.rich-md-sync {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.rich-md-label { position: relative; }
.rich-md-editor,
.rich-md-host {
  width: 100%;
  min-height: 12rem;
}
.rich-md-editor .vditor,
.note-rich-editor .vditor,
.forum-rich-editor .vditor,
.detail-comment-composer .vditor {
  --toolbar-background-color: var(--surface2);
  --toolbar-icon-color: var(--text);
  --toolbar-icon-hover-color: var(--accent);
  --panel-background-color: var(--surface);
  --textarea-background-color: var(--surface);
  --textarea-text-color: var(--text);
  --border-color: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
}
.rich-md-editor .vditor-toolbar,
.note-rich-editor .vditor-toolbar,
.forum-rich-editor .vditor-toolbar,
.detail-comment-composer .vditor-toolbar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.rich-md-editor .vditor-toolbar__item .vditor-tooltipped,
.note-rich-editor .vditor-toolbar__item .vditor-tooltipped,
.forum-rich-editor .vditor-toolbar__item .vditor-tooltipped,
.detail-comment-composer .vditor-toolbar__item .vditor-tooltipped {
  color: var(--text);
}
.rich-md-editor .vditor-toolbar__item svg,
.note-rich-editor .vditor-toolbar__item svg,
.forum-rich-editor .vditor-toolbar__item svg,
.detail-comment-composer .vditor-toolbar__item svg {
  color: var(--text);
  fill: currentColor !important;
  stroke: currentColor !important;
  opacity: 1 !important;
  width: 15px !important;
  height: 15px !important;
  display: inline-block !important;
}
.rich-md-editor .vditor-toolbar__item button:hover,
.note-rich-editor .vditor-toolbar__item button:hover,
.forum-rich-editor .vditor-toolbar__item button:hover,
.detail-comment-composer .vditor-toolbar__item button:hover,
.rich-md-editor .vditor-toolbar__item--current button,
.note-rich-editor .vditor-toolbar__item--current button,
.forum-rich-editor .vditor-toolbar__item--current button,
.detail-comment-composer .vditor-toolbar__item--current button {
  background-color: var(--accent-soft, color-mix(in srgb, var(--accent) 14%, transparent)) !important;
}
.rich-md-editor .vditor-content,
.note-rich-editor .vditor-content,
.forum-rich-editor .vditor-content,
.detail-comment-composer .vditor-content,
.rich-md-editor .vditor-wysiwyg,
.rich-md-editor .vditor-ir,
.rich-md-editor .vditor-sv {
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans, "Source Sans 3", sans-serif);
  font-size: var(--text-sm);
}
/* .vditor-hint is the toolbar dropdown (headings, emoji); .vditor-panel is the
   wysiwyg link/table popover. Both must clear the sticky editor chrome. */
.rich-md-editor .vditor-panel,
.note-rich-editor .vditor-panel,
.forum-rich-editor .vditor-panel,
.detail-comment-composer .vditor-panel,
#editorModal .vditor-panel,
#view-editor .vditor-panel,
.rich-md-editor .vditor-hint,
.note-rich-editor .vditor-hint,
.forum-rich-editor .vditor-hint,
.detail-comment-composer .vditor-hint,
#editorModal .vditor-hint,
#view-editor .vditor-hint {
  z-index: 10060;
  /* --surface would match the editor body exactly, leaving the menu looking
     like loose text floating over the content. */
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.rich-md-editor .vditor-hint button,
.note-rich-editor .vditor-hint button,
.forum-rich-editor .vditor-hint button,
.detail-comment-composer .vditor-hint button,
#editorModal .vditor-hint button,
#view-editor .vditor-hint button {
  color: var(--text);
}
.rich-md-editor .vditor-hint button:hover,
.note-rich-editor .vditor-hint button:hover,
.forum-rich-editor .vditor-hint button:hover,
.detail-comment-composer .vditor-hint button:hover,
.rich-md-editor .vditor-hint button.vditor-hint--current,
.note-rich-editor .vditor-hint button.vditor-hint--current,
.forum-rich-editor .vditor-hint button.vditor-hint--current,
.detail-comment-composer .vditor-hint button.vditor-hint--current,
#editorModal .vditor-hint button:hover,
#view-editor .vditor-hint button:hover {
  background-color: var(--accent-soft, color-mix(in srgb, var(--accent) 14%, transparent));
  color: var(--text);
}
#editorModal .rich-md-label,
#editorModal .rich-md-editor,
#view-editor .rich-md-label,
#view-editor .rich-md-editor {
  overflow: visible;
}
#editorModal .rich-md-editor .vditor-toolbar,
#view-editor .rich-md-editor .vditor-toolbar {
  overflow: visible;
}
.note-rich-editor { min-height: 340px; }
.forum-rich-editor { min-height: 160px; }
.detail-comment-composer .rich-md-editor { min-height: 140px; margin-bottom: var(--space-2); }
.prose img,
.detail-body img,
.forum-body img,
.comment .comment-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin: 0.75rem 0;
}

.adm-phase-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.adm-checklist { display: flex; flex-direction: column; gap: 0.75rem; margin: 1rem 0; }

/* Interactive TOGAF ADM cycle diagram */
.adm-diagram-details { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 1rem; background: var(--surface); }
.adm-diagram-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.adm-diagram-summary::-webkit-details-marker { display: none; }
.adm-diagram-summary::marker { content: ""; display: none; }
.adm-diagram-summary .appearance-toggle { margin-left: auto; }
.adm-diagram-summary:hover .appearance-toggle { background: var(--accent-hover); }
.adm-diagram-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
.adm-diagram-hint { font-weight: 400; font-size: var(--text-sm); color: var(--muted); }
.adm-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: center;
  padding: 0 0.9rem 1rem;
}
.adm-diagram-svg { width: 100%; max-width: 340px; height: auto; margin: 0 auto; flex: 0 0 auto; }
.adm-ring { fill: none; stroke: var(--border); stroke-width: 2; }
.adm-connector { stroke: var(--muted); stroke-width: 2; }
.adm-node { cursor: pointer; }
.adm-node circle {
  fill: var(--surface2);
  stroke: var(--border);
  stroke-width: 1.5;
  transition: fill var(--transition-fast), stroke var(--transition-fast);
}
.adm-node text { fill: var(--text); font-weight: 600; font-size: 20px; pointer-events: none; }
.adm-node--hub circle { fill: var(--accent-soft); }
.adm-node--hub text { font-size: 12px; }
.adm-node:hover circle { stroke: var(--accent); }
.adm-node.is-selected circle { fill: var(--accent); stroke: var(--accent); }
.adm-node.is-selected text { fill: var(--on-accent); }
.adm-node:focus-visible { outline: none; }
.adm-node:focus-visible circle { stroke: var(--accent); stroke-width: 3; }
.adm-diagram-desc { flex: 1 1 220px; min-width: 200px; align-self: center; }
.adm-diagram-desc strong { display: block; margin-bottom: 0.3rem; color: var(--text); }
.adm-diagram-desc p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }
.adm-phase-card, .adm-phase-row { padding: 0.75rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius); }
.adm-phase-head { display: flex; align-items: center; gap: 0.4rem; }
.adm-phase-name { font-weight: 600; }
.adm-phase-info {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  cursor: help;
  border-radius: 50%;
}
.adm-phase-info:hover { color: var(--accent-readable); }
.adm-phase-info:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; color: var(--accent-readable); }
.adm-phase-bar { height: 6px; background: var(--border); border-radius: 3px; margin: 0.35rem 0; overflow: hidden; }
.adm-phase-fill { height: 100%; background: var(--accent); }
.approval-diff { font-family: var(--mono, monospace); font-size: 0.75rem; }
.home-stat-link { cursor: pointer; }
.home-stat-link:hover { text-decoration: underline; }
.stakeholder-portal .sidebar .nav-item[data-view="admin"] { display: none; }
.adm-phase-row--disabled { opacity: 0.55; }
.adm-phase-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; margin: 0.75rem 0; }
.adm-phase-detail,
.adm-phase-detail-col,
.adm-phase-actions {
  text-align: left;
}
.adm-phase-purpose { margin: 0 0 0.5rem; }
.adm-phase-detail-heading {
  margin: 0 0 0.4rem;
  font-size: var(--text-sm, 0.85rem);
  font-weight: var(--weight-semibold, 600);
  color: var(--text);
}
.adm-phase-detail-grid .adm-phase-detail-heading { margin-bottom: 0.35rem; }
.adm-phase-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.adm-phase-actions .adm-phase-detail-heading {
  margin: 0.5rem 0 0;
}
.adm-phase-actions .adm-phase-detail-heading:first-child {
  margin-top: 0;
}
.adm-detail-list { margin: 0.35rem 0 0; padding-left: 1.1rem; font-size: 0.92rem; text-align: left; }
.adm-tailoring-panel { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.adm-tailor-row { display: block; margin: 0.35rem 0; }
.home-adm-engagement {
  max-width: 52rem;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto 2rem;
  padding: 0 var(--space-5);
  text-align: left;
}
.home-engagement-details {
  margin: 0;
  box-shadow: none;
}
.home-engagement-summary {
  gap: 0.6rem;
}
.home-engagement-summary .home-section-title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  flex: 0 1 auto;
  min-width: 0;
}
.home-engagement-summary .adm-diagram-hint {
  flex: 1 1 auto;
  min-width: 0;
}
.home-engagement-summary .appearance-toggle {
  margin-left: auto;
}
.home-engagement-summary:hover .appearance-toggle {
  background: var(--accent-hover);
}
.home-adm-engagement-body {
  padding: 0 0.9rem 1rem;
  border-top: none;
}
.home-engagement-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  text-align: left;
  background: var(--surface);
}
.home-engagement-card:last-child { margin-bottom: 0; }
.home-checklist {
  max-width: 52rem;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto 2rem;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}
.home-checklist-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.home-checklist-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.5rem;
}
.home-checklist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
}
.home-checklist-item.is-done { opacity: 0.72; }
.home-checklist-title { font-weight: 600; }
.home-checklist-status { color: var(--muted); font-size: 0.9rem; }
.report-filters { gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.report-output { margin-top: 1rem; }
.report-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.report-table th, .report-table td { border: 1px solid var(--border); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top; }
.adm-playbook-phase { margin-bottom: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.75rem; }
.adm-create-row { /* alias kept for older markup */ }
.roadmap-timeline { margin: 0.5rem 0; padding-left: 1.2rem; }
.detail-roadmap-timeline { margin: 1rem 0; padding: 0.75rem 1rem; border: 1px solid var(--border, rgba(127,127,127,0.25)); border-radius: var(--radius-md, 8px); background: var(--surface-2, rgba(127,127,127,0.06)); }
.detail-roadmap-timeline .roadmap-timeline li { margin: 0.35rem 0; }
.landscape-phase-f { margin-left: 0.5rem; align-self: center; }
.landscape-horizon-hint { margin-top: 0.5rem; }
.viewpoints-save-row input { min-width: 12rem; flex: 1; }
.solutions-arch-toolbar { margin-bottom: 0.75rem; }

@media (max-width: 900px) { .split-editor { grid-template-columns: 1fr; } }

/* ── Design system (Admin → Design system) ── */
.design-system { display: flex; flex-direction: column; gap: var(--space-6); }
.ds-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.ds-control-group { display: flex; flex-direction: column; gap: var(--space-2); }
.ds-control-label { font-size: var(--text-sm); color: var(--muted); }
.ds-accent-row { display: flex; flex-wrap: wrap; gap: 6px; max-width: 540px; }
.ds-accent-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.ds-accent-swatch.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.ds-section { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.ds-section-title { margin: 0 0 var(--space-1); font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.ds-section-desc { margin: 0 0 var(--space-3); color: var(--muted); font-size: var(--text-sm); max-width: 70ch; }
.ds-swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--space-3); }
.ds-swatch {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3);
}
.ds-swatch-chip { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); flex-shrink: 0; }
.ds-swatch-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--text-sm); }
.ds-swatch-val { color: var(--muted); font-size: var(--text-xs); font-family: var(--font-mono); }
.ds-token-copy { background: none; border: none; padding: 0; cursor: pointer; text-align: left; }
.ds-token-copy code { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent-readable); }
.ds-token-copy:hover code { text-decoration: underline; }
.ds-inline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
/* Give stacked inline rows (e.g. the button variants) room to breathe */
.ds-section-body > .ds-inline { gap: var(--space-4); }
.ds-section-body > .ds-inline + .ds-inline { margin-top: var(--space-4); }
/* Space action buttons below specimen class chips (e.g. Modal "Open example modal"). */
.ds-specimen + .ds-inline { margin-top: var(--space-4); }
.ds-type-list { display: flex; flex-direction: column; }
.ds-type-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-4); border-bottom: 1px dashed var(--border); padding: var(--space-2) 0;
}
.ds-type-sample { color: var(--text); line-height: var(--leading-tight); }
.ds-type-meta { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.ds-space-list { display: flex; flex-direction: column; gap: var(--space-2); }
.ds-space-row { display: flex; align-items: center; gap: var(--space-3); }
.ds-space-bar { height: 14px; background: var(--accent); border-radius: var(--radius-sm); flex-shrink: 0; }
.ds-space-meta { display: flex; gap: var(--space-2); align-items: center; }
.ds-radius-list { align-items: flex-start; }
.ds-radius-item, .ds-shadow-item { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); font-size: var(--text-xs); }
.ds-radius-box { width: 64px; height: 64px; background: var(--surface2); border: 1px solid var(--border); }
.ds-shadow-box { width: 64px; height: 64px; background: var(--surface); border-radius: var(--radius-md); }
.ds-nav-demo {
  max-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}
.ds-nav-demo .nav-group { margin-bottom: 0; }
.ds-disclosure-demo { max-width: 240px; }
.ds-card-demo {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
  max-width: 640px;
  align-items: start;
}
.ds-card-demo .card { cursor: default; }
.ds-card-demo .card:hover { transform: none; border-color: var(--border); }
.ds-card-demo .card-folder:hover { border-color: var(--folder-border); }
/* Cards shown as reference specimens don't lift/hover so the demo stays static. */
.ds-specimen .card { cursor: default; }
.ds-specimen .card:hover { transform: none; border-color: var(--border); }
.ds-specimen .card-folder:hover { border-color: var(--folder-border); }
.ds-form-demo { max-width: 520px; }

/* Layout dimension tokens (chrome widths + FAB sizing) */
.ds-dim-list { display: flex; flex-direction: column; gap: var(--space-3); }
.ds-dim-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 2fr) minmax(0, 2fr); align-items: center; gap: var(--space-3); }
.ds-dim-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ds-dim-track { height: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.ds-dim-bar { display: block; height: 100%; background: var(--accent); border-radius: var(--radius-pill); }
.ds-dim-note { font-size: var(--text-xs); color: var(--muted); line-height: var(--leading-tight); }

/* Table demo */
.ds-table-demo { max-width: 640px; overflow-x: auto; }

@media (max-width: 640px) {
  .ds-dim-row { grid-template-columns: 1fr; }
  .ds-dim-track { display: none; }
}

/* Icon catalogue — responsive grid of icon swatches */
.ds-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-3);
}
.ds-icon-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.ds-icon-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-soft, var(--surface2));
  color: var(--accent-readable);
}
.ds-icon-swatch svg { width: 24px; height: 24px; display: block; }
.ds-icon-label { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text); }
.ds-icon-usage { font-size: var(--text-xs); color: var(--muted); line-height: var(--leading-tight); overflow-wrap: anywhere; word-break: break-word; hyphens: auto; max-width: 100%; }

.ds-modal-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  background: var(--overlay);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.ds-modal-card {
  width: min(420px, 100%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ds-modal-card .modal-body { max-height: none; }
.ds-demo-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(480px, 92vw);
}
.ds-demo-dialog::backdrop { background: var(--overlay); }

/* Design-system demos that neutralise fixed positioning so components render inline */
.ds-search-demo { margin: 0; max-width: 520px; }
.ds-banner-demo { border: 1px solid var(--error-border); border-radius: var(--radius); }
.ds-toast-stack { display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; }
.ds-toast-stack .toast { position: static; inset: auto; max-width: none; }
.ds-menu-demo { display: flex; }
.ds-menu-demo .context-menu { position: static; z-index: auto; }
.ds-fab-demo {
  display: flex;
  justify-content: center;
  padding: var(--space-5);
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.ds-fab-demo .archie-fab { position: relative; inset: auto; }

/* Design-system group headings */
.ds-group-title {
  margin: var(--space-6) 0 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-readable);
}
.ds-group-title:first-child { margin-top: 0; }

/* Line-height samples */
.ds-lead-row { display: flex; flex-direction: column; gap: var(--space-1); border-bottom: 1px dashed var(--border); padding: var(--space-2) 0; }
.ds-lead-sample { color: var(--text); font-size: var(--text-sm); max-width: 62ch; }

/* Motion previews */
.ds-motion-list { display: flex; flex-direction: column; gap: var(--space-3); }
.ds-motion-row { display: flex; align-items: center; gap: var(--space-4); }
.ds-motion-track {
  flex: 1; max-width: 220px; height: 28px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 3px; overflow: hidden;
}
.ds-motion-box { display: block; width: 22px; height: 22px; border-radius: var(--radius-pill); background: var(--accent); }
.ds-motion-row:hover .ds-motion-box { transform: translateX(190px); }

/* Z-index list */
.ds-z-list { display: flex; flex-direction: column; gap: var(--space-1); }
.ds-z-row { display: flex; align-items: center; gap: var(--space-3); }

/* Breakpoints */
.ds-bp-list { display: flex; flex-direction: column; gap: var(--space-2); }
.ds-bp-row {
  display: grid;
  grid-template-columns: 3.5rem 4.5rem minmax(80px, 1fr) 2fr;
  align-items: center;
  gap: var(--space-3);
}
.ds-bp-name { font-weight: var(--weight-semibold, 600); color: var(--text); font-size: var(--text-sm); }
.ds-bp-value { font-family: ui-monospace, monospace; font-size: var(--text-xs); color: var(--muted); }
.ds-bp-track { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.ds-bp-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.ds-bp-note { font-size: var(--text-xs); color: var(--muted); line-height: var(--leading-tight); }
@media (max-width: 640px) {
  .ds-bp-row { grid-template-columns: 3rem 4rem 1fr; }
  .ds-bp-note { grid-column: 1 / -1; }
}

/* Logo showcase */
.ds-logo-row { display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; }
.ds-logo-row .ea-diamond-logo--lg { margin: 0; }

/* Animated title demo */
.ds-anim-demo { display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; }
.ds-anim-demo .home-title { font-size: var(--text-2xl); }
.ds-anim-viewheader { margin: 0; padding: 0; border: none; background: none; }
.ds-anim-viewheader h1 { margin: 0; }

/* Sub-group labels within a section (e.g. Badges & counts groupings) */
.ds-subgroup-label {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.ds-section-body > .ds-subgroup-label:first-child { margin-top: 0; }

/* State notes */
.ds-state-note { margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--text-sm); max-width: 70ch; }
.ds-state-note--inline { margin: 0; }
.ds-state-note code { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent-readable); }

/* Per-element class/token references — same neat monospace look as .ds-token-copy
   (accent code, no chip fill). Click-to-copy, keyboard-focusable buttons. */
.ds-ref {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
  color: var(--accent-readable);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0;
  white-space: nowrap;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.ds-ref + .ds-ref { margin-left: 0.65rem; }

button.ds-ref,
.ds-ref--copy {
  margin: 0;
  font: inherit;
  font-family: var(--font-mono);
  cursor: pointer;
  text-align: left;
}
button.ds-ref code,
.ds-ref--copy code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: inherit;
}
button.ds-ref:hover code,
.ds-ref--copy:hover code { text-decoration: underline; }
button.ds-ref:focus-visible,
.ds-ref--copy:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Specimen: demo stacked above its selector ref(s), with clear gaps between siblings. */
.ds-specimen {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
  max-width: 100%;
}
.ds-specimen-demo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); max-width: 100%; }
.ds-specimen-refs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  max-width: 100%;
  padding-top: 1px;
}

/* Wrapping row of specimens (e.g. button / pill variants). */
.ds-specimen-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-5) var(--space-5);
}
/* Vertical rhythm for stacked specimens / rows — NOT for siblings inside a
   horizontal specimen row or a CSS grid (those use gap). The adjacent-sibling
   margin otherwise staircases every 2nd+ item in a wrap row. */
.ds-specimen-row + .ds-state-note,
.ds-specimen + .ds-state-note,
.ds-specimen + .ds-specimen,
.ds-specimen + .ds-specimen-row,
.ds-specimen-row + .ds-specimen,
.ds-specimen-row + .ds-specimen-row { margin-top: var(--space-5); }
.ds-specimen-row > .ds-specimen,
.ds-form-demo > .ds-specimen,
.form-grid > .ds-specimen {
  margin-top: 0;
}

/* Let block-level specimens (cards, tables, banners…) fill the available width. */
.ds-specimen--block { display: flex; align-items: stretch; width: 100%; }
.ds-specimen--block > .ds-specimen-demo { display: block; width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .ds-motion-row:hover .ds-motion-box { transform: none; }
}

/* ── Personal notes ─────────────────────────────────────────────────────── */
.notes-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
  margin-top: var(--space-4);
}
.notes-list-pane {
  grid-column: 1; grid-row: 1;
  display: flex; flex-direction: column; gap: var(--space-2);
  min-width: 0;
}
.notes-search {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
}
.notes-list { display: flex; flex-direction: column; gap: var(--space-2); }
.notes-list-empty { padding: var(--space-3); font-size: var(--text-sm); }
.note-list-item {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.note-list-item:hover { border-color: var(--accent); }
.note-list-item.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.note-list-title { font-weight: var(--weight-semibold); color: var(--text); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-list-snippet { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-list-date { color: var(--muted); font-size: var(--text-xs); }

.notes-editor {
  grid-column: 2; grid-row: 1;
  display: flex; flex-direction: column; gap: var(--space-3);
  min-width: 0;
}
.notes-empty {
  grid-column: 2; grid-row: 1;
  align-self: stretch;
}
.note-title-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.note-mode-tabs { align-self: flex-start; }
.note-body-input {
  width: 100%;
  min-height: 340px;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  resize: vertical;
}
.note-preview {
  min-height: 340px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.note-editor-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
}
.note-status { min-height: 1em; }
.note-editor-actions { display: flex; gap: var(--space-2); }

@media (max-width: 720px) {
  .notes-layout { grid-template-columns: 1fr; }
  .notes-list-pane, .notes-editor, .notes-empty { grid-column: 1; grid-row: auto; }
  .note-body-input, .note-preview { min-height: 240px; }
}

/* ── Community forum ── */
.forum-new-topic {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.forum-topic-title-input,
.forum-topic-body-input,
.forum-comment-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
}
.forum-topic-title-input { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.forum-topic-body-input,
.forum-comment-input {
  min-height: 120px;
  font-family: var(--font-mono);
  line-height: var(--leading-relaxed);
  resize: vertical;
}
.forum-form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

.forum-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.forum-empty { padding: var(--space-4); }

.forum-topic-card,
.forum-detail-topic,
.forum-comment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.forum-topic-card { transition: border-color var(--transition-fast); }
.forum-topic-card:hover { border-color: var(--accent); }
.forum-topic-main,
.forum-detail-main,
.forum-comment-main { min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }

.forum-topic-open {
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--accent-readable);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
.forum-topic-open:hover { text-decoration: underline; }
.forum-topic-open:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

.forum-topic-meta,
.forum-comment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--text-xs);
}
.forum-author { color: var(--text); font-weight: var(--weight-medium); }

/* Vote controls (icon-only buttons + net score) */
.forum-votes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-width: 2.25rem;
}
.forum-vote {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 1.75rem;
  padding: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.forum-vote svg { width: 1rem; height: 1rem; display: block; }
.forum-vote:hover { color: var(--text); border-color: var(--accent); }
.forum-vote:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.forum-vote.active,
.forum-vote[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.forum-score {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  min-width: 1.25rem;
  text-align: center;
}

.forum-back { align-self: flex-start; margin-bottom: var(--space-4); }
.forum-detail-topic { margin-bottom: var(--space-4); }
.forum-detail-title { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text); }
.forum-body { color: var(--text); }
.forum-detail-actions,
.forum-comment-actions { display: flex; justify-content: flex-end; }

.forum-comments-heading {
  margin: var(--space-4) 0 var(--space-3);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
}
.forum-comments { display: flex; flex-direction: column; gap: var(--space-3); }
.forum-add-comment {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .forum-topic-card,
  .forum-detail-topic,
  .forum-comment { padding: var(--space-3); gap: var(--space-2); }
}

/* Design-system demos for the forum components */
.ds-vote-demo { display: flex; flex-wrap: wrap; gap: var(--space-5, 1.5rem); align-items: flex-start; }
.ds-vote-demo-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.ds-vote-demo-item .ds-specimen { align-items: center; }
.ds-forum-demo { margin-top: 0; }

/* Chrome popovers: My drafts + Notifications */
.chrome-popover {
  position: fixed;
  z-index: var(--z-overlay, 1000);
  max-height: min(28rem, calc(100vh - 2rem));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.chrome-popover.hidden { display: none !important; }
.chrome-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chrome-popover-title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
}
.chrome-popover-body {
  overflow: auto;
  padding: var(--space-2);
  min-height: 4rem;
}
.chrome-popover-loading {
  margin: var(--space-3);
  text-align: center;
}
.chrome-popover-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-5) var(--space-4);
  min-height: 8rem;
}
.chrome-popover-empty .empty {
  margin: 0;
  padding: 0;
  max-width: none;
}
.chrome-popover-hint {
  margin: var(--space-2) 0 0;
  max-width: 18rem;
  line-height: 1.45;
}
.chrome-popover-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-1);
}
.chrome-popover-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 8px);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.chrome-popover-item:hover {
  background: var(--surface2);
  border-color: var(--border);
}
.chrome-popover-item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.chrome-popover-item--unread {
  background: var(--accent-soft);
  border-color: transparent;
}
.chrome-popover-item--unread:hover {
  border-color: var(--accent);
}
.chrome-popover-item-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  line-height: 1.35;
}

/* Admin → OpenAPI explorer (Swagger UI) */
.openapi-explorer-status:empty {
  display: none;
}
.openapi-explorer {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  background: var(--surface);
  overflow: hidden;
}
.openapi-explorer .swagger-ui {
  font-family: inherit;
}
.openapi-explorer .swagger-ui .topbar,
.openapi-explorer .swagger-ui .information-container {
  display: none;
}
.openapi-explorer .swagger-ui .wrapper {
  padding: 0.75rem 1rem 1.25rem;
}
.openapi-explorer .swagger-ui .scheme-container {
  background: var(--surface2);
  box-shadow: none;
  border-bottom: 1px solid var(--border);
  margin: 0;
  padding: 0.75rem 1rem;
}
.openapi-explorer .swagger-ui .opblock-tag,
.openapi-explorer .swagger-ui .opblock .opblock-summary-description,
.openapi-explorer .swagger-ui .opblock .opblock-summary-path,
.openapi-explorer .swagger-ui .opblock .opblock-summary-method,
.openapi-explorer .swagger-ui .tab li,
.openapi-explorer .swagger-ui .response-col_status,
.openapi-explorer .swagger-ui .response-col_description,
.openapi-explorer .swagger-ui table thead tr td,
.openapi-explorer .swagger-ui table thead tr th,
.openapi-explorer .swagger-ui .parameter__name,
.openapi-explorer .swagger-ui .parameter__type,
.openapi-explorer .swagger-ui .model-title,
.openapi-explorer .swagger-ui .model,
.openapi-explorer .swagger-ui label,
.openapi-explorer .swagger-ui .btn,
.openapi-explorer .swagger-ui select,
.openapi-explorer .swagger-ui input,
.openapi-explorer .swagger-ui textarea {
  font-family: inherit;
}
.openapi-explorer .swagger-ui .opblock-tag {
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.openapi-explorer .swagger-ui .opblock {
  border-radius: var(--radius-sm, 6px);
  box-shadow: none;
}
.openapi-explorer .swagger-ui .opblock .opblock-summary-path,
.openapi-explorer .swagger-ui .opblock .opblock-summary-description {
  color: var(--text);
}
.openapi-explorer .swagger-ui .opblock-description-wrapper p,
.openapi-explorer .swagger-ui .opblock-external-docs-wrapper p,
.openapi-explorer .swagger-ui .opblock-title_normal p,
.openapi-explorer .swagger-ui .response-col_description p,
.openapi-explorer .swagger-ui .markdown p,
.openapi-explorer .swagger-ui .renderedMarkdown p {
  color: var(--text-muted, var(--muted, #64748b));
}
.openapi-explorer .swagger-ui section.models {
  border-color: var(--border);
}
.openapi-explorer .swagger-ui section.models h4 {
  color: var(--text);
}
.openapi-explorer .swagger-ui .model-box,
.openapi-explorer .swagger-ui .model-toggle::after {
  background: var(--surface2);
}
.openapi-explorer .swagger-ui .highlight-code,
.openapi-explorer .swagger-ui .highlight-code > .microlight,
.openapi-explorer .swagger-ui .microlight {
  background: var(--openapi-code-bg, var(--bg)) !important;
  color: var(--openapi-code-fg, var(--text)) !important;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  padding: 0.75rem 1rem !important;
  border-radius: var(--radius-sm);
  border: var(--border-width, 1px) solid var(--border);
  box-shadow: none;
}
.openapi-explorer .swagger-ui .microlight span {
  color: inherit !important;
}
[data-theme="high-contrast"] .openapi-explorer .swagger-ui .highlight-code,
[data-theme="high-contrast"] .openapi-explorer .swagger-ui .microlight {
  border-width: 2px;
}
/* Swagger pastels + syntax tokens = unreadable; use app surfaces instead */
.openapi-explorer .swagger-ui .opblock {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none;
}
.openapi-explorer .swagger-ui .opblock .opblock-summary {
  background: var(--surface2);
  border-color: var(--border);
}
.openapi-explorer .swagger-ui .opblock .opblock-body,
.openapi-explorer .swagger-ui .opblock .opblock-section {
  background: var(--surface);
}
.openapi-explorer .swagger-ui .opblock.opblock-get,
.openapi-explorer .swagger-ui .opblock.opblock-post,
.openapi-explorer .swagger-ui .opblock.opblock-put,
.openapi-explorer .swagger-ui .opblock.opblock-delete,
.openapi-explorer .swagger-ui .opblock.opblock-patch,
.openapi-explorer .swagger-ui .opblock.opblock-head,
.openapi-explorer .swagger-ui .opblock.opblock-options {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}
.openapi-explorer .swagger-ui .responses-inner,
.openapi-explorer .swagger-ui .response-col_description,
.openapi-explorer .swagger-ui .response-col_description__inner,
.openapi-explorer .swagger-ui .response .response-col_status {
  color: var(--text);
}
.openapi-explorer .swagger-ui .response-control-media-type__title,
.openapi-explorer .swagger-ui .response-control-media-type__accept-message {
  color: var(--muted);
}
.openapi-explorer .swagger-ui .tab li button.tablinks {
  color: var(--muted);
}
.openapi-explorer .swagger-ui .tab li button.tablinks.active {
  color: var(--text);
}
.openapi-explorer .swagger-ui .btn.execute {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.openapi-explorer .swagger-ui .btn.execute:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}
[data-theme="high-contrast"] .openapi-explorer .swagger-ui .btn.execute,
[data-theme="high-contrast"] .openapi-explorer .swagger-ui .btn.execute:hover {
  color: var(--on-accent);
  border-width: 2px;
}
[data-theme="high-contrast"] .openapi-explorer .swagger-ui .filter-container .operation-filter-input,
[data-theme="high-contrast"] .openapi-explorer .swagger-ui select,
[data-theme="high-contrast"] .openapi-explorer .swagger-ui input,
[data-theme="high-contrast"] .openapi-explorer .swagger-ui textarea {
  border-width: 2px;
  background: var(--input-bg, var(--bg));
  color: var(--text);
}
.openapi-explorer .swagger-ui .filter-container .operation-filter-input {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm, 6px);
}

/* OpenAPI explorer — readable on narrow viewports (Swagger default flex crushes). */
@media (max-width: 720px) {
  .openapi-explorer {
    overflow-x: auto;
  }
  .openapi-explorer .swagger-ui .wrapper {
    padding: 0.65rem 0.65rem 1rem;
  }
  .openapi-explorer .swagger-ui .scheme-container {
    padding: 0.65rem;
  }
  .openapi-explorer .swagger-ui .opblock-tag {
    font-size: 1.05rem;
    padding: 0.65rem 0;
  }
  .openapi-explorer .swagger-ui .opblock {
    margin: 0 0 0.55rem;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.65rem 0.7rem;
    background: var(--surface2) !important;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary-control {
    all: unset;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "method path"
      ". desc";
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.3rem;
    flex: 1 1 auto;
    min-width: 0;
    cursor: pointer;
    color: inherit;
    font: inherit;
    text-align: left;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary-method {
    grid-area: method;
    margin: 0;
    min-width: 3.1rem;
    padding: 0.28rem 0.35rem;
    font-size: 0.68rem;
    line-height: 1.2;
    text-align: center;
    border-radius: var(--radius-sm, 4px);
    align-self: start;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary-path-description-wrapper {
    display: contents;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary-path,
  .openapi-explorer .swagger-ui .opblock .opblock-summary-path__deprecated {
    grid-area: path;
    display: block;
    margin: 0;
    max-width: none !important;
    padding: 0;
    font-size: 0.82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary-description {
    grid-area: desc;
    margin: 0;
    padding: 0;
    font-size: 0.78rem;
    line-height: 1.35;
    word-break: break-word;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary-control > .arrow,
  .openapi-explorer .swagger-ui .opblock .opblock-summary .arrow {
    flex: 0 0 auto;
    margin: 0.15rem 0 0;
    align-self: start;
  }
  .openapi-explorer .swagger-ui .opblock .authorization__btn {
    flex: 0 0 auto;
    margin: 0.1rem 0 0;
    padding: 0.15rem;
    align-self: start;
  }
  .openapi-explorer .swagger-ui .opblock .opblock-summary .view-line-link {
    display: none;
  }
  .openapi-explorer .swagger-ui .filter-container .operation-filter-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .openapi-explorer .swagger-ui table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }
  .openapi-explorer .swagger-ui .parameters-col_description,
  .openapi-explorer .swagger-ui .parameters-col_name {
    padding: 0.5rem 0.35rem;
  }
  .openapi-explorer .swagger-ui .btn {
    min-height: 2.25rem;
  }
}

/* ── Governance calendar (month + agenda) ── */
.cal-toolbar { align-items: center; }
.cal-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.cal-month-label {
  margin: 0;
  min-width: 10rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.waiver-expiry-note {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--danger, #c44) 35%, var(--border));
  background: color-mix(in srgb, var(--danger, #c44) 10%, var(--surface));
}
.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.9fr);
  gap: var(--space-4);
  align-items: start;
}
.cal-month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}
.cal-dow-row,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}
.cal-dow {
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--muted);
  padding: var(--space-2) 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-cell {
  min-height: 5.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  padding: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.cal-cell:hover,
.cal-cell:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.cal-cell-outside {
  background: transparent;
  border-color: transparent;
  cursor: default;
  min-height: 5.5rem;
}
.cal-cell.is-today {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.cal-cell.is-selected {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: var(--accent);
}
.cal-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}
.cal-day-num {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  line-height: 1.2;
}
.cal-cell.is-today .cal-day-num {
  color: var(--accent-readable, var(--accent));
}
.cal-day-add {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cal-cell:hover .cal-day-add,
.cal-cell:focus-within .cal-day-add,
.cal-cell.is-selected .cal-day-add {
  opacity: 1;
}
.cal-day-add:hover,
.cal-day-add:focus-visible {
  color: var(--accent-readable, var(--accent));
  outline: none;
}
.cal-cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  flex: 1;
}
.cal-chip {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  font-size: 0.65rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
}
.cal-chip-board {
  background: color-mix(in srgb, #3b82f6 28%, var(--surface));
}
.cal-chip-waiver {
  background: color-mix(in srgb, var(--danger, #c44) 28%, var(--surface));
}
.cal-chip:hover,
.cal-chip:focus-visible {
  filter: brightness(1.08);
  outline: none;
}
.cal-more {
  font-size: 0.65rem;
  color: var(--muted);
  padding-left: 0.2rem;
}
.cal-agenda {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  min-height: 12rem;
  position: sticky;
  top: var(--space-3);
}
.cal-agenda-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.cal-agenda-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.cal-agenda-empty { margin: 0; }
.cal-agenda-item {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.cal-agenda-item:first-child { border-top: none; padding-top: 0; }
.cal-agenda-item:hover .cal-agenda-title,
.cal-agenda-item:focus-visible .cal-agenda-title {
  color: var(--accent-readable, var(--accent));
}
.cal-agenda-item:focus-visible { outline: none; }
.cal-agenda-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  padding-top: 0.15rem;
}
.cal-agenda-kind {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.cal-agenda-waiver .cal-agenda-kind { color: var(--danger, #c44); }
.cal-agenda-board .cal-agenda-kind { color: #3b82f6; }
.cal-agenda-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  margin-bottom: 0.25rem;
}
@media (max-width: 900px) {
  .cal-layout {
    grid-template-columns: 1fr;
  }
  .cal-agenda { position: static; }
  .cal-cell { min-height: 4.25rem; }
}
@media (max-width: 700px) {
  .cal-day-add { opacity: 1; }
  .cal-chip { font-size: 0.6rem; }
  .cal-agenda-item { grid-template-columns: 4.5rem 1fr; }
}

/* ── System status (mirrors /healthz public page; theme-aware for Design system) ── */
.status-card {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-4) var(--space-4);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.status-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  text-decoration: none;
  color: inherit;
}

.status-brand .ea-diamond-logo {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--accent);
  flex-shrink: 0;
}

.status-brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: clamp(1.55rem, 3.2vw, 1.95rem);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  padding: 0.1em 0.4em;
}

.status-kicker {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  line-height: var(--leading-tight);
  font-family: var(--font-display);
  color: var(--text);
}

.status-state {
  margin: 0 0 var(--space-3);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.status-pill--operational {
  color: var(--pill-success-text, var(--success));
  background: var(--pill-success-bg);
  border-color: var(--success-border);
}

.status-pill--degraded {
  color: var(--draft-text);
  background: var(--draft-bg);
  border-color: var(--draft-border);
}

.status-pill--maintenance {
  color: var(--pill-warn-text, var(--warn));
  background: var(--pill-warn-bg);
  border-color: var(--draft-border);
}

.status-checked {
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
}

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: left;
}

.status-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface2);
}

.status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 18%, transparent);
}

.status-row--ok .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent);
}

.status-row--down .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent);
}

.status-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.status-copy strong {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.status-detail {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  overflow-wrap: anywhere;
}

.status-badge {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-row--ok .status-badge { color: var(--pill-success-text, var(--success)); }
.status-row--down .status-badge { color: var(--error-text); }

.status-note {
  margin: var(--space-4) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  text-align: left;
}
