:root {
  --bg: #fbfaf6;
  --fg: #22262a;
  --muted: #5d656c;
  --accent: #8a5a00;
  --link: #0b5a73;
  --line: #ddd8cc;
  --card: #f2efe6;
  --warn-bg: #fff1e0;
  --warn-line: #d9822b;
  --d-amber: #c98a1b;
  --d-blue: #3b6fb6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --fg: #e6e4de;
    --muted: #a3abb0;
    --accent: #e2a640;
    --link: #7cc4dc;
    --line: #2c3236;
    --card: #1d2326;
    --warn-bg: #2b2016;
    --warn-line: #b8691f;
    --d-amber: #e2a640;
    --d-blue: #6fa3e8;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); }
header.site, footer.site, main { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }
header.site { padding-top: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.brand { font-size: 1.4rem; font-weight: 700; text-decoration: none; color: var(--accent); }
nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .4rem; font-size: .95rem; }
nav a { text-decoration: none; color: var(--fg); }
nav a:hover, nav a[aria-current] { color: var(--accent); text-decoration: underline; }
main { padding-top: 1.5rem; padding-bottom: 2rem; }
h1 { font-size: 2rem; line-height: 1.2; margin: .2rem 0 1rem; }
h2 { font-size: 1.4rem; margin: 2.2rem 0 .5rem; border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
h3 { font-size: 1.1rem; margin: 1.6rem 0 .3rem; }
.lede { font-size: 1.15rem; color: var(--muted); }
.crumbs { font-size: .9rem; color: var(--muted); margin: 0; }
figure { margin: 1.2rem 0; }
figure img, figure video { width: 100%; height: auto; display: block; border-radius: 4px; background: var(--card); }
figcaption, .caption { font-size: .9rem; color: var(--muted); margin-top: .35rem; line-height: 1.45; }
.credit { font-style: italic; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.gallery figure { margin: 0; }
.ratio { position: relative; aspect-ratio: 16 / 9; }
.ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 4px; }
.callout, .warn { background: var(--card); border-left: 4px solid var(--accent); padding: .6rem 1rem; margin: 1.2rem 0; border-radius: 0 4px 4px 0; }
.warn { background: var(--warn-bg); border-left-color: var(--warn-line); }
.callout > :first-child, .warn > :first-child { margin-top: 0; }
.callout > :last-child, .warn > :last-child { margin-bottom: 0; }
.hero { margin: -1.5rem -1rem 1.5rem; position: relative; }
.hero img { width: 100%; max-height: 22rem; object-fit: cover; display: block; border-radius: 0; }
.hero .overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.2rem 1rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.hero h1 { color: #fff; margin: 0; font-size: 2.3rem; }
.hero p { margin: .2rem 0 0; font-size: 1.15rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: .8rem 1rem; text-decoration: none; color: var(--fg); display: block; }
.card:hover { border-color: var(--accent); }
.card strong { display: block; color: var(--accent); }
.card span { font-size: .92rem; color: var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; margin: 1rem 0; }
th, td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; }
th { background: var(--card); }
.table-wrap { overflow-x: auto; }
ol.key > li { margin: .6rem 0; }
footer.site { border-top: 1px solid var(--line); padding-top: 1rem; padding-bottom: 2rem; color: var(--muted); font-size: .9rem; }
footer.site p { margin: .2rem 0; }
@media (max-width: 30rem) { h1 { font-size: 1.6rem; } .hero h1 { font-size: 1.8rem; } }

/* diagrams (inline SVG) */
.diagram-fig { margin: 1.5rem 0; }
.diagram { width: 100%; height: auto; max-width: 40rem; display: block; margin: 0 auto; }
.diagram .t  { fill: var(--fg); font: 13px system-ui, -apple-system, sans-serif; }
.diagram .ts { fill: var(--muted); font: 12px system-ui, -apple-system, sans-serif; }
.diagram .tb { fill: var(--fg); font: 600 13.5px system-ui, -apple-system, sans-serif; }
.diagram .o  { fill: none; stroke: var(--fg); stroke-width: 2; }
.diagram .of { fill: var(--card); stroke: var(--fg); stroke-width: 2; }
.diagram .lead { fill: none; stroke: var(--muted); stroke-width: 1; }
.diagram .thin { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.diagram .groove { fill: var(--line); stroke: var(--muted); stroke-width: 1; }
.diagram .chloro { fill: none; stroke: var(--d-amber); stroke-width: 5; stroke-linecap: round; opacity: .85; }
.diagram .nuc { fill: var(--d-blue); fill-opacity: .35; stroke: var(--d-blue); stroke-width: 2; }
.diagram .flag { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.diagram .box { fill: var(--card); stroke: var(--line); stroke-width: 1.5; }
.diagram .q { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.diagram .warnbox { fill: var(--warn-bg); stroke: var(--warn-line); stroke-width: 2; }
.diagram .arrow { fill: none; stroke: var(--fg); stroke-width: 1.8; marker-end: url(#ah-key); }
.ratio.short { aspect-ratio: 9 / 16; max-width: 20rem; margin: 0 auto; }
figure.small { max-width: 26rem; }
figure.portrait { max-width: 20rem; margin-left: auto; margin-right: auto; }

/* ID guide cards */
.dino-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.dino-card { display: block; text-align: center; text-decoration: none; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .8rem .5rem .9rem; }
.dino-card:hover { border-color: var(--accent); }
.dino-card.toxic { background: var(--warn-bg); border-color: var(--warn-line); }
.dino-card svg.icon { width: 100%; max-width: 7.5rem; height: auto; display: block; margin: 0 auto .4rem; }
.dino-card strong { display: block; font-size: 1.05rem; }
.dino-card span { display: block; font-size: .88rem; color: var(--muted); line-height: 1.3; margin-top: .15rem; }
.dino-card .tag { display: inline-block; margin-top: .35rem; font-size: .72rem; font-style: normal; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--warn-line); }
.dino-card svg .of { fill: var(--bg); }

.diagram a { cursor: pointer; }
.diagram a:hover rect { stroke: var(--accent); stroke-width: 3; }
details { margin: 1rem 0; border: 1px solid var(--line); border-radius: 6px; padding: .5rem 1rem; background: var(--card); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .5rem; }
