:root {
  --paper: #f4f5f1;
  --panel: #ffffff;
  --ink: #17201b;
  --ink-2: #3e4a43;
  --muted: #6b766f;
  --line: #dde2dc;
  --line-2: #c9d0c8;
  --spruce: #1d3a2d;
  --spruce-2: #2b5140;
  --moss: #e6ece3;
  --iris: #d9661e;
  --iris-soft: #fbeadd;
  --ok: #2f7d4f;
  --warn: #b7791f;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(20, 35, 27, .06), 0 4px 16px rgba(20, 35, 27, .05);
  --radius: 10px;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101613; --panel: #16201b; --ink: #e8ede9; --ink-2: #c3cdc6; --muted: #8d9a92; --line: #26332c; --line-2: #33443a;
    --spruce: #0b1511; --spruce-2: #1b3024; --moss: #1c2a22; --iris: #f08a45; --iris-soft: #3a2415; --ok: #5cb883; --warn: #e0a84a; --bad: #ef6b62;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101613; --panel: #16201b; --ink: #e8ede9; --ink-2: #c3cdc6; --muted: #8d9a92; --line: #26332c; --line-2: #33443a;
  --spruce: #0b1511; --spruce-2: #1b3024; --moss: #1c2a22; --iris: #f08a45; --iris-soft: #3a2415; --ok: #5cb883; --warn: #e0a84a; --bad: #ef6b62;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { color: var(--iris); text-decoration-color: currentColor; }
h1, h2, h3 { line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; }
h2 { font-size: 20px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-size: .95em; }
.muted { color: var(--muted); }
.label { font: 600 11px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 20px; }

/* header */
.top { background: var(--spruce); color: #eef3ef; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 1000; }
.top .wrap { display: flex; align-items: center; gap: 28px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand:hover { color: inherit; }
.brand svg { width: 30px; height: 30px; }
.brand b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; display: block; line-height: 1; }
.brand small { display: block; font: 500 10px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; opacity: .7; margin-top: 3px; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { text-decoration: none; padding: 7px 11px; border-radius: 7px; font-weight: 600; font-size: 14px; color: #c9d6cd; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav a.on { color: #fff; background: rgba(255, 255, 255, .12); box-shadow: inset 0 -2px 0 var(--iris); }
.live { display: inline-flex; align-items: center; gap: 7px; font: 600 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #bfe0c9; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .55); } 70% { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 7px; padding: 6px 10px; font: 600 13px var(--sans); }
.theme-btn { background: none; border: 1px solid rgba(255, 255, 255, .2); color: #dfe8e2; border-radius: 7px; width: 34px; height: 32px; cursor: pointer; }

/* layout pieces */
main { padding-block: 28px 56px; min-height: 70vh; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.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)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.lead { font-size: 17px; color: var(--ink-2); max-width: 64ch; margin-top: 10px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 11px var(--mono); letter-spacing: .05em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--moss); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; }
.stat { padding: 16px 18px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .v { font: 700 26px/1.1 var(--mono); letter-spacing: -.02em; margin-top: 6px; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* maps */
.map { height: 560px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--moss); }
.map.tall { height: calc(100vh - 210px); min-height: 520px; }
.map.mid { height: 460px; }
.leaflet-container { font: 13px var(--sans); background: var(--moss); }
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 12px 14px; line-height: 1.45; }
.pop b { font-size: 14px; }
.pop .mono { font-size: 12px; color: #55615a; }
.bird-pin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.bird-pin.live::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 2px solid var(--c); opacity: .6; animation: ring 2.2s infinite; }
@keyframes ring { 0% { transform: scale(.5); opacity: .7; } 100% { transform: scale(1.4); opacity: 0; } }
.pin-label { font: 700 12px var(--sans); color: #111; background: #fff; padding: 2px 7px; border-radius: 99px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); white-space: nowrap; }
.find-pin { width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #111; font: 700 13px/20px var(--sans); text-align: center; border: 1.5px solid #111; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.nest-pin { font-size: 15px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .4)); }
.map-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 6px 12px; font: 600 13px var(--sans); color: var(--ink-2); cursor: pointer; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--spruce); color: #fff; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: 600 14px var(--sans); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--iris); color: var(--iris); }
.btn.primary { background: var(--spruce); border-color: var(--spruce); color: #fff; }
.btn.primary:hover { background: var(--spruce-2); color: #fff; }

/* bird list on the home map */
.birdlist { display: flex; flex-direction: column; }
.birdrow { display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); text-decoration: none; }
.birdrow:first-child { border-top: 0; }
.birdrow:hover { background: var(--moss); color: inherit; }
.birdrow .n { font-weight: 700; }
.birdrow .m { font-size: 12.5px; color: var(--muted); }
.birdrow .r { text-align: right; font: 500 12px var(--mono); color: var(--muted); }
.birdrow .r b { display: block; color: var(--ink); font-size: 13px; }

/* bird cards */
.card { display: flex; flex-direction: column; text-decoration: none; overflow: hidden; }
.card:hover { color: inherit; border-color: var(--line-2); transform: translateY(-1px); }
.card .mini { height: 170px; background: var(--moss); border-bottom: 1px solid var(--line); }
.card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card .title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card .title h3 { font-size: 20px; display: flex; align-items: center; gap: 9px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; }
.kv div { font-size: 12px; color: var(--muted); }
.kv b { display: block; font: 600 15px var(--mono); color: var(--ink); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; padding-top: 0; }
.feed time { font: 500 12px/1.5 var(--mono); color: var(--muted); }
.feed .t { font-size: 14px; }
.feed .k { font: 600 10.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--iris); margin-right: 6px; }

/* diary */
.post { padding: 22px 24px; }
.post + .post { border-top: 1px solid var(--line); }
.post h3 { font-size: 19px; margin: 6px 0 10px; }
.post p + p { margin-top: 10px; }
.post p { color: var(--ink-2); max-width: 70ch; }
.byline { font: 500 12px var(--mono); color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 600 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 10.5px var(--mono); fill: var(--muted); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-2); }
.bars rect { fill: var(--spruce-2); }
.bars rect.hi { fill: var(--iris); }
.hbar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; font-size: 13.5px; padding: 4px 0; }
.hbar .b { height: 10px; border-radius: 3px; background: var(--spruce-2); }
.hbar .c { font: 500 12px var(--mono); color: var(--muted); text-align: right; }

/* playback */
.player { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.player input[type=range] { flex: 1; accent-color: var(--iris); }
.player .clock { font: 600 13px var(--mono); min-width: 150px; text-align: right; }

/* profile */
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.facts div { padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.facts div:nth-child(-n+2) { border-top: 0; }
.facts b { display: block; color: var(--ink); font: 600 14px var(--sans); }
.facts b.mono { font: 600 13.5px var(--mono); }
.story { font-size: 16px; color: var(--ink-2); max-width: 70ch; }
.hero-bird { display: flex; align-items: center; gap: 14px; }
.hero-bird .swatch { width: 16px; height: 16px; }

.notice { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px; color: var(--ink-2); background: color-mix(in srgb, var(--panel) 60%, transparent); }

footer { border-top: 1px solid var(--line); padding-block: 28px 40px; color: var(--muted); font-size: 13px; }
footer .wrap { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.loading { padding: 60px 0; text-align: center; color: var(--muted); font: 500 13px var(--mono); }

@media (max-width: 1020px) {
  .split { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wrap { padding-inline: 16px; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; background: var(--spruce); padding: 8px 12px 14px; }
  .nav.open { display: flex; }
  .menu-btn { display: inline-block; }
  .top .live { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .map { height: 420px; }
  .map.tall { height: 70vh; min-height: 380px; }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
  .feed li { grid-template-columns: 1fr; gap: 2px; }
  .player .clock { min-width: 0; }
  .facts { grid-template-columns: 1fr; }
  .facts div:nth-child(2) { border-top: 1px solid var(--line); }
}
