:root {
  --paper: #f5efe2;
  --paper-deep: #ece3cf;
  --ink: #2e2a22;
  --ink-soft: #6b6353;
  --accent: #3e5c41;      /* veld green */
  --accent-warm: #b3552e; /* sandstone/bishop red */
  --card: #fffdf7;
  --line: #d8cdb4;
  --shadow: 0 2px 14px rgba(46, 42, 34, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.55;
}

/* ---------- Header ---------- */
.site-header {
  padding: 2.2rem 1.5rem 1.1rem;
  text-align: center;
  background:
    linear-gradient(to bottom, rgba(62, 92, 65, 0.07), transparent 65%);
  border-bottom: 1px solid var(--line);
}
.masthead h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent);
}
.tagline {
  margin: 0.5rem auto 1.2rem;
  max-width: 42rem;
  color: var(--ink-soft);
  font-style: italic;
}

.time-filter { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.time-filter button, .sort-toggle button {
  font: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.9rem;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.time-filter button:hover, .sort-toggle button:hover { border-color: var(--accent); color: var(--accent); }
.time-filter button.active, .sort-toggle button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* ---------- Collage ---------- */
.collage-wrap { position: relative; }
.collage {
  position: relative;
  width: 100%;
  min-height: 420px;
  overflow: hidden;
}
.collage-empty[hidden] { display: none; }
.collage-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-style: italic;
}

.bird-tile {
  position: absolute;
  cursor: pointer;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2), filter 0.2s ease;
  filter: drop-shadow(2px 4px 6px rgba(46, 42, 34, 0.25));
}
.bird-tile.placed { transform: translate(-50%, -50%) scale(1); }
.bird-tile:hover {
  transform: translate(-50%, -50%) scale(1.05);
  filter: drop-shadow(3px 7px 12px rgba(46, 42, 34, 0.4));
  z-index: 60 !important;
}
.bird-tile img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.bird-tile .tile-label {
  position: absolute;
  left: 50%; bottom: -0.4em;
  transform: translateX(-50%);
  background: rgba(46, 42, 34, 0.85);
  color: #f7f2e4;
  font-size: 0.74rem;
  padding: 0.12em 0.65em;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.bird-tile:hover .tile-label { opacity: 1; }
.bird-tile.large .tile-label { font-size: 0.9rem; }
.bird-tile.placeholder { filter: none; }
.bird-tile .no-image {
  display: block;
  width: 100%; height: 100%;
  border: 1.5px dashed var(--line);
  border-radius: 50%;
  background: rgba(216, 205, 180, 0.25);
}
.bird-tile.placeholder:hover .no-image { border-color: var(--accent); }
.thumb-empty { display: inline-block; border-style: dashed; }

/* ---------- Stats bar ---------- */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  padding: 1.1rem 1rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}
.stat { text-align: center; }
.stat .num {
  display: block;
  font-size: 1.7rem;
  color: var(--accent-warm);
  font-weight: 600;
}
.stat .lbl {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Species list ---------- */
.species-section { max-width: 62rem; margin: 0 auto; padding: 1.8rem 1.2rem 3rem; }
.species-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.species-head h2 { color: var(--accent); font-weight: 600; margin: 0 0 1rem; }
.sort-toggle { display: inline-flex; gap: 0.3rem; }

.species-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.7rem;
}
.species-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.species-list li:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
/* A round mask only fits its inscribed square (side = diameter ÷ √2 ≈ 0.71 × D),
   so an image padded to less than that gets its corners — and, on an upright
   bird, its head — sliced off by the curve. Padding here is sized so the drawing
   always lands inside that square: 52 − 2 border − 14 padding = 36 ≤ 36.8. Same
   sum done again for .mylist-items below. Grow the circle and the padding
   together, or the heads come back off. */
.species-list .thumb {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: contain;
  padding: 7px;
  flex: none;
  background: var(--card);
  border: 1px solid var(--line);
}
.species-list .info { min-width: 0; }
.species-list .cname {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.species-list .meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.species-list .badge {
  margin-left: auto;
  flex: none;
  background: var(--accent);
  color: var(--paper);
  border-radius: 999px;
  min-width: 2em;
  text-align: center;
  padding: 0.1em 0.5em;
  font-size: 0.85rem;
}
.species-list li.unseen { opacity: 0.55; }
.species-list li.unseen .badge { background: var(--line); color: var(--ink-soft); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.2rem 1.5rem 2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.site-footer a { color: var(--accent); }
.link-btn {
  font: inherit;
  font-size: 0.82rem;
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* ---------- "Get a Bird List" banner ---------- */
.cta-banner {
  max-width: 44rem;
  margin: 1.5rem auto 0;
  padding: 1.4rem 1.4rem;
  background: var(--accent);
  color: var(--paper);
  border-radius: 0.9rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}
.cta-banner-text { margin: 0; font-size: 1.05rem; }
.cta-banner-text b { color: #fff; }
.cta-banner-btn {
  display: inline-block;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--accent);
  text-decoration: none;
  transition: transform 0.12s ease;
}
.cta-banner-btn:hover { transform: translateY(-1px); }

/* ---------- Consent / privacy modal ---------- */
.modal.consent { max-width: 28rem; }
.consent-intro { margin: 0.4rem 0 0.8rem; font-size: 0.95rem; }
.consent-points {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.consent-points li { margin-bottom: 0.4rem; }
.consent-agree {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.9rem;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
}
.consent-agree input { margin-top: 0.15rem; flex: none; width: 1.1rem; height: 1.1rem; }
.consent.info-only .consent-agree,
.consent.info-only #consentAgree { display: none; }

/* ---------- Modal ---------- */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(38, 33, 24, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  /* must clear the collage tiles, which take z-index up to the species count */
  z-index: 1000;
}
.modal {
  position: relative;
  background: var(--card);
  border-radius: 0.9rem;
  max-width: 30rem;
  width: 100%;
  min-width: 0;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}
.modal-media {
  background: var(--paper);
  border-radius: 0.9rem 0.9rem 0 0;
  padding: 1.2rem 1.2rem 0.6rem;
}
.modal-media img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  display: block;
}
.modal-body { padding: 1.1rem 1.4rem 1.4rem; }
.modal-body h3 { margin: 0; color: var(--accent); font-size: 1.4rem; }
.modal-body .afr { margin: 0.15rem 0 0; color: var(--ink); font-weight: 600; font-size: 0.95rem; }
.modal-body .sci { margin: 0.1rem 0 0.7rem; font-style: italic; color: var(--ink-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.8rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2em 0.7em;
  font-size: 0.8rem;
  color: var(--ink);
}
.chip-icon { padding-left: 0.35em; }
.chip-icon img { width: 1.5em; height: 1.5em; object-fit: contain; display: block; }

.call { display: flex; align-items: center; gap: 0.7rem; margin: 0.4rem 0 0.2rem; }
.call-label {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft); flex: none;
}
.call audio { height: 34px; max-width: 100%; }

.modal-body .section { margin-top: 0.9rem; }
.modal-body .section h4 {
  margin: 0 0 0.25rem;
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
}
.modal-body .section p { margin: 0; font-size: 0.92rem; }
.modal-stats {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.modal-stats b { color: var(--accent-warm); }
.blurb { font-size: 0.92rem; }
.modal-links { display: flex; gap: 1.2rem; margin-bottom: 0; }
.modal-links a { color: var(--accent); }
.credit-note {
  margin: 0.6rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.modal-close {
  position: absolute;
  top: 0.5rem; right: 0.6rem;
  width: 2.1rem; height: 2.1rem;
  border-radius: 50%;
  border: none;
  background: rgba(38, 33, 24, 0.55);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}

/* ---------- Log CTA + floating action button ---------- */
.log-cta {
  margin: 0.4rem 0 1.4rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  border: none;
  background: var(--accent-warm);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, background 0.15s ease;
}
.log-cta:hover { transform: translateY(-1px); background: #9c481f; }

.fab {
  position: fixed;
  right: 1.1rem; bottom: 1.1rem;
  width: 3.6rem; height: 3.6rem;
  border-radius: 50%;
  border: none;
  background: var(--accent-warm);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(46, 42, 34, 0.4);
  z-index: 200;
  display: none;
}
.fab:active { transform: scale(0.94); }

.toast {
  position: fixed;
  left: 50%; bottom: 1.4rem;
  transform: translateX(-50%) translateY(2rem);
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.2rem;
  border-radius: 1.4rem;
  width: max-content; max-width: calc(100% - 2rem); text-align: center;
  font-size: 0.92rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 300;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Header actions + My list ---------- */
.header-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.list-btn {
  margin: 0.4rem 0 1.4rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.list-btn:hover { background: var(--accent); color: var(--paper); }

.modal.mylist { max-width: 26rem; }
.list-name-field {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft);
  margin: 0.6rem 0 0.4rem;
}
.list-name-field input {
  font: inherit; font-size: 1rem; font-weight: 400; color: var(--ink);
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 0.5rem;
  background: var(--paper);
}
.list-summary { margin: 0.3rem 0 0.7rem; color: var(--ink-soft); font-size: 0.95rem; }
.list-summary b { color: var(--accent-warm); }
.mylist-items {
  list-style: none; margin: 0 0 1rem; padding: 0;
  max-height: 46vh; overflow-y: auto;
}
.mylist-items li {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.4rem 0; border-bottom: 1px solid var(--line);
}
.mylist-items img, .mylist-items .thumb-empty {
  width: 46px; height: 46px; border-radius: 50%; object-fit: contain;
  padding: 6px; background: var(--card); border: 1px solid var(--line); flex: none;
}
.mylist-items .ml-name { font-weight: 600; flex: 1; min-width: 0; }
.mylist-items .ml-meta { color: var(--ink-soft); font-size: 0.82rem; white-space: nowrap; }
.list-export {
  width: 100%; font: inherit; font-weight: 600; font-size: 1rem;
  padding: 0.7rem; border-radius: 0.6rem; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
}
.list-export:hover { background: #33502f; }
.list-export:disabled { opacity: 0.5; cursor: default; }

/* ---------- Last-seen-by in species modal ---------- */
.last-seen {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.last-seen .last-photo {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: 0.4rem;
  flex: none;
}
.last-seen .last-when { color: var(--ink-soft); font-size: 0.82rem; }
.last-seen a { color: var(--accent); }
.log-species-btn {
  display: block;
  width: 100%;
  margin: 0.9rem 0 0.2rem;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem;
  border-radius: 0.6rem;
  border: 1.5px solid var(--accent-warm);
  background: transparent;
  color: var(--accent-warm);
  cursor: pointer;
}
.log-species-btn:hover { background: var(--accent-warm); color: #fff; }

/* ---------- Capture form ---------- */
.modal.capture { max-width: 27rem; }
.capture-form { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 0.6rem; }
.capture-form label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft);
}
.capture-form .opt { font-weight: 400; }
.capture-form .field-hint {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}
.identity-banner[hidden] { display: none; }
.identity-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  margin: 0.2rem 0;
}
.identity-banner b { color: var(--accent); }
.identity-banner button {
  margin-left: auto;
  font: inherit;
  font-size: 0.85rem;
  background: none;
  border: none;
  color: var(--accent-warm);
  text-decoration: underline;
  cursor: pointer;
  flex: none;
}
/* Fixed height on both: Chrome ignores line-height on <select>, so the select and
   the date input won't agree on a height unless it is stated outright. 2.75rem
   leaves the content box comfortably taller than the text, so digits can't clip. */
.capture-form input,
.capture-form select {
  font: inherit; font-size: 1rem; font-weight: 400; color: var(--ink);
  height: 2.75rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--paper);
  width: 100%;
  min-width: 0;
}
.capture-form select { appearance: auto; }
.capture-form input:focus,
.capture-form select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
/* min-width: 0 overrides the flex default (min-width: auto), which otherwise
   stops these shrinking below their content size (e.g. a native date picker)
   and forces the whole modal into horizontal scroll on narrow phones. */
.field-row { display: flex; gap: 0.7rem; min-width: 0; }
.field-row label { flex: 1; min-width: 0; }
.field-row .count-field { flex: 0 0 6.5rem; min-width: 0; }
.field-row.extras { align-items: stretch; }
.field-row.extras > * { min-width: 0; }
.photo-btn, .geo-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font: inherit; font-size: 0.9rem; font-weight: 600;
  padding: 0.6rem; border-radius: 0.5rem;
  border: 1px dashed var(--line); background: var(--paper-deep);
  color: var(--ink); cursor: pointer; text-align: center;
}
.photo-btn:hover, .geo-btn:hover { border-color: var(--accent); color: var(--accent); }
.cap-photo-preview:empty { display: none; }
.cap-photo-preview img { max-width: 100%; max-height: 160px; border-radius: 0.5rem; display: block; }
.geo-status { font-size: 0.82rem; color: var(--accent); min-height: 1em; }
.cap-msg { color: var(--accent-warm); font-size: 0.85rem; margin: 0; min-height: 1em; }
.cap-submit {
  font: inherit; font-size: 1.05rem; font-weight: 600;
  padding: 0.75rem; border-radius: 0.6rem; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
}
.cap-submit:hover { background: #33502f; }
.cap-submit:disabled { opacity: 0.6; cursor: default; }
.cap-another {
  font: inherit; font-size: 1.05rem; font-weight: 600;
  padding: 0.7rem; border-radius: 0.6rem; cursor: pointer;
  background: transparent; color: var(--accent); border: 2px solid var(--accent);
}
.cap-another:hover { background: rgba(62, 92, 65, 0.08); }
.cap-another:disabled { opacity: 0.6; cursor: default; }
.cap-msg.ok { color: var(--accent); font-weight: 600; }
.pending-note {
  display: block; margin: 0 auto 1.1rem; max-width: 100%;
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  padding: 0.5rem 1rem; border-radius: 999px;
  background: var(--card); color: var(--accent-warm); border: 1px solid var(--accent-warm);
}
.pending-note[hidden] { display: none; }

@media (max-width: 600px) {
  .stats-bar { gap: 1.3rem; }
  .species-list { grid-template-columns: minmax(0, 1fr); }
  .fab { display: block; }
  .log-cta { display: none; }
}
