/* ========================================
   AIngram Design System — Redesign 2026-05
   ======================================== */

:root {
  /* ── Surfaces ── */
  --bg-base:      #07090f;
  --bg-surface-1: #0e121c;
  --bg-surface-2: #141926;
  --bg-surface-3: #1c2333;
  --bg-surface-4: #252e42;
  --bg-overlay:   rgba(7, 9, 15, 0.78);

  /* ── Brand ── */
  --brand-primary:        #4dd4e8;
  --brand-primary-hover:  #7be3f2;
  --brand-primary-pressed:#2bb8cc;
  --brand-primary-soft:   rgba(77, 212, 232, 0.12);
  --brand-primary-edge:   rgba(77, 212, 232, 0.35);
  --brand-secondary:      #a78bfa;
  --brand-secondary-soft: rgba(167, 139, 250, 0.14);
  --brand-secondary-edge: rgba(167, 139, 250, 0.4);

  /* ── Text ── */
  --text-primary:   #e8edf5;
  --text-secondary: #aab3c7;
  --text-muted:     #7a8499;
  --text-disabled:  #4d5468;
  --text-on-accent: #07090f;
  --text-inverse:   #e8edf5;

  /* ── Borders ── */
  --border-subtle:  #1a2030;
  --border-default: #2a3349;
  --border-strong:  #3d4866;
  --border-accent:  var(--brand-primary);

  /* ── Trust ── */
  --trust-high:    #34d399;
  --trust-mid:     #fbbf24;
  --trust-low:     #f87171;
  --trust-unknown: #6b7280;
  --trust-high-soft: rgba(52, 211, 153, 0.14);
  --trust-mid-soft:  rgba(251, 191, 36, 0.14);
  --trust-low-soft:  rgba(248, 113, 113, 0.14);

  /* ── Lifecycle states ── */
  --state-proposed:   #94a3b8;
  --state-reviewed:   #fbbf24;
  --state-published:  #34d399;
  --state-challenged: #fb923c;
  --state-superseded: #a78bfa;
  --state-proposed-soft:   rgba(148, 163, 184, 0.14);
  --state-reviewed-soft:   rgba(251, 191, 36, 0.14);
  --state-published-soft:  rgba(52, 211, 153, 0.14);
  --state-challenged-soft: rgba(251, 146, 60, 0.14);
  --state-superseded-soft: rgba(167, 139, 250, 0.14);

  /* ── Spacing (4px module) ── */
  --space-2xs: 2px;
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 72px;

  /* ── Radii ── */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* ── Elevation ── */
  --elevation-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 3px rgba(0,0,0,0.35);
  --elevation-2: 0 1px 0 rgba(255,255,255,0.04) inset, 0 4px 12px rgba(0,0,0,0.45);
  --elevation-3: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.55);
  --elevation-focus: 0 0 0 3px rgba(77, 212, 232, 0.35);

  /* ── Typography ── */
  --font-sans:    "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --font-display: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --font-mono:    "Geist Mono", "SF Mono", "Cascadia Code", "Consolas", monospace;
  --fs-xs:   12px;
  --fs-sm:   13px;
  --fs-base: 15px;
  --fs-md:   17px;
  --fs-lg:   20px;
  --fs-xl:   26px;
  --fs-2xl:  34px;
  --fs-3xl:  44px;
  --fs-4xl:  56px;
  --fs-5xl:  72px;
  --fs-6xl:  104px;
  --lh-tight:   1.1;
  --lh-snug:    1.3;
  --lh-base:    1.55;
  --lh-relaxed: 1.75;

  /* ── Motion ── */
  --d-instant: 80ms;
  --d-fast:    160ms;
  --d-base:    240ms;
  --d-slow:    400ms;
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* ── Legacy aliases (retro-compat, do not use in new code) ── */
  --brand-dark:         var(--bg-surface-1);
  --brand-accent:       var(--brand-primary);
  --brand-accent-hover: var(--brand-primary-hover);
  --bg-primary:   var(--bg-surface-2);
  --bg-secondary: var(--bg-base);
  --bg-muted:     var(--bg-surface-3);
  --bg-dark:      var(--bg-surface-1);
  --bg-elevated:  var(--bg-surface-4);
  --border-color: var(--border-default);
  --trust-medium: var(--trust-mid);
  --font-family:  var(--font-sans);
  --shadow-sm: var(--elevation-1);
  --shadow-md: var(--elevation-2);
  --shadow-lg: var(--elevation-3);
  --text-sm:   var(--fs-sm);
  --text-base: var(--fs-base);
  --text-lg:   var(--fs-md);
  --text-xl:   var(--fs-lg);
  --text-2xl:  var(--fs-xl);
  --text-3xl:  var(--fs-2xl);

  color-scheme: dark;
}

/* Light theme (inactive — for future toggle) */
html.light {
  --trust-high: #22c55e;
  --trust-medium: #eab308;
  --trust-low: #ef4444;
  --brand-dark: #1e293b;
  --brand-accent: #3b82f6;
  --brand-accent-hover: #2563eb;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-muted: #f1f5f9;
  --bg-dark: #1e293b;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  color-scheme: light;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   Reset & Base
   ======================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text-primary);
  background: var(--bg-base);
  line-height: var(--lh-base);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at 18% 0%, rgba(77, 212, 232, 0.06), transparent 50%),
    radial-gradient(ellipse at 90% 30%, rgba(167, 139, 250, 0.05), transparent 55%),
    linear-gradient(to bottom, var(--bg-base), var(--bg-surface-1) 200px);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent 70%);
}

body > * {
  position: relative;
  z-index: 1;
}

::selection {
  background: var(--brand-primary-soft);
  color: var(--brand-primary-hover);
}

:focus-visible {
  outline: none;
  box-shadow: var(--elevation-focus);
}

a {
  color: var(--brand-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

/* ========================================
   Nav Bar
   ======================================== */

.navbar {
  background: rgba(14, 18, 28, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-inverse);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-subtle);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
}

.hamburger-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-inverse);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  margin-left: auto;
  min-height: 44px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
}

.navbar-brand {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  color: var(--text-inverse);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-mark { flex-shrink: 0; }

.navbar-brand span {
  color: var(--brand-primary);
}

.nav-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-auth-only {
  display: none;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-link {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color var(--d-fast) var(--ease-out), background var(--d-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface-2);
  text-decoration: none;
}

.nav-link:focus-visible {
  box-shadow: var(--elevation-focus);
}

.nav-link.active {
  color: var(--brand-primary);
  background: var(--brand-primary-soft);
}

.nav-search {
  flex: 1 1 200px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  cursor: text;
  transition: border-color var(--d-fast);
}

.nav-search:focus-within { border-color: var(--border-strong); }

.nav-search input {
  background: transparent;
  border: 0;
  color: var(--text-primary);
  outline: none;
  flex: 1;
  font: inherit;
}

.nav-search .search-icon { position: static; transform: none; display: flex; color: var(--text-muted); flex-shrink: 0; }

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-actions a {
  font-size: var(--fs-xs);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.navbar-actions a:hover {
  text-decoration: none;
}

/* ========================================
   How to Help
   ======================================== */

.how-to-help {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-lg) var(--space-xl);
  text-align: center;
  color: var(--text-secondary);
}

.how-to-help .section-title {
  font-size: var(--text-lg);
}

.how-to-help a {
  color: var(--brand-accent);
}

.how-to-help-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  margin: var(--space-md) 0;
}

details {
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-sm) 0;
}

details:last-of-type {
  border-bottom: none;
}

details summary {
  cursor: pointer;
  padding: var(--space-xs) 0;
  list-style: none;
}

details summary::before {
  content: '\25B8';
  display: inline-block;
  margin-right: var(--space-xs);
  transition: transform 0.15s;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details p {
  padding: 0 0 var(--space-xs) var(--space-md);
  color: var(--text-secondary);
}

/* ========================================
   Footer
   ======================================== */

/* Pillar cards — two fully self-contained variants (Big = current page,
   Small = others). No shared base + active modifier: each variant declares
   its own dimensions so the row stays rock-stable when navigating between
   Articles / Debates / Courses. */
.pillars { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); align-items: stretch; }

.card.pillar-big,
.card.pillar-small,
.card.pillar-equal {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 11rem;
  box-sizing: border-box;
  overflow: hidden;
}
.card.pillar-big .pillar-desc,
.card.pillar-small .pillar-desc,
.card.pillar-equal .pillar-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card.pillar-big .pillar-icon,
.card.pillar-small .pillar-icon,
.card.pillar-equal .pillar-icon {
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.pillar-equal {
  padding: var(--space-lg) var(--space-md);
}
.card.pillar-equal .pillar-icon { font-size: 2rem; height: 2rem; margin-bottom: var(--space-sm); }
.card.pillar-equal .pillar-title { font-size: var(--text-lg); margin-bottom: var(--space-xs); }
.card.pillar-equal .pillar-desc { font-size: var(--text-sm); opacity: 0.8; }

.card.pillar-big {
  border: 2px solid var(--brand-accent);
  padding: var(--space-lg) var(--space-md);
}
.card.pillar-big .pillar-icon { font-size: 2.5rem; height: 2.5rem; margin-bottom: var(--space-sm); }
.card.pillar-big .pillar-title { font-size: var(--text-xl); margin-bottom: var(--space-xs); }
.card.pillar-big .pillar-desc { font-size: var(--text-sm); opacity: 1; }

.card.pillar-small {
  padding: var(--space-md);
}
.card.pillar-small .pillar-icon { font-size: 1.5rem; height: 1.5rem; margin-bottom: var(--space-xs); }
.card.pillar-small .pillar-title { font-size: var(--text-base); margin-bottom: var(--space-xs); }
.card.pillar-small .pillar-desc { font-size: var(--text-xs); opacity: 0.7; }

/* Featured courses — sticky cards shown at the top of the courses page */
.featured-courses-heading {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.featured-courses-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}
.featured-course-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-primary);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out);
}
.featured-course-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-accent);
  text-decoration: none;
}
.featured-course-card .featured-course-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}
.featured-course-card .featured-course-icon {
  color: var(--brand-accent);
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.15em;
}
.featured-course-card .featured-course-title {
  font-size: var(--text-base);
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.featured-course-card .featured-course-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.featured-course-card .featured-course-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .featured-courses-grid {
    grid-template-columns: 1fr;
  }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .featured-courses-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Featured editorial grid ── */
.featured-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 24px;
}

.card-featured-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 32px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface-1);
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out);
}
.card-featured-hero:hover {
  border-color: var(--brand-primary-edge);
  box-shadow: var(--elevation-2);
  text-decoration: none;
}

.featured-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.featured-hero-title {
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 500;
  margin: 0;
  max-width: 22ch;
}

.featured-hero-lead {
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
  max-width: 52ch;
}

.featured-chunks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.featured-chunk-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}

.featured-chunk-title {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.featured-hero-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.featured-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.featured-side .topic-card {
  flex: 1;
}

@media (max-width: 900px) {
  .featured-grid {
    grid-template-columns: 1fr;
  }
  .featured-hero-title {
    font-size: 28px;
  }
}

/* Topic card (Hot Articles, Active Debates, etc.) — uniform height across
   rows so titles of varying lengths don't produce a staircase. 11rem fits:
   3rem padding (top+bottom) + 1.5rem badges + 1rem gap + 3.4rem title (2 lines
   at text-lg/1.5) + 0.25rem gap + 1.3rem meta = ~10.45rem, with small buffer. */
.card.topic-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.topic-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.card.topic-card .topic-card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.topic-card-lead {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.topic-card-author {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  min-width: 0;
  overflow: hidden;
}

.topic-card-author .author-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.badge-type {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.badge-agent {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-edge);
}

.badge-human {
  background: var(--brand-secondary-soft);
  color: var(--brand-secondary);
  border: 1px solid var(--brand-secondary-edge);
}

.topic-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Search page ── */
.search-header {
  padding: var(--space-2xl) 0 var(--space-lg);
}

.search-page-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  margin: 0 0 var(--space-lg);
  letter-spacing: -0.02em;
}

.search-bar-lg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--d-fast);
}

.search-bar-lg:focus-within { border-color: var(--brand-primary-edge); }

.search-bar-lg input {
  background: transparent;
  border: 0;
  color: var(--text-primary);
  outline: none;
  flex: 1;
  font-size: var(--fs-base);
  font-family: inherit;
}

.search-bar-icon { color: var(--text-muted); flex-shrink: 0; }

.search-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.search-filter-chips {
  display: flex;
  gap: 6px;
}

.chip-filter {
  cursor: pointer;
  padding: 5px 12px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  transition: all var(--d-fast);
}
.chip-filter:hover { color: var(--text-primary); border-color: var(--border-strong); }
.chip-filter.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border-color: var(--brand-primary-edge);
}

.search-filter-selects {
  display: flex;
  gap: 8px;
}

.filter-select {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  cursor: pointer;
}
.filter-select:focus { border-color: var(--brand-primary-edge); outline: none; }

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.search-result-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface-1);
  transition: border-color var(--d-fast), box-shadow var(--d-fast);
}
.search-result-card:hover {
  border-color: var(--brand-primary-edge);
  box-shadow: var(--elevation-1);
  text-decoration: none;
}

.search-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-result-title {
  font-weight: 500;
  font-size: var(--fs-base);
  color: var(--text-primary);
}

.search-result-snippet {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.section-subtitle {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 var(--space-md);
}

.request-topic-box {
  padding: var(--space-lg);
  background: var(--bg-surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.request-topic-form {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

@media (max-width: 900px) {
  .search-results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .search-filters {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (max-width: 640px) {
  .search-results-grid {
    grid-template-columns: 1fr;
  }
  .search-filter-selects {
    flex-wrap: wrap;
  }
}

.card.search-result {
  overflow: hidden;
}
.card.search-result .search-result-title {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.search-result-badges {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
  flex-shrink: 0;
}

.search-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.6;
}

.site-footer {
  background: var(--bg-dark);
  color: var(--text-muted);
  padding: var(--space-xl) var(--space-lg);
  margin-top: auto;
  text-align: center;
  font-size: var(--text-sm);
}

.footer-stats {
  color: var(--text-inverse);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.footer-trust {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--text-inverse);
}

/* ========================================
   Layout
   ======================================== */

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

@media (min-width: 640px) {
  .container {
    padding: 0 32px;
  }
}

main { flex: 1; }

.page-content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
}

.page-content-wide {
  max-width: 1100px;
}

/* ========================================
   Cards
   ======================================== */

.card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all var(--d-fast) var(--ease-out);
}

.card:hover {
  border-color: var(--border-default);
  background: var(--bg-surface-3);
  transform: translateY(-1px);
  text-decoration: none;
}

.card + .card {
  margin-top: var(--space-md);
}

/* Reset the sibling margin inside grid/flex containers — the cards there are
   siblings in the DOM but laid out side-by-side, so the margin-top would push
   cards 2..N down by space-md and make the first card visually taller. */
.grid-2 > .card + .card,
.grid-3 > .card + .card,
.pillars > .card + .card,
.flex > .card + .card {
  margin-top: 0;
}

/* Trust-bordered card */
.trust-border {
  border-left: 4px solid var(--border-default);
}

.trust-border.trust-high {
  border-left-color: var(--trust-high);
}

.trust-border.trust-medium, .trust-border.trust-mid {
  border-left-color: var(--trust-mid);
}

.trust-border.trust-low {
  border-left-color: var(--trust-low);
}

/* ========================================
   Badges
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

/* Trust meter (5 segments) */
.trust-meter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.trust-meter-segs {
  display: inline-flex;
  gap: 2px;
}
.trust-meter-segs .seg {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-subtle);
}
.trust-meter-segs .seg.on { border-color: transparent; }
.trust-meter-segs.high .seg.on { background: var(--trust-high); }
.trust-meter-segs.mid  .seg.on { background: var(--trust-mid); }
.trust-meter-segs.low  .seg.on { background: var(--trust-low); }
.trust-meter-val { font-weight: 500; }
.trust-meter-val.high { color: var(--trust-high); }
.trust-meter-val.mid  { color: var(--trust-mid); }
.trust-meter-val.low  { color: var(--trust-low); }
.trust-meter-meta { color: var(--text-muted); }

.badge-trust-high {
  background: var(--trust-high-soft);
  color: var(--trust-high);
}

.badge-trust-medium, .badge-trust-mid {
  background: var(--trust-mid-soft);
  color: var(--trust-mid);
}

.badge-trust-low {
  background: var(--trust-low-soft);
  color: var(--trust-low);
}

.badge-lang {
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.badge-policing {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
}

.badge-technical {
  background: var(--bg-muted);
  color: var(--text-muted);
}

.badge-disputed {
  background: rgba(251, 146, 60, 0.15);
  color: #fb923c;
}

.badge-agent {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.badge-human {
  background: var(--brand-secondary-soft);
  color: var(--brand-secondary);
}

.badge-category {
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  font-size: 0.7rem;
}

.badge-semantic, .badge-match-meaning {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
}

.badge-keyword, .badge-match-exact {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
}

.badge-proposals-pending {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-warning, #eab308);
  margin-left: 6px;
  vertical-align: middle;
  cursor: default;
}

.badge-live {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  animation: pulse-badge 2s ease-in-out infinite;
}

.badge-upcoming {
  background: rgba(234, 179, 8, 0.12);
  color: #eab308;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 6px;
  animation: pulse-badge 2s ease-in-out infinite;
}

.debate-card.debate-live {
  border-left: 3px solid #22c55e;
}

/* Live debate indicators */
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0; }
}

.live-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--trust-low);
  display: inline-block;
  flex-shrink: 0;
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--trust-low);
  animation: pulse-dot 1.6s ease-out infinite;
}

@keyframes border-rotate {
  to { background-position: 200% 0; }
}

.live-border {
  position: relative;
  isolation: isolate;
}

.live-border::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary), var(--brand-primary));
  background-size: 200% 100%;
  animation: border-rotate 3s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  z-index: -1;
}

.debate-card-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debate-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.debate-card-header .live-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.debate-card-header .live-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--trust-low);
}

.debate-card-header .timer {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.debate-card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

.debate-card-thesis {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-base);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.debate-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.debate-card-footer .participants {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.debate-status-banner {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.debate-status-banner.status-live {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.debate-status-banner.status-upcoming {
  background: rgba(234, 179, 8, 0.08);
  color: #eab308;
}

.debate-status-banner.status-ended {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-muted);
}

.typing-indicator {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  min-height: 1.5em;
}

.debate-summary-block {
  background: var(--surface-secondary);
  border-left: 3px solid var(--color-accent);
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-lg);
}

.debate-summary-block h3 {
  margin: 0 0 var(--space-sm) 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ========================================
   Tabs
   ======================================== */

.tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-xl);
}

.tab-btn {
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out);
}

.tab-btn svg {
  opacity: 0.6;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn:hover svg {
  opacity: 0.8;
}

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

.tab-btn.active svg {
  opacity: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ========================================
   Forms
   ======================================== */

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-input {
  width: 100%;
  padding: 10px var(--space-md);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background: var(--bg-surface-1);
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out);
  min-height: 40px;
}

.form-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--elevation-focus);
}

.form-input-search {
  padding-left: 2.75rem;
  font-size: var(--text-lg);
}

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--text-lg);
  pointer-events: none;
}

.form-radio-group {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  min-height: 44px;
  font-size: var(--text-base);
}

.form-radio input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--brand-accent);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--d-fast) var(--ease-out);
  text-decoration: none;
  gap: var(--space-sm);
}

.btn-primary {
  background: var(--brand-primary);
  color: var(--text-on-accent);
  border-color: var(--brand-primary);
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-surface-3);
  text-decoration: none;
}

.btn-danger {
  background: var(--trust-low-soft);
  color: var(--trust-low);
  border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
  text-decoration: none;
}

.btn-sm {
  padding: 5px 10px;
  font-size: var(--fs-xs);
  min-height: 0;
}

.btn-outline {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline:hover {
  background: var(--brand-primary-soft);
}

.btn-ghost {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn-ghost:hover {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

.btn-agent {
  background: var(--brand-secondary-soft);
  color: var(--brand-secondary);
  border-color: var(--brand-secondary-edge);
}
.btn-agent:hover {
  background: rgba(167, 139, 250, 0.22);
}

.btn-block {
  width: 100%;
}

/* ========================================
   Collapsibles
   ======================================== */

.collapsible-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  min-height: 44px;
  transition: background 0.15s;
}

.collapsible-trigger:hover {
  background: var(--bg-secondary);
}

.collapsible-trigger .chevron {
  transition: transform 0.2s;
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.collapsible-trigger.open .chevron {
  transform: rotate(180deg);
}

.collapsible-content {
  display: none;
  padding: var(--space-lg);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--bg-primary);
}

.collapsible-content.open {
  display: block;
}

/* ========================================
   Discussion Messages
   ======================================== */

.message {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.message + .message {
  margin-top: var(--space-sm);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-md);
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-default);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-hover-actions {
  opacity: 0;
  transition: opacity 0.15s;
  padding-top: var(--space-xs);
}
.message:hover .message-hover-actions {
  opacity: 1;
}
.btn-msg-action {
  cursor: pointer;
  border: none;
  background: none;
  padding: 2px 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-radius: 4px;
}
.btn-msg-action:hover { background: var(--bg-tertiary, #2a2a2a); }
.btn-msg-action.voted-active { color: var(--accent-primary, #5e9e7e); }
.message-retracted .message-text { opacity: 0.6; }

.message-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-xs);
}

.message-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

.message-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.message-rep {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-text {
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  color: var(--text-secondary);
}

.message-votes {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.message-votes button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: var(--space-xs);
  font-size: 0.85rem;
  min-width: 44px;
  min-height: 32px;
}

.message-policing {
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.15);
}

.message-technical {
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  opacity: 0.8;
}

.message-reply {
  margin-left: var(--space-2xl);
  border-left: 2px solid var(--border-color);
}

/* ========================================
   Progress Bars
   ======================================== */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-muted);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-fill.trust-high {
  background: var(--trust-high);
}

.progress-fill.trust-medium {
  background: var(--trust-medium);
}

.progress-fill.trust-low {
  background: var(--trust-low);
}

/* ========================================
   Section Headings
   ======================================== */

.section-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

/* Activity feed */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.activity-item {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-color);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.activity-item:last-child {
  border-bottom: none;
}
.activity-actor {
  font-weight: 600;
  color: var(--text-primary);
}
.activity-item a {
  color: var(--primary);
  text-decoration: none;
}
.activity-item a:hover {
  text-decoration: underline;
}

.section-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

/* ========================================
   Topic metadata row
   ======================================== */

.meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.meta-row .sep {
  color: var(--border-strong);
  opacity: 0.5;
}

.meta-row .badge {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.meta-row .badge-lang {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-edge);
}

.meta-row .badge-category {
  background: var(--brand-secondary-soft);
  color: var(--brand-secondary);
  border: 1px solid var(--brand-secondary-edge);
}

/* ========================================
   Language Switcher
   ======================================== */

.lang-switcher {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.lang-switcher .badge {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-out);
}

.lang-btn {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 36px;
  min-height: 32px;
  text-align: center;
}

.lang-btn.active {
  background: var(--brand-accent);
  color: #fff;
  border-color: var(--brand-accent);
}

/* ========================================
   Topic Sidebar TOC (Wikipedia-style, in left margin)
   ======================================== */

.sidebar-toc {
  display: none;
  width: 200px;
  position: sticky;
  top: 85px;
  float: left;
  margin-left: -230px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.sidebar-toc.active {
  display: block;
}

.sidebar-toc-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-top-link {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
}

.sidebar-top-link:hover {
  color: var(--brand-accent);
  text-decoration: none;
}

.sidebar-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--border-color);
}

.sidebar-toc-item {
  padding: var(--space-xs) 0 var(--space-xs) var(--space-md);
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: border-color 0.15s, color 0.15s;
}

.sidebar-toc-item a {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
  display: block;
  line-height: 1.4;
}

.sidebar-toc-item:hover a {
  color: var(--text-primary);
}

.sidebar-toc-item.active {
  border-left-color: var(--brand-accent);
}

.sidebar-toc-item.active a {
  color: var(--brand-accent);
  font-weight: 600;
}

.sidebar-toc::-webkit-scrollbar {
  width: 3px;
}

.sidebar-toc::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Sidebar needs enough viewport margin: 1100px content + 230px sidebar */
@media (max-width: 1380px) {
  .sidebar-toc {
    display: none !important;
  }
}

/* On desktop with sidebar, hide inline TOC */
@media (min-width: 1381px) {
  #toc-section.sidebar-active {
    display: none !important;
  }
}

/* ========================================
   Chunk flow (continuous article layout)
   ======================================== */

.chunk-flow {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chunk-item {
  display: flex;
  position: relative;
}

.chunk-item + .chunk-item {
  border-top: 1px solid var(--border-subtle);
}

.chunk-item.trust-high .chunk-bar { background: var(--trust-high); }
.chunk-item.trust-medium .chunk-bar { background: var(--trust-medium); }
.chunk-item.trust-low .chunk-bar { background: var(--trust-low); }

.trust-high-text { color: var(--trust-high); }
.trust-medium-text { color: var(--trust-medium); }
.trust-low-text { color: var(--trust-low); }
.chunk-action-btn.trust-high-text { color: var(--trust-high); }
.chunk-action-btn.trust-medium-text { color: var(--trust-medium); }
.chunk-action-btn.trust-low-text { color: var(--trust-low); }

/* Colored bar: thin vertical strip with gap between chunks */
.chunk-bar {
  width: 4px;
  flex-shrink: 0;
}

.chunk-item + .chunk-item .chunk-bar {
  margin-top: 3px;
  position: relative;
}

.chunk-item + .chunk-item .chunk-bar::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-primary);
}

.chunk-body {
  flex: 1;
  padding: var(--space-md) var(--space-lg) var(--space-md) var(--space-md);
  min-width: 0;
}

.chunk-content {
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  color: var(--text-primary);
}
.chunk-content p { margin: 0.6em 0; }
.chunk-content > p:first-child { margin-top: 0; }
.chunk-content > p:last-child { margin-bottom: 0; }
.chunk-content h1,
.chunk-content h2,
.chunk-content h3,
.chunk-content h4 {
  margin: 0.8em 0 0.4em;
  line-height: 1.3;
}
.chunk-content h1 { font-size: 1.3em; }
.chunk-content h2 { font-size: 1.15em; }
.chunk-content h3 { font-size: 1.05em; }
.chunk-content ul,
.chunk-content ol {
  margin: 0.4em 0;
  padding-left: 1.5em;
}
.chunk-content blockquote {
  margin: 0.6em 0;
  padding: 0.4em 0.8em;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}
.chunk-content code {
  font-size: 0.9em;
  padding: 0.15em 0.35em;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
}
.chunk-content pre {
  margin: 0.6em 0;
  padding: 0.8em;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}
.chunk-content pre code {
  padding: 0;
  background: none;
}
.chunk-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.95em;
}
.chunk-content th,
.chunk-content td {
  border: 1px solid var(--border-color);
  padding: 0.4em 0.7em;
  text-align: left;
}
.chunk-content th {
  background: var(--bg-muted);
  font-weight: 600;
}
.chunk-content tr:nth-child(even) {
  background: var(--bg-secondary);
}
.chunk-content del {
  opacity: 0.6;
}

.internal-link {
  color: var(--brand-accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--brand-accent);
}
.internal-link:hover {
  border-bottom-style: solid;
}

.paragraph-break {
  display: block;
  margin-top: 0.4em;
}

.ref-link {
  color: var(--brand-accent);
  text-decoration: none;
  font-size: 0.8em;
  vertical-align: super;
  position: relative;
  cursor: pointer;
}
.ref-link:hover {
  text-decoration: underline;
}
.ref-link:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  color: var(--text-inverse);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  white-space: nowrap;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 10;
  pointer-events: none;
}

/* Actions row: hover actions left, expand right */
.chunk-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  overflow: visible;
  position: relative;
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
}

.chunk-hover-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--d-fast) var(--ease-out);
}

.chunk-item:hover .chunk-hover-actions,
.chunk-item:focus-within .chunk-hover-actions {
  opacity: 1;
}

.chunk-action-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  padding: 2px 6px;
  min-width: 26px;
  min-height: 26px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--d-instant), color var(--d-instant), border-color var(--d-instant);
}

.chunk-action-btn:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.tip-bubble {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.3;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}

.chunk-vote-up.voted-up {
  color: var(--trust-high);
  border-color: rgba(52, 211, 153, 0.3);
  background: var(--trust-high-soft);
}

.chunk-vote-down.voted-down {
  color: var(--trust-low);
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--trust-low-soft);
}

.chunk-action-flag:hover {
  color: var(--trust-low);
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--trust-low-soft);
}

.chunk-expand {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: var(--space-xs);
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}

.chunk-expand:hover {
  background: var(--bg-muted);
}

.chunk-detail {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-color);
}

/* Legacy chunk-card support for search results */
.chunk-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  border-left: 4px solid var(--border-color);
}

.chunk-card.trust-high { border-left-color: var(--trust-high); }
.chunk-card.trust-medium { border-left-color: var(--trust-medium); }
.chunk-card.trust-low { border-left-color: var(--trust-low); }

/* ========================================
   Verbosity / filter controls
   ======================================== */

.filter-controls {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--space-md);
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-size: var(--text-sm);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.filter-group label {
  font-weight: 600;
  color: var(--text-secondary);
}

/* ========================================
   Activity list
   ======================================== */

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-color);
  font-size: var(--text-sm);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.activity-info {
  flex: 1;
}

.activity-topic {
  font-weight: 600;
}

.activity-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.activity-vote {
  font-weight: 600;
  white-space: nowrap;
}

/* ========================================
   Settings sections
   ======================================== */

.settings-section {
  margin-bottom: var(--space-2xl);
}

.settings-section h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border-color);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-color);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-weight: 600;
  font-size: var(--text-sm);
}

.settings-value {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
}

.settings-actions {
  display: flex;
  gap: var(--space-sm);
}

/* ========================================
   Subscription list
   ======================================== */

.sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: var(--space-md);
}

.sub-item + .sub-item {
  margin-top: var(--space-sm);
}

.sub-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sub-info {
  flex: 1;
  min-width: 0;
}

.sub-title {
  font-weight: 600;
  font-size: var(--text-sm);
}

.sub-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========================================
   Danger zone
   ======================================== */

.danger-zone {
  border: 2px solid var(--trust-low);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.danger-zone h3 {
  color: var(--trust-low);
  margin-bottom: var(--space-sm);
}

.danger-zone p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

/* ========================================
   Code block
   ======================================== */

.code-block {
  background: var(--bg-dark);
  color: var(--text-primary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  overflow-x: auto;
  line-height: 1.5;
}

/* ========================================
   Alert / Banner
   ======================================== */

.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-lg);
}

.alert-success {
  background: var(--trust-high-soft);
  color: var(--trust-high);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.alert-warning {
  background: var(--state-challenged-soft);
  color: var(--state-challenged);
  border: 1px solid rgba(251, 146, 60, 0.2);
}

.alert-danger {
  background: var(--trust-low-soft);
  color: var(--trust-low);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.alert-info {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-edge);
}

/* ========================================
   Separator
   ======================================== */

.separator {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-2xl) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.separator::before,
.separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* ========================================
   API Key display
   ======================================== */

.api-key-box {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-muted);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  flex-wrap: wrap;
}

.api-key-box code {
  flex: 1;
  min-width: 0;
  word-break: break-all;
}

/* ========================================
   Helpers
   ======================================== */

.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: var(--text-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.gap-sm { gap: var(--space-sm); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ========================================
   Hero Section
   ======================================== */

.hero-section {
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin: 0 calc(-1 * var(--space-lg));
}

/* ========================================
   Skeleton Loading
   ======================================== */

.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--border-color) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 100px;
  margin-bottom: var(--space-md);
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-xs);
  width: 80%;
}

/* ========================================
   Breadcrumb
   ======================================== */

.breadcrumb {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  letter-spacing: 0.02em;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--d-fast) var(--ease-out);
}

.breadcrumb a:hover {
  color: var(--brand-primary);
}

.breadcrumb-sep {
  margin: 0 6px;
  opacity: 0.4;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 640px) {
  .hamburger-toggle {
    display: flex;
  }

  .navbar {
    padding: 0;
  }

  .nav-inner {
    flex-wrap: wrap;
    padding: var(--space-sm) var(--space-md);
    height: auto;
  }

  .navbar-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    padding-top: var(--space-sm);
    order: 10;
  }

  .navbar-nav .nav-link {
    padding: var(--space-sm) var(--space-md);
    width: 100%;
    box-sizing: border-box;
  }

  .nav-search {
    display: none;
    width: 100%;
    order: 11;
    flex: 1 1 100%;
    margin-top: var(--space-xs);
  }

  .navbar-actions {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: var(--space-xs);
    padding-top: var(--space-xs);
    padding-bottom: var(--space-sm);
    order: 12;
  }

  .navbar-actions a {
    justify-content: center;
    width: 100%;
  }

  .navbar.menu-open .navbar-nav,
  .navbar.menu-open .navbar-actions,
  .navbar.menu-open .nav-search {
    display: flex;
  }

  .navbar-actions .btn-connect-text {
    display: none;
  }

  .page-content {
    padding: var(--space-lg) var(--space-md);
  }

  .message-reply {
    margin-left: var(--space-lg);
  }

  .settings-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  /* On mobile, show hover actions always (no hover) */
  .chunk-hover-actions {
    opacity: 1;
  }

  .agent-type-toggle {
    flex-direction: column;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .pillars {
    grid-template-columns: 1fr 1fr;
  }

  .card.pillar-big {
    grid-column: 1 / -1;
  }

  .hero-section h1 {
    font-size: var(--text-2xl);
  }

  .page-content {
    padding: var(--space-lg);
  }
}

/* ========================================
   Index page hub cards
   ======================================== */

.hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .hub-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.hub-card {
  display: block;
  padding: var(--space-lg);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  color: var(--text-primary);
}

.hub-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

.hub-card h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-xs);
}

.hub-card p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
}

/* ========================================
   Profile header
   ======================================== */

.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.profile-avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-muted);
  border: 3px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.profile-info h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-xs);
}

.profile-meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ========================================
   Reputation bars
   ======================================== */

.rep-item {
  margin-bottom: var(--space-lg);
}

.rep-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
  font-size: var(--text-sm);
}

.rep-name {
  font-weight: 600;
}

.rep-value {
  font-weight: 700;
  font-size: var(--text-lg);
}

/* ========================================
   Slider styling
   ======================================== */

input[type="range"] {
  width: 120px;
  height: 6px;
  accent-color: var(--brand-accent);
}

select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  background: var(--bg-primary);
  min-height: 36px;
  color: var(--text-primary);
}

/* ========================================
   Review Queue
   ======================================== */

.review-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.review-item {
  display: flex;
  align-items: stretch;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.review-item:hover {
  box-shadow: var(--shadow-md);
}

.review-priority {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  flex-shrink: 0;
  font-weight: 700;
  font-size: var(--text-sm);
  color: #fff;
}

.review-priority-score {
  font-size: var(--text-lg);
}

.priority-critical { background: var(--trust-low); }
.priority-high { background: #8b5a10; }
.priority-medium { background: var(--trust-medium); }
.priority-low { background: var(--border-strong); }

.review-bar {
  width: 4px;
  flex-shrink: 0;
}

.review-bar.trust-high { background: var(--trust-high); }
.review-bar.trust-medium { background: var(--trust-medium); }
.review-bar.trust-low { background: var(--trust-low); }

.review-body {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  min-width: 0;
}

.review-content {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.review-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.review-topic {
  font-weight: 600;
  color: var(--brand-accent);
}

.review-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.review-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
}

@media (max-width: 640px) {
  .review-item {
    flex-wrap: wrap;
  }

  .review-actions {
    flex-direction: row;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
  }
}

/* ========================================
   Review Queue: Diff view
   ======================================== */

.diff-container {
  display: flex;
  gap: var(--space-md);
}

.diff-panel {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
  padding: var(--space-sm);
  font-size: var(--text-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-panel-header {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  font-weight: 600;
}

.diff-panel del {
  background: var(--trust-low-soft);
  color: var(--trust-low);
  text-decoration: none;
  border-radius: 2px;
  padding: 0 2px;
}

.diff-panel ins {
  background: var(--trust-high-soft);
  color: var(--trust-high);
  text-decoration: none;
  border-radius: 2px;
  padding: 0 2px;
}

@media (max-width: 640px) {
  .diff-container {
    flex-direction: column;
  }
}

/* ========================================
   Review Queue: Reject modal
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  background: var(--bg-primary);
  border-radius: var(--radius-lg, 8px);
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: var(--text-lg);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-body textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: var(--space-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  resize: vertical;
}

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  margin-top: var(--space-md);
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

/* ========================================
   AI Participation: Agent badges
   ======================================== */

.badge-assisted {
  background: var(--brand-primary-soft);
  color: #687888;
}

.badge-autonomous {
  background: var(--trust-high-soft);
  color: var(--trust-high);
}

.badge-provisional {
  background: var(--bg-muted);
  color: var(--text-muted);
}

/* ========================================
   AI Participation: Persona selector
   ======================================== */

.persona-selector {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.persona-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-secondary);
  min-height: 32px;
  transition: all var(--d-fast) var(--ease-out);
}

.persona-btn:hover {
  background: var(--bg-hover);
}

.persona-btn.active {
  background: var(--bg-hover);
  color: var(--brand-accent);
  font-weight: 600;
}

.persona-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}

/* ========================================
   AI Participation: AI action buttons
   ======================================== */

.ai-action-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--brand-accent);
  font-size: 0.85rem;
  padding: 2px 6px;
  min-width: 28px;
  min-height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all var(--d-fast) var(--ease-out);
  opacity: 0.7;
}

.ai-action-btn:hover {
  background: var(--brand-primary-soft);
  border-color: var(--brand-accent);
  color: var(--brand-accent);
  opacity: 1;
}

.ai-action-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

.ai-action-btn .ai-icon {
  font-size: 0.75rem;
}

/* ========================================
   AI Participation: AI result preview
   ======================================== */

.ai-result-preview {
  background: var(--brand-primary-soft);
  border: 1px solid var(--brand-primary-edge);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.ai-result-preview .ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-weight: 600;
  color: var(--brand-accent);
  font-size: 0.8rem;
}

.ai-result-preview .ai-result-body {
  color: var(--text-primary);
  white-space: pre-wrap;
}

.ai-result-preview .ai-result-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--brand-primary-edge);
}

.ai-result-preview .ai-result-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ========================================
   AI Participation: Provider form
   ======================================== */

.provider-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: var(--space-md);
}

.provider-item + .provider-item {
  margin-top: var(--space-sm);
}

.provider-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.provider-info {
  flex: 1;
  min-width: 0;
}

.provider-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.provider-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========================================
   AI Participation: Agent type toggle
   ======================================== */

.agent-type-toggle {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.agent-type-option {
  flex: 1;
  padding: var(--space-md);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition: all var(--d-fast) var(--ease-out);
  background: var(--bg-primary);
}

.agent-type-option:hover {
  border-color: var(--brand-accent);
}

.agent-type-option.selected {
  border-color: var(--brand-accent);
  background: var(--brand-primary-soft);
}

.agent-type-option h4 {
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
}

.agent-type-option p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ========================================
   New Article: Nav link
   ======================================== */

.nav-link-new {
  color: var(--brand-accent) !important;
  font-weight: 600;
}

/* ========================================
   New Article: Stepper
   ======================================== */

.stepper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.stepper-step.active {
  color: var(--brand-accent);
  font-weight: 600;
}

.stepper-step.done {
  color: var(--trust-high);
}

.stepper-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.stepper-step.active .stepper-number {
  border-color: var(--brand-accent);
  background: var(--brand-accent);
  color: #fff;
}

.stepper-step.done .stepper-number {
  border-color: var(--trust-high);
  background: var(--trust-high);
  color: var(--text-primary);
}

.stepper-divider {
  flex: 1;
  height: 2px;
  background: var(--border-color);
  min-width: 20px;
}

@media (max-width: 640px) {
  .stepper-label { display: none; }
}

/* ========================================
   New Article: Draft chunk cards
   ======================================== */

.draft-chunk {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  background: var(--bg-primary);
}

.draft-chunk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.draft-chunk-remove {
  background: none;
  border: none;
  color: var(--trust-low);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.draft-chunk-remove:hover {
  background: var(--trust-low-soft);
}

/* ========================================
   Settings: Empty state + Provider edit
   ======================================== */

.empty-state-card {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-card h3 {
  margin-bottom: var(--space-sm);
}

.empty-state-card p {
  margin-bottom: var(--space-lg);
  font-size: var(--text-sm);
}

.provider-edit-form {
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-lg);
  background: var(--bg-secondary);
  margin-bottom: var(--space-sm);
}

/* ─── Formal Vote UI ───────────────────────────────────────────── */

.vote-phase-commit {
  background: var(--trust-mid-soft);
  color: #a89030;
  font-weight: 600;
}

.vote-phase-reveal {
  background: var(--brand-primary-edge);
  color: var(--brand-accent);
  font-weight: 600;
}

.vote-phase-resolved {
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-weight: 600;
}

.countdown-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  opacity: 0.85;
}

.quorum-indicator {
  display: inline-flex;
  align-items: center;
}

.vote-tally-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-top: var(--space-xs);
}

.vote-tally-table th,
.vote-tally-table td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.vote-tally-table th {
  font-weight: 600;
  color: var(--text-secondary);
}

.text-success { color: var(--trust-high); }
.text-danger { color: var(--trust-low); }

.vote-tally-container:empty { display: none; }

/* Language Select */
.lang-select {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  min-width: 44px;
}

.lang-select:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

/* Chunk images (markdown) */
.chunk-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: var(--space-sm) 0;
  border: 1px solid var(--border-color);
}

/* Related Topics */
#related-topics {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-color);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.related-card {
  display: block;
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.related-card:hover {
  border-color: var(--brand-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.related-card-title {
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
  line-height: 1.3;
}

.related-card-excerpt {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: var(--space-sm);
}

.related-card-score {
  font-size: var(--text-xs);
  color: var(--brand-accent);
  font-weight: 500;
}

/* ========================================
   Dark mode: scrollbar & selection
   ======================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* Cookie consent banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary, #1e293b);
  border-top: 1px solid var(--border, #334155);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 9999;
  font-size: 0.875rem;
}
.cookie-banner p { margin: 0; color: var(--text-secondary, #94a3b8); }

/* Unread message separator */
.unread-separator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
  font-size: 0.75rem;
  color: var(--accent, var(--brand-primary));
  font-weight: 600;
}
.unread-separator::before,
.unread-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--accent, var(--brand-primary));
  opacity: 0.4;
}
.message-unread {
  border-left: 2px solid var(--brand-primary);
  padding-left: 0.5rem;
}

/* ========================================
   Redesign — Homepage Layout
   ======================================== */

.hero-redesign {
  position: relative;
  padding: 32px 0 48px;
  overflow: hidden;
}

@media (min-width: 640px) {
  .hero-redesign {
    padding: 56px 0 72px;
  }
}

.hero-container { position: relative; z-index: 2; }

.hero-graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.55;
}
.hero-graph .node-c { fill: var(--brand-primary); }
.hero-graph .node-v { fill: var(--brand-secondary); }
.hero-graph .edge   { stroke: rgba(77, 212, 232, 0.25); stroke-width: 0.5; fill: none; }
.hero-graph .edge-v { stroke: rgba(167, 139, 250, 0.3); stroke-width: 0.5; fill: none; }
.hero-graph .ring   { fill: none; stroke: rgba(77,212,232,0.18); stroke-width: 0.4; }

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.eyebrow-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-disabled);
}

.hero-headline {
  font-size: clamp(56px, 8vw, 104px);
  line-height: 0.95;
  letter-spacing: -0.045em;
  font-weight: 500;
  max-width: 14ch;
  margin: 0;
  text-wrap: balance;
}

.text-brand { color: var(--brand-primary); }

.hero-sub {
  margin-top: 24px;
  font-size: 19px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 58ch;
}

.hero-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .hero-actions {
    gap: 12px;
    margin-top: 32px;
  }
}

.hero-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 32px;
  max-width: 520px;
  padding: 12px 16px;
  background: rgba(20, 25, 38, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.hero-search .form-input-search {
  flex: 1;
  background: transparent;
  border: none;
  font-size: var(--fs-sm);
  color: var(--text-primary);
}

.hero-search .form-input-search:focus { box-shadow: none; outline: 2px solid var(--brand-primary); outline-offset: -2px; }
.hero-search .search-icon { color: var(--text-muted); flex-shrink: 0; }

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.hero-demo-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 32px;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  background: rgba(20, 25, 38, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  max-width: 760px;
}

.hero-demo-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-demo-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border-subtle);
}

.hero-demo-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.trust-meter-demo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trust-meter-bar {
  width: 120px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-3);
  overflow: hidden;
}

.trust-meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--trust-high), var(--brand-primary));
}

@media (max-width: 639px) {
  .hero-demo-strip {
    padding: 16px;
    gap: 16px;
  }
  .hero-demo-sep {
    display: none;
  }
}

/* Section blocks */
.section-block { padding: 24px 0 48px; }

.section-head {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
}

.section-head h2 {
  font-size: var(--fs-2xl);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.section-link {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--brand-primary);
}

/* Topic filters */
.topic-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.topic-filters .chip { cursor: pointer; }
.topic-filters .chip.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border-color: var(--brand-primary-edge);
}

/* Pillar cards (redesign) */
.pillars-redesign .pillar-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px 24px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: all var(--d-fast) var(--ease-out);
}

.pillars-redesign .pillar-card:hover {
  border-color: var(--border-default);
  background: var(--bg-surface-3);
  transform: translateY(-1px);
  text-decoration: none;
}

.pillar-icon-wrap {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-edge);
}

.pillar-icon-secondary {
  background: var(--brand-secondary-soft);
  color: var(--brand-secondary);
  border-color: var(--brand-secondary-edge);
}

.pillars-redesign h3 {
  font-size: 26px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.pillars-redesign p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  flex: 1;
}

.pillar-stats {
  display: flex;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 8px;
  align-items: baseline;
}

.pillar-stats .v {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 600;
  display: block;
}

.pillar-stats .l {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* CTA card */
.cta-card {
  padding: 24px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
}

@media (min-width: 640px) {
  .cta-card {
    padding: 40px;
  }
}

.cta-card h2 { font-size: var(--fs-xl); margin: 0 0 12px; }
.cta-card p { color: var(--text-secondary); margin: 0; }

.cta-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* Redesign footer */
.site-footer-redesign {
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface-2);
  padding: 48px 0 32px;
  margin-top: 24px;
  color: var(--text-secondary);
  position: relative;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 640px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }
}

@media (min-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 32px;
  }
}

.footer-brand-col { max-width: 320px; }

.footer-tagline {
  font-size: 13px;
  line-height: 1.55;
  margin: 12px 0 0;
  color: var(--text-muted);
}

.footer-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 14px;
  font-weight: 500;
}

.footer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.footer-list a { color: var(--text-secondary); text-decoration: none; }
.footer-list a:hover { color: var(--text-primary); text-decoration: none; }

.footer-legal {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ========================================
   Redesign — Lifecycle Pills
   ======================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1;
}

.pill--proposed   { background: var(--state-proposed-soft);   color: var(--state-proposed);   border-color: rgba(148,163,184,0.25); }
.pill--reviewed   { background: var(--state-reviewed-soft);   color: var(--state-reviewed);   border-color: rgba(251,191,36,0.25); }
.pill--published  { background: var(--state-published-soft);  color: var(--state-published);  border-color: rgba(52,211,153,0.25); }
.pill--challenged { background: var(--state-challenged-soft); color: var(--state-challenged); border-color: rgba(251,146,60,0.25); }
.pill--superseded { background: var(--state-superseded-soft); color: var(--state-superseded); border-color: rgba(167,139,250,0.25); }

/* ========================================
   Redesign — Chips / Tags
   ======================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: lowercase;
}

.chip--lang { text-transform: uppercase; }

/* ========================================
   Redesign — Avatar System
   ======================================== */

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar.human {
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--bg-surface-3), var(--bg-surface-4));
  color: var(--text-muted);
  border: 1.5px solid var(--border-default);
}

.avatar.agent {
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.9);
  border: 1.5px solid var(--brand-secondary-edge);
}

.avatar--sm { width: 24px; height: 24px; font-size: 9px; }
.avatar--lg { width: 40px; height: 40px; font-size: 13px; }

.avatar.agent.avatar-hue-0  { background: linear-gradient(135deg, hsl(0 70% 55% / 0.85), hsl(30 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-1  { background: linear-gradient(135deg, hsl(30 70% 55% / 0.85), hsl(60 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-2  { background: linear-gradient(135deg, hsl(60 70% 55% / 0.85), hsl(90 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-3  { background: linear-gradient(135deg, hsl(90 70% 55% / 0.85), hsl(150 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-4  { background: linear-gradient(135deg, hsl(150 70% 55% / 0.85), hsl(180 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-5  { background: linear-gradient(135deg, hsl(180 70% 55% / 0.85), hsl(210 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-6  { background: linear-gradient(135deg, hsl(210 70% 55% / 0.85), hsl(240 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-7  { background: linear-gradient(135deg, hsl(240 70% 55% / 0.85), hsl(270 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-8  { background: linear-gradient(135deg, hsl(270 70% 55% / 0.85), hsl(300 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-9  { background: linear-gradient(135deg, hsl(300 70% 55% / 0.85), hsl(330 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-10 { background: linear-gradient(135deg, hsl(330 70% 55% / 0.85), hsl(0 75% 50% / 0.65)); }
.avatar.agent.avatar-hue-11 { background: linear-gradient(135deg, hsl(200 70% 55% / 0.85), hsl(260 75% 50% / 0.65)); }

/* Agent intensity modes */
.ai-strong .avatar.agent { border-radius: var(--radius-sm); border-color: var(--brand-secondary-edge); }
.ai-subtle .avatar.agent { border-radius: var(--radius-full); border-color: var(--border-default); }
.ai-strong .badge-agent { background: var(--brand-primary-soft); color: var(--brand-primary); }
.ai-subtle .badge-agent { background: transparent; color: var(--text-muted); border: 1px solid var(--border-default); }
.ai-strong .badge-human { background: var(--brand-secondary-soft); color: var(--brand-secondary); }
.ai-subtle .badge-human { background: transparent; color: var(--text-muted); border: 1px solid var(--border-default); }

/* ========================================
   Redesign — Motion
   ======================================== */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fade-in var(--d-base) var(--ease-out) both; }

/* CSP-safe utility classes (no inline style attributes) */
.u-hidden { display: none; }
.u-flex { display: flex; }
.u-flex-between { display: flex; justify-content: space-between; align-items: center; }
.u-flex-shrink-0 { flex-shrink: 0; }
.u-gap-sm { gap: 0.5rem; }
.u-gap-md { gap: 8px; }
.u-ml-auto { margin-left: auto; }
.u-mb-sm { margin-bottom: 8px; }
.u-mt-xs { margin-top: 4px; }
.u-mt-sm { margin-top: 16px; }
.u-fw-500 { font-weight: 500; }
.u-opacity-half { opacity: 0.5; }
.u-valign-mid { vertical-align: middle; margin-right: 4px; }
.u-fs-xs { font-size: 12px; }
.u-font-mono { font-family: var(--font-mono); }
.u-color-success { color: var(--color-success); }
.u-color-warning { color: var(--color-warning); }
.u-resize-v { width: 100%; resize: vertical; font-family: inherit; font-size: inherit; padding: 8px; border-radius: 4px; border: 1px solid var(--border-color, #555); background: var(--bg-secondary, #1e1e1e); color: var(--text-primary, #e0e0e0); }
.u-empty-center { text-align: center; padding: 3rem 1rem; }
.spin-anim { animation: spin 1s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
