:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --bg: #16181b;
  --panel: rgba(24, 26, 30, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8e6e1;
  --muted: #a3a09a;
  --accent: #e0915a;
  --accent-ink: #1a1308;
  --control: #2b2e33;
  --control-hover: #363a40;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; font-size: 13px; }
#view { position: absolute; inset: 0; }

header.bar {
  position: absolute; top: calc(12px + var(--safe-top)); left: 12px; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 6px 6px 6px 14px; backdrop-filter: blur(8px);
}
header.bar h1 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: 0.01em; white-space: nowrap; }
a.home-link {
  font-family: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--control);
  border: 1px solid var(--panel-border);
  white-space: nowrap;
}
a.home-link:hover { color: var(--text); background: var(--control-hover); border-color: var(--accent); }
nav.tabs { display: flex; gap: 2px; background: var(--control); border-radius: 8px; padding: 2px; }
nav.tabs a {
  color: var(--muted); text-decoration: none; padding: 5px 12px; border-radius: 6px; font-weight: 500; white-space: nowrap;
}
nav.tabs a:hover { color: var(--text); }
nav.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

aside.panel {
  position: absolute; top: calc(64px + var(--safe-top)); left: 12px; bottom: 12px; z-index: 4; width: 300px;
  display: flex; flex-direction: column; gap: 0;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  backdrop-filter: blur(8px); overflow: hidden;
}
aside.panel .scroll { overflow-y: auto; padding: 4px 14px 14px; }
aside.panel h2 {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  margin: 14px 0 8px;
}
.row { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.row label { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.row label span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row input[type="range"] { width: 90px; }
.row select { flex: none; }
.sub { padding-left: 26px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,0.35); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; }
input[type="range"] { accent-color: var(--accent); }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 6px 0 10px; }
.slider input { grid-column: 1 / -1; width: 100%; }
.slider output { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { display: grid; gap: 3px; margin-top: 4px; }
.legend .item { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 12px; line-height: 1.3; }
.legend .item .swatch { margin-top: 2px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
button, select {
  font: inherit; color: var(--text); background: var(--control); border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
button:hover, select:hover { background: var(--control-hover); }
.note { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 6px 0; }
.note a { color: var(--accent); }

#info {
  position: absolute; right: 12px; bottom: 34px; z-index: 4; max-width: 340px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 10px 12px; line-height: 1.5; display: none; backdrop-filter: blur(8px);
}
#info .k { color: var(--muted); }
#info.show { display: block; }
#status {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 12px 18px;
}
#status:empty { display: none; }
#toggle-panel { display: none; }

.maplibregl-popup-content { background: var(--panel) !important; color: var(--text); border-radius: 8px !important; }
.maplibregl-popup-tip { border-top-color: var(--panel) !important; border-bottom-color: var(--panel) !important; }
.maplibregl-ctrl-attrib { background: rgba(24, 26, 30, 0.7) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

@media (max-width: 700px) {
  header.bar { right: 12px; padding-left: 10px; }
  header.bar h1 { font-size: 13px; }
  a.home-link .home-host { display: none; }
  aside.panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 45vh; border-radius: var(--radius) var(--radius) 0 0; }
  aside.panel.collapsed .scroll { display: none; }
  #toggle-panel { display: block; margin: 8px 14px 0; }
  #info { left: 12px; right: 12px; bottom: auto; top: calc(64px + var(--safe-top)); max-width: none; }
}
@media (max-width: 700px) {
  .maplibregl-ctrl-top-right { top: calc(56px + var(--safe-top)); }
}

/* ---------------------------------------------------------------- rock-layers sidebar (column.js) */
:root { --column-w: 420px; --hl: #ffd65c; }
body.column-wide { --column-w: min(1000px, calc(100vw - 360px)); }
body.column-wide .column-figure { width: min(100%, calc((100vh - 300px) * 1.5)); margin: 0 auto; }
.column-toggle { display: flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; max-width: 280px; }
.column-toggle[aria-pressed="true"] { background: var(--control-hover); box-shadow: inset 0 0 0 1px var(--accent); }
.column-toggle .sel { color: var(--hl); overflow: hidden; text-overflow: ellipsis; }
.column-toggle .sel:empty { display: none; }
.column-toggle .sel::before { content: "· "; color: var(--muted); }

aside.column-panel {
  position: absolute; top: calc(64px + var(--safe-top)); right: 12px; bottom: 12px; z-index: 4; width: var(--column-w);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  backdrop-filter: blur(8px); overflow: hidden;
}
aside.column-panel[hidden] { display: none; }
.column-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 6px 14px; border-bottom: 1px solid var(--panel-border); }
.column-head h2 { flex: 1; margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.column-head button { padding: 3px 9px; font-size: 12px; }
.column-top { padding: 10px 14px 0; flex: none; border-bottom: 1px solid var(--panel-border); }
.column-scroll { overflow-y: auto; padding: 6px 14px 14px; min-height: 0; }
.column-figure { position: relative; border-radius: 6px; overflow: hidden; background: #fff; line-height: 0; user-select: none; aspect-ratio: 1300 / 867; }
.column-stage { position: absolute; inset: 0; transform-origin: 0 0; transition: transform 0.45s cubic-bezier(.2,.7,.2,1); }
.column-stage img, .column-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.column-stage canvas { pointer-events: none; }
.column-fit { position: absolute; right: 6px; bottom: 6px; line-height: 1.2; font-size: 11.5px; padding: 3px 8px; background: rgba(24, 26, 30, 0.85); }
.column-fit[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .column-stage { transition: none; } }
.column-caption { margin: 8px 0; min-height: 20px; color: var(--muted); line-height: 1.4; }
.column-caption.has { color: var(--hl); font-weight: 600; }
.column-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.column-list li { display: flex; gap: 9px; align-items: flex-start; padding: 5px 8px; border-radius: 6px; cursor: pointer; line-height: 1.3; border: 1px solid transparent; }
.column-list li:hover { background: var(--control); }
.column-list li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.column-list li .swatch { margin-top: 2px; }
.column-list li .t { display: flex; flex-direction: column; min-width: 0; }
.column-list li .sub { color: var(--muted); font-size: 11.5px; }
.column-list li.absent .nm { color: var(--muted); }
.column-list li.on { background: rgba(255, 214, 92, 0.12); border-color: var(--hl); }
.column-list li.on .nm { color: var(--hl); font-weight: 600; }

/* keep the map controls and the info box clear of the open sidebar */
body.column-open .maplibregl-ctrl-top-right,
body.column-open .maplibregl-ctrl-bottom-right { right: calc(var(--column-w) + 12px); }
body.column-open #info { right: calc(var(--column-w) + 24px); }

@media (max-width: 700px) {
  header.bar { flex-wrap: wrap; }
  .column-toggle { max-width: 100%; }
  aside.column-panel { top: calc(104px + var(--safe-top)); left: 12px; right: 12px; bottom: auto; width: auto; max-height: 55vh; }
  body.column-open .maplibregl-ctrl-top-right,
  body.column-open .maplibregl-ctrl-bottom-right { right: 0; }
  body.column-open #info { right: 12px; }
  .column-head #column-expand { display: none; }
}

.maplibregl-ctrl-top-right { top: var(--safe-top); }

/* ---------------------------------------------------------------- offline section (offline.js) */
.off-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; padding: 4px 0; }
.off-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.off-st { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.off-btn { padding: 3px 10px; font-size: 12px; min-width: 70px; }
.off-btn.saved { color: var(--muted); }
.off-bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--control); overflow: hidden; }
.off-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.off-bar[hidden] { display: none; }
.off-foot { margin-top: 6px; }

/* ---------------------------------------------------------------- tablets: one panel at a time */
@media (min-width: 701px) and (max-width: 1100px) {
  :root { --column-w: 380px; }
  body.column-wide { --column-w: calc(100vw - 24px); }
  #toggle-panel { display: block; margin: 8px 14px 0; flex: none; }
  aside.panel.collapsed { bottom: auto; }
  aside.panel.collapsed .scroll { display: none; }
  aside.panel.collapsed #toggle-panel { margin-bottom: 8px; }
}
@media (pointer: coarse) {
  .column-list li { padding: 8px; }
  .off-btn { padding: 6px 12px; }
}
