/* Sparrow · "Golden Hour"
   Layout: a dark, photo-led app. Sticky translucent header, one centred content column,
   full-bleed photographs where they matter (login, dashboard hero, species pages).
   Dark is the default; [data-theme="light"] is the daytime variant (menu → theme). */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../vendor/fonts/bricolage-grotesque-latin.c47ac31e5437.woff2") format("woff2");
  font-weight: 200 800; font-stretch: 75% 100%; font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("../vendor/fonts/figtree-latin.392aed3eb142.woff2") format("woff2");
  font-weight: 300 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("../vendor/fonts/figtree-italic-latin.6989d9a11b73.woff2") format("woff2");
  font-weight: 300 900; font-style: italic; font-display: swap;
}

:root {
  color-scheme: dark;
  /* Colour: dusk at a waterhole */
  --bg: #14161f;            /* night sky */
  --surface: #1c1f2b;       /* raised panels */
  --surface-2: #252938;     /* inputs, hover */
  --line: #2f3445;
  --text: #f3efe6;          /* warm white */
  --text-2: #b6b1a6;        /* secondary */
  --text-3: #8a867d;        /* captions */
  --amber: #f0a33a;         /* the accent: low sun */
  --amber-text: #f5b65c;    /* amber used as text on --bg */
  --on-amber: #1c1306;
  --danger: #f07a6a;
  --success: #7cc98a;
  --header: rgba(20, 22, 31, 0.82);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  /* Charts and map pins: seen = blue, photographed = amber-orange (fixed order). */
  --series-1: #4b93ea; --series-2: #f0a33a; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #3aa63a; --series-7: #9085e9; --series-8: #e66767;
  --grid: #2a2e3d;
  --map-tiles: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6);

  /* Type */
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --step-4: clamp(2.6rem, 6vw, 4rem);

  /* Space and shape */
  --gap: 1rem;
  --radius: 14px;
  --radius-sm: 9px;
  --content: 76rem;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --line: #dde0e8;
  --text: #171a24;
  --text-2: #565b69;
  --text-3: #767b88;
  --amber: #f0a33a;
  --amber-text: #9a5a00;
  --on-amber: #1c1306;
  --danger: #b4231a;
  --success: #1d7a33;
  --header: rgba(244, 245, 248, 0.85);
  --shadow: 0 1px 2px rgba(23, 26, 36, 0.06), 0 8px 24px rgba(23, 26, 36, 0.06);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --grid: #e3e5eb;
  --map-tiles: none;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--step-0)/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0; }
a { color: var(--amber-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; display: block; }
em.sci, .sci { font-style: italic; color: var(--text-2); }
.muted { color: var(--text-2); }
.eyebrow { font-size: var(--step--1); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.tnum { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.page {
  max-width: var(--content); margin: 0 auto;
  padding-block: 1.75rem 4rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 1.75rem;
}
.page-head { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: end; justify-content: space-between; }
.page-head .lede { color: var(--text-2); margin-top: 0.35rem; }

/* ---------- Header ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--header); }
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--header); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .inner {
  max-width: var(--content); margin: 0 auto; min-height: 3.5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 1.5rem;
}
.wordmark { font: 700 1.45rem/1 var(--font-display); letter-spacing: -0.03em; color: var(--text); }
.wordmark em { font-style: normal; color: var(--amber); }
.wordmark:hover { text-decoration: none; }
.main-nav { display: flex; gap: 0.25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav a {
  color: var(--text-2); padding: 0.45rem 0.75rem; border-radius: 99px; white-space: nowrap; font-weight: 500;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.main-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--amber); }
.account { position: relative; }
.account summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
  color: var(--text-2); padding: 0.35rem 0.5rem; border-radius: 99px;
}
.account summary::-webkit-details-marker { display: none; }
.avatar {
  width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--amber); color: var(--on-amber); font: 700 0.9rem/1 var(--font-display);
}
.account .menu {
  position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 13rem; padding: 0.4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  display: grid;
}
/* Menu items: links and buttons (log out sits in its own small form) look the same. */
.account .menu a, .account .menu button, .account .menu .who {
  display: block; width: 100%; text-align: left; padding: 0.55rem 0.75rem; border-radius: 6px;
  color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; appearance: none;
}
.account .menu a:hover, .account .menu button:hover { background: var(--surface-2); text-decoration: none; }
.account .menu .who { color: var(--text-3); font-size: var(--step--1); cursor: default; }
.account .menu form { margin: 0; }
.account .menu hr { border: 0; border-top: 1px solid var(--line); margin: 0.3rem 0; }
@media (max-width: 44rem) {
  .site-header .inner { flex-wrap: wrap; gap: 0 1rem; padding-block: 0.4rem 0; }
  .main-nav { order: 3; flex-basis: 100%; padding-bottom: 0.4rem; }
  .account { margin-left: auto; }
  .account .name { display: none; }
}

/* ---------- Buttons and form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.6rem; padding: 0 1.1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 var(--step-0)/1 var(--font-body); cursor: pointer; text-decoration: none;
  background: var(--amber); color: var(--on-amber);
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.ghost { background: none; color: var(--text-2); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { min-height: 2rem; padding: 0 0.75rem; font-size: var(--step--1); }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="email"],
input[type="file"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; min-height: 2.6rem;
}
input[type="file"] { padding: 0.45rem; }
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: 0; border-color: transparent; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--amber); }
label { font-weight: 500; }

.form { display: grid; gap: 1rem; }
.form .field { display: grid; gap: 0.35rem; }
.form .field.checkbox { grid-template-columns: auto 1fr; align-items: center; gap: 0.6rem; }
.helptext { font-size: var(--step--1); color: var(--text-3); }
.errorlist { list-style: none; padding: 0; margin: 0; color: var(--danger); font-size: var(--step--1); }

.filters {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end;
  padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.filters label { display: grid; gap: 0.3rem; font-size: var(--step--1); color: var(--text-2); flex: 1 1 9rem; }
.filters label.wide { flex: 2 1 14rem; }
.filters .actions { display: flex; gap: 0.5rem; align-items: center; }

/* ---------- Messages ---------- */
.messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.messages li {
  padding: 0.8rem 1rem; border-radius: var(--radius-sm); background: var(--surface);
  border: 1px solid var(--line); border-left: 4px solid var(--amber);
}
.messages li.success { border-left-color: var(--success); }
.messages li.error { border-left-color: var(--danger); }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: 0.75rem; }
.tile {
  display: grid; gap: 0.15rem; align-content: start; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text-2); font-size: var(--step--1);
}
.tile strong { font: 700 var(--step-3)/1.05 var(--font-display); color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile.accent strong { color: var(--amber-text); }
a.tile:hover { border-color: var(--amber); text-decoration: none; }
a.tile .go { color: var(--amber-text); font-weight: 600; }

/* ---------- Cards, chips, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.5rem; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600; border: 1px solid var(--line); color: var(--text-2); white-space: nowrap;
}
.chip.amber { border-color: transparent; background: color-mix(in srgb, var(--amber) 22%, transparent); color: var(--amber-text); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th {
  text-align: left; font-size: var(--step--1); font-weight: 600; color: var(--text-3);
  letter-spacing: 0.04em; text-transform: uppercase; padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.species-cell { display: flex; align-items: center; gap: 0.75rem; min-width: 14rem; }
.species-cell .thumb { width: 2.75rem; height: 2.75rem; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.species-cell .names { display: grid; line-height: 1.25; }
.species-cell .names a { color: var(--text); font-weight: 600; }
.species-cell .names .sci { font-size: var(--step--1); }

/* The photographed toggle: a pill that is amber when on. */
.toggle {
  display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2rem; padding: 0 0.75rem;
  border-radius: 99px; border: 1px solid var(--line); background: none; color: var(--text-3);
  font: 600 var(--step--1)/1 var(--font-body); cursor: pointer; white-space: nowrap;
}
.toggle:hover { border-color: var(--amber); color: var(--text); }
.toggle.on { background: var(--amber); border-color: transparent; color: var(--on-amber); }
.toggle svg { width: 1rem; height: 1rem; }
form.inline { margin: 0; }
.htmx-request .toggle, .toggle.htmx-request { opacity: 0.6; }

.pagination { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: center; color: var(--text-2); }

/* ---------- Photos ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius); min-height: 15rem;
  display: flex; align-items: end; background: var(--surface-2); isolation: isolate;
}
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; z-index: -2; }
/* Shade under the caption only (bottom-left), so white text stays readable on bright photos
   such as a sky or sand, while the rest of the photo stays clear. */
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgba(14, 15, 22, 0.78) 0%, rgba(14, 15, 22, 0.45) 35%, transparent 65%),
    linear-gradient(0deg, rgba(14, 15, 22, 0.9) 0%, rgba(14, 15, 22, 0.35) 55%, transparent 85%);
}
.hero .caption { text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45); }
.hero .caption { padding: 1.5rem 1.75rem; display: grid; gap: 0.3rem; color: #f3efe6; }
.hero .caption .eyebrow { color: rgba(243, 239, 230, 0.92); }
.hero .caption h2 { font-size: var(--step-4); letter-spacing: -0.03em; color: #fff; }
.hero .caption .sci { color: rgba(243, 239, 230, 0.8); }
.hero .caption a { color: #fff; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 0.75rem; }
.gallery figure { margin: 0; display: grid; gap: 0.4rem; }
.gallery img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.gallery figcaption { font-size: var(--step--1); color: var(--text-2); }
.gallery figcaption a { color: var(--text); font-weight: 600; }
.gallery figcaption .species-name { font-size: 0.95rem; }

/* ---------- Detail lists ---------- */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1.5rem; margin: 0; }
.details dt { color: var(--text-3); font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 0.15rem; }
.details dd { margin: 0; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1.25rem; align-items: start; }

/* ---------- Charts ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1rem; }
.chart { margin: 0; min-width: 0; display: grid; gap: 0.75rem; }
.chart.wide { grid-column: 1 / -1; }
.chart figcaption { font: 700 var(--step-1)/1.2 var(--font-display); letter-spacing: -0.01em; }
.chart-box { position: relative; height: 18rem; }
.chart details { font-size: var(--step--1); color: var(--text-2); }
.chart details summary { cursor: pointer; }
.chart details table { margin-top: 0.5rem; max-height: 20rem; display: block; overflow-y: auto; }

.year-switch { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.year-switch a {
  padding: 0.35rem 0.85rem; border-radius: 99px; border: 1px solid var(--line); color: var(--text-2); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.year-switch a:hover { color: var(--text); border-color: var(--text-3); text-decoration: none; }
.year-switch a[aria-current="true"] { background: var(--amber); border-color: transparent; color: var(--on-amber); }

/* ---------- Map ---------- */
.map { height: 72vh; min-height: 22rem; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: var(--surface-2); }
.map .leaflet-tile-pane { filter: var(--map-tiles); }
/* Leaflet's own stylesheet loads after this one, so these overrides are scoped to .map
   to win on specificity (otherwise popups turn white with light text in the dark theme). */
.map.leaflet-container { font-family: var(--font-body); }
.map .leaflet-popup-content-wrapper, .map .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.map .leaflet-popup-content { margin: 0.85rem 1.1rem; display: grid; gap: 0.3rem; font-size: 0.9rem; line-height: 1.4; }
.map .leaflet-popup-content a { color: var(--amber-text); }
.map a.leaflet-popup-close-button { color: var(--text-3); }
.map .leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--text-3); }
.map .leaflet-control-attribution a { color: var(--text-2); }
.map .leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--line); }
.map .leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-marker-icon.cluster {
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: color-mix(in srgb, var(--amber) 88%, black); color: var(--on-amber); font: 700 0.8rem/1 var(--font-body);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 30%, transparent);
}
.map .leaflet-popup-content a.popup-title { font: 700 1.1rem/1.2 var(--font-display); color: var(--text); }
.map .popup { display: grid; gap: 0.35rem; justify-items: start; }
.popup-details { color: var(--text-2); }
.legend { display: inline-flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font-size: var(--step--1); color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 50%; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; min-height: 100dvh; position: relative; isolation: isolate;
  display: grid; align-items: center; background: var(--bg);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.login > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.login::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(14, 15, 22, 0.94) 0%, rgba(14, 15, 22, 0.7) 38%, rgba(14, 15, 22, 0.05) 75%);
}
.login .panel { width: min(100%, 24rem); margin-left: clamp(0px, 6vw, 6rem); display: grid; gap: 1.25rem; color: #f3efe6; }
.login .wordmark { font-size: clamp(3.2rem, 9vw, 5rem); line-height: 0.9; color: #f3efe6; }
.login .tagline { color: rgba(243, 239, 230, 0.75); font-size: var(--step-1); }
.login label { color: rgba(243, 239, 230, 0.85); }
.login input { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16); color: #fff; }
.login .errorlist, .login .errornote { color: #ffb3a8; }
.login .credit {
  position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: 1.25rem;
  text-align: right; color: rgba(255, 255, 255, 0.85); font-size: var(--step--1); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}
.login .credit b { display: block; font: 700 var(--step-1)/1.2 var(--font-display); color: #fff; }
@media (max-width: 44rem) {
  .login { align-items: end; padding-bottom: 5rem; }
  .login::before { background: linear-gradient(0deg, rgba(14, 15, 22, 0.95) 0%, rgba(14, 15, 22, 0.75) 50%, rgba(14, 15, 22, 0.1) 85%); }
  .login .panel { margin: 0 auto; }
}

/* Phones: tables marked .stack become one small card per row, with the action on the right. */
@media (max-width: 44rem) {
  .stack table, .stack tbody, .stack td { display: block; }
  .stack thead { display: none; }
  .stack tr {
    display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0.75rem; align-items: center;
    grid-template-areas: "species species" "date toggle" "trip toggle" "notes notes";
    padding: 0.85rem 0.9rem; border-bottom: 1px solid var(--line);
  }
  .stack tbody tr:last-child { border-bottom: 0; }
  .stack td { padding: 0; border: 0; }
  .stack .c-species { grid-area: species; }
  .stack .c-species .species-cell { min-width: 0; }
  .stack .c-date { grid-area: date; font-size: var(--step--1); }
  .stack .c-trip { grid-area: trip; font-size: var(--step--1); color: var(--text-2); }
  .stack .c-toggle { grid-area: toggle; justify-self: end; }
  .stack .c-notes { grid-area: notes; font-size: var(--step--1); }
  .stack .c-notes:empty, .stack.life .c-num, .stack.life .c-last, .stack.life .c-count { display: none; }
  .stack.life tr { grid-template-areas: "species species" "date toggle"; }
  .stack td[colspan] { grid-column: 1 / -1; }
}

/* Small screens: tighten tiles. */
@media (max-width: 30rem) {
  .tile strong { font-size: var(--step-2); }
  .hero .caption { padding: 1.1rem 1.2rem; }
}

/* ---------- Lightbox ---------- */
.lightbox {
  border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none;
  background: rgba(10, 11, 16, 0.94); color: #f3efe6;
}
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; place-items: center; }
.lightbox::backdrop { background: rgba(10, 11, 16, 0.94); }
.lightbox img { max-width: calc(100vw - 7rem); max-height: calc(100dvh - 6rem); object-fit: contain; border-radius: 6px; }
.lightbox-caption { padding: 0.75rem 1rem 1.25rem; font-size: var(--step--1); color: rgba(243, 239, 230, 0.85); text-align: center; }
.lightbox button {
  position: absolute; width: 3rem; height: 3rem; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.1); color: #fff; font: 400 2rem/1 var(--font-body);
}
.lightbox button:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox-prev { left: max(1rem, env(safe-area-inset-left, 0px)); top: 50%; transform: translateY(-50%); }
.lightbox-next { right: max(1rem, env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-50%); }
.lightbox-close { right: max(1rem, env(safe-area-inset-right, 0px)); top: calc(1rem + env(safe-area-inset-top, 0px)); }
.lightbox.single .lightbox-prev, .lightbox.single .lightbox-next { display: none; }
@media (max-width: 44rem) {
  .lightbox img { max-width: 100vw; border-radius: 0; }
  .lightbox-prev, .lightbox-next { top: auto; bottom: 3.5rem; transform: none; }
}
.gallery figcaption .remove-photo { display: inline; }
.photo-count { display: inline-flex; align-items: center; gap: 0.25rem; margin-left: 0.4rem; color: var(--text-2); font-size: var(--step--1); white-space: nowrap; }
.photo-count svg { width: 0.95rem; height: 0.95rem; }
.upload { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; }
.upload .field { flex: 1 1 16rem; display: grid; gap: 0.35rem; }
input[type="file"]::file-selector-button {
  margin-right: 0.75rem; padding: 0.4rem 0.9rem; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: 600 var(--step--1)/1.2 var(--font-body); cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--amber); }

/* ---------- Photos to sort ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.sort-list { display: grid; gap: 1rem; }
.sort-card { display: grid; grid-template-columns: minmax(0, 22rem) 1fr; gap: 1.25rem; padding: 1rem; }
.sort-image img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.sort-body { display: grid; gap: 0.75rem; align-content: start; min-width: 0; }
.sort-file { display: block; color: var(--text-3); font-size: var(--step--1); overflow-wrap: anywhere; }
.sort-form { display: grid; gap: 0.75rem; }
.picks { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pick {
  display: grid; text-align: left; gap: 0.05rem; padding: 0.45rem 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 600 0.9rem/1.25 var(--font-body); cursor: pointer;
}
.pick small { font-weight: 400; color: var(--text-3); font-size: 0.75rem; }
.pick:hover { border-color: var(--amber); }
.pick-done { color: var(--amber-text); font-weight: 700; }
.sort-search { display: flex; gap: 0.5rem; max-width: 26rem; }
.sort-search input { flex: 1; min-width: 0; } /* inputs have a built-in minimum width that would widen the card */
.sort-body > *, .sort-form > * { min-width: 0; }
.sort-actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.sort-login { display: inline-flex; gap: 0.4rem; align-items: center; font-weight: 400; color: var(--text-2); font-size: var(--step--1); margin-right: auto; }
.sort-done { display: flex; gap: 0.9rem; align-items: center; padding: 0.75rem 1rem; color: var(--text-2); }
.sort-done .thumb { width: 3.5rem; height: 2.5rem; object-fit: cover; border-radius: 6px; }
.sort-done strong { color: var(--text); }
@media (max-width: 44rem) { .sort-card { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Dashboard: last trip ---------- */
.last-trip { display: grid; gap: 1rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.last-trip .tile { background: var(--bg); }
.last-trip h2 { font-size: var(--step-3); }
.lifers { display: grid; gap: 0.4rem; }
.lifers p { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.lifers .chip { font-size: 0.8rem; padding: 0.2rem 0.6rem; }
.lifers .chip:hover { text-decoration: none; filter: brightness(1.1); }
.last-trip-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.last-trip-body.no-photos { grid-template-columns: minmax(0, 1fr); }
.last-trip-body .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.map-medium { height: 22rem; min-height: 0; }
@media (max-width: 52rem) {
  .last-trip-body { grid-template-columns: minmax(0, 1fr); }
  .map-medium { height: 18rem; }
}

/* ---------- Trips ---------- */
.plain-link { color: inherit; }
.phone-only { display: none; }
@media (max-width: 44rem) { .phone-only { display: inline; } }
.btn.danger { background: var(--danger); color: #fff; }
.delete-list, .change-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.5rem; }
.chips-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
@media (max-width: 44rem) {
  .stack.trips tr { grid-template-areas: "species species" "date toggle" "trip toggle"; }
  .stack.trips .c-count, .stack.trips .c-last { display: none; }
}
