:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #ebe8df;
  --text: #17231d;
  --muted: #5d6a62;
  --line: #e0dbcf;
  --primary: #1c5a43;
  --primary-soft: #dcebe3;
  --on-primary: #ffffff;
  --accent: #c2611a;
  --good: #1f6e42;
  --good-bg: #dff0e5;
  --warn: #8a5a08;
  --warn-bg: #f6ead0;
  --bad: #a83428;
  --bad-bg: #f7e1dd;
  --wave: #2f8f6b;
  --wave-rest: #c9cfc9;
  --radius: 14px;
  --tabs-h: 62px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --surface: #18211c;
    --surface-2: #222c26;
    --text: #e8ece7;
    --muted: #9ba79f;
    --line: #2b372f;
    --primary: #7fcfa6;
    --primary-soft: #1d3a2d;
    --on-primary: #0c1912;
    --accent: #eda25f;
    --good: #86d6a4;
    --good-bg: #173524;
    --warn: #e6b45c;
    --warn-bg: #3a2c10;
    --bad: #f08d80;
    --bad-bg: #40201b;
    --wave: #6fc79f;
    --wave-rest: #3a473f;
  }
}

* { box-sizing: border-box; }
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;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 1.75rem; font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 650; }
h3 { font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: 1.4rem; }
p { margin: .5rem 0; }
a { color: var(--primary); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.solid { fill: currentColor; stroke: none; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
}
.share-page .page { padding-bottom: 40px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font-size: .8rem; color: var(--muted); margin: 0 0 .2rem; }
.sci { font-style: italic; color: var(--muted); margin: .2rem 0 1rem; }
.lead { font-size: 1.05rem; line-height: 1.6; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.section-title { font-size: .95rem; font-weight: 650; margin: 22px 0 8px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.quiet { background: none; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg.icon { width: 18px; height: 18px; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.round {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; text-decoration: none; padding: 0;
}

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: flex; justify-content: center;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; max-width: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.tabs svg.icon { width: 22px; height: 22px; }
.tabs a.active { color: var(--primary); }

/* ---------- record ---------- */
.record { display: flex; flex-direction: column; align-items: center; text-align: center; min-height: calc(100dvh - var(--tabs-h) - 80px); }
.record h1 { margin-top: 10px; font-size: 2rem; }
.record .intro { max-width: 32ch; color: var(--muted); margin-top: 6px; }
.scope {
  width: 100%; height: 150px; margin: 20px 0 16px;
  border-radius: var(--radius); background: #0c1410; display: block;
}
.timer { font-variant-numeric: tabular-nums; font-size: 2.1rem; font-weight: 650; letter-spacing: .01em; }
.mic {
  width: 104px; height: 104px; margin: 14px 0 10px; border-radius: 50%; border: 0;
  background: var(--primary); color: var(--on-primary); cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 0 0 8px var(--primary-soft);
  transition: transform .15s;
}
.mic:active { transform: scale(.96); }
.mic svg.icon { width: 40px; height: 40px; }
.mic.recording { background: var(--bad); color: #fff; box-shadow: none; animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(178 58 46 / .5); }
  100% { box-shadow: 0 0 0 26px rgb(178 58 46 / 0); }
}
@media (prefers-reduced-motion: reduce) { .mic.recording { animation: none; } }
.record .options { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.notice {
  width: 100%; text-align: left;
  background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; font-size: .9rem;
}
.notice.error { background: var(--bad-bg); color: var(--bad); }
.notice.error .btn { color: var(--text); }

/* ---------- lists ---------- */
.toolbar { display: flex; gap: 8px; margin: 14px 0 6px; }
.search {
  flex: 1; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 10px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .875rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { font-size: .78rem; color: var(--muted); }
.day { margin: 20px 0 8px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.card-list {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.card-list li + li { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: inherit; text-decoration: none; }
.thumb {
  width: 52px; height: 52px; flex: none; border-radius: 10px; object-fit: cover; background: var(--surface-2);
  display: grid; place-items: center; color: var(--muted);
}
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex: none; font-size: .76rem; font-weight: 650; padding: 4px 10px; border-radius: 8px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.high { background: var(--good-bg); color: var(--good); }
.badge.medium { background: var(--warn-bg); color: var(--warn); }
.badge.low, .badge.bad { background: var(--bad-bg); color: var(--bad); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.bird-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; }
.bird-card .pic { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.bird-card .pic svg.icon { width: 32px; height: 32px; }
.bird-card .body { padding: 9px 11px 11px; }
.bird-card .title { font-weight: 600; line-height: 1.25; }
.empty { text-align: center; padding: 48px 12px; color: var(--muted); }

/* ---------- detail: hero ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hero { position: relative; margin: calc(-18px - env(safe-area-inset-top)) -16px 16px; background: var(--surface-2); }
.hero .slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.hero .slides::-webkit-scrollbar { display: none; }
.hero figure { flex: 0 0 100%; margin: 0; scroll-snap-align: center; position: relative; }
.hero img { width: 100%; aspect-ratio: 4 / 3; max-height: 420px; object-fit: cover; }
.hero figcaption {
  position: absolute; right: 8px; bottom: 8px; max-width: 70%;
  padding: 2px 8px; border-radius: 6px; background: rgb(0 0 0 / .55); color: #fff; font-size: .68rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hero figcaption a { color: inherit; text-decoration: none; }
.hero .controls {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; justify-content: space-between; pointer-events: none;
}
.hero .controls > * { pointer-events: auto; border-color: transparent; box-shadow: 0 1px 4px rgb(0 0 0 / .25); }
.hero .dots { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 5px; }
.hero .dots span { width: 6px; height: 6px; border-radius: 50%; background: rgb(255 255 255 / .5); }
.hero .dots span.on { background: #fff; }
@media (min-width: 672px) { .hero { margin-left: 0; margin-right: 0; margin-top: 0; border-radius: var(--radius); overflow: hidden; } }

.title-block h1 { font-size: 1.7rem; }
.title-block .sci { margin-bottom: 0; }

/* ---------- detail: player ---------- */
.player {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.player .play {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; padding: 0;
  background: var(--primary); color: var(--on-primary); display: grid; place-items: center; cursor: pointer;
}
.player .play svg.icon { width: 20px; height: 20px; }
.player .track { flex: 1; min-width: 0; }
.player canvas { width: 100%; height: 36px; display: block; cursor: pointer; touch-action: none; }
.player .caption { font-size: .76rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .caption a { color: inherit; }
.player.compact { border: 0; padding: 8px 0; background: none; }
.player.compact .play { width: 38px; height: 38px; background: var(--primary-soft); color: var(--primary); }

/* ---------- detail: panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel h2 { margin-bottom: 6px; }
.working { display: flex; align-items: center; gap: 12px; }
.spinner {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.facts div { flex: 1 1 auto; background: var(--surface-2); border-radius: 12px; padding: 9px 12px; }
.facts dt { font-size: .72rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; }
.account p { margin-top: .35rem; }
.candidate { padding: 10px 0; border-top: 1px solid var(--line); }
.candidate:first-of-type { border-top: 0; padding-top: 2px; }
.candidate:last-child { padding-bottom: 0; }

.sections { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sections details + details { border-top: 1px solid var(--line); }
.sections summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 50px; padding: 0 14px; cursor: pointer; font-weight: 600; font-size: .95rem; list-style: none;
}
.sections summary::-webkit-details-marker { display: none; }
.sections summary svg.icon { width: 18px; height: 18px; color: var(--muted); transition: transform .15s; }
.sections details[open] summary svg.icon { transform: rotate(180deg); }
.sections .content { padding: 0 14px 14px; }
.sections .content p:first-child { margin-top: 0; }
.sections .content p:last-child { margin-bottom: 0; }

.map-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.map { height: 260px; background: var(--surface-2); z-index: 0; }
.map-note { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 12px; font-size: .74rem; color: var(--muted); border-top: 1px solid var(--line); }
.map-note a { color: inherit; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: #3f9b6c; margin-right: 5px; vertical-align: -1px; }
.swatch.pin { border-radius: 50%; background: var(--accent); }
.leaflet-container { font: inherit; }

textarea {
  width: 100%; min-height: 84px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit;
}
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn.whatsapp { background: #1f8f4e; color: #fff; border-color: transparent; }
.disclaimer { font-size: .8rem; color: var(--muted); margin: 18px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; z-index: 1100;
  background: var(--text); color: var(--bg); font-size: .9rem; font-weight: 600;
}

.reference + .reference { border-top: 1px solid var(--line); }

/* ---------- shared page (rendered by the server) ---------- */
.back { display: inline-flex; align-items: center; min-height: 44px; margin: -8px 0 4px -4px; padding: 0 4px; text-decoration: none; font-weight: 600; }
.gallery {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 14px -16px; padding: 0 16px 6px; scrollbar-width: thin;
}
.gallery figure { flex: 0 0 86%; max-width: 440px; margin: 0; scroll-snap-align: center; }
.gallery figure:only-child { flex-basis: 100%; max-width: none; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); background: var(--surface-2); }
.gallery figcaption { font-size: .7rem; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery figcaption a { color: inherit; }
audio { width: 100%; margin: 10px 0; }
