/* The map builder: a bar across the top, a panel on the left, the map or the page on the right. */
html, body.builder { height: 100%; }
body.builder { display: flex; flex-direction: column; overflow: hidden; font-size: 15px; }
#top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; flex-wrap: wrap; }
#top .brand { font-weight: 650; text-decoration: none; color: var(--fg); margin-right: 6px; }
#top #mapname { flex: 1 1 12rem; min-width: 8rem; max-width: 26rem; font-weight: 600; }
#top .spacer { flex: 1 1 0; }
#top nav a { color: var(--muted); text-decoration: none; font-size: 14px; margin-left: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--fg); padding: 6px 12px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { color: #10161c; } }

#work { flex: 1 1 auto; display: flex; min-height: 0; }
#panel { flex: 0 0 320px; max-width: 46vw; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 9px 0; border-bottom: 2px solid transparent; }
#tabs button[aria-selected="true"] { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent); }
.pane { overflow-y: auto; padding: 12px; flex: 1 1 auto; }
.pane h3 { font-size: 13px; text-transform: none; color: var(--muted); font-weight: 600; margin: 16px 0 6px; }
.pane h3:first-child { margin-top: 0; }
.pane label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 2px; }
.pane input[type="text"], .pane input[type="number"], .pane select, .pane textarea { width: 100%; }
.pane textarea { min-height: 4.5em; resize: vertical; }
.pane .check { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; margin: 6px 0; }
.pane .check input { margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.lyr { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 0 0 8px; background: var(--bg); }
.lyr .head { display: flex; align-items: center; gap: 8px; }
.lyr .head input[type="checkbox"] { margin: 0; flex: 0 0 auto; }
.lyr .swatch { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line); padding: 0; }
.lyr .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.lyr .meta { font-size: 12px; color: var(--muted); margin: 3px 0 0 26px; }
.lyr .local { color: var(--warn); }
.lyr .tools { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 0 26px; font-size: 13px; }
.lyr .tools button { background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; }
.lyr .tools a { color: var(--accent); font-size: 13px; text-decoration: none; }
.lyr .style { margin: 8px 0 0 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.lyr .style label { margin: 0; }
.lyr .style input[type="number"] { width: 100%; }
.lyr .style input[type="color"] { width: 100%; height: 32px; padding: 2px; }
.empty { color: var(--muted); font-size: 14px; border: 1px dashed var(--line); border-radius: 8px; padding: 14px; text-align: center; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.hint.warn { color: var(--warn); }

#stage { flex: 1 1 auto; position: relative; min-width: 0; background: #e9ecef; overflow: hidden; }
@media (prefers-color-scheme: dark) { #stage { background: #0c0e10; } }
#paper { position: absolute; background: #fff; box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35); }
body.mode-map #paper { inset: 0; box-shadow: none; }
#map { position: absolute; }
body.mode-map #map { inset: 0; }
#inset { position: absolute; display: none; pointer-events: none; background: #fff; }
#marginalia { position: absolute; inset: 0; pointer-events: none; }
body.mode-map #marginalia { display: none; }
#marginalia svg { width: 100%; height: 100%; display: block; }
#status { position: absolute; left: 8px; bottom: 8px; background: rgba(255, 255, 255, 0.92); color: #1a1a1a; font-size: 12.5px; padding: 3px 8px; border-radius: 5px; pointer-events: none; font-variant-numeric: tabular-nums; }
#busy { position: absolute; inset: 0; background: rgba(255, 255, 255, 0.7); color: #1a1a1a; display: none; align-items: center; justify-content: center; font-size: 16px; z-index: 5; }
#busy.on { display: flex; }
#drop { position: absolute; inset: 0; border: 3px dashed var(--accent); background: rgba(31, 90, 138, 0.12); display: none; align-items: center; justify-content: center; font-size: 18px; color: #1a1a1a; z-index: 6; pointer-events: none; }
#drop.on { display: flex; }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; max-width: min(34rem, 94vw); width: 34rem; background: var(--bg); color: var(--fg); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog .dlg-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
dialog .dlg-head h2 { font-size: 1.05rem; margin: 0; flex: 1; }
dialog .dlg-body { padding: 12px 16px 16px; max-height: 70vh; overflow-y: auto; }
dialog .dlg-body p { margin: 0.5em 0; font-size: 14px; }
.choices { display: grid; gap: 8px; }
.choices button { text-align: left; background: var(--bg); color: var(--fg); border-color: var(--line); padding: 10px 12px; }
.choices button b { display: block; }
.choices button span { font-size: 13px; color: var(--muted); }
.pick { width: 100%; }
.pick td { padding: 6px 8px 6px 0; }
.maplibregl-popup-content { font: 13px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #1a1a1a; max-width: 280px; max-height: 240px; overflow: auto; }
.maplibregl-popup-content table { margin: 4px 0 0; font-size: 12.5px; width: auto; }
.maplibregl-popup-content td { padding: 1px 8px 1px 0; border: 0; }
@media (max-width: 720px) {
  #work { flex-direction: column-reverse; }
  #panel { flex: 0 0 44%; max-width: none; border-right: 0; border-top: 1px solid var(--line); }
}
