/* ============================================================
   Ontario Fish Finder — UI shell
   Palette roles follow the validated reference palette:
   categorical slots for thermal regime, blue sequential ramp
   for depth, reserved highlight/selection hues.
   ============================================================ */

:root {
  /* surfaces & ink (light) */
  --surface-1: #fcfcfb;
  --surface-2: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --hairline: #e1e0d9;
  --border-ring: rgba(11, 11, 11, 0.10);
  --shadow: 0 2px 12px rgba(11, 11, 11, 0.14);

  /* data colors — validated categorical set */
  --therm-cold: #2a78d6;   /* blue   */
  --therm-cool: #1baf7a;   /* aqua   */
  --therm-warm: #eb6834;   /* orange */
  --therm-unknown: #898781;
  --match: #eda100;        /* species-filter highlight */
  --selected: #e34948;     /* selected waterbody outline */
  --stocking: #4a3aa7;     /* stocking markers */

  /* categorical series slots (validated fixed order — charts assign 1..8, never cycle) */
  --cat-1: #2a78d6;  /* blue */
  --cat-2: #1baf7a;  /* aqua */
  --cat-3: #eda100;  /* yellow */
  --cat-4: #008300;  /* green */
  --cat-5: #4a3aa7;  /* violet */
  --cat-6: #e34948;  /* red */
  --cat-7: #e87ba4;  /* magenta */
  --cat-8: #eb6834;  /* orange */

  /* blue sequential ramp (depth) */
  --bathy-1: #86b6ef;
  --bathy-2: #5598e7;
  --bathy-3: #2a78d6;
  --bathy-4: #1c5cab;
  --bathy-5: #104281;
  --bathy-6: #0d366b;

  --accent: #2a78d6;
  --radius: 10px;
  --topbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --surface-2: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --hairline: #2c2c2a;
    --border-ring: rgba(255, 255, 255, 0.10);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.45);

    --therm-cold: #3987e5;
    --therm-cool: #199e70;
    --therm-warm: #d95926;
    --match: #c98500;
    --selected: #e66767;
    --stocking: #9085e9;
    --accent: #3987e5;

    /* categorical slots stepped for the dark surface (same hues, not a new palette) */
    --cat-1: #3987e5;
    --cat-2: #199e70;
    --cat-3: #c98500;
    --cat-4: #008300;
    --cat-5: #9085e9;
    --cat-6: #e66767;
    --cat-7: #d55181;
    --cat-8: #d95926;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--surface-2);
}

/* Header height is content-driven (it wraps to two rows on mobile);
   the map pane simply takes whatever height remains. */
body { display: flex; flex-direction: column; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ---------- top bar ---------- */

.topbar {
  min-height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--hairline);
  position: relative;
  z-index: 1100;
}

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-icon { font-size: 28px; }
.brand-text h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.brand-text p { font-size: 11px; margin: 0; color: var(--text-muted); }

.controls {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.search-wrap, .species-wrap { position: relative; }

.search-wrap input, .species-wrap input {
  width: 300px;
  max-width: 42vw;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  outline: none;
}
.search-wrap input:focus, .species-wrap input:focus { border-color: var(--accent); }
.species-wrap input { width: 230px; padding-right: 28px; }

.chip-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  border: 0; background: none;
  font-size: 16px; line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
}
.chip-clear:hover { color: var(--text-primary); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1200;
}
.search-results li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.search-results li:hover, .search-results li.active { background: var(--surface-2); }
.search-results .sr-name { font-weight: 600; }
.search-results .sr-sub { color: var(--text-muted); font-size: 11px; }
.search-results .sr-none { color: var(--text-muted); cursor: default; }

/* ---------- map & floating cards ---------- */

.app {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#map { position: absolute; inset: 0; background: #b8d4e3; }

/* Dark basemap loads in dark mode — don't flash daylight water behind it. */
@media (prefers-color-scheme: dark) {
  #map { background: #0d0d0d; }
}

.layers-card, .legend-card {
  position: absolute;
  left: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  z-index: 1000;
  font-size: 12px;
  width: 200px;
}
.layers-card { top: 240px; } /* opens below the zoom + tools + base-map + 🗂 control stack */
.legend-card { bottom: 24px; }

/* Collapsed behind the 🗂 button on desktop; the selector is scoped to the
   map (.app) so the card is always visible once moved into the ☰ sheet. */
.app > .layers-card.card-hidden { display: none; }
.leaflet-bar a.layers-open { background: var(--accent); }

.layers-card h2, .legend-card h2 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.layers-card label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  cursor: pointer;
  color: var(--text-secondary);
}
.layers-card input { accent-color: var(--accent); margin: 0; }

.swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 4px;
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
}
.swatch-lakes    { background: var(--therm-cold); opacity: 0.75; }
.swatch-bathy    { background: linear-gradient(90deg, var(--bathy-1), var(--bathy-6)); }
.swatch-stocking { background: var(--stocking); border-radius: 50%; }
.swatch-fmz      { border: 2px dashed var(--text-secondary); background: none; }
.swatch-sanctuary { background: none; font-size: 13px; }

.legend-list { list-style: none; margin: 0; padding: 0; }
.legend-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  color: var(--text-secondary);
}
.legend-list .legend-sep { margin-top: 6px; border-top: 1px solid var(--hairline); padding-top: 6px; }

.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--c);
  flex: 0 0 auto;
}
.dot.ring { background: transparent; border: 3px solid var(--c); }

.legend-bathy { margin-top: 8px; }
.bathy-ramp {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--bathy-1), var(--bathy-2), var(--bathy-3),
    var(--bathy-4), var(--bathy-5), var(--bathy-6));
}
.bathy-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- status pill ---------- */

.status-pill {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-1);
  color: var(--text-secondary);
  border: 1px solid var(--border-ring);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 1000;
  max-width: 60vw;
  text-align: center;
  transition: opacity 0.25s;
}
.status-pill.loading::after {
  content: "…";
  display: inline-block;
  animation: pulse 1s infinite;
}
.status-pill.error { color: var(--selected); }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- details panel ---------- */

/* Explicit display on .panel would otherwise defeat the hidden attribute. */
.panel[hidden] { display: none; }

.panel {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 24px;
  width: 380px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1050;
  overflow: hidden;
}

.panel-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  z-index: 2;
}
.panel-close:hover { color: var(--text-primary); }

.panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 16px 8px;
}

.panel-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--hairline);
  padding: 8px 16px;
  font-size: 10.5px;
  color: var(--text-muted);
}
.panel-footer p { margin: 0; }
.panel-footer a { color: var(--accent); }

.wb-title { margin: 0 24px 2px 0; font-size: 20px; line-height: 1.25; }
.fav-btn {
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--match);
  cursor: pointer;
  vertical-align: -2px;
  padding: 0 2px;
}

.fav-wrap { position: relative; }
.fav-open {
  height: 100%;
  min-height: 34px;
  padding: 0 12px;
  font-size: 16px;
  color: var(--match);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  cursor: pointer;
}
.fav-open:hover { border-color: var(--match); }
.fav-list { min-width: 240px; right: auto; }

/* Trip planner dropdown (header) */
.trip-wrap { position: relative; }
.trip-open { color: var(--text-primary); }
.trip-panel { right: 0; left: auto; min-width: 300px; }
.trip-panel ul { list-style: none; margin: 0; padding: 0; }
.trip-title { margin: 4px 6px 6px; font-size: 12px; color: var(--text-muted); }
.trip-km { float: right; font-weight: 400; color: var(--text-muted); font-size: 12px; }

.exc-box {
  border: 1px solid var(--hairline);
  border-left: 3px solid #ec835a; /* status "serious" — reserved, not a series color */
  border-radius: 8px;
  background: var(--surface-2);
  padding: 4px 10px;
  margin-bottom: 4px;
}
.exc-row { font-size: 12px; color: var(--text-secondary); margin: 8px 0; }
.exc-row b { display: block; color: var(--text-primary); }

.regs-more { margin-top: 8px; font-size: 12px; }
.regs-more summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  margin-bottom: 6px;
}
.wb-alias { margin: 0 0 8px; font-size: 12px; color: var(--text-muted); font-style: italic; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--text-secondary);
  background: var(--surface-2);
  text-decoration: none;
}
.badge-thermal { border-color: var(--c); color: var(--c); background: transparent; }
a.badge-fmz:hover { border-color: var(--accent); color: var(--accent); }

/* Driving directions (native maps handoff) */
a.badge-dir { border-color: var(--accent); color: var(--accent); background: transparent; }
a.badge-dir:hover { background: var(--accent); color: #fcfcfb; }
a.badge-dir #dir-note { font-weight: 400; }
.dir-mini { text-decoration: none; margin-left: 2px; font-size: 12px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 16px;
}
.stat-tile {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 10px;
}
.stat-tile .v { font-size: 16px; font-weight: 700; }
.stat-tile .v small { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.stat-tile .k { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.section-h {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 16px 0 8px;
}
.section-h .count { color: var(--text-secondary); }

.species-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--text-secondary);
  background: var(--surface-2);
}
.sp-chip.game {
  border-color: var(--accent);
  color: var(--text-primary);
  font-weight: 600;
}
.sp-chip.game::before { content: "🎣 "; font-size: 11px; }
.sp-none { color: var(--text-muted); font-size: 13px; }

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.stock-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 6px;
  border-bottom: 1px solid var(--hairline);
}
.stock-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-secondary);
}
.stock-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Live conditions (weather / water level / solunar) */
.cond-row { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0; line-height: 1.6; }
.hint-inline { color: var(--text-muted); font-size: 11px; }
.solunar-chip { font-variant-numeric: tabular-nums; }
.sp-chip.solunar-chip.active {
  border-color: var(--match);
  color: var(--text-primary);
  font-weight: 600;
}

/* Community catches (iNaturalist) */
.sp-chip.inat-new { border-style: dashed; border-color: var(--text-muted); }
.inat-count { color: var(--text-muted); font-size: 10px; }

/* Stocking trend chart (hand-rolled SVG) */
.stock-chart { margin: 4px 0 8px; }
.stock-chart svg { display: block; width: 100%; height: auto; }
.stock-chart .tick {
  font-size: 8.5px;
  fill: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.legend-chip { font-size: 11px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }

/* Compare favourites & similar lakes */
.compare-scroll { overflow-x: auto; }
.compare-scroll .stock-table th { white-space: nowrap; }
.compare-scroll .stock-table th a { color: var(--accent); cursor: pointer; }
.similar-list { list-style: none; margin: 4px 0; padding: 0; }
.similar-list li { padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.similar-list li:hover { background: var(--surface-2); }
.similar-list .sr-name { font-weight: 600; }
.similar-list .sr-sub { color: var(--text-muted); font-size: 11px; }
.fav-compare { border-bottom: 1px solid var(--hairline); color: var(--accent); font-weight: 600; }

/* Consumption advisories: tables can run to 100+ rows for big lakes —
   cap the height and scroll inside the section. */
.adv-scroll { max-height: 260px; overflow-y: auto; border-bottom: 1px solid var(--hairline); }
.adv-scroll .stock-table thead th { position: sticky; top: 0; background: var(--surface-1); }
.adv-table td { vertical-align: top; }
.adv-zero { color: #e34948; font-weight: 700; }

.ext-links { margin: 14px 0 6px; font-size: 12px; }
.ext-links a { color: var(--accent); }

.hint { color: var(--text-muted); font-size: 12px; margin: 6px 0; }

/* ---------- waypoints & measure tool ---------- */

.waypoint-icon { font-size: 18px; }

.wp-form b { display: block; font-size: 13px; margin-bottom: 6px; }
.wp-form input {
  width: 100%;
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  margin-bottom: 6px;
}
.wp-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-primary);
  cursor: pointer;
}
.wp-btn:hover { border-color: var(--accent); color: var(--accent); }
.wp-del { margin-top: 6px; }
.wp-del:hover { border-color: var(--selected); color: var(--selected); }

.fav-sep {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: default;
  border-top: 1px solid var(--hairline);
  margin-top: 4px;
}
.search-results li.fav-sep:hover { background: none; }

.leaflet-bar a.measure-on { background: var(--accent); }
.leaflet-container.measuring,
.measuring .leaflet-interactive { cursor: crosshair !important; }
.measure-tip {
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border-ring);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- catch log ---------- */

.catch-actions { margin: 8px 0 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.tool-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }

.catch-form { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.catch-form[hidden] { display: none; }
.catch-form input {
  flex: 1 1 45%;
  min-width: 120px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 6px;
}
.catch-form input:focus { border-color: var(--accent); outline: none; }

.catch-del {
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.catch-del:hover { color: var(--selected); }

/* ---------- species technique cards ---------- */

.sp-chip.has-card { cursor: pointer; }
.sp-chip.has-card:hover, .sp-chip.has-card:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.sp-card {
  position: relative;
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 26px 8px 10px;
  margin: 8px 0 4px;
}
.sp-card h4 { margin: 0 0 4px; font-size: 13px; }
.sp-card-row { font-size: 12px; color: var(--text-secondary); margin: 4px 0; line-height: 1.5; }
.sp-card-row b { color: var(--text-primary); }
.sp-card-close {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.sp-card-close:hover { color: var(--text-primary); background: var(--surface-1); }

/* Print button shares .fav-btn sizing but keeps neutral ink. */
.print-btn { color: var(--text-muted); font-size: 16px; }
.print-btn:hover { color: var(--text-primary); }

/* ---------- Leaflet chrome tweaks ---------- */

.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-bar a {
  background: var(--surface-1);
  color: var(--text-primary);
}
.leaflet-popup-content { font-size: 12.5px; line-height: 1.45; }
.leaflet-popup-content b { font-size: 13px; }
.leaflet-bar a { border-bottom-color: var(--hairline); }
.leaflet-control-attribution { font-size: 10px; }

.access-icon {
  font-size: 18px;
  line-height: 22px;
  text-align: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

/* FMZ zone-number labels (non-interactive divIcons at zone centroids) */
.fmz-label {
  font-size: 15px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: var(--text-primary);
  text-shadow: 0 0 3px var(--surface-1), 0 0 6px var(--surface-1), 0 0 9px var(--surface-1);
  pointer-events: none;
}

/* ---------- mobile sheet (hidden on desktop) ---------- */

.menu-open { display: none; font-size: 18px; color: var(--text-primary); }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.4);
  z-index: 1290;
}
.sheet-backdrop[hidden], .mobile-sheet[hidden] { display: none; }

.mobile-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 75%;
  overflow-y: auto;
  background: var(--surface-1);
  border-top: 1px solid var(--border-ring);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  z-index: 1300;
  padding: 6px 16px 20px;
}
.sheet-head { position: relative; padding-top: 10px; }
.sheet-grab {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--hairline);
}
.sheet-head h2, .sheet-h {
  margin: 8px 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
#sheet-content section { margin-bottom: 14px; }

/* Cards relocated into the sheet drop their floating-on-map chrome. */
.mobile-sheet .layers-card, .mobile-sheet .legend-card {
  position: static;
  width: auto;
  max-width: none;
  border: 0;
  box-shadow: none;
  padding: 0;
}
.mobile-sheet .layers-card label { padding: 8px 0; }  /* comfortable touch rows */
.mobile-sheet .species-wrap { display: block; }
.mobile-sheet .species-wrap input { width: 100%; max-width: none; min-height: 42px; }
.mobile-sheet .search-results { position: static; box-shadow: none; border: 0; }

/* ---------- mobile ---------- */

@media (max-width: 820px) {
  .topbar { min-height: 0; flex-wrap: wrap; padding: 8px 12px; gap: 8px 6px; align-items: center; }
  .brand { margin-right: auto; }
  .brand-text p { display: none; }

  /* Promote the control cluster's children to topbar flex items:
     row 1 = brand + ★ 🧭 ☰ buttons, row 2 = full-width search. */
  .controls { display: contents; }
  .menu-open { display: block; }
  .fav-open { height: auto; min-height: 40px; min-width: 44px; }
  .search-wrap { flex: 1 1 100%; order: 10; }
  .search-wrap input { width: 100%; max-width: none; min-height: 40px; }

  /* Header dropdowns become full-width sheets under the bar
     (--topbar-actual tracks the real, content-driven header height). */
  .search-results, .fav-list, .trip-panel {
    position: fixed;
    left: 8px; right: 8px;
    top: calc(var(--topbar-actual, var(--topbar-h)) + 4px);
    min-width: 0;
    max-height: 50vh;
  }

  .panel {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-width: none;
    max-height: 62%;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  /* grab handle on the details bottom sheet */
  .panel::before {
    content: "";
    position: absolute;
    top: 6px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    border-radius: 2px;
    background: var(--hairline);
    z-index: 3;
  }
  .panel-body { padding-top: 20px; }

  /* Layers & legend live in the ☰ sheet on mobile, not on the map. */
  .app > .layers-card, .app > .legend-card { display: none; }

  .status-pill { max-width: 86vw; top: 8px; }
}

/* ---------- printable lake sheet ---------- */
/* The open details panel becomes a clean one-pager: species, seasons &
   limits, advisories and solunar. Map chrome and interactive bits go away.
   !important throughout: paper width can be under the 820px mobile
   breakpoint, and those positioning rules must never win in print. */

@media print {
  :root {
    /* Always print the light palette, whatever the OS theme. */
    --surface-1: #ffffff;
    --surface-2: #ffffff;
    --text-primary: #000000;
    --text-secondary: #333333;
    --text-muted: #666666;
    --hairline: #cccccc;
    --border-ring: #cccccc;
    --shadow: none;
  }

  body { display: block !important; height: auto !important; background: #fff !important; }

  .topbar, #map, .layers-card, .legend-card, .status-pill,
  .mobile-sheet, .sheet-backdrop, .leaflet-container,
  .panel-close, .fav-btn, .print-btn,
  #community-section, #stocking-wrap, #similar-section, #catchlog-section,
  .ext-links {
    display: none !important;
  }

  .app { position: static !important; }

  .panel {
    position: static !important;
    display: block !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
  .panel[hidden] { display: none !important; }
  .panel::before { display: none !important; }
  .panel-body { overflow: visible !important; padding: 0 !important; }

  /* Advisory tables lose their scroll cage and print in full. */
  .adv-scroll { max-height: none !important; overflow: visible !important; border-bottom: 0; }

  .stats-grid, .stock-table tr, .exc-box, .sp-card { break-inside: avoid; }
  .section-h { break-after: avoid; }

  a { color: inherit; text-decoration: none; }
}
