:root { color-scheme: dark; --surface-map:#0b1418; --surface-panel:rgba(20,34,40,.95); --surface-elevated:#1b2c33; --surface-input:#101d22; --text-primary:#f1f8f9; --text-muted:#aec0c5; --brand-primary:#cef2fb; --brand-accent:#f3b040; --focus:#8fe7f7; --danger:#ff8178; --line:rgba(206,242,251,.19); --shadow:0 16px 42px rgba(0,0,0,.4); --safe-top:env(safe-area-inset-top,0px); --safe-bottom:env(safe-area-inset-bottom,0px); --radius:14px; }
* { box-sizing:border-box; }
html, body { width:100%; height:100%; margin:0; overflow:hidden; background:var(--surface-map); color:var(--text-primary); font:15px/1.45 ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif; }
button, input, select { font:inherit; }
button { touch-action:manipulation; }
button, a, input, select { -webkit-tap-highlight-color:transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline:3px solid var(--focus); outline-offset:3px; }
.skip-link { position:fixed; z-index:2000; top:8px; left:8px; padding:8px 12px; border-radius:8px; background:var(--brand-primary); color:#0b1418; transform:translateY(-140%); }
.skip-link:focus { transform:translateY(0); }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
.map-app, #map { width:100%; height:100%; }
.map-app { position:relative; min-height:100dvh; overflow:hidden; }
#map { position:absolute; inset:0; background:var(--surface-map); }
.topbar { position:absolute; z-index:700; top:max(14px,calc(var(--safe-top) + 10px)); left:16px; right:16px; display:grid; grid-template-columns:minmax(225px,340px) minmax(0,1fr) auto; align-items:start; gap:12px; pointer-events:none; }
.brand, .status-row, .toolbar, .measure-panel, .map-footer { pointer-events:auto; }
.brand { min-height:58px; display:flex; align-items:center; gap:11px; padding:9px 12px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface-panel); box-shadow:var(--shadow); backdrop-filter:blur(14px); }
.brand img { width:38px; height:38px; border-radius:9px; object-fit:contain; background:#fff; }
.brand h1, .brand p, .panel-heading h2, .dialog-header h2, .layer-list-heading h3, .detail-empty h3 { margin:0; }
.brand h1 { font-size:17px; line-height:1.15; letter-spacing:.01em; }
.brand p, .eyebrow, .field-label, .switch-row small, .detail-meta, .detail-note { color:var(--text-muted); font-size:12px; }
.brand p { margin:3px 0 0; }
.status-row { display:flex; flex-wrap:wrap; align-items:center; gap:8px; min-height:42px; padding-top:8px; }
.status-chip { min-height:34px; display:inline-flex; align-items:center; gap:7px; max-width:280px; padding:0 10px; overflow:hidden; border:1px solid var(--line); border-radius:999px; background:rgba(11,20,24,.88); box-shadow:0 8px 24px rgba(0,0,0,.23); color:var(--text-muted); font-size:12px; white-space:nowrap; text-overflow:ellipsis; }
.status-chip strong { overflow:hidden; color:var(--text-primary); text-overflow:ellipsis; }
.status-chip svg { width:15px; height:15px; flex:none; color:var(--brand-primary); }
.toolbar { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:6px; padding:6px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface-panel); box-shadow:var(--shadow); backdrop-filter:blur(14px); }
.tool-button, .icon-button, .secondary-button, .group-button, .text-button { border:1px solid transparent; cursor:pointer; color:var(--text-primary); }
.tool-button { display:inline-flex; align-items:center; justify-content:center; gap:7px; min-width:44px; min-height:44px; padding:0 12px; border-radius:10px; background:#263b43; font-weight:650; }
.tool-button:hover, .tool-button[aria-pressed="true"] { border-color:rgba(206,242,251,.45); background:#34515d; }
.tool-button--primary { background:#dff7fb; color:#102127; }
.tool-button--primary:hover { background:var(--brand-primary); }
.tool-button[aria-pressed="true"] { color:#fff6df; box-shadow:inset 0 0 0 1px rgba(243,176,64,.65); }
.tool-button svg { width:18px; height:18px; }
.measure-panel { position:absolute; z-index:680; top:96px; left:16px; width:min(350px,calc(100vw - 32px)); transition:transform .2s ease; }
.measure-panel[hidden] { display:none; }
.measure-panel__content { padding:14px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface-panel); box-shadow:var(--shadow); backdrop-filter:blur(14px); }
.measure-panel.is-collapsed { transform:translateX(calc(-100% + 42px)); }
.panel-edge-handle { position:absolute; top:14px; right:-38px; display:grid; place-items:center; width:38px; height:44px; border:1px solid var(--line); border-left:0; border-radius:0 10px 10px 0; background:var(--surface-panel); color:var(--text-primary); cursor:pointer; }
.measure-panel.is-collapsed .panel-edge-handle svg { transform:rotate(180deg); }
.legend-panel { position:absolute; z-index:680; top:96px; right:16px; width:min(370px,calc(100vw - 32px)); transition:transform .2s ease; }
.legend-panel[hidden] { display:none; }
.legend-panel.is-collapsed { transform:translateX(calc(100% + 16px)); }
.legend-panel__content { max-height:min(68dvh,720px); padding:14px; overflow:auto; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface-panel); box-shadow:var(--shadow); backdrop-filter:blur(14px); }
.legend-panel__handle { right:auto; left:-38px; border:1px solid var(--line); border-right:0; border-radius:10px 0 0 10px; }
.legend-panel__intro { margin:12px 0; color:var(--text-muted); font-size:12px; }
.map-legend-list { display:grid; gap:8px; }
.map-legend-group-title { margin:8px 0 0; padding-top:12px; border-top:1px solid var(--line); color:var(--brand-accent); font-size:14px; }
.map-legend-group-title:first-child { margin-top:0; padding-top:0; border-top:0; }
.map-legend-item { display:grid; gap:3px; padding:9px 10px; border:1px solid rgba(206,242,251,.13); border-radius:10px; background:rgba(206,242,251,.05); }
.map-legend-item > strong { font-size:13px; }
.map-legend-item > small, .map-legend-symbols { color:var(--text-muted); font-size:12px; }
.map-legend-symbols { display:grid; gap:5px; margin-top:5px; }
.map-legend-symbol { display:flex; align-items:center; gap:7px; min-height:24px; cursor:help; }
.map-legend-symbol img { width:26px; height:26px; object-fit:contain; background:rgba(255,255,255,.06); }
.leaflet-tooltip.map-feature-tooltip { max-width:260px; padding:7px 10px; border:1px solid rgba(206,242,251,.42); border-radius:8px; background:rgba(11,28,35,.96); box-shadow:0 8px 20px rgba(0,0,0,.3); color:var(--text-primary); font:700 13px/1.45 "Noto Sans SC",system-ui,sans-serif; text-align:left; white-space:nowrap; }
.leaflet-tooltip-top.map-feature-tooltip::before { border-top-color:rgba(11,28,35,.96); }
.panel-heading, .layer-list-heading, .dialog-header, .dialog-header__actions, .switch-row, .detail-title-row { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.eyebrow { display:block; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.panel-heading h2 { font-size:18px; }
.icon-button { display:inline-grid; place-items:center; width:44px; height:44px; border-radius:10px; background:#263b43; }
.icon-button:hover { background:#34515d; }
.icon-button--danger { color:#ffe8e5; background:rgba(255,129,120,.17); }
.measure-total { display:flex; align-items:baseline; justify-content:space-between; margin:14px 0 10px; padding:13px; border:1px solid rgba(206,242,251,.23); border-radius:11px; background:rgba(206,242,251,.08); }
.measure-total span { color:var(--text-muted); font-weight:700; font-size:13px; }
.measure-total strong { font-size:26px; line-height:1; font-variant-numeric:tabular-nums; }
.segments { max-height:190px; overflow:auto; border:1px solid var(--line); border-radius:10px; }
.segment-row { display:grid; grid-template-columns:26px minmax(0,1fr) auto; gap:7px; align-items:center; min-height:39px; padding:7px 10px; border-bottom:1px solid rgba(206,242,251,.1); color:var(--text-muted); font-size:12px; }
.segment-row:last-child { border-bottom:0; }
.segment-row strong { color:var(--text-primary); }
.panel-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:12px; }
.panel-actions .secondary-button:last-child { grid-column:1/-1; }
.secondary-button { display:flex; align-items:center; justify-content:center; min-height:42px; gap:7px; padding:8px; border-radius:10px; background:#263b43; font-weight:650; }
.secondary-button:hover { background:#34515d; }
.secondary-button svg { width:16px; height:16px; }
.map-footer { position:absolute; z-index:650; right:12px; bottom:max(12px,calc(var(--safe-bottom) + 8px)); display:flex; align-items:center; gap:10px; max-width:calc(100vw - 24px); padding:7px 10px; border:1px solid var(--line); border-radius:10px; background:rgba(11,20,24,.88); box-shadow:0 10px 28px rgba(0,0,0,.28); color:var(--text-muted); font-size:12px; backdrop-filter:blur(10px); }
.map-footer strong { color:var(--text-primary); font-variant-numeric:tabular-nums; }
.map-footer a { color:var(--brand-primary); }
.live-status { position:absolute; z-index:720; left:50%; bottom:26px; max-width:min(92vw,520px); margin:0; padding:9px 12px; border-radius:9px; transform:translate(-50%,120px); background:#102127; box-shadow:var(--shadow); color:var(--text-primary); font-size:13px; opacity:0; transition:transform .18s ease,opacity .18s ease; pointer-events:none; }
.live-status.is-visible { transform:translate(-50%,0); opacity:1; }
.leaflet-control-zoom a { width:42px!important; height:42px!important; line-height:40px!important; border-color:var(--line)!important; background:var(--surface-panel)!important; color:var(--text-primary)!important; }
.leaflet-control-attribution { max-width:min(420px,75vw); border-radius:8px 0 0 0!important; background:rgba(255,255,255,.88)!important; }
.leaflet-container.measure-mode { cursor:crosshair; }
.location-marker { width:26px; height:26px; border:3px solid #fff; border-radius:50%; background:#3eafe9; box-shadow:0 0 0 8px rgba(62,175,233,.24),0 10px 22px rgba(0,0,0,.36); }
.point-marker { display:grid; place-items:center; width:26px; height:26px; border:2px solid #fff; border-radius:50%; background:#d7901b; color:#fff; box-shadow:0 6px 18px rgba(0,0,0,.4); font-weight:800; font-size:12px; }
.segment-label { min-width:58px; padding:4px 7px; border:1px solid rgba(255,255,255,.28); border-radius:6px; background:rgba(11,20,24,.9); color:#fff; font-size:11px; font-weight:700; text-align:center; }
.layer-dialog { position:fixed; inset:0; width:100dvw; height:100dvh; max-width:none; max-height:100dvh; margin:0; padding:0; overflow:hidden; overscroll-behavior:contain; border:0; background:var(--surface-map); color:var(--text-primary); }
.layer-dialog::backdrop { background:rgba(3,9,12,.62); }
.dialog-shell { display:flex; flex-direction:column; height:100dvh; min-height:0; overflow:hidden; padding:calc(var(--safe-top) + 18px) max(18px,env(safe-area-inset-right)) calc(var(--safe-bottom) + 18px) max(18px,env(safe-area-inset-left)); }
.dialog-header { min-height:62px; margin-bottom:15px; }
.dialog-header h2 { font-size:clamp(22px,3vw,30px); }
.dialog-layout { display:grid; grid-template-columns:minmax(185px,240px) minmax(330px,1fr) minmax(290px,.85fr); gap:14px; min-height:0; flex:1; }
.group-nav, .layer-list-panel, .layer-detail { min-height:0; overflow:auto; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface-panel); box-shadow:var(--shadow); }
.group-nav { padding:10px; }
.group-button { display:flex; align-items:center; width:100%; min-height:46px; gap:10px; margin:2px 0; padding:9px 10px; border-radius:10px; background:transparent; color:var(--text-muted); font-weight:700; text-align:left; }
.group-button:hover, .group-button.is-active { background:rgba(206,242,251,.13); color:var(--text-primary); }
.group-button svg { width:17px; height:17px; color:var(--brand-primary); }
.group-button small { margin-left:auto; color:var(--brand-accent); font-variant-numeric:tabular-nums; }
.layer-list-panel { display:flex; flex-direction:column; padding:16px; }
.layer-list-heading h3 { font-size:20px; }
.text-button { min-height:32px; padding:5px 8px; border-radius:7px; background:transparent; color:var(--brand-primary); font-weight:750; }
.text-button:hover { background:rgba(206,242,251,.12); }
.base-controls { display:grid; gap:14px; padding:16px 0; }
.field-label { display:grid; gap:7px; font-size:13px; font-weight:700; }
.field-label > span { display:flex; justify-content:space-between; gap:10px; }
select, input[type="search"] { min-height:44px; width:100%; padding:0 11px; border:1px solid var(--line); border-radius:9px; background:var(--surface-input); color:var(--text-primary); }
input[type="range"] { width:100%; accent-color:var(--brand-accent); }
.switch-row { min-height:55px; padding:10px 0; border-top:1px solid var(--line); }
.switch-row span { display:grid; gap:2px; }
.switch-row input { width:22px; height:22px; accent-color:var(--brand-accent); }
.layer-tools { display:grid; gap:10px; align-items:center; padding:14px 0; border-top:1px solid var(--line); }
.group-all-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px; border:1px solid rgba(243,176,64,.42); border-radius:10px; background:rgba(243,176,64,.1); }
.group-all-row > div { display:grid; gap:2px; }
.group-all-row strong { font-size:13px; }
.group-all-row small, .field-label small { color:var(--text-muted); font-size:12px; }
.layer-tools > div:last-child { display:flex; justify-content:flex-end; }
.search-field { position:relative; display:block; }
.search-field svg { position:absolute; left:12px; top:13px; width:18px; height:18px; color:var(--text-muted); }
.search-field input { padding-left:38px; }
.layer-list { min-height:0; overflow:auto; border-top:1px solid var(--line); }
.layer-row { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:10px; min-height:60px; padding:8px 2px; border-bottom:1px solid rgba(206,242,251,.11); }
.layer-row--select-all { min-height:56px; padding:8px 2px; background:rgba(243,176,64,.1); }
.layer-row--select-all strong { color:var(--brand-accent); }
.layer-row input { width:21px; height:21px; margin:0; accent-color:var(--brand-accent); }
.layer-row label { min-width:0; cursor:pointer; }
.layer-row strong, .layer-row small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.layer-row strong { font-size:14px; }
.layer-row small { color:var(--text-muted); font-size:12px; }
.layer-row.is-selected { background:rgba(206,242,251,.07); }
.layer-detail { padding:20px; }
.detail-empty { display:grid; place-items:center; min-height:100%; align-content:center; gap:8px; color:var(--text-muted); text-align:center; }
.detail-empty svg { width:32px; height:32px; color:var(--brand-primary); }
.detail-empty p { margin:0; }
.detail-title-row h3 { margin:0; font-size:20px; }
.detail-section { margin:18px 0; padding-top:16px; border-top:1px solid var(--line); }
.detail-section h4 { margin:0 0 7px; font-size:14px; }
.detail-section p { margin:0; color:var(--text-muted); }
.detail-meta { display:grid; gap:6px; }
.detail-link { color:var(--brand-primary); }
.legend-list { display:grid; gap:8px; }
.legend-row { display:flex; align-items:center; gap:8px; min-height:28px; color:var(--text-muted); font-size:13px; cursor:help; }
.legend-row img { width:28px; height:28px; object-fit:contain; background:rgba(255,255,255,.05); }
.detail-loading { color:var(--text-muted); }
@media (max-width:980px) { .topbar { grid-template-columns:minmax(200px,1fr) auto; } .status-row { grid-column:1/-1; grid-row:2; padding:0; } .dialog-layout { grid-template-columns:minmax(170px,220px) minmax(0,1fr); } .layer-detail { grid-column:1/-1; min-height:260px; } }
@media (max-width:720px) { .topbar { top:max(8px,calc(var(--safe-top) + 7px)); left:8px; right:8px; gap:7px; } .brand { min-height:48px; padding:6px 8px; } .brand img { width:33px; height:33px; } .brand h1 { font-size:15px; } .brand p { display:none; } .toolbar { gap:3px; padding:3px; } .tool-button { width:42px; min-height:42px; padding:0; } .tool-button span { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; } .status-row { flex-wrap:nowrap; overflow:auto; padding-bottom:2px; } .status-chip { flex:0 0 auto; } .status-chip--wide { display:none; } .measure-panel { top:auto; bottom:calc(var(--safe-bottom) + 8px); left:8px; width:calc(100vw - 16px); } .measure-panel.is-collapsed { transform:translateY(calc(100% - 44px)); } .measure-panel__content { padding:12px; } .panel-edge-handle { top:-38px; right:50%; border:1px solid var(--line); border-bottom:0; border-radius:10px 10px 0 0; transform:translateX(50%); } .measure-panel.is-collapsed .panel-edge-handle svg { transform:rotate(-90deg); } .legend-panel { top:auto; right:8px; bottom:calc(var(--safe-bottom) + 8px); width:calc(100vw - 16px); } .legend-panel.is-collapsed { transform:translateY(calc(100% + 8px)); } .legend-panel__content { max-height:min(58dvh,560px); padding:12px; } .legend-panel__handle { top:-38px; left:50%; right:auto; border:1px solid var(--line); border-bottom:0; border-radius:10px 10px 0 0; transform:translateX(-50%); } .legend-panel.is-collapsed .legend-panel__handle svg { transform:rotate(90deg); } .map-footer { right:8px; bottom:calc(var(--safe-bottom) + 8px); max-width:calc(100vw - 16px); font-size:11px; } .measure-panel:not(.is-collapsed) ~ .map-footer { display:none; } .dialog-shell { padding:calc(var(--safe-top) + 12px) 12px calc(var(--safe-bottom) + 12px); } .dialog-header { min-height:50px; margin-bottom:10px; } .selection-count { display:none; } .dialog-layout { display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr) minmax(0,30vh); min-height:0; overflow:hidden; } .group-nav { display:flex; gap:4px; overflow:auto; padding:6px; } .group-nav > div { display:flex; gap:4px; } .group-button { flex:0 0 auto; width:auto; min-height:42px; padding:8px; } .group-button span { max-width:11ch; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } .layer-list-panel { display:flex; min-height:0; overflow:hidden; } .layer-list { flex:1; max-height:none; overflow:auto; } .layer-detail { grid-column:auto; min-height:0; overflow:auto; } .layer-tools > div { display:flex; justify-content:flex-end; } .group-all-row { justify-content:space-between!important; } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto!important; transition-duration:.01ms!important; animation-duration:.01ms!important; } }

/* The list is the primary task surface.  Keep its own scroll area independent
   from the modal shell so it remains reachable on short and narrow screens. */
.base-controls[hidden], .layer-tools[hidden] { display:none!important; }
.dialog-layout { grid-template-columns:minmax(210px,260px) minmax(0,1fr); }
.layer-list-panel { min-height:0; overflow:hidden; }
.layer-list { flex:1 1 auto; min-height:0; overscroll-behavior:contain; }
.base-controls { min-height:0; overflow:auto; overscroll-behavior:contain; }
.layer-tools > div { display:none; }

/* Contextual layer help replaces the former permanently occupied third column. */
.layer-detail { position:fixed; z-index:1400; width:min(390px,calc(100vw - 24px)); max-height:min(68dvh,560px); overflow:auto; overscroll-behavior:contain; padding:16px; border:1px solid rgba(206,242,251,.35); border-radius:14px; background:var(--surface-panel); box-shadow:0 20px 48px rgba(0,0,0,.5); backdrop-filter:blur(16px); }
.layer-detail[hidden] { display:none; }
.layer-detail .detail-section:first-of-type { margin-top:14px; }
.layer-detail-close { flex:none; min-width:44px; min-height:44px; }

@media (max-width:720px) {
  .topbar { grid-template-columns:minmax(0,1fr) auto; grid-template-rows:auto auto; align-items:start; }
  .brand { min-width:0; gap:8px; }
  .brand h1 { overflow:hidden; font-size:16px; text-overflow:ellipsis; white-space:nowrap; }
  .toolbar { display:grid; grid-template-columns:repeat(4,42px); flex-wrap:nowrap; justify-content:initial; }
  .tool-button { width:42px; min-width:42px; min-height:42px; }
  .status-row { display:grid; grid-column:1/-1; grid-row:2; grid-template-columns:minmax(0,126px) minmax(0,1fr); width:100%; min-width:0; overflow:hidden; }
  .status-chip { min-width:0; max-width:none; }
  .status-chip > span, .status-chip strong { min-width:0; overflow:hidden; text-overflow:ellipsis; }
  .dialog-layout { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); gap:10px; }
  .group-nav { grid-column:auto; grid-row:auto; display:flex; gap:5px; min-height:54px; overflow-x:auto; overflow-y:hidden; padding:6px; overscroll-behavior-x:contain; }
  .group-nav > #layerGroups { display:flex; gap:5px; }
  .group-button { flex:0 0 auto; min-height:42px; }
  .group-button span { max-width:13ch; }
  .layer-list-panel { grid-column:auto; min-height:0; padding:14px; }
  .layer-list-heading h3 { font-size:clamp(18px,5vw,22px); }
  .layer-detail { width:calc(100vw - 24px); max-height:min(66dvh,520px); padding:14px; }
  .layer-row { min-height:64px; }
  .layer-row .icon-button { min-width:44px; min-height:44px; }
  input[type="search"], select { font-size:16px; }
  .map-footer { right:62px; bottom:calc(var(--safe-bottom) + 34px); left:8px; justify-content:space-between; max-width:none; font-size:10px; }
  .map-footer a { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .leaflet-control-attribution { max-width:calc(100vw - 118px); overflow:hidden; font-size:10px; white-space:nowrap; text-overflow:ellipsis; }
}

@media (max-width:460px) {
  .toolbar { grid-template-columns:repeat(4,38px); gap:2px; padding:4px; }
  .tool-button { width:38px; min-width:38px; min-height:38px; }
  .brand { min-height:46px; padding:6px 7px; }
  .brand img { width:32px; height:32px; }
  .brand h1 { font-size:15px; }
  .status-row { grid-template-columns:minmax(0,116px) minmax(0,1fr); gap:6px; }
  .status-chip { min-height:32px; padding:0 8px; }
}

@media (max-height:480px) and (orientation:landscape) {
  .dialog-shell { padding:8px 14px; }
  .dialog-header { min-height:44px; margin-bottom:6px; }
  .dialog-header .eyebrow, .layer-list-heading .eyebrow { display:none; }
  .dialog-header h2 { font-size:21px; }
  .dialog-layout { gap:6px; }
  .group-nav { min-height:48px; padding:4px; }
  .group-button { min-height:38px; padding:6px 8px; }
  .layer-list-panel { padding:9px 12px; }
  .layer-list-heading { min-height:32px; }
  .layer-list-heading h3 { font-size:18px; }
  .layer-tools { gap:6px; padding:7px 0; }
  .layer-row { min-height:52px; padding:4px 2px; }
  .layer-row--select-all { min-height:48px; }
}
