/* ════════════════════════════════════════════════════════════════════
   Catbird — Still Habitat PWA app styles.

   Layered ON TOP of the shared design kit (/vendor/catbird-kit/catbird-kit.css,
   loaded BEFORE this file in catbird.html). We do NOT redefine the kit's
   --cb-* tokens; we reference them via var(--cb-…). The :root block below is
   a FALLBACK only — if the kit somehow isn't loaded, these warm-linen /
   sage / clay / forest values keep the app legible. The kit's own :root wins
   on cascade order when present (same specificity, kit loads first… so we
   guard each fallback with the kit value via var(--cb-x, fallback) at use
   sites where it matters, and keep these here as a safety net).

   Fonts: Spectral serif comes from the kit's already-loaded /vendor/fonts.
   This file references NO external/CDN URLs. CDN-free is mandatory.

   Class inventory (everything app.js / map.js / catbird.html emit):
     shell    .cb-status-bar .cb-header .cb-brand .cb-app-name .cb-main
              .cb-pane .cb-nav .nav-btn #toast/.toast .cb-map-container
              .cb-gps-indicator .cb-pending-badge .cb-stale-bar
     content  .cb-card .cb-heading .cb-subheading .cb-body .cb-muted .cb-pad
              .cb-input .cb-btn .cb-btn-primary .cb-spinner .cb-label
              .cb-stat-hero .cb-bucket-list/row/label/count
              .cb-det-row/species/ear/day
              .cb-log-list/row/tier/species/ear/day
     record   .cb-taxon-row/btn .cb-rec-center .cb-mic-btn .cb-rec-timer
              .cb-id-result .cb-canopy-status .cb-id-guess
              .cb-live-toggle #live-panel .cb-spec-canvas
              .cb-live-list/row/dim/species/pct/tag
     fleet    .cb-fleet-summary/row/ear/status/quiet/active/count
     suggest  .cb-suggest-row/title/reason/badge
     guest    .cb-gb-list/row/head/name/day/species/note  body.cb-guest
     onboard  .cb-onboard-gps .cb-onboard-status .cb-checklist
     toast    .toast-info/ok/warn/error
     markers  .cb-map-marker .cb-ear-marker .cb-suggest-marker
   ════════════════════════════════════════════════════════════════════ */

/* ── Fallback tokens (kit's :root wins when loaded) ──────────────────── */
:root {
  --cb-bg:        #F5F2EE;
  --cb-panel:     #EDE8E1;
  --cb-panel-2:   #E2DAD0;
  --cb-fg:        #211E18;
  --cb-muted:     #6B6358;
  --cb-accent:    #3E6B57;
  --cb-accent-2:  #9E5A3E;
  --cb-danger:    #A6463A;
  --cb-warn:      #9E5A3E;
  --cb-border:    rgba(33, 30, 24, 0.14);
  --cb-sage:      #C4BEAF;
  --cb-hover:     rgba(33, 30, 24, 0.05);
  --cb-tier-rare:    #9E5A3E;
  --cb-tier-notable: #6B8E6E;
  --cb-tier-common:  #C4BEAF;
  --cb-status-online:  #3E6B57;
  --cb-status-stale:   #9E5A3E;
  --cb-status-offline: #6B6358;
  --cb-hf:   'Spectral', Georgia, 'Times New Roman', serif;
  --cb-bf:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --cb-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --cb-shadow:      0 1px 1px rgba(33,30,24,0.05), 0 2px 4px rgba(33,30,24,0.07);
  --cb-shadow-card: 0 2px 12px rgba(33,30,24,0.09);
  --cb-radius:    12px;
  --cb-radius-sm: 8px;

  /* App-local layout rhythm (NOT kit tokens — safe to define) */
  --sh-header-h: 52px;
  --sh-status-h: 26px;
  --sh-nav-h:    58px;
  --sh-safe-top:    env(safe-area-inset-top, 0px);
  --sh-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset / base ────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--cb-bg);
  color: var(--cb-fg);
  font-family: var(--cb-bf);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Lock the document; only .cb-main scrolls. Prevents the fixed nav from
     drifting and stops iOS rubber-banding over the chrome. */
  overflow: hidden;
  overscroll-behavior: none;
}

/* THE FOOTGUN (requirement 1): a bare `.cb-pane { display: … }` rule would
   override the [hidden] attribute. We never give .cb-pane a display rule, and
   we add this global belt-and-suspenders guard so ANY [hidden] element (panes,
   nav buttons, badges, timers, previews) is truly removed from layout. */
[hidden] { display: none !important; }

/* ════════════════════════════════════════════════════════════════════
   SHELL — fixed status bar + header on top, fixed nav at bottom,
   scrollable .cb-main between them.
   ════════════════════════════════════════════════════════════════════ */

/* Stale-data banner — thin amber ribbon pinned to the very top, above the
   status bar. Shown via [hidden] toggle from app.js when reading a cache. */
.cb-stale-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  padding: calc(4px + var(--sh-safe-top)) 12px 4px;
  background: var(--cb-accent-2);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
}
/* When a stale-bar is rendered INSIDE a pane (renderPlace/renderLog inline it
   as a non-fixed block), keep it a normal in-flow chip, not a fixed banner. */
.cb-pane .cb-stale-bar {
  position: static;
  padding: 6px 10px;
  margin-bottom: 0.75rem;
  border-radius: var(--cb-radius-sm);
  text-align: left;
}

/* Status bar — GPS indicator + pending badge. Sits under the notch. */
.cb-status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: calc(var(--sh-status-h) + var(--sh-safe-top));
  padding: var(--sh-safe-top) 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--cb-panel);
  border-bottom: 1px solid var(--cb-border);
  font-size: 0.7rem;
}

.cb-gps-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--cb-muted);
  font-family: var(--cb-mono);
  letter-spacing: 0.02em;
}
.cb-gps-indicator::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-status-offline);
}
/* A live fix turns the dot forest-green (heuristic: text starts with "GPS"). */
.cb-gps-indicator:not(:empty)::before { background: var(--cb-status-online); }

.cb-pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--cb-accent-2);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* App header — brand lockup. Pinned just below the status bar. */
.cb-header {
  position: fixed;
  top: calc(var(--sh-status-h) + var(--sh-safe-top));
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--sh-header-h);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 16px;
  background: var(--cb-bg);
  border-bottom: 1px solid var(--cb-border);
  /* family signature sage→clay→forest hairline under the header */
  box-shadow: 0 2px 0 -1px transparent;
  /* clip the decorative bird layer to the header bar */
  overflow: hidden;
}

/* Flying-bird silhouettes — drift behind the header text at half opacity.
   Pure CSS; ported from Maggii field.html. Pointer-transparent. */
#bird-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;          /* behind .cb-brand / .cb-app-name (raised below) */
  opacity: 0.5;        /* half opacity behind the header text */
  overflow: hidden;
}
#bird-layer .bird {
  position: absolute; opacity: 0;
  animation: bird-fly linear infinite;
}
@keyframes bird-fly {
  0%   { transform: translateX(-40px); opacity: 0; }
  4%   { opacity: 0.55; }
  92%  { opacity: 0.4; }
  100% { transform: translateX(calc(100vw + 40px)); opacity: 0; }
}
/* Honour reduced-motion: hold the birds still and out of sight. */
@media (prefers-reduced-motion: reduce) {
  #bird-layer .bird { animation: none; opacity: 0; }
}
/* Keep the brand lockup above the bird layer. */
.cb-header > .cb-brand,
.cb-header > .cb-app-name { position: relative; z-index: 1; }
.cb-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg,
    var(--cb-sage), var(--cb-accent-2), var(--cb-accent));
  opacity: 0.55;
}
.cb-brand {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cb-accent);
  font-style: italic;
}
.cb-app-name {
  font-family: var(--cb-hf);
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--cb-fg);
  letter-spacing: 0.01em;
}

/* Scrollable content region — the only thing that scrolls. */
.cb-main {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--sh-status-h) + var(--sh-safe-top) + var(--sh-header-h));
  bottom: calc(var(--sh-nav-h) + var(--sh-safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 14px 20px;
}

/* Field-notebook pattern — a muted forest-green duotone owl, tiled behind the
   whole app as a quiet vintage-endpaper motif. The colour is pre-baked into the
   tile (already a soft sage duotone), so no filter is applied here. Fixed and
   low opacity, sitting behind the solid card backgrounds; it reads through the
   gutters and the empty/loading state. Pure CSS — no render-path code, so it can
   never blank the app. Owl: BHL, Edinburgh Jrnl of Nat. Hist. 1835–40. */
body::before {
  content: "";
  position: fixed;
  left: 0; right: 0;
  top: calc(var(--sh-status-h) + var(--sh-safe-top) + var(--sh-header-h));
  bottom: calc(var(--sh-nav-h) + var(--sh-safe-bottom));
  z-index: 0;
  pointer-events: none;
  background: url(/vendor/plates/owl-motif.jpg) left top / 128px auto repeat;
  opacity: 0.22;
}
/* Keep app content above the pattern. */
.cb-main { z-index: 1; }
@media (prefers-color-scheme: dark) { body::before { opacity: 0.16; } }

/* Panes stack their cards. NOTE: deliberately NO `display` here so [hidden]
   wins (see footgun note above). We only set spacing via children. */
.cb-pane > * + * { margin-top: 14px; }

/* The map pane needs to fill its area, so it gets flow layout when visible. */
.cb-pane[data-pane="map"]:not([hidden]) {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cb-map-container {
  flex: 1;
  min-height: 60vh;
  width: 100%;
  border-radius: var(--cb-radius);
  overflow: hidden;
  border: 1px solid var(--cb-border);
  box-shadow: var(--cb-shadow);
  background: var(--cb-panel-2);
}

/* ── Bottom navigation ───────────────────────────────────────────────── */
.cb-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--sh-nav-h) + var(--sh-safe-bottom));
  padding-bottom: var(--sh-safe-bottom);
  display: flex;
  align-items: stretch;
  background: var(--cb-panel);
  border-top: 1px solid var(--cb-border);
  box-shadow: 0 -2px 12px rgba(33, 30, 24, 0.08);
}

.nav-btn {
  flex: 1 1 0;        /* equal share; hidden ones are removed via [hidden] */
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--cb-muted);
  font-family: var(--cb-bf);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.18s ease;
}
.nav-btn svg {
  width: 22px;
  height: 22px;
  opacity: 0.78;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.nav-btn span {
  line-height: 1;
}
.nav-btn:active svg { transform: scale(0.9); }

.nav-btn.active {
  color: var(--cb-accent);
}
.nav-btn.active svg {
  opacity: 1;
  transform: translateY(-1px);
}
/* Active accent tick above the icon. */
.nav-btn.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 26px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--cb-accent);
}
.nav-btn { position: relative; }

/* Field Sync nav badge — the pending-upload count on the tab itself (the app's #1
   nag: "you still have detections to send"). Fulcrum rule: show the number up to 9,
   then a bare dot for 10+ (.cb-nav-badge-dot), so it stays legible in sun/gloves. */
.cb-nav-badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 8px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--cb-accent-2);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.cb-nav-badge-dot {
  min-width: 9px;
  width: 9px;
  height: 9px;
  padding: 0;
}

/* ════════════════════════════════════════════════════════════════════
   CARDS + TYPOGRAPHY — parchment surface, Spectral letterpress headings.
   ════════════════════════════════════════════════════════════════════ */
.cb-card {
  background: var(--cb-panel);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--cb-shadow-card);
}

.cb-heading {
  margin: 0 0 0.5rem;
  font-family: var(--cb-hf);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.12;
  color: var(--cb-fg);
  letter-spacing: 0.005em;
  /* subtle letterpress: a faint light edge above, soft dark below */
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.cb-subheading {
  margin: 0 0 0.5rem;
  font-family: var(--cb-hf);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--cb-fg);
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.cb-body {
  margin: 0 0 0.7rem;
  color: var(--cb-fg);
  font-size: 0.94rem;
  line-height: 1.5;
}
.cb-muted {
  color: var(--cb-muted);
  font-size: 0.88rem;
}
/* Status-line color modifiers (e.g. the field clock-sync result). */
.cb-muted.cb-ok   { color: var(--cb-accent); }
.cb-muted.cb-warn { color: var(--cb-warn); }
.cb-pad { padding: 1rem; }

/* Small "ready/online" dot — leads a status line (account "Signed in as…",
   the Offline-ID "Ready for offline" line). Forest-green, gently glowing. */
.cb-signed-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--cb-accent);
  box-shadow: 0 0 6px var(--cb-accent);
  vertical-align: middle;
}

/* Hero stat — big mono number, the "X total" on Place/Now. */
.cb-stat-hero {
  font-family: var(--cb-hf);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--cb-accent);
  line-height: 1;
  margin: 0.1rem 0 0.8rem;
  letter-spacing: 0.01em;
}

/* ── Forms ───────────────────────────────────────────────────────────── */
.cb-input,
textarea.cb-input {
  display: block;
  width: 100%;
  margin: 0.4rem 0;
  padding: 0.7rem 0.8rem;
  min-height: 44px;                 /* comfortable tap target */
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius-sm);
  background: var(--cb-bg);
  color: var(--cb-fg);
  font-family: var(--cb-bf);
  font-size: 1rem;
  line-height: 1.35;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
textarea.cb-input {
  min-height: 72px;
  resize: vertical;
}
.cb-input:focus,
textarea.cb-input:focus {
  outline: none;
  border-color: var(--cb-accent);
  box-shadow: 0 0 0 3px rgba(62, 107, 87, 0.16);
}
.cb-input::placeholder { color: var(--cb-muted); opacity: 0.8; }

.cb-label {
  display: block;
  margin: 0.65rem 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--cb-muted);
}
.cb-label .cb-input { margin-top: 0.3rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.cb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin: 0.4rem 0;
  padding: 0.7rem 1rem;
  min-height: 44px;
  border: 1px solid var(--cb-accent);
  border-radius: var(--cb-radius-sm);
  background: transparent;
  color: var(--cb-accent);
  font-family: var(--cb-bf);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
}
.cb-btn:active { transform: translateY(1px); }
.cb-btn:hover { background: var(--cb-hover); }
.cb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.cb-btn-primary {
  background: var(--cb-accent);
  border-color: var(--cb-accent);
  color: #fff;
  box-shadow: var(--cb-shadow);
}
.cb-btn-primary:hover { background: #355d4b; }
.cb-btn-primary:disabled { background: var(--cb-accent); }

/* Field-grade primary: taller target for cold/gloved hands in the field (toward
   NN/g ~2cm). WCAG 2.5.8 (AA) floor is 24px and the base .cb-btn already clears
   that at 44px; this pushes the FIELD primaries (Collect / Upload) to ~58px. */
.cb-btn-field {
  min-height: 58px;
  font-size: 1.02rem;
}

/* ── Spinner ─────────────────────────────────────────────────────────── */
.cb-spinner {
  width: 34px;
  height: 34px;
  margin: 2.5rem auto;
  border: 3px solid var(--cb-border);
  border-top-color: var(--cb-accent);
  border-radius: 50%;
  animation: cb-spin 0.85s linear infinite;
}
@keyframes cb-spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════════════
   BUCKET LIST (species counts) + DETECTION ROWS (Place/Now)
   ════════════════════════════════════════════════════════════════════ */
.cb-bucket-list { margin: 0.3rem 0 0.2rem; }
.cb-bucket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--cb-border);
}
.cb-bucket-row:last-child { border-bottom: none; }
.cb-bucket-label {
  flex: 1;
  min-width: 0;
  color: var(--cb-fg);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-bucket-count {
  flex: 0 0 auto;
  font-family: var(--cb-mono);
  font-weight: 700;
  color: var(--cb-accent);
  font-variant-numeric: tabular-nums;
}

.cb-det-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--cb-border);
}
.cb-det-row:last-child { border-bottom: none; }
.cb-det-species {
  flex: 1;
  min-width: 0;
  font-family: var(--cb-hf);
  font-size: 1rem;
  font-weight: 600;
  color: var(--cb-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-det-ear {
  flex: 0 0 auto;
  font-size: 0.74rem;
  color: var(--cb-accent);
  font-weight: 600;
}
.cb-det-day {
  flex: 0 0 auto;
  font-family: var(--cb-mono);
  font-size: 0.72rem;
  color: var(--cb-muted);
  white-space: nowrap;
  /* tappable: title shows the absolute local time */
  cursor: help;
  text-decoration: underline dotted var(--cb-border);
  text-underline-offset: 2px;
}

/* ── Log tab rows ────────────────────────────────────────────────────── */
.cb-log-list {
  background: var(--cb-panel);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  overflow: hidden;
  box-shadow: var(--cb-shadow);
}
.cb-log-row {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--cb-border);
}
.cb-log-row:last-child { border-bottom: none; }
/* confidence glyph — ✓ confirmed / ~ likely / ? maybe, mapped to tier hues */
.cb-log-tier {
  flex: 0 0 auto;
  width: 1.3rem;
  text-align: center;
  font-weight: 700;
  color: var(--cb-status-offline);
}
.cb-log-tier[title="confirmed"] { color: var(--cb-status-online); }
.cb-log-tier[title="likely"]    { color: var(--cb-status-stale); }
.cb-log-tier[title="maybe"]     { color: var(--cb-muted); }
.cb-log-species {
  flex: 1;
  min-width: 0;
  font-family: var(--cb-hf);
  font-weight: 600;
  color: var(--cb-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-log-ear {
  flex: 0 0 auto;
  font-size: 0.74rem;
  color: var(--cb-accent);
  font-weight: 600;
}
.cb-log-day {
  flex: 0 0 auto;
  font-family: var(--cb-mono);
  font-size: 0.72rem;
  color: var(--cb-muted);
  white-space: nowrap;
  /* tappable: title shows the absolute local time */
  cursor: help;
  text-decoration: underline dotted var(--cb-border);
  text-underline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════════════
   RECORD TAB — taxon segmented row, big mic button, timer, ID result.
   ════════════════════════════════════════════════════════════════════ */
.cb-taxon-row {
  display: flex;
  gap: 0;
  margin: 0.6rem 0 1rem;
  border: 1px solid var(--cb-border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--cb-bg);
}
.cb-taxon-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.55rem 0.4rem;
  border: 0;
  border-right: 1px solid var(--cb-border);
  background: transparent;
  color: var(--cb-muted);
  font-family: var(--cb-bf);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: capitalize;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s ease, color 0.16s ease;
}
.cb-taxon-btn:last-child { border-right: 0; }
.cb-taxon-btn.active {
  background: var(--cb-accent);
  color: #fff;
}

/* Live spectrogram waterfall on the Record tab. The widget paints onto the
   canvas; the dark surface matches the widget's own #131822 background so the
   idle state and live frames read as one panel. */
.cb-rec-canvas-wrap {
  position: relative;
  margin-top: 0.9rem;
  border-radius: var(--cb-radius-sm);
  overflow: hidden;
  background: #131822;
  border: 1px solid var(--cb-border);
  line-height: 0;
}
#rec-canvas {
  display: block;
  width: 100%;
  height: 150px;
}
.cb-rec-canvas-idle {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.38);
  font-size: 0.88rem;
  line-height: 1.2;
  pointer-events: none;
}
.cb-rec-canvas-idle[hidden] { display: none; }

.cb-rec-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 1.2rem 0 0.6rem;
}

.cb-mic-btn {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 0;
  background: var(--cb-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 16px rgba(62, 107, 87, 0.35);
  transition: transform 0.12s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.cb-mic-btn:active { transform: scale(0.94); }
.cb-mic-btn svg { width: 38px; height: 38px; }

/* Recording state — clay-red + a sonar pulse ring that breathes outward. */
.cb-mic-btn.recording {
  background: var(--cb-danger);
  box-shadow: 0 4px 18px rgba(166, 70, 58, 0.45);
}
.cb-mic-btn.recording::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--cb-danger);
  animation: cb-mic-pulse 1.5s ease-out infinite;
  pointer-events: none;
}
@keyframes cb-mic-pulse {
  0%   { transform: scale(1);    opacity: 0.7; }
  100% { transform: scale(1.7);  opacity: 0; }
}

.cb-rec-timer {
  font-family: var(--cb-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cb-danger);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.cb-id-result {
  margin: 0.7rem 0;
  padding: 0.7rem 0.85rem;
  min-height: 1.5rem;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-panel-2);
  border-left: 4px solid var(--cb-accent);
  color: var(--cb-fg);
  font-size: 0.95rem;
}
.cb-id-result:empty {
  display: none;
}
.cb-id-result strong {
  font-family: var(--cb-hf);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--cb-accent);
}

/* On-device ID engine status line. */
.cb-canopy-status {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--cb-border);
  font-size: 0.78rem;
  color: var(--cb-muted);
}
.cb-canopy-status #canopy-state {
  font-family: var(--cb-mono);
  color: var(--cb-accent);
  font-weight: 600;
}
/* Phase C debug line (?debug=1): build-time adaptive metadata + live cell. */
.cb-canopy-debug {
  margin-top: 0.4rem;
  font-family: var(--cb-mono);
  font-size: 0.72rem;
  color: var(--cb-muted);
  word-break: break-all;
}

/* ── Phase 2: live "rolling" listen mode ─────────────────────────────────────── */
.cb-live-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.2rem;
  font-size: 0.85rem;
  color: var(--cb-muted);
  cursor: pointer;
}
.cb-live-toggle input { accent-color: var(--cb-accent); }

#live-panel {
  margin: 0.7rem 0;
}
.cb-spec-canvas {
  width: 100%;
  height: 120px;
  display: block;
  border-radius: var(--cb-radius-sm);
  background: #131822;
  border: 1px solid var(--cb-border);
}
.cb-live-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.cb-live-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-panel-2);
  border-left: 4px solid var(--cb-accent);
}
.cb-live-row.cb-live-dim {
  opacity: 0.6;
  border-left-color: var(--cb-muted);
}
.cb-live-species {
  flex: 1;
  font-family: var(--cb-hf);
  font-weight: 600;
  color: var(--cb-fg);
}
.cb-live-pct {
  font-family: var(--cb-mono);
  color: var(--cb-accent);
  font-weight: 600;
}
.cb-live-dim .cb-live-pct { color: var(--cb-muted); }
.cb-live-tag {
  font-size: 0.72rem;
  color: var(--cb-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* recorded-clip preview audio element */
#clip-preview audio {
  width: 100%;
  margin: 0.6rem 0;
}

/* ════════════════════════════════════════════════════════════════════
   FLEET HEALTH — summary line + per-ear rows with a status pill.
   ════════════════════════════════════════════════════════════════════ */
.cb-fleet-summary {
  margin: 0.2rem 0 0.6rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--cb-muted);
  letter-spacing: 0.01em;
}
.cb-fleet-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--cb-border);
}
.cb-fleet-row:last-child { border-bottom: none; }
.cb-fleet-ear {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--cb-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-fleet-ear-stack {
  flex: 1 1 11rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.cb-fleet-ear-stack .cb-fleet-ear { display: block; }
.cb-fleet-strategy {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.72rem;
  color: var(--cb-muted);
}
.cb-fleet-strategy > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-fleet-strategy-summary {
  margin: -0.2rem 0 0.45rem;
  padding: 0.45rem 0.6rem;
  border-left: 3px solid var(--cb-accent);
  background: var(--cb-panel-2);
  color: var(--cb-text);
  font-size: 0.8rem;
  line-height: 1.35;
}
.cb-strategy-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 1.35rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}
.cb-strategy-static { color: var(--cb-status-online); background: rgba(62, 107, 87, 0.12); }
.cb-strategy-shadow { color: #675a22; background: rgba(194, 158, 45, 0.17); }
.cb-strategy-stale { color: var(--cb-status-stale); background: rgba(158, 90, 62, 0.12); }
.cb-strategy-unknown { color: var(--cb-muted); background: var(--cb-panel-2); }
.cb-fleet-status {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.cb-fleet-active {
  background: rgba(62, 107, 87, 0.14);
  color: var(--cb-status-online);
}
.cb-fleet-quiet {
  background: rgba(158, 90, 62, 0.14);
  color: var(--cb-status-stale);
}
.cb-fleet-count {
  flex: 0 0 auto;
  min-width: 1.8rem;
  text-align: right;
  font-family: var(--cb-mono);
  font-weight: 700;
  color: var(--cb-accent);
  font-variant-numeric: tabular-nums;
}
/* The word "detections" next to the count — turns a bare number into a label. */
.cb-fleet-count-label {
  flex: 0 0 auto;
  font-size: 0.74rem;
  color: var(--cb-muted);
  margin-left: -0.3rem;
}

/* ── Clickable fleet rows + inline ear-detail accordion ─────────────────── */
.cb-fleet-clickable { cursor: pointer; }
.cb-fleet-clickable:hover { background: rgba(33, 30, 24, 0.03); }
.cb-fleet-clickable:focus-visible { outline: 2px solid var(--cb-accent); outline-offset: -2px; }
.cb-fleet-caret {
  flex: 0 0 auto;
  color: var(--cb-muted);
  font-size: 0.8rem;
  transition: transform 0.15s ease;
}
.cb-fleet-row.open .cb-fleet-caret { transform: rotate(90deg); }

.cb-ear-detail {
  padding: 0.4rem 0 0.7rem 1.2rem;
  border-bottom: 1px solid var(--cb-border);
}
.cb-fleet-item:last-child .cb-ear-detail { border-bottom: none; }
.cb-spinner-sm { width: 20px; height: 20px; border-width: 2px; margin: 0.6rem auto; }

.cb-ear-detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.2rem 0 0.5rem;
}
.cb-ear-detail-total { font-weight: 700; color: var(--cb-fg); font-size: 0.9rem; }
.cb-ear-detail-seen { font-size: 0.78rem; color: var(--cb-muted); }
.cb-ear-detail-note { font-size: 0.85rem; margin: 0.4rem 0 0; }

.cb-ear-rename {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.cb-ear-rename-input { flex: 1; min-width: 0; }

.cb-ear-taxon { margin-bottom: 0.5rem; }
.cb-ear-taxon-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.cb-ear-taxon-name { font-weight: 600; color: var(--cb-fg); font-size: 0.92rem; }
.cb-ear-taxon-counts { font-family: var(--cb-mono); font-size: 0.76rem; color: var(--cb-muted); }
.cb-ear-species-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0 0.2rem 0.9rem;
}
.cb-ear-species-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  color: var(--cb-fg);
}
.cb-ear-species-count {
  flex: 0 0 auto;
  font-family: var(--cb-mono);
  font-weight: 700;
  color: var(--cb-accent);
  font-variant-numeric: tabular-nums;
}

/* ── Owner-only listening strategy ──────────────────────────────────────── */
.cb-listening-card {
  margin: 0.75rem 0 0.9rem;
  padding: 0.8rem;
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius-sm);
  background: var(--cb-panel);
  background: color-mix(in srgb, var(--cb-panel) 88%, var(--cb-accent) 12%);
}
.cb-listening-warning { border-color: var(--cb-status-stale); }
.cb-listening-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.cb-listening-heading .cb-subheading { margin-bottom: 0.05rem; }
.cb-strategy-kicker { margin: 0; color: var(--cb-muted); font-size: 0.77rem; }
.cb-strategy-stale-note {
  margin-bottom: 0.55rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--cb-radius-sm);
  background: rgba(158, 90, 62, 0.12);
  color: var(--cb-status-stale);
  font-size: 0.78rem;
  font-weight: 600;
}
.cb-strategy-active,
.cb-strategy-proposal {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0;
}
.cb-strategy-active > div,
.cb-strategy-proposal { flex-direction: column; }
.cb-strategy-active strong,
.cb-strategy-proposal strong { color: var(--cb-fg); font-size: 0.9rem; }
.cb-strategy-active span,
.cb-strategy-proposal span { color: var(--cb-muted); font-size: 0.78rem; }
.cb-strategy-dot {
  flex: 0 0 0.65rem;
  width: 0.65rem;
  height: 0.65rem;
  margin-top: 0.25rem;
  border-radius: 50%;
  background: var(--cb-status-online);
  box-shadow: 0 0 0 3px rgba(62, 107, 87, 0.12);
}
.cb-strategy-proposal {
  border-top: 1px dashed var(--cb-border);
  border-bottom: 1px dashed var(--cb-border);
}
.cb-strategy-proposal-empty { opacity: 0.86; }
.cb-strategy-safety,
.cb-strategy-controls-note {
  margin: 0.55rem 0;
  color: var(--cb-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}
.cb-strategy-label {
  margin: 0.8rem 0 0.35rem;
  color: var(--cb-fg);
  font-size: 0.85rem;
  font-weight: 700;
}
.cb-strategy-reasons,
.cb-strategy-history ol,
.cb-strategy-history li ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.cb-strategy-reasons > li,
.cb-strategy-history li ul > li {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.3rem 0;
  color: var(--cb-text);
  font-size: 0.8rem;
  line-height: 1.35;
}
.cb-strategy-reason-tag {
  flex: 0 0 auto;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--cb-panel-2);
  color: var(--cb-muted);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.cb-strategy-context {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.7rem;
}
.cb-strategy-context > div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-panel-2);
}
.cb-strategy-context span { color: var(--cb-muted); font-size: 0.68rem; }
.cb-strategy-context strong { color: var(--cb-fg); font-size: 0.78rem; }
.cb-strategy-advanced { margin-top: 0.75rem; }
.cb-strategy-advanced summary {
  cursor: pointer;
  color: var(--cb-accent);
  font-size: 0.78rem;
  font-weight: 700;
}
.cb-strategy-advanced summary:focus-visible { outline: 2px solid var(--cb-accent); outline-offset: 3px; }
.cb-strategy-advanced dl { margin: 0.5rem 0 0; }
.cb-strategy-advanced dl > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.2rem 0;
  border-bottom: 1px dotted var(--cb-border);
  font-size: 0.76rem;
}
.cb-strategy-advanced dt { color: var(--cb-muted); }
.cb-strategy-advanced dd { margin: 0; color: var(--cb-fg); font-family: var(--cb-mono); }
.cb-strategy-history { margin-top: 0.85rem; padding-top: 0.2rem; border-top: 1px solid var(--cb-border); }
.cb-strategy-history-note { margin: 0 0 0.55rem; font-size: 0.72rem; line-height: 1.35; }
.cb-strategy-history > ol > li { padding: 0.55rem 0; border-bottom: 1px dotted var(--cb-border); }
.cb-strategy-event-head { display: flex; justify-content: space-between; gap: 0.6rem; }
.cb-strategy-event-head strong { color: var(--cb-fg); font-size: 0.8rem; }
.cb-strategy-event-head > span { color: var(--cb-muted); font-family: var(--cb-mono); font-size: 0.68rem; }
.cb-strategy-more { margin-top: 0.6rem; }

@media (max-width: 640px) {
  .cb-fleet-row { flex-wrap: wrap; gap: 0.4rem 0.55rem; }
  .cb-fleet-ear-stack { flex-basis: calc(100% - 1.5rem); }
  .cb-fleet-clickable .cb-fleet-status { margin-left: 1.45rem; }
  .cb-fleet-locate { margin-left: auto; }
  .cb-listening-card { margin-left: -0.55rem; padding: 0.7rem; }
  .cb-listening-heading { align-items: center; }
  .cb-strategy-context { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .cb-fleet-caret { transition: none; }
}

/* ════════════════════════════════════════════════════════════════════
   PLACEMENT SUGGESTIONS — advisory rows with a reason + optional badge.
   ════════════════════════════════════════════════════════════════════ */
.cb-suggest-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--cb-border);
}
.cb-suggest-row:last-child { border-bottom: none; }
.cb-suggest-title {
  flex: 1 1 100%;
  font-family: var(--cb-hf);
  font-size: 1rem;
  font-weight: 600;
  color: var(--cb-fg);
}
.cb-suggest-reason {
  flex: 1 1 auto;
  font-size: 0.82rem;
  color: var(--cb-muted);
  line-height: 1.4;
}
.cb-suggest-badge {
  flex: 0 0 auto;
  align-self: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--cb-accent-2);
  background: rgba(158, 90, 62, 0.08);
  color: var(--cb-accent-2);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════════
   GUESTBOOK — entry cards: name/day header, optional species, note body.
   ════════════════════════════════════════════════════════════════════ */
.cb-gb-list > * + * { margin-top: 12px; }
.cb-gb-row {
  background: var(--cb-panel);
  border: 1px solid var(--cb-border);
  border-left: 4px solid var(--cb-sage);
  border-radius: var(--cb-radius-sm);
  padding: 0.75rem 0.9rem;
  box-shadow: var(--cb-shadow);
}
.cb-gb-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.cb-gb-name {
  font-family: var(--cb-hf);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--cb-fg);
}
.cb-gb-day {
  flex: 0 0 auto;
  font-family: var(--cb-mono);
  font-size: 0.72rem;
  color: var(--cb-muted);
}
.cb-gb-species {
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--cb-accent);
  letter-spacing: 0.01em;
}
.cb-gb-note {
  color: var(--cb-fg);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ════════════════════════════════════════════════════════════════════
   ONBOARDING — add-ear flow: GPS readout, status line, "you're live" list.
   ════════════════════════════════════════════════════════════════════ */
.cb-onboard-gps,
.cb-onboard-status {
  margin: 0.6rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-panel-2);
  font-family: var(--cb-mono);
  font-size: 0.85rem;
  color: var(--cb-fg);
}
.cb-onboard-status { color: var(--cb-muted); }

.cb-checklist {
  list-style: none;
  margin: 0.4rem 0 0.9rem;
  padding: 0;
}
.cb-checklist li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--cb-border);
  font-size: 0.92rem;
  color: var(--cb-fg);
}
.cb-checklist li:last-child { border-bottom: none; }
/* A ✓-prefixed line reads as done (forest green); ○ stays muted. */
.cb-checklist li { color: var(--cb-muted); }

/* Empty-fleet two-way CTA: stack the branch buttons with a little breathing room. */
.cb-empty-cta { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.6rem; }
.cb-empty-cta .cb-body { margin: 0 0 0.2rem; }

/* ════════════════════════════════════════════════════════════════════
   TOAST — bottom-center pill, sits above the nav. Color by kind.
   ════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sh-nav-h) + var(--sh-safe-bottom) + 14px);
  transform: translateX(-50%);
  z-index: 80;
  max-width: calc(100vw - 28px);
  padding: 0.65rem 1.05rem;
  border-radius: 999px;
  background: var(--cb-fg);
  color: var(--cb-bg);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 4px 20px rgba(33, 30, 24, 0.3);
  animation: cb-toast-in 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes cb-toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast-info  { background: var(--cb-fg);     color: var(--cb-bg); }
.toast-ok    { background: var(--cb-accent); color: #fff; }
.toast-warn  { background: var(--cb-warn);   color: #fff; }
.toast-error { background: var(--cb-danger); color: #fff; }

/* ════════════════════════════════════════════════════════════════════
   UPLOAD SUCCESS CARD (Phase F) — persistent confirmation of a field
   round-trip. Top-anchored banner; stays until dismissed.
   ════════════════════════════════════════════════════════════════════ */
.cb-upload-card {
  position: fixed;
  left: 50%;
  top: calc(var(--sh-safe-top, 0px) + 12px);
  transform: translateX(-50%);
  z-index: 90;
  width: min(calc(100vw - 24px), 440px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: var(--cb-accent);
  color: #fff;
  box-shadow: 0 6px 26px rgba(33, 30, 24, 0.32);
  animation: cb-upload-in 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes cb-upload-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.cb-upload-card-body { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.cb-upload-card-check {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 800; font-size: 1rem;
}
.cb-upload-card-title { font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.cb-upload-card-sub   { font-size: 0.8rem; opacity: 0.92; line-height: 1.3; }
.cb-upload-card-x {
  flex: none;
  appearance: none; border: none; background: none; color: #fff;
  font-size: 1.5rem; line-height: 1; cursor: pointer;
  padding: 0.1rem 0.3rem; opacity: 0.85;
}
.cb-upload-card-x:active { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .cb-upload-card { animation: none; } }

/* ════════════════════════════════════════════════════════════════════
   MAP MARKERS — L.divIcon HTML, styled globally (must be top-level, not
   scoped to a pane, since Leaflet appends them to the map overlay panes).
   ════════════════════════════════════════════════════════════════════ */

/* Bio-bucket detection dot — a tier-ringed parchment disc with an ink
   silhouette inside (naturalist field-guide treatment). The ring color is
   set inline by map.js per confidence tier. */
.cb-map-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 242, 238, 0.92);  /* warm-linen fill, map peeks through */
  border: 2.5px solid var(--cb-accent);   /* overridden inline per tier */
  box-shadow: 0 1px 3px rgba(30, 20, 10, 0.28);
}
.cb-map-marker svg { width: 20px; height: 20px; display: block; }

/* Ear pin — a QUIET reference marker (2-letter ear initials). Detections are
   the focus of this map, so ears are deliberately small, muted, and low-
   contrast: a slate chip that recedes behind the colored detection clusters.
   Hover lifts it slightly so it's still discoverable/tappable to move it. */
.cb-ear-marker {
  width: 20px;
  height: 20px;
  border-radius: 50% 50% 50% 2px;   /* teardrop nod — this is a placed thing */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(96, 110, 116, 0.82);  /* cool slate, semi-transparent */
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  color: #fff;
  font-family: var(--cb-bf);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 3px rgba(30, 20, 10, 0.25);
  opacity: 0.78;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.cb-ear-marker-wrap:hover .cb-ear-marker {
  opacity: 1;
  transform: scale(1.15);
}
/* "location not set" hint in a detection popup + Fleet Health row. */
.cb-map-noloc { color: var(--cb-accent-2); font-size: 0.82em; }
.cb-fleet-noloc { font-size: 0.8em; opacity: 0.7; cursor: help; }
.cb-fleet-locate { white-space: nowrap; }

/* Suggestion marker — DELIBERATELY ghostly: dashed clay ring, hollow fill,
   a "+" glyph. Must read as advisory, NOT as a real ear (requirement 7). */
.cb-suggest-marker {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 242, 238, 0.55);
  border: 2px dashed var(--cb-accent-2);
  color: var(--cb-accent-2);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
  opacity: 0.92;
}

/* Leaflet popup — align to the kit so it isn't default-blue Leaflet chrome. */
.leaflet-popup-content {
  font-family: var(--cb-bf);
  color: var(--cb-fg);
  font-size: 0.85rem;
}
.leaflet-popup-content strong {
  font-family: var(--cb-hf);
  color: var(--cb-accent);
}

/* ════════════════════════════════════════════════════════════════════
   GUEST MODE — body.cb-guest. The nav buttons are hidden in JS via the
   [hidden] attribute (handled by the global guard); this is just for any
   guest-only tonal shift. Kept light: a faint clay top-rule on the header
   so a guest can tell at a glance they're in the visitor view.
   ════════════════════════════════════════════════════════════════════ */
body.cb-guest .cb-header::after {
  opacity: 0.75;
}
body.cb-guest .cb-brand::after {
  content: " · visitor";
  color: var(--cb-muted);
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.04em;
}

/* ── Reduced-motion: respect the OS setting ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cb-spinner,
  .cb-mic-btn.recording::after,
  .toast { animation: none; }
  .nav-btn svg, .cb-btn, .cb-mic-btn { transition: none; }
}

/* ── Move-confirm modal ─────────────────────────────────────────────────────
   Confirmation before stamping an ear's location. Shows the ear name, a mini
   map with the OLD and PROPOSED pins, and the coords/accuracy being saved. */
.cb-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;                 /* above the nav (40) and status bar (50) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(33, 30, 24, 0.5);
}
.cb-modal {
  width: 100%;
  max-width: 380px;
  background: var(--cb-panel);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow-card);
  padding: 1rem 1.05rem calc(1rem + var(--sh-safe-bottom));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.cb-modal-title {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  color: var(--cb-text, #211E18);
}
.cb-modal-map {
  width: 100%;
  height: 200px;
  border-radius: var(--cb-radius-sm);
  border: 1px solid var(--cb-border);
  overflow: hidden;
  background: var(--cb-sage);
}
.cb-modal-detail {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  color: var(--cb-muted);
  line-height: 1.4;
}
.cb-modal-detail .cb-modal-warn { color: var(--cb-accent-2); font-weight: 600; }
.cb-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 0.9rem;
}
/* Legend dots reused inline in the detail line. */
.cb-modal-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 3px;
}
.cb-modal-dot-old { background: #9aa0a6; }
.cb-modal-dot-new { background: #1565c0; }
/* Preview map pins (old vs proposed). */
.cb-preview-pin {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.cb-preview-pin-old { opacity: 0.85; }

/* ── Insights tab (Increment 1) ──────────────────────────────────────────── */
.cb-cooc-note {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
}
.cb-cooc-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cb-cooc-grid {
  display: grid;
  gap: 2px;
  min-width: max-content;
}
.cb-cooc-cell {
  min-width: 26px;
  height: 26px;
  border-radius: 3px;
  font-size: 0.66rem;
  line-height: 1;
}
.cb-cooc-corner { background: transparent; }
.cb-cooc-col-label {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 56px;
  color: var(--cb-muted);
  overflow: hidden;
}
/* Column labels read bottom-to-top so the matrix stays narrow. */
.cb-cooc-col-label span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  max-height: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-cooc-row-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.4rem;
  color: var(--cb-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-cooc-data { border: 1px solid rgba(33, 30, 24, 0.05); }
.cb-cooc-diag {
  background: repeating-linear-gradient(
    45deg, var(--cb-panel-2), var(--cb-panel-2) 3px, transparent 3px, transparent 6px);
}
.cb-cooc-toptitle {
  margin: 0.9rem 0 0.4rem;
  font-family: var(--cb-hf);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cb-fg);
}
.cb-cooc-toplist { display: flex; flex-direction: column; gap: 0.25rem; }
.cb-cooc-toprow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.3rem 0.1rem;
  border-bottom: 1px solid var(--cb-border);
}
.cb-cooc-toprow:last-child { border-bottom: none; }
.cb-cooc-toppair { font-size: 0.92rem; color: var(--cb-fg); }
.cb-cooc-topn { font-weight: 700; color: var(--cb-accent); }

/* Morning chorus — per-day 24-bar profile, dawn hour highlighted. */
.cb-chorus-day { margin-top: 0.85rem; }
.cb-chorus-day:first-of-type { margin-top: 0.4rem; }
.cb-chorus-dayhead {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.cb-chorus-date { font-weight: 600; color: var(--cb-fg); font-size: 0.9rem; }
.cb-chorus-total { font-size: 0.78rem; color: var(--cb-muted); }
.cb-chorus-dawnlabel { font-size: 0.72rem; color: var(--cb-accent); margin-left: auto; }
.cb-chorus-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 64px;
  padding: 2px 0;
  background: linear-gradient(to top, var(--cb-panel-2) 0%, transparent 60%);
  border-radius: var(--cb-radius-sm);
}
.cb-chorus-bar {
  flex: 1 1 0;
  min-height: 1px;
  /* now a stacked container: species segments fill bottom-up */
  display: flex;
  flex-direction: column-reverse;
  background: var(--cb-muted);
  border-radius: 1px 1px 0 0;
  overflow: hidden;
}
/* A bar with no species segments (flat fallback) still reads as activity. */
.cb-chorus-bar:empty { opacity: 0.45; }
.cb-chorus-seg { display: block; width: 100%; min-height: 1px; }
/* Civil-dawn hour: outline the whole bar instead of recoloring it (segments keep
   their species colors). */
.cb-chorus-dawn {
  outline: 2px solid var(--cb-accent);
  outline-offset: -1px;
  border-radius: 2px 2px 0 0;
}

/* Dawn-window species ranking (who's singing at dawn) */
.cb-chorus-ranking { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.cb-chorus-sprow { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.cb-chorus-spdot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; }
.cb-chorus-spname {
  flex: 0 0 92px; color: var(--cb-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cb-chorus-spbar {
  flex: 1 1 auto; height: 8px; background: var(--cb-panel-2);
  border-radius: var(--cb-radius-sm); overflow: hidden;
}
.cb-chorus-spbar > span { display: block; height: 100%; border-radius: var(--cb-radius-sm); min-width: 2px; }
.cb-chorus-spshare { flex: 0 0 auto; color: var(--cb-muted); min-width: 30px; text-align: right; }
.cb-chorus-spmore { font-size: 0.72rem; margin-top: 2px; }

/* Chorus stats line: start–end / peak / strength-vs-baseline */
.cb-chorus-stats {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline;
  margin: 2px 0 6px; font-size: 0.78rem; color: var(--cb-muted);
}
.cb-chorus-strength { font-weight: 600; }
.cb-chorus-up   { color: #3e8e5e; }
.cb-chorus-down { color: #c06a4a; }

/* Dawn-by-weather per-condition species split */
.cb-dbw-species {
  display: flex; flex-wrap: wrap; gap: 4px 8px;
  margin: -2px 0 6px 78px;  /* align under the bar track, not the label */
}
.cb-dbw-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; color: var(--cb-text);
}
.cb-dbw-chipdot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }

/* Soundscape "current hour" column marker */
.cb-ss-now { outline: 1px solid var(--cb-accent); outline-offset: -1px; }
.cb-ss-hour.cb-ss-now { color: var(--cb-accent); font-weight: 600; }

/* Patterns section header inside Place */
.cb-patterns-head { margin-top: 6px; }

/* ── Dawn chorus by weather (Increment 2) ─────────────────────────────────── */
.cb-dbw-group { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.cb-dbw-row { display: flex; align-items: center; gap: 8px; }
.cb-dbw-label {
  flex: 0 0 76px; font-size: 0.82rem; color: var(--cb-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cb-dbw-track {
  flex: 1 1 auto; height: 14px; background: var(--cb-panel-2);
  border-radius: var(--cb-radius-sm); overflow: hidden;
}
.cb-dbw-fill { display: block; height: 100%; border-radius: var(--cb-radius-sm); min-width: 2px; }
.cb-dbw-wx { background: var(--cb-accent); }
.cb-dbw-season { background: var(--cb-muted); opacity: 0.75; }
.cb-dbw-val { flex: 0 0 auto; font-size: 0.82rem; color: var(--cb-text); min-width: 30px; text-align: right; }
.cb-dbw-days { font-size: 0.72rem; }

/* ── Soundscape band heat strip (Increment 2) ─────────────────────────────── */
.cb-ss-scroll { overflow-x: auto; margin-top: 6px; -webkit-overflow-scrolling: touch; }
.cb-ss-grid { display: grid; gap: 1px; min-width: 460px; }
.cb-ss-cell { min-height: 16px; font-size: 0.62rem; line-height: 16px; }
.cb-ss-corner { background: transparent; }
.cb-ss-hour { color: var(--cb-muted); text-align: center; }
.cb-ss-bandlabel {
  color: var(--cb-text); font-size: 0.68rem; padding-right: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right;
}
.cb-ss-data { border-radius: 1px; }
.cb-ss-empty { background: var(--cb-panel-2); opacity: 0.4; border-radius: 1px; }
.cb-ss-coverage { margin-top: 6px; font-size: 0.72rem; }
