/* ==========================================================================
   Quy hoạch Hà Nội — UI styles
   ========================================================================== */

:root {
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --bg: #eef2f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-2: rgba(241, 245, 249, 0.9);
  --surface-3: #e8eef5;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --glass-edge: rgba(255, 255, 255, 0.7);
  --text: #0b1726;
  --text-2: #475569;
  --text-3: #7a889a;
  --accent: #0e7490;
  --accent-strong: #0b5f77;
  --accent-soft: rgba(14, 116, 144, 0.1);
  --accent-ring: rgba(14, 116, 144, 0.32);
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);
  --danger: #c2410c;
  --danger-soft: rgba(194, 65, 12, 0.1);
  --mark: rgba(14, 116, 144, 0.16);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 16px rgba(15, 23, 42, 0.08), 0 18px 40px -12px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, 0.05), 0 12px 32px rgba(15, 23, 42, 0.12), 0 32px 64px -16px rgba(15, 23, 42, 0.26);

  --r-xs: 6px;
  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur: 220ms;
  --dur-lg: 360ms;

  --gap: 14px;
  --left-w: 408px;
  --blur: saturate(170%) blur(18px);
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #070d18;
  --surface: rgba(13, 21, 36, 0.84);
  --surface-solid: #0e1727;
  --surface-2: rgba(23, 34, 54, 0.82);
  --surface-3: #1a2639;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --glass-edge: rgba(148, 163, 184, 0.1);
  --text: #e7eef8;
  --text-2: #a5b4c8;
  --text-3: #74849b;
  --accent: #38bdf8;
  --accent-strong: #7dd3fc;
  --accent-soft: rgba(56, 189, 248, 0.13);
  --accent-ring: rgba(56, 189, 248, 0.4);
  --on-accent: #04121f;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #fb923c;
  --danger-soft: rgba(251, 146, 60, 0.12);
  --mark: rgba(56, 189, 248, 0.22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 56px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'tnum' 0;
  touch-action: manipulation;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--mark); }
.tnum { font-variant-numeric: tabular-nums; }

/* icons (Lucide sprite) */
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i.sm { width: 15px; height: 15px; }
.i.xs { width: 13px; height: 13px; }
.i.lg { width: 22px; height: 22px; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- map ---------- */
.map, .compare-map { position: absolute; inset: 0; }
.map { background: var(--bg); }
.compare-map { pointer-events: none; z-index: 1; }
.maplibregl-canvas { outline: none; }
.maplibregl-ctrl-bottom-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding: 0 12px 10px 0; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 0 !important; }
.maplibregl-ctrl-scale {
  background: var(--surface); color: var(--text-2); border: 1.5px solid var(--text-3); border-top: none;
  font: 500 10.5px/1.5 var(--font); padding: 0 6px; border-radius: 0 0 4px 4px; backdrop-filter: var(--blur);
}
.maplibregl-ctrl-attrib {
  background: var(--surface) !important; color: var(--text-3); font-size: 10.5px; border-radius: 8px !important;
  backdrop-filter: var(--blur); box-shadow: var(--shadow-sm);
}
.maplibregl-ctrl-attrib a { color: var(--text-2); }
.maplibregl-ctrl-attrib-button { filter: none; }
[data-theme='dark'] .maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-popup-content { background: var(--surface-solid); color: var(--text); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px 12px; font: 500 12.5px/1.4 var(--font); }
.maplibregl-popup-tip { border-top-color: var(--surface-solid) !important; border-bottom-color: var(--surface-solid) !important; }

/* ---------- glass surfaces ---------- */
.glass {
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--surface-solid); }
}

/* ---------- top progress ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2.5px; z-index: 60; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 300ms var(--ease); }
.progress.on { opacity: 1; }
.progress span { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: sweep 1.15s var(--ease) infinite; }
@keyframes sweep { to { left: 100%; } }

/* ---------- buttons ---------- */
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface-solid); color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform 120ms var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.ghost { background: transparent; border-color: transparent; }
.icon-btn.ghost:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text);
  font-weight: 550; font-size: 13px; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 120ms var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 6px 16px -6px var(--accent-ring); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.subtle { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.subtle:hover { background: var(--mark); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn .i { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.kbd {
  font: 600 11px/1 var(--mono); color: var(--text-3); padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-solid); box-shadow: 0 1px 0 var(--border-strong);
}

/* ---------- left column ---------- */
.left-col {
  position: absolute; top: var(--gap); left: var(--gap); bottom: var(--gap); width: var(--left-w);
  display: flex; flex-direction: column; gap: 10px; z-index: 20; pointer-events: none;
}
.left-col > * { pointer-events: auto; }

.search-card { border-radius: var(--r-lg); padding: 12px 12px 12px; position: relative; flex: none; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 2px 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: var(--on-accent);
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  box-shadow: 0 6px 14px -6px var(--accent-ring), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.brand-mark .i { width: 19px; height: 19px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-text strong { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text span { font-size: 12px; color: var(--text-3); }

.search {
  position: relative; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 8px 0 13px;
  border-radius: var(--r); background: var(--surface-solid); border: 1px solid var(--border-strong);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-icon { color: var(--text-3); }
.search:focus-within .search-icon { color: var(--accent); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 14.5px; }
.search input::placeholder { color: var(--text-3); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); opacity: 0; transition: opacity 160ms; animation: spin 0.7s linear infinite; flex: none; }
.spinner.on { opacity: 1; }

.search-drop { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; animation: dropIn 220ms var(--ease); }
@keyframes dropIn { from { opacity: 0; transform: translateY(-4px); } }
.search-list { list-style: none; margin: 0; padding: 0; max-height: min(56vh, 430px); overflow: auto; overscroll-behavior: contain; }
.search-group { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }
.opt {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer;
  animation: optIn 240ms var(--ease) both; animation-delay: calc(var(--i, 0) * 16ms);
}
@keyframes optIn { from { opacity: 0; transform: translateY(3px); } }
.opt.keep { animation: none; }
.opt[aria-selected='true'], .opt:hover { background: var(--accent-soft); }
.opt-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.opt[aria-selected='true'] .opt-ico { background: var(--accent); color: var(--on-accent); }
.opt-main { min-width: 0; }
.opt-title { font-weight: 560; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-title mark { background: none; color: var(--accent); font-weight: 700; }
.opt-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-tag { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.search-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px 2px; font-size: 11.5px; color: var(--text-3); }
.search-foot .keys { display: flex; gap: 6px; align-items: center; }
.search-foot .kbd { padding: 2px 5px; font-size: 10.5px; }
@media (hover: none) and (pointer: coarse) { .search-foot .keys { display: none; } }
.search-empty { padding: 14px 10px; color: var(--text-2); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 6px 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface-solid); font-size: 12.5px; color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip .i { width: 14px; height: 14px; }

/* ---------- info panel ---------- */
.panel {
  border-radius: var(--r-lg); flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  animation: panelIn var(--dur-lg) var(--ease) both;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
.panel.closing { animation: panelOut 200ms var(--ease) both; }
@keyframes panelOut { to { opacity: 0; transform: translateY(8px) scale(0.985); } }
.panel-scroll { overflow: auto; overscroll-behavior: contain; flex: 1; min-height: 0; scrollbar-width: thin; scroll-behavior: smooth; }
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.sheet-grip { display: none; }

.panel-head { padding: 16px 16px 12px; position: relative; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.eyebrow .i { width: 13px; height: 13px; color: var(--accent); }
.addr-title { margin: 6px 0 2px; font-size: 18px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; padding-right: 76px; }
.addr-sub { margin: 0; color: var(--text-2); font-size: 13px; }
.head-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 2px; }
.coords { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.coord {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 7px 9px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface-2); position: relative; min-width: 0;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.coord:hover { border-color: var(--accent-ring); background: var(--accent-soft); }
.coord .k { font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em; color: var(--text-3); text-transform: uppercase; display: flex; align-items: center; gap: 5px; width: 100%; }
.coord .k-x { white-space: nowrap; }
.coord .k .i { margin-left: auto; width: 13px; height: 13px; opacity: 0; transition: opacity var(--dur); }
.coord:hover .k .i { opacity: 0.8; }
.coord .v { font: 560 12.5px/1.35 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; letter-spacing: -0.01em; }
.quick-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.tabs { position: sticky; top: 0; z-index: 2; display: flex; gap: 2px; padding: 6px 8px 0; background: var(--surface); backdrop-filter: var(--blur); border-bottom: 1px solid var(--border); }
.tab {
  position: relative; display: inline-flex; flex: 1 0 auto; justify-content: center; align-items: center; gap: 6px; height: 38px; padding: 0 8px;
  border: 0; background: none; white-space: nowrap; color: var(--text-2); font-weight: 560; font-size: 13px; border-radius: 8px 8px 0 0;
  transition: color var(--dur) var(--ease);
}
.tab .i { width: 15px; height: 15px; }
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--accent); }
.tab::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); transform: scaleX(0); transition: transform var(--dur-lg) var(--ease); }
.tab[aria-selected='true']::after { transform: scaleX(1); }
.tab .count { font-size: 11px; font-weight: 650; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }

.panel-body { padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.panel-body > * { animation: fadeUp 380ms var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

/* hero summary */
.hero { border-radius: var(--r); padding: 14px; background: linear-gradient(160deg, var(--surface-solid), var(--surface-2)); border: 1px solid var(--border); position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--sw, var(--accent)); }
.hero-top { display: flex; gap: 12px; align-items: flex-start; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; background: var(--sw, #ccc); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.swatch.lg { width: 40px; height: 40px; border-radius: 11px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 6px 14px -8px var(--sw); }
.hero-title { font-size: 16px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.hero-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge .i { width: 12px; height: 12px; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.code { font-family: var(--mono); letter-spacing: -0.01em; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 6px; margin-top: 12px; }
.metric { padding: 9px 10px; border-radius: var(--r-sm); background: var(--surface-solid); border: 1px solid var(--border); min-width: 0; }
.metric .k { font-size: 11px; color: var(--text-3); font-weight: 560; line-height: 1.25; }
.nw { white-space: nowrap; }
.metric .v { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .v small { font-size: 11.5px; font-weight: 560; color: var(--text-2); margin-left: 2px; }

/* level cards */
.card { border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-solid); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer; user-select: none; }
.card-head:hover { background: var(--surface-2); }
.card-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.card-ico .i { width: 16px; height: 16px; }
.card-title { font-weight: 650; font-size: 13.5px; line-height: 1.3; }
.card-sub { font-size: 12px; color: var(--text-3); }
.card-head .chev { margin-left: auto; color: var(--text-3); transition: transform var(--dur-lg) var(--ease); }
.card[data-open='false'] .chev { transform: rotate(-90deg); }
.card-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--dur-lg) var(--ease); }
.card[data-open='false'] .card-body { grid-template-rows: 0fr; }
.card-inner { overflow: hidden; min-height: 0; }
.card-content { padding: 2px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.card.muted .card-ico { background: var(--surface-3); color: var(--text-3); }
.card.muted .card-head { cursor: default; }
.card.muted .card-head:hover { background: none; }

.cat { display: flex; gap: 10px; align-items: flex-start; }
.cat .swatch { margin-top: 3px; }
.cat-name { font-weight: 650; font-size: 14px; line-height: 1.35; }
.cat-sub { font-size: 12px; color: var(--text-2); }

.kv { display: grid; grid-template-columns: minmax(110px, 42%) 1fr; gap: 0; font-size: 12.5px; border-top: 1px solid var(--border); }
.kv > div { padding: 7px 0; border-bottom: 1px solid var(--border); min-width: 0; overflow-wrap: anywhere; }
.kv > div:nth-child(odd) { color: var(--text-3); padding-right: 10px; }
.kv > div:nth-child(even) { font-weight: 550; }
.kv > div:nth-last-child(-n + 2) { border-bottom: 0; }

.snap { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.snap-head span:last-child { white-space: nowrap; }
.snap-head { display: flex; justify-content: space-between; gap: 8px; padding: 0 2px 6px; font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.snap-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto 16px; gap: 10px; align-items: center; width: 100%; padding: 9px 8px; margin: 0 0 4px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-align: left; font-size: 12.5px; transition: border-color var(--dur), background var(--dur), transform var(--dur); }
.snap-row:last-child { margin-bottom: 0; }
.snap-row:hover, .snap-row:focus-visible { border-color: var(--accent-ring); background: var(--accent-soft); }
.snap-row:active { transform: scale(0.99); }
.snap-row .nm { min-width: 0; }
.snap-row .nm b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snap-row .nm span { color: var(--text-3); font-size: 11.5px; }
.snap-row .val { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.snap-row > .i { color: var(--text-3); }
.snap-loading { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12.5px; padding: 2px; }
.swap-in { animation: fadeUp 240ms var(--ease) both; }
.link-row { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 12.5px; font-weight: 560; text-align: left; width: 100%; transition: border-color var(--dur), background var(--dur); }
.link-row:hover { border-color: var(--accent-ring); background: var(--accent-soft); text-decoration: none; }
.link-row .i { color: var(--accent); }
.link-row .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-row .meta { font-size: 11px; color: var(--text-3); font-weight: 500; }

.note { display: flex; gap: 9px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); font-size: 12px; line-height: 1.5; border: 1px solid var(--border); }
.note .i { color: var(--text-3); margin-top: 1px; width: 15px; height: 15px; }
.note.warn { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.note.warn .i { color: var(--warn); }
.empty-line { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12.5px; padding: 2px 0; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin: 4px 2px -2px; }

/* skeleton */
.sk { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.sk::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent); animation: shimmer 1.3s var(--ease) infinite; }
[data-theme='dark'] .sk::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 7px 0; }
.sk-title { height: 18px; width: 70%; margin: 4px 0 8px; }
.sk-block { height: 92px; border-radius: var(--r); }

/* nearby */
.near-group { display: flex; flex-direction: column; gap: 2px; }
.near-item { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; border: 0; background: none; text-align: left; width: 100%; transition: background var(--dur); }
.near-item:hover { background: var(--accent-soft); }
.near-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.near-ico .i { width: 15px; height: 15px; }
.near-name { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.near-dist { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* analysis */
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); margin: 8px 0 4px; }
.bar > span { height: 100%; background: var(--sw); transition: flex-grow 600ms var(--ease); min-width: 2px; }
.bar > span + span { box-shadow: -1px 0 0 var(--surface-solid); }
.alist { display: flex; flex-direction: column; }
.arow { display: grid; grid-template-columns: 14px 1fr auto; gap: 9px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 12.5px; cursor: pointer; border-radius: 6px; transition: background var(--dur); }
.arow:hover { background: var(--surface-2); }
.arow:last-child { border-bottom: 0; }
.arow .nm { min-width: 0; }
.arow .nm b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow .nm span { color: var(--text-3); font-size: 11.5px; }
.arow .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.arow .val small { display: block; color: var(--text-3); font-weight: 500; font-size: 11px; }
.vtable { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.vtable th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 11px; padding: 5px 4px; border-bottom: 1px solid var(--border); }
.vtable td { padding: 5px 4px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 11.5px; }
.vtable tr:last-child td { border-bottom: 0; }

/* ---------- right controls ---------- */
.controls { position: absolute; top: var(--gap); right: var(--gap); z-index: 25; display: flex; flex-direction: column; gap: 10px; }
.ctl-group { display: flex; flex-direction: column; border-radius: var(--r); padding: 4px; gap: 2px; }
.ctl {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9px; border: 0; background: transparent; color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform 120ms var(--ease);
}
.ctl:hover { background: var(--accent-soft); color: var(--accent); }
.ctl:active { transform: scale(0.92); }
.ctl[aria-pressed='true'] { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 14px -6px var(--accent-ring); }
#compass-icon { transition: transform 200ms linear; }

/* ---------- drawer (layers) ---------- */
.drawer {
  position: absolute; top: var(--gap); right: calc(var(--gap) + 58px); bottom: var(--gap); width: 352px; z-index: 24;
  border-radius: var(--r-lg); display: flex; flex-direction: column; overflow: hidden;
  animation: drawerIn var(--dur-lg) var(--ease) both;
}
@keyframes drawerIn { from { opacity: 0; transform: translateX(14px); } }
.drawer.closing { animation: drawerOut 200ms var(--ease) both; }
@keyframes drawerOut { to { opacity: 0; transform: translateX(14px); } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 16px 14px 10px 16px; }
.drawer-head h2 { margin: 2px 0 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.drawer-body { overflow: auto; padding: 0 12px 16px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; overscroll-behavior: contain; }
.group-title { font-size: 11.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin: 0 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.layer-opt {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface-solid); text-align: left; margin-bottom: 6px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.layer-opt:hover { border-color: var(--accent-ring); }
.layer-opt[aria-checked='true'] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.layer-opt .lo-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.layer-opt[aria-checked='true'] .lo-ico { background: var(--accent); color: var(--on-accent); }
.layer-opt .lo-title { display: block; font-weight: 620; font-size: 13px; line-height: 1.3; }
.layer-opt .lo-sub { display: block; margin-top: 2px; font-size: 11.5px; color: var(--text-3); line-height: 1.35; }
.radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; transition: border-color var(--dur); }
.layer-opt[aria-checked='true'] .radio { border-color: var(--accent); }
.layer-opt[aria-checked='true'] .radio::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pop 260ms var(--ease-spring); }
@keyframes pop { from { transform: scale(0); } }
.toggle-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.toggle-row:hover { background: var(--surface-2); }
.toggle-row .grow { flex: 1; }
.toggle-row small { display: block; color: var(--text-3); font-size: 11.5px; }
.switch { position: relative; width: 36px; height: 21px; border-radius: 999px; background: var(--border-strong); transition: background var(--dur) var(--ease); flex: none; }
.switch::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform var(--dur-lg) var(--ease-spring); }
input:checked + .switch { background: var(--accent); }
input:checked + .switch::after { transform: translateX(15px); }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.line-sample { width: 22px; height: 0; border-top: 2px solid #e31010; flex: none; }
.line-sample.dash { border-top-style: dashed; }

.range { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.range label { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.range output { font: 600 12px var(--mono); width: 40px; text-align: right; color: var(--text-2); }
input[type='range'] { -webkit-appearance: none; appearance: none; flex: 1; height: 22px; background: transparent; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--border-strong) var(--p, 50%)); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: var(--border-strong); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); transition: transform 150ms var(--ease); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
input[type='range']:active::-webkit-slider-thumb { transform: scale(1.18); }

.basemaps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.bm {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 9px; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface-solid); font-size: 12px; font-weight: 560; color: var(--text-2); transition: all var(--dur) var(--ease);
}
.bm .i { width: 20px; height: 20px; }
.bm:hover { border-color: var(--accent-ring); color: var(--text); }
.bm[aria-checked='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.legend-search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-solid); margin-bottom: 6px; }
.legend-search input { flex: 1; border: 0; outline: 0; background: none; font-size: 13px; min-width: 0; }
.legend-search .i { color: var(--text-3); width: 15px; height: 15px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.legend li { display: flex; align-items: center; gap: 10px; padding: 5px 6px; font-size: 12.5px; border-radius: 7px; line-height: 1.3; }
.legend li:hover { background: var(--surface-2); }
.legend .swatch { width: 18px; height: 13px; border-radius: 3px; }
.legend-more { font-size: 12px; color: var(--text-3); padding: 6px; }

/* active layer chip */
.layer-chip {
  position: absolute; left: calc(var(--gap) + var(--left-w) + 10px); bottom: var(--gap); z-index: 15; display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 12px 0 10px; border-radius: 14px; text-align: left; max-width: 360px;
  transition: left var(--dur-lg) var(--ease), transform 120ms var(--ease), box-shadow var(--dur);
}
.layer-chip:hover { box-shadow: var(--shadow-lg); }
.layer-chip:active { transform: scale(0.98); }
body:not(.has-panel) .layer-chip { left: var(--gap); }
.layer-chip-text { display: flex; flex-direction: column; min-width: 0; }
.layer-chip-text small { font-size: 10.5px; color: var(--text-3); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.layer-chip-text strong { font-size: 13px; font-weight: 640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-chip > .i { color: var(--text-3); width: 16px; height: 16px; }
.swatch-stack { display: flex; }
.swatch-stack .swatch { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface-solid); }
.swatch-stack .swatch + .swatch { margin-left: -6px; }

/* status bar */
.statusbar {
  position: absolute; right: calc(var(--gap) + 0px); bottom: 64px; z-index: 14; display: flex; align-items: center; gap: 0;
  height: 30px; padding: 0 4px; border-radius: 10px; font: 500 11.5px/1 var(--mono); color: var(--text-2);
}
.sb-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; height: 100%; white-space: nowrap; }
.sb-item + .sb-item { border-left: 1px solid var(--border); }
.sb-item .i { width: 13px; height: 13px; color: var(--text-3); }

/* tool card */
.tool-card {
  position: absolute; left: 50%; bottom: calc(var(--gap) + 2px); z-index: 26; transform: translateX(-50%);
  width: min(560px, calc(100vw - 2 * var(--gap))); border-radius: var(--r-lg); padding: 14px; animation: toolIn var(--dur-lg) var(--ease) both;
}
body.has-panel .tool-card { left: calc(var(--gap) + var(--left-w) + (100vw - var(--left-w) - var(--gap)) / 2); }
@keyframes toolIn { from { opacity: 0; transform: translate(-50%, 12px); } }
.tool-head { display: flex; align-items: center; gap: 10px; }
.tool-head .card-ico { width: 34px; height: 34px; }
.tool-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.tool-head p { margin: 0; font-size: 12px; color: var(--text-3); }
.tool-head .grow { flex: 1; min-width: 0; }
.tool-metrics { display: flex; gap: 18px; margin: 12px 2px 4px; flex-wrap: wrap; }
.tool-metrics .m .k { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.tool-metrics .m .v { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.tool-metrics .m .v small { font-size: 12px; color: var(--text-2); font-weight: 560; margin-left: 3px; }
.tool-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; justify-content: flex-end; }
.tool-actions .grow { flex: 1; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-3); gap: 2px; margin: 12px 0 10px; }
.seg button { height: 30px; padding: 0 12px; border-radius: 8px; border: 0; background: none; font-size: 12.5px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; transition: background var(--dur), color var(--dur), box-shadow var(--dur); }
.seg button[aria-selected='true'] { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.seg .i { width: 14px; height: 14px; }
.seg.fill { display: flex; width: 100%; }
.seg.fill button { flex: 1 1 auto; justify-content: center; padding: 0 6px; white-space: nowrap; }
textarea.coords-input {
  width: 100%; min-height: 130px; max-height: 34vh; resize: vertical; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface-solid); font: 500 12.5px/1.55 var(--mono); outline: none; transition: border-color var(--dur), box-shadow var(--dur);
}
textarea.coords-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.select { height: 34px; padding: 0 30px 0 10px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-solid); font-size: 12.5px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.form-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.form-row label { font-size: 12px; color: var(--text-2); }
.parse-status { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.parse-status.err { color: var(--danger); }
.parse-status.ok { color: var(--ok); }

/* compare */
.compare-bar { position: absolute; top: var(--gap); left: 50%; transform: translateX(-50%); z-index: 27; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 14px; animation: dropIn 260ms var(--ease); }
/* centred in the free map area between the left column (search / panel) and the control rail */
.compare-bar, body.has-panel .compare-bar { left: calc(var(--gap) + var(--left-w) + (100vw - var(--left-w) - var(--gap) - 62px) / 2); }
.compare-bar .side { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); font-weight: 600; white-space: nowrap; flex: none; }
.compare-handle { position: absolute; top: 0; bottom: 0; width: 0; z-index: 3; left: 50%; }
.compare-handle::before { content: ''; position: absolute; top: 0; bottom: 0; left: -1.5px; width: 3px; background: var(--surface-solid); box-shadow: 0 0 0 1px var(--border-strong), 0 0 18px rgba(0, 0, 0, 0.25); }
.compare-knob { position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--surface-solid); color: var(--accent); box-shadow: var(--shadow-lg); cursor: ew-resize; touch-action: none; }
.compare-knob:active { transform: translate(-50%, -50%) scale(0.95); }
.compare-label { position: absolute; top: 76px; padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; z-index: 3; pointer-events: none; }

/* markers */
.pin { position: relative; width: 38px; height: 46px; pointer-events: none; }
.pin svg { position: absolute; left: 0; top: 0; width: 38px; height: 38px; fill: var(--accent); stroke: #fff; stroke-width: 1.6; filter: drop-shadow(0 4px 6px rgba(2, 6, 23, 0.35)); animation: pinDrop 520ms var(--ease-spring) both; transform-origin: 50% 100%; }
[data-theme='dark'] .pin svg { stroke: #04121f; }
.pin::after { content: ''; position: absolute; left: 50%; bottom: 4px; width: 14px; height: 6px; margin-left: -7px; border-radius: 50%; background: rgba(2, 6, 23, 0.28); animation: shadowIn 520ms var(--ease) both; }
.pin .pulse { position: absolute; left: 50%; bottom: 1px; width: 44px; height: 18px; margin-left: -22px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: pulse 2.2s var(--ease) 0.5s infinite; }
@keyframes pinDrop { from { transform: translateY(-18px) scale(0.85); opacity: 0; } }
@keyframes shadowIn { from { transform: scale(0.3); opacity: 0; } }
@keyframes pulse { 0% { transform: scale(0.3); opacity: 0.9; } 100% { transform: scale(1.6); opacity: 0; } }
.poi-marker { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-solid); color: var(--accent); box-shadow: var(--shadow); border: 1.5px solid var(--accent); animation: pop 300ms var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 20ms); cursor: pointer; }
.poi-marker .i { width: 14px; height: 14px; }
.poi-marker:hover { background: var(--accent); color: var(--on-accent); }
.vertex-marker { width: 14px; height: 14px; border-radius: 50%; background: var(--surface-solid); border: 2.5px solid var(--accent); box-shadow: var(--shadow-sm); cursor: grab; }

/* toasts */
.toasts { position: fixed; top: var(--gap); left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 14px 8px 12px; border-radius: 12px; max-width: min(520px, 92vw);
  background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-lg); border: 1px solid var(--border); font-size: 13px; font-weight: 520;
  animation: toastIn 340ms var(--ease-spring) both;
}
.toast.out { animation: toastOut 220ms var(--ease) both; }
.toast .i { width: 17px; height: 17px; }
.toast.ok .i { color: var(--ok); }
.toast.err .i { color: var(--danger); }
.toast.info .i { color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(0.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px) scale(0.98); } }

/* tooltip */
.tooltip { position: fixed; z-index: 90; padding: 6px 9px; border-radius: 8px; background: #0b1726; color: #f1f5f9; font-size: 12px; font-weight: 520; pointer-events: none; white-space: pre; box-shadow: var(--shadow); animation: tipIn 140ms var(--ease) both; }
[data-theme='dark'] .tooltip { background: #e7eef8; color: #0b1726; }
@keyframes tipIn { from { opacity: 0; transform: translateY(2px); } }

/* modal */
.modal { border: 0; padding: 0; border-radius: var(--r-xl); width: min(620px, 94vw); max-height: 86vh; color: var(--text); background: var(--surface-solid); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(2, 6, 23, 0.42); backdrop-filter: blur(3px); animation: fadeIn 200ms var(--ease); }
.modal[open] { animation: modalIn 320ms var(--ease) both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes fadeIn { from { opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 22px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-body { padding: 6px 22px 22px; overflow: auto; max-height: calc(86vh - 70px); font-size: 13.5px; color: var(--text-2); }
.modal-body h3 { font-size: 13px; color: var(--text); margin: 16px 0 8px; font-weight: 700; }
.modal-body ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.keys-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.keys-grid .kbd { justify-self: start; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-size: 16px; }

/* ---------- responsive: tablet ---------- */

/* ---------- inline links, notes, tabs ---------- */
.btn-link { display: inline; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 620; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; cursor: pointer; letter-spacing: 0; text-transform: none; }
.btn-link:hover { text-decoration-thickness: 2px; }
.note .meta-line { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--text-3); }
.note .meta-line .i { width: 12px; height: 12px; margin: 0; }
.note b { color: var(--text); font-weight: 650; }
.coord .v.two { white-space: normal; display: flex; flex-direction: column; }
.section-title .seg { margin: 0; }
.section-title .seg button { text-transform: none; letter-spacing: 0; height: 26px; padding: 0 9px; font-size: 12px; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.toast .toast-act { margin-left: 4px; padding: 5px 10px; border-radius: 8px; border: 0; background: var(--accent-soft); color: var(--accent); font: 620 12.5px/1.2 var(--font); cursor: pointer; white-space: nowrap; transition: background var(--dur), color var(--dur); }
.toast .toast-act:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- legend extras ---------- */
.legend li .grow { flex: 1; min-width: 0; }
.legend li.on { background: var(--accent-soft); font-weight: 620; }
.legend li .badge { flex: none; margin: 0; }
.legend li.empty-line { padding: 8px 6px; }
.legend-more { border: 0; background: none; text-align: left; }
.group-title span { font-weight: 560; letter-spacing: 0; text-transform: none; }
.range input[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- drawing tools ---------- */
body.drawing .maplibregl-canvas-container.maplibregl-interactive,
body.drawing .maplibregl-canvas-container.maplibregl-interactive:active { cursor: crosshair; }
.map .maplibregl-marker { z-index: 2; }
.m-label {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  font: 650 11.5px/1.25 var(--font); font-variant-numeric: tabular-nums;
}
.m-label .i { width: 12px; height: 12px; }
.m-label small { color: var(--text-3); font-weight: 560; font-size: 11px; }
.m-label.seg { padding: 2px 6px; font-size: 11px; font-weight: 600; opacity: 0.96; }
.m-label.total { background: #b45309; color: #fff; border-color: transparent; font-size: 12.5px; padding: 4px 10px; box-shadow: var(--shadow); }
.m-label.total.parcel { background: var(--accent); color: var(--on-accent); }
.m-label.live { box-shadow: var(--shadow); }
.m-label.live small { margin-left: 2px; }
.vertex-marker { transition: box-shadow 140ms var(--ease), background 140ms var(--ease), opacity 140ms var(--ease); }
.vertex-marker:hover { box-shadow: 0 0 0 5px var(--accent-soft), var(--shadow-sm); }
.vertex-marker:active { cursor: grabbing; }
.vertex-marker.first { width: 18px; height: 18px; background: var(--accent); border-color: var(--surface-solid); box-shadow: 0 0 0 5px var(--accent-soft), var(--shadow-sm); cursor: pointer; }
.vertex-marker.mid { width: 11px; height: 11px; border-width: 2px; opacity: 0.72; }
.vertex-marker.mid:hover { opacity: 1; }
body.vertex-drag .vertex-marker.mid { opacity: 0; pointer-events: none; }
.vertex-num {
  position: absolute; left: 12px; top: -16px; padding: 0 5px; border-radius: 5px; pointer-events: none; white-space: nowrap;
  background: var(--surface-solid); color: var(--text-2); box-shadow: var(--shadow-sm); font: 650 10.5px/16px var(--font);
}
.tool-card.closing { animation: toolOut 180ms var(--ease) both; }
@keyframes toolOut { to { opacity: 0; transform: translate(-50%, 10px); } }
.tool-card .seg { margin: 12px 0 8px; }
.tool-card .form-row .grow { flex: 1; }
.tool-card .form-row .select { flex: 1 1 230px; min-width: 0; }
.tool-card .parse-status { margin-top: 8px; line-height: 1.4; align-items: flex-start; }
.tool-card .parse-status .i { width: 14px; height: 14px; flex: none; margin-top: 1px; }
.tool-card [data-issue] { padding: 8px 10px; border-radius: var(--r-sm); background: var(--danger-soft, rgba(220, 38, 38, 0.08)); flex-wrap: wrap; }
.tool-card [data-issue] .btn-link { color: var(--danger); }
.ctl.busy { color: var(--accent); }
#btn-north.rotated { color: var(--accent); }

/* ---------- compare ---------- */
.compare-map { transition: opacity 260ms var(--ease); }
.compare-map:not(.ready) { opacity: 0; }
.compare-handle { cursor: ew-resize; touch-action: none; }
.compare-handle::after { content: ''; position: absolute; top: 0; bottom: 0; left: -10px; width: 20px; }
.compare-handle.dragging .compare-knob { transform: translate(-50%, -50%) scale(1.06); }
.compare-label { white-space: nowrap; color: var(--text); }
.compare-label.l { right: 14px; }
.compare-label.r { left: 14px; }
.compare-label:empty { display: none; }
.compare-bar .select { height: 32px; max-width: 240px; }
.compare-bar .side .i { width: 15px; height: 15px; }
.compare-bar.closing { animation: barOut 180ms var(--ease) both; }
@keyframes barOut { to { opacity: 0; transform: translate(-50%, -6px); } }

@media (max-width: 1100px) {
  :root { --left-w: 372px; }
  .statusbar .sb-vn { display: none; }
  .compare-bar { gap: 6px; }
  .compare-bar .select { max-width: 172px; }
  .compare-bar .side > span { display: none; }
}

/* ---------- responsive: mobile ---------- */
@media (max-width: 760px) {
  :root { --gap: 10px; --left-w: 100vw; }
  body { font-size: 14px; }
  .left-col { left: var(--gap); right: var(--gap); width: auto; bottom: auto; }
  .search-card { padding: 8px; }
  .brand { display: none; }
  .search { height: 46px; }
  .search .kbd { display: none; }
  .search-list { max-height: 60vh; }
  body.has-panel .left-col { z-index: 31; } /* the sheet covers the control rail, never the reverse */
  .ctl-group { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s; }
  /* only the tool group stays beside the sheet */
  body.has-panel .ctl-group:not(:first-child) { opacity: 0; transform: translateX(8px); visibility: hidden; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s linear var(--dur); }
  body.search-open .left-col { z-index: 45; }

  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: var(--sheet-h, 46vh); max-height: calc(100dvh - 76px);
    border-radius: 20px 20px 0 0; border-bottom: 0; z-index: 30; animation: sheetIn var(--dur-lg) var(--ease) both;
    transition: height var(--dur-lg) var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.dragging { transition: none; }
  .panel.closing { animation: sheetOut 220ms var(--ease) both; }
  @keyframes sheetIn { from { transform: translateY(40%); opacity: 0; } }
  @keyframes sheetOut { to { transform: translateY(40%); opacity: 0; } }
  .sheet-grip { display: grid; place-items: center; height: 22px; flex: none; cursor: grab; touch-action: none; }
  .sheet-grip span { width: 40px; height: 5px; border-radius: 99px; background: var(--border-strong); }
  .panel-head { padding-top: 4px; }

  .controls { top: 74px; right: var(--gap); gap: 8px; }
  .ctl { width: 38px; height: 38px; }
  #btn-fullscreen, #btn-compare { display: none; }
  .drawer { left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 72dvh; border-radius: 20px 20px 0 0; z-index: 40; animation: sheetIn var(--dur-lg) var(--ease) both; }
  .drawer.closing { animation: sheetOut 220ms var(--ease) both; }
  .layer-chip { left: var(--gap) !important; bottom: calc(var(--gap) + env(safe-area-inset-bottom)); height: 42px; max-width: calc(100vw - 2 * var(--gap) - 120px); }
  body.has-panel .layer-chip { opacity: 0; pointer-events: none; }
  .statusbar { display: none; }
  .tool-card, body.has-panel .tool-card { left: 50%; bottom: calc(var(--gap) + env(safe-area-inset-bottom)); z-index: 35; }
  .compare-bar, body.has-panel .compare-bar { left: 50%; top: 70px; }
  .maplibregl-ctrl-bottom-right { padding-bottom: 60px; }
  .addr-title { font-size: 16.5px; }
}

@media (max-width: 760px) and (pointer: coarse) {
  #btn-zoom-in, #btn-zoom-out { display: none; } /* pinch to zoom; keeps the rail clear of the sheet */
}
@media (max-width: 420px) {
  .coord .k-x { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
