.lake-popup {
  box-sizing: border-box;
  min-width: min(260px, calc(100vw - 5rem));
  max-width: min(320px, calc(100vw - 5rem));
  font-size: 0.9rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.regulatory-assessment__provenance,
.regulatory-assessment__decision p,
.regulatory-assessment__decision a {
  overflow-wrap: anywhere;
}

.regulatory-assessment__provenance {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.regulatory-assessment__unit > h4 {
  margin: 0.85rem 0 0.35rem;
}

.regulatory-assessment__unit ul {
  margin: 0;
  padding-left: 1.15rem;
}

.regulatory-assessment__decision {
  margin-bottom: 0.75rem;
}

.regulatory-assessment__decision h4,
.regulatory-assessment__decision p {
  margin: 0.2rem 0;
}

.assessment-status--impaired {
  color: #a13024;
  font-weight: 700;
}

/* Desktop popups carry many sections (fish, stocking, water quality,
   satellite, launches); cap their height and scroll internally so the lake
   name and close button always stay on screen. */
.leaflet-popup-content {
  max-height: min(60vh, 480px);
  max-width: calc(100vw - 4rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lake-popup .popup-section,
.lake-popup dl,
.lake-popup dt,
.lake-popup dd,
.lake-popup li,
.lake-popup p,
.lake-popup a {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.lake-popup a {
  overflow-wrap: anywhere;
}

/* The popup's <header> matches the global page-header rule; reset it so the
   lake name and location line align with the sections below */
.lake-popup header {
  padding: 0;
  background: none;
  border-bottom: none;
  display: block;
}

/* Inside the scrollable desktop popup the lake name stays pinned while the
   sections scroll beneath it. Scoped to Leaflet popups: the mobile sheet has
   its own sticky title bar. Solid backgrounds match the popup wrapper in
   both themes so scrolled content cannot show through. */
.leaflet-popup .lake-popup header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  padding-bottom: 0.35rem;
}

body.theme-dark .leaflet-popup .lake-popup header {
  background: #111c2b;
}

.lake-popup header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent);
}

.lake-popup .location-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.lake-popup .location-row span:empty {
  display: none;
}

.lake-popup dl {
  margin: 0.75rem 0;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 0.35rem 0.75rem;
}

.lake-popup dt {
  font-weight: 600;
  color: var(--text);
}

.lake-popup dd {
  margin: 0;
  color: var(--text-muted);
}

.lake-popup .evidence-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.35rem;
  border: 1px solid var(--text-muted);
  border-radius: 0.6rem;
  font-size: 0.7rem;
  line-height: 1.25rem;
  color: var(--text-muted);
  background: none;
  vertical-align: middle;
  white-space: nowrap;
}

/* Step 8 context notes: a neutral list in its own default-collapsed
   disclosure immediately after At a glance. No alert styling or live
   region — factual supporting context, not warnings. Evidence actions
   honor the 32 px dense-secondary touch floor. */

.lake-popup .context-notes__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.lake-popup .context-note__text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.lake-popup .context-notes__failure {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.lake-popup .context-note__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.lake-popup .context-note__jump {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 0.6rem;
  background: none;
  color: var(--accent);
  font-size: 0.75rem;
  cursor: pointer;
}

.lake-popup .context-note__jump:hover,
.lake-popup .context-note__jump:focus-visible {
  background: var(--accent);
  color: #fff;
}

/* Water-quality evidence overview: links the three sibling disclosures.
   Same neutral badge presentation as the at-a-glance inventory. */
.lake-popup .wq-evidence h3 {
  margin: 0;
  font-size: 0.95rem;
}

.lake-popup .wq-evidence__list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.lake-popup .wq-evidence__list li {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.lake-popup .wq-evidence__label {
  font-weight: 600;
  margin-right: 0.35rem;
}

.lake-popup .wq-evidence__label::after {
  content: ':';
}

.lake-popup .wq-evidence__value {
  color: var(--text-muted);
}

.lake-popup .wq-evidence__note {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Fish surveys & management: one domain section, two separately badged
   subsections, plus the combined per-species timeline. */
.lake-popup .fish-management__title {
  margin: 0;
  font-size: 0.95rem;
}

.lake-popup .fishery__survey-age {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lake-popup .species-chronology__intro {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lake-popup .species-chronology__species {
  margin: 0.5rem 0 0.15rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.lake-popup .species-chronology__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.lake-popup .species-chronology__year {
  font-weight: 600;
  margin-right: 0.4rem;
}

.lake-popup .species-chronology__list .evidence-badge {
  margin-right: 0.4rem;
}

/* UNIFORM section chrome: every top-level popup block is the same card,
   so no domain looks styled differently from its siblings. Disclosures
   nested inside a section (the fishery subsections) take a lighter card
   on the base surface so hierarchy reads as containment, not emphasis. */
.lake-popup > .popup-section {
  margin-top: 0.6rem;
  padding: 0.15rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-alt);
}

.lake-popup > .popup-section[open] {
  padding-bottom: 0.75rem;
}

.lake-popup .popup-section .popup-section {
  margin-top: 0.6rem;
  padding: 0.1rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface);
}

.lake-popup .popup-section .popup-section[open] {
  padding-bottom: 0.6rem;
}

.lake-popup .popup-section[hidden] {
  display: none;
}

/* Collapsible popup sections: each keeps its card background for separation,
   but the heading row is now a <summary> that expands/collapses the body —
   the same disclosure affordance as the boat-launches section. */
.lake-popup .popup-section > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: clip;
  cursor: pointer;
  list-style: none;
  user-select: none;
  /* 44px touch target: these summaries are now the primary way to reach
     almost all popup detail content. */
  min-height: 2.75rem;
  padding-block: 0.35rem;
}
.lake-popup .popup-section > summary::-webkit-details-marker {
  display: none;
}
.lake-popup .popup-section > summary h3 {
  margin: 0;
}
/* Chevron on the right, rotating between collapsed (down) and open (up). */
.lake-popup .popup-section > summary::after {
  content: "";
  box-sizing: border-box;
  flex: 0 0 0.5rem;
  margin-left: auto;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
  opacity: 0.55;
  transition: transform 0.15s ease;
}
.lake-popup .popup-section[open] > summary::after {
  transform: rotate(-135deg);
}
/* Space between the heading and the revealed body only while open. */
.lake-popup .popup-section[open] > summary {
  margin-bottom: 0.5rem;
}
.lake-popup .popup-section > summary:focus-visible {
  outline: 2px solid var(--accent, var(--border-color));
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .lake-popup .popup-section > summary::after {
    transition: none;
  }
}

.lake-popup .water-quality__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.lake-popup .water-quality__list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.lake-popup .water-quality__list li > *,
.lake-popup .fish-frequency li > * {
  min-width: 0;
}

.lake-popup .water-quality__value {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.lake-popup .water-quality__year {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.lake-popup .water-quality__meta,
.lake-popup .water-quality__flags,
.lake-popup .water-quality__empty {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lake-popup .water-quality__classification {
  margin: 0.35rem 0 0.6rem;
  line-height: 1.4;
}

/* The satellite section keeps the UNIFORM card chrome: the modeled-versus-
   observed distinction is carried by its heading, "Modeled" badge, and
   provenance line — never by a different card style. */

.observed-history__series + .observed-history__series {
  border-top: 1px solid var(--border-color, #d7dde2);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.observed-history__series h4 {
  margin: 0 0 0.45rem;
}

.observed-history__body dl {
  display: grid;
  grid-template-columns: minmax(7.5rem, auto) 1fr;
  gap: 0.3rem 0.75rem;
  margin: 0;
}

.observed-history__body dt {
  font-weight: 650;
}

.observed-history__body dd {
  margin: 0;
}

.observed-history__note,
.observed-history__safety {
  font-size: 0.88em;
  line-height: 1.4;
}

.observed-history__safety {
  font-weight: 650;
}

@media (max-width: 520px) {
  .observed-history__body dl {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .observed-history__body dd {
    margin-bottom: 0.45rem;
  }
}

.lake-popup .water-quality__provenance {
  font-style: italic;
}

.lake-popup .fish-frequency ul {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.lake-popup .fish-frequency li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.lake-popup .fish-frequency .fish-group-heading {
  justify-content: flex-start;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.lake-popup .fish-frequency .fish-group-heading:first-child {
  margin-top: 0;
}

.lake-popup .fish-methodology__intro,
.lake-popup .fish-methodology__survey {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.lake-popup .fish-methodology__list {
  display: grid;
  gap: 0.65rem;
  margin: 0.4rem 0 0;
}

.lake-popup .fish-methodology__list li {
  display: grid;
  justify-content: stretch;
  gap: 0.15rem;
  font-size: 0.825rem;
}

.lake-popup .fish-methodology__list span {
  color: var(--text-muted);
}

.lake-popup .stocking-summary {
  margin-top: 1rem;
}

.lake-popup .stocking-summary[hidden] {
  display: none;
}

.lake-popup .stocking-summary ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.lake-popup .stocking-summary .stocking-species-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.lake-popup .stocking-summary .stocking-species-item + .stocking-species-item {
  border-top: 1px dotted rgba(0, 0, 0, 0.08);
  padding-top: 0.45rem;
}

.stocking-history {
  position: relative;
  display: inline-flex;
  margin-top: 0.3rem;
}

.stocking-history__trigger {
  border: 1px solid var(--border-color);
  background: var(--surface);
  color: var(--accent);
  border-radius: 0.5rem;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  box-shadow: 0 2px 6px -4px rgba(0, 0, 0, 0.35);
}

.stocking-history__trigger:hover,
.stocking-history__trigger:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  outline: none;
}

.stocking-history__trigger-icon {
  font-size: 0.9rem;
}

.stocking-history__tooltip {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: auto;
  min-width: min(220px, calc(100vw - 5rem));
  max-width: min(240px, calc(100vw - 5rem));
  padding: 0.75rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 18px 36px -20px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 20;
}

.stocking-history__tooltip[hidden] {
  display: none;
}

.stocking-history__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
}

.stocking-history__year {
  width: 3rem;
  color: var(--text-muted);
}

.stocking-history__bar-track {
  position: relative;
  height: 0.45rem;
  border-radius: 0.3rem;
  background: var(--surface-alt);
  overflow: hidden;
}

.stocking-history__bar-fill {
  position: absolute;
  inset: 0;
  width: var(--stocking-bar, 0%);
  background: linear-gradient(90deg, var(--accent) 0%, rgba(20, 92, 168, 0.25) 100%);
  border-radius: inherit;
}

.stocking-history__value {
  white-space: nowrap;
  color: var(--text-muted);
}

.lake-popup .stocking-summary .stocking-note {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lake-popup footer {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lake-popup a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.lake-popup a:hover,
.lake-popup a:focus {
  text-decoration: underline;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  /* 44px: primary header action. */
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}

.theme-toggle:hover,
.theme-toggle:focus {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: 0 10px 24px -16px var(--shadow);
}

.theme-toggle__icon {
  font-size: 1.05rem;
  display: inline-flex;
}

.theme-toggle__mode {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-toggle--system .theme-toggle__mode {
  display: inline-flex;
}

body.theme-dark .theme-toggle {
  border-color: rgba(103, 179, 255, 0.35);
}

body.theme-dark .leaflet-popup-content-wrapper,
body.theme-dark .leaflet-popup-tip {
  background: rgba(17, 28, 43, 0.95);
  color: var(--text);
}

body.theme-dark .leaflet-control-zoom a {
  background: rgba(17, 28, 43, 0.85);
  color: var(--text);
  border-color: var(--border-color);
}

body.theme-dark .marker-cluster-small,
body.theme-dark .marker-cluster-medium,
body.theme-dark .marker-cluster-large {
  background-color: rgba(103, 179, 255, 0.25);
}

body.theme-dark .marker-cluster-small div,
body.theme-dark .marker-cluster-medium div,
body.theme-dark .marker-cluster-large div {
  background-color: #67b3ff;
  color: #07111d;
}

.map-status {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 500;
  max-width: 18rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(9, 22, 36, 0.92);
  color: #ffffff;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 16px 32px -24px rgba(0, 0, 0, 0.6);
}

body.theme-dark .map-status {
  background: rgba(17, 28, 43, 0.88);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
