:root { color-scheme: dark; font-family: Inter, system-ui, sans-serif; color: #e8edf2; background: #171b20; }
/* Historical raster overlays live below trackPane (390) and overlayPane (400). */
.historical-pane { pointer-events: none; }
.active-map-indicator { position: absolute; top: 12px; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 1601; width: auto; max-width: calc(100% - 144px); min-height: 40px; padding: 3px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid rgba(255,255,255,.3); border-radius: 9px; background: rgba(32,38,45,.84); color: #fff; font: 600 13px/20px system-ui,sans-serif; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.active-map-indicator.has-layers { width: 340px; }
.active-map-heading, .active-map-name { min-width: 0; padding: 0; color: inherit; background: transparent; font: inherit; cursor: pointer; }
.active-map-heading { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 34px; }
.active-map-heading[hidden] { display: none; }
.active-map-heading:focus, .active-map-name:focus { outline: 2px solid #79c7ff; outline-offset: -2px; }
.active-map-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-map-offset { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.active-map-rows { max-height: 30vh; overflow-x: hidden; overflow-y: auto; }
.active-map-row { display: flex; align-items: center; min-height: 40px; }
.active-map-name { flex: 0 1 64px; width: 64px; min-height: 40px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-map-slider { flex: 1 1 96px; width: 96px; min-width: 96px; height: 40px; margin: 0 4px; padding: 0; border: 0; border-radius: 0; background: transparent; touch-action: none; cursor: pointer; }
.active-map-percent { flex: 0 0 32px; width: 32px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.leaflet-zoom-anim .historical-pane { transition: transform .25s cubic-bezier(0,0,.25,1); }
#desktop-historical-open { margin: 0 0 14px; width: 100%; }
#historical-maps-dialog { width: 560px; max-width: calc(100vw - 24px); }
#historical-maps-dialog > header { position: sticky; top: -12px; z-index: 2; background: #20262d; padding: 8px 0; }
#historical-maps-dialog > header h2 { margin: 0; }
#historical-maps-status { font-size: 13px; }
.historical-card { padding: 12px; margin-bottom: 12px; border: 1px solid #53616d; border-radius: 8px; }
.historical-card small { display: block; overflow-wrap: break-word; margin: 8px 0; }
.historical-visibility, .historical-opacity, .historical-fast-step { display: flex; align-items: center; }
.historical-visibility input, .historical-fast-step input { width: 22px; height: 22px; flex: 0 0 22px; margin-right: 8px; }
.historical-opacity input { flex: 1; min-width: 0; min-height: 44px; padding: 0; margin-right: 12px; }
.historical-opacity output { min-width: 48px; }
.historical-card button, #historical-maps-dialog button { min-height: 44px; }
.historical-drag-shield { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1500; cursor: move; touch-action: none; }
.historical-calibration { position: absolute; z-index: 1600; left: 70px; right: 12px; bottom: 12px; max-width: 460px; max-height: 70%; overflow-y: auto; padding: 10px; border: 1px solid #7b8ea0; border-radius: 10px; background: #20262d; color: #fff; font: 13px/1.4 system-ui,sans-serif; }
.historical-calibration[hidden], .historical-drag-shield[hidden] { display: none; }
.historical-calibration strong, .historical-calibration output { display: block; margin-bottom: 4px; }
.historical-nudges, .historical-calibration-actions { display: flex; flex-wrap: wrap; }
.historical-calibration button { min-height: 44px; min-width: 44px; margin: 2px; padding: 6px 8px; }
.historical-fast-step { margin: 6px 0; }
.historical-calibrating .map-legend { visibility: hidden; }
@media (max-width: 768px) {
  #desktop-historical-open { display: none; }
  #historical-maps-dialog input { font-size: 16px; }
  .historical-calibration { bottom: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
}
* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body { margin: 0; height: 100vh; display: grid; grid-template-columns: 300px 1fr; overflow: hidden; }
.sidebar { padding: 20px; background: #20262d; overflow-y: auto; box-shadow: 4px 0 16px #0004; z-index: 500; }
h1 { margin: 0; font-size: 24px; } h2 { font-size: 15px; margin-top: 26px; }
.hint { color: #9da8b3; font-size: 13px; margin: 6px 0 22px; }
.filters, .grid { display: grid; gap: 12px; }
label { display: grid; gap: 5px; color: #b8c2cc; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid #46515d; border-radius: 7px; padding: 9px 10px; color: #eef2f5; background: #151a1f; font: inherit; }
textarea { resize: vertical; }
button { border: 0; border-radius: 7px; padding: 9px 13px; color: white; background: #2479cf; cursor: pointer; font-weight: 600; }
button:hover { filter: brightness(1.1); } button.secondary { background: #414b55; } button.danger { background: #ad3540; }
.actions { display: flex; gap: 8px; margin-top: 4px; }
#map { height: 100vh; width: 100%; }
.unlocated { display: grid; gap: 7px; font-size: 13px; }.unlocated button { text-align: left; background: #303842; }
dialog { width: min(620px, calc(100vw - 30px)); max-height: calc(100vh - 30px); overflow-y: auto; border: 1px solid #46515d; border-radius: 12px; background: #20262d; color: inherit; box-shadow: 0 18px 60px #0009; }
dialog::backdrop { background: #080b0ecc; } dialog header { display: flex; justify-content: space-between; align-items: center; } dialog header h2 { margin: 0 0 16px; font-size: 20px; }
.icon { font-size: 24px; padding: 0 8px; background: transparent; }.grid { grid-template-columns: 1fr 1fr; }.wide { grid-column: 1 / -1; }
.error { color: #ff8b92; min-height: 1.2em; }.popup-meta { color: #4c5863; font-size: 12px; }.popup-actions { display: flex; gap: 6px; margin-top: 10px; }
.leaflet-popup-content { min-width: 220px; max-width: 290px; }.leaflet-popup-content h3 { margin: 0 0 7px; }.leaflet-popup-content p { margin: 5px 0; }
@media (max-width: 700px) { body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }.sidebar { max-height: 42vh; }.sidebar section { display: none; }#map { height: 58vh; }.grid { grid-template-columns: 1fr; }.wide { grid-column: auto; } }
.logout-form { margin: -10px 0 20px; }
.logout-form button { width: 100%; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #29323c, #15191e 65%); }
.login-card { width: min(390px, 100%); padding: 30px; border: 1px solid #3c4651; border-radius: 14px; background: #20262d; box-shadow: 0 20px 60px #0008; }
.login-card h1 { margin-bottom: 8px; }
.login-form { display: grid; gap: 15px; margin-top: 22px; }
.login-form button { margin-top: 5px; }
.login-error { padding: 10px 12px; border: 1px solid #8d3d45; border-radius: 7px; color: #ffb0b5; background: #4a252a; font-size: 13px; }
summary { cursor: pointer; color: #c8d1da; font-size: 13px; }
.nested-filters { margin-top: 12px; padding-left: 10px; border-left: 2px solid #3b4651; }
#editor { width: min(760px, calc(100vw - 30px)); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.finds-list { display: grid; gap: 9px; margin-top: 12px; }
.find-card { padding: 10px 12px; border: 1px solid #414b56; border-radius: 8px; background: #191e24; }
.find-card summary { font-weight: 600; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.photo-grid figure { width: 108px; margin: 0; padding: 6px; border: 1px solid #414b56; border-radius: 7px; background: #171b20; }
.photo-grid figcaption { margin: 4px 0; overflow: hidden; color: #aeb8c1; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 72px; height: 58px; border-radius: 5px; object-fit: cover; image-orientation: from-image; cursor: zoom-in; vertical-align: middle; }
.photo-grid figure .thumb { width: 94px; height: 72px; }
.popup-photos, .popup-find div { display: flex; gap: 4px; margin: 6px 0; }
.popup-find { margin: 7px 0; padding-top: 6px; border-top: 1px solid #ddd; font-size: 12px; }
.upload-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.small { padding: 5px 8px; font-size: 11px; }.muted { color: #8f9aa5; font-size: 13px; }
#lightbox { width: min(1000px, calc(100vw - 30px)); padding: 40px 16px 16px; text-align: center; background: #11161b; }
#lightbox .icon { position: absolute; top: 5px; right: 8px; }
#lightbox-image { max-width: 100%; max-height: 78vh; object-fit: contain; image-orientation: from-image; }
.exif-orientation-2 { transform: scaleX(-1); }
.exif-orientation-3 { transform: rotate(180deg); }
.exif-orientation-4 { transform: scaleY(-1); }
.exif-orientation-5 { transform: rotate(90deg) scaleY(-1) scale(.72); }
.exif-orientation-6 { transform: rotate(90deg) scale(.72); }
.exif-orientation-7 { transform: rotate(90deg) scaleX(-1) scale(.72); }
.exif-orientation-8 { transform: rotate(-90deg) scale(.72); }
.thumb[class*='exif-orientation-'], #lightbox-image[class*='exif-orientation-'] { transform-origin: center; }
#lightbox-caption { margin-bottom: 0; color: #bbc4cd; }
@media (max-width: 700px) { .upload-row { grid-template-columns: 1fr; } #editor, #find-editor { width: calc(100vw - 16px); } }
.popup-actions { flex-wrap: wrap; }
button.btn-copernicus { background: #174f78; color: #eaf6ff; }
.popup-navigation-actions { display: grid; flex: 1 0 100%; gap: 7px; width: 100%; }
.popup-navigation-actions button { width: 100%; min-height: 44px; white-space: normal; }
button.btn-yandex-route { color: #171b20; background: #f6d44a; }
.point-popup h4 { margin: 8px 0 4px; }
.map-legend { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid #52606d; border-radius: 7px; color: #e8edf2; background: #20262de8; box-shadow: 0 2px 10px #0006; font-size: 12px; line-height: 1.2; }
.map-legend strong { margin-bottom: 2px; font-size: 12px; }
.map-legend span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-dot { width: 11px; height: 11px; border: 1.5px solid #fff; border-radius: 50%; box-shadow: 0 0 2px #000; }
.point-pin-icon { background: transparent; border: 0; filter: drop-shadow(0 2px 3px #0007); cursor: pointer; }
.point-pin-icon svg { display: block; width: 44px; height: 44px; }
.point-cluster-icon { display: grid; place-items: center; border: 2px solid #fff; border-radius: 50%; background: #2563eb; color: #fff; box-shadow: 0 2px 8px #0007; font-weight: 700; font-size: 13px; cursor: pointer; }
.point-cluster-icon span { display: block; width: 100%; text-align: center; line-height: 44px; }
@media (max-width: 700px) { .map-legend { padding: 6px 8px; font-size: 11px; } }
#mobile-menu-toggle { display: none; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (max-width: 768px) {
  body { height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: 52px minmax(0, 1fr); overflow: hidden; }
  .sidebar, #map { width: 100%; max-width: 100%; min-width: 0; }
  .sidebar { position: relative; max-height: none; padding: 0; overflow: visible; box-shadow: 0 3px 12px #0006; z-index: 1000; }
  .sidebar-header { width: 100%; max-width: 100%; min-width: 0; height: 52px; padding: 7px max(16px, env(safe-area-inset-right)) 7px max(16px, env(safe-area-inset-left)); overflow-x: hidden; background: #20262d; }
  .sidebar-header h1 { flex: 1 1 auto; min-width: 0; overflow: hidden; font-size: 19px; text-overflow: ellipsis; white-space: nowrap; }
  #mobile-menu-toggle { display: block; flex: 0 0 auto; min-width: 96px; min-height: 44px; padding: 8px 10px; }
  .sidebar-content { display: none; position: absolute; top: 52px; left: 0; right: 0; width: 100%; max-width: 100%; min-width: 0; max-height: calc(100dvh - 52px); padding: 14px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left)); overflow-x: hidden; overflow-y: auto; background: #20262df7; box-shadow: 0 8px 18px #0007; }
  .sidebar.mobile-menu-open .sidebar-content { display: block; }
  .sidebar .hint { margin: 0 0 14px; }
  .sidebar .logout-form { margin: 0 0 14px; }
  .sidebar section { display: block; }
  .sidebar input, .sidebar select, .sidebar button { min-height: 42px; }
  #map { height: 100%; min-height: 0; }
}
.user-summary { display: grid; gap: 8px; margin: -10px 0 16px; color: #b9c4ce; font-size: 13px; }
.button-link { display: inline-block; border-radius: 7px; padding: 9px 13px; color: #fff; background: #2479cf; text-align: center; text-decoration: none; font-weight: 600; }
.button-link.secondary { background: #414b55; }
.admin-page { min-height: 100vh; display: block; overflow: auto; background: #171b20; }
.admin-shell { width: min(1180px, calc(100% - 30px)); margin: 0 auto; padding: 24px 0; }
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.admin-card { margin-top: 18px; padding: 18px; border: 1px solid #3d4752; border-radius: 10px; background: #20262d; }
.admin-card h2 { margin: 0 0 14px; font-size: 18px; }
.admin-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.table-wrap { overflow-x: auto; } table { width: 100%; border-collapse: collapse; font-size: 13px; } th,td { padding: 9px; border-bottom: 1px solid #3c4650; text-align: left; vertical-align: middle; } td .actions { min-width: 230px; }
@media (max-width: 768px) { .user-summary { margin-top: 0; } .admin-form { grid-template-columns: 1fr; } .admin-header { align-items: flex-start; } }
.location-popup h3 { margin: 0 0 6px; }.location-popup p { margin: 5px 0 9px; }
.location-popup .location-warning { color: #9b4d00; font-weight: 700; }
.map-tools-control { position: relative; margin: 0 0 12px 10px; }
.map-tools-buttons { display: grid; gap: 6px; }
.map-tool-button { display: grid; width: 44px; height: 44px; min-width: 44px; min-height: 44px; place-items: center; padding: 0; border: 1px solid #53616d; color: #edf4fa; background: #20262df2; box-shadow: 0 2px 9px #0007; }
.map-tool-button:hover, .map-tool-button:focus-visible { background: #2d75b8; }
.map-tool-button.is-following { border-color: #79c7ff; background: #1769aa; box-shadow: 0 0 0 2px #79c7ff55, 0 2px 9px #0007; }
.map-tool-button:disabled { cursor: wait; opacity: .85; }
.auth-debug-diagnostic { position: fixed; z-index: 10000; top: 12px; right: 12px; bottom: 12px; left: 12px; inset: 12px; max-width: 680px; max-height: 80vh; max-height: min(80vh,500px); margin: auto; overflow: auto; border: 2px solid #ef4444; border-radius: 12px; padding: 20px; color: #f8fafc; background: #20262df7; box-shadow: 0 8px 30px #000b; }
.auth-debug-diagnostic h2 { margin-top: 0; color: #fca5a5; }
.map-tool-icon { position: relative; display: block; width: 19px; height: 19px; }
.search-icon { width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 50%; }
.search-icon::after { position: absolute; right: -5px; bottom: -3px; width: 7px; height: 2px; background: currentColor; content: ''; transform: rotate(45deg); transform-origin: left center; }
.location-icon { width: 17px; height: 17px; border: 2px solid currentColor; border-radius: 50%; }
.location-icon::before, .location-icon::after { position: absolute; background: currentColor; content: ''; }
.location-icon::before { top: -5px; left: 6px; width: 2px; height: 23px; }
.location-icon::after { top: 6px; left: -5px; width: 23px; height: 2px; }
.map-tool-button.is-loading .location-icon { border-top-color: transparent; animation: map-tool-spin .8s linear infinite; }
@keyframes map-tool-spin { to { transform: rotate(360deg); } }
.map-search-panel { position: absolute; bottom: 0; left: 54px; width: min(420px, calc(100vw - 90px)); max-height: min(520px, calc(100vh - 30px)); overflow-x: hidden; overflow-y: auto; border: 1px solid #53616d; border-radius: 10px; padding: 8px; color: #e8edf2; background: #20262df7; box-shadow: 0 5px 20px #0009; box-sizing: border-box; }
.map-search-panel[hidden], .map-toast[hidden] { display: none; }
.map-search-header { display: flex; min-width: 0; min-height: 44px; align-items: center; justify-content: space-between; gap: 8px; padding-left: 4px; }
.map-search-header strong { flex: 1 1 auto; min-width: 0; }
.map-search-close { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; color: #e8edf2; background: transparent; font-size: 24px; }
.map-search-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
.map-search-form input, .map-search-form button { min-height: 44px; }
.map-search-form button { min-width: 76px; }
.map-search-status { padding: 8px 3px 1px; color: #dbe5ee; font-size: 13px; }
.map-search-status.error { min-height: 0; color: #ffb0b5; }
.map-search-results { display: grid; gap: 5px; max-height: 230px; margin-top: 7px; overflow-y: auto; }
.map-search-results button { min-height: 44px; padding: 8px 10px; color: #e8edf2; background: #303943; text-align: left; font-size: 13px; line-height: 1.25; }
.map-search-attribution { display: block; margin: 5px 2px 0; color: #aebbc6; font-size: 10px; text-align: right; }
.map-toast { position: absolute; bottom: 0; left: 54px; width: min(360px, calc(100vw - 90px)); border: 1px solid #596775; border-radius: 9px; padding: 11px 13px; color: #f2f6f9; background: #20262df7; box-shadow: 0 4px 18px #0009; font-size: 13px; line-height: 1.35; }
.search-result-popup .search-result-name { font-weight: 600; }
.search-result-popup button { width: 100%; min-height: 44px; }
#kml-import-dialog { width: min(640px, calc(100vw - 30px)); }
.kml-file-label { margin-top: 12px; }
.kml-file-label input { padding: 8px; }
.kml-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 12px 0; }
.kml-stats span { padding: 8px; border: 1px solid #46515d; border-radius: 7px; background: #171c22; font-size: 12px; }
.kml-preview-list { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.kml-preview-item { display: grid; gap: 3px; padding: 8px 10px; border: 1px solid #46515d; border-radius: 7px; background: #171c22; }
.kml-preview-item span, .kml-duplicate-note, #kml-warnings { color: #aeb8c1; font-size: 12px; }
#kml-warnings { max-height: 120px; overflow-y: auto; }
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px; }
  .leaflet-popup { max-width: calc(100vw - 20px); }
  .leaflet-popup-content-wrapper { border-radius: 8px; }
  .leaflet-popup-content { width: calc(100vw - 52px) !important; width: min(270px, calc(100vw - 52px)) !important; min-width: 0; max-width: none; margin: 6px 9px; overflow: hidden; font-size: 11px; line-height: 1.24; }
  .leaflet-popup-close-button { width: 34px !important; height: 34px !important; padding: 4px 4px 0 0 !important; font-size: 23px !important; line-height: 25px !important; }
  .point-popup { display: flex; max-height: 58vh; max-height: 58dvh; flex-direction: column; padding-right: 12px; overflow: hidden; }
  .point-popup-body { min-height: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .point-popup h3 { margin: 0 20px 3px 0; font-size: 14px; line-height: 1.18; }
  .point-popup h4 { margin: 3px 0 1px; font-size: 12px; line-height: 1.18; }
  .point-popup p { margin: 2px 0; }
  .point-popup .point-status, .point-popup .popup-meta { display: none; }
  .point-popup .popup-photos { gap: 2px; margin: 3px 0; overflow: hidden; }
  .point-popup .popup-photos .thumb, .point-popup .popup-find .thumb { width: 56px; height: 40px; max-width: 56px; max-height: 40px; object-fit: contain; image-orientation: from-image; }
  .point-popup .popup-find { margin: 3px 0; padding-top: 3px; font-size: 10px; line-height: 1.18; }
  .point-popup .popup-find div { gap: 2px; margin: 2px 0; }
  .point-popup .popup-actions { display: grid; flex: 0 0 auto; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 3px; margin: 3px -1px 0; padding: 3px 1px 1px; border-top: 1px solid #e0e0e0; background: #fff; }
  .point-popup .popup-actions > button, .point-popup .popup-navigation-actions button { min-height: 38px; padding: 4px 6px; font-size: 10px; line-height: 1.12; }
  .point-popup .popup-navigation-actions { grid-column: 1 / -1; gap: 3px; }
  .leaflet-left .map-tools-control { margin-bottom: calc(12px + env(safe-area-inset-bottom)); margin-left: 12px; }
  .map-search-panel { position: fixed; top: 64px; top: calc(64px + env(safe-area-inset-top)); right: 12px; right: max(12px, env(safe-area-inset-right)); bottom: auto; left: 12px; left: max(12px, env(safe-area-inset-left)); width: auto; max-width: none; max-height: none; margin: 0; padding: 12px; overflow: visible; }
  .map-search-header { min-height: 44px; margin-bottom: 8px; padding-left: 0; }
  .map-search-form { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .map-search-form input { width: 100%; max-width: 100%; min-width: 0; height: 46px; font-size: 16px; }
  .map-search-form button { width: 100%; height: 46px; }
  .map-search-results { max-height: min(40dvh, 320px); overflow-y: auto; }
  .map-toast { position: fixed; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); left: 12px; width: auto; }
  .leaflet-right .map-legend { max-width: calc(100vw - 24px); margin-right: 12px; margin-bottom: calc(8px + env(safe-area-inset-bottom)); overflow: hidden; padding: 6px 8px; font-size: 11px; }
  .leaflet-control-attribution { max-width: calc(100vw - 24px); margin-bottom: env(safe-area-inset-bottom) !important; white-space: normal; }
  dialog, #editor, #find-editor { position: fixed; inset: 0; width: calc(100vw - 24px); max-width: none; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); margin: auto; padding: 12px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  dialog > form { min-width: 0; }
  dialog > form > header { position: sticky; top: -12px; z-index: 3; margin: -12px -12px 0; padding: 12px; background: #20262d; }
  dialog > form > .actions { position: sticky; bottom: -12px; z-index: 3; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); margin: 12px -12px -12px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); background: #20262d; }
  dialog > form > .actions button { min-height: 44px; white-space: normal; }
  dialog .grid { grid-template-columns: minmax(0,1fr); }
  dialog .wide { grid-column: auto; }
  dialog input, dialog select, dialog textarea { width: 100%; min-width: 0; font-size: 16px; }
  .kml-stats { grid-template-columns: minmax(0,1fr); }
  .kml-preview-list { max-height: min(30dvh, 240px); }
}

.mobile-map-menu { display: none; }
.desktop-tracks-open { width: 100%; }
.track-control-button { display: none; }
#tracks-dialog { width: min(620px, calc(100vw - 30px)); }
#tracks-dialog > header { display: flex; align-items: center; justify-content: space-between; }
#tracks-dialog > header h2 { margin: 0; font-size: 20px; }
.tracks-list { display: grid; gap: 10px; }
.track-card { display: grid; gap: 7px; padding: 12px; border: 1px solid #46515d; border-radius: 10px; background: #171c22; }
.track-card-meta, .track-card-details { color: #aeb8c1; font-size: 12px; }
.track-card button { min-height: 44px; margin-top: 2px; }
.track-card-actions { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 7px; }
.track-card-actions [data-track-action='open'] { grid-column: 1 / -1; }
.tracks-pagination { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 8px; align-items: center; margin-top: 14px; text-align: center; }
.tracks-pagination button { min-height: 44px; }
#track-rename-dialog, #track-delete-dialog { width: min(430px, calc(100vw - 30px)); }
#track-rename-dialog label { margin-top: 16px; }
.track-delete-summary { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 7px 12px; margin: 18px 0; }
.track-delete-summary dt { color: #aeb8c1; }
.track-delete-summary dd { margin: 0; font-weight: 600; }
.track-delete-warning { color: #ffb0b5; font-weight: 700; }

@keyframes track-control-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,68,89,.4), 0 2px 9px rgba(0,0,0,.47); }
  50% { box-shadow: 0 0 0 7px rgba(255,68,89,0), 0 2px 9px rgba(0,0,0,.47); }
}

@media (max-width: 768px) {
  body { position: relative; display: block; height: 100vh; height: 100dvh; overflow: hidden; }
  #map { position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100vh; height: 100dvh; }
  .sidebar { position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; width: 100%; max-height: none; padding: 0; overflow: visible; pointer-events: none; background: transparent; box-shadow: none; z-index: 1400; }
  .sidebar-header { position: static; width: 0; height: 0; padding: 0; overflow: visible; background: transparent; }
  .sidebar-header h1 { display: none; }
  #mobile-menu-toggle { position: fixed; top: 12px; top: calc(12px + env(safe-area-inset-top)); right: 12px; right: max(12px, env(safe-area-inset-right)); display: grid; width: 48px; height: 48px; min-width: 48px; min-height: 48px; place-items: center; overflow: hidden; padding: 0; border: 1px solid rgba(255,255,255,.67); border-radius: 50%; pointer-events: auto; color: transparent; background: #e52337; box-shadow: 0 3px 12px rgba(0,0,0,.6); font-size: 0; }
  #mobile-menu-toggle::before { color: #fff; content: '☰'; font-size: 24px; line-height: 1; }
  #mobile-menu-toggle[aria-expanded='true']::before { content: '×'; font-size: 30px; }
  .sidebar-content { position: fixed; top: 70px; top: calc(70px + env(safe-area-inset-top)); right: 12px; right: max(12px, env(safe-area-inset-right)); bottom: auto; left: auto; display: none; width: calc(100vw - 24px); width: min(320px, calc(100vw - 24px)); max-height: calc(100vh - 84px); max-height: calc(100dvh - 84px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 12px; overflow-x: hidden; overflow-y: auto; border: 1px solid #53616d; border-radius: 14px; pointer-events: auto; background: rgba(32,38,45,.97); box-shadow: 0 10px 28px rgba(0,0,0,.67); }
  .sidebar.mobile-menu-open .sidebar-content { display: block; }
  .mobile-map-menu { display: grid; gap: 8px; }
  .desktop-tracks-open { display: none; }
  .mobile-map-menu button { width: 100%; min-height: 48px; text-align: left; }
  .mobile-settings-content { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid #46515d; }
  .mobile-settings-content.is-open { display: block; }
  .mobile-settings-content .logout-form, .mobile-settings-content #kml-import-open { display: none; }
  .leaflet-bottom.leaflet-left { z-index: 1300; pointer-events: none; }
  .leaflet-left .map-tools-control { margin-bottom: calc(14px + env(safe-area-inset-bottom)); margin-left: max(12px, env(safe-area-inset-left)); pointer-events: auto; }
  .map-tools-buttons { gap: 8px; }
  #map-search-toggle { position: fixed; top: 68px; top: calc(68px + env(safe-area-inset-top)); right: 12px; right: max(12px, env(safe-area-inset-right)); z-index: 1300; width: 48px; height: 48px; border-color: rgba(255,255,255,.67); border-radius: 50%; background: #2479cf; }
  .track-control-button { display: grid; width: 48px; height: 48px; border: 2px solid #fff; border-radius: 50%; }
  .track-control-dot { width: 18px; height: 18px; border: 2px solid #fff; border-radius: 50%; background: #777f88; }
  .track-control-button.track-off { background: #414952; }
  .track-control-button.track-recording { background: #e52337; animation: track-control-pulse 1.25s ease-in-out infinite; }
  .track-control-button.track-recording .track-control-dot { background: #ff3045; }
  .track-control-button.track-paused { background: #d79a16; }
  .track-control-button.track-paused .track-control-dot { background: #ffd15a; }
  .map-search-panel { top: 126px; top: calc(126px + env(safe-area-inset-top)); max-height: calc(100vh - 142px); max-height: calc(100dvh - 142px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
  .leaflet-top.leaflet-right .leaflet-control-layers { margin-top: 126px; margin-right: max(12px, env(safe-area-inset-right)); }
  #tracks-dialog { width: calc(100vw - 24px); }
  .tracks-pagination { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .tracks-pagination span { grid-column: 1 / -1; grid-row: 1; }
  .tracks-pagination button { grid-row: 2; }
  .track-card-actions { grid-template-columns: minmax(0,1fr); }
  .track-card-actions [data-track-action='open'] { grid-column: auto; }
  #tracks-dialog > header { position: sticky; top: -12px; z-index: 3; margin: -12px -12px 8px; padding: 12px; background: #20262d; }
}

@media (hover: none) and (pointer: coarse) {
  .map-tool-button:hover, .map-tool-button:active, .map-tool-button:focus { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .track-control-button.track-recording { animation: none; }
}
@media (max-width: 768px) {
  @supports not (display: grid) {
    .mobile-map-menu, .map-tools-buttons { display: flex; flex-direction: column; }
    .mobile-map-menu button + button, .map-tools-buttons > .map-tool-button + .map-tool-button { margin-top: 8px; }
    #mobile-menu-toggle, .map-tool-button, .track-control-button { display: flex; align-items: center; justify-content: center; }
  }
}
