:root {
  color-scheme: light;
  --deep: #12382d;
  --deep-2: #0b2a25;
  --green: #1f7a5f;
  --green-soft: #dcefe7;
  --sand: #f4eddc;
  --sand-2: #fbf7ed;
  --water: #d9edf4;
  --text: #17211d;
  --muted: #53635c;
  --line: rgba(18, 56, 45, .15);
  --line-strong: rgba(18, 56, 45, .28);
  --shadow: 0 16px 40px rgba(8, 32, 28, .13);
  --sidebar-width: clamp(340px, 28vw, 420px);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--sand-2);
}
a { color: #0b5f88; }
button, input { font: inherit; }
.app-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--sand-2);
  transition: grid-template-columns .24s ease;
}
.app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.sidebar {
  grid-column: 1;
  grid-row: 1;
  z-index: 1200;
  height: 100dvh;
  width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  overflow-y: auto;
  padding: 10px;
  background:
    radial-gradient(circle at top left, rgba(217, 237, 244, .95), transparent 26rem),
    linear-gradient(210deg, var(--sand-2), var(--sand));
  border-right: 1px solid var(--line);
  box-shadow: 16px 0 34px rgba(8, 32, 28, .08);
  transition: transform .24s ease, opacity .2s ease, padding .24s ease;
}
.app-shell.sidebar-collapsed .sidebar {
  padding: 0;
  opacity: 0;
  transform: translateX(-100%);
  pointer-events: none;
  overflow: hidden;
}
.map-wrap {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--water);
}
#map { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--water); }
.leaflet-container { width: 100% !important; height: 100% !important; }
.sidebar-header, .panel {
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(18, 56, 45, .12);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(8, 32, 28, .08);
  backdrop-filter: blur(12px);
}
.sidebar-header { padding: 12px; margin-bottom: 10px; }
.topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 850;
  color: var(--green);
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 29px);
  line-height: 1.05;
  letter-spacing: -.04em;
  color: var(--deep);
}
.lead { margin: 9px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.version-badge {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f2ec;
  color: #174f3f;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(23,79,63,.18);
}
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.stat { background: rgba(255,255,255,.78); border: 1px solid var(--line); border-radius: 16px; padding: 8px 9px; min-width: 0; }
.stat b { display: block; font-size: 20px; line-height: 1; color: var(--deep); }
.stat span { display: block; margin-top: 3px; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.panel { margin-top: 10px; padding: 0; overflow: hidden; }
.panel.search-panel, .panel.fish-panel { padding: 11px; }
.panel summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 850;
  color: var(--deep);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s ease;
}
details[open] summary::after { transform: rotate(225deg) translateY(-2px); }
details > .chips, details > .quality-note, details > .list-toolbar, details > .spot-list, details > .legend, details > .downloads, details > .notice { margin: 0 11px 11px; }
.label, .panel-head h2 { display: block; margin: 0 0 7px; color: var(--deep); font-weight: 850; font-size: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 8px; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 10px;
  font-size: 12px;
  background: white;
  outline: none;
}
.search:focus { border-color: rgba(31,122,95,.72); box-shadow: 0 0 0 4px rgba(31,122,95,.12); }
.fish-search { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fish-chips { max-height: 122px; overflow: auto; padding-right: 2px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.86);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--deep);
  font-weight: 800;
  font-size: 10.8px;
  line-height: 1.25;
}
.chip:hover { background: white; border-color: var(--line-strong); }
.chip.active { background: var(--deep); color: white; border-color: var(--deep); }
.chip .count { opacity: .68; font-weight: 700; margin-left: 3px; }
.small-action, .text-button, .sidebar-toggle, .sidebar-open {
  border: 1px solid var(--line);
  background: white;
  color: var(--deep);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  white-space: nowrap;
}
.small-action:hover, .text-button:hover, .sidebar-toggle:hover, .sidebar-open:hover { border-color: var(--green); color: var(--green); }
.sidebar-toggle.in-panel { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; }
.sidebar-open {
  position: fixed;
  z-index: 1600;
  top: 12px;
  left: 62px;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 10px 28px rgba(8,32,28,.14);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
}
.app-shell.sidebar-collapsed .sidebar-open { display: inline-flex; }
.active-filter {
  margin: 0 0 8px;
  padding: 7px 9px;
  border-radius: 12px;
  background: #e7f2ec;
  border: 1px solid rgba(31,122,95,.2);
  color: var(--deep);
  font-size: 11px;
  font-weight: 800;
}
.list-toolbar { display: flex; justify-content: space-between; gap: 10px; align-items: center; color: var(--muted); font-size: 11px; }
.spot-list { display: grid; gap: 7px; max-height: min(42vh, 440px); overflow: auto; padding-right: 4px; }
.spot-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(18,56,45,.12);
  border-radius: 14px;
  background: rgba(255,255,255,.78);
  padding: 7px;
  cursor: pointer;
  color: inherit;
}
.spot-item:hover { border-color: rgba(31,122,95,.55); background: #fff; }
.spot-row { display: grid; grid-template-columns: 13px 1fr auto; align-items: start; gap: 7px; }
.spot-color { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; border: 2px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,.22); }
.spot-main { min-width: 0; }
.spot-main strong { display: block; font-size: 12.5px; line-height: 1.22; color: var(--deep); }
.spot-meta { display: block; color: var(--muted); margin-top: 3px; line-height: 1.28; font-size: 11px; }
.spot-number { display: inline-flex; min-width: 22px; justify-content: center; margin-right: 4px; border-radius: 999px; background: rgba(18,56,45,.08); color: var(--deep); font-size: 10px; line-height: 1.65; }
.badge { border-radius: 999px; padding: 3px 6px; font-size: 10px; font-weight: 850; white-space: nowrap; border: 1px solid transparent; }
.badge-high { background: #dcefe7; color: #0d4a38; border-color: #b8decf; }
.badge-mid { background: #fff1c7; color: #6b4a00; border-color: #ead99b; }
.badge-low { background: #eee9e1; color: #5d5348; border-color: #d8cfc1; }
.legend { display: grid; grid-template-columns: 16px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.dash { border-bottom: 2px dashed #333; width: 18px; display: inline-block; }
.quality-note, .notice { margin-top: 10px; padding: 9px 10px; border-radius: 14px; background: #fff7db; border: 1px solid #ead99b; color: #654600; font-size: 10.8px; line-height: 1.35; }
.downloads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.downloads a { display: block; text-align: center; text-decoration: none; border-radius: 14px; padding: 7px 6px; background: var(--deep); color: white; font-weight: 850; font-size: 11px; }
.downloads a:hover { background: var(--green); }
.map-badge { position: absolute; z-index: 800; right: 14px; bottom: 14px; max-width: min(360px, calc(100% - 28px)); background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 18px; padding: 8px 10px; font-size: 12px; color: var(--muted); box-shadow: 0 10px 28px rgba(0,0,0,.12); }
.leaflet-control-layers { border: none !important; border-radius: 18px !important; box-shadow: 0 12px 30px rgba(0,0,0,.16) !important; overflow: hidden; }
.leaflet-popup-content-wrapper { border-radius: 18px; }
.popup h3 { margin: 0 0 8px; font-size: 17px; color: var(--deep); }
.popup table { border-collapse: collapse; font-size: 12px; min-width: min(310px, 72vw); }
.popup td { padding: 5px 6px; vertical-align: top; border-top: 1px solid #eee; }
.popup td:first-child { font-weight: 750; color: #2b3934; white-space: nowrap; }
.inline-status { display: inline-block; padding: 2px 7px; border-radius: 999px; font-weight: 850; font-size: 11px; }
.inline-status.status-safe { background:#dcefe7; color:#0d4a38; }
.inline-status.status-candidate { background:#fff1c7; color:#6b4a00; }
.inline-status.status-habitat { background:#d9f0ea; color:#12604b; }
.inline-status.status-drift { background:#d9edf4; color:#155675; }
.inline-status.status-uncertain { background:#f6dfd4; color:#743018; }
.status-safe { border-left: 3px solid #1f7a5f; }
.status-candidate { border-left: 3px solid #b9933a; }
.status-habitat { border-left: 3px solid #2f8f83; }
.status-drift { border-left: 3px solid #2474a6; }
.status-uncertain { border-left: 3px solid #b35a35; opacity: .9; }
.spot-label { background: rgba(255,255,255,.92) !important; border: 1px solid rgba(0,0,0,.12) !important; border-radius: 999px !important; padding: 3px 8px !important; font-weight: 750; color: var(--deep) !important; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.no-results { color: var(--muted); font-size: 12px; padding: 10px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 14px; }
@media (max-width: 900px) {
  .app-shell { display: block; height: 100dvh; }
  .map-wrap { width: 100vw; height: 100dvh; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(390px, 92vw); max-width: 92vw; height: 100dvh; }
  .app-shell.sidebar-collapsed .sidebar { padding: 0; transform: translateX(-100%); }
  .spot-list { max-height: 36vh; }
  .map-badge { font-size: 11px; bottom: 10px; right: 10px; }
}
@media (max-width: 520px) {
  .sidebar { padding: 8px; }
  .sidebar-header, .panel { border-radius: 16px; }
  .topline { align-items: flex-start; }
  h1 { font-size: 23px; }
  .lead { font-size: 12px; }
  .stats { gap: 6px; }
  .stat { padding: 7px; }
  .stat b { font-size: 18px; }
  .spot-row { grid-template-columns: 13px 1fr; }
  .badge { grid-column: 2; width: fit-content; margin-top: 4px; }
  .downloads { grid-template-columns: 1fr 1fr; }
  .leaflet-control-layers { max-width: 220px; font-size: 12px; }
}
