:root {
  --bg: #141414;
  --panel: #1e1e1e;
  --ink: #f3f3f3;
  --muted: #b0b0b0;
  --accent: #e8b923;
  --line: #333;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Segoe UI, system-ui, sans-serif; background: var(--bg); color: var(--ink); }
body.map-page {
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
}
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 1500;
}
.bar-main { min-width: 0; flex: 1; }
.bar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub, .muted, .hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.back {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  flex-shrink: 0;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}
.panel-head .back { flex: 1; min-width: 0; }
.panel h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.panel .sub {
  margin: 4px 0 12px;
  font-size: 12px;
  line-height: 1.35;
}
.panel-hide,
.panel-show {
  flex-shrink: 0;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #2a2a2a;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.panel-hide:hover,
.panel-show:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.panel-show {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1100;
  min-height: 36px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.map-page.panel-collapsed .panel-show { display: block; }
.panel-toggle {
  margin-left: auto;
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #2a2a2a;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.panel-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
.panel-backdrop {
  display: none;
}
.catalog { padding: 20px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.card {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: inherit;
  text-decoration: none;
}
.card img { width: 120px; height: 90px; object-fit: cover; border-radius: 4px; background: #000; }
.card h2 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; font-size: 13px; color: var(--muted); }
.card .link { color: var(--accent); margin-top: 8px; }
.map-page {
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: 196px 1fr;
  height: 100dvh;
  height: 100vh;
}
.map-page.panel-collapsed { grid-template-columns: 0 1fr; }
.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 10px 12px;
  overflow: auto;
  min-width: 0;
}
.map-page.panel-collapsed .panel {
  visibility: hidden;
  padding: 0;
  border: 0;
  overflow: hidden;
}
.row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; }
.row:has(> input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  min-height: 28px;
  margin-bottom: 6px;
}
.row input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; }
.row input[type="range"], .row select { width: 100%; }
.legend { margin: -6px 0 16px; padding: 8px 0 0; font-size: 13px; }
.legend-item { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--muted); }
.legend-swatch {
  width: 16px;
  height: 10px;
  border: 2px solid #888;
  background: transparent;
  flex-shrink: 0;
}
.coords {
  margin: 0 0 16px;
  padding: 10px;
  background: #161616;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  line-height: 1.45;
}
.coords-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.map-wrap { position: relative; min-height: 0; min-width: 0; height: 100%; }
#map { height: 100%; background: #0b0b0b; touch-action: none; }
.leaflet-container { background: #0b0b0b; font-family: inherit; cursor: grab; touch-action: none; }
.leaflet-container:active { cursor: grabbing; }
.map-rotator { position: absolute; top: 0; left: 0; }
.return-ortho {
  display: none;
  width: 100%;
  margin: -6px 0 14px;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #2a240e;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.return-ortho.is-visible,
.return-ortho-map.is-visible { display: block; }
.return-ortho-map {
  display: none;
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1000;
  padding: 10px 16px;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #1a1a1a;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.compass {
  position: absolute;
  top: 10px;
  right: max(10px, env(safe-area-inset-right));
  z-index: 1000;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #555;
  background: #141414;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
  overflow: hidden;
}
.compass:hover { border-color: var(--accent); }
.compass-rose {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
}

@media (max-width: 720px) {
  .bar { padding: 8px 10px; gap: 8px; }
  .bar h1 { font-size: 16px; }
  .catalog { padding: 12px; }
  .card { min-height: 72px; }
  .row:has(> input[type="checkbox"]) { min-height: 44px; }
  .map-page,
  .map-page.panel-collapsed {
    display: grid;
    grid-template-rows: 1fr;
    grid-template-columns: 1fr;
  }
  .map-wrap {
    min-height: 0;
    width: 100%;
  }
  .map-page.panel-collapsed .panel {
    visibility: visible;
    overflow: auto;
    padding: 12px;
    border-right: 1px solid var(--line);
  }
  .panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 88vw);
    z-index: 1600;
    visibility: visible;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    border-right: 1px solid var(--line);
    box-shadow: none;
  }
  .map-page.panel-open .panel {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.45);
  }
  .panel-show {
    min-height: 44px;
    z-index: 1500;
  }
  .panel-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1550;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.45);
    cursor: pointer;
  }
  .map-page.panel-open .panel-backdrop {
    display: block;
  }
  .leaflet-control-zoom a {
    width: 36px;
    height: 36px;
    line-height: 36px;
  }
}
