/* ==========================================================================
   Jose Luis Villca Villegas — personal site
   Palette taken from the portrait (navy suit, pin colours) + clinical teal.
   Type: Newsreader (display) + Public Sans (text & interface).
   ========================================================================== */

:root {
  --ink: #1e2b3a;          /* navy — headings, text */
  --ink-2: #3b4a57;        /* body text */
  --muted: #5d6a73;        /* secondary text */
  --paper: #f5f7f6;        /* page */
  --surface: #ffffff;      /* panels, inputs */
  --rule: #d5dcda;         /* hairlines */
  --rule-strong: #b7c2bf;
  --teal: #0b6e6b;         /* clinical accent, links */
  --teal-soft: #e3efed;
  --ochre: #b7862a;        /* pooled diamond, highlights */
  --ochre-soft: #f6eedc;
  --danger: #a33a2c;
  --focus: #0b6e6b;
  --shadow: 0 1px 0 rgba(30, 43, 58, .04), 0 8px 24px -16px rgba(30, 43, 58, .25);

  --f-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --f-text: "Public Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;

  --step--1: .875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --step-4: clamp(2.4rem, 1.6rem + 3.2vw, 4rem);

  --wrap: 1120px;
  --gutter: clamp(1.1rem, .6rem + 2.4vw, 2.5rem);
  --radius-s: 4px;
  --radius-m: 10px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #e7edf0;
  --ink-2: #c9d3d8;
  --muted: #95a4ac;
  --paper: #121a22;
  --surface: #18232d;
  --rule: #2a3843;
  --rule-strong: #3a4b57;
  --teal: #5fbdb7;
  --teal-soft: #173a3b;
  --ochre: #e0aa4c;
  --ochre-soft: #3a3020;
  --danger: #e57b6b;
  --focus: #7fd3cd;
  --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 10px 30px -18px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Language switching (content ships in both languages) ---------- */
html[lang="en"] [data-l="es"],
html[lang="es"] [data-l="en"] { display: none !important; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--f-text);
  font-size: var(--step-0);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3, h4 { color: var(--ink); font-family: var(--f-display); font-weight: 500; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: var(--step-4); font-weight: 450; letter-spacing: -.02em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); font-family: var(--f-text); font-weight: 600; letter-spacing: 0; }
p { margin: 0 0 1em; max-width: 68ch; }
small { font-size: var(--step--1); }
code, pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.skip { position: absolute; left: -999px; top: .5rem; background: var(--ink); color: var(--paper); padding: .5rem .8rem; z-index: 99; border-radius: var(--radius-s); }
.skip:focus { left: .5rem; }
.muted { color: var(--muted); }
.lede { font-size: var(--step-1); color: var(--ink-2); max-width: 60ch; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap { display: flex; align-items: center; gap: 1.25rem; min-height: 4rem; }
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--rule); }
.brand span { font-family: var(--f-display); font-size: 1.15rem; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
.nav { display: flex; gap: .15rem; }
.nav a { color: var(--ink-2); text-decoration: none; padding: .45rem .7rem; border-radius: var(--radius-s); font-size: .95rem; }
.nav a:hover { background: var(--teal-soft); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--teal); border-radius: 0; }
.header-tools { display: flex; align-items: center; gap: .5rem; }

/* Language switch — the header's one bold control */
.lang-switch {
  position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; align-items: center;
  width: 5.6rem; height: 2.25rem; padding: 3px; border-radius: 999px;
  border: 1px solid var(--rule-strong); background: var(--surface); cursor: pointer;
  font: 600 .8rem/1 var(--f-text); color: var(--muted); letter-spacing: .02em;
}
.lang-switch::before {
  content: ""; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: 999px; background: var(--ink); transition: transform .28s cubic-bezier(.3,.7,.2,1);
}
html[lang="es"] .lang-switch::before { transform: translateX(100%); }
.lang-switch span { position: relative; z-index: 1; text-align: center; transition: color .2s; }
html[lang="en"] .lang-switch .opt-en, html[lang="es"] .lang-switch .opt-es { color: var(--paper); }
.lang-switch:hover { border-color: var(--teal); }

.icon-btn {
  display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--teal); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .moon { display: block; }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .menu-toggle { display: inline-grid; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule); padding: .5rem var(--gutter) 1rem;
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: .8rem .2rem; border-bottom: 1px solid var(--rule); border-radius: 0; }
  .nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--teal); padding-left: .8rem; }
  .brand span { font-size: 1rem; }
}
@media (max-width: 420px) { .brand span { display: none; } }

/* ---------- Page sections ---------- */
main { display: block; }
.section { padding: clamp(2.5rem, 1.5rem + 4vw, 5rem) 0; }
.section + .section { border-top: 1px solid var(--rule); }
.section-head { display: grid; gap: .25rem; margin-bottom: 2rem; }
.section-head p { color: var(--muted); margin: 0; }
.page-head { padding: clamp(2.5rem, 1.5rem + 4vw, 4.5rem) 0 1.5rem; }
.page-head h1 { font-size: clamp(2.2rem, 1.5rem + 2.6vw, 3.4rem); margin-bottom: .35em; }

/* ---------- Hero ---------- */
.hero { padding: clamp(2rem, 1rem + 4vw, 4.5rem) 0 2.5rem; }
.hero-grid { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: clamp(1.5rem, 1rem + 3vw, 4rem); align-items: end; }
.portrait { margin: 0; position: relative; }
.portrait img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius-m); background: #eadfcf; }
.portrait figcaption { margin-top: .6rem; font-size: var(--step--1); color: var(--muted); }
.hero h1 { margin-bottom: .25em; }
.hero .role { font-size: var(--step-1); color: var(--ink); margin: 0 0 1.1rem; max-width: 46ch; }
.hero .lede { margin-bottom: 1.5rem; }
.id-links { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0; list-style: none; }
.id-links a {
  display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .85rem; border-radius: 999px;
  border: 1px solid var(--rule-strong); color: var(--ink); text-decoration: none; font-size: .92rem; background: var(--surface);
}
.id-links a:hover { border-color: var(--teal); color: var(--teal); }
.id-links svg { width: 16px; height: 16px; }
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { max-width: 240px; }
}

/* ---------- Forest plot (signature element) ---------- */
.forest {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m);
  padding: clamp(1rem, .6rem + 1.6vw, 1.75rem); box-shadow: var(--shadow);
}
.forest-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 2rem; margin-bottom: .75rem; }
.forest-head h2 { font-size: var(--step-2); margin: 0; }
.forest-head p { margin: 0; color: var(--muted); font-size: var(--step--1); }
.forest-legend { display: flex; gap: .3rem 1.1rem; font-size: var(--step--1); color: var(--muted); flex-wrap: wrap; }
.forest-legend i { display: inline-block; width: 10px; height: 10px; margin-right: .35rem; vertical-align: -1px; }
.forest-legend .k-clin { background: var(--teal); }
.forest-legend .k-acad { background: var(--ink); }
.forest-legend .k-past { border: 1.5px solid var(--muted); }
.forest-scroll { overflow-x: auto; }
.forest { margin: 3rem 0 0; }
.forest svg { width: 100%; height: auto; font-family: var(--f-text); }
.forest svg.forest-mobile { display: none; }
@media (max-width: 640px) {
  .forest svg.forest-desktop { display: none; }
  .forest svg.forest-mobile { display: block; }
  .forest .row-label { font-size: 14px; }
  .forest .row-meta { font-size: 11.5px; }
}
.forest .axis line, .forest .grid line { stroke: var(--rule); }
.forest .axis text { fill: var(--muted); font-size: 11px; }
.forest .row-label { fill: var(--ink); font-size: 12.5px; }
.forest .row-meta { fill: var(--muted); font-size: 11px; }
.forest .ci { stroke-width: 2; }
.forest .clin .ci, .forest .clin .pt { stroke: var(--teal); }
.forest .acad .ci, .forest .acad .pt { stroke: var(--ink); }
.forest .clin .pt.now { fill: var(--teal); }
.forest .acad .pt.now { fill: var(--ink); }
.forest .pt { fill: var(--surface); stroke-width: 1.6; }
.forest .diamond { fill: var(--ochre); }
.forest .pooled-label { fill: var(--ink); font-size: 13px; font-weight: 600; }
.forest .now-line { stroke: var(--ochre); stroke-dasharray: 3 3; }
.forest .now-text { fill: var(--ochre); font-size: 11px; font-weight: 600; }
.forest .ci { stroke-dasharray: var(--len, 400); stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) {
  .forest.animate .ci { animation: draw 1s cubic-bezier(.4,.1,.2,1) both; animation-delay: calc(var(--i) * 90ms); }
  .forest.animate .pt { animation: pop .35s ease-out both; animation-delay: calc(var(--i) * 90ms + 500ms); transform-box: fill-box; transform-origin: center; }
  .forest.animate .diamond { animation: pop .45s ease-out both; animation-delay: 1.3s; transform-box: fill-box; transform-origin: center; }
}
@keyframes draw { from { stroke-dashoffset: var(--len, 400); } to { stroke-dashoffset: 0; } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ---------- Index directory (home) ---------- */
.directory { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--rule); }
.directory > article { padding: 1.75rem 1.75rem 1.75rem 0; border-bottom: 1px solid var(--rule); }
.directory > article:nth-child(odd) { border-right: 1px solid var(--rule); }
.directory > article:nth-child(even) { padding-left: 1.75rem; padding-right: 0; }
.directory h3 { margin-bottom: .2em; }
.directory h3 a { color: var(--ink); text-decoration: none; }
.directory h3 a:hover { color: var(--teal); }
.directory p { color: var(--muted); margin-bottom: .9rem; }
.sublinks { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.sublinks a {
  display: inline-block; font-size: .88rem; padding: .3rem .65rem; border-radius: var(--radius-s);
  background: var(--teal-soft); color: var(--ink); text-decoration: none;
}
.sublinks a:hover { background: var(--teal); color: #fff; }
@media (max-width: 760px) {
  .directory { grid-template-columns: 1fr; }
  .directory > article, .directory > article:nth-child(even) { padding: 1.5rem 0; border-right: 0; }
}

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.5rem 2rem; margin: 0; }
.facts div { border-left: 2px solid var(--ochre); padding-left: .9rem; }
.facts dt { font-size: var(--step--1); color: var(--muted); }
.facts dd { margin: .15rem 0 0; color: var(--ink); font-family: var(--f-display); font-size: var(--step-1); line-height: 1.3; }

/* ---------- About / timeline ---------- */
.two-col { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; }
.two-col > h2 { font-size: var(--step-2); position: sticky; top: 5.5rem; align-self: start; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; gap: .5rem; } .two-col > h2 { position: static; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 9.5rem 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.timeline li:first-child { padding-top: 0; }
.timeline .when { color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums; padding-top: .2rem; }
.timeline h4 { margin: 0 0 .15rem; }
.timeline .where { color: var(--teal); font-size: .95rem; margin-bottom: .35rem; }
.timeline p { margin: 0; font-size: .95rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 3px; margin-left: .35rem; vertical-align: 2px; }
.tag.now { background: var(--ochre-soft); color: var(--ochre); }
.tag.clin { background: var(--teal-soft); color: var(--teal); }
@media (max-width: 560px) { .timeline li { grid-template-columns: 1fr; gap: .2rem; } }

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: .55rem 0; border-bottom: 1px solid var(--rule); }
.plain-list li:last-child { border-bottom: 0; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; list-style: none; padding: 0; margin: 0; }
.chips li { border: 1px solid var(--rule-strong); border-radius: 999px; padding: .3rem .75rem; font-size: .9rem; color: var(--ink); background: var(--surface); }

/* Publications */
.pubs-status { font-size: var(--step--1); color: var(--muted); margin-bottom: 1rem; }
.pubs { list-style: none; margin: 0; padding: 0; counter-reset: pub; }
.pubs li { padding: .9rem 0 .9rem 2.6rem; border-bottom: 1px solid var(--rule); position: relative; counter-increment: pub; }
.pubs li::before { content: counter(pub); position: absolute; left: 0; top: .95rem; font-family: var(--f-display); color: var(--ochre); font-size: 1.1rem; width: 2rem; text-align: right; }
.pubs .t { color: var(--ink); font-weight: 500; }
.pubs .m { color: var(--muted); font-size: .92rem; }
.pubs a.doi { font-size: .88rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: var(--radius-s); border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper); font: 600 .92rem/1.2 var(--f-text); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn.ghost:hover { border-color: var(--teal); color: var(--teal); background: transparent; }
.btn.small { padding: .35rem .65rem; font-size: .82rem; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Tools ---------- */
.tools-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: clamp(1.5rem, 1rem + 2vw, 3rem); padding-bottom: 5rem; }
.tool-index { position: sticky; top: 5.5rem; align-self: start; }
.tool-index h2 { font-family: var(--f-text); font-size: var(--step--1); font-weight: 600; color: var(--muted); margin: 1.25rem 0 .4rem; letter-spacing: 0; }
.tool-index h2:first-child { margin-top: 0; }
.tool-index ul { list-style: none; margin: 0; padding: 0; }
.tool-index a { display: block; padding: .42rem .7rem; border-radius: var(--radius-s); color: var(--ink-2); text-decoration: none; font-size: .95rem; border-left: 2px solid transparent; }
.tool-index a:hover { background: var(--teal-soft); color: var(--ink); }
.tool-index a[aria-current="true"] { border-left-color: var(--teal); background: var(--teal-soft); color: var(--ink); font-weight: 600; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.field.tool-select { display: none; }
@media (max-width: 900px) {
  .tools-layout { grid-template-columns: 1fr; }
  .tool-index { display: none; }
  .field.tool-select { display: grid; margin-bottom: 1.5rem; }
}

.tool { display: none; }
.tool.active { display: block; }
.tool > header h2 { margin-bottom: .3rem; }
.tool > header p { color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: clamp(1rem, .7rem + 1.2vw, 1.6rem); box-shadow: var(--shadow); margin-bottom: 1.25rem; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem 1rem; }
.field { display: grid; gap: .3rem; }
.field label, .field .lbl { font-size: .86rem; color: var(--ink); font-weight: 500; }
.field .hint { font-size: .78rem; color: var(--muted); }
input[type="number"], input[type="text"], select {
  width: 100%; padding: .55rem .65rem; border-radius: var(--radius-s); border: 1px solid var(--rule-strong);
  background: var(--paper); color: var(--ink); font: 500 1rem/1.3 var(--f-text); font-variant-numeric: tabular-nums;
}
input:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
input:invalid { border-color: var(--danger); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule-strong); border-radius: var(--radius-s); overflow: hidden; margin-bottom: 1.1rem; }
.seg button { border: 0; background: var(--surface); color: var(--ink-2); padding: .5rem .85rem; font: 500 .88rem var(--f-text); cursor: pointer; border-right: 1px solid var(--rule); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.subform { display: none; }
.subform.active { display: block; }

.twobytwo { border-collapse: separate; border-spacing: 6px; margin: 0 0 .5rem -6px; }
.twobytwo th { font-size: .82rem; color: var(--muted); font-weight: 500; text-align: center; padding: 0 .25rem; }
.twobytwo th[scope="row"] { text-align: right; }
.twobytwo td { width: 8.5rem; }
.twobytwo td input { text-align: center; }
.twobytwo .cell-note { display: block; font-size: .72rem; color: var(--muted); text-align: center; margin-top: .2rem; }

.groups-table { width: 100%; border-collapse: collapse; margin-bottom: .75rem; }
.groups-table th { text-align: left; font-size: .82rem; color: var(--muted); font-weight: 500; padding: 0 .4rem .35rem; }
.groups-table td { padding: .25rem .4rem; }
.groups-table td:first-child { color: var(--muted); font-variant-numeric: tabular-nums; width: 2rem; }
.groups-table button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.2rem; padding: .2rem .4rem; }
.groups-table button:hover { color: var(--danger); }

.result { margin-top: 1.25rem; }
.result-empty { color: var(--muted); font-size: .95rem; border: 1px dashed var(--rule-strong); border-radius: var(--radius-s); padding: .9rem 1rem; }
.result-error { color: var(--danger); font-size: .95rem; border: 1px solid currentColor; border-radius: var(--radius-s); padding: .9rem 1rem; }
.result-main { display: flex; flex-wrap: wrap; gap: .8rem 2.5rem; margin-bottom: 1rem; }
.result-main div { display: grid; }
.result-main span { font-size: .82rem; color: var(--muted); }
.result-main strong { font-family: var(--f-display); font-weight: 500; font-size: 2rem; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.15; }
.result-main strong.accent { color: var(--ochre); }
table.res { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.res th, table.res td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--rule); font-size: .94rem; }
table.res th { color: var(--muted); font-weight: 500; font-size: .82rem; }
table.res td:first-child { color: var(--ink); }
.res-wrap { overflow-x: auto; }
.note { font-size: .88rem; color: var(--muted); background: var(--ochre-soft); border-left: 3px solid var(--ochre); padding: .6rem .8rem; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin: .9rem 0 0; max-width: none; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

details.method { border-top: 1px solid var(--rule); padding-top: .9rem; margin-top: .5rem; }
details.method summary { cursor: pointer; color: var(--ink); font-weight: 600; font-size: .95rem; }
details.method[open] summary { margin-bottom: .6rem; }
details.method p, details.method li { font-size: .92rem; }
details.method ol { padding-left: 1.2rem; margin: .4rem 0 0; }
.formula { font-family: var(--f-display); font-style: italic; font-size: 1.05rem; color: var(--ink); background: var(--paper); padding: .5rem .75rem; border-radius: var(--radius-s); overflow-x: auto; white-space: nowrap; margin: .4rem 0 .8rem; }

/* ---------- Toolkit (R) ---------- */
.pkg { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1.5rem; padding: 1.75rem 0; border-bottom: 1px solid var(--rule); }
.pkg:first-of-type { border-top: 1px solid var(--rule); }
.pkg h3 { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; font-weight: 600; margin-bottom: .25rem; }
.pkg .use { color: var(--muted); font-size: .9rem; }
.pkg .src { font-size: .85rem; }
@media (max-width: 760px) { .pkg { grid-template-columns: 1fr; gap: .5rem; } }
.code { position: relative; margin: .75rem 0 0; }
.code pre {
  margin: 0; padding: 1rem 1.1rem; background: #17222c; color: #dbe5e9; border-radius: var(--radius-m);
  overflow-x: auto; line-height: 1.55; font-size: .84rem;
}
html[data-theme="dark"] .code pre { background: #0c1218; border: 1px solid var(--rule); }
.code pre .c { color: #87a3ae; }
.code .copy { position: absolute; top: .5rem; right: .5rem; background: rgba(255,255,255,.08); color: #dbe5e9; border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius-s); font: 600 .75rem var(--f-text); padding: .3rem .55rem; cursor: pointer; }
.code .copy:hover { background: rgba(255,255,255,.18); }

.downloads { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.download { border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1.1rem 1.2rem; background: var(--surface); display: grid; gap: .4rem; align-content: start; }
.download h3 { font-size: var(--step-1); margin: 0; }
.download p { margin: 0 0 .5rem; color: var(--muted); font-size: .93rem; }

/* ---------- Projects ---------- */
.venture { display: grid; grid-template-columns: 1fr 2fr; gap: 2rem; padding: 2rem 0; border-bottom: 1px solid var(--rule); }
.venture:first-of-type { border-top: 1px solid var(--rule); }
.venture h3 { margin-bottom: .2rem; }
.venture .kind { color: var(--muted); font-size: .92rem; margin: 0 0 .6rem; }
.venture .link { font-size: .92rem; }
@media (max-width: 760px) { .venture { grid-template-columns: 1fr; gap: .5rem; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 2.5rem 0 3rem; margin-top: 2rem; font-size: .92rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem; }
.site-footer a { color: var(--ink-2); }
.site-footer p { margin: 0; }

/* ---------- 404 ---------- */
.notfound { min-height: 60vh; display: grid; align-content: center; gap: 1rem; }
.notfound .big { font-family: var(--f-display); font-size: clamp(4rem, 3rem + 6vw, 8rem); color: var(--ochre); line-height: 1; }

/* ---------- Misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); background: var(--ink); color: var(--paper);
  padding: .6rem 1rem; border-radius: var(--radius-s); font-size: .9rem; z-index: 100; transition: transform .25s ease;
}
.toast.show { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

@media print {
  .site-header, .site-footer, .tool-index, .tool-select, .actions, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  .tool { display: block !important; page-break-after: always; }
  .panel, .forest { box-shadow: none; }
}
.download .btn { justify-self: start; }
