:root {
  --ink: #f2f1ec; --muted: rgba(242, 241, 236, 0.62); --bg: rgba(16, 19, 23, 0.84); --bg2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12); --accent: #ffd23f; --hike: #ff5a2e; --ski: #2a7bff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a1f25; color: var(--ink);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; touch-action: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; padding: 6px 10px; }
button:hover { border-color: rgba(255, 255, 255, 0.3); }
button.primary { background: rgba(255, 210, 63, 0.16); border-color: var(--accent); font-weight: 600; flex: 1; }
button.primary:disabled { opacity: 0.55; cursor: progress; }
button.ghost { background: none; }
input, select { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; min-width: 0; }
select option { background: #1d2228; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row > input[type=search] { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); white-space: nowrap; }
.chips label { font-size: 12px; display: flex; gap: 4px; align-items: center; padding: 2px 8px; border: 1px solid var(--line); border-radius: 10px; }

#side { position: fixed; top: 12px; left: 12px; bottom: 40px; width: 360px; display: flex; flex-direction: column;
  background: var(--bg); backdrop-filter: blur(10px); border-radius: 14px; border: 1px solid var(--line); overflow: hidden; z-index: 5; }
#side > header, #side > section { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; letter-spacing: 0.02em; margin-bottom: 8px; }
.brand .logo { color: var(--accent); }
.brand small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
#region-form { display: flex; gap: 8px; }
#region-form input { flex: 1; }
#crawl-log { margin: 6px 0 0; padding-left: 18px; max-height: 120px; overflow: auto; font-size: 11px; color: var(--muted); }
#crawl-status { margin-top: 6px; }
.static-site .local-only, body:not(.static-site) .static-only { display: none; }
#browse { display: flex; flex-direction: column; min-height: 0; flex: 1; border-bottom: none !important; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { flex: 1; border: none; border-radius: 0; background: none; padding: 6px 4px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: rgba(255, 210, 63, 0.18); color: #fff; font-weight: 600; }
#count { margin-left: auto; }
.kinds { display: flex; flex-wrap: wrap; gap: 5px; }
.kinds button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 14px; font-size: 12.5px; background: none; }
.kinds button i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.kinds button.on { background: rgba(255, 210, 63, 0.18); border-color: var(--accent); color: #fff; font-weight: 600; }
.kinds button::after { content: attr(data-count); font-size: 10.5px; color: var(--muted); font-weight: 400; }
.kinds button.none { opacity: 0.4; }
#list { list-style: none; margin: 8px -14px 0; padding: 0; overflow-y: auto; flex: 1; }
#list li { padding: 8px 14px; border-top: 1px solid rgba(255, 255, 255, 0.05); cursor: pointer; display: grid; grid-template-columns: 10px 1fr; gap: 2px 9px; }
#list li:hover, #list li.hover { background: rgba(255, 255, 255, 0.07); }
#list li .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; }
#list li .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list li .meta { grid-column: 2; font-size: 12px; color: var(--muted); }
#list .empty { color: var(--muted); padding: 16px 14px; cursor: default; display: block; }

#detail { overflow-y: auto; flex: 1; border-bottom: none !important; }
#detail h2 { margin: 8px 0 4px; font-size: 18px; line-height: 1.25; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stats div { background: var(--bg2); border-radius: 8px; padding: 6px 8px; }
.stats b { display: block; font-size: 15px; }
.stats span { font-size: 11px; color: var(--muted); }
#profile { width: 100%; height: 110px; background: rgba(0, 0, 0, 0.25); border-radius: 8px; cursor: crosshair; }
#d-desc { color: rgba(242, 241, 236, 0.85); font-size: 13px; }
#d-img { width: 100%; border-radius: 8px; margin: 4px 0 8px; }
#detail.drop { outline: 2px dashed var(--accent); outline-offset: -8px; background: rgba(255, 210, 63, 0.06); }
#d-actions { flex-wrap: wrap; }
#d-actions a, #d-actions button { text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--bg2); font-size: 13px; }

.panel { position: fixed; background: var(--bg); backdrop-filter: blur(10px); border-radius: 12px; border: 1px solid var(--line); z-index: 5; }
#layers { top: 12px; right: 12px; width: 250px; padding: 12px; }
#layers .field { display: grid; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--muted); }
#layers .field select { color: var(--ink); font-size: 13px; }
#layers .checks { display: grid; gap: 5px; margin-top: 10px; font-size: 13px; }
#layers .checks label { display: flex; gap: 7px; align-items: center; cursor: pointer; }
#s2-info { margin-top: 4px; }
#mapstyle { margin-top: 10px; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; translate: -50% -100%; white-space: nowrap; font-weight: 600; font-size: 12px; color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.8); letter-spacing: 0.01em; }
.label.peak::before { content: '▲ '; font-size: 9px; color: #ffd8a8; }
.label.saddle::before { content: '⌒ '; color: #d8e6ff; }
.label.place.town, .label.place.city { font-size: 14px; font-weight: 700; }
.label.place.hamlet { font-weight: 500; font-size: 11px; opacity: 0.9; }
.legend { display: flex; margin-top: 8px; font-size: 10px; }
.legend span { flex: 1; border-top: 6px solid var(--c); padding-top: 2px; color: var(--muted); }
#sun { width: 100%; }
#nav { right: 12px; bottom: 44px; display: grid; padding: 4px; gap: 2px; border-radius: 22px; }
#nav button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: none; background: none; border-radius: 50%; font-size: 18px; line-height: 1; }
#nav button:hover { background: rgba(255, 255, 255, 0.1); }
#nav #tilt { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
#nav #help-btn { font-size: 14px; color: var(--muted); }
#help { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(8, 10, 12, 0.45); }
#help .card { position: relative; max-width: 560px; margin: 16px; padding: 18px 22px; }
#help h3 { margin: 0 0 10px; font-size: 16px; }
#help .close { position: absolute; top: 10px; right: 10px; padding: 2px 8px; }
#help .keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; align-items: baseline; }
#help .keys b { font-weight: 600; white-space: nowrap; }
#help .keys span { color: rgba(242, 241, 236, 0.8); }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; margin: 0 1px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 4px;
  font: 11px/17px ui-monospace, Menlo, monospace; text-align: center; }

#status { position: fixed; left: 0; right: 0; bottom: 0; height: 30px; padding-bottom: env(safe-area-inset-bottom); display: flex; gap: 16px; align-items: center; padding: 0 14px;
  background: rgba(12, 14, 17, 0.8); font-size: 12px; z-index: 6; white-space: nowrap; overflow: hidden; }
#cursor { font-variant-numeric: tabular-nums; min-width: 260px; }
#loading { color: var(--accent); min-width: 110px; }
#status .attr { margin-left: auto; color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }
#tooltip { position: fixed; pointer-events: none; z-index: 7; background: rgba(12, 14, 17, 0.9); padding: 4px 9px; border-radius: 8px; font-size: 12px;
  transform: translate(12px, -50%); white-space: nowrap; border: 1px solid var(--line); }

#layers-btn { display: none; }
#sheet-handle { display: none; }

/* phones: the map fills the screen; the side panel is a bottom sheet (peek, half, full) pulled up by its handle */
@media (max-width: 760px) {
  html, body { height: 100dvh; }
  #side { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: var(--sheet-h, 72px); border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom); transition: height 0.22s ease; border-bottom: none; }
  #side.dragging { transition: none; }
  #side > header, #side > section { padding: 8px 12px; }
  #side > header { padding-top: 0; }
  #sheet-handle { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 0 6px; cursor: grab; touch-action: none; }
  #sheet-handle .grip { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); }
  #sheet-summary { font-size: 12px; color: var(--muted); max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand { display: none; }
  #side[data-sheet="peek"] > section { visibility: hidden; }
  #crawl-status { margin-top: 4px; }
  #browse .row { margin-top: 6px; }
  #list { margin: 6px -12px 0; }
  #list li { padding: 7px 12px; }
  #layers-btn { display: grid; place-items: center; top: calc(8px + env(safe-area-inset-top)); right: 8px; width: 42px; height: 42px; padding: 0; border-radius: 50%; }
  #layers { display: none; width: 230px; top: calc(58px + env(safe-area-inset-top)); right: 8px; padding: 10px; max-height: calc(100dvh - var(--sheet-h, 72px) - 80px); overflow-y: auto; }
  #layers.open { display: block; }
  #nav { bottom: calc(var(--sheet-h, 72px) + 28px); right: 8px; transition: bottom 0.22s ease; }
  #nav #help-btn { display: none; }
  #side[data-sheet="full"] ~ #nav { display: none; }
  #help .keys { grid-template-columns: 1fr; gap: 2px; }
  #help .keys span { margin-bottom: 6px; }
  /* the status line shrinks to the attribution, just above the sheet; tap it to read all */
  #status { left: 0; right: 0; bottom: var(--sheet-h, 72px); height: auto; padding: 3px 10px; background: none; z-index: 4; pointer-events: auto; }
  #status #cursor, #status #loading { display: none; }
  #status .attr { margin-left: 0; font-size: 9px; color: rgba(255, 255, 255, 0.75); text-shadow: 0 0 2px #000; white-space: nowrap; }
  #status.open .attr { white-space: normal; background: rgba(12, 14, 17, 0.85); padding: 6px 8px; border-radius: 8px; }
}
