/* Distances & Divergences Dictionary — styles.
   Palette and typography mirror the blog's taxonomy post for visual continuity. */

:root {
  --paper: #fffef8;
  --ink: #1f2429;
  --muted: #55606a;
  --line: #d8d3c9;
  --accent: #8a2d1f;
  --accent-soft: #f2ebe2;
  --maxw: 1080px;

  --panel: #fbfaf5;
  --code-bg: #f6f8fa;
  --code-border: #e3e6ea;
  --good: #2f7d3a;
  --bad: #9a3b2c;

  /* pipeline stage-category accents (warm-harmonized with the palette) */
  --cat-model: #a8432a;   --cat-model-bg: #f8ece5;
  --cat-browser: #3f7d74; --cat-browser-bg: #e9f2f0;
  --cat-data: #8a7f72;    --cat-data-bg: #f1ede7;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", serif;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Menlo", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 520px at 5% -10%, #f3efe5 0%, rgba(243, 239, 229, 0) 65%),
    radial-gradient(900px 440px at 95% 0%, #efe6dc 0%, rgba(239, 230, 220, 0) 62%),
    #f8f6f1;
  font-family: var(--serif);
  line-height: 1.65;
}

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

.page {
  width: min(var(--maxw), 94vw);
  margin: 0 auto;
  padding: 34px 0 80px;
}

/* ------------------------------- intro header ----------------------------- */

.intro { margin-bottom: 18px; }
.meta {
  color: var(--muted);
  font-family: var(--sans);
  letter-spacing: 0.02em;
  font-size: 0.82rem;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.intro-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
}
.authors { margin: 6px 0 0; color: var(--muted); font-size: 1rem; }
.intro-lead { margin: 14px 0 0; max-width: 70ch; font-size: 1.05rem; }
.intro-tools {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--sans);
}
.intro-tools a {
  color: var(--accent);
  border: 1px solid #d6c6b7;
  background: #fff;
  border-radius: 999px;
  padding: 7px 13px;
  font-weight: 600;
  font-size: 0.9rem;
}
.intro-tools a:hover { background: var(--accent-soft); text-decoration: none; }

/* --------------------------------- toolbar -------------------------------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 18px;
  background: rgba(255, 254, 248, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--sans);
}
.search-input {
  flex: 1 1 320px;
  min-width: 220px;
  font-family: var(--sans);
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.toolbar-nav { display: flex; gap: 6px; }
.toolbar-nav a {
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--muted);
}
.toolbar-nav a:hover { background: var(--accent-soft); text-decoration: none; }
.toolbar-nav a.active { background: var(--accent); color: #fff; }
.ai-toggle { display: flex; align-items: center; gap: 8px; }
.ai-btn {
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 12px;
  border: 1px solid #c9b9a8;
  background: #fff;
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
}
.ai-btn:hover { background: var(--accent-soft); }
.ai-btn.on { background: var(--good); color: #fff; border-color: var(--good); }
.ai-btn:disabled { opacity: 0.6; cursor: default; }
.ai-status { font-size: 0.82rem; color: var(--muted); max-width: 240px; }

/* --------------------------------- home ----------------------------------- */

.hero-block { margin-bottom: 16px; }
.hero-lead { margin: 0 0 12px; color: var(--muted); font-size: 1.02rem; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--sans); }
.example-chip {
  font-family: var(--sans);
  font-size: 0.86rem;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
}
.example-chip:hover { border-color: var(--accent); color: var(--accent); }

.home-body {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 24px;
  margin-top: 18px;
}

/* filter rail */
.filter-rail {
  align-self: start;
  position: sticky;
  top: 84px;
  font-family: var(--sans);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.filter-head { display: flex; align-items: center; justify-content: space-between; }
.filter-head h2 { margin: 0; font-size: 1.05rem; }
.link-btn {
  background: none; border: none; color: var(--accent);
  font-family: var(--sans); font-size: 0.84rem; cursor: pointer; padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.filter-group { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.filter-group summary {
  cursor: pointer; font-weight: 700; font-size: 0.9rem; list-style: none;
}
.filter-group summary::-webkit-details-marker { display: none; }
.filter-group summary::before { content: "▸ "; color: var(--accent); }
.filter-group[open] summary::before { content: "▾ "; }
.filter-options { display: grid; gap: 4px; margin-top: 8px; }
.filter-opt { display: flex; align-items: center; gap: 7px; font-size: 0.86rem; cursor: pointer; }
.filter-opt input { accent-color: var(--accent); }

/* results */
.results-col { min-width: 0; }
.results-status {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.exact-note { color: var(--ink); }
.ai-on { color: var(--good); font-weight: 600; }
.empty { color: var(--muted); font-style: italic; }
.empty-state { font-style: normal; }
.empty-state p { margin: 0 0 6px; }
.empty-state .ai-btn { margin-top: 8px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(40, 35, 26, 0.05);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-title { font-family: var(--sans); font-weight: 700; font-size: 1.04rem; line-height: 1.25; }
.card-aliases { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }
.card-desc { margin: 2px 0; font-size: 0.96rem; }
.card-meta { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }

.cmp-toggle {
  font-family: var(--sans);
  font-size: 0.78rem;
  white-space: nowrap;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
}
.cmp-toggle:hover { border-color: var(--accent); color: var(--accent); }
.cmp-toggle.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* chips & badges */
.chips { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--sans); }
.chip {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}
a.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.chip-family { background: var(--accent-soft); color: var(--accent); border-color: #e3d2c2; }
.chip-type { background: #eef3f7; color: #345; border-color: #d6e0e8; }
.chip-alias { font-style: italic; }
.chip-related { background: #fff; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--sans); }
.badge {
  font-size: 0.76rem;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.badge-yes { background: #eef6ef; color: var(--good); border-color: #cfe6d2; }
.badge-no { background: #f7eeec; color: var(--bad); border-color: #ecd3cd; }
.badge-soft { background: #f3f0e8; color: var(--muted); }

/* --------------------------------- detail --------------------------------- */

.detail, .compare, .ask, .not-found, .data-error {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: clamp(18px, 3.5vw, 40px);
  box-shadow: 0 14px 40px rgba(40, 35, 26, 0.07);
}
.back-link { font-family: var(--sans); font-size: 0.88rem; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 8px 0 10px; }
.detail-head h1 { margin: 0; font-size: clamp(1.5rem, 3.4vw, 2.3rem); line-height: 1.15; }
.detail-head h1:focus { outline: none; }
.detail-lead { font-size: 1.08rem; margin: 12px 0 6px; }
.detail-section { margin-top: 22px; }
.detail-section h2 {
  font-size: 1.2rem; margin: 0 0 8px;
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
.detail-section h3 { font-size: 1.02rem; color: var(--accent); margin: 0 0 4px; }
.detail-section ul { margin: 6px 0; padding-left: 20px; }

.eq {
  margin: 8px 0;
  padding: 12px 14px;
  border: 1px solid #e0dbd1;
  background: #fff;
  border-radius: 8px;
  overflow-x: auto;
}
.worked {
  background: #f0f5ee;
  border-left: 3px solid #6f9e6f;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 0.96rem;
}

.relations { display: grid; gap: 14px; }
.relation .eq { margin: 0 0 4px; }
.relation-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-family: var(--sans); font-size: 0.85rem; }
.relation-note { color: var(--muted); font-style: italic; }

.prop-table { border-collapse: collapse; width: 100%; margin-top: 8px; font-family: var(--sans); font-size: 0.92rem; }
.prop-table td { padding: 6px 10px; border-top: 1px solid #ece6dc; }
.prop-name { color: var(--muted); width: 60%; }
.prop-val.is-yes { color: var(--good); font-weight: 700; }
.prop-val.is-no { color: var(--bad); font-weight: 700; }

.when-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.when-use, .when-not {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--panel);
}
.when-use h3 { color: var(--good); }
.when-not h3 { color: var(--bad); }
.when-use h3, .when-not h3 { margin: 0 0 4px; font-size: 0.98rem; }
.when-grid p { margin: 0; font-size: 0.98rem; }

.graph-wrap { margin-top: 12px; }
.source-note { margin-top: 20px; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }

/* relationships (Phase 3): learning path + typed relations */
.learning-path { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--sans); }
.learning-path .lp-arrow { color: var(--muted); }
.learning-path .lp-current { font-weight: 700; color: var(--accent); }
.rel-typed { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rel-typed .rel-type-label { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }

/* related graph */
.rel-graph { width: 100%; height: auto; }
.rel-edge { stroke: #d8d3c9; stroke-width: 1.4; }
.rel-rect { fill: #fff; stroke: #d6c6b7; stroke-width: 1; }
.rel-rect-center { fill: var(--accent); stroke: var(--accent); }
.rel-text { font-family: var(--sans); font-size: 12px; fill: var(--ink); }
.rel-text-center { font-family: var(--sans); font-size: 13px; font-weight: 700; fill: #fff; }
.rel-node:hover .rel-rect { stroke: var(--accent); fill: var(--accent-soft); }

/* --------------------------------- codegen -------------------------------- */

.codegen { margin-top: 24px; }
.codegen h2 { font-size: 1.2rem; margin: 0 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.code-tabs { display: flex; gap: 4px; }
.code-tab {
  font-family: var(--sans); font-size: 0.84rem; font-weight: 600;
  padding: 5px 11px; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 7px 7px 0 0; cursor: pointer;
}
.code-tab[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.copy-btn {
  font-family: var(--sans); font-size: 0.82rem; padding: 5px 11px;
  border: 1px solid var(--line); background: #fff; color: var(--accent); border-radius: 7px; cursor: pointer;
}
.copy-btn:hover { background: var(--accent-soft); }
.code-block {
  margin: 0; padding: 14px 16px;
  background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 8px;
  overflow-x: auto;
}
.code-block code { font-family: var(--mono); font-size: 0.86rem; line-height: 1.55; white-space: pre; color: #1f2429; }
.code-notes-title { font-family: var(--sans); font-weight: 700; font-size: 0.9rem; margin: 12px 0 2px; }
.code-notes { font-family: var(--sans); font-size: 0.88rem; color: var(--muted); margin: 4px 0; padding-left: 20px; }

/* --------------------------------- compare -------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-top: 12px; }
.compare-table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.9rem; }
.compare-table th {
  background: var(--accent); color: #fff; text-align: left; padding: 10px 12px; vertical-align: top;
}
.compare-table th a { color: #fff; text-decoration: underline; }
.compare-table td { padding: 9px 12px; border-top: 1px solid #ece6dc; vertical-align: top; }
.compare-table tr:nth-child(even) td { background: #faf7f0; }
.row-label { font-weight: 700; color: var(--accent); background: var(--accent-soft) !important; white-space: nowrap; }

/* compare tray */
.compare-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(120%);
  transition: transform 0.18s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 92vw;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-family: var(--sans);
  font-size: 0.9rem;
  z-index: 40;
}
.compare-bar.show { transform: translateX(-50%) translateY(0); }
.cmp-count { font-weight: 700; }
.cmp-names { color: #d8d3c9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.cmp-open { background: var(--accent); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 700; }
.cmp-open:hover { text-decoration: none; filter: brightness(1.08); }
.cmp-open.disabled { background: #555; opacity: 0.6; cursor: default; }
.compare-bar .link-btn { color: #f0c9bf; }

/* ----------------------------------- ask ---------------------------------- */

.assistant-panel, .chat-panel { margin-top: 22px; }
.assistant-panel h2, .chat-panel h2 { font-size: 1.2rem; margin: 0 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.ask-row, .chat-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.ask-input, .chat-input-field, .chat-question {
  font-family: var(--sans); font-size: 0.98rem; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
.ask-input { flex: 1 1 320px; width: auto; }
.chat-question { resize: vertical; }
.chat-btn {
  font-family: var(--sans); font-weight: 600; font-size: 0.9rem;
  padding: 9px 16px; border: 1px solid var(--line); background: #fff; color: var(--accent);
  border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.chat-btn:hover { background: var(--accent-soft); }
.chat-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.chat-btn:disabled { opacity: 0.6; cursor: default; }
.chat-status { font-family: var(--sans); font-size: 0.86rem; color: var(--muted); }

.assistant-out, .chat-answer { margin-top: 10px; font-size: 1rem; }
.answer-title { margin: 0 0 4px; font-size: 1.05rem; }
.answer-lead { margin: 0 0 8px; }
.answer-list { margin: 6px 0; padding-left: 20px; }
.answer-link { font-weight: 600; }
.answer-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.answer-cta { font-family: var(--sans); font-weight: 600; font-size: 0.88rem; border: 1px solid #d6c6b7; background: #fff; border-radius: 999px; padding: 6px 12px; }
.answer-cta:hover { background: var(--accent-soft); text-decoration: none; }
.answer-caveats { margin: 4px 0; padding-left: 20px; color: var(--muted); font-size: 0.9rem; }
.caveat-label { font-family: var(--sans); font-weight: 700; font-size: 0.84rem; color: var(--bad); }

.chat-settings { margin: 8px 0; font-family: var(--sans); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--panel); }
.chat-settings summary { cursor: pointer; font-weight: 700; font-size: 0.92rem; }
.chat-warn { color: var(--bad); font-size: 0.85rem; background: #faf0ed; border-radius: 8px; padding: 8px 10px; }
.field-label { display: block; font-size: 0.82rem; color: var(--muted); margin: 8px 0 3px; font-weight: 600; }
.chat-consent { display: flex; align-items: center; gap: 6px; font-size: 0.86rem; margin-top: 6px; }
.chat-consent input { accent-color: var(--accent); }
.chat-sources { font-family: var(--sans); font-size: 0.84rem; color: var(--muted); margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 6px; }
.chat-error { color: var(--bad); font-family: var(--sans); font-size: 0.9rem; }

/* --------------------- conversational reply (home) ------------------------ */

.ai-reply {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-family: var(--sans);
  box-shadow: 0 6px 18px rgba(40, 35, 26, 0.05);
}
.ai-reply.greeting { border-left-color: #6f9e6f; }
.ai-reply-text { margin: 0 0 10px; font-size: 1rem; }
.ai-reply .examples { margin-top: 4px; }
.ai-reply .answer-title { margin-top: 0; }
.ai-reply-generated { font-size: 1rem; line-height: 1.6; }
.ai-reply-loading { color: var(--muted); font-style: italic; margin: 8px 0 0; }
.ai-reply-loading::before { content: "✦ "; }
.ai-reply-hint { font-size: 0.86rem; margin: 8px 0 0; }
.ai-reply-meta { font-size: 0.8rem; margin: 8px 0 0; }

/* ------------------------------- PDF linker ------------------------------- */

.linker .detail-lead { margin-top: 8px; }
.llm-settings {
  font-family: var(--sans);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--panel);
  margin: 12px 0;
}
.llm-settings summary { cursor: pointer; font-weight: 700; font-size: 0.92rem; }
.llm-field { width: 100%; font-family: var(--sans); font-size: 0.95rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 4px; }
.llm-cors { font-size: 0.8rem; margin: 4px 0; }
.llm-hint { font-size: 0.8rem; margin: 0 0 8px; font-style: italic; }

.lk-input { margin: 14px 0; }
.lk-file { display: block; font-family: var(--sans); margin-bottom: 8px; }
.lk-summary { font-family: var(--sans); font-weight: 600; margin: 8px 0; }
.lk-section { margin-top: 22px; }
.lk-section h2 { font-size: 1.2rem; margin: 0 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }

.lk-reading {
  font-family: var(--serif);
  line-height: 1.8;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  max-height: 460px;
  overflow-y: auto;
}
.lk-hit {
  background: #eef6ef;
  border-bottom: 2px solid var(--good);
  border-radius: 3px;
  padding: 0 2px;
  text-decoration: none;
}
.lk-hit:hover { background: #d9ecdc; }
.lk-hit.review { background: #fdf3e7; border-bottom-color: #c98a3a; }
.lk-hit.variant { background: #eef4fb; border-bottom-style: dashed; border-bottom-color: #6aa3d8; }
.lk-hit.variant:hover { background: #dce9f7; }
.lk-miss {
  background: #f7eeec;
  border-bottom: 2px dotted var(--bad);
  border-radius: 3px;
  padding: 0 2px;
  color: var(--ink);
}

.lk-measure { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; background: var(--paper); }
.lk-measure h3 { margin: 0 0 6px; font-size: 1.05rem; }
.lk-unmatched { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: #fbfaf5; font-family: var(--sans); }
.lk-unmatched .chat-btn { margin-top: 6px; }
.lk-draft { margin-top: 8px; }
.lk-draft .code-block { max-height: 320px; overflow: auto; }
.lk-verify { margin-top: 8px; font-family: var(--sans); font-size: 0.9rem; }
.lk-checks { margin: 4px 0; padding-left: 18px; }
.lk-pass { color: var(--good); }
.lk-fail { color: var(--bad); }
.lk-equation { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; background: var(--paper); }
.lk-eq-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-family: var(--sans); font-size: 0.85rem; margin-bottom: 2px; }
.lk-eq-link { color: var(--accent); text-decoration: none; }
.lk-eq-link:hover { text-decoration: underline; }
.lk-equation .eq { margin: 0; overflow-x: auto; }
.lk-equation.variant { border-style: dashed; border-color: #6aa3d8; background: #eef4fb; }
.lk-eq-group { font-size: 1rem; margin: 16px 0 6px; }
.lk-other-math { margin-top: 12px; }
.lk-other-math > summary { cursor: pointer; font-family: var(--sans); font-size: 0.9rem; }
.lk-draftblock { margin-top: 6px; }
.lk-eq-note { font-family: var(--sans); font-size: 0.85rem; margin: 4px 0 0; }

/* ------------------------------ browse by type ---------------------------- */

.types-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }
.types-nav .chip { cursor: pointer; font-family: var(--sans); border-color: #d6c6b7; }
.types-nav .chip:hover { background: var(--accent-soft); color: var(--accent); }
.types-view .lk-section h2 { scroll-margin-top: 80px; }
.topic-subhead { font-size: 0.95rem; font-weight: 700; color: var(--muted); margin: 14px 0 6px; text-transform: none; }

/* -------------------------------- contribute ------------------------------ */

.hero-contribute { margin: 12px 0 0; font-size: 0.95rem; }
.hero-contribute a { font-weight: 600; }
.contribute-actions { gap: 10px; margin: 4px 0; }
.contribute-actions .answer-cta { font-size: 0.95rem; padding: 8px 14px; }
.contribute-steps { margin: 4px 0 0; padding-left: 20px; line-height: 1.6; }
.contribute-steps li { margin-bottom: 8px; }
.schema-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 6px 0; }
.schema-list dt { font-family: var(--mono, monospace); font-weight: 600; color: var(--accent); }
.schema-list dd { margin: 0; color: var(--ink, inherit); }

/* Contribute form (Phase 4) */
.contrib-form { font-family: var(--sans); margin: 6px 0; }
.contrib-field { margin: 10px 0; }
.contrib-hint { display: block; font-size: 0.78rem; color: var(--muted); margin: 0 0 3px; font-style: italic; }
.contrib-input { width: 100%; }
textarea.contrib-input { resize: vertical; min-height: 2.2em; }
.contrib-checks .filter-options { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.contrib-kind-group { border-left: 3px solid var(--accent-soft); padding-left: 12px; margin: 8px 0; }
.contrib-preview { min-height: 2.4em; margin: 6px 0 0; padding: 6px 10px; border: 1px dashed var(--line); border-radius: 8px; background: var(--panel); overflow-x: auto; }
.contrib-refs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.ref-row { display: flex; gap: 8px; align-items: center; }
.ref-row .contrib-input { margin-bottom: 0; flex: 1 1 45%; }
.contrib-ref-rm { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--muted); }
.contrib-ref-rm:hover { color: var(--bad); border-color: var(--bad); }
.contrib-errors { display: none; }
.contrib-errors:not(:empty) { display: block; margin: 10px 0; padding: 10px 14px; border-radius: 8px; background: #faf0ed; border: 1px solid #e6c9c0; color: var(--bad); font-size: 0.9rem; }
.contrib-errors p { margin: 0; font-weight: 700; }
.contrib-errors ul { margin: 4px 0 0; padding-left: 20px; }
.contrib-status { margin-left: 6px; }
.answer-cta.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.answer-cta.primary:hover { background: var(--accent); opacity: 0.9; color: #fff; }
.contrib-info { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--panel); }
.contrib-info summary { cursor: pointer; font-weight: 700; font-size: 0.92rem; }

/* --------------------------- linker mode badge ---------------------------- */

.lk-mode { display: inline-block; font-family: var(--sans); font-weight: 600; font-size: 0.82rem; border-radius: 999px; padding: 4px 12px; margin: 0 0 10px; }
.lk-mode.light { background: #eef3f6; color: #33627a; border: 1px solid #cfe0e8; }
.lk-mode.ai { background: var(--accent-soft); color: var(--accent); border: 1px solid #d6c6b7; }

/* ------------------------------- pipeline --------------------------------- */

/* Legends: node shape (role) + color (compute tier). */
.pipe-legends { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 8px 0 4px; }
.pipe-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--sans); font-size: 0.82rem; color: var(--muted); }
.pipe-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pipe-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; background: var(--cat-bg, #eee); border-left: 3px solid var(--cat, #999); }
.pipe-mini { display: inline-block; vertical-align: middle; }
.pipe-mini .shape { fill: #efe7db; stroke: #b9a892; stroke-width: 1.2; }
.pipe-lead { margin-bottom: 6px; }
.pipe-caption { font-size: 0.82rem; margin: 2px 0 10px; }

/* Category accents drive shape fill + stroke + legend swatch. */
.cat-model   { --cat: var(--cat-model);   --cat-bg: var(--cat-model-bg); }
.cat-browser { --cat: var(--cat-browser); --cat-bg: var(--cat-browser-bg); }
.cat-data    { --cat: var(--cat-data);    --cat-bg: var(--cat-data-bg); }

/* Two-pane layout: an SVG diagram that scales to fit + a detail panel. Both panes are
   bounded to the viewport so the page doesn't scroll on desktop; a long panel scrolls
   inside itself. (Natural reading state: the sticky toolbar is pinned, intro scrolled off.) */
.pipe-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.pipe-diagram { min-width: 0; }
.pipe-svg { width: 100%; height: auto; display: block; } /* fills width; tall portrait viewBox → big shapes */
.pipe-panel { position: sticky; top: 78px; align-self: start; max-height: calc(100vh - 96px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.pipe-panel-content h2 { margin: 0 0 8px; font-size: 1.15rem; }
.pipe-panel-content p { margin: 0 0 10px; line-height: 1.6; }
.pipe-panel .pipe-modules { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }

/* SVG nodes + connectors (fills/strokes from the cat-* vars). */
.pipe-node .shape { fill: var(--cat-bg, #fff); stroke: var(--cat, var(--accent)); stroke-width: 1.5; }
.pipe-endpoint .shape { fill: #f4efe8; stroke: #cbbdad; stroke-width: 1.5; }
.pipe-node-label { fill: var(--ink); font-family: var(--sans); font-size: 15px; font-weight: 600; pointer-events: none; }
.pipe-endpoint .pipe-node-label { fill: var(--muted); font-weight: 500; font-size: 12px; }
.pipe-node { cursor: pointer; }
.pipe-edge { fill: none; stroke: #c2b4a4; stroke-width: 1.6; }
.pipe-edge.dashed { stroke-dasharray: 5 4; }
.pipe-arrowhead { fill: #b09c86; }
.pipe-edge-label { fill: var(--muted); font-family: var(--sans); font-size: 11px; }

/* Selection: ring the node, dim the rest, light up its connectors. */
.pipe-node.selected .shape { stroke: var(--accent); stroke-width: 2.5; }
.pipe-node:focus-visible .shape { stroke: var(--accent); stroke-width: 2.5; }
.pipe-node:focus { outline: none; }
.pipe-svg.has-selection .pipe-node:not(.selected) { opacity: 0.5; }
.pipe-edge.active { stroke: var(--accent); stroke-width: 2.2; }

.pipe-footnote { margin-top: 14px; }

/* Motion only when the user hasn't asked to reduce it. */
@media (prefers-reduced-motion: no-preference) {
  .pipe-node { transform-box: fill-box; transform-origin: center; transition: transform 0.25s ease, opacity 0.25s ease; }
  .pipe-node.selected { transform: scale(1.07); }
  .pipe-panel-content { animation: pipeZoom 0.26s ease; }
  @keyframes pipeZoom { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
}

/* Stack on mobile; the SVG keeps its aspect ratio and the page may scroll (acceptable). */
@media (max-width: 820px) {
  .pipe-layout { grid-template-columns: 1fr; }
  .pipe-panel { position: static; max-height: none; }
}

/* ------------------------------ misc / states ----------------------------- */

.muted { color: var(--muted); }
.loading { color: var(--muted); font-style: italic; }
.data-error h2 { margin-top: 0; }

/* -------------------------------- responsive ------------------------------ */

@media (max-width: 900px) {
  .home-body { grid-template-columns: 1fr; }
  .filter-rail { position: static; }
  .when-grid { grid-template-columns: 1fr; }
  .cmp-names { display: none; }
  .toolbar { position: static; }
}
