/* SiteBlock — "กระดาษร่างผังกับดินเผา". UI-REDESIGN §3. สีทั้งหมดอยู่ใน token ด้านล่างเท่านั้น (ไม่มีฟอนต์/ทรัพยากรภายนอก) */
:root {
  color-scheme: light dark;

  /* — สีพื้นผิว — */
  --sb-paper:        #F6F2EA;
  --sb-surface:      #FFFDF8;
  --sb-surface-2:    #EFE9DD;
  --sb-line:         #D9D0BF;
  --sb-ink:          #2A2622;
  --sb-ink-2:        #6B6258;
  --sb-ink-3:        #9A9083;

  /* — สีเน้น — */
  --sb-accent:       #B4532A;
  --sb-accent-ink:   #FFFFFF;
  --sb-accent-soft:  #F3DFD3;
  --sb-site:         #5E7B52;
  --sb-site-fill:    #DDE5D3;
  --sb-select:       #E0A100;
  --sb-warn:         #A15C00;
  --sb-danger:       #A8322D;
  --sb-stale:        #A8A398;

  /* — viewer (viewer.js อ่านผ่าน palette.js) — */
  --sb-scene-bg:     #E9E3D7;
  --sb-scene-bg-night:#8E8A86;
  --sb-ground:       #D8D1C3;
  --sb-grid-major:   #B9AF9E;
  --sb-grid-minor:   #CCC4B5;
  --sb-edge:         #3A342E;
  --sb-north:        #B4532A;

  /* — สีหน้าที่ใช้สอย — */
  --sb-fn-residential: #D08C3C;
  --sb-fn-office:      #3C7A86;
  --sb-fn-retail:      #B85470;
  --sb-fn-hotel:       #7563A8;
  --sb-fn-parking:     #8A8478;
  --sb-fn-other:       #6F9558;

  /* — บริบทรอบที่ดิน (OSM): อาคาร / ขอบ / ถนน — สีเทากลาง ไม่แย่งความสนใจจากอาคารโครงการ — */
  --sb-ctx-bldg:     #B9B3A8;
  --sb-ctx-edge:     #8F887C;
  --sb-ctx-road:     #EEE8DC;

  /* — ไล่สีความสูง/จำนวนชั้น — */
  --sb-seq-1: #F1E3CF; --sb-seq-2: #E2B98F; --sb-seq-3: #CC8A5A;
  --sb-seq-4: #A85E36; --sb-seq-5: #6E3A22;

  /* — ไล่สีแดด — */
  --sb-sun-0: #2E2F6B; --sb-sun-1: #7A3F78; --sb-sun-2: #C9643F;
  --sb-sun-3: #EBA83A; --sb-sun-4: #F8EBB0;

  /* — ระยะ (ฐาน 4px) — */
  --sb-space-1: 4px; --sb-space-2: 8px; --sb-space-3: 12px;
  --sb-space-4: 16px; --sb-space-5: 24px; --sb-space-6: 32px;

  /* — มุมโค้ง — */
  --sb-radius-s: 2px;
  --sb-radius-m: 4px;
  --sb-radius-l: 6px;

  /* — เงา — */
  --sb-shadow-float: 0 1px 0 rgba(42,38,34,.06), 0 4px 14px rgba(42,38,34,.14);

  /* — ตัวอักษร: system font เท่านั้น — */
  --sb-font: system-ui, -apple-system, "Segoe UI", "Sukhumvit Set", "Thonburi",
             "Leelawadee UI", "Noto Sans Thai", "Tahoma", sans-serif;
  --sb-font-num: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sb-text-xs: 11px; --sb-text-s: 12px; --sb-text-m: 13px;
  --sb-text-l: 15px;  --sb-text-kpi: 22px;
  --sb-leading: 1.5;
  --sb-weight-ui: 500; --sb-weight-strong: 650;

  /* — ขนาด layout — */
  --sb-topbar-h: 48px; --sb-bottombar-h: 52px;
  --sb-left-w: 272px;  --sb-right-w: 320px; --sb-tool-btn: 36px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sb-paper:#1C1A18; --sb-surface:#24211E; --sb-surface-2:#2E2A26; --sb-line:#3D3832;
    --sb-ink:#EDE6DA; --sb-ink-2:#B3A898; --sb-ink-3:#7C7368;
    --sb-accent:#D9774C; --sb-accent-ink:#1C1A18; --sb-accent-soft:#4A2E22;
    --sb-site:#93B184; --sb-site-fill:#3A4636; --sb-select:#F2C14E;
    --sb-warn:#E3A048; --sb-danger:#E07A70; --sb-stale:#6F6A62;
    --sb-scene-bg:#2A2724; --sb-scene-bg-night:#151413; --sb-ground:#3A3631;
    --sb-grid-major:#57514A; --sb-grid-minor:#45403A; --sb-edge:#14120F; --sb-north:#D9774C;
    --sb-ctx-bldg:#5B5650; --sb-ctx-edge:#3E3A35; --sb-ctx-road:#47423C;
    --sb-shadow-float: 0 1px 0 rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: grid; grid-template-rows: var(--sb-topbar-h) 1fr var(--sb-bottombar-h);
  font: var(--sb-weight-ui) var(--sb-text-m)/var(--sb-leading) var(--sb-font);
  color: var(--sb-ink); background: var(--sb-paper); overflow: hidden;
}
.mono { font-family: var(--sb-font-num); }
svg { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--sb-accent); outline-offset: 1px; }

/* ---------- top bar ---------- */
#topbar { display: flex; align-items: center; gap: var(--sb-space-2); padding: 0 var(--sb-space-3); background: var(--sb-surface); border-bottom: 1px solid var(--sb-line); }
.brand { display: flex; align-items: center; gap: var(--sb-space-2); color: var(--sb-ink); font-size: var(--sb-text-l); }
.brand-mark { display: flex; color: var(--sb-accent); }
.brand-mark svg { width: 24px; height: 24px; }
.wm-site { font-weight: 400; }
.wm-block { font-weight: 700; }
.project-name { color: var(--sb-ink-2); margin-left: var(--sb-space-2); }
.spacer { flex: 1; }
.topbar-sep { width: 1px; height: 22px; background: var(--sb-line); margin: 0 var(--sb-space-1); }

/* ---------- ปุ่ม / ฟอร์ม ---------- */
button { font: inherit; padding: 4px 10px; border: 1px solid var(--sb-line); border-radius: var(--sb-radius-m); background: transparent; color: var(--sb-ink); cursor: pointer; }
button:hover:not(:disabled) { background: var(--sb-surface-2); }
button:disabled { color: var(--sb-ink-3); cursor: not-allowed; opacity: .6; }
button.primary { background: var(--sb-accent); color: var(--sb-accent-ink); border-color: var(--sb-accent); }
button.primary:hover:not(:disabled) { background: var(--sb-accent); filter: brightness(1.08); }
button.danger { color: var(--sb-danger); border-color: var(--sb-danger); }
.btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.btn-icon svg { width: 18px; height: 18px; }
.rot-90 svg { transform: rotate(90deg); }
input[type=number], input[type=date], input[type=text], select {
  font: inherit; padding: 3px 6px; border: 1px solid var(--sb-line); border-radius: var(--sb-radius-s);
  width: 100%; background: var(--sb-surface-2); color: var(--sb-ink);
}
input.narrow { width: 64px; }
input[type=range] { width: 100%; accent-color: var(--sb-accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--sb-accent); }

/* ---------- ผังหลัก ---------- */
#edit { position: relative; display: grid; grid-template-columns: var(--sb-left-w) 1fr var(--sb-right-w); min-height: 0; }
.panel { background: var(--sb-surface); overflow-y: auto; padding: var(--sb-space-2) var(--sb-space-3) var(--sb-space-4); min-height: 0; }
#panel-left { border-right: 1px solid var(--sb-line); }
#panel-right { border-left: 1px solid var(--sb-line); }
.left-toggle { display: none; }

/* section พับได้: หัวมีเส้นประใต้ตัว (ลายเซ็น SiteBlock) */
.sec { margin: 0 0 var(--sb-space-3); }
.sec > summary, .sec-title {
  display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer;
  font-size: var(--sb-text-s); font-weight: var(--sb-weight-strong); color: var(--sb-ink);
  padding: var(--sb-space-2) 0 var(--sb-space-1); border-bottom: 1px dashed var(--sb-line); margin-bottom: var(--sb-space-2);
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary svg { width: 14px; height: 14px; transform: rotate(-90deg); transition: transform .12s; color: var(--sb-ink-2); }
.sec[open] > summary svg { transform: none; }
.sec-title { cursor: default; margin-top: var(--sb-space-3); }
.sec-title:first-child { margin-top: 0; }

.form { display: flex; flex-direction: column; gap: 6px; }
.form label { display: flex; flex-direction: column; gap: 2px; color: var(--sb-ink-2); font-size: var(--sb-text-s); }
.form label.inline { flex-direction: row; align-items: center; gap: 6px; }
.note { margin: 6px 0 0; color: var(--sb-ink-2); font-size: var(--sb-text-s); }
.warn { margin: 6px 0 0; color: var(--sb-warn); font-weight: var(--sb-weight-strong); font-size: var(--sb-text-s); display: flex; align-items: center; gap: 6px; }
.warn svg { width: 16px; height: 16px; }

/* รายการอาคาร */
.bld-list { display: flex; flex-direction: column; gap: 2px; }
.bld-row { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: var(--sb-space-2); width: 100%; text-align: left; padding: 4px 6px; border: 1px solid transparent; border-left: 3px solid transparent; border-radius: var(--sb-radius-s); }
.bld-row.selected { background: var(--sb-accent-soft); border-left-color: var(--sb-accent); }
.bld-row .sw { width: 12px; height: 12px; border-radius: var(--sb-radius-s); border: 1px solid var(--sb-edge); }
.bld-row .sub { color: var(--sb-ink-2); font-size: var(--sb-text-s); font-variant-numeric: tabular-nums; }

/* แท็บข้อความของแผงขวา */
.tabs-text { display: flex; border-bottom: 1px solid var(--sb-line); margin: 0 calc(var(--sb-space-3) * -1) var(--sb-space-3); padding: 0 var(--sb-space-3); gap: 2px; }
.tabs-text button { border: 0; border-bottom: 2px solid transparent; border-radius: var(--sb-radius-s) var(--sb-radius-s) 0 0; padding: 6px 12px; color: var(--sb-ink-2); background: transparent; }
.tabs-text button[aria-selected=true] { color: var(--sb-ink); border-bottom-color: var(--sb-accent); font-weight: var(--sb-weight-strong); }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sb-space-2); margin-bottom: var(--sb-space-3); }
.kpi { border: 1px solid var(--sb-line); border-radius: var(--sb-radius-m); padding: var(--sb-space-2) var(--sb-space-3); background: var(--sb-paper); }
.kpi .k { font-size: var(--sb-text-xs); color: var(--sb-ink-2); }
.kpi .v { font-size: var(--sb-text-kpi); font-weight: var(--sb-weight-strong); font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi .u { font-size: var(--sb-text-xs); color: var(--sb-ink-2); min-height: 1.5em; }
table.metrics { width: 100%; border-collapse: collapse; }
table.metrics th { text-align: left; font-weight: var(--sb-weight-ui); padding: 2px 0; }
table.metrics td { text-align: right; font-variant-numeric: tabular-nums; padding: 2px 0 2px 8px; }
table.metrics td.unit { text-align: left; color: var(--sb-ink-2); font-size: var(--sb-text-xs); width: 3.2em; }
table.metrics td.pct { color: var(--sb-ink-2); width: 3.4em; }
table.metrics .sw { display: inline-block; width: 10px; height: 10px; border-radius: var(--sb-radius-s); margin-right: 6px; vertical-align: baseline; border: 1px solid var(--sb-edge); }
.stack-bar { display: flex; height: 10px; margin: var(--sb-space-1) 0 var(--sb-space-2); border: 1px solid var(--sb-line); border-radius: var(--sb-radius-s); overflow: hidden; background: var(--sb-surface-2); }
.stack-bar > span { display: block; height: 100%; }

/* ไล่สี / legend */
.grad-bar { height: 10px; border-radius: var(--sb-radius-s); margin-top: 6px; border: 1px solid var(--sb-line); }
.legend-labels { display: flex; justify-content: space-between; font-size: var(--sb-text-xs); color: var(--sb-ink-2); font-variant-numeric: tabular-nums; }
.legend-title { font-size: var(--sb-text-xs); font-weight: var(--sb-weight-strong); margin-bottom: 2px; }
.legend-row { display: flex; align-items: center; gap: 6px; font-size: var(--sb-text-xs); line-height: 1.6; }
.legend-row .sw { width: 12px; height: 12px; border-radius: var(--sb-radius-s); border: 1px solid var(--sb-edge); flex: none; }
.legend-row .grow { flex: 1; }
.legend-row .num { font-variant-numeric: tabular-nums; color: var(--sb-ink-2); }
.legend-sep { margin-top: var(--sb-space-2); padding-top: var(--sb-space-2); border-top: 1px dashed var(--sb-line); }

.radio-card { display: block; padding: var(--sb-space-2); border: 1px solid var(--sb-line); border-radius: var(--sb-radius-m); margin-bottom: var(--sb-space-2); cursor: pointer; }
.radio-card.on { border-color: var(--sb-accent); background: var(--sb-accent-soft); }
.radio-card.off { opacity: .6; cursor: not-allowed; }
.radio-card .t { display: flex; align-items: center; gap: 6px; font-weight: var(--sb-weight-strong); }
.radio-card .d { margin: 2px 0 0 22px; font-size: var(--sb-text-xs); color: var(--sb-ink-2); }

/* ---------- viewer ---------- */
#viewer-wrap { position: relative; min-width: 0; min-height: 0; background: var(--sb-scene-bg); }
#viewer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.float-panel { position: absolute; background: color-mix(in srgb, var(--sb-surface) 96%, transparent); border-radius: var(--sb-radius-l); box-shadow: var(--sb-shadow-float); border: 1px solid var(--sb-line); }
.viewer-hint { position: absolute; left: var(--sb-space-2); bottom: var(--sb-space-2); max-width: 60%; padding: 3px 8px; background: color-mix(in srgb, var(--sb-surface) 90%, transparent); border-radius: var(--sb-radius-m); font-size: var(--sb-text-s); color: var(--sb-ink-2); pointer-events: none; }

#viewer-toolbar { left: var(--sb-space-3); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; padding: var(--sb-space-1); gap: 2px; }
#viewer-toolbar .tb-btn { position: relative; width: var(--sb-tool-btn); height: var(--sb-tool-btn); padding: 0; display: flex; align-items: center; justify-content: center; border: 0; border-left: 3px solid transparent; border-radius: var(--sb-radius-s); color: var(--sb-ink); }
#viewer-toolbar .tb-btn svg { width: 20px; height: 20px; }
#viewer-toolbar .tb-btn.active { background: var(--sb-accent-soft); border-left-color: var(--sb-accent); color: var(--sb-accent); }
#viewer-toolbar .tb-sep { height: 1px; background: var(--sb-line); margin: var(--sb-space-1) 2px; }

#viewer-status { right: var(--sb-space-3); top: var(--sb-space-3); padding: var(--sb-space-1); min-width: 190px; display: flex; flex-direction: column; }
#viewer-status button { display: flex; align-items: center; gap: 6px; border: 0; text-align: left; padding: 3px 8px; font-size: var(--sb-text-s); }
#viewer-status svg { width: 16px; height: 16px; color: var(--sb-accent); }
#viewer-status .warn { margin: 0; padding: 2px 8px; }
#viewer-legend { right: var(--sb-space-3); bottom: var(--sb-space-3); padding: var(--sb-space-2) var(--sb-space-3); min-width: 180px; max-width: 260px; }

/* ---------- แถบแบบเสนอล่าง ---------- */
#proposals-bar { display: flex; align-items: center; gap: var(--sb-space-3); padding: 0 var(--sb-space-3); background: var(--sb-surface); border-top: 1px solid var(--sb-line); overflow-x: auto; }
#proposals-bar .lbl { color: var(--sb-ink-2); font-size: var(--sb-text-s); white-space: nowrap; }
#proposals-bar .tabs { display: flex; gap: var(--sb-space-1); flex: 1; align-items: stretch; height: 100%; }
.tab { display: flex; align-items: center; gap: 6px; padding: 0 var(--sb-space-3); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; user-select: none; color: var(--sb-ink-2); }
.tab:hover { background: var(--sb-surface-2); }
.tab.active { border-bottom-color: var(--sb-accent); color: var(--sb-ink); font-weight: var(--sb-weight-strong); }
.tab .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sb-accent); }
.tab-del { padding: 0; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border: none; color: var(--sb-ink-2); }
.tab-del svg { width: 14px; height: 14px; }
.tab-del:hover:not(:disabled) { color: var(--sb-danger); }
.rename { width: 140px; }
#proposals-bar .actions { display: flex; gap: 6px; }

/* ---------- เปรียบเทียบ ---------- */
#compare { grid-row: 2; display: flex; flex-direction: column; min-height: 0; overflow: auto; padding: var(--sb-space-2) var(--sb-space-3); }
.compare-head { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sb-space-3); margin-bottom: var(--sb-space-2); }
.compare-title { margin-right: var(--sb-space-2); }
.inline-field { display: flex; align-items: center; gap: 6px; color: var(--sb-ink-2); font-size: var(--sb-text-s); white-space: nowrap; }
.inline-field select, .inline-field input[type=date] { width: auto; }
.compare-legend { flex: none; margin-bottom: var(--sb-space-2); max-width: 420px; }
#compare-grid { flex: none; display: grid; gap: var(--sb-space-2); grid-template-columns: repeat(2, 1fr); }
.cell { background: var(--sb-surface); border: 1px solid var(--sb-line); border-radius: var(--sb-radius-l); overflow: hidden; }
.cell-head { display: flex; align-items: center; gap: var(--sb-space-2); padding: 4px var(--sb-space-2); border-bottom: 1px solid var(--sb-line); }
.cell-head .slot { font-weight: var(--sb-weight-strong); white-space: nowrap; }
.cell-head select { flex: 1; width: auto; min-width: 0; }
.cell-head .cell-x { padding: 0; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.cell-head .cell-x svg { width: 14px; height: 14px; }
.cell canvas { display: block; width: 100%; height: 260px; }
.cell-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--sb-line); border-top: 1px solid var(--sb-line); }
.cell-kpis > div { background: var(--sb-surface); padding: 4px var(--sb-space-2); font-variant-numeric: tabular-nums; }
.cell-kpis .k { font-size: var(--sb-text-xs); color: var(--sb-ink-2); }
.cell-kpis .v { font-weight: var(--sb-weight-strong); }
.cell-kpis .d { font-size: var(--sb-text-xs); color: var(--sb-ink-2); }
.cell-sun { display: flex; align-items: baseline; gap: var(--sb-space-2); padding: 4px var(--sb-space-2); border-top: 1px solid var(--sb-line); font-size: var(--sb-text-s); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.cell-sun .k { color: var(--sb-ink-2); }
.cell-sun .v { font-weight: var(--sb-weight-strong); }
.cell-sun .d { color: var(--sb-ink-2); font-size: var(--sb-text-xs); }
.cell-sun .stale { color: var(--sb-warn); font-weight: var(--sb-weight-strong); }
.compare-actions { flex: none; display: flex; align-items: center; gap: var(--sb-space-3); margin: var(--sb-space-2) 0; }
.compare-actions .note { margin: 0; }
.compare-table-wrap { flex: none; overflow-x: auto; background: var(--sb-surface); border: 1px solid var(--sb-line); border-radius: var(--sb-radius-l); }
#compare-table { border-collapse: collapse; width: 100%; }
#compare-table th, #compare-table td { padding: 5px 10px; border-bottom: 1px solid var(--sb-line); text-align: right; font-variant-numeric: tabular-nums; }
#compare-table th:first-child { text-align: left; color: var(--sb-ink-2); font-weight: var(--sb-weight-ui); }
#compare-table thead th { font-weight: var(--sb-weight-strong); color: var(--sb-ink); }
#compare-table td.delta, #compare-table th.delta { color: var(--sb-ink-2); border-left: 1px dashed var(--sb-line); }

/* ---------- toast ---------- */
#toast { position: fixed; right: var(--sb-space-3); top: calc(var(--sb-topbar-h) + 4px); display: flex; flex-direction: column; gap: 6px; z-index: 10; max-width: 380px; }
.toast-item { padding: 8px 12px; border-radius: var(--sb-radius-m); background: var(--sb-ink); color: var(--sb-surface); white-space: pre-line; box-shadow: var(--sb-shadow-float); }
.toast-item.error { background: var(--sb-danger); color: var(--sb-accent-ink); }

/* ---------- จอแคบ < 1100px: แผงซ้ายพับเป็นแถบ 40px ---------- */
@media (max-width: 1099px) {
  #edit { grid-template-columns: 40px 1fr var(--sb-right-w); }
  #panel-left { overflow: hidden; padding: var(--sb-space-1); }
  #panel-left #panel-left-body { display: none; }
  .left-toggle { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; }
  .left-toggle svg { width: 18px; height: 18px; transform: rotate(-90deg); }
  #edit.left-open #panel-left { position: absolute; left: 0; top: 0; bottom: 0; width: var(--sb-left-w); z-index: 5; overflow-y: auto; padding: var(--sb-space-2) var(--sb-space-3) var(--sb-space-4); box-shadow: var(--sb-shadow-float); }
  #edit.left-open #panel-left #panel-left-body { display: block; }
  /* แผงซ้ายเป็น absolute (ออกจาก flow ของ grid) → ต้องระบุคอลัมน์ให้ viewer/แผงขวา ไม่งั้น auto-placement เลื่อนไปคอลัมน์ 40px */
  #edit.left-open #viewer-wrap { grid-column: 2; }
  #edit.left-open #panel-right { grid-column: 3; }
  #edit.left-open .left-toggle svg { transform: rotate(90deg); }
  /* viewer แคบ: ย้าย hint ขึ้นบนซ้าย ไม่ให้ซ้อนกับ legend มุมขวาล่าง */
  .viewer-hint { bottom: auto; top: var(--sb-space-3); max-width: calc(100% - 240px); }
}

/* ---------- แถบเตือนแท็บชนกัน (ไม่บล็อกหน้าจอ) ---------- */
.tab-conflict { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--sb-topbar-h) + 8px); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sb-space-2); max-width: min(640px, calc(100vw - 24px)); padding: var(--sb-space-2) var(--sb-space-3); background: var(--sb-surface); color: var(--sb-ink); border: 1px solid var(--sb-warn); border-left-width: 4px; border-radius: var(--sb-radius-l); box-shadow: var(--sb-shadow-float); font-size: var(--sb-text-s); }
.tab-conflict .msg { flex: 1 1 260px; }

/* ---------- ป้ายจับจุด / ความยาวเส้นตอนวาด ---------- */
.snap-label { position: absolute; z-index: 5; pointer-events: none; padding: 2px 6px; border-radius: var(--sb-radius-m); background: color-mix(in srgb, var(--sb-surface) 94%, transparent); border: 1px solid var(--sb-line); box-shadow: var(--sb-shadow-float); font-size: var(--sb-text-s); color: var(--sb-ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.snap-label[hidden] { display: none; }
.snap-label .snap-kind { display: block; font-weight: var(--sb-weight-strong); }
.snap-label .snap-kind.close { color: var(--sb-accent); }
.snap-label .snap-kind.site { color: var(--sb-site); }
.snap-label .snap-kind.building { color: var(--sb-warn); }

/* ---------- บริบทรอบที่ดิน (OSM) ---------- */
.ctx-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--sb-space-2) 0; }
.ctx-actions button { flex: 0 1 auto; }
.ctx-sub { margin: 0; font-size: var(--sb-text-xs); color: var(--sb-ink-3); }
.ctx-stats { white-space: pre-line; }
.ctx-switches { margin-top: var(--sb-space-2); }
.ctx-offset { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: end; }
.ctx-offset-title { grid-column: 1 / -1; color: var(--sb-ink-2); font-size: var(--sb-text-s); }
.ctx-offset label { display: flex; flex-direction: column; gap: 2px; }
.ctx-credit { overflow-wrap: anywhere; }
.ctx-import { margin: var(--sb-space-2) 0; padding: var(--sb-space-2) 0; border-top: 1px solid var(--sb-line); border-bottom: 1px solid var(--sb-line); }
.ctx-import-title { margin: 0 0 var(--sb-space-1); font-size: var(--sb-text-s); font-weight: 600; color: var(--sb-ink-2); }
.ctx-steps { margin: var(--sb-space-1) 0; padding-left: 1.4em; font-size: var(--sb-text-s); color: var(--sb-ink-2); }
.ctx-steps li { margin: 2px 0; }
.ctx-query { width: 100%; box-sizing: border-box; margin: var(--sb-space-1) 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: var(--sb-text-xs); color: var(--sb-ink); background: var(--sb-surface); border: 1px solid var(--sb-line); border-radius: var(--sb-radius-m); }
.osm-attrib-link { color: var(--sb-ink-2); text-decoration: underline; text-underline-offset: 2px; }
.osm-attrib-link:hover { color: var(--sb-accent); }
.viewer-attrib { position: absolute; right: 0; bottom: 0; z-index: 2; max-width: 100%; padding: 1px 8px; font-size: var(--sb-text-xs); line-height: 1.6; background: color-mix(in srgb, var(--sb-surface) 85%, transparent); border-top-left-radius: var(--sb-radius-m); }
#viewer-wrap:has(#viewer-attrib:not([hidden])) #viewer-legend { bottom: calc(var(--sb-space-3) + 22px); }
.compare-attrib { margin: 0 0 var(--sb-space-2); }

/* กล่องแจ้งก่อนส่งพิกัดออกภายนอก */
dialog.consent-dialog { max-width: min(520px, calc(100vw - 32px)); padding: var(--sb-space-4); color: var(--sb-ink); background: var(--sb-surface); border: 1px solid var(--sb-line); border-radius: var(--sb-radius-l); box-shadow: var(--sb-shadow-float); }
dialog.consent-dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog.consent-dialog h2 { margin: 0 0 var(--sb-space-2); font-size: var(--sb-text-l); }
dialog.consent-dialog p { margin: 0 0 var(--sb-space-2); }
.consent-actions { display: flex; justify-content: flex-end; gap: var(--sb-space-2); margin-top: var(--sb-space-3); }
