:root {
  --bg: #f6f3ea;
  --surface: #ffffff;
  --surface-2: #efeadc;
  --text: #1f2a24;
  --muted: #5f6b63;
  --border: #ddd6c4;
  --accent: #1d6b47;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe4;
  --good: #1d6b47;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --bad: #b3261e;
  --bad-soft: #fde4e1;
  --t-habitat: #d9ecd0; --t-habitat-ink: #2c5a1f;
  --t-aviary: #dbe6fb; --t-aviary-ink: #22467f;
  --t-aquarium: #d3eef2; --t-aquarium-ink: #155a66;
  --t-exhibit: #eee0f6; --t-exhibit-ink: #5b2d78;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714;
    --surface: #1a211d;
    --surface-2: #222b26;
    --text: #e6ece8;
    --muted: #9aa8a0;
    --border: #2f3a34;
    --accent: #5cc48f;
    --accent-ink: #0d1f15;
    --accent-soft: #1d3a2a;
    --good: #5cc48f;
    --warn: #f0b153;
    --warn-soft: #3a2d14;
    --bad: #ff8a80;
    --bad-soft: #3d1d1b;
    --t-habitat: #24391f; --t-habitat-ink: #b5e0a3;
    --t-aviary: #1f2d45; --t-aviary-ink: #adc6f5;
    --t-aquarium: #173a40; --t-aquarium-ink: #9adbe6;
    --t-exhibit: #33253d; --t-exhibit-ink: #dab8ef;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; margin: 1.2rem 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 1.8rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .2rem; }
p { margin: .4rem 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.sci { font-style: italic; color: var(--muted); font-weight: 400; }
h1 .sci { font-size: .55em; display: block; margin-top: .3rem; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 70ch; }

/* header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 750; font-size: 1.1rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.site-header nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.site-header nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-size: .95rem; }
.site-header nav a:hover { background: var(--surface-2); color: var(--text); }
.site-header nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
@media (max-width: 720px) {
  .site-header .wrap { padding-top: 8px; gap: 4px; }
  .site-header nav { margin: 0 -16px; padding: 0 12px 8px; width: calc(100% + 32px); }
}
.site-footer { margin-top: 3rem; padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .88rem; }
.kofi { display: inline-block; margin-bottom: .6rem; padding: 8px 14px; border-radius: 999px; background: #ff5e5b; color: #fff; text-decoration: none; font-weight: 600; }

/* buttons & badges */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.t-habitat { background: var(--t-habitat); color: var(--t-habitat-ink); }
.t-aviary { background: var(--t-aviary); color: var(--t-aviary-ink); }
.t-aquarium { background: var(--t-aquarium); color: var(--t-aquarium-ink); }
.t-exhibit { background: var(--t-exhibit); color: var(--t-exhibit-ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.deluxe { background: var(--warn-soft); color: var(--warn); }
.status { font-size: .85rem; white-space: nowrap; }
.status::before { content: ""; display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .35em; background: var(--muted); }
.s-least-concern::before { background: #3a9d5d; }
.s-near-threatened::before { background: #a3b83a; }
.s-vulnerable::before { background: #e0a526; }
.s-endangered::before { background: #e0701f; }
.s-critically-endangered::before { background: #d23b2e; }

/* planner */
.hero { padding: .5rem 0 .2rem; }
.planner { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; margin-top: 1rem; }
@media (max-width: 820px) { .planner { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; }
.label { display: block; font-weight: 650; margin-bottom: 6px; }
.search-box { position: relative; }
input[type="search"], select {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
input[type="search"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.15); z-index: 5; max-height: 360px; overflow-y: auto; }
.results li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: var(--accent-soft); }
.results li.none { color: var(--muted); cursor: default; background: none; }
.selected { list-style: none; margin: 12px 0 0; padding: 0; }
.selected li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sel-name { flex: 1; min-width: 0; }
.sel-name a { font-weight: 600; color: var(--text); text-decoration: none; margin-right: 4px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.stepper button { width: 30px; height: 30px; border: 0; background: var(--surface-2); color: var(--text); font-size: 1.05rem; cursor: pointer; }
.stepper output { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.remove { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 6px; }
.remove:hover { color: var(--bad); }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.row { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.row:first-of-type { border-top: 0; }
.row-icon { font-size: 1.3rem; line-height: 1.3; width: 1.6rem; text-align: center; flex: none; }
.row ul { margin: .3rem 0; padding-left: 1.1rem; }
.row.bad { background: var(--bad-soft); margin: 0 -16px; padding: 12px 16px; }
.row.warn h3 { color: var(--warn); }
.row.bad h3 { color: var(--bad); }
.note { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 1.2rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; font-size: .92rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.prose { max-width: 75ch; }
.prose li { margin: .3rem 0; }

/* animal pages */
.crumbs { margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.cta-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 1rem 0; }
.facts > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.facts h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .3rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.card:hover { border-color: var(--accent); }

/* tables */
.filters { display: grid; grid-template-columns: 2fr repeat(5, 1fr); gap: 8px; margin: 1rem 0 .4rem; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters input { grid-column: 1 / -1; } }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.animals { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.animals th, table.animals td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.animals th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); position: sticky; top: 0; }
table.animals tr:last-child td { border-bottom: 0; }
table.animals td a { font-weight: 600; }
@media (max-width: 640px) {
  table.animals thead { display: none; }
  table.animals tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  table.animals td { display: block; padding: 2px 0; border: 0; }
}
