/* Layout: one reading column (max 72rem); spectrograms sit in dark "instrument" frames
   that look the same in both themes, since the magma colour map is dark by nature.
   Palette: eucalyptus-grey ground, deep ink, Hawkesbury sandstone accent. */
:root {
  --bg: #eef1ec; --surface: #f8faf6; --ink: #14231f; --muted: #55645e; --line: #d2dbd3;
  --accent: #a65a1f; --accent-soft: #f1e2d3; --frame: #0d0a12; --frame-ink: #d9d2e3;
  --night: #dde3dc; --cell: #e3e8e2; --warn: #8a5a00; --warn-soft: #f6ead0;
  --bird: #2f6b3f; --mammal: #8b4f2a; --frog: #2d7a6c; --insect: #8a7210; --bat: #5a4c8c;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --body: "Atkinson Hyperlegible", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1513; --surface: #161e1b; --ink: #e3eae5; --muted: #94a39c; --line: #26322e;
    --accent: #e0954f; --accent-soft: #3a2a1c; --night: #1b2420; --cell: #1f2925;
    --warn: #e7b955; --warn-soft: #3a2f16;
    --bird: #74b884; --mammal: #d39466; --frog: #6cc2b1; --insect: #d1b74c; --bat: #a99ae0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1513; --surface: #161e1b; --ink: #e3eae5; --muted: #94a39c; --line: #26322e;
  --accent: #e0954f; --accent-soft: #3a2a1c; --night: #1b2420; --cell: #1f2925;
  --warn: #e7b955; --warn-soft: #3a2f16;
  --bird: #74b884; --mammal: #d39466; --frog: #6cc2b1; --insect: #d1b74c; --bat: #a99ae0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 1.0625rem/1.6 var(--body); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 72rem; margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px)); }

h1, h2, h3 { font-family: var(--display); line-height: 1.1; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw + 1rem, 4.2rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.45rem, 1.5vw + 1rem, 2rem); font-weight: 700; margin-top: 3.2rem; margin-bottom: 0.6rem; }
h3 { font-size: 1.2rem; font-weight: 500; }
.eyebrow { font: 500 0.78rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 0 0 0.6rem; }
.lede { font-size: 1.2rem; max-width: 40rem; margin: 1rem 0 0; }
.section-note { color: var(--muted); max-width: 44rem; margin: 0 0 1.2rem; }
.sci { font-style: italic; color: var(--muted); margin: 0.3rem 0 0.6rem; font-size: 1.15rem; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky;
  top: env(safe-area-inset-top, 0px); z-index: 5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--bg); }
.top .wrap { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; align-items: center;
  justify-content: space-between; padding-block: 0.7rem; }
.brand { font: 700 1.1rem/1 var(--display); color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 1.1rem; font-size: 0.95rem; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover, .top nav a[aria-current] { color: var(--ink); }

/* hero */
.hero { padding-block: clamp(2.5rem, 6vw, 5rem) 1.5rem; }
.hero.small h1 { font-size: clamp(1.9rem, 3vw + 1rem, 3rem); }
.tally { list-style: none; padding: 0; margin: 1.8rem 0 0; display: flex; flex-wrap: wrap; gap: 0.6rem 2.2rem; }
.tally li { color: var(--muted); font-size: 0.95rem; }
.tally b { display: block; font: 700 2.2rem/1 var(--display); color: var(--ink);
  font-variant-numeric: tabular-nums; }

.soundscape figure { margin: 0; }
.soundscape img { border-radius: 10px; background: #fff; width: 100%; }
.soundscape figcaption { color: var(--muted); font-size: 0.92rem; margin-top: 0.6rem; max-width: 48rem; }

/* featured clips */
.featured { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1.6rem 1.4rem; }
.feat { min-width: 0; }
.feat h3 { margin-bottom: 0.4rem; }
.feat h3 a { color: var(--ink); text-decoration: none; }
.feat h3 a:hover { text-decoration: underline; }
.feat .eyebrow { margin-bottom: 0.3rem; color: var(--kind); }
.feat .clip { margin-top: 0.7rem; grid-template-columns: 1fr; }

/* kind colours */
.k-bird { --kind: var(--bird); } .k-mammal { --kind: var(--mammal); } .k-frog { --kind: var(--frog); }
.k-insect { --kind: var(--insect); } .k-bat { --kind: var(--bat); }

/* badges */
.badges { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.badge { font: 500 0.72rem/1 var(--mono); letter-spacing: 0.03em; padding: 0.3rem 0.5rem;
  border-radius: 999px; white-space: nowrap; border: 1px solid var(--kind, var(--accent)); }
.badge.solid { background: var(--kind, var(--accent)); color: var(--surface); }
.badge.outline { color: var(--kind, var(--accent)); }
.badge.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

/* section heads */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.toggle-all { font: inherit; font-size: 0.9rem; color: var(--accent); background: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.9rem; cursor: pointer; }
.group { margin: 2rem 0 0.6rem; color: var(--kind); display: flex; gap: 0.5rem; align-items: baseline; }
.group span { font: 400 0.85rem var(--mono); color: var(--muted); }

/* species panels */
.panels { border-top: 1px solid var(--line); }
details.sp { border-bottom: 1px solid var(--line); }
details.sp > summary { list-style: none; cursor: pointer; display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto auto 3.2rem; align-items: center; gap: 0.4rem 1rem;
  padding: 0.6rem 0.2rem; }
details.sp > summary::-webkit-details-marker { display: none; }
details.sp > summary:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
details.sp[open] > summary { background: var(--surface); }
.thumb { width: 3rem; height: 3rem; border-radius: 8px; overflow: hidden; background: var(--cell); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.names { display: flex; flex-direction: column; min-width: 0; }
.names b { font-weight: 700; }
.names i { color: var(--muted); font-size: 0.9rem; }
.count { font: 500 0.95rem var(--mono); text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.count::after { content: " \25BE"; font-size: 0.7rem; }
details[open] .count::after { content: " \25B4"; }
.sp-body { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 1.2rem 1.6rem;
  padding: 1rem 0.2rem 1.6rem; background: var(--surface); }
.sp-body .clips { grid-column: 1 / -1; }
.sp-body .text p { margin: 0 0 0.8rem; max-width: 42rem; }
.photo { margin: 0; }
.photo img { border-radius: 10px; aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.photo figcaption { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }
.call .lbl, .caution::before { font: 500 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--kind); margin-right: 0.4rem; }
.caution { background: var(--warn-soft); color: var(--ink); border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.95rem; }
.caution::before { content: "Caution"; color: var(--warn); }
.links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; font-size: 0.95rem; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 0.6rem 1.4rem; margin: 0.4rem 0 1rem; }
.facts div { min-width: 0; }
.facts dt { font: 500 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.facts dd { margin: 0.15rem 0 0; }

/* hour strips */
svg.hours { width: 168px; height: 14px; display: block; }
svg.hours.big { width: min(100%, 30rem); height: auto; margin: 0.4rem 0 1rem; }
svg.hours .cell, .daychart .cell { fill: var(--cell); }
svg.hours .cell.night, .daychart .cell.night { fill: var(--night); stroke: var(--line); stroke-width: 0.5; }
svg.hours .hit { fill: var(--kind, var(--accent)); }
svg.hours text, .daychart text { font: 8px var(--mono); fill: var(--muted); }
.daychart svg { width: 100%; max-width: 46rem; height: auto; }
.daychart .hit { fill: var(--kind); }
.daychart .rowlabel { font: 10px var(--body); fill: var(--ink); }

/* clips: spectrogram beside its player */
.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); gap: 1rem; }
.clip { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) 11rem; gap: 0.7rem;
  align-items: stretch; min-width: 0; }
.spec { position: relative; background: var(--frame); border-radius: 8px; overflow: hidden; cursor: pointer;
  aspect-ratio: 960 / 280; }
.spec img { width: 100%; height: 100%; object-fit: fill; }
.playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8); opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.clip.playing .playhead, .clip.paused .playhead { opacity: 1; }
.yaxis { position: absolute; inset: 0.25rem auto 0.25rem 0.35rem; display: flex; flex-direction: column;
  justify-content: space-between; font: 500 0.65rem/1 var(--mono); color: var(--frame-ink);
  text-shadow: 0 0 3px #000; pointer-events: none; }
.side { display: flex; gap: 0.6rem; align-items: flex-start; min-width: 0; font-size: 0.85rem; }
.side .meta { display: flex; flex-direction: column; gap: 0.15rem; color: var(--muted); min-width: 0; }
.side .meta b { color: var(--ink); font-weight: 700; }
.play { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--kind, var(--accent)); color: var(--surface); display: grid; place-items: center; }
.play svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }
.play .i-pause, .clip.playing .play .i-play { display: none; }
.clip.playing .play .i-pause { display: block; }

/* deployments list */
.deps { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.deps a { display: grid; gap: 0.15rem; padding: 0.9rem 1rem; border: 1px solid var(--line);
  border-radius: 10px; text-decoration: none; color: var(--muted); background: var(--surface); }
.deps a b { color: var(--ink); font-family: var(--display); font-size: 1.15rem; }
.deps a:hover { border-color: var(--accent); }

/* species page */
.sp-head { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 1.4rem 2.4rem;
  padding-block: 2.5rem 0.5rem; align-items: start; }
.sp-head .lede { font-size: 1.1rem; }
.sp-head .call, .sp-head .caution { margin-top: 1rem; max-width: 42rem; }
.table { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 500 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* about */
.prose { max-width: 44rem; padding-block: 2.5rem 1rem; }
.prose h1 { font-size: clamp(2rem, 3vw + 1rem, 3rem); }
.prose li { margin-bottom: 0.5rem; }
.defs { display: grid; gap: 1rem; }
.defs dt { margin-bottom: 0.3rem; }
.defs dd { margin: 0; }
.defs .badge { --kind: var(--bird); }

.foot { color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); margin-top: 4rem;
  padding-block: 1.5rem 2.5rem; }
.foot p { max-width: 50rem; margin: 0; }

@media (max-width: 760px) {
  details.sp > summary { grid-template-columns: 2.6rem minmax(0, 1fr) 2.8rem; }
  .thumb { width: 2.6rem; height: 2.6rem; }
  details.sp > summary .badges { grid-column: 2; grid-row: 2; }
  details.sp > summary .strip { grid-column: 2 / -1; grid-row: 3; }
  .count { grid-column: 3; grid-row: 1; }
  .sp-body, .sp-head { grid-template-columns: 1fr; }
  .sp-body .photo { max-width: 22rem; }
  .clip { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* home: section bar, group tabs, call to action */
.sectionbar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 3.05rem); z-index: 4;
  display: flex; gap: 0.3rem 1.2rem; flex-wrap: wrap; padding-block: 0.55rem; margin-bottom: 1.5rem;
  background: var(--bg); border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.sectionbar a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.sectionbar a:hover { color: var(--accent); }
section[id] { scroll-margin-top: 7rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 1rem; }
.tab { font: inherit; font-size: 0.95rem; cursor: pointer; border-radius: 999px; padding: 0.35rem 0.9rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.tab span { font: 400 0.8rem var(--mono); color: var(--muted); margin-left: 0.2rem; }
.tab[aria-selected="true"] { background: var(--kind); border-color: var(--kind); color: var(--surface); }
.tab[aria-selected="true"] span { color: inherit; opacity: 0.8; }
.js-tabs .tabpanel .group { display: none; }
.cta { margin-top: 4rem; padding: 1.6rem; border-radius: 14px; background: var(--accent-soft);
  display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.cta h2 { margin-top: 0; }
.cta p { margin: 0.4rem 0 0; max-width: 40rem; }
.cta-links { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.button { display: inline-block; font: 700 0.98rem/1 var(--body); padding: 0.75rem 1.1rem; border-radius: 999px;
  background: var(--accent); color: var(--surface); border: 1px solid var(--accent); text-decoration: none; cursor: pointer; }
.button.ghost { background: transparent; color: var(--accent); }
.button.small { font-size: 0.85rem; padding: 0.45rem 0.8rem; }
.button:disabled { opacity: 0.5; cursor: progress; }

/* record + contribute */
.prose.wide { max-width: 60rem; }
.mono { font-family: var(--mono); font-size: 0.9em; }
.inline-stats { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: 0.6rem; }
.panel-box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.4rem 1.4rem; margin-top: 2rem; }
.panel-box h2 { margin-top: 0; }
fieldset { border: 0; padding: 0; margin: 1.6rem 0 0; display: grid; gap: 1rem; }
legend { font: 700 1.1rem var(--display); margin-bottom: 0.6rem; }
.field { display: grid; gap: 0.3rem; max-width: 34rem; }
.field label, .field .label { font-weight: 700; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }
input:not([type]), input[type="number"], select, textarea { font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.7rem; width: 100%; }
input[type="file"] { font: inherit; font-size: 0.9rem; }
.private { font: 500 0.68rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0.1rem 0.3rem; margin-left: 0.3rem; vertical-align: middle; }
.consent label { display: flex; gap: 0.6rem; align-items: flex-start; max-width: 44rem; }
.consent input { margin-top: 0.35rem; }
.linklike { color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 400; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.form-error { color: var(--warn); font-weight: 700; min-height: 1.2em; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 0.9rem 1rem; }
#progress { margin-top: 1rem; }
.bar { height: 0.7rem; border-radius: 999px; background: var(--cell); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

@media (max-width: 760px) {
  .cta { grid-template-columns: 1fr; }
  .sectionbar { top: calc(env(safe-area-inset-top, 0px) + 5.4rem); }
}

/* nav sign-in and admin */
.top nav { align-items: center; flex-wrap: wrap; }
.top nav .nav-signin { color: var(--surface); padding: 0.45rem 0.95rem; }
.top nav .nav-signin:hover { color: var(--surface); }
.top nav .nav-signin.signed-in { background: transparent; color: var(--accent); }
.admin td.actions { white-space: nowrap; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.admin tr.st-waiting td { background: var(--warn-soft); }

/* home: group tiles and "show all" */
.group-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: 0.6rem; margin: 0.6rem 0 0.4rem; }
.gtile { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem; border-radius: 12px; text-decoration: none;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--kind); min-width: 0; }
.gtile:hover { border-color: var(--kind); }
.gphoto { flex: none; width: 3.2rem; height: 3.2rem; border-radius: 8px; overflow: hidden; background: var(--cell); }
.gphoto img { width: 100%; height: 100%; object-fit: cover; }
.gtext { font-size: 1rem; line-height: 1.2; }
.gtext b { display: block; font: 700 1.6rem/1 var(--display); color: var(--kind); font-variant-numeric: tabular-nums; }
.group-block { scroll-margin-top: 7rem; }
.panels.more { border-top: 0; }
.show-more { font: inherit; font-size: 0.95rem; margin-top: 0.6rem; color: var(--kind); background: none; cursor: pointer;
  border: 1px solid var(--kind); border-radius: 999px; padding: 0.35rem 0.95rem; }
