:root {
  --bg: #11161c; --panel: rgba(20, 26, 33, 0.92); --line: rgba(255, 255, 255, 0.1); --text: #e8edf2; --mute: #9aa7b4;
  --acc: #f2b33d; --acc2: #4fa3ff; --cut: #e5483a; --fill: #3d74f0; --ok: #5cc27a;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
[hidden] { display: none !important; }
.screen { position: fixed; inset: 0; }
#map, #viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; touch-action: none; }
h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
h1 span { color: var(--acc); }
h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mute); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }
.pick-panel { position: absolute; top: 12px; left: 12px; width: 340px; max-width: calc(100vw - 24px); padding: 16px; z-index: 1000; max-height: calc(100vh - 24px); overflow: auto; }
.lede { margin: 0 0 12px; color: #c9d3dc; }
.fine { font-size: 12px; color: var(--mute); margin: 8px 0 0; }
.info { font-size: 13px; color: #cfd8e1; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 10px 0; }
.info.bad { border-color: rgba(229, 72, 58, 0.6); }
.info.good { border-color: rgba(92, 194, 122, 0.5); }
.row { display: flex; align-items: center; gap: 6px; }
.row.gap { gap: 8px; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
input[type=search], input[type=number], select { background: #0c1116; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font: inherit; min-width: 0; }
input[type=search] { flex: 1; }
input[type=number] { width: 90px; }
input[type=range] { width: 100%; accent-color: var(--acc); }
.field { display: block; margin: 10px 0 0; color: #cfd8e1; }
.field select { width: 100%; margin-top: 4px; }
.field output { float: right; color: var(--acc); font-variant-numeric: tabular-nums; }
.chk { display: flex; gap: 8px; align-items: center; margin: 4px 0; cursor: pointer; }
.btn { background: #233040; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #2d3d51; }
.btn.primary { background: var(--acc); color: #1b1407; border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.big { width: 100%; padding: 11px; font-size: 15px; }
.btn.tiny { padding: 3px 8px; }
.btn.file { display: inline-block; }
.results { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.results button { text-align: left; background: none; border: 0; color: #cfe3ff; padding: 4px 2px; cursor: pointer; font: inherit; font-size: 13px; }
.results button:hover { text-decoration: underline; }
.load-panel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 460px; max-width: calc(100vw - 24px); padding: 20px; }
.bar { height: 8px; background: #0c1116; border-radius: 4px; overflow: hidden; }
#loadBar { height: 100%; width: 0; background: linear-gradient(90deg, var(--acc), #ffd27a); transition: width 0.3s; }
.log { list-style: none; padding: 0; margin: 10px 0 0; max-height: 200px; overflow: auto; font-size: 12px; color: var(--mute); }
.log li { padding: 2px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }

/* editor */
.tools { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 2px; padding: 6px; z-index: 5; }
.tools button { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); padding: 6px 10px 6px 6px; border-radius: 8px; cursor: pointer; font: inherit; text-align: left; }
.tools button b { width: 26px; text-align: center; font-size: 17px; font-weight: 400; }
.tools button:hover { background: rgba(255, 255, 255, 0.07); }
.tools button.on { background: var(--acc); color: #1b1407; }
.side { position: absolute; right: 10px; top: 10px; width: 290px; max-height: calc(100% - 56px); overflow: auto; padding: 10px 14px 14px; z-index: 5; }
.side h3:first-of-type { margin-top: 2px; }
#sideToggle { position: sticky; top: 0; float: right; z-index: 2; }
.side.collapsed { width: auto; padding: 6px; }
.side.collapsed .side-body { display: none; }
.opt { margin: 8px 0; }
.opt label { display: flex; justify-content: space-between; color: #cfd8e1; }
.opt output { color: var(--acc); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-variant-numeric: tabular-nums; font-size: 13px; }
.stats .k { color: var(--mute); }
.stats .cut { color: #ff7b6e; } .stats .fill { color: #7ea6ff; }
.status { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 12px; background: rgba(10, 14, 18, 0.85); font-size: 12px; color: #cfd8e1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 4; }
#splitHandle { position: absolute; top: 0; bottom: 30px; width: 0; z-index: 3; cursor: ew-resize; touch-action: none; }
#splitHandle i { position: absolute; top: 0; bottom: 0; left: -2px; width: 4px; background: #fff; box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); }
#splitHandle::after { content: "⟷"; position: absolute; top: 50%; left: -18px; width: 36px; height: 36px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 18px; transform: translateY(-50%); }
#splitHandle span { position: absolute; top: 60px; font-size: 12px; background: rgba(0, 0, 0, 0.6); padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
#splitHandle span:first-child { right: 10px; } #splitHandle span:nth-child(3) { left: 10px; }
#splitHandle span:first-child, #splitHandle span:nth-child(3) { pointer-events: none; }
.tag { position: absolute; z-index: 4; transform: translate(-50%, -130%); background: rgba(10, 14, 18, 0.9); border: 1px solid var(--acc); border-radius: 8px; padding: 4px 8px; font-size: 12px; pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
#profile { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); height: 150px; background: rgba(10, 14, 18, 0.9); border: 1px solid var(--line); border-radius: 10px; z-index: 4; }
.toast { position: fixed; left: 50%; bottom: 50px; transform: translateX(-50%); background: #222c37; border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; z-index: 2000; max-width: calc(100vw - 24px); }
kbd { background: #0c1116; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 11px; }
.leaflet-container { background: #1a2028; }
.leaflet-control-layers { color: #111; }

@media (max-width: 760px) {
  .pick-panel { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 55vh; padding: 12px; }
  .lede { display: none; }
  .tools { left: 0; right: 0; top: auto; bottom: 28px; flex-direction: row; overflow-x: auto; border-radius: 0; padding: 4px; }
  .tools button { flex-direction: column; gap: 0; padding: 4px 6px; font-size: 10px; min-width: 56px; align-items: center; }
  .tools button b { width: auto; }
  .side { top: 6px; right: 6px; width: min(300px, calc(100vw - 12px)); max-height: calc(100% - 140px); }
  #profile { bottom: 100px; }
}
