: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; }

.layout { position: relative; min-height: 0; flex: 1; display: grid; grid-template-columns: 370px 1fr; }
.panel { z-index: 800; overflow: auto; padding: 18px; border-right: 1px solid var(--line); background: var(--panel); }
.panel-heading { margin-bottom: 15px; }
.panel-heading h2 { margin: 0; font-size: 1.08rem; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.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; }

.place-form { display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 0 9px; margin-bottom: 5px; }
.place-form label { min-width: 0; }
.place-submit { grid-column: 1 / -1; min-height: 42px; margin: -3px 0 0; border: 1px solid #247ba0; border-radius: 9px; background: #125d7c; color: #fff; cursor: pointer; font-weight: 800; }
.place-submit:hover { background: #11749a; }
.place-status { grid-column: 1 / -1; min-height: 0; margin: 7px 0 8px; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.place-status:empty { display: none; }

.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; align-items: end; }
.filter-grid .area-filter { grid-column: 1 / -1; }
.panel-action { width: 100%; min-height: 44px; margin-bottom: 14px; border: 1px solid #405a78; border-radius: 9px; background: var(--panel-raised); color: #eaf5ff; cursor: pointer; font-size: .8rem; font-weight: 800; }
.panel-action:hover:not(:disabled) { border-color: var(--accent); background: #1b5371; }
.panel-action:disabled { cursor: default; opacity: .45; }

.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; }

.legend { margin-bottom: 12px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: .84rem; line-height: 1.65; }
.legend h2 { margin: 0 0 5px; color: #fff; font-size: .92rem; }
.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 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, .nearby-card { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #101b2c; }
.coordinates h3, .conditions-card h3, .nearby-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; }
.nearby-list { margin: 0; padding: 0; list-style: none; }
.nearby-list li + li { border-top: 1px solid var(--line); }
.nearby-list button { width: 100%; min-height: 49px; display: flex; flex-direction: column; justify-content: center; padding: 7px 3px; border: 0; background: transparent; color: #edf6ff; text-align: left; cursor: pointer; }
.nearby-list button:hover { color: var(--accent); }
.nearby-list small { margin-top: 2px; color: var(--muted); }
.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.location-summary { min-width: 190px; margin: 0 0 10px 10px; padding: 10px 12px; border: 1px solid rgba(14, 78, 106, .3); border-radius: 10px; background: rgba(255, 255, 255, .94); box-shadow: 0 3px 14px rgba(0, 0, 0, .2); color: #152132; font: 12px/1.35 Inter, ui-sans-serif, system-ui, sans-serif; backdrop-filter: blur(5px); }
.location-summary-title { margin-bottom: 6px; color: #075c7d; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.location-summary dl { margin: 0; }
.location-summary dl div { display: flex; justify-content: space-between; gap: 18px; padding: 2px 0; }
.location-summary dt { color: #42546b; }
.location-summary dd { margin: 0; color: #07111f; font-variant-numeric: tabular-nums; font-weight: 800; }
.support-link { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 7px; margin: 9px -4px -4px; padding: 7px 9px; border-top: 1px solid #c9d8e4; border-radius: 0 0 7px 7px; color: #075c7d; font-size: 11px; font-weight: 800; text-decoration: none; }
.support-link span { color: #d54b67; font-size: 15px; line-height: 1; }
.support-link:hover, .support-link:focus-visible { background: #e7f5fb; color: #034b68; 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 { min-height: 0; display: block; }
  #map { height: 100%; min-height: 0; }
  .panel { position: absolute; z-index: 1050; top: 0; left: 0; width: min(360px, 88vw); height: 100%; padding: 16px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border-right: 1px solid var(--line); box-shadow: 12px 0 35px rgba(0, 0, 0, .42); overscroll-behavior: contain; transform: translateX(-105%); transition: transform .2s ease; }
  .panel.is-open { transform: translateX(0); }
  .filter-scrim { position: absolute; z-index: 1040; inset: 0; display: block; border: 0; background: rgba(2, 9, 17, .52); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .filter-scrim.is-open { opacity: 1; pointer-events: auto; }
  .search-results { max-height: 38dvh; }
  .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-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; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-grid .area-filter { grid-column: auto; }
  .leaflet-control.location-summary { min-width: 156px; margin: 0 0 26px 6px; padding: 7px 9px; font-size: 10px; }
  .location-summary-title { margin-bottom: 3px; font-size: 9px; }
  .location-summary dl div:nth-child(2) { display: none; }
  .support-link { margin-top: 6px; font-size: 10px; }
  .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; }
}
