/* Hive: map planner. Light + dark theme following the device (FR-8.11), same fonts as the rest of zroute-tools. */
:root {
  color-scheme: light;
  --bg: #f1eee7; --surface: #ffffff; --surface2: #f7f5f0; --line: #ddd7cb; --line2: #c9c1b2;
  --ink: #1f2128; --muted: #686258; --title: #2b2015;
  --accent: #c27c0e; --accent-ink: #ffffff; --accent-soft: #f8ead0;
  --danger: #c8372d; --danger-soft: #fbe3e0; --ok: #2f8a3c; --warn-soft: #fff3d6; --warn-ink: #7a4b00;
  --bar1: #8f6b40; --bar2: #5b3f24; --bar-ink: #f6e7c4;
  --map-bg: #f8f6f1; --map-out: #e2ddd2; --map-grid: rgba(60,50,30,.07); --map-grid10: rgba(60,50,30,.16); --map-grid100: rgba(60,50,30,.34);
  --map-axis-bg: rgba(255,255,255,.92); --map-axis-ink: #5d5a54;
  --map-capitol: rgba(150,40,40,.07); --map-capitol-line: rgba(150,40,40,.55); --map-capitol-ink: rgba(150,40,40,.30);
  --base-neutral: #9aa0aa; --base-empty: rgba(0,0,0,.035); --base-empty-ink: #4f4b45;
  --shadow: 0 6px 22px rgba(30,20,10,.16);
  --f-head: "Exo 2", "Titillium Web", system-ui, sans-serif;
  --f-body: "Titillium Web", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161a22; --surface: #222731; --surface2: #1b1f28; --line: #353b48; --line2: #4a5161;
    --ink: #ece6d8; --muted: #a39f97; --title: #f6e7c4;
    --accent: #e8c15a; --accent-ink: #241a06; --accent-soft: #3a3020;
    --danger: #ff6b5e; --danger-soft: #3d1c19; --ok: #7fd36b; --warn-soft: #3a2e14; --warn-ink: #f2c66a;
    --map-bg: #1d2330; --map-out: #11141a; --map-grid: rgba(255,255,255,.05); --map-grid10: rgba(255,255,255,.11); --map-grid100: rgba(255,255,255,.24);
    --map-axis-bg: rgba(17,20,26,.9); --map-axis-ink: #b3ada2;
    --map-capitol: rgba(255,120,100,.07); --map-capitol-line: rgba(255,120,100,.55); --map-capitol-ink: rgba(255,120,100,.28);
    --base-neutral: #7c8391; --base-empty: rgba(255,255,255,.035); --base-empty-ink: #c9c3b7;
    --shadow: 0 8px 26px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161a22; --surface: #222731; --surface2: #1b1f28; --line: #353b48; --line2: #4a5161;
  --ink: #ece6d8; --muted: #a39f97; --title: #f6e7c4;
  --accent: #e8c15a; --accent-ink: #241a06; --accent-soft: #3a3020;
  --danger: #ff6b5e; --danger-soft: #3d1c19; --ok: #7fd36b; --warn-soft: #3a2e14; --warn-ink: #f2c66a;
  --map-bg: #1d2330; --map-out: #11141a; --map-grid: rgba(255,255,255,.05); --map-grid10: rgba(255,255,255,.11); --map-grid100: rgba(255,255,255,.24);
  --map-axis-bg: rgba(17,20,26,.9); --map-axis-ink: #b3ada2;
  --map-capitol: rgba(255,120,100,.07); --map-capitol-line: rgba(255,120,100,.55); --map-capitol-ink: rgba(255,120,100,.28);
  --base-neutral: #7c8391; --base-empty: rgba(255,255,255,.035); --base-empty-ink: #c9c3b7;
  --shadow: 0 8px 26px rgba(0,0,0,.5);
}

* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--f-body); -webkit-text-size-adjust: 100% }
h1, h2, h3 { font-family: var(--f-head); color: var(--title); margin: 0; line-height: 1.15 }
h2 { font-size: 20px } h3 { font-size: 15px; letter-spacing: .02em }
a { color: var(--accent) }
small, .muted { color: var(--muted) }
button, input, select, textarea { font: inherit; color: inherit }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.num { font-variant-numeric: tabular-nums }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: var(--r);
  border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; touch-action: manipulation }
.btn:hover { background: var(--surface2) }
.btn:disabled { opacity: .5; cursor: default }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.btn.primary:hover { filter: brightness(1.06) }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff }
.btn.ghost { background: transparent; border-color: transparent }
.btn.ghost:hover { background: var(--surface2) }
.btn.sm { min-height: 32px; padding: 3px 10px; font-size: 14px }
.btn.icon { width: 44px; min-height: 44px; padding: 0 }
.btn.icon.sm { width: 34px; min-height: 34px }
.btn svg, .ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink) }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 7px 10px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--surface); min-width: 0 }
textarea.input { min-height: 160px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 14px }
.input.num { font-variant-numeric: tabular-nums }
.field { display: grid; gap: 4px; min-width: 0 }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted) }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap }
.row > .grow { flex: 1; min-width: 0 }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px }
.check { display: flex; gap: 8px; align-items: center; min-height: 36px; cursor: pointer }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; background: var(--surface) }
.seg button { border: 0; background: none; padding: 6px 12px; min-height: 36px; cursor: pointer; font-weight: 600; color: var(--muted) }
.seg button + button { border-left: 1px solid var(--line) }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink) }
.err { color: var(--danger); margin: 0; font-size: 14px }
.warn { background: var(--warn-soft); color: var(--warn-ink); padding: 10px 12px; border-radius: var(--r); margin: 0; font-weight: 600 }
.hint { color: var(--muted); font-size: 14px; margin: 0 }
.chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 1px 8px 1px 4px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.sw { width: 14px; height: 14px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.3); display: inline-block }
.badge { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); color: var(--muted) }
.badge.on { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent }

/* ---------- dialogs & toasts ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px) }
dialog.modal.wide { width: min(640px, calc(100vw - 24px)) }
dialog.modal::backdrop { background: rgba(0,0,0,.5) }
.dlg { padding: 20px; display: grid; gap: 14px }
.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap }
.dlg p { margin: 0 }
.linkrow { display: grid; gap: 4px }
.linkrow .lbl { font-weight: 700 }
.linkbox { display: flex; gap: 6px }
.linkbox .input { font-size: 13px; flex: 1; min-width: 0 }
.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none }
.toast { pointer-events: auto; background: #20242c; color: #f3eee4; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; justify-content: space-between; font-weight: 600 }
.toast.bad { background: var(--danger); color: #fff }
.toast button { background: none; border: 1px solid currentColor; color: inherit; border-radius: 6px; padding: 3px 10px; cursor: pointer; font-weight: 700 }

/* ---------- home ---------- */
.home { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; display: grid; gap: 20px }
.home header { display: flex; align-items: center; gap: 12px }
.home header a.back { color: var(--muted); text-decoration: none; font-weight: 600 }
.home h1 { font-size: clamp(30px, 7vw, 42px); font-weight: 800; text-transform: uppercase; letter-spacing: .02em }
.home h1 span { color: var(--accent) }
.lede { margin: 0; color: var(--muted); font-size: 17px; max-width: 36em }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 14px; min-width: 0 }
.card > .bar { margin: -18px -18px 0; padding: 10px 18px; border-radius: 12px 12px 0 0; background: linear-gradient(100deg, var(--bar1), #7a5733 40%, var(--bar2)); }
.card > .bar h2 { color: var(--bar-ink); text-shadow: 0 2px 0 rgba(0,0,0,.45) }
.recent { list-style: none; margin: 0; padding: 0; display: grid }
.recent li { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 8px 0 }
.recent li a { flex: 1; min-width: 0; font-weight: 700; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 32px; display: flex; align-items: center }
.recent li a:hover { color: var(--accent) }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; color: var(--muted) }

/* ---------- lock screen ---------- */
.lock { min-height: 100dvh; display: grid; place-items: center; padding: 16px }
.lock .card { width: min(380px, 100%) }
.pin { font-size: 24px; letter-spacing: .3em; text-align: center }

/* ---------- editor layout ---------- */
body.ed { height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto 1fr }
/* Fixed rows, so stray body children (toasts, dialogs, extension widgets) can't take the header's row. */
body.ed > :not(.topbar, .edmain, .tabbar) { grid-row: 1; grid-column: 1 }
body.ed > .topbar { grid-row: 1; grid-column: 1 }
body.ed > .edmain { grid-row: 2; grid-column: 1 }
body.ed > .tabbar { grid-row: 3; grid-column: 1 }
.topbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); background: linear-gradient(#2a2118, #1d1812); color: var(--bar-ink); border-bottom: 2px solid var(--bar2); min-width: 0 }
.topbar .btn { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.18); color: var(--bar-ink) }
.topbar .btn:hover { background: rgba(255,255,255,.12) }
.topbar .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
:root:not([data-theme="dark"]) .topbar .btn.primary { background: #e8c15a; border-color: #e8c15a; color: #241a06 }
.topbar .title { flex: 1; min-width: 0; display: grid; line-height: 1.15 }
.topbar .title b { font: 800 17px var(--f-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #f6e7c4 }
.topbar .title span { font-size: 12px; color: #cdbf9f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.1); color: #e9dcc0; white-space: nowrap }
.status.offline, .status.error { background: #8e2b22; color: #fff }
.status.dirty { background: #6a4a17; color: #ffe2a6 }

#map.hand { cursor: grab }
#map.hand.grabbing, #map.grabbing { cursor: grabbing }
.edmain { position: relative; display: grid; grid-template-columns: 300px minmax(0, 1fr) 340px; min-height: 0 }
.edmain.noleft { grid-template-columns: 0 minmax(0, 1fr) 340px }
.edmain.noright { grid-template-columns: 300px minmax(0, 1fr) 0 }
.edmain.noleft.noright { grid-template-columns: 0 minmax(0, 1fr) 0 }
.edmain.noleft .pane.left, .edmain.noright .pane.right { display: none }
.pane { background: var(--surface); min-height: 0; display: flex; flex-direction: column; min-width: 0 }
.pane.left { border-right: 1px solid var(--line) }
.pane.right { border-left: 1px solid var(--line) }
.pane-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line) }
.pane-head h2 { font-size: 16px; flex: 1 }
.pane-body { overflow: auto; flex: 1; min-height: 0; padding: 10px; display: grid; gap: 12px; align-content: start }
.sectabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; flex: none }
.sectabs button { flex: 1 0 auto; border: 0; background: none; padding: 10px 7px; min-height: 44px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; font-size: 14px }
.sectabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent) }
.section { display: grid; gap: 12px; align-content: start }
.section h3 { margin-top: 4px }
.divider { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100% }

/* players list */
.plist { list-style: none; margin: 0; padding: 0; display: grid }
.prow { display: grid; grid-template-columns: 24px 22px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 4px 4px 4px 2px; border-bottom: 1px solid var(--line); min-height: 44px; background: var(--surface) }
.prow.sel { background: var(--accent-soft) }
.prow.dragging { opacity: .4 }
.prow.drop-before { box-shadow: inset 0 3px 0 var(--accent) }
.prow .handle { cursor: grab; color: var(--muted); display: grid; place-items: center; touch-action: none; height: 36px }
.prow .handle.off { visibility: hidden }
.prow .handle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round }
.prow .main { min-width: 0; display: grid; cursor: pointer }
.prow .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.prow .meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); min-width: 0 }
.prow .meta .cat { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis }
.prow .where { font-size: 12px; font-weight: 700; color: var(--ok); white-space: nowrap; background: none; border: 0; cursor: pointer; padding: 6px }
.prow .where.none { color: var(--muted); font-weight: 600; cursor: default }
.prow input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent) }
.batchbar { position: sticky; top: -10px; z-index: 2; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r); padding: 8px; display: grid; gap: 6px }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px }
.filters .input { min-height: 36px; padding: 4px 8px; font-size: 14px }

/* categories */
.clist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px }
.crow { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 8px; align-items: center }
.crow .swbtn { width: 34px; height: 34px; border-radius: 6px; border: 2px solid rgba(0,0,0,.25); cursor: pointer }
.crow .counts { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; line-height: 1.2 }
.palette { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px }
.palette button { aspect-ratio: 1; border-radius: 6px; border: 2px solid transparent; cursor: pointer; min-height: 36px }
.palette button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset }

/* map */
.mapwrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--map-out) }
.mapwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: default }
.mapwrap canvas.grab { cursor: grab }
.mapwrap canvas.cross { cursor: crosshair }
.mapwrap canvas.paint { cursor: cell }
.mtools { position: absolute; z-index: 3; left: 38px; right: 8px; top: 8px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; align-items: flex-start }
.mtools > * { pointer-events: auto }
.tgroup { display: flex; background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden }
.tgroup .btn { border: 0; border-radius: 0; min-height: 40px; background: transparent }
.tgroup .btn + .btn { border-left: 1px solid var(--line) }
.tgroup .btn.icon { width: 42px; min-height: 40px }
.tgroup .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink) }
.tlabel { font-size: 13px }
.paintbar { display: flex; gap: 6px; align-items: center; background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; padding: 4px 8px; box-shadow: var(--shadow); max-width: 100%; overflow-x: auto }
.paintbar button { min-width: 34px; height: 34px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; flex: none; font-size: 12px; font-weight: 700; padding: 0 8px }
.paintbar button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset }
.mzoom { position: absolute; z-index: 3; right: 8px; bottom: 28px; display: grid; gap: 6px }
.mzoom .tgroup { flex-direction: column }
.mzoom .tgroup .btn + .btn { border-left: 0; border-top: 1px solid var(--line) }
.legend { position: absolute; z-index: 3; left: 38px; bottom: 26px; max-width: min(60%, 420px); display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none }
.legend button { pointer-events: auto; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line2); background: var(--surface); border-radius: 99px; padding: 3px 9px 3px 5px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15); min-height: 30px; max-width: 160px }
.legend button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.legend button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) }
.legend button.dim { opacity: .55 }
.tip { position: absolute; z-index: 4; pointer-events: none; background: #1d2028; color: #f1ece2; font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 6px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.3); transform: translate(12px, 14px) }
.coordchip { position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); bottom: 96px; background: #1d2028; color: #f1ece2; padding: 6px 12px; border-radius: 99px; font-weight: 700; box-shadow: var(--shadow) }
.notice { position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); top: 56px; width: min(520px, calc(100% - 24px)); background: var(--warn-soft); color: var(--warn-ink); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; box-shadow: var(--shadow); font-weight: 600 }

/* side panel details */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 }
.kv dt { color: var(--muted); font-size: 13px } .kv dd { margin: 0; font-weight: 700 }
.picker { display: grid; gap: 6px }
.picker ul { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r) }
.picker li button { width: 100%; text-align: left; display: flex; gap: 8px; align-items: center; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 8px 10px; min-height: 44px; cursor: pointer }
.picker li button:hover { background: var(--surface2) }
.picker li button .n { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.picker li button small { white-space: nowrap }
.summary { width: 100%; border-collapse: collapse; font-size: 14px }
.summary th, .summary td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line) }
.summary td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700 }
.preview-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); font-size: 14px }
.preview-list div { display: flex; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--line) }
.preview-list div b { flex: none; width: 68px; font-size: 12px; text-transform: uppercase }
.preview-list .st-new b { color: var(--ok) } .preview-list .st-dupList b, .preview-list .st-dupPaste b { color: var(--warn-ink) } .preview-list .st-invalid b { color: var(--danger) }
.counts4 { display: flex; gap: 6px; flex-wrap: wrap }

.tabbar { display: none }

/* ---------- phone editor (FR-8.4) ---------- */
@media (max-width: 899px) {
  body.ed { grid-template-rows: auto 1fr auto }
  .edmain, .edmain.noleft, .edmain.noright, .edmain.noleft.noright { grid-template-columns: minmax(0, 1fr) }
  .edmain > .pane, .edmain > .mapwrap { grid-area: 1 / 1; display: none }
  .edmain.noleft .pane.left, .edmain.noright .pane.right { display: none }
  .edmain[data-tab="players"] > .pane.left { display: flex }
  .edmain[data-tab="map"] > .mapwrap { display: block }
  .edmain[data-tab="categories"] > .pane.right { display: flex }
  .edmain[data-tab="map"] > .pane.right.sheet { display: flex; position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; max-height: 58%; border: 0; border-top: 1px solid var(--line2); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 26px rgba(0,0,0,.3) }
  .edmain[data-tab="categories"] .sectabs { display: none }
  .collapse-btn { display: none !important }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px) }
  .tabbar button { border: 0; background: none; min-height: 52px; font-weight: 700; color: var(--muted); cursor: pointer; display: grid; place-items: center; gap: 0; font-size: 13px }
  .tabbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2 }
  .tabbar button[aria-selected="true"] { color: var(--accent) }
  .topbar .wide-only { display: none }
  .mtools { left: 36px }
  .tlabel { display: none }
  .legend { max-width: calc(100% - 100px) }
}
.sheet-close { display: none }
@media (max-width: 899px) { .pane.right.sheet .sheet-close { display: inline-flex } }
@media (min-width: 900px) { .phone-only { display: none !important } }

/* ---------- viewer (FR-8.1 – 8.3) ---------- */
body.vw { height: 100dvh; overflow: hidden }
.vw .mapwrap { position: fixed; inset: 0 }
.vtop { position: fixed; z-index: 5; top: 0; left: 0; right: 0; padding: 10px 12px 0 40px; padding-top: max(10px, env(safe-area-inset-top)); display: grid; gap: 6px; pointer-events: none }
.vtop > * { pointer-events: auto }
.vtitle { display: flex; gap: 8px; align-items: baseline; min-width: 0; text-shadow: 0 1px 0 var(--map-bg) }
.vtitle b { font: 800 18px var(--f-head); color: var(--title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.vtitle span { font-size: 12px; color: var(--muted); white-space: nowrap }
.search { position: relative; max-width: 460px; width: 100% }
.search input { width: 100%; min-height: 46px; padding: 8px 14px 8px 40px; border-radius: 99px; border: 1px solid var(--line2); background: var(--surface); box-shadow: var(--shadow); font-size: 16px }
.search svg { position: absolute; left: 13px; top: 13px; width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2 }
.vbottom { position: fixed; z-index: 5; left: 40px; right: 12px; bottom: 24px; padding-bottom: env(safe-area-inset-bottom, 0px); display: flex; gap: 8px; justify-content: flex-end; align-items: flex-end; pointer-events: none }
.vbottom > * { pointer-events: auto }
.vbottom .btn { box-shadow: var(--shadow); min-height: 46px }
.vbottom .legend { position: static; flex: 1; max-width: none }

.bsheet { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.35);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); max-height: 60dvh; overflow: auto; display: grid; gap: 10px; animation: up .18s ease-out }
.bsheet::before { content: ""; justify-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line2) }
@keyframes up { from { transform: translateY(30px); opacity: 0 } }
@media (min-width: 700px) { .bsheet { left: 50%; right: auto; width: 420px; transform: translateX(-50%); bottom: 16px; border-radius: 16px; animation: none } }
@media (prefers-reduced-motion: reduce) { .bsheet { animation: none } }
.bsheet .head { display: flex; gap: 10px; align-items: center }
.bsheet .head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 20px }
.coordbig { font: 800 30px var(--f-head); font-variant-numeric: tabular-nums; letter-spacing: .02em }
.results { list-style: none; margin: 0; padding: 0; display: grid }
.results button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; min-height: 48px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; padding: 6px 4px }
.results button .n { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.results mark { background: var(--accent-soft); color: inherit; border-radius: 3px }
.center-msg { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center }
[data-span] { grid-column: 1 / -1 }
[data-push] { margin-left: auto }
.vw .mzoom { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); right: 12px }
.vtitle { flex-wrap: wrap; column-gap: 8px; row-gap: 0 }
.vtitle b { max-width: 100% }
@media (min-width: 900px) {
  .edmain > .pane.left { grid-column: 1 } .edmain > .mapwrap { grid-column: 2 } .edmain > .pane.right { grid-column: 3 }
  .edmain > * { grid-row: 1 }
}
