/* fuglelyde beta2 — pre-flight + listening shell */
:root {
  --bg: #0f1410;
  --surface: #1a2219;
  --border: #2d3d2e;
  --text: #e8eee8;
  --muted: #8fa090;
  --accent: #4a9c5c;
  --accent-dim: #2f6a3d;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #1e3828 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); }
header.app-header {
  padding: 1rem 1.25rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem 1rem;
  text-align: center;
}
.app-header__text { min-width: 0; text-align: center; }
header.app-header h1 { margin: 0; font-size: 1.35rem; font-weight: 600; }
header.app-header p { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }
.app-header__wave-wrap {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0a0d0a;
  padding: 3px 5px;
  line-height: 0;
  box-shadow: inset 0 0 0 1px rgba(74, 156, 92, 0.12);
}
.app-header__wave-wrap canvas {
  display: block;
  width: 96px;
  height: 22px;
}
.index-doc-link {
  margin: 0;
  padding: 0.5rem 1rem 0.65rem;
  text-align: center;
  font-size: 0.82rem;
}
.index-doc-link a {
  color: var(--accent);
}
.index-doc-link a:hover {
  text-decoration: underline;
}
main { max-width: 32rem; margin: 0 auto; padding: 0 1rem 3rem; }
details.preflight {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
details.preflight > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  user-select: none;
}
details.preflight > summary::-webkit-details-marker { display: none; }
details.preflight > summary::after { content: "▾"; color: var(--muted); font-size: 0.75rem; }
details.preflight[open] > summary::after { content: "▴"; }
.preflight-hint { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0 1rem 1rem;
}
@media (min-width: 28rem) { .check-grid { grid-template-columns: repeat(3, 1fr); } }
.check-grid button {
  appearance: none;
  border: 1px solid var(--border);
  background: #222b22;
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.65rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 3.25rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.check-grid button:hover:not(:disabled) { border-color: var(--accent-dim); background: #283428; }
.check-grid button:disabled { opacity: 0.45; cursor: not-allowed; }
.check-grid button.is-done { border-color: var(--accent); background: #1e3024; }
.check-grid button.is-done.upload-deactivated {
  border-color: #3d4248;
  background: #22262c;
  color: var(--muted);
}
.check-grid button.is-done.upload-deactivated .sub { color: #7a828c; }
.check-grid button .sub { display: block; margin-top: 0.2rem; font-size: 0.65rem; font-weight: 400; color: var(--muted); }
.check-grid button.check-preload {
  --preload-p: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.check-grid button.check-preload .check-preload-inner {
  position: relative;
  display: block;
  min-height: 3.25rem;
  padding: 0.65rem 0.5rem;
}
.check-grid button.check-preload .check-preload-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(3.45rem * var(--preload-p, 0));
  max-height: 100%;
  background: linear-gradient(0deg, rgba(74, 156, 92, 0.55) 0%, rgba(74, 156, 92, 0.12) 92%, transparent 100%);
  pointer-events: none;
  transition: height 0.1s ease-out;
  z-index: 0;
}
.check-grid button.check-preload .check-preload-content {
  position: relative;
  z-index: 1;
  display: block;
}
.check-grid button.check-preload.is-done .check-preload-fill {
  height: 100%;
  opacity: 0.4;
  transition: height 0.35s ease-out, opacity 0.25s ease;
}
.check-grid button.check-preload[aria-busy="true"] { cursor: wait; }
.listen-wrap { margin-top: 0.5rem; }
button.listen-main {
  width: 100%;
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(165deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #fff;
  box-shadow: 0 4px 0 #1a4a24;
}
button.listen-main:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
button.listen-main.is-listening {
  background: linear-gradient(165deg, #8b4513 0%, #5c2e0d 100%);
  box-shadow: 0 4px 0 #3d2008;
}
details.disclosure {
  background: #151c15;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.82rem;
}
details.disclosure > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.65rem 1rem;
  font-weight: 600;
  user-select: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure-body { padding: 0 1rem 1rem; color: var(--muted); }
.disclosure-lead { color: var(--text); margin: 0 0 0.5rem; }
.disclosure-note { font-size: 0.78rem; margin: 0.75rem 0 0; }
pre.ascii-model {
  font-size: 0.55rem;
  line-height: 1.25;
  overflow-x: auto;
  background: #0a0d0a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  color: #b8c8b8;
  margin: 0.5rem 0 0;
}
.step-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.step-panel__h { margin: 0 0 0.75rem; font-size: 1rem; }
.hint { font-size: 0.78rem; color: var(--muted); margin: 0 0 0.75rem; }
.tabs { display: flex; gap: 0.35rem; margin-bottom: 0.75rem; }
.tab {
  flex: 1;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #222b22;
  color: var(--text);
  cursor: pointer;
}
.tab.is-active { border-color: var(--accent); background: #1e3024; }
.tabpanel { margin-bottom: 0.75rem; }
.input-text {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #121812;
  color: var(--text);
  font-size: 0.9rem;
}
.map-canvas {
  height: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 0.5rem 0;
  z-index: 0;
}
.check-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin: 0.5rem 0 1rem;
  cursor: pointer;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.btn-primary, .btn-secondary {
  appearance: none;
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
}
.btn-primary {
  background: linear-gradient(165deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #fff;
  border-color: #2f6a3d;
  width: 100%;
  margin-top: 0.25rem;
}
.btn-secondary {
  background: #2a3328;
  color: var(--text);
  flex: 1;
}
.mic-panel-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.mic-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  user-select: none;
}
.mic-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.mic-toggle__ui {
  width: 2.75rem;
  height: 1.55rem;
  border-radius: 999px;
  background: #2a3328;
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.mic-toggle__ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.55rem - 6px);
  height: calc(1.55rem - 6px);
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.mic-toggle input:focus-visible + .mic-toggle__ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.mic-toggle input:checked + .mic-toggle__ui {
  background: #1e3024;
  border-color: var(--accent-dim);
}
.mic-toggle input:checked + .mic-toggle__ui::after {
  transform: translateX(1.15rem);
  background: var(--accent);
}
.mic-panel-controls #btn-mic-permission {
  width: 100%;
  flex: none;
}
.progress-wrap {
  height: 8px;
  background: #121812;
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}
.tally-section { margin-top: 1.5rem; }
.tally-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.tally-title { margin: 0; font-size: 1rem; }
.tally-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}
.tally-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 22rem;
  overflow-y: auto;
}
.tally-list--server {
  max-height: none;
  margin-top: 0.75rem;
}
.tally-page { max-width: 32rem; margin: 0 auto; padding: 0 1rem 3rem; }
.tally-page .index-doc-link { text-align: center; }
.tally-page__intro { margin: 0.5rem 0 0; }
.tally-page__status {
  min-height: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
.tally-page__status--err { color: #c97a6a; }
.tally-page__more { margin-top: 0.75rem; }
.tally-page__more .btn-secondary { width: 100%; max-width: 16rem; }
.server-obs-row { list-style: none; }
.tally-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
}
.tally-row:last-child { border-bottom: none; }
.tally-row__name { color: var(--text); word-break: break-word; }
.tally-row__meta { color: var(--muted); font-size: 0.68rem; }

/* BirdNET observation row: micro-card + meta bar */
.obs-row {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.6rem;
  font-size: 0.72rem;
}
.obs-row:last-child { border-bottom: none; }
.obs-row__card { margin-bottom: 0.45rem; }
.micro-card {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  min-width: 0;
}
.micro-card__thumb-wrap {
  flex-shrink: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 6px;
  overflow: hidden;
  background: #121812;
  border: 1px solid var(--border);
}
.micro-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.micro-card__thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.65rem;
}
.micro-card__thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.6rem;
}
.micro-card__body { flex: 1; min-width: 0; }
.micro-card__names {
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
  font-size: 0.72rem;
}
.micro-card__facts {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.35;
}
.micro-card__fact { display: block; }
.micro-card__k {
  color: #7a8a7c;
  font-weight: 600;
  margin-right: 0.2rem;
}
.obs-row__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  color: var(--muted);
  font-size: 0.65rem;
}
.obs-row__time { color: var(--text); font-variant-numeric: tabular-nums; }
.obs-row__wave-wrap {
  flex: 1 1 5.5rem;
  min-width: 4.5rem;
  max-width: 10rem;
  height: 1.65rem;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0e0a;
  align-self: center;
}
.obs-row__wave {
  display: block;
  width: 100%;
  height: 100%;
  vertical-align: top;
}
.obs-row__play {
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #1e281f;
  color: var(--accent);
  cursor: pointer;
}
.obs-row__upload {
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #1e281f;
  color: var(--text);
  cursor: pointer;
}
.obs-row__upload:disabled { opacity: 0.45; cursor: not-allowed; }
.obs-row__play:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.obs-row__play.is-playing { color: var(--text); }
.obs-row__conf { font-variant-numeric: tabular-nums; }
.obs-row__db { font-variant-numeric: tabular-nums; }
.obs-row__tally {
  margin-left: auto;
  color: var(--accent);
  font-weight: 600;
}
.bird-card-host { margin-top: 1rem; }
.bird-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  font-size: 0.78rem;
}
.bird-card__title {
  font-weight: 700;
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  line-height: 1.35;
}
.bird-card__img-wrap {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: #121812;
  min-height: 4rem;
}
.bird-card__img-meta {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  z-index: 1;
}
.bird-card__img-wrap--empty { min-height: 3rem; display: flex; align-items: center; justify-content: center; }
.bird-card__img-wrap img { width: 100%; height: auto; display: block; }
.bird-card__img-fallback { color: var(--muted); font-size: 0.75rem; padding: 0.5rem; text-align: center; }
.bird-card__dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
  font-size: 0.72rem;
}
.bird-card__dl dt { color: var(--muted); margin: 0; }
.bird-card__dl dd { margin: 0; }
.bird-card__dd-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.bird-card__value { flex: 1; min-width: 0; }
.bird-card__dd--stack { grid-column: 2; }
.bird-card__fact { margin-bottom: 0.45rem; }
.bird-card__fact:last-child { margin-bottom: 0; }
.bird-card__fact-body { margin: 0.2rem 0 0; line-height: 1.4; white-space: pre-wrap; }
.bird-card__wiki-note {
  margin: 0.45rem 0 0;
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.35;
}
.fact-src {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.28rem;
  border-radius: 3px;
  background: #243028;
  color: #9bc4a6;
  border: 1px solid var(--border);
  cursor: help;
  line-height: 1.2;
}
.fact-src--unknown { color: var(--muted); }
.bird-card__sources {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.45;
}
.bird-card__sources-title {
  margin: 0 0 0.25rem;
  font-weight: 600;
  color: var(--text);
  font-size: 0.68rem;
}
.bird-card__sources-body { display: block; }
.bird-card__sources-body span { display: inline; margin-right: 0.5rem; }
.bird-card__season { margin-top: 0.5rem; }
.bird-card__season-note { margin: 0.35rem 0 0; font-size: 0.72rem; color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.toast-host { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); max-width: min(90vw, 22rem); z-index: 100; }
.toast {
  background: #252e26;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
