/* =========================================================================
   Ontario Wildlife Log, iOS design system
   A vanilla-CSS approximation of native iOS (UIKit) styling: San Francisco
   system font, grouped inset lists, large-title nav bars, translucent tab &
   nav bars, iOS controls, full light/dark support and safe-area handling.
   Accent colour is an Ontario forest green for a distinct identity.
   ========================================================================= */

:root {
  /* Accent / tint. Ontario forest green */
  --tint: #14804a;
  --tint-press: #0f6b3d;
  --tint-soft: rgba(20, 128, 74, 0.12);
  --on-tint: #ffffff;

  /* Semantic system colours (light) */
  --bg: #f2f2f7;              /* systemGroupedBackground */
  --bg-elevated: #ffffff;    /* secondarySystemGroupedBackground (cells) */
  --bg-secondary: #efeff4;
  --bar: rgba(249, 249, 249, 0.82); /* translucent nav / tab bar */
  --bar-border: rgba(0, 0, 0, 0.28);

  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.75); /* secondary text, bumped from iOS 0.6 to clear WCAG AA (≈5:1) */
  --label-3: rgba(60, 60, 67, 0.3);
  --tab-inactive: #6d6d72;           /* inactive tab labels, accessible grey, not 0.3 fill */
  --separator: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);

  --red: #d1372b;
  --orange: #ff9500; --orange-strong: #b45309;
  --yellow: #ffcc00;
  --green: #34c759;
  --blue: #007aff;
  --purple: #af52de;

  --radius-cell: 12px;
  --radius-card: 16px;
  --radius-btn: 12px;

  --nav-h: 44px;
  --tab-h: 50px;

  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --tint: #30d158;
    --tint-press: #28b84c;
    --tint-soft: rgba(48, 209, 88, 0.16);
    --on-tint: #05230f;

    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bar: rgba(30, 30, 30, 0.8);
    --bar-border: rgba(255, 255, 255, 0.18);

    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.65);
    --label-3: rgba(235, 235, 245, 0.3);
    --tab-inactive: rgba(235, 235, 245, 0.6);
    --separator: rgba(84, 84, 88, 0.6);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);

    --red: #ff6961;
    --orange: #ff9f0a; --orange-strong: #ff9f0a;
    --yellow: #ffd60a;
    --green: #30d158;
    --blue: #0a84ff;
    --purple: #bf5af3;
  }
}

/* Explicit theme override, the in-app Appearance toggle stamps data-theme on
   <html> and must win over the media query in both directions. */
:root[data-theme='light'] {
  color-scheme: light;
  --tint: #14804a; --tint-press: #0f6b3d; --tint-soft: rgba(20, 128, 74, 0.12); --on-tint: #fff;
  --bg: #f2f2f7; --bg-elevated: #fff; --bg-secondary: #efeff4; --bar: rgba(249, 249, 249, 0.82); --bar-border: rgba(0, 0, 0, 0.28);
  --label: #000; --label-2: rgba(60, 60, 67, 0.75); --label-3: rgba(60, 60, 67, 0.3); --tab-inactive: #6d6d72; --separator: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.12); --fill-strong: rgba(120, 120, 128, 0.2);
  --red: #d1372b; --orange: #ff9500; --orange-strong: #b45309; --yellow: #ffcc00; --green: #34c759; --blue: #007aff; --purple: #af52de;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --tint: #30d158; --tint-press: #28b84c; --tint-soft: rgba(48, 209, 88, 0.16); --on-tint: #05230f;
  --bg: #000; --bg-elevated: #1c1c1e; --bg-secondary: #2c2c2e; --bar: rgba(30, 30, 30, 0.8); --bar-border: rgba(255, 255, 255, 0.18);
  --label: #fff; --label-2: rgba(235, 235, 245, 0.65); --label-3: rgba(235, 235, 245, 0.3); --tab-inactive: rgba(235, 235, 245, 0.6); --separator: rgba(84, 84, 88, 0.6);
  --fill: rgba(120, 120, 128, 0.24); --fill-strong: rgba(120, 120, 128, 0.36);
  --red: #ff6961; --orange: #ff9f0a; --orange-strong: #ff9f0a; --yellow: #ffd60a; --green: #30d158; --blue: #0a84ff; --purple: #bf5af3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
    'Helvetica Neue', 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Visible keyboard focus for accessibility (AODA / WCAG 2.4.7) */
:focus-visible { outline: 2.5px solid var(--tint); outline-offset: 2px; border-radius: 6px; }

/* Kill the tap flash + text selection on interactive chrome for a native feel */
button, .tap, .cell, .tab, .chip, .seg-opt {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: var(--tint); text-decoration: none; }
input, textarea, select { font: inherit; color: var(--label); }
img { max-width: 100%; }

/* ---------------------------------------------------------------- App shell */
#app {
  min-height: 100%;
  padding-bottom: calc(var(--tab-h) + var(--sa-bottom) + 8px);
}

/* Optional "In depth" species account (native <details> styled as a group). */
.notes {
  margin: 18px 16px; background: var(--bg-elevated);
  border-radius: var(--radius-card); overflow: hidden;
}
.notes > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 44px;
}
.notes > summary::-webkit-details-marker { display: none; }
.notes > summary .cell-emoji { font-size: 22px; width: 28px; text-align: center; }
.notes > summary .cell-title { font-size: 17px; }
.notes > summary .chevron { margin-left: auto; transition: transform 0.2s var(--ease); }
.notes[open] > summary .chevron { transform: rotate(90deg); }
.notes > summary:active { background: var(--fill); }
.notes-body {
  padding: 2px 18px 18px; border-top: 0.5px solid var(--separator);
}
.notes-body p { margin: 12px 0 0; font-size: 16px; line-height: 1.55; color: var(--label); }
.notes-body p:first-child { margin-top: 14px; }

.screen { animation: screen-in 0.28s var(--ease); }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* iOS push/pop navigation transitions. Two screens overlay while the incoming one
   slides in and the outgoing one parallaxes off and dims, like a UINavigationController. */
#app.nav-animating { position: relative; overflow: hidden; }
#app.nav-animating .screen { position: absolute; top: 0; left: 0; width: 100%; }
.screen.sc-anim { animation: none; transition: transform 0.34s var(--ease), opacity 0.34s var(--ease); will-change: transform; }
.screen.sc-from-right { transform: translateX(100%); }
.screen.sc-from-left { transform: translateX(-100%); }
.screen.sc-exit-left { transform: translateX(-26%); opacity: 0.55; }
.screen.sc-exit-right { transform: translateX(100%); }

/* --------------------------------------------------------- Navigation bar */
.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: var(--sa-top);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s;
}
.nav.scrolled { border-bottom-color: var(--bar-border); }
.nav-row {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 8px;
}
.nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* 50%, not 60%: a centred title 60% wide starts at 80px, which is where the
     back button ends. At 50% there is always a gap, and a title too long for it
     truncates the way iOS truncates rather than colliding. */
  max-width: 50%;
  transition: opacity 0.2s;
}
/* On large-title screens the inline title stays hidden until you scroll past
   the big title, mirroring iOS navigation bars. */
.nav.has-large .nav-title { opacity: 0; }
.nav.has-large.show-title .nav-title { opacity: 1; }
.nav-left, .nav-right {
  position: absolute;
  top: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-left { left: 4px; max-width: 42%; }
.nav-right { right: 8px; }
/* Belt and braces for the back label: JS already swaps a long one for "Back",
   and this keeps a medium one from ever reaching the centred title. */
.nav-btn { min-width: 0; }
.nav-btn .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-btn {
  color: var(--tint);
  font-size: 17px;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 8px;
}
.nav-btn:active { opacity: 0.4; }
.nav-btn.bold { font-weight: 600; }
.nav-btn svg { width: 17px; height: 17px; }

/* Large title (collapses as user scrolls) */
.large-title {
  padding: 4px 20px 6px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.large-title h1 {
  margin: 0;
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.37px;
}
.large-title .large-head { display: flex; align-items: center; gap: 10px; }
.large-title .large-head h1 { flex: 0 1 auto; }
.large-title .ver {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--label-2);
  background: var(--fill);
  border-radius: 100px;
  padding: 3px 9px;
  align-self: center;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
/* Fitts: the chip is deliberately small, but the thing you aim at should not be.
   An invisible overlay grows the hit area to 44px without touching the look. */
.large-title .ver::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 44px;
  transform: translateY(-50%);
}
.large-title .ver:active { opacity: 0.6; }
.large-title .subtitle { color: var(--label-2); font-size: 15px; margin-top: 2px; max-width: 34em; }

/* -------------------------------------------------------------- Tab bar */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: calc(var(--tab-h) + var(--sa-bottom));
  padding-bottom: var(--sa-bottom);
  display: flex;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--bar-border);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--tab-inactive);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
  padding-top: 6px;
  transition: color 0.15s, transform 0.1s;
}
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--tint); }
.tab.active span { font-weight: 700; }   /* non-colour cue for the selected tab */
.tab:active { transform: scale(0.92); }

/* ------------------------------------------------------- Grouped lists */
.group {
  margin: 18px 16px 8px;
}
.group-header {
  padding: 0 4px 7px;
  font-size: 13px;
  font-weight: 400;
  color: var(--label-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.group-footer {
  padding: 7px 4px 0;
  font-size: 13px;
  color: var(--label-2);
  line-height: 1.35;
}
.list {
  background: var(--bg-elevated);
  border-radius: var(--radius-cell);
  overflow: hidden;
}
.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 11px 16px;
  position: relative;
  background: var(--bg-elevated);
  color: var(--label); /* keep anchor cells from inheriting the link tint */
  transition: background 0.12s;
  text-align: left;
}
/* A <button> is a form control, so its width is fit-content unless told otherwise.
   Left alone, a button row shrink-wraps its text: the chevron lands beside the
   label and the hairline divider stops short, while the <a> rows above it run the
   full width. Force every row element to the same box so a list looks like one list. */
a.cell, button.cell, summary.cell {
  width: 100%;
  box-sizing: border-box;
}
button.cell {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: var(--bg-elevated);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.cell + .cell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}
.cell.tap:active { background: var(--fill); }
.cell-emoji {
  width: 30px;
  font-size: 26px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.cell-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 17px;
  flex-shrink: 0;
  color: #fff;
}
.cell-body { flex: 1 1 auto; min-width: 0; }
.cell-title { display: block; font-size: 17px; letter-spacing: -0.2px; color: var(--label); }
.cell-title.i { font-style: italic; }
.cell-sub {
  display: block;
  font-size: 13px;
  color: var(--label-2);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-emoji svg { width: 26px; height: 26px; display: block; margin: 0 auto; }
/* margin-left:auto pins the trailing value and chevron to the right edge even on
   rows with no .cell-body to push them there (a plain "Version 2.4" row). */
.cell-value { color: var(--label-2); font-size: 16px; flex: none; margin-left: auto; }
.chevron { color: var(--label-3); flex: none; margin-left: auto; }
.cell-value + .chevron { margin-left: 8px; }
.chevron svg { width: 14px; height: 20px; display: block; }

/* -------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  transition: transform 0.08s, opacity 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.975); }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn-primary { background: var(--tint); color: var(--on-tint); }
.btn-primary:active { background: var(--tint-press); }
.btn-tinted { background: var(--tint-soft); color: var(--tint); }
.btn-gray { background: var(--fill-strong); color: var(--label); }
.btn-plain { color: var(--tint); }
.btn-danger { color: var(--red); background: var(--fill); }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: 0.4; }

/* ----------------------------------------------------------------- Chips */
.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 16px 8px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* 44px so a filter is easy to hit one-handed with a glove on, which is the
     situation this app is actually used in. */
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--fill-strong);
  color: var(--label);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.12s, transform 0.08s;
}
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--tint); color: var(--on-tint); }

/* ------------------------------------------------------- Segmented control */
.segmented {
  display: flex;
  background: var(--fill-strong);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}
.seg-opt {
  flex: 1;
  /* Fitts: a segment is wide but was only 36px tall, which is a thin thing to
     hit while walking. Flex centring holds the label while the segment grows. */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
  transition: background 0.15s;
}
.seg-opt.on {
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  font-weight: 600;
}

/* --------------------------------------------------------------- Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.badge-risk { background: rgba(255, 149, 0, 0.16); color: var(--orange-strong); }
.badge-danger { background: rgba(255, 59, 48, 0.16); color: var(--red); }
.badge-ok { background: var(--tint-soft); color: var(--tint); }
.badge-info { background: var(--fill-strong); color: var(--label-2); }

/* ------------------------------------------------------------ Form inputs */
.field { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 16px; }
.field-label { font-size: 17px; flex-shrink: 0; }
.field input[type='text'],
.field input[type='number'],
.field input[type='datetime-local'],
.field input[type='search'] {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 17px;
  text-align: right;
  color: var(--label);
}
.field input::placeholder, textarea.notes::placeholder { color: var(--label-2); opacity: 0.7; }
textarea.notes {
  width: 100%;
  border: 0;
  background: none;
  outline: none;
  resize: none;
  font-size: 17px;
  padding: 12px 16px;
  min-height: 88px;
  color: var(--label);
}

/* iOS switch */
.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--fill-strong);
  border-radius: 31px;
  transition: background 0.25s var(--ease);
}
.switch .knob {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.25s var(--ease);
}
.switch input:checked ~ .track { background: var(--tint); }
.switch input:checked ~ .knob { transform: translateX(20px); }

/* Stepper */
.stepper { display: inline-flex; align-items: center; background: var(--fill-strong); border-radius: 8px; overflow: hidden; }
.stepper button { width: 44px; height: 40px; font-size: 22px; color: var(--label); display: grid; place-items: center; }
.stepper .val { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper button:active { background: var(--fill); }
.stepper .sep { width: 0.5px; background: var(--separator); }

/* Search bar */
.searchbar {
  margin: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--fill-strong);
  color: var(--label-2);
}
.searchbar svg { width: 16px; height: 16px; flex-shrink: 0; }
.searchbar input {
  flex: 1; border: 0; background: none; outline: none;
  font-size: 17px; color: var(--label);
}

/* --------------------------------------------------------------- Sheets */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  transform: translateY(100%);
  transition: transform 0.34s var(--ease);
  box-shadow: 0 -1px 0 var(--separator);
}
.sheet.show { transform: translateY(0); }
.sheet-grabber {
  width: 36px; height: 5px; border-radius: 3px;
  background: var(--label-3);
  margin: 8px auto 0;
  flex-shrink: 0;
}
.sheet-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 6px;
  flex-shrink: 0;
}
.sheet-nav .t { font-size: 17px; font-weight: 600; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(24px + var(--sa-bottom)); }

/* ---------------------------------------------------------- Species hero */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 20px 8px;
}
.hero-emoji {
  width: 96px; height: 96px;
  border-radius: 26px;
  display: grid; place-items: center;
  font-size: 56px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  margin-bottom: 14px;
}
.sp-photo-wrap { display: none; width: 100%; }
.sp-photo-wrap.show { display: block; margin-bottom: 14px; }
.sp-photo { width: 100%; max-height: 300px; object-fit: cover; border-radius: 16px; display: block; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }
.photo-credit { font-size: 11px; color: var(--label-2); margin-top: 6px; line-height: 1.3; }
.hero h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }
.hero .sci { color: var(--label-2); font-style: italic; font-size: 15px; margin-top: 2px; }
.hero .badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }

/* Card grid (Explore categories) */
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px 16px 8px; }
.cat-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-card);
  padding: 16px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.1s;
  position: relative;
  overflow: hidden;
}
.cat-card:active { transform: scale(0.97); }
.cat-card .ce { font-size: 34px; }
.cat-card .cn { font-size: 17px; font-weight: 600; margin-top: 8px; }
.cat-card .cc { font-size: 13px; color: var(--label-2); margin-top: 1px; }
.cat-card.soon { opacity: 0.55; }

/* Info rows in species detail */
.info-row { padding: 11px 16px; }
.info-row + .info-row::before {
  content: ''; display: block; height: 0.5px; background: var(--separator);
  margin: -11px -16px 11px; margin-left: 0;
}
.info-k { font-size: 13px; color: var(--label-2); }
.info-v { font-size: 16px; margin-top: 2px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 4px 16px 8px; }
.stat {
  background: var(--bg-elevated);
  border-radius: var(--radius-card);
  padding: 14px 12px;
  text-align: center;
  display: block;
}
a.stat { color: inherit; text-decoration: none; }
a.stat:active { background: var(--fill); }

/* -------------------------------------------------- Journal: the life list
   The headline of the Journal. One big honest number, and a bar that says how
   much of Ontario's guide is still out there. It is never padded and never
   nags: the count is simply the truth, and the gap is the invitation. */
.lifecard {
  background: var(--bg-elevated);
  border-radius: var(--radius-card);
  padding: 18px 18px 16px;
  margin-top: 4px;
}
.lifecard-n {
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1.4px;
  color: var(--tint);
  font-variant-numeric: tabular-nums;
}
.lifecard-l { font-size: 15px; color: var(--label); margin-top: 5px; }
.lifecard .riskbar { margin-top: 13px; }
.lifecard .riskbar-fill { background: var(--tint); }
.lifecard-f { font-size: 13px; color: var(--label-2); margin-top: 7px; }

/* The lifer mark. Small, set in the tint, and only ever on the one encounter
   that first put a species on the list. */
.pill-new {
  display: inline-block;
  vertical-align: 2px;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--tint);
  color: var(--on-tint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* A species you have already logged, seen while browsing the guide. A tick, not
   a badge: the guide is a checklist you work quietly, not a scoreboard. */
.seen-tick {
  display: inline-flex;
  vertical-align: 1px;
  margin-left: 6px;
  color: var(--tint);
}
.seen-tick svg { width: 13px; height: 13px; display: block; }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; color: var(--tint); }
.stat .l { font-size: 12px; color: var(--label-2); margin-top: 2px; }

/* Empty state */
.empty { text-align: center; padding: 60px 32px; color: var(--label-2); }
.empty .e { font-size: 52px; }
/* Most empty states use an emoji, which font-size sizes. The search hint uses an
   inline SVG, which font-size does not touch, so it has to be sized and thinned
   here or it fills the screen in near-black. */
.empty .e svg {
  width: 42px;
  height: 42px;
  display: block;
  margin: 0 auto;
  color: var(--label-3);
  stroke-width: 1.4;
}
.empty h3 { color: var(--label); font-size: 20px; margin: 14px 0 4px; }
.empty p { font-size: 15px; line-height: 1.4; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--sa-bottom) + 20px);
  transform: translate(-50%, 20px);
  z-index: 80;
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-action { display: flex; align-items: center; gap: 14px; pointer-events: auto; }
.toast-btn {
  flex: 0 0 auto; background: none; border: 0; color: #4ea1ff;
  font-size: 15px; font-weight: 700; padding: 2px 2px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.toast-btn:active { opacity: 0.6; }

/* Misc helpers */
.muted { color: var(--label-2); }
.center { text-align: center; }
.hpad { padding-left: 16px; padding-right: 16px; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.entry-photo { width: 100%; border-radius: 12px; margin-top: 4px; display: block; }
.shared-recv { text-align: center; }
.shared-card-wrap { max-width: 420px; margin: 8px auto 2px; }
.shared-card { width: 100%; height: auto; display: block; border-radius: 22px; box-shadow: 0 12px 34px rgba(0,0,0,.18); background: var(--fill-2, #f2f2f7); }
.shared-note { margin: 14px 20px 2px; color: var(--label-2); font-style: italic; }
.spacer { height: 12px; }
.spacer-lg { height: 28px; }
.wrap-note {
  margin: 8px 16px; padding: 12px 14px;
  background: rgba(255, 149, 0, 0.12);
  border-radius: 12px;
  font-size: 14px; line-height: 1.4;
  color: var(--label);
  display: flex; gap: 10px;
}
.wrap-note.danger { background: rgba(255, 59, 48, 0.12); }
.wrap-note .i { flex-shrink: 0; font-size: 18px; }

/* ---- Chip variants (report actions) ---- */
.chip-alert { background: rgba(93, 64, 55, 0.16); color: #6d4c41; }
.chip-warn { background: rgba(255, 149, 0, 0.18); color: #b25e00; }
@media (prefers-color-scheme: dark) {
  .chip-alert { background: rgba(161, 136, 127, 0.26); color: #d7ccc8; }
  .chip-warn { background: rgba(255, 159, 10, 0.24); color: #ffb340; }
}

/* ---------------------------------------------------------------- Map */
.map-chiprow { padding-top: 8px; padding-bottom: 8px; }
.map-wrap {
  position: relative;
  z-index: 0;
  overflow: hidden;
  height: calc(100dvh - var(--sa-top) - 44px - 52px - var(--tab-h) - var(--sa-bottom) - 8px);
  min-height: 320px;
  background: var(--bg-secondary);
}
#map { position: absolute; inset: 0; background: var(--bg-secondary); }
.map-msg { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--label-2); }
.map-fabs { position: absolute; right: 12px; bottom: 16px; z-index: 500; display: flex; flex-direction: column; gap: 12px; }
.fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--bg-elevated); color: var(--label);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  display: grid; place-items: center; font-size: 24px;
  transition: transform 0.08s;
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 24px; height: 24px; color: var(--tint); }
.fab-bear { background: var(--tint); }
.map-hint {
  position: absolute; left: 12px; right: 76px; top: 12px; z-index: 500;
  background: rgba(28, 28, 30, 0.92); color: #fff;
  padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.35;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.map-hint.show { opacity: 1; transform: none; }
.hint-btn {
  pointer-events: auto; margin-left: 6px; background: rgba(255, 255, 255, 0.2); color: #fff;
  border-radius: 8px; padding: 4px 9px; font-size: 12px; font-weight: 600; min-height: 30px;
}
.map-note {
  position: absolute; left: 12px; right: 76px; bottom: 12px; z-index: 500;
  background: rgba(28, 28, 30, 0.92); color: #fff; padding: 8px 12px; border-radius: 10px;
  font-size: 12px; line-height: 1.35;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.map-note[hidden] { display: none; }

/* Leaflet teardrop pins built from divIcons */
.pin-wrap { background: none; border: 0; }
.pin {
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  display: grid; place-items: center;
}
.pin-i { transform: rotate(45deg); font-size: 16px; line-height: 1; }
.pin-wild { background: #2f8f5b; }
.pin-bear { background: #5d4037; }
.pin-hazard { background: #e68a00; }
.leaflet-popup-content { font: 14px -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }
.leaflet-popup-content b { font-weight: 600; }
.leaflet-popup-content a { color: #14804a; }
@media (prefers-color-scheme: dark) {
  .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #1c1c1e; color: #fff; }
  .leaflet-popup-content a { color: #30d158; }
  .leaflet-container a.leaflet-popup-close-button { color: #aaa; }
}

/* ---------------------------------------------------- Learn articles */
.article-intro { margin: 8px 20px 4px; font-size: 16px; line-height: 1.5; color: var(--label); }
.article-sec { margin: 16px 20px; }
.article-sec h3 { font-size: 18px; margin: 0 0 6px; letter-spacing: -0.2px; }
.article-sec p { margin: 0 0 8px; font-size: 15.5px; line-height: 1.5; color: var(--label); }
.article-sec ul, .article-sec ol { margin: 4px 0 8px; padding-left: 22px; }
.article-sec li { font-size: 15.5px; line-height: 1.45; margin-bottom: 6px; color: var(--label); }
.callout { margin: 10px 0; padding: 12px 14px; border-radius: 12px; font-size: 14.5px; line-height: 1.45; color: var(--label); }
.callout-t { font-weight: 700; margin-bottom: 3px; }
.callout-info { background: var(--tint-soft); }
.callout-warn { background: rgba(255, 149, 0, 0.15); }
.callout-danger { background: rgba(255, 59, 48, 0.14); }

/* -------------------------------------------------- Hazard type grid */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 2px 0; }
.type-opt {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated); border-radius: 12px; padding: 12px 14px;
  font-size: 15px; color: var(--label); text-align: left;
  border: 2px solid transparent; transition: border-color 0.12s, background 0.12s;
}
.type-opt .te { font-size: 22px; flex-shrink: 0; }
.type-opt.on { border-color: var(--tint); background: var(--tint-soft); }

/* ------------------------------------------ Reliability / anomaly bars */
.riskbar { display: block; margin-top: 8px; height: 6px; border-radius: 3px; background: var(--fill-strong); overflow: hidden; }
.riskbar-fill { display: block; height: 100%; border-radius: 3px; transition: width 0.4s var(--ease); }
.risk-hi { background: var(--red); }
.risk-mid { background: var(--orange); }
.risk-lo { background: var(--tint); }
.zrow { padding: 9px 16px; }
.zrow-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }

/* ------------------------------------------------------------- Badges */
.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px 16px 8px; }
.badge-card {
  position: relative;
  background: var(--bg-elevated);
  border-radius: var(--radius-card);
  padding: 16px 14px;
  text-align: center;
  overflow: hidden;
}
.badge-card.locked { opacity: 0.5; filter: grayscale(0.9); }
.badge-ico { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.badge-name { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.badge-desc { font-size: 12.5px; color: var(--label-2); margin-top: 3px; line-height: 1.35; }
.badge-chk {
  position: absolute; top: 10px; right: 10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--tint); color: var(--on-tint);
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
@media (min-width: 640px) { .badge-grid { grid-template-columns: 1fr 1fr 1fr; } }

@media (min-width: 640px) {
  #app { max-width: 480px; margin: 0 auto; }
  .tabbar { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .card-grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===================== laptop / desktop layout =====================
   Same iOS design; on a wide screen the bottom tab bar becomes a left sidebar
   and the content column opens up, so it reads like a web app on a laptop. */
@media (min-width: 900px) {
  :root { --sidebar-w: 248px; }
  .tabbar {
    top: 0; bottom: 0; left: 0; right: auto; width: var(--sidebar-w); height: 100dvh;
    max-width: none; transform: none;
    flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 3px;
    padding: calc(20px + env(safe-area-inset-top)) 12px 20px;
    border-top: 0; border-right: 0.5px solid var(--bar-border);
  }
  .tabbar::before {
    content: "on-wildlife"; display: block; font-size: 21px; font-weight: 700;
    letter-spacing: -0.4px; color: var(--label); padding: 4px 14px 18px;
  }
  .tab {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; align-items: center;
    gap: 14px; height: 46px; padding: 0 14px; border-radius: 10px; font-size: 16px; letter-spacing: -0.2px;
  }
  .tab svg { width: 24px; height: 24px; }
  .tab span { font-weight: 500; }
  .tab.active { background: var(--tint-soft); }
  .tab.active span { font-weight: 600; }
  #app { max-width: none; margin: 0; padding-left: var(--sidebar-w); padding-bottom: 0; }
  .screen { max-width: 900px; margin: 0 auto; }
  #app.nav-animating .screen { max-width: none; }   /* transitions overlay full width */
  .map-wrap { height: calc(100dvh - var(--sa-top) - 44px - 52px); }
}
@media (min-width: 1240px) {
  .screen { max-width: 1000px; }
}
@media (min-width: 900px) {
  .sheet { left: var(--sidebar-w); right: 0; margin: 0 auto; max-width: 720px; }
  .toast { left: calc(50% + var(--sidebar-w) / 2); }
}
