:root {
  --bg: #ffffff;
  --fg: #1d2330;
  --muted: #6b7385;
  --line: #e3e6ec;
  --accent: #1a73e8;
  --accent-fg: #ffffff;
  --btn: #f2f4f7;
  --btn-hover: #e6e9ef;
  --warn: #c5221f;
  --ok: #188038;
  --shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f2229;
    --fg: #e8eaed;
    --muted: #9aa0ab;
    --line: #353a45;
    --accent: #8ab4f8;
    --accent-fg: #0b1a33;
    --btn: #2b2f38;
    --btn-hover: #363b46;
    --warn: #f28b82;
    --ok: #81c995;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #111; color: var(--fg);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; background: #222; }

/* ---------- panel ---------- */
#panel {
  position: fixed; top: 10px; left: 10px; bottom: 10px; width: 320px; z-index: 1000;
  background: var(--bg); border-radius: 12px; box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 14px;
}
body.panel-hidden #panel { display: none; }
#panel header { position: sticky; top: 0; background: var(--bg); z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 0 10px 40px; border-bottom: 1px solid var(--line); }
#panel h1 { font-size: 15px; margin: 0; }
#panel section { padding: 12px 0; border-bottom: 1px solid var(--line); }
#panel section:last-child { border-bottom: 0; }
#panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; color: var(--muted); }
#panel h2 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
body.locked .edit-only { display: none; }

.panel-toggle { position: fixed; top: 18px; left: 18px; z-index: 1001; width: 30px; height: 30px;
  border: 0; border-radius: 8px; background: var(--btn); color: var(--fg); cursor: pointer; font-size: 16px; }
body.panel-hidden .panel-toggle { box-shadow: var(--shadow); background: var(--bg); }

.btn { appearance: none; border: 1px solid var(--line); background: var(--btn); color: var(--fg);
  border-radius: 7px; padding: 6px 10px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.sm { padding: 4px 6px; font-size: 12px; }
.btn.active { outline: 2px solid var(--accent); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.lock { border: 0; border-radius: 999px; padding: 6px 12px; font: 600 12px system-ui, sans-serif; cursor: pointer;
  background: #fbe9e7; color: #b3261e; }
.lock.is-locked { background: #e6f4ea; color: #137333; }

select, input[type=search], input[type=number] {
  font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 8px; min-width: 0; }
select { width: 100%; }
#searchForm input { flex: 1; }
input[type=number] { width: 90px; }
.slider, .field { display: block; margin-top: 8px; }
.slider input[type=range] { width: 100%; display: block; margin-top: 4px; }
.slider output { float: right; color: var(--muted); }
.slider .num { float: right; }
.slider .num input { width: 80px; padding: 2px 6px; }
.field .row input { flex: 1; width: 0; }
.field .num input { width: 90px; margin-left: 6px; }
.check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; margin-right: 8px; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); }

#pairList { margin: 8px 0 0; padding-left: 20px; }
#pairList li { padding: 2px 0; }
#pairList li button { float: right; border: 0; background: none; color: var(--warn); cursor: pointer; font: inherit; }
#pairList .err { color: var(--muted); font-size: 12px; }

/* ---------- map chrome ---------- */
#banner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1002;
  background: #202124; color: #fff; padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow);
  font-weight: 500; max-width: calc(100vw - 24px); text-align: center; }
#banner b { color: #fdd663; }
#readout { position: fixed; right: 10px; bottom: 22px; z-index: 999; background: rgba(32,33,36,.8); color: #fff;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 8px; border-radius: 6px; pointer-events: none; }
#readout:empty { display: none; }
#drop { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: rgba(26,115,232,.25);
  color: #fff; font-size: 28px; font-weight: 700; border: 4px dashed #fff; }
#drop[hidden] { display: none; }

.leaflet-pane.plan-pane { pointer-events: none; }
.plan-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
body.editing #map.over-plan { cursor: move; }
body.picking #map, body.picking #map .leaflet-interactive { cursor: crosshair; }

.handle { width: 16px !important; height: 16px !important; margin: -8px 0 0 -8px !important;
  background: #fff; border: 3px solid #1a73e8; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.5); cursor: grab; }
.pin { width: 22px !important; height: 22px !important; margin: -11px 0 0 -11px !important; border-radius: 50%;
  color: #fff; font: 700 11px/18px system-ui, sans-serif; text-align: center; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.pin.img { background: #d93025; pointer-events: none; }
.pin.geo { background: #188038; cursor: grab; }

@media (max-width: 640px) {
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 55vh; border-radius: 14px 14px 0 0; }
  #panel header { padding-left: 0; }
  .panel-toggle { top: auto; bottom: 12px; left: 12px; }
  body:not(.panel-hidden) .panel-toggle { bottom: calc(55vh + 8px); }
  #readout { bottom: auto; top: 56px; }
}
