/* Inter + JetBrains Mono + Source Serif 4 (the textbook voice for headings). */
@import url("https://rsms.me/inter/inter.css");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,600&display=swap");

:root {
  --bg: #f7f8fa;                       /* clean paper */
  --grid-line: rgba(15, 23, 42, .05);  /* fine graph-paper hairline */
  --panel: #ffffff;
  --panel-2: #f4f6f9;
  --ink: #0b1220;          /* near-black slate */
  --ink-2: #334155;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #cbd5e1;
  /* One deep, restrained indigo — used sparingly, like an academic press. */
  --brand: #3730a3;
  --brand-2: #4338ca;      /* a near sibling for the rare gradient — no cyan */
  --brand-glow: rgba(55, 48, 163, .18);
  --brand-ink: #ffffff;
  /* Buttons are a single solid ink-indigo: crisp, not glowy. */
  --cta: #3730a3;
  --cta-h: #312a8a;
  --pos: #047857;
  --neg: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 1.5px rgba(15, 23, 42, .04), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-elev: 0 14px 36px -18px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .05);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Source Serif 4", "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  --sans: "Inter var", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --wide: 1200px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Always reserve the scrollbar gutter so switching filters (which changes page
   height) never nudges the centred layout sideways. */
html { scrollbar-gutter: stable; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--bg);
  /* Engineering-paper grid that slowly drifts — the most visible bit of motion,
     and pure CSS so it needs no extra element. */
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  animation: gridDrift 45s linear infinite;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01", "tnum" 0;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.005em;
}
@keyframes gridDrift { from { background-position: 0 0; } to { background-position: 72px 72px; } }
@supports (font-variation-settings: normal) {
  body { font-family: "Inter var", var(--sans); }
}
/* Dynamic atmosphere: large, soft, drifting colour blobs on a dedicated fixed
   layer at z-index 0 — content is lifted to z-index 1 so it sits on top, and
   the blobs show in the margins, the header strip and through the frosted rail.
   (Negative z-index proved unreliable.) Animation runs regardless of the
   reduced-motion setting, by request. */
/* Background stays quiet on purpose: clean paper plus the fine graph-paper grid
   on <body>. The earlier drifting colour-blob layer was removed — too decorative
   for the audience. .bg-aurora is hidden but kept so the markup needn't change. */
.bg-aurora { display: none; }
.topbar, .page, .footer { position: relative; z-index: 1; }
a { color: var(--brand); text-decoration: none; transition: color .15s; }
a:hover { text-decoration: underline; }
code, .mono, .vote-score, .rail-count, .profile-count strong { font-family: var(--mono); font-feature-settings: "tnum"; }

/* Universal focus ring — subtle cyan glow that ties the whole site together */
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-glow);
  border-radius: 6px;
}

.container { max-width: var(--wide); margin: 0 auto; padding: 0 18px; }

/* Top bar */
.topbar {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar::after {
  content: ""; display: block; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand) 30%, var(--brand-2) 70%, transparent);
  opacity: .6;
}
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 56px; }
.brand {
  font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em;
  color: var(--ink); display: inline-flex; align-items: center; gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--brand);
  color: #fff; border-radius: 7px; width: 28px; height: 28px;
  display: inline-grid; place-items: center; font-style: italic;
  font-family: var(--serif); font-weight: 600; font-size: 1.12rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .18);
}
.nav { display: flex; align-items: center; gap: 14px; }
.nav a { color: var(--ink); font-size: .94rem; }
.nav-right { margin-left: auto; }

/* Hover/focus dropdown anchored to the @username trigger */
.nav-menu { position: relative; }
.nav-menu-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  transition: background .12s;
}
.nav-menu-trigger:hover { background: #f3f4f6; text-decoration: none; }
.nav-menu-name { font-size: .9rem; }
.nav-menu-caret { font-size: .7rem; color: var(--muted); }
.nav-menu-panel {
  display: none; position: absolute; right: 0; top: 100%;
  min-width: 160px; padding: 6px 0; margin-top: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); z-index: 20;
}
/* Bridge the visual gap so hover doesn't drop when crossing it */
.nav-menu-panel::before {
  content: ""; position: absolute; left: 0; right: 0;
  top: -8px; height: 8px;
}
.nav-menu:hover .nav-menu-panel,
.nav-menu:focus-within .nav-menu-panel { display: block; }
.nav-menu-panel a,
.nav-menu-panel .linklike {
  display: block; padding: 7px 14px; font-size: .9rem;
  color: var(--ink); text-decoration: none; text-align: left; width: 100%;
}
.nav-menu-panel a:hover,
.nav-menu-panel .linklike:hover { background: #f3f4f6; text-decoration: none; }
.nav-menu-form { display: block; margin: 0; }

/* Buttons */
.btn {
  display: inline-block; padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font-size: .88rem;
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .12s;
}
.btn:hover { text-decoration: none; border-color: var(--line-2); background: var(--panel-2); }
.btn-primary {
  background: linear-gradient(180deg, var(--brand) 0%, #3730a3 100%);
  border-color: #3730a3; color: var(--brand-ink); font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 8px 18px -10px rgba(67, 56, 202, .6);
}
.btn-primary:hover { background: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%); transform: translateY(-1px); }
.btn-post {
  /* Solid ink-indigo CTA, matched to the search button. `.nav a` (0,1,1) was
     beating this rule's color, so white is reasserted below via .nav a.btn-post. */
  background: var(--cta);
  height: 34px; display: inline-flex; align-items: center; padding: 0 15px;
  border: none; border-radius: 8px; font-weight: 600; letter-spacing: .01em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}
.nav a.btn-post, .nav a.btn-post:visited { color: #fff; }
.btn-post:hover {
  transform: translateY(-1px); background: var(--cta-h);
  box-shadow: 0 4px 12px -4px rgba(55, 48, 163, .45);
}
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.linklike { background: none; border: none; color: var(--ink); cursor: pointer; font-size: .94rem; padding: 0; white-space: nowrap; }
.linklike:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 16px 0 0; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: .92rem; }
.msg-success { background: #ecfdf3; color: #027a48; }
.msg-error { background: #fef3f2; color: #b42318; }
.msg-info { background: #eff8ff; color: #175cd3; }

/* Hero */
.hero { padding: 22px 0 6px; position: relative; }
.hero h1 {
  margin: 0 0 10px; font-size: 1.9rem; letter-spacing: -.028em;
  font-weight: 700; line-height: 1.05; color: var(--ink);
  position: relative; display: inline-block;
}
.hero h1::after {
  content: ""; position: absolute; left: 0; bottom: -6px;
  height: 2px; width: 38px; border-radius: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.hero p { color: var(--muted); margin: 12px 0 0; max-width: 72ch; font-size: .95rem; }
.hero p a { color: var(--brand); font-weight: 500; }
.hero p a:hover { color: var(--brand-2); text-decoration: none; }
.hero-kicker {
  display: inline-block; font-family: var(--mono); font-size: .68rem;
  text-transform: uppercase; letter-spacing: .18em; color: var(--brand);
  margin: 0 0 8px; padding: 2px 8px;
  background: linear-gradient(90deg, rgba(67, 56, 202, .08), rgba(55, 48, 163, .08));
  border-radius: 4px;
}

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.searchbar { display: flex; gap: 8px; }
.searchbar input[type=search] { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 220px; }
.sortlinks a { color: var(--muted); margin-left: 12px; font-size: .9rem; }
.sortlinks a.active { color: var(--ink); font-weight: 600; }

.tagbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tag-chip { font-size: .82rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--panel); }
.tag-chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tag-chip:hover { text-decoration: none; }

/* App shell with an optional floating left category rail */
.page { display: flex; align-items: flex-start; }
.main { flex: 1; min-width: 0; }

/* Railed layout: rail + content are grouped and centered together, and the
   rail floats next to the content as a card (instead of being jammed against
   the viewport edge with a big gap to centered content). */
.page.has-rail { max-width: var(--wide); margin: 0 auto; gap: 24px; padding: 16px 18px 0; }
.page.has-rail .main .container { max-width: none; margin: 0; padding: 0; }
.page.has-rail .hero { padding-top: 0; }

.leftrail {
  flex-shrink: 0; width: 244px;
  position: sticky; top: 74px;
  max-height: calc(100vh - 90px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px 10px;
}
.leftrail::before {
  content: ""; display: block; height: 2px;
  margin: -14px -10px 12px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 50%, transparent 100%);
  opacity: .8;
}
.rail-heading {
  color: var(--muted); font-family: var(--mono); font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em; margin: 2px 10px 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.rail-links { display: flex; flex-direction: column; gap: 1px; counter-reset: rail; }
.rail-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px 7px 12px; border-radius: 6px;
  color: var(--ink-2); font-size: .88rem;
  transition: background .12s ease, color .12s ease;
}
.rail-link:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.rail-link.active {
  background: linear-gradient(90deg, rgba(67, 56, 202, .08), rgba(67, 56, 202, 0));
  color: var(--brand); font-weight: 600;
}
.rail-link.active::after {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 2px; border-radius: 0 2px 2px 0; background: var(--brand);
}
.rail-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-count {
  font-family: var(--mono); font-feature-settings: "tnum"; font-size: .72rem;
  color: var(--muted); flex-shrink: 0;
  padding: 1px 6px; border-radius: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.rail-link:hover .rail-count { color: var(--ink); }
.rail-link.active .rail-count { color: var(--brand); background: rgba(67, 56, 202, .08); border-color: rgba(67, 56, 202, .25); }

/* Colored dot for tag/stage rows — slim square accent on the left edge */
.rail-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--line-2); }
.rail-family .rail-dot { width: 6px; height: 18px; border-radius: 2px; }
/* Stages (workflows) */
.rail-stage-diagnostic .rail-dot { background: #94a3b8; }
.rail-stage-prep .rail-dot { background: #6366f1; }
.rail-stage-estimation .rail-dot { background: var(--brand); }
.rail-stage-inference .rail-dot { background: var(--pos); }
.rail-stage-robustness .rail-dot { background: var(--neg); }
.rail-stage-heterogeneity .rail-dot { background: #94a3b8; }
.rail-stage-reporting .rail-dot { background: #94a3b8; }
.rail-stage-other .rail-dot { background: #9ca3af; }
/* Method tag dots — slug-keyed; an unknown tag falls back to the neutral default. */
.rail-tag-did .rail-dot { background: #3b82f6; }
.rail-tag-doubly-robust .rail-dot { background: #ec4899; }
.rail-tag-event-study .rail-dot { background: #8b5cf6; }
.rail-tag-matrix-completion .rail-dot { background: #10b981; }
.rail-tag-panel-iv .rail-dot { background: #f97316; }
.rail-tag-synthetic-control .rail-dot { background: #94a3b8; }

/* Identification-strategy families on the methods rail */
.rail-blurb { color: var(--muted); font-size: .78rem; line-height: 1.45; margin: 0 8px 12px; }
.rail-blurb em { color: var(--ink); font-style: italic; }
.rail-subheading { color: var(--muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; margin: 18px 8px 6px; }
.rail-links-sub { gap: 1px; }
.rail-links-sub .rail-link { padding: 5px 10px; font-size: .85rem; color: #475467; }
.rail-link.is-empty { opacity: .55; }
.rail-link.is-empty:hover { opacity: 1; }
.rail-family .rail-dot { background: var(--brand); }
.rail-family-rct .rail-dot { background: #94a3b8; }
.rail-family-unconfoundedness .rail-dot { background: #6366f1; }
.rail-family-did .rail-dot { background: #3b82f6; }
.rail-family-iv .rail-dot { background: #f97316; }
.rail-family-rd .rail-dot { background: #94a3b8; }
.rail-family-synth .rail-dot { background: #94a3b8; }
.rail-family-hte .rail-dot { background: #8b5cf6; }
.rail-family-sensitivity .rail-dot { background: #ec4899; }
.rail-family-mediation .rail-dot { background: #94a3b8; }
.rail-family-survival .rail-dot { background: var(--neg); }
/* Secondary-page rails (workflow list, legacy method list) stay monochrome too —
   one quiet slate marker, organised by label rather than colour. */
[class*="rail-stage-"] .rail-dot,
[class*="rail-tag-"] .rail-dot,
[class*="rail-family-"] .rail-dot { background: #94a3b8; }
.rail-all-tags { margin: 14px 8px 0; }
.rail-all-tags > summary {
  list-style: none; cursor: pointer; font-size: .75rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .07em;
  padding: 4px 0; display: inline-flex; align-items: center; gap: 4px;
}
.rail-all-tags > summary::-webkit-details-marker { display: none; }
.rail-all-tags > summary::before { content: "▸"; font-size: .65rem; transition: transform .15s; }
.rail-all-tags[open] > summary::before { transform: rotate(90deg); }
.rail-all-tags > summary:hover { color: var(--brand); }
.rail-all-tags .rail-links-sub { margin-top: 6px; }

@media (max-width: 820px) {
  .page.has-rail { flex-direction: column; gap: 12px; padding: 14px 18px 0; }
  .leftrail {
    position: static; width: auto; max-height: none;
    box-shadow: none; padding: 10px 12px; border-radius: 12px;
  }
  .rail-links { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .rail-heading { width: 100%; margin: 0 0 6px; }
  .rail-link { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: .82rem; }
  .rail-count { display: none; }
}

/* Cards */
.cards { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px; display: flex; gap: 16px;
  transition: border-color .15s ease, box-shadow .2s ease, transform .15s ease;
}
.card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-elev), 0 0 0 1px rgba(67, 56, 202, .04);
}
.card-body { flex: 1; min-width: 0; }
.card-title {
  margin: 0 0 6px; font-size: 1.08rem; font-weight: 600;
  letter-spacing: -.01em; line-height: 1.3;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-title a { color: var(--ink); display: inline; }
.card-title a:hover { color: var(--brand); text-decoration: none; }
.title-pkg-pill {
  display: inline-block; font-family: var(--mono);
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  padding: 1px 7px; border-radius: 4px; vertical-align: 2px;
  margin-right: 8px;
  background: linear-gradient(180deg, #0f172a, #1e293b); color: #c7d2fe;
  border: 1px solid #1e293b;
  text-transform: uppercase;
}
.title-rest { color: inherit; }
.detail-head h1 .title-pkg-pill { vertical-align: 4px; font-size: .72rem; }
.card-summary { margin: 0 0 10px; color: var(--ink-2); font-size: .92rem; line-height: 1.5; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: center; }
.card-meta { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-meta a { color: var(--ink-2); font-weight: 500; }
.card-meta a:hover { color: var(--brand); text-decoration: none; }
.card-meta code { font-size: .78rem; padding: 1px 5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; color: var(--brand); }
.empty { color: var(--muted); padding: 24px; text-align: center; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Badges */
.badge {
  font-size: .72rem; padding: 2px 9px; border-radius: 6px;
  background: var(--panel); color: var(--ink-2);
  border: 1px solid var(--line); font-weight: 500;
}
a.badge:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.badge-estimand {
  font-family: var(--mono); font-feature-settings: "tnum";
  letter-spacing: .04em; font-weight: 700; font-size: .68rem;
  background: linear-gradient(180deg, #eef2ff, #e0e7ff);
  color: var(--brand); border-color: #c7d2fe;
  text-transform: uppercase; padding: 2px 7px;
}
.badge-public { background: #ecfdf3; color: #027a48; border-color: #abefc6; }
.badge-private { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.badge-hidden { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.badge-draft, .badge-pending { background: #fffaeb; color: #b54708; }
.badge-rejected { background: #fef3f2; color: #b42318; }

/* Key/value table (dataset metadata) */
.kv { border-collapse: collapse; margin: 12px 0; }
.kv th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 16px 5px 0; vertical-align: top; font-size: .9rem; white-space: nowrap; }
.kv td { padding: 5px 0; font-size: .92rem; }

/* Vote box */
/* Star widget: a hollow indigo star that fills in when you star the item —
   matching the site palette, no hint of a hidden downvote. */
.votebox {
  flex: none; width: 44px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 4px 6px 5px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); align-self: flex-start;
  transition: background .18s, border-color .18s, box-shadow .18s;
}
.votebox.is-lit {
  background: color-mix(in srgb, var(--brand) 6%, var(--panel));
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.detail-head .votebox { padding: 5px 7px 6px; }
.vote-star {
  display: inline-grid; place-items: center;
  background: none; border: none; cursor: pointer;
  width: 26px; height: 26px; padding: 0;
  color: var(--line-2);        /* unlit: pale slate outline */
  transition: color .18s ease, transform .12s ease, filter .18s ease;
}
.vote-star svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.vote-star:hover { color: var(--brand); text-decoration: none; }
.vote-star.active-up { color: var(--brand); filter: drop-shadow(0 1px 2px color-mix(in srgb, var(--brand) 40%, transparent)); }
.vote-star.active-up svg { fill: currentColor; }
/* Satisfying pop when clicked (AJAX path). */
.vote-star.vote-pulse { animation: vote-pop .36s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes vote-pop {
  0%   { transform: scale(1) rotate(0); }
  40%  { transform: scale(1.4) rotate(-8deg); }
  70%  { transform: scale(.95) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@media (prefers-reduced-motion: reduce) { .vote-star.vote-pulse { animation: none; } }
.vote-score { transition: color .15s ease; font-weight: 700; font-size: .92rem; font-variant-numeric: tabular-nums; color: var(--muted); padding: 0; line-height: 1.1; }
.vote-score.pos { color: var(--brand); }

/* Detail */
.detail {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-top: 18px;
  position: relative; overflow: hidden;
}
.detail::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 50%, transparent 100%);
  opacity: .85;
}
.detail-head { display: flex; gap: 18px; align-items: flex-start; }
/* Only the main column flexes — NOT the votebox, which is a fixed-size div. */
.detail-head > div:not(.votebox) { min-width: 0; flex: 1; }
.detail-head h1 { font-family: var(--serif); margin: 0 0 10px; font-size: 1.7rem; line-height: 1.18; letter-spacing: -.005em; }
/* Major page headings share the serif voice — the textbook register. */
.hero h1, .hero-workflows h1, .formwrap-head h1, .compose-head h1,
.profile-head h1, .guide-hero h1 { font-family: var(--serif); letter-spacing: -.005em; }
.detail-head .byline { margin-bottom: 10px; font-size: .9rem; }
.detail-head .card-tags { margin-bottom: 0; gap: 8px; }
.lead { font-size: 1.05rem; color: #374151; }
/* "Summary · by StatsDoge" — a labelled plain-English digest of the workflow.
   Lives between SOURCE and the long description; quietly indigo-tinted so it
   reads as a curated synopsis, not editorial body copy. */
.ai-summary {
  position: relative; margin: 18px 0 22px;
  padding: 14px 18px 14px 18px; border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 4%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line));
}
.ai-summary-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.ai-summary-mark {
  display: inline-grid; place-items: center; flex: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-family: var(--serif); font-style: italic; font-weight: 700; font-size: .82rem; line-height: 1;
}
.ai-summary-kicker {
  font-family: var(--mono); font-size: .62rem; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--brand);
}
.ai-summary-by { color: var(--muted); }
.ai-summary-body {
  margin: 0; font-family: var(--serif); font-size: 1.02rem; line-height: 1.55;
  color: var(--ink); font-feature-settings: "kern", "liga";
  min-height: 1.55em;
}
/* Reserve the typed text's height up front so the page doesn't jump as the
   characters arrive (estimated 3 lines is comfortable for the summaries). */
.ai-summary-body[data-typewriter] { min-height: calc(3em * 1.55); }
/* A slim indigo caret sits at the end of the typed text. It stays visible AND
   keeps blinking even after the typewriter finishes — leaving a "cursor parked
   at the end" feel. While typing it shows a steady stroke (no blink) so it
   visibly leads the characters; once done it switches to a 0.9s blink. */
.ai-summary-body.has-caret::after {
  content: ""; display: inline-block;
  width: 2px; height: 1em; vertical-align: -.12em;
  margin-left: 2px; background: var(--brand);
  animation: aiCaret .9s steps(1) infinite;
}
.ai-summary-body.has-caret.is-typing::after { animation: none; background: var(--brand); }
@keyframes aiCaret { 50% { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  .ai-summary-body[data-typewriter] { min-height: 0; }
  .ai-summary-body.has-caret::after { animation: none; }
}
.links { display: flex; gap: 10px; margin: 12px 0; }
.muted { color: var(--muted); }
.eval-status { font-size: .9rem; padding: 10px 12px; border-radius: 8px; background: #f8fafc; border: 1px solid var(--line); margin: 12px 0; color: var(--muted); }
.eval-scored, .eval-published { background: #ecfdf3; color: #027a48; border-color: #abefc6; }
.eval-rejected { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.eval-draft, .eval-pending { background: #fffaeb; color: #b54708; border-color: #fedf89; }

/* Prose (rendered markdown) */
.prose { overflow-wrap: anywhere; max-width: 78ch; }
.prose h1, .prose h2, .prose h3 { margin: 1em 0 .4em; }
.prose p { margin: .6em 0; }
.prose pre { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.prose code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; }
.prose blockquote {
  border-left: 2px solid var(--line-2); margin: 8px 0; padding: 6px 0 6px 12px;
  color: var(--muted); font-size: .82rem; line-height: 1.5;
  background: var(--panel-2); border-radius: 0 4px 4px 0;
}
.prose blockquote p { margin: 0; }

/* Datasets used / methods using (cross-links) */
.datasets-used { margin-top: 24px; }
.datasets-used h2 { font-size: 1.2rem; margin-bottom: 10px; }

/* Method list page — single-block cards, emerald accent (distinct from workflow indigo) */
.method-card { border-left: 2px solid var(--pos); }
.method-card:hover { border-left-color: var(--pos); box-shadow: var(--shadow-elev), inset 2px 0 0 var(--pos); }
.method-badge { display: inline-block; background: #ecfdf3; color: #027a48; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; margin-right: 8px; vertical-align: middle; }

/* Workflow list page — pipeline-style cards (distinct from method cards) */
.hero-workflows h1 { display: inline-block; }
.hero-workflows .hero-sub { color: var(--muted); font-weight: 400; font-size: 1.1rem; }
.workflow-card { border-left: 2px solid var(--brand); }
.workflow-card:hover { border-left-color: var(--brand); box-shadow: var(--shadow-elev), inset 2px 0 0 var(--brand); }
.workflow-badge { display: inline-block; background: #eef2ff; color: var(--brand); padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; margin-right: 8px; vertical-align: middle; }
.pipeline-preview {
  list-style: none; padding: 10px 0 6px; margin: 4px 0 8px;
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 0;
}
.pipeline-preview .pipe-step {
  position: relative;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px 6px 12px; margin-right: 22px; margin-bottom: 6px;
  display: flex; flex-direction: column; min-width: 0; max-width: 220px;
}
.pipeline-preview .pipe-step::after {
  content: "→"; position: absolute; right: -18px; top: 50%; transform: translateY(-50%);
  color: var(--brand); font-weight: 700; font-size: .95rem;
}
.pipeline-preview .pipe-step:last-child { margin-right: 0; }
.pipeline-preview .pipe-step:last-child::after { content: ""; }
.pipe-stage { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pipe-label { font-size: .85rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-more { align-self: center; color: var(--muted); font-size: .8rem; padding: 0 4px; }

/* Layered DAG on workflow cards — vertical stack of layers, each layer is one
   or more step pills side-by-side (parallel branches). Arrows between layers
   show flow direction. Compact enough to fit inside list/profile cards. */
.vdag { display: flex; flex-direction: column; align-items: stretch; gap: 0; margin: 14px 0 14px; position: relative; }
.vdag-layer { display: flex; gap: 10px; justify-content: center; align-items: stretch; flex-wrap: wrap; padding: 3px 0; }
.vdag-arrow {
  text-align: center; color: rgba(99, 102, 241, .35); font-size: .7rem;
  line-height: 1.4; font-family: var(--mono); letter-spacing: 0;
  position: relative;
}
.vdag-arrow::before {
  /* a 1 px gradient connector line through the arrow glyph */
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1px; transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(99, 102, 241, .35), rgba(55, 48, 163, .25));
  z-index: -1;
}
.vdag-step {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 8px;
  color: var(--ink); text-decoration: none;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .92) 0%, rgba(248, 250, 252, .9) 100%);
  min-width: 0; max-width: 360px; flex: 0 1 auto;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .8) inset,
    0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
a.vdag-step:hover {
  border-color: rgba(99, 102, 241, .35);
  text-decoration: none; transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .8) inset,
    0 8px 20px -10px rgba(67, 56, 202, .25);
}
.vdag-step .vpipe-text { flex: 1; min-width: 0; }
.vdag-step .vpipe-label { font-weight: 500; color: var(--ink); }
/* Branched layer: tinted panel that visually groups the parallel siblings */
.vdag-branch {
  background:
    radial-gradient(ellipse at center, rgba(99, 102, 241, .065) 0%, rgba(55, 48, 163, .03) 60%, transparent 100%),
    linear-gradient(180deg, rgba(99, 102, 241, .04), rgba(55, 48, 163, .03));
  border-radius: 10px;
  padding: 8px;
  border: 1px dashed rgba(99, 102, 241, .22);
  position: relative;
}
.vdag-branch::before {
  /* Soft outer glow to suggest "this is a parallel block, not just a row" */
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 24px -8px rgba(99, 102, 241, .18) inset;
}
.vdag-branch .vdag-step { flex: 1 1 0; min-width: 140px; }

/* Shared pieces still used by the new DAG step partial */
.vpipe-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--line);
  box-shadow:
    0 0 0 2px var(--panel),
    0 0 0 3px rgba(99, 102, 241, .15),
    0 0 10px currentColor;
  position: relative;
}
.vpipe-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.vpipe-stage {
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
}
.vpipe-label { font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }

.vpipe-diagnostic .vpipe-dot { background: #94a3b8; color: #94a3b8; }
.vpipe-prep .vpipe-dot { background: #6366f1; color: #6366f1; }
.vpipe-estimation .vpipe-dot { background: var(--brand); color: var(--brand); }
.vpipe-inference .vpipe-dot { background: var(--pos); color: var(--pos); }
.vpipe-robustness .vpipe-dot { background: var(--neg); color: var(--neg); }
.vpipe-heterogeneity .vpipe-dot { background: #94a3b8; color: #94a3b8; }
.vpipe-reporting .vpipe-dot { background: #94a3b8; color: #94a3b8; }
.vpipe-other .vpipe-dot { background: #9ca3af; color: #9ca3af; }

/* Profile sections — 2×2 grid of blocks (own / saved × methods / workflows) */
.profile-group-heading { font-size: 1.15rem; margin: 26px 0 4px; letter-spacing: -.01em; }
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 12px; }
.profile-block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.profile-block .cards { gap: 10px; }
.profile-block .card { padding: 10px 12px; }
.profile-block .card-title { font-size: 1rem; }
.profile-section-title { font-size: 1.05rem; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.profile-section-title .muted { font-weight: 400; font-size: .85rem; }
@media (max-width: 820px) {
  .profile-grid { grid-template-columns: 1fr; }
}

/* Workflow detail — layered DAG. Each layer is a horizontal row of step cards
   (parallel steps render side-by-side); a vertical connector between layers
   makes the top-down flow clear, while the "↳ from #N" tags on each card
   spell out the exact DAG edges. */
.workflow-dag { display: flex; flex-direction: column; gap: 28px; margin-top: 10px; }
.dag-layer { display: flex; gap: 14px; justify-content: center; align-items: stretch; flex-wrap: wrap; position: relative; }
.dag-layer:not(:last-child)::after {
  content: ""; position: absolute; left: 50%; bottom: -22px;
  width: 2px; height: 16px; background: var(--brand);
}
.dag-layer:not(:last-child)::before {
  content: "▼"; position: absolute; left: 50%; bottom: -10px;
  transform: translate(-50%, 0); color: var(--brand); font-size: .7rem;
}
.dag-layer-parallel { padding: 6px 0; }
.dag-step { flex: 0 1 280px; min-width: 220px; max-width: 340px; display: flex; }
.dag-step .dstep-link { flex: 1; margin: 0; }
.branch-flag { font-size: .72rem; background: #fdf4ff; color: #a21caf; padding: 2px 8px; border-radius: 999px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; margin-left: 8px; }

/* Workflow detail steps — same vertical timeline, with full bodies */
.dstep-list { margin-top: 6px; }
.dstep-row::before { left: 15px; top: 28px; bottom: -4px; }
.dstep-link { display: flex; align-items: flex-start; gap: 14px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; border: 1px solid var(--line); background: var(--panel); margin: 6px 0; }
a.dstep-link:hover { background: #f9fafb; border-color: #cbd0d6; }
.dstep-noop { cursor: default; }
.dstep-row .vpipe-dot { margin-top: 5px; }
.dstep-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.dstep-head { display: flex; align-items: center; gap: 8px; }
.dstep-num { color: var(--muted); font-size: .78rem; font-weight: 700; }
.dstep-title { font-weight: 600; font-size: 1rem; color: var(--ink); }
a.dstep-link .dstep-title { color: var(--brand); }
.dstep-note { color: #374151; font-size: .9rem; }
.dstep-deps { color: var(--muted); font-size: .82rem; }
.dstep-dep { display: inline-block; background: #f1f2f4; color: #475467; padding: 1px 8px; border-radius: 6px; margin-left: 4px; font-size: .76rem; }

/* Stage accents — give each stage a tint so the pipeline reads at a glance. */
.pipe-diagnostic { background: #fffaeb; border-color: #fedf89; }
.pipe-prep { background: #f1f5ff; border-color: #c7d2fe; }
.pipe-estimation { background: #eef2ff; border-color: #c7d2fe; }
.pipe-inference { background: #ecfdf3; border-color: #abefc6; }
.pipe-robustness { background: #fef3f2; border-color: #fecdca; }
.pipe-heterogeneity { background: #fdf4ff; border-color: #f5d0fe; }
.pipe-reporting { background: #f0fdfa; border-color: #99f6e4; }
.pipe-other { background: #f4f4f5; border-color: var(--line); }

/* Workflow step list (detail page) */
.step-list { list-style: none; padding: 0; margin: 10px 0 18px; counter-reset: stepc; display: flex; flex-direction: column; gap: 10px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; counter-increment: stepc; position: relative; }
.step::before { content: counter(stepc); position: absolute; left: -12px; top: 12px; background: var(--brand); color: #fff; width: 24px; height: 24px; border-radius: 50%; font-size: .8rem; font-weight: 700; display: grid; place-items: center; }
.step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-title { font-weight: 600; }
.step-note { color: #374151; margin-top: 6px; font-size: .92rem; }
.step-deps { margin-top: 6px; font-size: .82rem; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* Workflow step formset — each row is a card with a left "order" rail, a
   structured body, and a small actions column. Replaces the cramped table. */
.steps-head { margin: 22px 0 10px; }
.steps-head h2 { margin: 0 0 4px; }
.steps-head p { margin: 0; font-size: .9rem; }
.step-formset { display: flex; flex-direction: column; gap: 14px; margin: 6px 0 8px; }
.step-formset-hint { font-size: .82rem; margin: 6px 0 0; }
.step-row {
  display: grid; grid-template-columns: 84px 1fr 84px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.step-row:hover { border-color: #c7d2fe; }
.step-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.step-row-rail {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-right: 1px solid var(--line);
  padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.step-rail-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.step-row-rail input[type=number] {
  width: 60px; padding: 6px 4px; text-align: center; font-weight: 700; font-size: 1.05rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink);
}
.step-row-rail input[type=number]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(79,70,229,.12); }

.step-row-body { padding: 14px 16px 16px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.step-row-body .field { display: flex; flex-direction: column; gap: 5px; margin: 0; min-width: 0; }
.step-row-body label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.step-row-body input[type=text],
.step-row-body input[type=url],
.step-row-body input[type=number],
.step-row-body select,
.step-row-body textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: .92rem; background: var(--panel); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.step-row-body input:focus,
.step-row-body select:focus,
.step-row-body textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.14);
}
.step-row-body textarea { min-height: 64px; resize: vertical; line-height: 1.45; }
.step-row-grid { display: grid; gap: 12px; }
.step-row-grid-top { grid-template-columns: 220px 1fr; }
.step-row-grid-ext { grid-template-columns: 1fr 2fr; margin-top: 8px; }

.step-external { background: #fafbfc; border: 1px dashed var(--line); border-radius: 8px; padding: 0 10px; }
.step-external > summary {
  list-style: none; cursor: pointer; padding: 8px 0;
  font-size: .82rem; color: var(--muted); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.step-external > summary::-webkit-details-marker { display: none; }
.step-external > summary::before { content: "▸"; font-size: .7rem; color: var(--muted); transition: transform .15s; }
.step-external[open] > summary::before { transform: rotate(90deg); }
.step-external > summary:hover { color: var(--brand); }
.step-external[open] { padding-bottom: 10px; }

.step-row-actions {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-left: 1px solid var(--line);
  padding: 16px 10px; display: flex; align-items: flex-start; justify-content: center;
}
.step-row-delete {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
}
.step-row-delete input[type=checkbox] {
  width: 18px; height: 18px; accent-color: var(--neg); cursor: pointer; margin: 0;
}
.step-row-delete span {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.step-row-delete:hover span { color: var(--neg); }
/* When a row is marked for deletion, dim it visibly */
.step-row:has(.step-row-delete input:checked) { opacity: .55; }
.step-row:has(.step-row-delete input:checked) .step-row-body input,
.step-row:has(.step-row-delete input:checked) .step-row-body select,
.step-row:has(.step-row-delete input:checked) .step-row-body textarea { text-decoration: line-through; }

@media (max-width: 720px) {
  .step-row { grid-template-columns: 1fr; }
  .step-row-rail, .step-row-actions {
    border-right: none; border-left: none; border-bottom: 1px solid var(--line);
    flex-direction: row; justify-content: flex-start; gap: 12px;
  }
  .step-row-actions { border-bottom: none; border-top: 1px solid var(--line); justify-content: flex-end; }
  .step-row-grid-top { grid-template-columns: 1fr; }
  .step-row-grid-ext { grid-template-columns: 1fr; }
}

/* Avatar — circular initial OR uploaded image */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  border-radius: 50%; color: #fff; font-weight: 700;
  text-transform: uppercase; line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  letter-spacing: 0; overflow: hidden;
}
.avatar-image { background: var(--line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.byline { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.byline .avatar { margin-right: 2px; }

/* Avatar editor — preview + file input side-by-side */
.avatar-edit { display: flex; gap: 18px; align-items: center; }
.avatar-edit-preview { flex: none; }
.avatar-edit-field { flex: 1; min-width: 0; }
.avatar-edit-field input[type=file] {
  display: block; padding: 14px 16px; border: 1.5px dashed var(--line-2);
  border-radius: 14px; background: var(--panel-2); font-size: .88rem; cursor: pointer;
  width: 100%; color: var(--muted); transition: border-color .15s, background .15s;
}
.avatar-edit-field input[type=file]::file-selector-button {
  margin-right: 14px; padding: 8px 14px; border: none;
  border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-size: .85rem; font-weight: 600; cursor: pointer;
}
.avatar-edit-field input[type=file]:hover { border-color: var(--brand); background: #f4f6f9; }

/* Comments + composer */
.comments { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.comments-h { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; letter-spacing: -.005em; margin: 0 0 14px; }
.comments-login { padding: 14px 16px; background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; margin: 0 0 16px; }
.comments-empty { color: var(--muted); padding: 18px 16px; background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; list-style: none; text-align: center; }

.comment-composer {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.comment-composer:focus-within { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: 0 0 0 3px var(--brand-glow); }
.comment-composer-form { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.comment-composer-form textarea {
  width: 100%; box-sizing: border-box;
  padding: 8px 10px; border: 1px solid transparent; border-radius: 8px;
  font-family: inherit; font-size: .94rem; resize: vertical; min-height: 60px; line-height: 1.5;
  background: var(--panel-2); color: var(--ink); transition: background .14s, border-color .14s;
}
.comment-composer-form textarea:focus { outline: none; background: var(--panel); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.comment-composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.comment-composer-actions .muted { font-size: .78rem; }
.comment-composer-actions .btn-primary { padding: 6px 14px; font-size: .85rem; font-weight: 600; }
.comment-composer-reply { background: var(--panel-2); padding: 10px; }

/* Top-level comments sit on a quiet panel; replies are nested with a left
   "thread line" that ties them to their parent. */
.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.comment-meta a { color: var(--ink); font-weight: 600; }
.comment.reply {
  margin: 10px 0 0 24px; background: var(--panel-2); border-color: var(--line);
  position: relative; padding-left: 18px;
}
.comment.reply::before {
  content: ""; position: absolute; left: -16px; top: 18px; width: 14px; height: 1px;
  background: color-mix(in srgb, var(--brand) 30%, var(--line-2));
}
.reply-toggle { margin-top: 8px; }
.reply-toggle summary { cursor: pointer; color: var(--brand); font-size: .85rem; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.reply-toggle summary::-webkit-details-marker { display: none; }
.reply-toggle summary::before { content: "↳"; font-size: .85rem; }
.reply-toggle[open] summary { color: var(--muted); }

/* Forms */
.formwrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 28px; margin-top: 18px; max-width: 760px; }
.formwrap.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.formwrap.formwrap-wide { max-width: 1000px; }
.formwrap-head { margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.formwrap-head h1 { margin: 0 0 6px; font-size: 1.5rem; letter-spacing: -.01em; }
.formwrap-head p { margin: 0; font-size: .92rem; }

.stacked-form .field { margin-bottom: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stacked-form label, .stacked-form > label { font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); }
.stacked-form input[type=text], .stacked-form input[type=email], .stacked-form input[type=password],
.stacked-form input[type=url], .stacked-form input[type=number], .stacked-form textarea, .stacked-form select {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: .95rem; background: var(--panel-2); color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .05);
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.stacked-form input::placeholder, .stacked-form textarea::placeholder { color: var(--muted); }
.stacked-form input:hover, .stacked-form textarea:hover, .stacked-form select:hover { border-color: var(--line-2); }
.stacked-form input:focus, .stacked-form textarea:focus, .stacked-form select:focus {
  outline: none; border-color: var(--brand); background: var(--panel);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .04), 0 0 0 4px var(--brand-glow);
}
.stacked-form select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.stacked-form textarea { line-height: 1.55; min-height: 96px; resize: vertical; }
.help { color: var(--muted); font-size: .82rem; }
.snippet { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: .82rem; margin: 8px 0; white-space: pre; line-height: 1.5; }
.field-error { color: var(--neg); font-size: .85rem; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions-sticky {
  position: sticky; bottom: 0;
  margin: 24px -28px -24px; padding: 16px 28px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
}

/* Fancy multi-section form (method/workflow create) */
.fancy-form { display: flex; flex-direction: column; gap: 20px; }
.form-section {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px; display: flex; flex-direction: column; gap: 16px;
}
.form-section-title { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-url-ref { grid-template-columns: 2fr 1fr; }
.help-block { margin: 0 0 6px; line-height: 1.5; }
.form-section-sub { font-weight: 500; color: var(--muted); font-size: .88rem; margin-left: 6px; }
@media (max-width: 720px) {
  .form-grid-2, .form-grid-url-ref { grid-template-columns: 1fr; }
}

/* Pinned repository banner on method detail */
.repo-pin {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 10px 0; padding: 8px 12px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line); border-radius: 8px; flex-wrap: wrap;
  font-size: .88rem;
}
.repo-pin-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.repo-pin-icon {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px;
  background: linear-gradient(135deg, var(--brand), #3730a3); color: #fff;
  border-radius: 6px; font-size: .85rem; font-weight: 700; font-family: var(--mono);
}
.repo-pin-info > div { min-width: 0; }
.repo-pin-url {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom; color: var(--ink); font-weight: 600;
}
.repo-pin-ref { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; font-size: .88rem; color: var(--muted); }
.repo-pin-ref code {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; color: var(--brand); font-size: .82rem;
}
.repo-pin-kind {
  font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
  background: var(--brand); color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: 700;
}
.repo-pin-ref-empty { color: var(--neg); font-style: italic; }
.repo-pin-actions { display: flex; align-items: center; gap: 8px; }
.repo-pin-history { position: relative; }
.repo-pin-history > summary {
  list-style: none; cursor: pointer; padding: 6px 10px;
  font-size: .82rem; color: var(--muted); border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel);
}
.repo-pin-history > summary::-webkit-details-marker { display: none; }
.repo-pin-history > summary::before { content: "≡ "; }
.repo-pin-history > summary:hover { color: var(--brand); border-color: var(--brand); }
.repo-pin-history[open] > summary { background: var(--brand); color: #fff; border-color: var(--brand); }
.repo-pin-history > ul {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  list-style: none; padding: 6px; margin: 0; min-width: 280px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 25px -10px rgba(0,0,0,.15);
}
.repo-pin-history > ul > li {
  padding: 8px 10px; border-radius: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.repo-pin-history > ul > li.is-current { background: #eef2ff; }
.repo-pin-history code {
  background: #f3f4f6; border-radius: 4px; padding: 1px 5px;
  font-size: .82rem; color: var(--brand); font-weight: 600;
}
.repo-pin-history .muted { font-size: .75rem; }

/* Topic tags as toggle pills (template iterates the field → labels are
   direct children, so this works regardless of Django's wrapper markup).
   The .stacked-form .field rule forces column layout, so we out-specify it. */
.stacked-form .pill-field { display: flex; flex-flow: row wrap; align-items: flex-start; gap: 8px; }
.pill-field ul { display: contents; }   /* flatten any <ul><li> wrapper into the row */
.pill-field li { margin: 0; }
.pill-field label {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  padding: 7px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--panel);
  font-size: .82rem; font-weight: 600; color: var(--ink-2);
  text-transform: none; letter-spacing: 0;
  transition: background .14s, border-color .14s, color .14s, transform .1s, box-shadow .14s;
}
.pill-field label:hover { border-color: #c7d2fe; background: #f4f6f9; color: var(--brand); transform: translateY(-1px); }
.pill-field input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill-field label:has(input:checked) {
  background: linear-gradient(135deg, var(--brand), #4f46e5); border-color: var(--brand); color: #fff;
  box-shadow: 0 5px 14px -6px var(--brand-glow);
}

/* ============================================================
   COMPOSE A WORKFLOW · the post form, rebuilt
   ============================================================ */
/* Drop the flat outer card — each section floats as its own raised card on
   the blueprint background. `display: contents` on the form lets the sections
   share ONE flex column with the header, so every vertical gap is identical. */
.compose.formwrap {
  display: flex; flex-direction: column; gap: 18px;
  background: transparent; border: none; box-shadow: none; padding: 0;
}
.compose .fancy-form { display: contents; }
.compose .form-section {
  margin: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 24px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 18px 34px -22px rgba(15,23,42,.26);
}
.compose .form-actions-sticky {
  position: sticky; bottom: 16px; z-index: 5;
  margin: 0; padding: 14px 18px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 36px -16px rgba(15,23,42,.32);
}
.compose-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin: 0; padding: 22px 26px;
  background:
    radial-gradient(75% 130% at 0% 0%, rgba(67, 56, 202, .12), transparent 60%),
    radial-gradient(65% 130% at 100% 0%, rgba(55, 48, 163, .12), transparent 55%),
    var(--panel);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 20px 38px -22px rgba(67, 56, 202, .34);
}
.opt { font-weight: 500; font-size: .82em; color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.compose-kicker {
  display: inline-block; font-family: var(--mono); font-size: .66rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--brand);
  background: rgba(67, 56, 202, .08); border: 1px solid rgba(67, 56, 202, .18);
  border-radius: 5px; padding: 2px 8px;
}
.compose-head h1 { margin: 9px 0 6px; font-size: 1.55rem; letter-spacing: -.02em; }
.compose-head p { margin: 0; color: var(--muted); font-size: .92rem; max-width: 66ch; line-height: 1.55; }
.compose-head p strong { color: var(--ink-2); font-weight: 600; }

/* Numbered, colour-coded section headers */
.form-section-title { display: flex; align-items: center; gap: 11px; }
.sec-ico {
  flex: none; width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center;
  color: #fff; font-family: var(--mono); font-weight: 700; font-size: .84rem;
  box-shadow: 0 5px 12px -5px rgba(15, 23, 42, .4);
}
.sec-ico-1 { background: var(--ink); }
.sec-ico-2 { background: #475569; }
.sec-ico-3 { background: #94a3b8; }

/* Free-text tag input */
.tag-input-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 10px; min-height: 48px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--panel-2);
  box-shadow: inset 0 1px 2px rgba(15,23,42,.05); transition: border-color .14s, box-shadow .14s, background .14s;
}
.tag-input-box:focus-within { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 4px var(--brand-glow); }
.tag-chips { display: contents; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 5px 4px 11px; border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), #4f46e5); color: #fff;
  font-size: .8rem; font-weight: 600; box-shadow: 0 4px 10px -5px var(--brand-glow);
}
.tag-chip button {
  border: none; cursor: pointer; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(255,255,255,.25); color: #fff; font-size: .82rem; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.tag-chip button:hover { background: rgba(255,255,255,.45); }
.tag-input-field {
  flex: 1 1 120px; min-width: 120px; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: .9rem; color: var(--ink); padding: 4px 2px;
}
.tag-input-field::placeholder { color: var(--muted); }
.tag-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 11px; }
.tag-suggest-label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-right: 2px; }
.tag-suggest-chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  padding: 4px 12px; border-radius: 999px; font-size: .8rem; cursor: pointer;
  font-family: inherit; transition: background .12s, border-color .12s, color .12s, transform .1s;
}
.tag-suggest-chip:hover { border-color: var(--brand); color: var(--brand); background: #f4f6f9; transform: translateY(-1px); }

/* Pipeline step cards */
.step-formset { display: flex; flex-direction: column; gap: 12px; }
.step-card {
  position: relative; display: grid; grid-template-columns: 54px 1fr;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 10px 22px -16px rgba(15,23,42,.22);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.step-card:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow), 0 14px 28px -18px rgba(15,23,42,.28); }
.step-card.is-removed { display: none; }
.step-del { display: none; }
.step-card-rail {
  display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 14px 0;
  background: var(--panel-2); border-right: 1px solid var(--line);
}
.step-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-family: var(--mono); font-weight: 700; font-size: .82rem;
  box-shadow: 0 4px 10px -4px var(--brand-glow);
}
.step-remove {
  width: 24px; height: 24px; border-radius: 50%; border: none; cursor: pointer;
  background: transparent; color: var(--muted); font-size: .82rem; line-height: 1;
  display: grid; place-items: center; transition: background .12s, color .12s;
}
.step-remove:hover { background: #fee2e2; color: var(--neg); }
.step-card-main { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.step-card-main .field { display: flex; flex-direction: column; gap: 5px; margin: 0; min-width: 0; }
.step-card-main label { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Stage chosen as a colour chip (matches the pipeline diagram) */
.stage-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-chip {
  --sc: #94a3b8;
  display: inline-flex; align-items: center; cursor: pointer; user-select: none;
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--panel);
  font-size: .77rem; font-weight: 600; color: var(--ink-2);
  transition: background .13s, border-color .13s, color .13s, box-shadow .13s, transform .1s;
}
.stage-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stage-chip:hover { border-color: var(--sc); color: var(--sc); transform: translateY(-1px); }
.stage-chip:has(input:checked) {
  background: var(--sc); border-color: var(--sc); color: #fff;
  box-shadow: 0 4px 12px -5px color-mix(in srgb, var(--sc) 75%, transparent);
}
.stage-diagnostic   { --sc: #94a3b8; }
.stage-prep         { --sc: #6366f1; }
.stage-estimation   { --sc: #4f46e5; }
.stage-inference    { --sc: var(--pos); }
.stage-robustness   { --sc: var(--neg); }
.stage-heterogeneity{ --sc: #94a3b8; }
.stage-reporting    { --sc: #94a3b8; }
.stage-other        { --sc: #94a3b8; }

.step-external summary {
  cursor: pointer; font-size: .82rem; color: var(--muted);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.step-external summary::-webkit-details-marker { display: none; }
.step-external summary::before { content: "▸"; font-size: .7rem; transition: transform .15s; }
.step-external[open] summary::before { transform: rotate(90deg); }
.step-ext-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-top: 9px; }
.step-note textarea { min-height: 58px; }

/* Dedicated code editor — a dark, monospace surface with a title bar. */
.code-ed {
  border-radius: 12px; overflow: hidden; border: 1.5px solid #1e293b;
  box-shadow: 0 10px 24px -14px rgba(15, 23, 42, .55);
  transition: border-color .14s, box-shadow .14s;
}
.code-ed:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.code-ed-bar { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: #1e293b; }
.code-ed-dots { display: inline-flex; gap: 5px; }
.code-ed-dots i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.code-ed-dots i:nth-child(1) { background: #cbd5e1; }
.code-ed-dots i:nth-child(2) { background: #94a3b8; }
.code-ed-dots i:nth-child(3) { background: #cbd5e1; }
.code-ed-tag { margin-left: auto; font-family: var(--mono); font-size: .6rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #94a3b8; }
.stacked-form .code-ed textarea {
  width: 100%; display: block; margin: 0; border: none; border-radius: 0;
  background: #0f172a; color: #e2e8f0;
  font-family: var(--mono); font-size: .85rem; line-height: 1.6; padding: 14px 16px;
  resize: vertical; min-height: 96px; box-shadow: none; tab-size: 2;
}
.stacked-form .code-ed textarea:focus { box-shadow: none; outline: none; background: #0f172a; }
.stacked-form .code-ed textarea::placeholder { color: #5b6b85; }

/* Formula editor — LaTeX in, live KaTeX preview out. */
.formula-ed {
  border-radius: 12px; overflow: hidden; border: 1.5px solid var(--line); background: var(--panel-2);
  transition: border-color .14s, box-shadow .14s;
}
.formula-ed:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.stacked-form .formula-ed textarea {
  width: 100%; display: block; margin: 0; border: none; border-radius: 0;
  background: var(--panel-2); color: var(--ink);
  font-family: var(--mono); font-size: .88rem; line-height: 1.5; padding: 11px 14px;
  resize: vertical; min-height: 46px; box-shadow: none;
}
.stacked-form .formula-ed textarea:focus { box-shadow: none; outline: none; }
.formula-preview {
  border-top: 1px dashed var(--line-2); padding: 14px 16px; background: var(--panel);
  text-align: center; color: var(--ink); overflow-x: auto; min-height: 22px;
}
.formula-preview .katex { font-size: 1.15em; }
.formula-empty { color: var(--muted); font-size: .82rem; font-style: italic; }

.step-add {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  margin-top: 2px; padding: 11px 20px; border-radius: 12px; cursor: pointer;
  border: 1.5px dashed var(--line-2); background: var(--panel); color: var(--brand);
  font-size: .9rem; font-weight: 600; font-family: var(--sans);
  transition: background .14s, border-color .14s, transform .12s, box-shadow .14s;
}
.step-add:hover { border-color: var(--brand); background: #f4f6f9; transform: translateY(-1px); box-shadow: 0 8px 20px -10px var(--brand-glow); }
.step-add span { font-size: 1.15rem; line-height: 1; }
@media (max-width: 640px) {
  .step-card { grid-template-columns: 1fr; }
  .step-card-rail { flex-direction: row; justify-content: space-between; border-right: none; border-bottom: 1px solid var(--line); padding: 8px 14px; }
  .step-ext-grid { grid-template-columns: 1fr; }
}

/* Profile */
.profile-head {
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6f9 100%);
  border: 1px solid #e0e7ff; border-radius: 16px;
  padding: 22px 26px; margin-top: 18px;
}
.profile-head-id { display: flex; align-items: center; gap: 18px; }
.profile-head-id > div:nth-child(2) { flex: 1; min-width: 0; }
.profile-head-icon {
  flex: none; display: grid; place-items: center; width: 72px; height: 72px;
  background: var(--brand); color: #fff; border-radius: 50%;
  font-size: 1.9rem; font-weight: 700;
  box-shadow: 0 6px 16px -8px rgba(79,70,229,.5);
}
.profile-head h1 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: -.015em; }
.profile-meta { display: flex; gap: 14px; color: var(--muted); font-size: .9rem; margin-bottom: 4px; flex-wrap: wrap; }
.profile-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-counts { display: flex; gap: 18px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid #e0e7ff; }
.profile-count { font-size: .88rem; color: var(--muted); }
.profile-count strong { color: var(--ink); font-size: 1.05rem; font-weight: 700; margin-right: 4px; }
.bio { color: #374151; margin: 6px 0 0; }
@media (max-width: 620px) {
  .profile-head-id { flex-direction: column; align-items: flex-start; }
}

/* Profile workflow cards — a compact mini-feed of created / saved workflows */
.profile-group-heading { font-size: 1.15rem; letter-spacing: -.01em; margin: 26px 0 14px; }
.pf-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 16px; margin: 0 0 8px; }
.pf-card {
  --fam: #64748b;
  position: relative; display: flex; flex-direction: column; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 14px 30px -24px rgba(15,23,42,.30);
  transition: transform .2s cubic-bezier(.2,.7,.3,1), box-shadow .25s, border-color .2s;
}
.pf-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 2;
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 22%, transparent));
}
.pf-card:hover {
  transform: translateY(-4px); text-decoration: none;
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  box-shadow: 0 28px 50px -28px rgba(55, 48, 163, .30), 0 6px 14px -8px rgba(15,23,42,.12);
}
/* Source label at the top of the profile mini-card (the card itself links to
   the detail page, where the citation is clickable). */
.pf-src {
  display: flex; align-items: baseline; gap: 5px; padding: 7px 12px 0;
  font-family: var(--mono); font-size: .54rem; color: var(--brand);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pf-src-k { font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); flex: none; }
.pf-up { color: var(--brand); font-size: .78rem; }
.pf-card-cover {
  position: relative; aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(130% 130% at 50% 0%, #fff 52%, #e9eef6 100%);
  box-shadow: inset 0 -1px 0 var(--line); overflow: hidden;
}
.pf-card-cover img { width: 100%; height: 100%; object-fit: contain; }
.pf-card-sigma { font-family: var(--mono); font-size: 2.2rem; color: var(--line-2); }
.pf-card-cats { position: absolute; top: 8px; left: 8px; display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 16px); }
.pf-cat {
  --c: #64748b; font-family: var(--mono); font-size: .55rem; font-weight: 700; color: #fff;
  padding: 2px 7px; border-radius: 5px; white-space: nowrap;
  background: var(--c); background: color-mix(in srgb, var(--c) 90%, transparent);
  box-shadow: 0 2px 6px -2px rgba(15,23,42,.4), inset 0 0 0 1px rgba(255,255,255,.18);
}
.pf-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.pf-card-title {
  margin: 0; font-family: var(--serif); font-size: 1rem; font-weight: 600; line-height: 1.3;
  color: var(--ink); letter-spacing: -.003em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pf-card-sum {
  margin: 0; font-size: .8rem; line-height: 1.45; color: var(--muted); flex: 1 1 auto;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pf-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 2px; padding-top: 9px; border-top: 1px solid var(--line);
}
.pf-author { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.pf-author-name { font-family: var(--mono); font-size: .7rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-stats { display: inline-flex; gap: 9px; flex: none; font-family: var(--mono); font-size: .72rem; font-weight: 600; color: var(--muted); }
.pf-empty { grid-column: 1 / -1; color: var(--muted); padding: 26px; text-align: center; background: var(--panel); border: 1px dashed var(--line-2); border-radius: 14px; }

/* Evaluation history (method detail) */
.eval-runs { margin: 12px 0; }
.eval-runs summary { cursor: pointer; color: var(--brand); font-size: .9rem; margin-bottom: 8px; }
.eval-runs .board { margin-top: 8px; }

/* Leaderboard */
.board { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.board th, .board td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: .92rem; }
.board th { background: #f9fafb; color: var(--muted); font-weight: 600; }
.board .num { text-align: right; }
.board .rank { color: var(--muted); width: 36px; }
.board tr:last-child td { border-bottom: none; }

/* Guide page — interactive, numbered, with live previews */
.guide-hero {
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6f9 100%);
  border: 1px solid #e0e7ff; border-radius: 16px;
  padding: 32px 34px; margin: 20px 0 24px;
}
.guide-kicker { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--brand); font-weight: 700; margin: 0 0 4px; }
.guide-hero h1 { font-size: 2rem; margin: 0 0 10px; letter-spacing: -.02em; }
.guide-hero .lead { color: #475467; font-size: 1.02rem; margin: 0 0 22px; max-width: 660px; }
.guide-jump { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.guide-jump-link {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.guide-jump-link:hover {
  border-color: var(--brand); transform: translateY(-2px);
  box-shadow: 0 8px 24px -8px rgba(79,70,229,.28); text-decoration: none;
}
.guide-jump-icon {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--brand); color: #fff; border-radius: 10px; font-size: 1.1rem; font-weight: 700;
}
.guide-jump-link span:last-child { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.guide-jump-link strong { font-size: .95rem; }
.guide-jump-link em { font-style: normal; font-size: .78rem; color: var(--muted); }

.guide-block {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; margin: 18px 0; box-shadow: var(--shadow);
  scroll-margin-top: 70px;
}
.guide-block-head { display: flex; align-items: flex-start; gap: 16px; margin: 0 0 16px; }
.guide-num {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px;
  background: var(--brand); color: #fff; border-radius: 12px;
  font-weight: 700; font-size: 1.15rem;
  box-shadow: 0 6px 16px -8px rgba(79,70,229,.5);
}
.guide-block-head h2 { margin: 0 0 4px; font-size: 1.35rem; letter-spacing: -.01em; }
.guide-block-sub { margin: 0; color: var(--muted); font-size: .92rem; }
.guide-block > p { color: #374151; margin: 6px 0 12px; }

.guide-howto { list-style: none; padding: 0; margin: 12px 0 16px; display: flex; flex-direction: column; gap: 8px; }
.guide-howto > li {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .12s, background .12s;
}
.guide-howto > li:hover { background: #f1f5f9; border-color: #cbd5e1; }
.guide-howto-num {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px;
  background: var(--brand); color: #fff; border-radius: 8px;
  font-weight: 700; font-size: .85rem; text-transform: uppercase;
}
.guide-howto > li > div p { margin: 4px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.guide-howto strong { font-size: .96rem; }

.guide-side-by-side {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  margin: 8px 0 16px;
}
.guide-side-by-side > div { min-width: 0; }
.guide-callout {
  padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid #94a3b8; border-radius: 8px;
  color: #78350f; font-size: .9rem; margin: 0 0 12px;
}

.guide-feature-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 8px; }
.guide-feature-list > li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .12s, transform .12s;
}
.guide-feature-list > li:hover { border-color: var(--brand); transform: translateX(2px); }
.guide-feature-list > li > div { font-size: .9rem; line-height: 1.5; flex: 1; min-width: 0; }
.guide-feature-list strong { color: var(--ink); }
.guide-feature-list em { color: var(--muted); font-style: normal; }
.guide-feature-emoji { font-size: 1.05rem; line-height: 1.4; width: 26px; text-align: center; color: var(--brand); flex: none; }
.guide-feature-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; margin-top: 6px; box-shadow: 0 0 0 3px var(--panel); }
.guide-feature-list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.guide-dag-demo {
  padding: 16px 18px; background: linear-gradient(180deg, #fafbff 0%, #f4f6f9 100%);
  border: 1px solid #e0e7ff; border-radius: 12px;
}
.guide-dag-caption { color: var(--muted); font-size: .8rem; margin: 0 0 12px; text-align: center; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

.guide-snippet-label { color: var(--muted); font-size: .82rem; margin: 0 0 6px; font-weight: 600; }

.guide-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

@media (max-width: 820px) {
  .guide-jump { grid-template-columns: repeat(2, 1fr); }
  .guide-side-by-side { grid-template-columns: 1fr; }
  .guide-feature-list-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   TERMINAL TOPBAR · mono brand identity + status badge
   ============================================================ */
.topbar-inner { height: 60px; gap: 16px; }
.brand { gap: 10px; align-items: center; }
.brand-text { display: inline-flex; flex-direction: column; line-height: 1.12; min-width: 0; }
.brand-name {
  font-family: var(--sans); font-weight: 800; font-size: 1.12rem;
  letter-spacing: -.02em; color: var(--ink);
}
.brand-name-acc { color: var(--brand); }
.brand-tag {
  font-family: var(--sans); font-size: .68rem; letter-spacing: 0;
  text-transform: none; color: var(--muted); font-weight: 500;
  margin-top: 1px;
}
.nav.nav-center { margin-left: 24px; gap: 18px; font-family: var(--mono); font-size: .82rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.nav-center a { color: var(--ink-2); padding: 4px 2px; border-bottom: 1.5px solid transparent; transition: color .15s, border-color .15s; }
.nav-center a:hover { color: var(--brand); border-bottom-color: var(--brand-2); text-decoration: none; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-family: var(--sans); font-size: .76rem; font-weight: 600;
  letter-spacing: 0; text-transform: none; color: var(--ink-2);
}
.status-pill .status-num { color: var(--ink); font-size: .8rem; font-weight: 700; }
.status-pill .status-label { color: var(--muted); }
.status-orb {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--pos); flex: none; position: relative;
  box-shadow: 0 0 0 0 rgba(5, 150, 105, .55);
  animation: orb-ping 2s ease-out infinite;
}
@keyframes orb-ping {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, .6); }
  70% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* ============================================================
   LEFT RAIL · search card + consensus metrics + family list
   ============================================================ */
.rail-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px 12px;
  margin-bottom: 14px; position: relative; overflow: hidden;
}
.rail-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), transparent);
  opacity: .8;
}
.rail-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
  padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.rail-card-title {
  font-family: var(--mono); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em; color: var(--ink);
  white-space: nowrap;
}
.rail-card-tag {
  font-family: var(--mono); font-size: .58rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--brand); background: rgba(67, 56, 202, .08);
  border: 1px solid rgba(67, 56, 202, .2); border-radius: 4px;
  padding: 1px 5px;
}
.rail-search { margin: 0 0 12px; }
.rail-search input[type=search] {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-family: var(--mono); font-size: .82rem;
  background: var(--panel-2); color: var(--ink);
  transition: border-color .15s, background .15s;
}
.rail-search input[type=search]:focus {
  outline: none; border-color: var(--brand);
  background: var(--panel); box-shadow: 0 0 0 3px var(--brand-glow);
}

.consensus-card {
  background: linear-gradient(160deg, #1e1b4b 0%, #0f172a 100%);
  border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.consensus-label {
  font-family: var(--mono); font-size: .58rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: #a5b4fc;
}
.consensus-row { display: flex; align-items: baseline; justify-content: space-between; }
.consensus-name { font-family: var(--mono); font-size: .72rem; color: #cbd5e1; }
.consensus-value {
  font-family: var(--mono); font-weight: 800; font-size: 1.05rem;
  color: #34d399; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.consensus-note { margin: 4px 0 0; font-size: .68rem; line-height: 1.45; color: #94a3b8; }

/* Family rail (override leftrail::before — we now use rail-card wrappers) */
.leftrail { background: transparent; border: none; box-shadow: none; padding: 0; }
.leftrail::before { display: none; }

/* ============================================================
   SORT DECK · dark gradient header above the cards
   ============================================================ */
.sort-deck {
  background:
    radial-gradient(ellipse 60% 80% at 12% 0%, rgba(129, 140, 248, .35), transparent 70%),
    radial-gradient(ellipse 70% 90% at 95% 110%, rgba(55, 48, 163, .25), transparent 65%),
    linear-gradient(180deg, rgba(30, 27, 75, .72) 0%, rgba(15, 23, 42, .68) 100%);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(129, 140, 248, .22);
  border-radius: 14px; padding: 16px 18px; margin: 2px 0 16px;
  position: relative; overflow: hidden;
  box-shadow:
    0 12px 36px -20px rgba(15, 23, 42, .28),
    0 1px 0 rgba(255, 255, 255, .06) inset,
    0 -1px 0 rgba(0, 0, 0, .18) inset;
}
.sort-deck::before {
  /* Subtle scan-line texture for the "instrument-panel" vibe */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    180deg, transparent 0 2px, rgba(255, 255, 255, .015) 2px 3px
  );
  border-radius: inherit;
}
.sort-deck::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand) 50%, transparent);
  opacity: .5;
}
.sort-deck-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; border-bottom: 1px solid rgba(148, 163, 184, .14);
}
.sort-deck-title {
  font-family: var(--mono); font-size: .88rem; font-weight: 700;
  letter-spacing: .06em; color: #fff;
  display: inline-flex; align-items: center; gap: 8px;
}
.sort-deck-icon { color: #818cf8; font-size: 1.05rem; }
.real-time-node {
  font-family: var(--mono); font-size: .6rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: #34d399;
  background: rgba(5, 150, 105, .12);
  border: 1px solid rgba(5, 150, 105, .35); border-radius: 999px;
  padding: 4px 10px; display: inline-flex; align-items: center; gap: 6px;
}
.real-time-node .status-orb { background: #34d399; }
.sort-deck-body { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
.sort-deck-label {
  font-family: var(--mono); font-size: .6rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: #94a3b8;
}
.sort-deck-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: rgba(2, 6, 23, .55);
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: 10px; padding: 4px;
}
.sort-tab {
  text-align: center; padding: 9px 8px; border-radius: 7px;
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
  color: #cbd5e1; transition: background .15s, color .15s;
}
.sort-tab:hover { color: #fff; text-decoration: none; background: rgba(15, 23, 42, .55); }
.sort-tab.active {
  color: #fff; background: linear-gradient(180deg, var(--brand) 0%, #3730a3 100%);
  box-shadow: 0 6px 14px -6px rgba(67, 56, 202, .55), inset 0 1px 0 rgba(255,255,255,.18);
}

/* ============================================================
   METHOD CARD · sub-header bar + stats + body + footer
   ============================================================ */
.method-card, .workflow-card, .dataset-card {
  flex-direction: column; gap: 0; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-left-width: 2px;
  background:
    linear-gradient(135deg, rgba(99, 102, 241, .025) 0%, transparent 38%),
    linear-gradient(225deg, rgba(55, 48, 163, .02) 0%, transparent 42%),
    var(--panel);
  transition: transform .18s ease, border-color .18s, box-shadow .25s;
}
.method-card:hover, .workflow-card:hover, .dataset-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-2);
  box-shadow:
    0 18px 40px -22px rgba(67, 56, 202, .22),
    0 4px 8px -4px rgba(15, 23, 42, .06);
}
.card-subheader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(99, 102, 241, .035) 0%, transparent 50%),
    linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  gap: 12px; flex-wrap: wrap;
}
.sub-pills { display: inline-flex; align-items: center; gap: 6px; }
.sub-stats {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: .68rem; font-weight: 700;
}
.pkg-pill {
  font-family: var(--mono); font-size: .62rem; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
  color: #e2e8f0; background: linear-gradient(180deg, #1e293b, #0f172a);
  border: 1px solid #334155; border-radius: 4px;
  padding: 2px 7px;
  box-shadow: 0 2px 4px -2px rgba(15,23,42,.4), inset 0 1px 0 rgba(255,255,255,.08);
}
.hot-index {
  color: var(--brand); background: #eef2ff;
  border: 1px solid #c7d2fe; border-radius: 999px;
  padding: 2px 9px; letter-spacing: .04em;
}
.peers-count {
  color: var(--ink-2); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 9px; letter-spacing: .04em;
  display: inline-flex; align-items: center; gap: 5px;
}
.peers-count .status-orb { width: 6px; height: 6px; }

.card-row { display: flex; gap: 14px; padding: 14px 18px 12px; }
.card-row .votebox { align-self: flex-start; margin-top: 2px; }
.method-card .card-title {
  font-size: 1.05rem; margin: 0 0 4px;
  letter-spacing: -.015em; line-height: 1.25;
}
.method-card .card-summary { margin: 0 0 8px; font-size: .9rem; color: var(--ink-2); }

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px; border-top: 1px solid var(--line);
  background: var(--panel-2); gap: 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: .72rem;
}
.card-footer .byline { font-family: var(--mono); color: var(--ink-2); }
.card-footer .byline a { color: var(--ink); font-weight: 600; }
.card-footer .dot { color: var(--line-2); }
.footer-meta { display: inline-flex; align-items: center; gap: 6px; }
.reviews-chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; color: var(--ink-2); font-weight: 600;
}
.ref-chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; color: var(--ink-2); font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.ref-chip code {
  background: var(--panel-2); padding: 0 4px; border-radius: 3px;
  font-size: .68rem; color: var(--brand);
}
.ref-chip:hover { text-decoration: none; border-color: var(--brand); }

/* ============================================================
   Rail CTA button (compose / upload primary action in rail card)
   ============================================================ */
.rail-cta {
  display: block; margin-top: 10px;
  padding: 8px 12px; border-radius: 8px;
  background: linear-gradient(180deg, var(--brand) 0%, #3730a3 100%);
  color: #fff !important; font-weight: 600; font-size: .82rem;
  text-align: center; letter-spacing: .01em;
  border: 1px solid #3730a3;
  box-shadow: 0 6px 14px -8px rgba(67, 56, 202, .55), inset 0 1px 0 rgba(255, 255, 255, .14);
  transition: transform .15s, box-shadow .15s;
}
.rail-cta:hover {
  text-decoration: none; transform: translateY(-1px);
  box-shadow: 0 10px 20px -10px rgba(67, 56, 202, .65), inset 0 1px 0 rgba(255, 255, 255, .14);
}

/* ============================================================
   Sort-deck color variants — workflows = indigo + emerald accent
   ============================================================ */
.sort-deck-workflows::after {
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 50%, #34d399 100%);
}
.sort-deck-datasets::after {
  background: linear-gradient(90deg, var(--brand-2) 0%, #94a3b8 50%, #94a3b8 100%);
}

/* ============================================================
   Workflow card extras: pipeline + branch chips
   ============================================================ */
.workflow-card { border-left: 2px solid var(--brand); }
.workflow-card.card { flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.workflow-card .card-row { padding: 14px 18px 12px; }
.badge-pipeline {
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: #3730a3; background: #eef2ff;
  border: 1px solid #c7d2fe; border-radius: 999px;
  padding: 2px 9px;
}
.badge-branch {
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: #a21caf; background: #fdf4ff;
  border: 1px solid #f5d0fe; border-radius: 999px;
  padding: 2px 9px;
}

/* ============================================================
   Dataset card extras: dimensions / synthetic / curated chips
   ============================================================ */
.dataset-card { border-left: 2px solid var(--brand-2); }
.dataset-card.card { flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.card-row-flush { padding: 14px 18px 12px; }
.badge-dim {
  font-family: var(--mono); font-size: .68rem; font-weight: 700;
  letter-spacing: .04em;
  color: var(--brand); background: #eef2ff;
  border: 1px solid #c7d2fe; border-radius: 6px;
  padding: 2px 8px;
}
.badge-synth {
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 9px;
}
.curated-pill {
  font-family: var(--mono); font-size: .7rem; font-weight: 700;
  letter-spacing: .04em;
  color: var(--brand); background: rgba(67, 56, 202, .08);
  border: 1px solid rgba(67, 56, 202, .25); border-radius: 999px;
  padding: 2px 9px;
  display: inline-flex; align-items: center; gap: 4px;
}

/* ============================================================
   Card thumbnail · small figure inset on method list cards
   ============================================================ */
.card-thumb {
  flex: none; display: block; align-self: flex-start;
  width: 124px; height: 88px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.card-thumb:hover {
  transform: translateY(-1px); border-color: rgba(99, 102, 241, .4);
  box-shadow: 0 6px 18px -8px rgba(67, 56, 202, .35);
  text-decoration: none;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 720px) {
  .card-thumb { width: 88px; height: 66px; }
}

/* Markdown <img> figures in method detail prose — center, rounded, soft shadow */
.prose img {
  max-width: 100%; height: auto; display: block;
  margin: 16px auto; border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 26px -14px rgba(15, 23, 42, .22);
  background: var(--panel);
}
/* Markdown caption pattern: a paragraph that starts with "*Figure:" italic.
   We can't style by content, but the surrounding emphasis renders as <em>
   in a <p>. So we approximate with a centered, smaller caption look on
   the paragraph that directly follows a figure image. */
.prose p > em:first-child:only-child { color: var(--muted); font-size: .82rem; }
.prose img + p { text-align: center; }
.prose img + p em { color: var(--muted); font-size: .82rem; font-style: italic; }
.prose img + p a { color: var(--brand-2); }

/* Rail tier dots (staff-only datasets) */
.rail-tier-public .rail-dot { background: #94a3b8; }
.rail-tier-private .rail-dot { background: var(--neg); }
.rail-tier-hidden .rail-dot { background: #94a3b8; }

/* ============================================================
   FEED · Xiaohongshu-style masonry grid (homepage)
   ============================================================ */
.body-feed .page {
  display: flex; align-items: flex-start; gap: 32px;
  max-width: 1680px; margin: 0 auto; padding: 0 28px;
}
.body-feed .main { flex: 1 1 auto; min-width: 0; padding-top: 16px; }
.body-feed .main .container { padding: 0; max-width: none; }

/* Left rail — the FIELD catalogue. Pick your field once; it rarely changes,
   so it reads like settled navigation, each field with its own quiet colour. */
.feed-rail {
  flex: none; width: 312px; align-self: flex-start;
  position: sticky; top: 72px; max-height: calc(100vh - 88px);
  /* The rail scrolls independently when its content overflows — your sub-
     categories are reachable without scrolling the whole page. */
  display: flex; flex-direction: column;
  padding: 0 12px 14px; border-radius: 18px; overflow: hidden;
  background: color-mix(in srgb, var(--brand) 4%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 16%, var(--line));
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 18px 40px -30px rgba(15,23,42,.3); margin-top: 16px;
  /* Smooth compact ↔ expanded morph, not an instant jump. */
  transition: width .42s cubic-bezier(.22, .8, .25, 1), padding .42s cubic-bezier(.22, .8, .25, 1);
}
/* Labels and sub-menus fade with the width morph. visibility is delayed off so
   the fade animation completes before they become inert. */
.feed-rail-head-text,
.feed-rail-cat-name, .feed-rail-cat-count,
.feed-rail-toggle, .feed-rail-subs,
.feed-rail-collapse {
  transition: opacity .2s ease, visibility 0s linear .42s;
}
.feed-rail-cats {
  display: flex; flex-direction: column; gap: 3px;
  overflow-y: auto; flex: 1 1 auto; min-height: 0;
  margin: 0 -12px; padding: 0 12px 4px;
  /* Scrollbar lives in its own gutter: invisible by default; it appears only
     while the user is hovering the rail or actively scrolling, then fades back. */
  scrollbar-width: thin; scrollbar-color: transparent transparent;
  transition: scrollbar-color .25s ease;
}
.feed-rail:hover .feed-rail-cats { scrollbar-color: color-mix(in srgb, var(--brand) 28%, var(--line-2)) transparent; }
.feed-rail-cats::-webkit-scrollbar { width: 5px; }
.feed-rail-cats::-webkit-scrollbar-track { background: transparent; }
.feed-rail-cats::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; transition: background .25s ease; }
.feed-rail:hover .feed-rail-cats::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--brand) 28%, var(--line-2)); }
.feed-rail:hover .feed-rail-cats::-webkit-scrollbar-thumb:hover { background: var(--brand); }
.feed-rail-head {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: .65rem; font-weight: 700; letter-spacing: .22em;
  text-transform: uppercase; color: var(--brand);
  padding: 12px 14px 11px; margin: 0 -12px 9px;
  /* A light, indigo-lettered section label with a hairline rule — refined,
     part of the system, but not a heavy dark slab. */
  background: color-mix(in srgb, var(--brand) 6%, var(--panel));
  border-bottom: 1px solid color-mix(in srgb, var(--brand) 16%, var(--line));
}
.feed-rail-head-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Admin shortcut into the taxonomy editor — visible only to taxonomy admins. */
.feed-rail-editlink {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: inline-grid; place-items: center; line-height: 1;
  color: var(--brand); text-decoration: none; font-size: .78rem; font-style: normal;
  transition: background .14s;
}
.feed-rail-editlink:hover { background: color-mix(in srgb, var(--brand) 12%, var(--panel)); text-decoration: none; }
.feed-rail.is-compact .feed-rail-editlink { display: none; }
/* Compact mode: thin icon-strip rail once the user has seen it once. Click ⇥
   to pin it back to the full width. */
.feed-rail.is-compact { width: 64px; padding-left: 8px; padding-right: 8px; }
.feed-rail.is-compact .feed-rail-head { justify-content: center; padding: 12px 4px 11px; margin: 0 -8px 4px; }
.feed-rail.is-compact .feed-rail-head-text,
.feed-rail.is-compact .feed-rail-cat-name,
.feed-rail.is-compact .feed-rail-cat-count,
.feed-rail.is-compact .feed-rail-toggle,
.feed-rail.is-compact .feed-rail-collapse {
  opacity: 0; visibility: hidden;
  transition: opacity .12s ease, visibility 0s linear .12s;
}
/* Sub-category panels must COLLAPSE in compact mode, not just hide — otherwise
   an expanded sub (left over from when the rail was wide) keeps its layout
   space and produces big gaps between the dots. */
.feed-rail.is-compact .feed-rail-subs { display: none !important; }
.feed-rail.is-compact .feed-rail-row { margin: 0; display: block; }
/* The chevron toggle has to leave the layout (not just go invisible) — even
   visibility:hidden keeps its 26px width, which would shrink the cat button
   and shove the dot off the rail's centre. */
.feed-rail.is-compact .feed-rail-toggle { display: none !important; }
.feed-rail.is-compact .feed-rail-cats { gap: 2px; }
.feed-rail.is-compact .feed-rail-expand { opacity: 1; visibility: visible; }
/* The dot is positioned absolutely at the button's exact centre, so the
   (still-rendered) cat-name / count don't push it off-axis. Result: every dot
   in the rail sits on the same perfectly vertical line. */
.feed-rail.is-compact .feed-rail-cat {
  position: relative; height: 26px; padding: 0; pointer-events: none;
}
.feed-rail.is-compact .feed-rail-dot {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
/* Compact mode: hide the scrollbar entirely (the labels are gone, the list is
   short, no scrollbar needed) and stop hover from re-summoning it. */
.feed-rail.is-compact .feed-rail-cats {
  overflow: hidden; scrollbar-width: none;
}
.feed-rail.is-compact .feed-rail-cats::-webkit-scrollbar { width: 0; display: none; }
.feed-rail.is-compact:hover .feed-rail-cats { scrollbar-color: transparent transparent; }
/* In compact mode the rail is a pure peek — only the ⇥ expand button works.
   Dots LIGHT UP for any field whose sub-category is selected so the shrunk
   rail still tells you at a glance where your filters are. */
.feed-rail.is-compact .feed-rail-cat.active { animation: none; background: transparent; }
.feed-rail.is-compact .feed-rail-cat.active::before { display: none; }
.feed-rail.is-compact .feed-rail-dot { width: 7px; height: 7px; transition: background .18s, transform .18s; }
/* Active state combines the centering translate with the scale. */
.feed-rail.is-compact .feed-rail-cat.active .feed-rail-dot {
  background: var(--brand); transform: translate(-50%, -50%) scale(1.45);
}
/* Expand button always usable when compact; absent when expanded. */
.feed-rail-expand { display: none; opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility 0s linear .15s; }
.feed-rail.is-compact .feed-rail-expand { display: inline-grid; }
.feed-rail-expand { display: none; }
.feed-rail-collapse,
.feed-rail-expand {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  background: none; border: none; cursor: pointer; color: var(--brand);
  display: inline-grid; place-items: center; line-height: 1;
  transition: background .14s;
}
.feed-rail-collapse::before { content: "⇤"; font-size: .9rem; font-weight: 700; }
.feed-rail-collapse:hover,
.feed-rail-expand:hover { background: color-mix(in srgb, var(--brand) 12%, var(--panel)); }
.feed-rail-cat {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border-radius: 12px; color: var(--ink-2);
  font-family: inherit; font-size: .94rem; text-align: left;
  background: none; border: none; cursor: pointer;
  transition: background .14s, color .14s;
}
.feed-rail-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dot, #94a3b8);
}
.feed-rail-cat-name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-rail-cat-count { font-family: var(--mono); font-size: .74rem; color: var(--muted); flex: none; }
.feed-rail-cat:hover { text-decoration: none; background: var(--panel-2); color: var(--ink); }
.feed-rail-cat.active {
  background: color-mix(in srgb, var(--brand) 10%, var(--panel));
  color: var(--ink); font-weight: 600;
  transform-origin: left center; backface-visibility: hidden;
  animation: railFlip .6s cubic-bezier(.2, .8, .25, 1) both;
}
.feed-rail-cat.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.feed-rail-cat.active .feed-rail-dot { background: var(--brand); }
/* "Page-turn" highlight when a field is selected — the row swings in on its left
   hinge like a turned page, with a soft shadow that lifts as it lands flat. */
@keyframes railFlip {
  0%   { transform: perspective(680px) rotateY(-42deg); opacity: .2; box-shadow: 14px 0 22px -14px rgba(55,48,163,.5); }
  60%  { transform: perspective(680px) rotateY(7deg);   opacity: 1; box-shadow: 5px 0 14px -10px rgba(55,48,163,.35); }
  100% { transform: perspective(680px) rotateY(0);      opacity: 1; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { .feed-rail-cat.active { animation: none; } }
.feed-rail-cat.is-empty { opacity: .45; }
.feed-rail-cat.is-all .feed-rail-dot { background: var(--ink); box-shadow: none; }
.feed-rail-cat.is-all.active { background: var(--panel-2); }
.feed-rail-cat.is-all.active::before { background: var(--ink); }

/* Sub-categories: an expandable, multi-select list under each field. */
.feed-rail-hint { font-weight: 600; letter-spacing: .04em; opacity: .55; }
.feed-rail-group.is-empty { opacity: .42; }
.feed-rail-row { display: flex; align-items: center; }
.feed-rail-row .feed-rail-cat { flex: 1 1 auto; }
.feed-rail-toggle {
  flex: none; width: 26px; align-self: stretch; margin-right: 2px;
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: .7rem; line-height: 1; border-radius: 8px;
  transition: transform .18s, color .14s, background .14s;
}
.feed-rail-toggle:hover { color: var(--brand); background: var(--panel-2); }
.feed-rail-toggle.open { transform: rotate(180deg); color: var(--brand); }
.feed-rail-subs {
  display: flex; flex-direction: column; gap: 1px; margin: 1px 0 5px 16px; padding-left: 9px;
  border-left: 1px solid color-mix(in srgb, var(--brand) 18%, var(--line));
}
.feed-rail-sub {
  display: flex; align-items: flex-start; gap: 9px; width: 100%;
  padding: 6px 10px; border-radius: 9px; color: var(--muted);
  font-family: inherit; font-size: .82rem; text-align: left;
  background: none; border: none; cursor: pointer; transition: background .14s, color .14s;
}
.feed-rail-sub:hover { background: var(--panel-2); color: var(--ink); }
.feed-rail-sub-tick {
  flex: none; width: 13px; height: 13px; border-radius: 4px; margin-top: 2px;
  border: 1.5px solid var(--line-2); background: var(--panel);
  transition: background .14s, border-color .14s;
}
/* Labels wrap rather than truncate — the rail is wide enough that almost all
   fit one line, and the rest stay fully readable. */
.feed-rail-sub-name { flex: 1 1 auto; min-width: 0; white-space: normal; line-height: 1.35; }
.feed-rail-sub.active { color: var(--ink); font-weight: 600; background: color-mix(in srgb, var(--brand) 8%, var(--panel)); }
.feed-rail-sub.active .feed-rail-sub-tick { background: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--panel); }

/* Active-filter chips above the grid (removable). */
.feed-selected { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; flex: 1 1 auto; min-width: 0; }
.feed-sel-all { font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.feed-sel-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: .72rem; font-weight: 600; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 26%, var(--line));
  border-radius: 999px; padding: 4px 6px 4px 11px; cursor: pointer;
  transition: background .14s, border-color .14s;
}
.feed-sel-chip:hover { background: color-mix(in srgb, var(--brand) 14%, var(--panel)); border-color: var(--brand); }
.feed-sel-x { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 18%, transparent); font-size: .82rem; line-height: 1; }
/* One-click "Clear all" — neutral, set apart from the brand-coloured chips so
   it reads as a reset, not another selection. */
.feed-sel-clear {
  margin-left: 4px; font-family: var(--mono); font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  background: none; border: none; border-bottom: 1px dashed var(--line-2);
  padding: 4px 0; cursor: pointer; transition: color .14s, border-color .14s;
}
.feed-sel-clear:hover { color: var(--brand); border-bottom-color: var(--brand); }

.feed-head { display: flex; flex-direction: column; gap: 12px; margin: 0 0 18px; }
#feed-inner { position: relative; }
/* Invisible trigger below the grid: when it nears the viewport the next batch
   of cards is revealed (incremental, so a huge field isn't laid out at once). */
.feed-sentinel { height: 8px; }

/* Tags (left) + sort (right) share one row, under the search. */
.feed-filterbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border-bottom: 1px solid var(--line); padding-bottom: 11px;
}
.feed-tagrow {
  flex: 1 1 auto; min-width: 0;
  display: flex; gap: 7px; flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, #000 96%, transparent);
          mask-image: linear-gradient(90deg, #000 96%, transparent);
}
.feed-tagrow::-webkit-scrollbar { display: none; }
.feed-tagchip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--ink-2); font-size: .82rem; font-weight: 500;
  transition: background .14s, border-color .14s, color .14s, transform .12s;
}
.feed-tagchip:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--line-2); color: var(--ink); }
.feed-tagchip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.feed-tagchip.is-all { font-weight: 600; }
.feed-tagchip-n { font-family: var(--mono); font-size: .66rem; opacity: .68; }
.feed-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 3px 3px 3px 16px;
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
.feed-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-glow); }
.feed-search input[type=search] {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: var(--sans); font-size: .9rem; color: var(--ink); padding: 9px 0;
}
.feed-search input::placeholder { color: var(--muted); }
.feed-search button {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  background: var(--cta);              /* same tone as the Post button */
  color: #fff; border: none; cursor: pointer; font-size: 1rem;
  display: grid; place-items: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12); transition: background .15s;
}
.feed-search button:hover { background: var(--cta-h); }

.feed-sort { display: flex; gap: 2px; flex: none; font-family: var(--mono); font-size: .72rem; }
.feed-sort a {
  padding: 5px 10px; border-radius: 7px; color: var(--muted);
  letter-spacing: .05em; text-transform: uppercase; font-weight: 700;
}
.feed-sort a:hover { color: var(--ink); text-decoration: none; background: var(--panel-2); }
.feed-sort a.active { color: var(--ink); background: var(--panel-2); }

@media (max-width: 900px) {
  .body-feed .page { flex-direction: column; gap: 0; padding: 0 16px; }
  .feed-rail {
    position: static; width: 100%; margin-top: 12px; padding: 8px 8px 6px;
    background: transparent; border: none; box-shadow: none; backdrop-filter: none;
  }
  .feed-rail-head { display: none; }
  .feed-rail-cats { flex-direction: row; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
  .feed-rail-cats::-webkit-scrollbar { display: none; }
  .feed-rail-cat { flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; }
  .feed-rail-cat.active::before { display: none; }
  .feed-rail-cat-count { display: none; }
}

/* ── Masonry waterfall ───────────────────────────────────────────────
   JS (.js-masonry) packs cards into balanced columns and gives each cover
   the natural shape of its lead figure, so heights vary like a real
   waterfall and the columns stay level — no lopsided empty corner. Without
   JS it degrades to a tidy centred flex-wrap. */
.feed-grid {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 18px; margin-top: 18px;
}
.feed-grid.js-masonry { display: block; position: relative; }

.feed-card {
  flex: 1 1 250px; max-width: 340px;
  position: relative; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 14px 30px -24px rgba(15,23,42,.26);
  transition: transform .22s cubic-bezier(.2,.7,.3,1), box-shadow .28s, border-color .2s;
  animation: feedCardIn .5s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: calc(min(var(--i, 0), 14) * 40ms);
}
/* In masonry mode JS owns position via --x/--y; opacity drives entrance.
   The first layout positions cards instantly (no transform transition yet);
   `.is-live` is added on the next frame so later reflows/hover glide smoothly. */
.feed-grid.js-masonry .feed-card {
  flex: none; max-width: none; margin: 0; animation: none;
  position: absolute; top: 0; left: 0; opacity: 0;
  transform: translate3d(var(--x, 0), var(--y, 0), 0);
  transition: opacity .5s ease;
}
.feed-grid.js-masonry.is-live .feed-card {
  transition: transform .42s cubic-bezier(.2,.7,.3,1), box-shadow .28s, border-color .2s, opacity .5s ease;
}
.feed-grid.js-masonry .feed-card.is-in { opacity: 1; }
/* Popular sort — the top three cards stand out clearly from the rest through
   four layered cues, no heavy card-wide frame. Only kicks in when no filter
   is active.
     #1: a real INDIGO HEADER BAND with the "★ TOP PICK" label embedded —
         the unmistakable winner. Indigo glow underneath; title color shifts
         to indigo; biggest font; subtle indigo border to bind it together.
     #2: a slim indigo top stripe (4px); medium indigo glow; bigger title.
     #3: a hairline indigo top stripe (2px, lighter); soft glow; slightly
         bigger title. */
.feed-grid:not(.is-filtered) .feed-card.is-feat-1 {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  box-shadow: 0 5px 10px rgba(15,23,42,.06),
              0 32px 60px -20px color-mix(in srgb, var(--brand) 58%, transparent);
}
.feed-grid:not(.is-filtered) .feed-card.is-feat-2 {
  border-color: color-mix(in srgb, var(--brand) 18%, var(--line));
  box-shadow: 0 3px 7px rgba(15,23,42,.05),
              0 22px 40px -18px color-mix(in srgb, var(--brand) 32%, transparent);
}
.feed-grid:not(.is-filtered) .feed-card.is-feat-3 {
  box-shadow: 0 2px 5px rgba(15,23,42,.05),
              0 14px 26px -16px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* All three get a same-thickness indigo top stripe — the only difference is
   the shade: solid indigo on #1, 65% on #2, 35% on #3. No text, no star, no
   header band — the contrast comes from the shadow ladder + title size. */
.feed-grid:not(.is-filtered) .feed-card.is-feat-1::before,
.feed-grid:not(.is-filtered) .feed-card.is-feat-2::before,
.feed-grid:not(.is-filtered) .feed-card.is-feat-3::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  z-index: 5; pointer-events: none;
}
.feed-grid:not(.is-filtered) .feed-card.is-feat-1::before { background: var(--brand); }
.feed-grid:not(.is-filtered) .feed-card.is-feat-2::before { background: color-mix(in srgb, var(--brand) 65%, var(--panel)); }
.feed-grid:not(.is-filtered) .feed-card.is-feat-3::before { background: color-mix(in srgb, var(--brand) 35%, var(--panel)); }


/* Title ladder: bigger AND indigo on #1, just bigger on #2/#3. */
.feed-grid:not(.is-filtered) .feed-card.is-feat-1 .feed-card-title {
  font-size: 1.3rem; color: var(--brand);
}
.feed-grid:not(.is-filtered) .feed-card.is-feat-2 .feed-card-title { font-size: 1.22rem; }
.feed-grid:not(.is-filtered) .feed-card.is-feat-3 .feed-card-title { font-size: 1.17rem; }
/* Client-side field/tag filter: a card fades + shrinks out (then leaves the
   layout); a newly-matching card fades in at its final spot; the rest glide. */
.feed-grid.js-masonry .feed-card.is-out { display: none !important; }
.feed-grid.js-masonry .feed-card.is-leaving {
  opacity: 0 !important; pointer-events: none;
  transform: translate3d(var(--x, 0), var(--y, 0), 0) scale(.86) !important;
}
.feed-grid.js-masonry .feed-card.is-enter { opacity: 0 !important; transition: opacity .42s ease !important; }

.feed-card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--brand) 28%, var(--line-2));
  box-shadow: 0 28px 50px -26px rgba(67, 56, 202, .28), 0 6px 14px -8px rgba(15, 23, 42, .10);
}
.feed-grid.js-masonry .feed-card:hover {
  transform: translate3d(var(--x, 0), var(--y, 0), 0) translateY(-6px); z-index: 4;
}
@keyframes feedCardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .feed-card { animation: none; transition: box-shadow .2s, border-color .2s; }
  .feed-grid.js-masonry .feed-card { opacity: 1; transition: none; }
}
@media (max-width: 560px) { .feed-grid { gap: 12px; } .feed-card { max-width: none; } }

/* Body + footer share one positioned context so the title's stretched link
   covers them (but not the cover, whose slides/arrows stay clickable). */
.feed-card-main { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; }
.feed-card-title a.feed-card-link { color: inherit; text-decoration: none; }
.feed-card-title a.feed-card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.feed-card-title a.feed-card-link:hover { text-decoration: none; }

/* Cover — always an image; the figure is the hero */
.feed-cover { position: relative; width: 100%; background: var(--panel-2); display: block; overflow: hidden; box-shadow: inset 0 -1px 0 var(--line); }
.feed-cover img { width: 100%; height: auto; display: block; }
/* Subtle scrim so the pills overlaid at the bottom stay legible on any figure. */
.feed-cover-scrim {
  position: absolute; left: 0; right: 0; bottom: 0; height: 46%; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, .26));
  opacity: 0; transition: opacity .25s;
}
.feed-card:hover .feed-cover-scrim { opacity: 1; }

/* Swipeable figure gallery */
.feed-carousel { overflow: hidden; }
.feed-carousel-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.feed-carousel-track::-webkit-scrollbar { display: none; }
.feed-slide {
  flex: 0 0 100%; scroll-snap-align: center; display: block;
  aspect-ratio: var(--cover-ar, 1.34); overflow: hidden;
  background:
    radial-gradient(130% 130% at 50% 0%, #ffffff 52%, #e9eef6 100%);
}
.feed-slide img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transition: transform .4s cubic-bezier(.2,.7,.3,1);
}
.feed-card:hover .feed-slide img { transform: scale(1.045); }
.feed-car-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: rgba(15, 23, 42, .55); color: #fff; font-size: 1.1rem; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
  opacity: 0; transition: opacity .15s, background .15s; z-index: 2;
  backdrop-filter: blur(3px);
}
.feed-car-prev { left: 7px; }
.feed-car-next { right: 7px; }
.feed-card:hover .feed-car-arrow { opacity: 1; }
.feed-car-arrow:hover { background: rgba(15, 23, 42, .8); }
.feed-car-dots {
  position: absolute; bottom: 8px; left: 0; right: 0; z-index: 2;
  display: flex; justify-content: center; gap: 4px; pointer-events: none;
}
.feed-car-dot { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .55); box-shadow: 0 0 2px rgba(0,0,0,.4); transition: background .15s, transform .15s; }
.feed-car-dot.is-active { background: #fff; transform: scale(1.3); }
@media (hover: none) { .feed-car-arrow { display: none; } }
/* No figure? Lead with the result instead — the headline formula, or a clean
   summary "snapshot" card (outputs aren't always plots). */
.feed-cover-snap {
  display: flex; flex-direction: column; gap: 10px; justify-content: center;
  min-height: 150px; padding: 20px 18px; color: var(--ink); text-decoration: none;
  background:
    linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
}
.feed-cover-snap:hover { text-decoration: none; }
.feed-snap-kicker {
  font-family: var(--mono); font-size: .58rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.feed-snap-summary { margin: 0; font-size: .92rem; line-height: 1.5; color: var(--ink-2); }
.feed-snap-formula { color: var(--ink); overflow-x: auto; padding: 4px 0; }
.feed-snap-formula .katex { font-size: 1.12em; }
.feed-cover-steps {
  position: absolute; bottom: 8px; left: 8px; z-index: 2;
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 2px 8px; border-radius: 999px;
}


.feed-card-body { padding: 18px 20px 12px; flex: 1 1 auto; }
.feed-card-title {
  font-family: var(--serif);
  font-size: 1.14rem; font-weight: 600; line-height: 1.34; letter-spacing: -.003em; color: var(--ink);
  margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-card:hover .feed-card-title { color: var(--brand); }
.feed-card-summary {
  font-size: .87rem; line-height: 1.58; color: var(--muted); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* One compact top row per card: the Source citation (with a hairline divider)
   then the user tags — a single line, overflow faded on the right, no wasted
   height. Tags never reach the cover, so the figure is never obscured. */
.feed-topbar {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 6px;
  padding: 9px 14px 7px; overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, #000 92%, transparent);
          mask-image: linear-gradient(to right, #000 92%, transparent);
}
.feed-src {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  font-family: var(--mono); font-size: .56rem; font-weight: 700;
  color: var(--brand); text-decoration: none; white-space: nowrap;
  padding-right: 7px; margin-right: 1px; border-right: 1px solid var(--line);
}
.feed-src:hover { text-decoration: underline; }
.feed-src-x { opacity: .7; font-weight: 400; }
.feed-tag-chip {
  font-family: var(--mono); font-size: .58rem; font-weight: 600; letter-spacing: .01em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto;
  color: var(--ink-2); background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  transition: color .16s ease, border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
.feed-tag-chip:hover {
  text-decoration: none; transform: translateY(-1px);
  color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line-2));
  background: color-mix(in srgb, var(--brand) 6%, #fff);
  box-shadow: 0 4px 10px -4px rgba(67, 56, 202, .3);
}
/* Small "verified" check for official package accounts. */
.feed-verified {
  display: inline-grid; place-items: center; flex: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: .56rem; font-weight: 900; line-height: 1;
}
/* Three independent badges: author (filled indigo), platform (filled with a P),
   data (outlined with a D). A card can carry any combination. */
.feed-badges { display: inline-flex; gap: 3px; flex: none; }
.feed-badge {
  display: inline-grid; place-items: center; flex: none;
  width: 14px; height: 14px; border-radius: 50%;
  font-family: var(--mono); font-size: .56rem; font-weight: 900; line-height: 1; letter-spacing: 0;
}
.feed-badge.fb-author   { background: var(--brand); color: #fff; }
.feed-badge.fb-platform { background: color-mix(in srgb, var(--brand) 22%, var(--panel)); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--line)); }
.feed-badge.fb-data     { background: var(--panel); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--line)); }
.feed-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 20px 14px; font-size: .8rem; gap: 8px;
  margin-top: auto; border-top: 1px solid var(--line);
}
.feed-author { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); min-width: 0; }
/* Certified authors get a gold gradient ring around their avatar. */
.feed-ava { display: inline-flex; border-radius: 50%; flex: none; }
.feed-ava.is-cert { padding: 1.5px; background: var(--brand); box-shadow: 0 0 0 1px #fff inset; }
.feed-ava.is-cert .avatar { box-shadow: 0 0 0 1.5px #fff; }
.feed-author-name {
  font-family: var(--mono); font-size: .74rem; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.feed-stats { display: inline-flex; align-items: center; gap: 9px; flex: none; }
.feed-likes, .feed-cmts {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600;
}
.feed-likes .heart { color: var(--brand); font-size: .8rem; line-height: 1; }
.feed-cmts { font-size: .72rem; }
.feed-cmts .cmt-mark { color: var(--muted); font-style: normal; font-variant-emoji: text; }
.feed-empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: .9rem; grid-column: 1 / -1; flex: 1 0 100%; }


/* ============================================================
   WORKFLOW DETAIL · input → pipeline → output tutorial blocks
   ============================================================ */
.wf-detail { max-width: 1100px; margin-left: auto; margin-right: auto; }
/* Discussion lives outside the .wf-detail article — keep it the same width so
   the page doesn't have a narrow article above a wide-open comment section. */
.wf-detail + #comments { max-width: 1100px; margin-left: auto; margin-right: auto; }
.detail + #comments { max-width: 1100px; margin-left: auto; margin-right: auto; }
/* Quieter kicker: no pill, no special glyphs — just a small mono label that
   sits under the title rather than crowding the head. */
.wf-kicker {
  display: inline-block; font-family: var(--mono); font-size: .62rem;
  font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.wf-kicker-sep { display: inline-block; margin: 0 6px; color: color-mix(in srgb, var(--muted) 50%, var(--line-2)); }
.wf-detail .detail-head h1 { letter-spacing: -.005em; }

/* Source citation under the byline — understated (a dashed-underlined link, not
   a heavy box) with a BibTeX toggle that reveals a copyable entry. */
.wf-cite {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  /* Symmetric breathing room above and below — same gap from the tags as to
     the AI summary that follows. */
  margin: 18px 0 18px; font-size: .88rem;
}
.wf-source {
  display: inline-flex; align-items: baseline; gap: 7px; color: var(--ink);
  text-decoration: none; padding-bottom: 1px;
  border-bottom: 1px dashed color-mix(in srgb, var(--brand) 45%, var(--line-2));
}
.wf-source:hover { border-bottom-style: solid; text-decoration: none; }
.wf-source-k {
  flex: none; font-family: var(--mono); font-size: .58rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.wf-source-label { font-weight: 600; }
.wf-source-x { color: var(--brand); font-weight: 700; }
.wf-cite-btn {
  font-family: var(--mono); font-size: .62rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--brand); cursor: pointer;
  background: color-mix(in srgb, var(--brand) 7%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--line));
  border-radius: 6px; padding: 4px 9px; transition: background .14s;
}
.wf-cite-btn:hover { background: color-mix(in srgb, var(--brand) 13%, var(--panel)); }
.wf-bibtex {
  flex-basis: 100%; position: relative; margin: 2px 0 0;
  background: var(--ink); border-radius: 10px; overflow: hidden;
}
.wf-bibtex pre {
  margin: 0; padding: 13px 15px; color: #e2e8f0; overflow-x: auto;
  font-family: var(--mono); font-size: .76rem; line-height: 1.55; white-space: pre;
}
.wf-bibtex-copy {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  font-family: var(--mono); font-size: .58rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #cbd5e1; cursor: pointer;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px; padding: 3px 8px; transition: background .14s, color .14s;
}
.wf-bibtex-copy:hover { background: rgba(255,255,255,.16); color: #fff; }

.io-block {
  position: relative;
  display: grid; grid-template-columns: 34px 1fr; gap: 16px;
  margin: 22px 0;
  padding-left: 2px;
}
/* connecting spine between the numbered nodes */
.io-block:not(:last-of-type)::before {
  content: ""; position: absolute; left: 16px; top: 40px; bottom: -22px;
  width: 2px; background: linear-gradient(180deg, var(--brand), var(--brand-2));
  opacity: .25;
}
.io-step-num {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 800; font-size: 1rem;
  color: #fff; background: linear-gradient(135deg, var(--brand), #3730a3);
  box-shadow: 0 6px 14px -7px rgba(67, 56, 202, .6);
  position: relative; z-index: 1;
}
.io-output .io-step-num { background: var(--ink); }
.io-content { min-width: 0; }
.io-label {
  font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em;
  margin: 4px 0 12px; color: var(--ink);
  display: flex; align-items: center; gap: 10px;
}
.io-input .io-content {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px;
}
.io-input .io-label { margin-top: 0; }
.io-input .prose { color: var(--ink-2); }
.io-input .prose p { margin: 0; }

/* Result figures: a tidy, centred gallery of uniformly-sized cards instead of
   full-width images sprawling down the page. Tall figures letterbox cleanly. */
/* A justified gallery: each figure keeps its natural shape (wide plots go wide,
   tall ones go narrow) and they tile side by side, wrapping as needed — instead
   of every figure forced into one full-width column. */
/* Uniform gallery: every figure is the SAME size cell (the image is letterboxed
   inside a fixed box), so a tall plot and a wide plot read as one tidy set
   rather than a jumble of big-and-small. */
.io-figures {
  display: grid; gap: 16px; margin: 12px 0;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  justify-content: center;
}
.io-figure {
  margin: 0; display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: var(--panel); box-shadow: var(--shadow);
}
.io-figure img {
  display: block; width: 100%; height: 280px; object-fit: contain;
  background: #fff; padding: 10px;
}
/* A lone figure shouldn't stretch full-width — keep it a tidy, centred card. */
.io-figures:has(> .io-figure:only-child) { grid-template-columns: minmax(0, 460px); }
.io-figure figcaption {
  font-size: .8rem; color: var(--ink-2); padding: 9px 13px; line-height: 1.5;
  border-top: 1px solid var(--line); background: var(--panel-2);
  text-align: left;
}
.io-figure figcaption a { color: var(--brand); }
.io-fig-n {
  display: inline-block; font-family: var(--mono); font-size: .58rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--brand);
  background: rgba(67, 56, 202, .08); border: 1px solid rgba(67, 56, 202, .16);
  padding: 1px 6px; border-radius: 4px; margin-right: 8px; vertical-align: 1px; white-space: nowrap;
}
.io-fig-count { font-family: var(--mono); font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.io-fig-credit { font-size: .76rem; color: var(--muted); margin: 4px 0 10px; }
.io-fig-credit a { color: var(--brand-2); }
.branch-flag {
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: #a21caf; background: #fdf4ff;
  border: 1px solid #f5d0fe; border-radius: 999px; padding: 2px 8px;
}
@media (max-width: 600px) {
  .io-block { grid-template-columns: 28px 1fr; gap: 12px; }
  .io-block:not(:last-of-type)::before { left: 13px; }
  .io-step-num { width: 28px; height: 28px; font-size: .85rem; }
}

/* ============================================================
   TECHNIQUE provenance · library intro · used-in back-links
   ============================================================ */
.lib-intro { text-align: center; margin: 4px 0 4px; }
.lib-title { font-size: 1.6rem; letter-spacing: -.025em; margin: 0 0 4px; }
.lib-title::after { content: none; }
.lib-sub { color: var(--muted); font-size: .92rem; margin: 0 auto; max-width: 64ch; }
.lib-sub a { color: var(--brand); font-weight: 600; }

.provenance-note {
  font-size: .85rem; line-height: 1.55; color: var(--ink-2);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 8px; padding: 10px 14px; margin: 12px 0;
}
.provenance-note a { color: var(--brand); font-weight: 600; }

.used-pill {
  font-family: var(--mono); font-size: .6rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px;
  background: #eef2ff; color: var(--brand); border: 1px solid #c7d2fe;
}

.used-in { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.used-in h2 { font-size: 1.1rem; margin: 0 0 12px; }
.used-in .cards { gap: 10px; }
.used-in .card { padding: 12px 14px; }

/* Method cover fallback in the Techniques grid (no figure → estimand slab) */
.feed-cover-method {
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,.16), transparent 65%),
    linear-gradient(160deg, #3730a3 0%, #1e1b4b 100%);
}
.feed-cover-estimand {
  font-family: var(--mono); font-weight: 800; font-size: 1.5rem;
  letter-spacing: .04em; color: #fff; text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.byline .avatar { vertical-align: middle; }

/* ============================================================
   PIPELINE · structure diagram (layered DAG) + expandable steps
   ============================================================ */
.wf-diagram {
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  margin: 4px 0 20px; padding: 16px;
  background:
    radial-gradient(ellipse 70% 60% at 15% 0%, rgba(99,102,241,.06), transparent 70%),
    radial-gradient(ellipse 70% 60% at 90% 100%, rgba(55,48,163,.05), transparent 70%),
    var(--panel-2);
  border: 1px solid var(--line); border-radius: 14px;
}
.wf-diagram-layer { display: flex; gap: 10px; justify-content: center; align-items: stretch; flex-wrap: wrap; }
.wf-diagram-layer.is-parallel {
  background: linear-gradient(180deg, rgba(99,102,241,.05), rgba(55,48,163,.04));
  border: 1px dashed rgba(99,102,241,.22); border-radius: 10px; padding: 7px;
}
.wf-diagram-arrow { text-align: center; color: rgba(99,102,241,.4); font-size: .7rem; line-height: 1.5; font-family: var(--mono); }
.wf-node {
  display: inline-flex; align-items: center; gap: 9px; text-align: left;
  padding: 8px 13px; border-radius: 9px; min-width: 0; max-width: 320px; flex: 0 1 auto;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  box-shadow: 0 1px 2px rgba(15,23,42,.04); cursor: pointer; font: inherit;
  transition: transform .15s, border-color .15s, box-shadow .2s;
}
.wf-node:hover {
  text-decoration: none; transform: translateY(-2px);
  border-color: rgba(99,102,241,.4);
  box-shadow: 0 10px 22px -12px rgba(67,56,202,.3);
}
.wf-node.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow), 0 10px 22px -12px rgba(67,56,202,.35);
}
.wf-node-num {
  flex: none; width: 20px; height: 20px; border-radius: 6px;
  display: grid; place-items: center; font-family: var(--mono); font-weight: 800;
  font-size: .72rem; color: #fff; background: linear-gradient(135deg, var(--brand), #3730a3);
}
.wf-node .vpipe-dot { width: 8px; height: 8px; }
.wf-node-text { display: flex; flex-direction: column; min-width: 0; gap: 0; }
.wf-node-stage { font-family: var(--mono); font-size: .58rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.wf-node-title { font-size: .85rem; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Detail area: nothing until a node is clicked (JS adds .is-active). */
.pipe-detail-area { margin-top: 4px; }
.pipe-placeholder {
  text-align: center; font-size: .84rem; color: var(--muted); font-family: var(--mono);
  padding: 22px 16px; border: 1px dashed var(--line); border-radius: 12px; background: var(--panel-2);
  margin: 0;
}
.pipe-detail { display: none; }
.pipe-detail.is-active { display: block; }
.pipe-detail {
  border: 1px solid var(--line); border-left: 3px solid var(--line-2);
  border-radius: 12px; background: var(--panel); padding: 18px 20px;
  animation: pipe-fade .22s ease;
}
@keyframes pipe-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.pipe-detail.vpipe-diagnostic { border-left-color: #94a3b8; }
.pipe-detail.vpipe-prep { border-left-color: #6366f1; }
.pipe-detail.vpipe-estimation { border-left-color: var(--brand); }
.pipe-detail.vpipe-inference { border-left-color: var(--pos); }
.pipe-detail.vpipe-robustness { border-left-color: var(--neg); }
.pipe-detail.vpipe-heterogeneity { border-left-color: #94a3b8; }
.pipe-detail.vpipe-reporting { border-left-color: #94a3b8; }
.pipe-detail.vpipe-other { border-left-color: #94a3b8; }

.pipe-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.pipe-detail-headtext { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.pipe-detail-headtext .vpipe-stage { font-family: var(--mono); }
.pipe-detail-title { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -.015em; color: var(--ink); }
.pipe-role { margin: 4px 0 14px; color: var(--muted); font-size: .9rem; font-style: italic; }

.pipe-detail .pipe-block { margin-bottom: 14px; }
.pipe-detail .pipe-block-text { font-size: .95rem; line-height: 1.55; }
.pipe-io { display: flex; flex-wrap: wrap; gap: 18px; margin: 0 0 14px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.pipe-io-item { font-size: .84rem; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.pipe-io-k { font-family: var(--mono); font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pipe-step {
  position: relative;
  border: 1px solid var(--line); border-left: 3px solid var(--line-2);
  border-radius: 12px; background: var(--panel);
  padding: 12px 14px; scroll-margin-top: 70px;
  transition: border-color .15s, box-shadow .2s;
}
.pipe-step:target { box-shadow: 0 0 0 3px var(--brand-glow); border-left-color: var(--brand); }
/* stage accent on the left bar */
.pipe-step.vpipe-diagnostic { border-left-color: #94a3b8; }
.pipe-step.vpipe-prep { border-left-color: #6366f1; }
.pipe-step.vpipe-estimation { border-left-color: var(--brand); }
.pipe-step.vpipe-inference { border-left-color: var(--pos); }
.pipe-step.vpipe-robustness { border-left-color: var(--neg); }
.pipe-step.vpipe-heterogeneity { border-left-color: #94a3b8; }
.pipe-step.vpipe-reporting { border-left-color: #94a3b8; }
.pipe-step.vpipe-other { border-left-color: #94a3b8; }

.pipe-step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pipe-step-num {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 800; font-size: .8rem;
  color: #fff; background: linear-gradient(135deg, var(--brand), #3730a3);
}
.pipe-step-head .vpipe-dot { width: 9px; height: 9px; }
.pipe-step-headtext { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.pipe-step-headtext .vpipe-stage { font-family: var(--mono); }
.pipe-step-title { font-weight: 600; font-size: 1rem; color: var(--ink); letter-spacing: -.01em; }
.pipe-step-deps { font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.pipe-step-note { margin: 8px 0 0 34px; color: var(--ink-2); font-size: .9rem; line-height: 1.5; }

.pipe-more { margin: 8px 0 0 34px; }
.pipe-more > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: .76rem; font-weight: 700;
  color: var(--brand); letter-spacing: .03em;
  padding: 3px 0;
}
.pipe-more > summary::-webkit-details-marker { display: none; }
.pipe-more > summary::before { content: "▸ "; }
.pipe-more[open] > summary::before { content: "▾ "; }
.pipe-more .pipe-more-close { display: none; }
.pipe-more[open] .pipe-more-open { display: none; }
.pipe-more[open] .pipe-more-close { display: inline; }
.pipe-more-count { color: var(--muted); font-weight: 500; }
.pipe-more-body {
  margin-top: 10px; padding: 12px 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; gap: 14px;
}
.pipe-block-label, .pipe-comments-label {
  display: block; font-family: var(--mono); font-size: .64rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.pipe-code .prose pre { margin: 0; }
.pipe-formula { padding: 8px 2px; overflow-x: auto; }
.pipe-formula .katex { font-size: 1.2em; }
.pipe-ref { margin: 0; font-size: .82rem; }

/* richer expand: meta row + 'what this is' block */
.pipe-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.pipe-meta-item {
  font-family: var(--mono); font-size: .72rem; color: var(--ink-2);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px;
}
.pipe-meta-k { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .62rem; margin-right: 4px; }
.pipe-block-text { margin: 0 0 8px; font-size: .9rem; color: var(--ink-2); line-height: 1.5; }
.pipe-block-links { display: flex; flex-wrap: wrap; gap: 12px; font-size: .82rem; }
.pipe-block-links code { font-size: .76rem; padding: 0 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; color: var(--brand); }
.io-input-more { margin: 10px 0 0; }

.pipe-comments { border-top: 1px solid var(--line); padding-top: 12px; }
.pipe-comment-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pipe-comment { display: flex; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pipe-comment .votebox { transform: scale(.85); transform-origin: top center; }
.pipe-comment-body { flex: 1; min-width: 0; }
.pipe-comment-body .comment-meta { font-size: .76rem; margin-bottom: 2px; }
.pipe-comment-body .prose { font-size: .88rem; }
.pipe-comment-empty { font-size: .84rem; padding: 4px 2px; list-style: none; }
.pipe-comment-form { display: flex; gap: 8px; align-items: flex-start; }
.pipe-comment-form textarea {
  flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: .88rem; resize: vertical; min-height: 38px; background: var(--panel);
}
.pipe-comment-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.pipe-login { font-size: .84rem; margin: 0; }
@media (max-width: 600px) {
  .pipe-step-note, .pipe-more { margin-left: 0; }
}

.formwrap-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.guide-btn { flex: none; white-space: nowrap; }

/* ============================================================
   TAXONOMY ADMIN · /taxonomy/ — edit the left-rail catalogue
   ============================================================ */
.tax-admin { max-width: 1000px; margin: 18px auto 48px; }
.tax-head h1 { font-family: var(--serif); font-size: 1.7rem; letter-spacing: -.005em; margin: 8px 0 8px; }
.tax-sub { color: var(--muted); font-size: .92rem; margin: 0 0 24px; max-width: 720px; line-height: 1.6; }

.tax-field {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.tax-field-head {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px;
  background: color-mix(in srgb, var(--brand) 4%, var(--panel));
  border-bottom: 1px solid var(--line);
}
.tax-move { display: flex; flex-direction: column; gap: 3px; flex: none; padding-top: 2px; }
.tax-move form { margin: 0; line-height: 0; }
.tax-move button {
  width: 24px; height: 19px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 5px; cursor: pointer; color: var(--muted); font-size: .58rem; line-height: 1;
  transition: color .14s, border-color .14s;
}
.tax-move button:hover:not(:disabled) { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.tax-move button:disabled { opacity: .35; cursor: default; }
.tax-move-h { flex-direction: row; padding-top: 0; }

.tax-field-main { flex: 1 1 auto; min-width: 0; }
.tax-name {
  font-family: var(--serif); font-size: 1.18rem; font-weight: 600; margin: 0;
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
}
.tax-slug {
  font-family: var(--mono); font-size: .64rem; font-weight: 600; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--line));
  padding: 1px 8px; border-radius: 999px;
}
.tax-count { font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.tax-blurb { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
.tax-tagrow { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tax-tagrow-inline { margin-top: 0; }
.tax-tag {
  font-family: var(--mono); font-size: .62rem; color: var(--ink-2);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 7px;
}
.tax-tag.is-unused { color: var(--muted); border-style: dashed; opacity: .75; }
.tax-none { color: var(--muted); font-size: .78rem; font-style: italic; }
.tax-none-block { padding: 4px 2px; margin: 0; }

.tax-actions { display: flex; align-items: flex-start; gap: 10px; flex: none; }
.tax-toggle > summary {
  cursor: pointer; list-style: none; display: inline-block;
  font-family: var(--mono); font-size: .66rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, var(--line));
  background: var(--panel); border-radius: 7px; padding: 4px 10px;
  transition: background .14s;
}
.tax-toggle > summary::-webkit-details-marker { display: none; }
.tax-toggle > summary:hover { background: color-mix(in srgb, var(--brand) 8%, var(--panel)); }
.tax-toggle[open] > summary { background: color-mix(in srgb, var(--brand) 10%, var(--panel)); }
.tax-del {
  font-family: var(--mono); font-size: .66rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--neg);
  border: 1px solid #fecaca; background: var(--panel); border-radius: 7px;
  padding: 4px 10px; cursor: pointer; transition: background .14s;
}
.tax-del:hover { background: #fef2f2; }

/* Edit/add forms drop below the row, full width, on a quiet panel. */
.tax-field-head .tax-toggle, .tax-sub-row .tax-toggle { position: relative; }
.tax-form {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 8;
  width: min(560px, 82vw);
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 14px; background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-radius: 12px; box-shadow: var(--shadow-elev);
}
.tax-add .tax-form { position: static; width: 100%; box-shadow: none; background: var(--panel-2); border-color: var(--line); margin-top: 8px; }
.tax-form label {
  display: block; font-family: var(--mono); font-size: .6rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.tax-form input {
  width: 100%; box-sizing: border-box; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: .9rem; background: #fff; color: var(--ink);
}
.tax-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.tax-form .full { grid-column: 1 / -1; }
.tax-form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

.tax-subs { padding: 10px 16px 14px 44px; display: flex; flex-direction: column; gap: 7px; }
.tax-sub-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
}
.tax-sub-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tax-sub-name { font-size: .92rem; font-weight: 600; color: var(--ink); }
.tax-add { margin-top: 4px; }

.tax-new {
  border: 1px dashed var(--line-2); border-radius: 14px; padding: 16px;
  background: color-mix(in srgb, var(--brand) 2%, var(--panel)); margin-top: 24px;
}
.tax-new-h { font-family: var(--serif); font-size: 1.1rem; margin: 0 0 12px; }
.tax-new .tax-form { position: static; width: 100%; box-shadow: none; border: none; padding: 0; background: transparent; }
@media (max-width: 640px) {
  .tax-field-head { flex-wrap: wrap; }
  .tax-subs { padding-left: 16px; }
  .tax-form { position: static; width: 100%; }
}

/* ============================================================
   VERIFICATION · apply (/verification/) + admin review
   ============================================================ */
.vr-form { margin-bottom: 28px; }
.vr-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-bottom: 16px; }
.vr-kind input { position: absolute; opacity: 0; pointer-events: none; }
.vr-kind { display: block; cursor: pointer; }
.vr-kind.is-held { cursor: default; opacity: .6; }
.vr-kind-card {
  display: flex; flex-direction: column; gap: 7px; height: 100%;
  padding: 14px 15px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, background .15s;
}
.vr-kind:hover .vr-kind-card { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.vr-kind input:checked + .vr-kind-card {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 5%, var(--panel));
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.vr-kind-head { display: flex; align-items: center; gap: 8px; }
.vr-kind-label { font-weight: 600; font-size: .95rem; color: var(--ink); }
.vr-held { font-family: var(--mono); font-size: .6rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--pos); }
.vr-kind-blurb { font-size: .8rem; line-height: 1.5; color: var(--muted); }

.vr-fields { display: flex; flex-direction: column; gap: 12px; }
.vr-label { display: block; font-family: var(--mono); font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.vr-select, .vr-textarea {
  width: 100%; box-sizing: border-box; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  font-family: inherit; font-size: .92rem; background: var(--panel); color: var(--ink);
}
.vr-select:focus, .vr-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.vr-textarea { resize: vertical; }

.vr-mine { margin-top: 8px; }
.vr-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); margin-bottom: 7px; font-size: .88rem;
}
.vr-row-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.vr-row-kind { font-weight: 600; color: var(--ink); }
.vr-row-wf { font-size: .82rem; }
.vr-row-note { font-size: .8rem; color: var(--muted); font-style: italic; flex-basis: 100%; }
.vr-row-date { font-family: var(--mono); font-size: .7rem; color: var(--muted); flex: none; }
.vr-status {
  flex: none; font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid;
}
.vr-status-pending  { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); background: color-mix(in srgb, var(--brand) 7%, var(--panel)); }
.vr-status-approved { color: var(--pos); border-color: #abefc6; background: #ecfdf3; }
.vr-status-rejected { color: var(--neg); border-color: #fecdca; background: #fef3f2; }

.vr-req .tax-field-head { border-bottom: none; }
.vr-req-who { display: flex; align-items: center; gap: 7px; margin: 6px 0 0; font-size: .88rem; color: var(--muted); }
.vr-req-msg { margin: 8px 0 0; font-size: .9rem; color: var(--ink-2); line-height: 1.55; }
.vr-decide {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-top: 1px solid var(--line); background: var(--panel-2);
}
.vr-note { flex: 1 1 auto; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: .85rem; background: var(--panel); }
.vr-note:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.vr-reject { flex: none; }
.vr-history-h { margin-top: 26px; }
.pf-verified { vertical-align: 6px; }

/* Admin moderation buttons */
.btn-admin-del { color: var(--neg); border-color: #fecaca; }
.btn-admin-del:hover { background: #fef2f2; border-color: var(--neg); }
.cmt-del-form { margin-left: 4px; }
.cmt-del {
  background: none; border: none; cursor: pointer; padding: 0 2px;
  font-family: var(--mono); font-size: .66rem; font-weight: 600;
  color: var(--muted); border-bottom: 1px dashed var(--line-2);
  transition: color .14s, border-color .14s;
}
.cmt-del:hover { color: var(--neg); border-bottom-color: var(--neg); }

/* ============================================================
   AI IMPORTER · /import/ — webpage → draft card, chat refinement
   ============================================================ */
.imp-nokey {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 18px;
  background: #fef3f2; border: 1px solid #fecdca; color: var(--neg); font-size: .9rem;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.imp-busy {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 18px;
  background: #eef2ff; border: 1px solid #c7d2fe; color: var(--brand); font-size: .9rem;
}
.imp-busy-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--brand); flex: none;
  animation: imp-pulse 1.1s ease-in-out infinite;
}
@keyframes imp-pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
.imp-textarea {
  width: 100%; box-sizing: border-box; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px; resize: vertical;
  font-family: inherit; font-size: .92rem; background: #fff; color: var(--ink);
}
.imp-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.imp-wait { font-size: .8rem; color: var(--brand); margin-right: auto; }
.tax-form-actions { align-items: center; gap: 12px; }
.imp-list-h { margin-top: 26px; }

/* Session page: full-width split — chat left, live preview right. */
.page-wide .container { max-width: none; }
.imp-session { max-width: 1640px; margin: 14px auto 30px; }
.imp-session-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.imp-session-title { font-family: var(--serif); font-size: 1.4rem; letter-spacing: -.005em; margin: 6px 0 4px; }
.imp-back {
  display: inline-block; margin-bottom: 4px;
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  letter-spacing: .04em; color: var(--muted); text-decoration: none;
}
.imp-back:hover { color: var(--brand); }
.imp-session-src a { font-family: var(--mono); font-size: .74rem; color: var(--muted); }
.imp-session-actions { display: flex; align-items: center; gap: 9px; flex: none; padding-top: 6px; }

.imp-split { display: grid; grid-template-columns: minmax(330px, 2fr) 3fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .imp-split { grid-template-columns: 1fr; } }
.imp-col-h { font-family: var(--serif); font-size: 1.05rem; margin: 0 0 10px; }
.imp-col-hint { font-family: var(--sans); font-size: .78rem; font-weight: 400; color: var(--muted); }

.imp-chat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 14px 16px;
  position: sticky; top: 72px; max-height: calc(100vh - 95px);
  display: flex; flex-direction: column;
}
.imp-chat-log { overflow-y: auto; flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.imp-msg { padding: 9px 12px; border-radius: 11px; max-width: 92%; }
.imp-msg-user { align-self: flex-end; background: color-mix(in srgb, var(--brand) 7%, var(--panel)); border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--line)); }
.imp-msg-assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.imp-msg-who { display: block; font-family: var(--mono); font-size: .58rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.imp-msg-text { margin: 0; font-size: .88rem; line-height: 1.55; white-space: pre-wrap; }
.imp-chat-form { margin-top: 12px; }
.imp-chat-form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.imp-lessons-form { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.imp-guidelink { font-size: .78rem; color: var(--muted); }

.imp-preview { min-width: 0; }
.imp-frame {
  width: 100%; height: calc(100vh - 150px); min-height: 540px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
  box-shadow: var(--shadow);
}
/* Double-buffered preview: two stacked iframes; the fresh snapshot loads in
   the hidden one and crossfades in, so the page itself never flashes. */
.imp-frame-stack { position: relative; height: calc(100vh - 150px); min-height: 540px; }
.imp-frame-abs {
  position: absolute; inset: 0; height: 100%; min-height: 0;
  opacity: 0; pointer-events: none; transition: opacity .4s ease;
}
.imp-frame-abs.is-front { opacity: 1; pointer-events: auto; }
.imp-frame-placeholder { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; }

/* Inline editor on draft cards (admin / author only) — hover any editable
   field to see a pencil affordance, click to open a textarea in place. */
.wf-edit-target {
  position: relative; cursor: text; border-radius: 8px;
  transition: background-color .15s ease, box-shadow .15s ease;
  outline-offset: 2px;
}
.wf-edit-target:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent); }
.wf-edit-target::after {
  content: "✎"; position: absolute; top: 4px; right: 6px;
  font-size: .75rem; color: var(--brand); opacity: 0;
  transition: opacity .15s ease; pointer-events: none;
}
.wf-edit-target:hover::after { opacity: .85; }
.wf-edit-flash { animation: wf-edit-flash 0.9s ease-out; }
@keyframes wf-edit-flash {
  0% { background: color-mix(in srgb, var(--brand) 22%, transparent); }
  100% { background: transparent; }
}
.wf-edit-shell {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--brand);
  border-radius: 10px; background: #fff;
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.wf-edit-input {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit; color: inherit;
  background: #fff; resize: vertical;
}
.wf-edit-input:focus { outline: none; border-color: var(--brand); }
.wf-edit-shell-mdblock .wf-edit-input { font-family: var(--mono); font-size: .9rem; line-height: 1.55; }
.wf-edit-shell-text .wf-edit-input { font-size: 1rem; }
/* Editing the H1 title: match the heading's typography so the input looks
   like an inline replacement, not a tiny popup. Also break the parent flex
   so the editor stretches to the full content width. */
.wf-edit-shell-h1 { width: 100%; flex: 1 1 100%; box-sizing: border-box; }
.wf-edit-input-h1 {
  font-family: var(--serif); font-size: 1.4rem; font-weight: 700;
  letter-spacing: -.005em; padding: 10px 14px;
}
/* While editing the title, give the headmain column 100% of its flex row
   so the editor stretches to the actual page width and the action buttons
   wrap to the next line. */
.imp-session-head.is-editing-title .imp-session-headmain { flex-basis: 100%; width: 100%; }
.imp-session-head.is-editing-title .imp-session-actions { width: 100%; justify-content: flex-end; }
.wf-edit-actions { display: flex; align-items: center; gap: 10px; }
.wf-edit-state { flex: 1 1 auto; font-size: .8rem; color: var(--muted); }

/* "StatsDoge is typing" bubble */
.imp-msg-typing .imp-msg-text { display: flex; align-items: center; gap: 9px; }
.imp-typing-note { font-size: .8rem; color: var(--muted); }
.imp-dots { display: inline-flex; gap: 4px; align-items: center; }
.imp-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
  animation: imp-dot 1.2s ease-in-out infinite;
}
.imp-dots i:nth-child(2) { animation-delay: .18s; }
.imp-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes imp-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Guidelines editor */
.imp-doc-form { padding: 12px 14px; }
.imp-doc-textarea {
  width: 100%; box-sizing: border-box; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; resize: vertical;
  font-family: var(--mono); font-size: .8rem; line-height: 1.6;
  background: #fcfcfd; color: var(--ink); tab-size: 2;
}
.imp-doc-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.imp-doc-actions { margin-top: 9px; }

/* Footer */
.footer { margin-top: 40px; padding: 22px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

/* Sidebar edit history: one row per revision, click for detail. */
.tax-history .tax-head .inline-form { margin-top: 10px; }
.tax-rev-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr) 110px 90px;
  align-items: center; gap: 14px;
  padding: 11px 14px; margin-bottom: 7px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-size: .88rem;
}
.tax-rev-when { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.tax-rev-label { font-weight: 600; color: var(--ink); text-decoration: none; }
.tax-rev-label:hover { color: var(--brand); }
.tax-rev-diff { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.tax-rev-who { font-family: var(--mono); font-size: .8rem; color: var(--muted); text-align: right; }
.tax-rev-current {
  justify-self: end; padding: 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, var(--panel));
  color: var(--brand); font-family: var(--mono); font-size: .68rem;
  font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
@media (max-width: 760px) {
  .tax-rev-row { grid-template-columns: 1fr; gap: 6px; }
  .tax-rev-who { text-align: left; }
}

/* Knowledge document pages (view/edit/upload). */
.doc-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.doc-form { margin-top: 6px; }
.doc-actions { display: flex; align-items: center; gap: 12px; }
.doc-hint { flex: 1 1 auto; font-size: .8rem; color: var(--muted); }
.doc-errors ul { margin: 8px 0 0 18px; padding: 0; }
.doc-errors li { margin: 3px 0; }
.doc-readonly {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; font-size: .84rem; line-height: 1.6; overflow-x: auto;
  white-space: pre-wrap; word-break: break-word;
}
.doc-history-h { margin-top: 26px; }
.doc-upload-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.doc-file-label { cursor: pointer; }
.doc-template { margin-top: 22px; }
.doc-template summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.doc-template .doc-readonly { margin-top: 10px; }
.doc-dup .inline-form { display: flex; gap: 10px; margin-top: 10px; }
.doc-dup-line { margin: 6px 0 0; }

/* API-key section on Profile settings (outside the form, same card look). */
.api-key-section { margin-top: 18px; }
.api-key-section .hint { margin: 4px 0 12px; }

/* API-key page: lists + modal. */
.api-key-issued {
  margin-bottom: 22px; padding: 14px 16px;
  background: color-mix(in srgb, var(--brand) 6%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--line));
  border-radius: 12px;
}
.api-key-issued-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 8px; }
.api-key-issued-dot { color: var(--brand); font-size: .9rem; }
.api-key-issued-warn { color: var(--muted); font-size: .82rem; }
.api-key-list { margin-bottom: 22px; }
.api-key-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.api-key-list-head .form-section-title { margin: 0; }
.api-key-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  align-items: center; gap: 14px;
  padding: 11px 14px; margin-bottom: 7px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-size: .88rem;
}
.api-key-row-main { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.api-key-label { font-weight: 600; color: var(--ink); }
.api-key-mask { font-family: var(--mono); font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.api-key-meta { font-family: var(--mono); font-size: .74rem; color: var(--muted); }
.api-key-expired { color: var(--neg); font-weight: 600; }
.api-key-dead-list { opacity: .85; }
.api-key-row-dead { background: color-mix(in srgb, var(--panel) 92%, var(--ink) 8%); border-style: dashed; }
.api-key-row-dead .api-key-label { color: var(--muted); }
.api-key-x {
  width: 26px; height: 26px; padding: 0; line-height: 1;
  background: transparent; border: 1px solid var(--line); border-radius: 50%;
  color: var(--muted); font-size: 1.1rem; cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.api-key-x:hover { color: var(--neg); border-color: var(--neg); background: #fef2f2; }
@media (max-width: 720px) {
  .api-key-row { grid-template-columns: 1fr; gap: 6px; }
  .api-key-list-head { flex-direction: column; align-items: flex-start; }
}

/* Site-wide centered modal (sd- prefix avoids any naming collisions). */
body.modal-open { overflow: hidden; }
.sd-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.sd-modal[hidden] { display: none !important; }
.sd-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .48); backdrop-filter: blur(4px); }
.sd-modal-card {
  position: relative; width: 100%; max-width: 480px;
  background: var(--panel); border-radius: 16px; padding: 22px 24px 18px;
  box-shadow: 0 32px 80px -20px rgba(15, 23, 42, .45), 0 0 0 1px rgba(15, 23, 42, .05);
  animation: sdModalIn .22s cubic-bezier(.2, .8, .3, 1.05);
}
@keyframes sdModalIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.sd-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.sd-modal-head h2 { font-family: var(--serif); font-size: 1.25rem; margin: 0; letter-spacing: -.005em; }
.sd-modal-x { background: none; border: 0; cursor: pointer; font-size: 1.55rem; line-height: 1; color: var(--muted); padding: 0 4px; }
.sd-modal-x:hover { color: var(--ink); }
.sd-modal-warn { display: block; margin: 4px 0 6px; font-size: .85rem; line-height: 1.6; }
.sd-modal-card .field { margin-top: 14px; }
.sd-modal-card .field + .field { margin-top: 18px; }
.sd-modal-opt { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.sd-pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sd-pill {
  display: inline-flex; align-items: center; cursor: pointer;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: .85rem; color: var(--ink-2);
  letter-spacing: 0; text-transform: none; font-weight: 500;
  transition: border-color .15s, background .15s, color .15s;
}
.sd-pill input { position: absolute; opacity: 0; pointer-events: none; }
.sd-pill:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); color: var(--brand); }
.sd-pill:has(input:checked) {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, #fff);
  color: var(--brand); font-weight: 700;
}
.sd-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.compose-head-actions { display: flex; gap: 10px; align-items: center; flex: none; }

/* Account pages (allauth) — restrained, matches the rest of the forms. */
.auth-page { max-width: 460px; }
.auth-page .stacked-form { margin-top: 14px; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 14px; border-radius: 12px;
  background: #fff; color: var(--ink); border: 1.5px solid var(--line);
  font-weight: 600; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.btn-google span { width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(#4285F4, #EA4335, #FBBC05, #34A853, #4285F4);
  color: #fff; font-weight: 800; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }
.btn-google:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: .8rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }
.auth-alt { margin-top: 14px; font-size: .85rem; color: var(--muted); }

/* Auth pages: narrow centered variant + email-sent emoji + live password rules */
.auth-page.auth-narrow { max-width: 460px; }
.auth-page.auth-narrow h1 { margin: 6px 0 10px; }
.auth-page.auth-narrow p { color: var(--ink-2); line-height: 1.6; }
.auth-page .auth-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: 8px; }
.auth-page .auth-hint { font-size: .82rem; color: var(--muted); }
.auth-page .form-actions { margin-top: 14px; }
.pw-rules { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 5px; }
.pw-rules li {
  position: relative; padding-left: 23px; font-size: .82rem; color: var(--muted);
  transition: color .15s ease;
}
.pw-rules li::before {
  content: "○"; position: absolute; left: 5px; top: -1px; color: var(--line-2);
  font-size: .9rem; transition: color .15s ease;
}
.pw-rules li.is-pending { color: var(--ink-2); }
.pw-rules li.is-pending::before { content: "○"; color: var(--muted); }
.pw-rules li.is-ok { color: var(--pos); }
.pw-rules li.is-ok::before { content: "✓"; color: var(--pos); font-weight: 800; }
