:root {
  --bg: #f4f5ef;
  --card: #ffffff;
  --ink: #15201a;
  --muted: #63706a;
  --line: #e2e5dc;
  --accent: #1f7a4c;
  --accent-2: #2e9a63;
  --accent-ink: #ffffff;
  --calling: #ffd34d;
  --calling-soft: #fff4cc;
  --likely: #1f7a4c;
  --possible: #b06d00;
  --group: #5a6bb0;
  --unknown: #707a75;
  --night: #0b1d1a;
  --shadow: 0 1px 2px rgb(20 30 25 / 0.06), 0 6px 18px rgb(20 30 25 / 0.06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1412; --card: #16201c; --ink: #e9efeb; --muted: #9fb0a7; --line: #24312b;
    --accent: #3fb47a; --accent-2: #4cc488; --accent-ink: #06130c; --calling: #ffcf3f; --calling-soft: #3a3214;
    --likely: #4cc488; --possible: #e6a644; --group: #8e9be0; --unknown: #a3aca8;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1412; --card: #16201c; --ink: #e9efeb; --muted: #9fb0a7; --line: #24312b;
  --accent: #3fb47a; --accent-2: #4cc488; --accent-ink: #06130c; --calling: #ffcf3f; --calling-soft: #3a3214;
  --likely: #4cc488; --possible: #e6a644; --group: #8e9be0; --unknown: #a3aca8;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100dvh; padding-bottom: calc(112px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: currentColor; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 21px; letter-spacing: 0.2px; }
.brand svg { width: 30px; height: 30px; color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 6px 12px 6px 9px; font-size: 13px; color: var(--muted); max-width: 58vw; box-shadow: var(--shadow); }
.chip svg { width: 15px; height: 15px; flex: none; color: var(--accent); }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* spectrogram band */
.spec-wrap { position: relative; max-width: 760px; margin: 0 auto; }
#spec { display: block; width: 100%; height: 150px; background: var(--night); }
@media (min-width: 760px) { #spec { border-radius: 16px; } .spec-wrap { padding: 0 16px; } .freq-axis { right: 20px !important; } .spec-overlay { left: 26px !important; } }
.spec-overlay { position: absolute; left: 10px; top: 8px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.clock { font: 600 13px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #e8f5ec; background: rgb(0 0 0 / 0.35);
  padding: 4px 7px; border-radius: 7px; }
.live-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #fff;
  background: rgb(214 61 46 / 0.9); padding: 4px 9px; border-radius: 999px; }
.live-tag i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
.freq-axis { position: absolute; right: 6px; top: 6px; bottom: 6px; display: flex; flex-direction: column; justify-content: space-between;
  font-size: 10px; color: rgb(232 245 236 / 0.55); pointer-events: none; text-align: right; }
@keyframes blink { 50% { opacity: 0.25; } }

/* main list */
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 0; }
.status { margin: 10px 2px 2px; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 2px 6px; }
.list-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 0; font-weight: 700; }
.text-btn { background: none; border: 0; color: var(--accent); padding: 6px 2px; font-size: 14px; font-weight: 600; }
.species { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card { position: relative; display: grid; grid-template-columns: 64px 1fr auto; gap: 4px 14px; align-items: center;
  background: var(--card); border-radius: var(--radius); padding: 10px 14px 10px 10px; box-shadow: var(--shadow);
  border: 1px solid transparent; cursor: pointer; transition: background-color .35s, border-color .35s, transform .2s; }
.card:active { transform: scale(0.99); }
.card.enter { animation: pop .55s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes pop { 0% { opacity: 0; transform: translateY(-14px) scale(.96); } 100% { opacity: 1; transform: none; } }
.card.calling { background: var(--calling-soft); border-color: var(--calling); }
.card.calling .thumb { box-shadow: 0 0 0 3px var(--calling); }
.card.calling::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 0 var(--calling); animation: glow 1.4s ease-out infinite; }
@keyframes glow { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--calling) 70%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.thumb { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: var(--line); grid-row: 1 / span 2;
  transition: box-shadow .35s; display: grid; place-items: center; color: var(--muted); }
.thumb svg { width: 34px; height: 34px; opacity: .55; }
.name { font-weight: 700; font-size: 17px; line-height: 1.2; }
.sub { grid-column: 2; font-size: 13px; color: var(--muted); line-height: 1.3; }
.sub i { font-style: italic; }
.badge { grid-column: 3; grid-row: 1 / span 2; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.badge.likely { background: color-mix(in srgb, var(--likely) 15%, transparent); color: var(--likely); }
.badge.possible { background: color-mix(in srgb, var(--possible) 16%, transparent); color: var(--possible); }
.badge.group { background: color-mix(in srgb, var(--group) 16%, transparent); color: var(--group); }
.badge.unknown { background: color-mix(in srgb, var(--unknown) 16%, transparent); color: var(--unknown); }
.empty { text-align: center; color: var(--muted); padding: 22px 12px 8px; }
.empty svg { width: 54px; height: 54px; color: var(--accent); opacity: .35; }
.empty p { margin: 8px 0 6px; font-size: 15px; }
.others { margin: 14px 2px 0; font-size: 13px; color: var(--muted); }
.others .tag { display: inline-block; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 10px; margin: 3px 4px 0 0; }

/* bottom dock */
.dock { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-around;
  padding: 10px 24px calc(14px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); z-index: 5; }
.dock-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; color: var(--muted);
  font-size: 12px; font-weight: 600; min-width: 64px; cursor: pointer; }
.dock-btn svg { width: 26px; height: 26px; }
.dock-btn input { display: none; }
.mic { position: relative; width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); transition: background .25s, transform .15s; }
.mic:active { transform: scale(0.95); }
.mic svg { width: 34px; height: 34px; position: relative; z-index: 1; }
.mic .ico-stop { display: none; }
.mic[aria-pressed="true"] { background: #d63d2e; color: #fff; box-shadow: 0 6px 18px rgb(214 61 46 / 0.45); }
.mic[aria-pressed="true"] .ico-mic { display: none; }
.mic[aria-pressed="true"] .ico-stop { display: block; }
.mic .ring { position: absolute; inset: 0; border-radius: 50%; }
.mic[aria-pressed="true"] .ring { animation: ring 1.6s ease-out infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgb(214 61 46 / 0.5); } 100% { box-shadow: 0 0 0 22px transparent; } }
.mic:disabled { opacity: .55; cursor: wait; }

/* bottom sheets */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: min(760px, 100vw); max-width: 100vw; max-height: 88dvh;
  border-radius: 22px 22px 0 0; background: var(--card); color: var(--ink); overflow: auto; box-shadow: 0 -10px 40px rgb(0 0 0 / .25); }
.sheet[open] { animation: up .32s cubic-bezier(.2, .9, .3, 1); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet::backdrop { background: rgb(8 14 11 / 0.5); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.sheet .close { position: absolute; right: 12px; top: 8px; z-index: 3; background: rgb(0 0 0 / .35); color: #fff; border: 0;
  width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; }
.sheet h3 { margin: 16px 18px 4px; }
.sheet .muted, .sheet .row { margin-left: 18px; margin-right: 18px; }
.hero { position: relative; margin-top: 8px; }
.hero img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--line); }
.hero .credit { position: absolute; right: 8px; bottom: 6px; font-size: 10.5px; color: #fff; background: rgb(0 0 0 / .45); padding: 2px 7px; border-radius: 6px; max-width: 92%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero.noimg { height: 120px; display: grid; place-items: center; color: var(--muted); background: var(--line); }
.hero.noimg svg { width: 60px; height: 60px; opacity: .5; }
.sheet-body { padding: 14px 18px 24px; }
.sheet-body h3 { margin: 0; font-size: 24px; }
.sheet-body .sci { color: var(--muted); font-style: italic; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.section { margin-top: 18px; }
.section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.clip { position: relative; border-radius: 12px; overflow: hidden; background: var(--night); }
.clip canvas { display: block; width: 100%; height: 120px; }
.play { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 7px 14px 7px 10px; background: rgb(255 255 255 / .92); color: #0b1d1a; font-weight: 700; font-size: 13px; }
.play svg { width: 18px; height: 18px; }
.why { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: center; font-size: 14px; }
.meter { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.note { font-size: 13.5px; color: var(--muted); margin: 10px 0 0; }
.alts { display: flex; flex-wrap: wrap; gap: 6px; }
.alt { font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.row { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 110px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; }
.pill-btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 700; }
.samples { list-style: none; margin: 8px 0 0; padding: 0 18px 22px; display: grid; gap: 8px; }
.sample { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; }
.sample .t { font-weight: 600; font-size: 15px; }
.sample .m { font-size: 12px; color: var(--muted); }
.icon-btn { border: 0; background: var(--bg); border-radius: 999px; width: 38px; height: 38px; display: grid; place-items: center; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.foot { max-width: 760px; margin: 28px auto 0; padding: 0 16px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted); text-align: center; }
