:root {
  color-scheme: light;
  --ink: #12313d;
  --muted: #5d737a;
  --foam: #f4fbf8;
  --mist: #e5f4f2;
  --panel: rgba(248, 253, 250, 0.92);
  --panel-solid: #f8fdfa;
  --ocean: #0c6e83;
  --ocean-deep: #074a5a;
  --teal: #159a9c;
  --kelp: #5c7c52;
  --coral: #e86f53;
  --sun: #f0b35a;
  --line: rgba(18, 49, 61, 0.14);
  --shadow: 0 18px 55px rgba(8, 45, 54, 0.2);
  --soft-shadow: 0 10px 34px rgba(8, 45, 54, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--foam);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(244, 251, 248, 0.2), rgba(244, 251, 248, 0.68)),
    #d9efee;
}

.map-surface {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh;
  z-index: 0;
  overflow: hidden;
  background: #d9efee;
}

.map-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(244, 251, 248, 0.66) 0%, rgba(244, 251, 248, 0.08) 32%, rgba(244, 251, 248, 0.18) 100%),
    linear-gradient(0deg, rgba(10, 77, 91, 0.16), transparent 42%);
  z-index: 450;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.topbar,
.left-rail,
.detail-panel,
.story-sheet {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar {
  position: fixed;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 650;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(220px, 330px) minmax(260px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
}

.brand-lockup,
.rail-heading,
.story-sheet-header,
.story-actions,
.mini-meta,
.lake-title,
.panel-actions,
.request-row,
.legend-row {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #f8fffb;
  background: linear-gradient(145deg, var(--ocean), var(--teal));
  border-radius: var(--radius);
  box-shadow: inset 0 -10px 20px rgba(7, 74, 90, 0.22);
}

.brand-mark svg,
button svg,
.rail-heading svg,
.empty-state svg {
  width: 18px;
  height: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--kelp);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 6px;
  font-size: 15px;
  line-height: 1.25;
}

.search-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.search-field {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-field svg {
  width: 17px;
  height: 17px;
  color: var(--ocean);
}

.search-field input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-strip > span,
.mini-meta span,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  color: var(--ocean-deep);
  background: rgba(229, 244, 242, 0.86);
  border: 1px solid rgba(12, 110, 131, 0.16);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
}

.summary-strip > .census-map-chip {
  gap: 7px;
  color: #6c4612;
  background: rgba(255, 248, 230, 0.92);
  border-color: rgba(240, 179, 90, 0.54);
}

.legend-pin-dot {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  background: var(--sun);
  border: 3px solid #f8fffb;
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(240, 179, 90, 0.48);
}

.left-rail {
  position: fixed;
  left: 18px;
  top: 112px;
  z-index: 620;
  width: 310px;
  display: grid;
  gap: 12px;
}

.rail-section {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
}

.rail-section.compact {
  padding-bottom: 8px;
}

.rail-heading {
  gap: 8px;
  margin-bottom: 12px;
}

.rail-heading svg {
  color: var(--ocean);
}

.request-form {
  display: grid;
  gap: 10px;
}

.request-form label {
  display: grid;
  gap: 5px;
}

.request-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.request-form input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline-color: rgba(21, 154, 156, 0.46);
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button {
  color: #f8fffb;
  background: linear-gradient(135deg, var(--ocean), var(--teal));
  box-shadow: 0 10px 24px rgba(12, 110, 131, 0.22);
}

.secondary-button,
.icon-button {
  color: var(--ocean-deep);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(12, 110, 131, 0.16);
}

.request-queue {
  display: grid;
  gap: 8px;
  max-height: 180px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.request-row {
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.request-row strong {
  display: block;
  font-size: 13px;
}

.request-row small {
  color: var(--muted);
  font-size: 11px;
}

.census-summary {
  display: grid;
  gap: 9px;
}

.census-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.38;
}

.census-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.census-kpis div,
.census-types span {
  padding: 8px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.census-kpis strong {
  display: block;
  color: var(--ocean-deep);
  font-size: 18px;
  line-height: 1;
}

.census-kpis span,
.census-types {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.census-types {
  display: grid;
  gap: 6px;
}

.census-types span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.detail-panel {
  position: fixed;
  top: 112px;
  right: 18px;
  bottom: 18px;
  z-index: 630;
  width: min(430px, calc(100vw - 36px));
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-state {
  height: 100%;
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--ocean);
}

.lake-dossier {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.lake-hero {
  position: relative;
  min-height: 170px;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(12, 110, 131, 0.98), rgba(21, 154, 156, 0.9));
  color: #f8fffb;
}

.lake-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 42, 50, 0.08), rgba(4, 42, 50, 0.55)),
    var(--hero-image, none);
  background-size: cover;
  background-position: center;
  opacity: 0.94;
}

.lake-hero-content {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 170px;
  padding: 16px;
}

.lake-title {
  justify-content: space-between;
  gap: 12px;
}

.lake-title h2 {
  max-width: 290px;
  font-size: 22px;
}

.type-badge {
  padding: 5px 8px;
  color: var(--ocean-deep);
  background: rgba(248, 253, 250, 0.88);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.mini-meta {
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.sentinel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sentinel-view {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sentinel-map {
  height: 168px;
  background: #cfe7df;
}

.sentinel-caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  font-size: 12px;
}

.sentinel-caption strong {
  color: var(--ocean-deep);
}

.sentinel-caption span {
  color: var(--muted);
}

.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  padding: 10px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.panel-note {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  background: rgba(244, 251, 248, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
}

.panel-actions {
  gap: 8px;
}

.panel-actions .primary-button,
.panel-actions .secondary-button {
  flex: 1;
}

.custom-pin-target {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.custom-pin-target::before,
.custom-pin-target::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.custom-pin-target::before {
  inset: 2px;
  background: rgba(248, 255, 251, 0.92);
  box-shadow: 0 9px 24px rgba(4, 42, 50, 0.3);
}

.custom-pin-target::after {
  inset: 8px;
  background: var(--pin-color, var(--ocean));
  opacity: 0.2;
}

.custom-pin-target.is-selected {
  width: 52px;
  height: 52px;
}

.custom-pin-target.has-census {
  width: 50px;
  height: 50px;
}

.custom-pin-target.has-census::before {
  box-shadow:
    0 0 0 5px rgba(240, 179, 90, 0.5),
    0 12px 30px rgba(4, 42, 50, 0.32);
}

.custom-pin-target.census-strong::before {
  box-shadow:
    0 0 0 6px rgba(240, 179, 90, 0.72),
    0 13px 32px rgba(4, 42, 50, 0.36);
}

.custom-pin-target.is-selected::before {
  inset: 0;
  box-shadow:
    0 0 0 5px rgba(232, 111, 83, 0.22),
    0 12px 30px rgba(4, 42, 50, 0.34);
}

.custom-pin {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  border: 4px solid #f8fffb;
  border-radius: 50% 50% 50% 0;
  background: var(--pin-color, var(--ocean));
  box-shadow: 0 5px 16px rgba(4, 42, 50, 0.36);
  transform: rotate(-45deg);
}

.custom-pin::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #f8fffb;
}

.custom-pin-target.is-selected .custom-pin {
  --pin-color: var(--coral);
  width: 32px;
  height: 32px;
}

.census-pin-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  z-index: 3;
  min-width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  color: #12313d;
  background: var(--sun);
  border: 3px solid #f8fffb;
  border-radius: 999px;
  box-shadow: 0 5px 13px rgba(4, 42, 50, 0.28);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.leaflet-marker-icon {
  background: transparent;
  border: 0;
}

.census-match-panel {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: rgba(255, 248, 230, 0.76);
  border: 1px solid rgba(240, 179, 90, 0.48);
  border-radius: var(--radius);
}

.census-match-panel.is-empty {
  background: rgba(244, 251, 248, 0.78);
  border-color: var(--line);
}

.census-match-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.census-match-head,
.census-match-stats span,
.census-match-list li {
  display: flex;
  align-items: center;
}

.census-match-head {
  justify-content: space-between;
  gap: 8px;
}

.census-status {
  color: #6c4612;
  background: rgba(240, 179, 90, 0.38);
  border-color: rgba(240, 179, 90, 0.58);
  text-transform: capitalize;
}

.census-match-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.census-match-stats span {
  min-height: 48px;
  justify-content: center;
  flex-direction: column;
  padding: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(240, 179, 90, 0.34);
  border-radius: var(--radius);
  font-size: 10px;
  font-weight: 800;
}

.census-match-stats strong {
  color: var(--ocean-deep);
  font-size: 17px;
}

.census-match-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.census-match-list li {
  align-items: flex-start;
  flex-direction: column;
  gap: 3px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(240, 179, 90, 0.26);
  border-radius: var(--radius);
}

.census-match-list strong {
  font-size: 12px;
}

.census-match-list span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.story-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
}

.story-modal.is-open {
  display: block;
}

.story-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 42, 50, 0.56);
}

.story-sheet {
  position: absolute;
  top: 22px;
  right: 22px;
  bottom: 22px;
  width: min(470px, calc(100vw - 44px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  background: var(--panel-solid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.story-sheet-header {
  justify-content: space-between;
  gap: 12px;
}

.story-preview-wrap {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(180deg, #dff2ef, #fbf4e9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

#storyCanvas {
  display: block;
  height: min(100%, 76vh);
  width: auto;
  max-width: 100%;
  aspect-ratio: 6 / 19;
  background: #eef8f6;
  border-radius: 6px;
  box-shadow: 0 18px 40px rgba(8, 45, 54, 0.18);
}

.story-actions {
  gap: 8px;
}

.story-actions button {
  flex: 1;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .left-rail {
    display: none;
  }

  .detail-panel {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 58vh;
  }

  .map-surface::after {
    background: linear-gradient(0deg, rgba(244, 251, 248, 0.66) 0%, rgba(244, 251, 248, 0.1) 48%);
  }
}

@media (max-width: 640px) {
  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    padding: 10px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: 22px;
  }

  .summary-strip > span {
    font-size: 11px;
  }

  .detail-panel {
    max-height: 63vh;
  }

  .sentinel-grid,
  .data-grid {
    grid-template-columns: 1fr;
  }

  .sentinel-map {
    height: 150px;
  }

  .story-sheet {
    inset: 10px;
    width: auto;
  }
}
