:root {
  --bg: #ffffff;
  --bg-soft: #f5f7f2;
  --fg: #1f2421;
  --fg-muted: #5b635d;
  --border: #dfe4dc;
  --accent: #2f6b3a;
  --accent-soft: #e6efe3;
  --accent-fg: #ffffff;
  /* Diagram palette: one hue per research thrust, plus a warning tone. */
  --t1: #2f6b3a;  --t1-soft: #e6efe3;
  --t2: #9a5f12;  --t2-soft: #f7ecda;
  --t3: #2c6587;  --t3-soft: #e1ecf4;
  --warn: #a8402f;
  --code-bg: #eef2ea;
  --chassis: #3a413c;
  --max-width: 920px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141714;
    --bg-soft: #1c201c;
    --fg: #e6e9e4;
    --fg-muted: #a4aca5;
    --border: #2f352f;
    --accent: #8cc98f;
    --accent-soft: #233225;
    --accent-fg: #141714;
    --t1: #8cc98f;  --t1-soft: #223024;
    --t2: #e3a95c;  --t2-soft: #382c1b;
    --t3: #82b9dc;  --t3-soft: #1b2a35;
    --warn: #ec907c;
    --code-bg: #1f2620;
    --chassis: #c5ccc6;
  }
  /* Raster figures are drawn on white; keep them readable on a dark page. */
  figure img { background: #fff; }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--accent-soft);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 24px;
  min-height: 60px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.15rem; color: var(--fg); text-decoration: none;
}
.brand-mark { color: var(--accent); }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  padding: 6px 12px; border-radius: 6px;
  color: var(--fg-muted); text-decoration: none; font-weight: 500;
}
.site-nav a:hover { color: var(--fg); background: var(--bg-soft); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* Main */
main { flex: 1 0 auto; width: 100%; padding-top: 32px; padding-bottom: 48px; }
section { margin-bottom: 40px; }
h1, h2, h3 { line-height: 1.3; }
h2 {
  font-size: 1.4rem; margin: 0 0 16px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
h3 { font-size: 1.05rem; margin: 0 0 6px; }
.page-title { font-size: 1.9rem; margin: 0 0 24px; }
.muted { color: var(--fg-muted); }

/* Hero */
.hero { margin-bottom: 40px; }
.eyebrow {
  margin: 0 0 8px; font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent);
}
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 16px; }
.hero-name { color: var(--accent); }
.pi-list { list-style: none; padding: 0; margin: 0; }
.pi-list li { margin: 2px 0; }
.pi-list span { color: var(--fg-muted); }

/* Figures */
figure { margin: 24px 0; }
figure img { display: block; width: 100%; height: auto; border-radius: 6px; }
figcaption { margin-top: 8px; font-size: 0.9rem; color: var(--fg-muted); text-align: center; }

/* Diagrams (inline SVG, themed via the tokens above) */
.diagram-pair {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}
.diagram-panel {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 14px 6px;
}
.diagram-label {
  font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg-muted); margin-bottom: 6px;
}
.diagram-panel.is-farmbrain .diagram-label { color: var(--accent); }
.diagram-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.diagram-scroll svg { min-width: 680px; }
svg.dg { display: block; width: 100%; height: auto; }
.dg text { font-family: inherit; }
.dg .t-title { font-size: 16px; font-weight: 600; fill: var(--fg); }
.dg .t-strong { font-size: 14px; font-weight: 600; fill: var(--fg); }
.dg .t-body { font-size: 13.5px; fill: var(--fg-muted); }
.dg .t-small { font-size: 13px; fill: var(--fg-muted); }
.dg .t-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; fill: var(--fg); }
.dg .t-code-k { fill: var(--t1); }
.dg .t-badge { font-size: 12px; font-weight: 700; fill: var(--bg); }
.dg .t-on-chassis { font-size: 14px; font-weight: 600; fill: var(--bg); }
.dg .t-warn { font-size: 17.5px; font-weight: 600; fill: var(--warn); }
.dg .t-good { font-size: 17.5px; font-weight: 600; fill: var(--accent); }
.dg .t-italic { font-size: 11.5px; font-style: italic; fill: var(--fg); }
.dg .box { fill: var(--bg-soft); stroke: var(--border); stroke-width: 1.5; }
.dg .plain { fill: var(--bg); stroke: var(--border); stroke-width: 1.2; }
.dg .code { fill: var(--code-bg); }
.dg .chassis { fill: var(--chassis); }
.dg .wheel { fill: var(--chassis); stroke: var(--bg); stroke-width: 3; }
.dg .warn-box { fill: var(--bg-soft); stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }
.dg .t1-box { fill: var(--t1-soft); stroke: var(--t1); stroke-width: 1.5; }
.dg .t2-box { fill: var(--t2-soft); stroke: var(--t2); stroke-width: 1.5; }
.dg .t3-box { fill: var(--t3-soft); stroke: var(--t3); stroke-width: 1.5; }
.dg .t1-fill { fill: var(--t1); } .dg .t2-fill { fill: var(--t2); } .dg .t3-fill { fill: var(--t3); }
.dg .fg-fill { fill: var(--fg-muted); }
.dg .line { fill: none; stroke: var(--fg-muted); stroke-width: 1.5; }
.dg .t1-line { fill: none; stroke: var(--t1); stroke-width: 2; }
.dg .t2-line { fill: none; stroke: var(--t2); stroke-width: 2; }
.dg .t3-line { fill: none; stroke: var(--t3); stroke-width: 2; }
.dg .dashed { stroke-dasharray: 4 4; }

/* Cards & thrusts */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}
.card {
  padding: 16px 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft);
}
.card p { margin: 0; font-size: 0.95rem; color: var(--fg-muted); }

.thrust { display: flex; gap: 16px; margin: 20px 0; }
.thrust-num {
  flex: 0 0 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; background: var(--tc, var(--accent)); color: var(--accent-fg);
}
.thrust-1 { --tc: var(--t1); }
.thrust-2 { --tc: var(--t2); }
.thrust-3 { --tc: var(--t3); }
.thrust-1 h3, .thrust-2 h3, .thrust-3 h3 { color: var(--tc); }
.thrust p { margin: 0; }

/* People */
.people-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.person { display: flex; gap: 14px; align-items: flex-start; }
.person-photo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: none; }
.person-name { font-weight: 600; }
.person-role {
  margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; background: var(--accent-soft); color: var(--accent);
}
.person-meta { font-size: 0.92rem; color: var(--fg-muted); }

/* Publications (jekyll-scholar output) */
.publications h2.bibliography {
  font-size: 1.3rem; margin: 32px 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.publications h2.bibliography:first-child { margin-top: 0; }
.publications ul.bibliography { list-style: none; padding: 0; margin: 0; }
.publications ul.bibliography > li { margin-bottom: 18px; }
.pub-item { scroll-margin-top: 80px; }
.pub-title { font-weight: 600; }
.pub-title a { color: var(--fg); text-decoration: none; }
.pub-title a:hover { color: var(--accent); text-decoration: underline; }
.pub-badge {
  display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 4px;
  font-size: 0.72rem; font-weight: 700; vertical-align: 0.1em;
  background: var(--accent); color: var(--accent-fg);
}
.pub-meta, .pub-venue { font-size: 0.93rem; color: var(--fg-muted); }
.pub-note { margin-left: 6px; font-weight: 600; color: var(--accent); }
.pub-links { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.pub-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 9px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 0.78rem; font-weight: 600; line-height: 1.7;
  color: var(--accent); background: none;
  text-decoration: none; cursor: pointer;
}
.pub-link:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.abstract-block {
  margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 6px;
  font-size: 0.92rem; color: var(--fg-muted);
}
.abstract-block p { margin: 0; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border); background: var(--bg-soft);
  padding: 20px 0; font-size: 0.85rem; color: var(--fg-muted);
}
.site-footer p { margin: 6px 0; }
.site-footer a { color: inherit; }

@media (max-width: 560px) {
  .thrust { gap: 12px; }
  .thrust-num { flex-basis: 32px; height: 32px; font-size: 0.9rem; }
}

/* Diagram icons */
.dg .ic { fill: var(--chassis); }
.dg .ic-line { fill: none; stroke: var(--chassis); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.dg .ic-thin { fill: none; stroke: var(--chassis); stroke-width: 2; stroke-linecap: round; }
.dg .ic-hole { fill: var(--bg); }
.dg .field { fill: var(--t1-soft); stroke: var(--t1); stroke-width: 1.2; stroke-opacity: 0.5; }
.dg .leaf { fill: var(--t1); }
.dg .stem { fill: none; stroke: var(--t1); stroke-width: 1.6; stroke-linecap: round; }
.dg .berry { fill: #d1453b; }
.dg .wave { fill: none; stroke: var(--t3); stroke-width: 2.2; stroke-linecap: round; }
/* The architecture figure is wide, so it gets larger type to stay readable. */
.dg-arch .t-title { font-size: 20px; }
.dg-arch .t-body { font-size: 16px; }
.dg-arch .t-strong { font-size: 17px; }
.dg-arch .t-small { font-size: 16px; }
.dg-arch .t-edge { font-size: 19px; font-weight: 700; }
