:root {
  --paper: #f6f1e4;
  --ink: #2d2a24;
  --muted: #6d665a;
  --line: #d8cfbb;
  --accent: #7a4b2a;
  --panel-shadow: 0 2px 14px rgba(40, 30, 10, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #8fb3c4; font: 14px/1.4 "Georgia", "Iowan Old Style", serif; color: var(--ink); }
#map { position: absolute; inset: 0; }

#panel {
  position: absolute; top: 12px; left: 12px; width: 250px; max-height: calc(100% - 24px); overflow: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--panel-shadow);
  padding: 10px 14px 12px;
}
#panel header { display: flex; align-items: center; justify-content: space-between; }
h1 { margin: 0; font-size: 22px; letter-spacing: .28em; font-weight: normal; }
h2 { margin: 14px 0 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-family: system-ui, sans-serif; font-weight: 600; }
section label { display: flex; gap: 8px; align-items: center; padding: 2px 0; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.search input { width: 100%; margin-top: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fffdf7; font: inherit; }
button { font: inherit; cursor: pointer; }
#collapse, #expand { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }
#expand { position: absolute; top: 12px; left: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; box-shadow: var(--panel-shadow); }
.mode { display: flex; gap: 4px; margin-bottom: 6px; }
.mode label { flex: 1; justify-content: center; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: #fffdf7; }
.mode label:has(input:checked) { background: var(--accent); color: #fff; border-color: var(--accent); }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
section label.off { opacity: 0.45; cursor: default; }
.tool { width: 100%; margin-top: 6px; padding: 5px; border: 1px solid var(--line); border-radius: 4px; background: #fffdf7; }
.tool.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#measure-out { margin-top: 6px; font-family: system-ui, sans-serif; font-size: 13px; }
#legend { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#legend li { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
#legend .sw { width: 14px; height: 14px; border-radius: 2px; border: 1px solid rgba(0,0,0,.2); flex: none; }
#legend .km { margin-left: auto; color: var(--muted); font-family: system-ui, sans-serif; font-size: 11px; }

#readout {
  position: absolute; right: 12px; bottom: 30px; background: rgba(246, 241, 228, .92); border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 8px; font: 12px system-ui, sans-serif; color: var(--ink); pointer-events: none; min-width: 180px;
}
#readout:empty { display: none; }

.maplibregl-popup-content { background: var(--paper); font-family: Georgia, serif; border-radius: 6px; padding: 10px 14px; }
.maplibregl-popup-tip { border-top-color: var(--paper) !important; border-bottom-color: var(--paper) !important; }
.popup h3 { margin: 0 0 2px; font-size: 16px; font-weight: normal; }
.popup .kind { color: var(--muted); font: 11px system-ui, sans-serif; text-transform: uppercase; letter-spacing: .1em; }
.popup p { margin: 6px 0 0; }
.popup .verify { color: #a0522d; font-size: 12px; }

@media (max-width: 600px) {
  #panel { width: calc(100% - 24px); max-height: 45%; }
  #readout { left: 12px; right: 12px; min-width: 0; }
}

#load-error {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 460px; width: calc(100% - 32px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--panel-shadow);
  padding: 16px 20px; line-height: 1.5;
}
#load-error code { font-size: 12px; background: #fffdf7; padding: 1px 4px; border-radius: 3px; }
