:root {
  --ink: #183126;
  --muted: #6b766f;
  --paper: #f4f1e8;
  --card: #fffdf7;
  --line: #ded9cd;
  --moss: #315f48;
  --night: #162c27;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 85% -10%, rgba(95, 143, 113, .16), transparent 30rem), var(--paper);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3.5rem); border-bottom: 1px solid rgba(49,95,72,.2);
  background: rgba(244,241,232,.86); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand-mark {
  width: 3.7rem; height: 2.7rem; flex: 0 0 auto; display: grid; place-items: center;
}
.brand-mark svg { width: 100%; height: 100%; overflow: visible; }
.logo-wing { fill: #6fa780; stroke: var(--moss); stroke-width: 2; stroke-linejoin: round; }
.logo-wing-line { fill: none; stroke: rgba(24,49,38,.48); stroke-width: 1.5; stroke-linecap: round; }
.logo-gear { fill: var(--moss); }
.logo-gear-hole { fill: var(--paper); stroke: var(--night); stroke-width: 2; }
.brand p, .brand h1 { margin: 0; }
.brand p { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .13em; }
.brand h1 { font: 600 1.3rem/1.05 Georgia, serif; letter-spacing: -.025em; }
.status { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .78rem; }
.status i { width: .5rem; height: .5rem; border-radius: 50%; background: #49a56c; box-shadow: 0 0 0 4px rgba(73,165,108,.12); }

main { min-height: calc(100vh - 8rem); }
.intro {
  max-width: 72rem; margin: 0 auto; padding: clamp(2.4rem,7vw,5rem) clamp(1rem,4vw,2rem) 1.5rem;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem;
}
.intro .eyebrow { margin: 0 0 .7rem; color: var(--moss); font-size: .72rem; text-transform: uppercase; font-weight: 700; letter-spacing: .15em; }
.intro h2 { margin: 0; max-width: 42rem; font: 500 clamp(2.15rem,7vw,4.5rem)/.98 Georgia, serif; letter-spacing: -.045em; }
.intro p:not(.eyebrow) { margin: 1rem 0 0; color: var(--muted); }
.intro .archive-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .65rem; font-size: .74rem; }
.archive-meta a, footer a { color: var(--moss); font-weight: 700; text-decoration: none; }
.archive-meta a:hover, .archive-meta a:focus, footer a:hover, footer a:focus { text-decoration: underline; }
.today-count { min-width: 5rem; text-align: right; }
.today-count strong { display: block; font: 500 2.1rem/1 Georgia, serif; }
.today-count span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }

.controls {
  max-width: 72rem; margin: 0 auto; padding: 0 clamp(1rem,4vw,2rem) 1.2rem;
  display: flex; align-items: center; gap: .65rem; flex-wrap: wrap;
}
.filters { display: flex; gap: .45rem; overflow-x: auto; }
.filters button, .load-more {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: .68rem 1rem; white-space: nowrap; cursor: pointer;
}
.filters button.active { color: white; background: var(--moss); border-color: var(--moss); }
.search { margin-left: auto; }
.search input, .minimum select, .view-mode select {
  min-height: 2.65rem; border: 1px solid var(--line); border-radius: .8rem; background: rgba(255,253,247,.75);
  color: var(--ink); padding: .62rem .8rem; outline: none;
}
.search input:focus, .minimum select:focus, .view-mode select:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(49,95,72,.11); }
.minimum, .view-mode { color: var(--muted); font-size: .78rem; }

.detection-list {
  max-width: 72rem; margin: 0 auto; padding: 0 clamp(1rem,4vw,2rem) 2rem;
  display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem;
}
.detection-card {
  min-width: 0; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 1.35rem;
  box-shadow: 0 12px 35px rgba(39,53,44,.055);
}
.photo-wrap { height: 12rem; position: relative; overflow: hidden; background: #dfe4dc; }
.animal-photo { width: 100%; height: 100%; object-fit: contain; display: block; background: #dfe4dc; }
.animal-photo[hidden] { display: none; }
.photo-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.72); }
.photo-placeholder[hidden] { display: none; }
.photo-placeholder::after { content: ""; position: absolute; width: 18rem; height: 18rem; border: 1px solid rgba(255,255,255,.12); transform: rotate(45deg); }
.photo-placeholder span { font-size: 4rem; z-index: 1; }
.type-label { position: absolute; left: .8rem; top: .8rem; color: white; background: rgba(16,35,29,.75); backdrop-filter: blur(8px); padding: .42rem .65rem; border-radius: 999px; font-size: .64rem; text-transform: uppercase; font-weight: 700; letter-spacing: .08em; }
.photo-credit { position: absolute; right: .5rem; bottom: .45rem; max-width: 70%; color: rgba(255,255,255,.85); background: rgba(15,26,22,.6); padding: .2rem .35rem; border-radius: .25rem; font-size: .48rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body { padding: 1rem; }
.card-title { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.card-title time { color: var(--muted); font-size: .7rem; }
.card-title h2 { margin: .35rem 0 .08rem; font: 600 1.45rem/1.05 Georgia,serif; }
.english-name { margin: 0 0 .25rem; color: #4c5b52; font-size: .85rem; }
.scientific-name { color: var(--muted); font-size: .8rem; text-decoration: none; }
.scientific-name:hover { color: var(--moss); text-decoration: underline; }
.confidence {
  flex: 0 0 auto; min-width: 3.35rem; height: 3.35rem; border-radius: 50%; border: 1px solid #bdcdbf;
  display: flex; align-items: baseline; justify-content: center; padding-top: .82rem; background: #edf4ed;
}
.confidence strong { font-size: 1rem; }
.confidence span { font-size: .62rem; }

.spectrogram-panel { width: 100%; height: auto; margin-top: 1rem; border-radius: .8rem; background: var(--night); overflow: hidden; display: block; }
.spectrogram-panel img { width: 100%; height: auto; display: block; object-fit: contain; }
.spectrogram-missing { margin-top: 1rem; min-height: 7rem; border-radius: .8rem; background: var(--night); color: rgba(255,255,255,.55); display: grid; place-items: center; font-size: .75rem; }
audio { display: none; }
.player-row { display: flex; align-items: center; gap: .55rem; margin-top: .8rem; position: relative; }
.player-row button {
  border: 1px solid var(--line); border-radius: .75rem; background: #f5f3eb;
  padding: .68rem .82rem; font-weight: 700; font-size: .8rem; cursor: pointer;
}
.player-row button.active { background: var(--night); color: white; border-color: var(--night); }
.player-row button:disabled { opacity: .38; cursor: not-allowed; }
.player-row button span { color: #4f956a; margin-right: .25rem; }
.player-row button.active span { color: #9ee0b1; }
.download-menu { position: relative; }
.download-menu summary {
  list-style: none; border: 1px solid var(--line); border-radius: .75rem; background: #f5f3eb;
  padding: .68rem .82rem; font-weight: 700; font-size: .8rem; cursor: pointer; white-space: nowrap;
  user-select: none;
}
.download-menu summary::-webkit-details-marker { display: none; }
.download-menu summary span { color: #4f956a; margin-right: .25rem; }
.download-menu[open] summary { color: white; background: var(--night); border-color: var(--night); }
.download-menu[open] summary span { color: #9ee0b1; }
.download-options {
  position: absolute; right: 0; bottom: calc(100% + .45rem); z-index: 5; min-width: 13rem;
  padding: .35rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--card);
  box-shadow: 0 12px 30px rgba(20,40,31,.18);
}
.download-options a {
  display: block; padding: .62rem .7rem; border-radius: .55rem; color: var(--ink); text-decoration: none;
}
.download-options a:hover, .download-options a:focus { background: #edf4ed; outline: none; }
.download-options strong, .download-options small { display: block; }
.download-options strong { font-size: .78rem; }
.download-options small { margin-top: .12rem; color: var(--muted); font-size: .64rem; }
.play-state { margin-left: auto; color: var(--muted); font-size: .7rem; text-align: right; }
.audio-note { display: block; margin-top: .6rem; color: #966a31; font-size: .68rem; }

.message { grid-column: 1/-1; padding: 2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--card); text-align: center; color: var(--muted); }
.message.error { max-width: 68rem; margin: 0 auto 1rem; color: #8a3333; border-color: #dbbcbc; }
.more-wrap { text-align: center; padding: 0 1rem 4rem; }
.load-more { background: var(--card); }
footer { max-width: 68rem; margin: 0 auto; padding: 1.5rem 1rem 2rem; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .7rem; }

@media (max-width: 760px) {
  .status { display: none; }
  .intro { align-items: flex-start; }
  .detection-list { grid-template-columns: 1fr; }
  .search { margin-left: 0; flex: 1 1 12rem; }
  .search input { width: 100%; }
}

@media (max-width: 460px) {
  .site-header { padding: .85rem 1rem; }
  .brand { gap: .6rem; }
  .brand-mark { width: 3.15rem; height: 2.35rem; }
  .brand h1 { font-size: 1.08rem; }
  .brand p { font-size: .56rem; }
  .intro { padding-top: 2rem; }
  .intro h2 { font-size: 2.35rem; }
  .intro p:not(.eyebrow) { font-size: .9rem; }
  .controls { align-items: stretch; }
  .filters { width: 100%; }
  .search { order: 2; }
  .view-mode { order: 3; }
  .minimum { order: 4; }
  .minimum, .view-mode { display: flex; align-items: center; gap: .4rem; flex: 1 1 100%; }
  .minimum select, .view-mode select { flex: 1; min-width: 0; }
  .photo-wrap { height: 10rem; }
  .card-title h2 { font-size: 1.2rem; }
  .confidence { min-width: 3rem; width: 3rem; height: 3rem; padding-top: .7rem; }
  .player-row button { flex: 1; padding-inline: .4rem; }
  .player-row { flex-wrap: wrap; }
  .download-menu { flex: 1 1 100%; }
  .download-menu summary { width: 100%; text-align: center; }
  .download-options { left: 0; right: 0; min-width: 0; }
  .play-state { display: none; }
  footer { flex-direction: column; }
}
