/* ==========================================================================
   BEANS — a field guide to the seeds of Fabaceae
   Design system
   ========================================================================== */

/* ---- Tokens -------------------------------------------------------------- */

:root {
  color-scheme: dark;

  /* Surfaces — warm, soil-toned neutrals */
  --bg:          #100d0a;
  --bg-deep:     #0a0807;
  --surface:     #191511;
  --surface-2:   #221d17;
  --surface-3:   #2c261e;
  --line:        #342c23;
  --line-soft:   #262019;

  /* Ink */
  --ink:         #f2ece1;
  --ink-2:       #c9bda9;
  --ink-3:       #948875;
  --ink-4:       #6b6153;

  /* Accents — drawn from real seed coats */
  --gold:        #d9a441;
  --gold-soft:   #8a6a2c;
  --rust:        #c05a38;
  --kidney:      #a33b2c;
  --black-bean:  #3b322c;
  --navy-bean:   #e6d9bd;
  --pinto:       #c08a52;
  --mung:        #7c9c4a;
  --leaf:        #6f9e52;
  --sky:         #5b95b8;
  --violet:      #8a6fae;
  --magenta:     #b35a7d;

  /* Semantic */
  --accent:      var(--gold);
  --accent-ink:  #100d0a;
  --danger:      #d95c48;
  --ok:          #7fae5a;
  --warn:        #dda23c;

  /* Categorical ramp. Searched in OKLCH and checked with the six-check
     validator against BOTH surfaces, so one set serves light and dark.
     The order is load-bearing: adjacent slots are the pairs that were
     verified for CVD separation, so series must be assigned c1, c2, c3 …
     in sequence and never cherry-picked. */
  --c1: #b78b2d;  /* amber */
  --c2: #4a87ca;  /* blue  */
  --c3: #9c4e2a;  /* rust  */
  --c4: #2aa681;  /* teal  */
  --c5: #8d539b;  /* plum  */
  --c6: #347910;  /* olive */
  --c7: #cf728d;  /* rose  */
  --c-other: #7d7264;

  /* Type */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Metrics */
  --rail: 1160px;
  --rail-wide: 1400px;
  --gut: clamp(18px, 4vw, 44px);
  --r-sm: 6px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.28);
  --shadow-2: 0 2px 6px rgba(0,0,0,.45), 0 18px 46px rgba(0,0,0,.42);

  --ease: cubic-bezier(.22,.75,.3,1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:          #f6f1e6;
  --bg-deep:     #ece4d4;
  --surface:     #fffdf8;
  --surface-2:   #f5efe2;
  --surface-3:   #ece3d2;
  --line:        #ddd2ba;
  --line-soft:   #e8dfcd;
  --ink:         #201a12;
  --ink-2:       #4a3f31;
  --ink-3:       #756751;
  --ink-4:       #9a8a72;
  --gold:        #9a6f14;
  --gold-soft:   #c9a75e;
  --accent:      #9a6f14;
  --accent-ink:  #fffdf8;
  --navy-bean:   #6a5c40;
  --black-bean:  #3b322c;
  --rust:        #a84121;
  --shadow-1: 0 1px 2px rgba(74,55,20,.10), 0 4px 14px rgba(74,55,20,.08);
  --shadow-2: 0 2px 8px rgba(74,55,20,.12), 0 18px 40px rgba(74,55,20,.14);
}

/* ---- Reset --------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, canvas { max-width: 100%; }
img { height: auto; display: block; }
[hidden] { display: none !important; }

/* ---- Type ---------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.018em;
  margin: 0 0 .5em;
  font-variation-settings: "SOFT" 20, "WONK" 1, "opsz" 40;
  text-wrap: balance;
}
h1 { font-size: clamp(2.3rem, 6.2vw, 4.3rem); }
h2 { font-size: clamp(1.7rem, 3.6vw, 2.6rem); }
h3 { font-size: clamp(1.22rem, 2.1vw, 1.5rem); letter-spacing: -.01em; }
h4 { font-size: 1.04rem; font-family: var(--font-body); font-weight: 650; letter-spacing: -.005em; }

p { margin: 0 0 1.05em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

strong, b { font-weight: 650; color: var(--ink); }
em { font-style: italic; }
small { font-size: .84em; }

code, kbd, .mono { font-family: var(--font-mono); font-size: .88em; }
code {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: .1em .38em;
  color: var(--ink);
}
sup { font-size: .68em; line-height: 0; }

.lede {
  font-size: clamp(1.06rem, 1.9vw, 1.28rem);
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 62ch;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .19em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 .85em;
  display: block;
  font-weight: 500;
}
.muted { color: var(--ink-3); }
.sci { font-style: italic; }

/* Screen-reader only */
.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Skip link */
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--r-sm); font-weight: 600;
  transition: top .18s var(--ease);
}
.skip:focus { top: 8px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---- Layout -------------------------------------------------------------- */

.wrap { width: 100%; max-width: var(--rail); margin-inline: auto; padding-inline: var(--gut); }
.wrap-wide { width: 100%; max-width: var(--rail-wide); margin-inline: auto; padding-inline: var(--gut); }

section { padding-block: clamp(48px, 8vw, 104px); position: relative; }
section.tight { padding-block: clamp(32px, 5vw, 60px); }

.section-head { max-width: 68ch; margin-bottom: clamp(28px, 4vw, 48px); }
.section-head p { color: var(--ink-2); }

.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

.grid { display: grid; gap: clamp(16px, 2.4vw, 28px); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-side { grid-template-columns: minmax(0,1fr) minmax(0, 340px); align-items: start; }
.g-side-l { grid-template-columns: minmax(0, 320px) minmax(0,1fr); align-items: start; }

@media (max-width: 980px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-side, .g-side-l { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 620px) {
  .g2, .g3, .g4 { grid-template-columns: minmax(0,1fr); }
  .g2.keep2, .g4.keep2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---- Header / nav -------------------------------------------------------- */

.masthead {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line-soft);
}
.masthead-in {
  display: flex; align-items: center; gap: 18px;
  height: 62px;
  max-width: var(--rail-wide); margin-inline: auto; padding-inline: var(--gut);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.12rem; letter-spacing: -.02em;
  color: var(--ink); text-decoration: none; flex: none;
}
.brand:hover { color: var(--ink); }
.brand .glyph { width: 26px; height: 26px; flex: none; }
.brand .glyph .body { fill: var(--gold); }
.brand .glyph .hilum { fill: var(--bg); }

.nav { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.nav a {
  font-size: .875rem; font-weight: 500;
  color: var(--ink-3); text-decoration: none;
  padding: 7px 11px; border-radius: var(--r-sm);
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.nav-toggle {
  display: none; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink); width: 38px; height: 34px; border-radius: var(--r-sm);
  cursor: pointer; align-items: center; justify-content: center;
}
.theme-btn {
  flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2); width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; display: grid; place-items: center;
  transition: color .15s, border-color .15s;
}
.theme-btn:hover { color: var(--accent); border-color: var(--gold-soft); }

@media (max-width: 1060px) {
  .nav-toggle { display: flex; }
  .nav {
    position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 8px var(--gut) 16px; margin: 0;
    box-shadow: var(--shadow-2);
    max-height: calc(100dvh - 62px); overflow-y: auto;
  }
  .nav:not(.open) { display: none; }
  .nav a { padding: 11px 12px; font-size: .95rem; }
  .theme-btn { margin-left: auto; }
}

/* ---- Footer -------------------------------------------------------------- */

.foot {
  border-top: 1px solid var(--line);
  background: var(--bg-deep);
  padding-block: 52px 40px;
  margin-top: 40px;
}
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 32px; }
@media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .foot-grid { grid-template-columns: 1fr; } }
.foot h4 { color: var(--ink-3); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; font-family: var(--font-mono); font-weight: 500; margin-bottom: 14px; }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li { margin-bottom: 7px; }
.foot a { color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.foot a:hover { color: var(--accent); }
.foot-note { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line-soft); color: var(--ink-4); font-size: .82rem; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---- Cards & panels ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(18px, 2.4vw, 26px);
  position: relative;
}
.card h3 { margin-bottom: .4em; }
.card p:last-child { margin-bottom: 0; }

.card-link {
  display: block; text-decoration: none; color: inherit;
  transition: transform .22s var(--ease), border-color .22s, box-shadow .22s;
}
.card-link:hover {
  transform: translateY(-3px);
  border-color: var(--gold-soft);
  box-shadow: var(--shadow-2);
  color: inherit;
}
.card-link .go { color: var(--accent); font-size: .85rem; font-weight: 600; margin-top: 14px; display: inline-flex; align-items: center; gap: 6px; }
.card-link:hover .go .arw { transform: translateX(4px); }
.go .arw { transition: transform .22s var(--ease); display: inline-block; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head {
  padding: 14px clamp(16px, 2vw, 22px);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.panel-head h3, .panel-head h4 { margin: 0; }
.panel-head .sub { color: var(--ink-3); font-size: .82rem; margin-left: auto; font-family: var(--font-mono); }
.panel-body { padding: clamp(16px, 2.2vw, 24px); }
.panel-body.flush { padding: 0; }

.note {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  padding: 14px 18px; border-radius: 0 var(--r) var(--r) 0;
  font-size: .94rem; color: var(--ink-2);
}
.note strong { color: var(--ink); }
.note.warn { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.note.leaf { border-color: var(--leaf); background: color-mix(in srgb, var(--leaf) 8%, transparent); }

/* ---- Stats --------------------------------------------------------------- */

.stat { }
.stat .n {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.2vw, 2.9rem);
  font-weight: 600; line-height: 1;
  color: var(--ink);
  font-variation-settings: "SOFT" 0, "WONK" 0;
  letter-spacing: -.03em;
  display: block;
}
.stat .n .u { font-size: .44em; color: var(--ink-3); margin-left: .18em; letter-spacing: 0; font-family: var(--font-body); font-weight: 500; }
.stat .k { display: block; margin-top: 8px; font-size: .8rem; color: var(--ink-3); line-height: 1.4; }
.stat.c1 .n { color: var(--c1); } .stat.c2 .n { color: var(--c2); }
.stat.c3 .n { color: var(--c3); } .stat.c4 .n { color: var(--c4); }

/* ---- Buttons & controls -------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  cursor: pointer; text-decoration: none;
  transition: background .16s, border-color .16s, transform .16s var(--ease), color .16s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--gold-soft); color: var(--ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #fff); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 13px; font-size: .82rem; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; flex-wrap: wrap;
}
.seg button {
  font: inherit; font-size: .81rem; font-weight: 550;
  padding: 6px 14px; border-radius: 999px;
  border: 0; background: transparent; color: var(--ink-3);
  cursor: pointer; transition: background .16s, color .16s;
  white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button.on { background: var(--accent); color: var(--accent-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font: inherit; font-size: .78rem; font-weight: 550;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3);
  cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--ink); border-color: var(--ink-4); }
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent); color: var(--accent);
}
.chip.static { cursor: default; }
.chip.static:hover { color: var(--ink-3); border-color: var(--line); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: .76rem; font-weight: 600; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; font-family: var(--font-mono); }
input[type="text"], input[type="search"], input[type="number"], select {
  font: inherit; font-size: .92rem;
  padding: 9px 13px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  width: 100%;
}
select { cursor: pointer; appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
input::placeholder { color: var(--ink-4); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--surface-3); border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 4px; background: var(--surface-3); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  margin-top: -6px; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--accent);
}

.ctl-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ctl-row .grow { flex: 1 1 180px; min-width: 0; }
.readout { font-family: var(--font-mono); font-size: .84rem; color: var(--accent); font-weight: 500; min-width: 5ch; }

/* ---- Tables -------------------------------------------------------------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  padding: 9px 13px; text-align: right; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--ink-3);
  font-size: .72rem; letter-spacing: .03em;
  font-family: var(--font-mono); font-weight: 500;
  border-bottom: 1px solid var(--line); cursor: pointer; user-select: none;
}
table.data thead th:first-child { z-index: 3; background: var(--surface-2); }
table.data thead th:hover { color: var(--ink); }
table.data thead th .dir { color: var(--accent); margin-left: 4px; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr:hover td:first-child { background: var(--surface-2); }
table.data td.num { font-family: var(--font-mono); font-size: .83rem; }
table.data .bar-cell { position: relative; }
table.data .bar-cell .fill {
  position: absolute; inset: 3px auto 3px 0; border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 22%, transparent); z-index: 0;
}
table.data .bar-cell span { position: relative; z-index: 1; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 18px; font-size: .9rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); font-size: .85rem; }

/* ---- Chart primitives ---------------------------------------------------- */

.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font-body); fill: var(--ink-3); }
.chart .axis-line { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .tick { font-size: 10.5px; fill: var(--ink-4); font-family: var(--font-mono); }
.chart .axis-label { font-size: 11px; fill: var(--ink-3); font-weight: 600; }
.chart .val { font-size: 11px; fill: var(--ink-2); font-family: var(--font-mono); }
.chart .series-label { font-size: 11.5px; fill: var(--ink-2); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar { transition: opacity .15s; }
.chart .dim { opacity: .28; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: .8rem; }
.legend .li { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); cursor: default; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.tip {
  position: fixed; z-index: 300; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 11px;
  font-size: .8rem; line-height: 1.45; color: var(--ink);
  box-shadow: var(--shadow-2); max-width: 260px;
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: translateY(0); }
.tip b { display: block; font-size: .84rem; margin-bottom: 2px; }
.tip .r { color: var(--ink-3); font-family: var(--font-mono); font-size: .76rem; }

/* ---- 3D viewer ----------------------------------------------------------- */

.viewer {
  position: relative; width: 100%;
  background:
    radial-gradient(120% 90% at 50% 12%, color-mix(in srgb, var(--gold) 9%, transparent), transparent 62%),
    linear-gradient(180deg, var(--surface-2), var(--bg-deep));
  border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line);
  touch-action: none;
}
.viewer canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.viewer canvas:active { cursor: grabbing; }
.viewer .hud {
  position: absolute; inset: auto 0 0 0; padding: 12px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: linear-gradient(0deg, color-mix(in srgb, var(--bg-deep) 88%, transparent), transparent);
  pointer-events: none;
}
.viewer .hud > * { pointer-events: auto; }
.viewer .badge {
  position: absolute; top: 12px; left: 12px;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-4);
  background: color-mix(in srgb, var(--bg-deep) 70%, transparent);
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-soft);
}
.viewer .fps { position: absolute; top: 12px; right: 12px; font-family: var(--font-mono); font-size: .66rem; color: var(--ink-4); }

.labels { position: absolute; inset: 0; pointer-events: none; }
.lbl {
  position: absolute; transform: translate(-50%, -50%);
  pointer-events: auto; cursor: pointer;
  transition: opacity .2s;
}
.lbl .dot {
  display: block;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-deep);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
}
.lbl .txt {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-size: .74rem; font-weight: 600;
  background: color-mix(in srgb, var(--bg-deep) 90%, transparent);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 3px 9px; color: var(--ink);
}
.lbl.flip .txt { left: auto; right: 16px; }
.lbl.behind { opacity: .28; }
.lbl.behind .txt { display: none; }

/* ---- Interactive SVG diagrams ------------------------------------------- */

.diagram { width: 100%; display: block; }
.diagram .hot { cursor: pointer; transition: opacity .18s, filter .18s; }
.diagram .hot:hover { filter: brightness(1.22); }
.diagram .hot.sel { filter: brightness(1.3); }
.diagram .lead { stroke: var(--ink-4); stroke-width: 1; stroke-dasharray: 2 3; fill: none; }
.diagram .callout { font-size: 11.5px; fill: var(--ink-2); font-weight: 600; }
.diagram .callout.sub { font-size: 10px; fill: var(--ink-4); font-weight: 400; }
.diagram .marker { fill: var(--accent); }

.diagram-wrap { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .diagram-wrap { grid-template-columns: minmax(0,1fr); } }
.readout-panel {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px; min-height: 180px;
}
.readout-panel h4 { color: var(--accent); margin-bottom: 4px; }
.readout-panel .latin { font-style: italic; color: var(--ink-4); font-size: .82rem; margin-bottom: 10px; }
.readout-panel p { font-size: .88rem; color: var(--ink-2); }

/* ---- Timeline ------------------------------------------------------------ */

.timeline { position: relative; }
.tl-track {
  position: relative; height: 3px; background: var(--line);
  border-radius: 2px; margin: 42px 0 30px;
}
.tl-track .prog { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 2px; }
.tl-pt {
  position: absolute; top: 50%; transform: translate(-50%,-50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface-3); border: 2px solid var(--ink-4);
  cursor: pointer; transition: all .18s var(--ease); padding: 0;
}
.tl-pt:hover { transform: translate(-50%,-50%) scale(1.4); border-color: var(--accent); }
.tl-pt.on { background: var(--accent); border-color: var(--accent); transform: translate(-50%,-50%) scale(1.5); }
.tl-pt .era { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); font-size: .62rem; font-family: var(--font-mono); color: var(--ink-4); white-space: nowrap; opacity: 0; transition: opacity .18s; }
.tl-pt:hover .era, .tl-pt.on .era { opacity: 1; }

.tl-card { min-height: 190px; }
.tl-card .yr { font-family: var(--font-mono); color: var(--accent); font-size: .8rem; letter-spacing: .06em; }
.tl-card h3 { margin: 6px 0 10px; }

.tl-nav { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; }
.tl-count { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-4); }

/* ---- Variety browser ----------------------------------------------------- */

.bean-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }
.bean-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
  transition: border-color .18s, transform .18s var(--ease), background .18s;
  display: flex; flex-direction: column; gap: 10px;
}
.bean-card:hover { border-color: var(--gold-soft); transform: translateY(-2px); }
.bean-card.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.bean-card .swatch { width: 100%; height: 58px; border-radius: var(--r-sm); position: relative; overflow: hidden; }
.bean-card .nm { font-weight: 640; font-size: .9rem; line-height: 1.25; }
.bean-card .sc { font-size: .72rem; font-style: italic; color: var(--ink-4); }
.bean-card .mini { display: flex; gap: 10px; font-size: .7rem; color: var(--ink-3); font-family: var(--font-mono); margin-top: auto; }

.detail {
  position: sticky; top: 78px;
}
@media (max-width: 980px) { .detail { position: static; } }

/* ---- Misc ---------------------------------------------------------------- */

.tag {
  display: inline-block; font-size: .68rem; font-family: var(--font-mono);
  letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-3); border: 1px solid var(--line-soft);
}
.tag.pulse { color: var(--leaf); border-color: color-mix(in srgb, var(--leaf) 40%, transparent); }
.tag.oil { color: var(--sky); border-color: color-mix(in srgb, var(--sky) 40%, transparent); }
.tag.veg { color: var(--magenta); border-color: color-mix(in srgb, var(--magenta) 40%, transparent); }
.tag.tox { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

.facts { list-style: none; padding: 0; margin: 0; }
.facts li {
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
  display: flex; gap: 16px; justify-content: space-between; align-items: baseline;
  font-size: .92rem;
}
.facts li:last-child { border-bottom: 0; }
.facts .k { color: var(--ink-3); flex: 1 1 auto; }
.facts .v { font-family: var(--font-mono); font-size: .86rem; text-align: right; flex: none; }

details.acc {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); margin-bottom: 10px; overflow: hidden;
}
details.acc > summary {
  padding: 14px 18px; cursor: pointer; font-weight: 600; font-size: .95rem;
  list-style: none; display: flex; align-items: center; gap: 12px;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after {
  content: "+"; margin-left: auto; color: var(--accent);
  font-family: var(--font-mono); font-size: 1.1rem; transition: transform .2s;
}
details.acc[open] > summary::after { content: "\2212"; }
details.acc > summary:hover { background: var(--surface-2); }
details.acc .acc-body { padding: 0 18px 18px; font-size: .93rem; color: var(--ink-2); }

.refs { font-size: .82rem; color: var(--ink-4); line-height: 1.6; }
.refs ol { padding-left: 1.4em; margin: 0; }
.refs li { margin-bottom: 6px; }
.refs a { color: var(--ink-3); }

.fig { margin: 0; }
.fig figcaption { font-size: .8rem; color: var(--ink-4); margin-top: 10px; line-height: 1.5; }
.fig figcaption b { color: var(--ink-3); font-weight: 600; }

.marquee-num {
  font-family: var(--font-mono); font-size: .72rem; color: var(--ink-4);
  letter-spacing: .1em;
}

.split-bar { display: flex; height: 30px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); }
.split-bar div { display: grid; place-items: center; font-size: .68rem; font-weight: 700; color: rgba(0,0,0,.62); overflow: hidden; transition: flex-grow .5s var(--ease); }

.scale-note { font-family: var(--font-mono); font-size: .7rem; color: var(--ink-4); letter-spacing: .08em; }

.anim-fade { animation: fade .5s var(--ease) both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

.nowrap { white-space: nowrap; }
.center { text-align: center; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt-s { margin-top: 12px; } .mt-m { margin-top: 22px; } .mt-l { margin-top: 38px; }
.flex { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.flex-between { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
