:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111a2b;
  --panel-raised: #162238;
  --muted: #a7b7cd;
  --line: #2b3a50;
  --accent: #71c7ec;
  --accent-strong: #20a7d8;
  --focus: #b8ebff;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: #eef5ff; }
body { min-height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input, select { font: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 3000; padding: 10px 13px; border-radius: 8px; background: #fff; color: #07111f; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(115deg, #0e1728, #10223a); }
.topbar > div { min-width: 0; flex: 1 1 auto; }
.topbar h1 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.55rem); letter-spacing: -.025em; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.filter-toggle { display: none; min-height: 44px; padding: 8px 12px; border: 1px solid #48617f; border-radius: 9px; background: var(--panel-raised); color: #fff; font-weight: 750; }
.filter-scrim { display: none; }
.mobile-resize-handle { display: none; }

.layout { position: relative; min-height: 0; flex: 1; display: grid; grid-template-columns: 370px 1fr; }
.panel { z-index: 800; overflow: auto; display: flex; flex-direction: column; padding: 18px; border-right: 1px solid var(--line); background: var(--panel); }
.loading-status { margin: 0 0 13px; padding: 9px 10px; border-radius: 8px; background: #172944; color: #d8eeff; font-size: .78rem; }
.panel label { display: block; margin-bottom: 14px; color: #dce8f6; font-size: .84rem; font-weight: 650; }
.panel input, .panel select { width: 100%; min-height: 44px; margin-top: 6px; padding: 9px 10px; border: 1px solid #39506e; border-radius: 9px; background: #0d1727; color: #fff; font-weight: 450; transition: border-color .15s ease, box-shadow .15s ease; }
.panel input:focus, .panel select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.search-control { position: relative; margin-bottom: 14px; }
.search-control label { margin-bottom: 0; }
.place-suggestions { position: absolute; z-index: 1200; top: calc(100% - 1px); right: 0; left: 0; overflow: hidden; border: 1px solid #39506e; border-radius: 9px; background: #0d1727; box-shadow: 0 12px 30px rgba(0, 0, 0, .38); }
.place-suggestion { width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 0; border-bottom: 1px solid #24354d; background: transparent; color: #eef5ff; text-align: left; cursor: pointer; }
.place-suggestion:last-child { border-bottom: 0; }
.place-suggestion:hover, .place-suggestion:focus-visible { background: #18304c; }
.place-suggestion span { min-width: 0; font-size: .82rem; font-weight: 760; }
.place-suggestion small { flex: 0 0 auto; color: var(--muted); font-size: .68rem; }
.active-place-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.place-chip { min-height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 9px 6px 11px; border: 1px solid #2d7896; border-radius: 999px; background: #12334a; color: #dff7ff; cursor: pointer; font-size: .74rem; font-weight: 780; }
.place-chip span { color: #9fdef1; font-size: 1rem; line-height: 1; }

.search-results { max-height: clamp(210px, 34vh, 330px); overflow: auto; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; background: #0d1727; box-shadow: 0 8px 24px rgba(0, 0, 0, .16); }
.search-results h2 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 11px; border-bottom: 1px solid var(--line); background: #101c30; font-size: .83rem; }
.search-results ol { margin: 0; padding: 0; list-style: none; }
.search-result { width: 100%; min-height: 52px; padding: 10px 10px 10px 12px; border: 0; border-bottom: 1px solid #1f2d42; border-left: 4px solid var(--result-accent, #52647c); background: transparent; color: #eef5ff; text-align: left; cursor: pointer; }
.search-result:hover { background: #172741; }
.search-result-name { display: block; font-size: .84rem; font-weight: 720; }
.search-result-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .69rem; line-height: 1.35; }
.search-results-note { margin: 0; padding: 10px 11px; color: var(--muted); font-size: .74rem; line-height: 1.4; }

.dot { width: 11px; height: 11px; display: inline-block; margin-right: 7px; border-radius: 50%; }
.shallow { background: #48c774; }
.recreational { background: #3e8ed0; }
.deep { background: #ffb347; }
.technical { background: #ff5c5c; }

.data-note { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #0d1727; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.data-note summary { min-height: 42px; padding: 10px; color: #d9e6f7; cursor: pointer; font-size: .78rem; font-weight: 750; }
.data-note[open] summary { border-bottom: 1px solid var(--line); }
.data-note p { margin: 0; padding: 10px; }
.data-note p + p { padding-top: 0; }

#map { width: 100%; height: 100%; min-height: 430px; background: #d8e1e8; touch-action: pan-x pan-y; }
.site-details { position: absolute; z-index: 1100; top: 14px; right: 14px; bottom: 14px; width: min(430px, calc(100% - 400px)); overflow: auto; padding: 22px; border: 1px solid #3b506a; border-radius: 15px; background: rgba(13, 23, 39, .98); box-shadow: 0 16px 48px rgba(0, 0, 0, .48); backdrop-filter: blur(10px); }
.details-close { position: sticky; z-index: 2; top: 0; float: right; width: 44px; height: 44px; margin: -8px -8px 2px 8px; border: 1px solid #445a75; border-radius: 50%; background: #16263b; color: #fff; cursor: pointer; font-size: 1.7rem; line-height: 1; }
.detail-kicker { display: block; max-width: calc(100% - 48px); color: var(--accent); font-size: .68rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.detail-header h2 { margin: 5px 0 10px; font-size: 1.55rem; line-height: 1.18; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 7px; }
.depth-badge, .quality-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; background: #20344a; font-size: .72rem; font-weight: 800; }
.depth-badge::before { width: 9px; height: 9px; border-radius: 50%; background: var(--depth-color); content: ""; }
.quality-badge { border: 1px solid #435a72; background: #18273a; color: #c3d2e3; }
.quality-2 { border-color: #8d6a2c; background: #332812; color: #ffd88a; }
.quality-3 { border-color: #65517f; background: #281d38; color: #d5bcf5; }
.detail-photo { margin: 16px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #0a111d; }
.detail-photo img { width: 100%; max-height: 245px; display: block; object-fit: cover; }
.detail-photo img.is-contain { max-height: 360px; object-fit: contain; background: #f4f5f6; }
.detail-media-link { display: block; background: #07101c; }
.detail-photo p { margin: 0; padding: 7px 9px; color: var(--muted); font-size: .64rem; line-height: 1.35; }
.media-source-card { min-height: 126px; display: flex; flex-direction: column; justify-content: end; padding: 18px; background: linear-gradient(135deg, rgba(5, 96, 128, .92), rgba(10, 24, 43, .96)); color: #fff; text-decoration: none; }
.media-source-card span { margin-bottom: auto; color: #a9e7ff; font-size: .65rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.media-source-card strong { font-size: 1rem; }
.media-source-card small { margin-top: 5px; color: #d5e8f5; font-size: .7rem; line-height: 1.4; }
.media-source-card:hover strong { text-decoration: underline; }
.detail-description { margin: 16px 0; color: #deebf8; line-height: 1.55; }
.detail-facts { margin: 15px 0; border-top: 1px solid var(--line); }
.detail-facts div { display: grid; grid-template-columns: 105px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.detail-facts dt { color: var(--muted); font-size: .76rem; font-weight: 750; }
.detail-facts dd { margin: 0; font-size: .78rem; line-height: 1.4; }
.detail-status, .detail-note { padding: 10px 11px; border-left: 3px solid #d9961e; border-radius: 5px; background: #312712; color: #ffe4a8; font-size: .78rem; line-height: 1.48; }
.detail-status.is-alert { border-left-color: #ff6b6b; background: #351919; color: #ffc0c0; }
.detail-note { border-left-color: #4b88aa; background: #13283a; color: #d8ebfa; }
.coordinates, .conditions-card { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #101b2c; }
.coordinates h3, .conditions-card h3 { margin: 0 0 8px; font-size: .9rem; }
.coordinates code { display: block; padding: 3px 0; color: #d8f1ff; cursor: text; font-size: .76rem; user-select: text; }
.detail-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.detail-links a, .conditions-card a { min-height: 40px; display: inline-flex; align-items: center; padding: 7px 10px; border-radius: 7px; background: #0f6589; color: #fff; font-size: .75rem; font-weight: 750; text-decoration: none; }
.async-content { color: var(--muted); font-size: .75rem; line-height: 1.45; }
.async-content p { margin: 5px 0; }
.async-meta { font-size: .68rem; }
.detail-loading, .detail-error { padding: 40px 8px; color: var(--muted); text-align: center; }

.leaflet-container img.leaflet-tile, .leaflet-container .leaflet-tile-pane img { max-width: none !important; max-height: none !important; }
.leaflet-control-layers { border-color: #34465c !important; background: rgba(17, 26, 43, .96); color: #eaf3ff; }
.leaflet-bar { border-color: #34465c !important; }
.leaflet-bar a, .leaflet-bar a:hover { border-bottom-color: #34465c; background: #111a2b; color: #eef5ff; }
.leaflet-control.depth-legend { min-width: 126px; margin: 0 10px 10px 0; padding: 9px 11px; border: 1px solid rgba(14, 78, 106, .3); border-radius: 9px; background: rgba(255, 255, 255, .94); box-shadow: 0 3px 14px rgba(0, 0, 0, .2); color: #31435a; font: 11px/1.55 Inter, ui-sans-serif, system-ui, sans-serif; backdrop-filter: blur(5px); }
.depth-legend h2 { margin: 0 0 4px; color: #075c7d; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.depth-legend div { display: flex; align-items: center; white-space: nowrap; }
.depth-legend .dot { flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(7, 17, 31, .22); }

.site-support { min-height: 44px; align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; margin-top: auto; padding: 7px 8px; border-radius: 7px; color: var(--accent); font-size: .76rem; font-weight: 800; text-decoration: none; }
.site-support span { color: #ef6680; font-size: 16px; line-height: 1; }
.site-support:hover, .site-support:focus-visible { background: #162a42; color: #bdeaff; text-decoration: underline; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 330px 1fr; }
  .site-details { width: min(410px, calc(100% - 360px)); }
}

@media (max-width: 780px) {
  .topbar { min-height: 68px; gap: 8px; padding: max(9px, env(safe-area-inset-top)) max(11px, env(safe-area-inset-right)) 9px max(11px, env(safe-area-inset-left)); }
  .topbar p { overflow: hidden; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
  .filter-toggle { flex: 0 0 auto; display: block; min-width: 76px; padding: 7px 11px; white-space: nowrap; }
  .layout { --mobile-panel-height: 48%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  #map { height: auto; min-height: 100px; flex: 1 1 auto; }
  .panel { position: relative; z-index: 800; width: 100%; height: auto; min-height: 0; flex: 0 0 var(--mobile-panel-height); padding: 13px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left)); border-right: 0; border-bottom: 1px solid var(--line); box-shadow: none; overscroll-behavior: contain; transform: none; transition: flex-basis .18s ease, padding .18s ease; }
  .layout.search-collapsed .panel { flex-basis: 0; padding-top: 0; padding-bottom: 0; border-bottom: 0; overflow: hidden; }
  .filter-scrim, .filter-scrim.is-open { display: none; }
  .mobile-resize-handle { z-index: 900; min-height: 44px; flex: 0 0 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-top: 1px solid #34475f; border-right: 0; border-bottom: 1px solid #34475f; border-left: 0; background: #132036; color: var(--muted); cursor: row-resize; touch-action: none; user-select: none; }
  .mobile-resize-handle:hover, .mobile-resize-handle:focus-visible { background: #192b46; color: #fff; }
  .resize-grip { width: 48px; height: 5px; border-radius: 999px; background: #7890aa; }
  .resize-label { font-size: .63rem; font-weight: 750; letter-spacing: .035em; }
  .layout.search-collapsed .resize-label { font-size: .72rem; }
  .layout.search-collapsed .resize-label::before { content: "Search hidden · "; }
  body.mobile-resizing { cursor: row-resize; user-select: none; }
  body.mobile-resizing .panel { transition: none; }
  .search-results { max-height: 38dvh; }
  .place-suggestion { min-height: 52px; }
  .place-chip { min-height: 40px; }
  .site-details { position: absolute; top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-height: min(82%, 720px); padding-bottom: max(22px, env(safe-area-inset-bottom)); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 18px 18px 0 0; overscroll-behavior: contain; }
  .site-details::before { width: 42px; height: 4px; display: block; margin: -9px auto 10px; border-radius: 999px; background: #60738b; content: ""; }
  .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .leaflet-control-layers-toggle { width: 44px !important; height: 44px !important; }
  .leaflet-control-attribution { max-width: calc(100vw - 12px); font-size: 9px !important; line-height: 1.15; white-space: normal; }
  .leaflet-control.depth-legend { min-width: 112px; margin-right: 6px; padding: 7px 9px; font-size: 10px; line-height: 1.45; }
  .depth-legend h2 { margin-bottom: 3px; font-size: 9px; }
  .depth-legend .dot { width: 9px; height: 9px; margin-right: 6px; }
  .leaflet-bottom { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 430px) {
  .topbar h1 { font-size: 1.13rem; }
  .topbar p { max-width: none; }
  .filter-toggle { min-width: 72px; padding: 7px 9px; font-size: .78rem; }
  .site-support { font-size: .72rem; }
  .site-details { padding: 18px; }
  .site-details { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .detail-header h2 { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
