/* Site map (the map button in the top bar): sitemap.js draws it; site_map.py keeps it. */
.site-map-dialog { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--ink); overflow: hidden; }
.site-map-dialog[open] { display: flex; flex-direction: column; }
.site-map-dialog::backdrop { background: rgba(12,54,84,.45); }

.sm-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .7rem 1rem;
  background: var(--card); border-bottom: 1px solid var(--line); position: relative; padding-right: 3.2rem; }
.sm-head h2 { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 1.15rem; }
.sm-head h2 img { width: 1.6rem; height: 1.6rem; }
.sm-head select.sm-map-pick { width: auto; min-width: 12rem; max-width: 22rem; }
.sm-search { display: flex; align-items: center; gap: .5rem; flex: 1 1 18rem; max-width: 30rem; }
.sm-search .select-search { flex: 1; }
.sm-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.sm-close { position: absolute; top: .55rem; right: .7rem; }
.sm-note { margin: 0; padding: .45rem 1rem; background: #ecfdf3; color: #05603a; border-bottom: 1px solid #abefc6; font-size: .9rem; }
.sm-note.error { background: #fef3f2; color: #b42318; border-color: #fecdca; }

.sm-body { flex: 1; display: flex; min-height: 0; }
.sm-stage { flex: 1; position: relative; min-width: 0; }
.sm-svg { width: 100%; height: 100%; display: block; background: #e3e8ef; cursor: grab; touch-action: none; user-select: none; }
.sm-svg:active { cursor: grabbing; }
.sm-body.editing .sm-svg { cursor: default; }
.sm-body.editing .sm-svg.tool-draw { cursor: crosshair; }
.sm-paper { fill: #fff; }
.sm-border { fill: none; stroke: #98a2b3; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sm-grid-line { fill: none; stroke: #eaecf0; stroke-width: 1; vector-effect: non-scaling-stroke; }
.sm-grid-major { fill: none; stroke: #d0d5dd; stroke-width: 1; vector-effect: non-scaling-stroke; }

.sm-area-fill { fill-opacity: .22; stroke-width: 2; vector-effect: non-scaling-stroke; transition: fill-opacity .2s, stroke .2s; }
.sm-area-label { font-weight: 700; dominant-baseline: hanging; pointer-events: none; }
.sm-area.muted .sm-area-fill { fill: #d0d5dd; stroke: #b0b7c3; fill-opacity: .25; }
.sm-area.muted .sm-area-label { fill: #98a2b3; }
.sm-area.focused .sm-area-fill { fill-opacity: .38; stroke-width: 3.5; }
.sm-shape.faded, .sm-text.faded { opacity: .55; }
.sm-label { text-anchor: middle; dominant-baseline: central; fill: #344054; pointer-events: none; font-weight: 600; }
.sm-text { text-anchor: middle; dominant-baseline: central; font-weight: 700; pointer-events: none; }
.sm-hit { fill: transparent; }
.sm-pin { cursor: pointer; }
.sm-pin.muted { opacity: .28; }
.sm-pin-label { font-weight: 700; fill: #1f2933; paint-order: stroke; stroke: #fff; stroke-linejoin: round; pointer-events: none; }
.sm-pulse { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; animation: sm-pulse 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes sm-pulse { from { opacity: .9; transform: scale(.4); } to { opacity: 0; transform: scale(1.6); } }
@media (prefers-reduced-motion: reduce) { .sm-pulse { animation: none; opacity: .7; } }
.sm-body.editing .sm-item { cursor: move; }
.sm-select-box { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.sm-select-ring { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.sm-handle { fill: #fff; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sm-rotate { cursor: grab; }
.sm-draft { fill: rgba(74,79,201,.12); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }

.sm-view-bar { position: absolute; left: .8rem; bottom: .8rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem;
  padding: .35rem .6rem; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: .6rem;
  box-shadow: 0 4px 14px rgba(12,54,84,.12); font-size: .88rem; }
.sm-view-bar button { min-width: 2rem; height: 2rem; padding: 0 .5rem; border: 1px solid var(--line); border-radius: .4rem;
  background: #fff; font-size: 1.05rem; line-height: 1; cursor: pointer; }
.sm-view-bar button:hover { background: #f2f4f7; }
.sm-check { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; cursor: pointer; }
.sm-grid-size { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.sm-grid-size input { width: 4.5rem; padding: .25rem .4rem; }

.sm-tools { width: 9.8rem; flex: none; overflow-y: auto; padding: .6rem .5rem; background: var(--card); border-right: 1px solid var(--line); }
.sm-tools h4 { margin: .8rem .3rem .3rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sm-tool { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .32rem .45rem; margin-bottom: .15rem;
  border: 1px solid transparent; border-radius: .45rem; background: none; text-align: left; font-size: .86rem; color: var(--ink); cursor: pointer; }
.sm-tool:hover { background: #f2f4f7; }
.sm-tool.active { background: #eef0fd; border-color: #c7caf3; color: #2f33a0; font-weight: 600; }
.sm-tool-icon { width: 1.35rem; height: 1.35rem; flex: none; color: #475467; }

.sm-side { width: 19rem; flex: none; overflow-y: auto; padding: .9rem 1rem; background: var(--card); border-left: 1px solid var(--line); }
.sm-side h3 { margin: .2rem 0 .5rem; font-size: 1rem; }
.sm-side .link-button { display: block; margin: .25rem 0; }
.sm-help { font-size: .86rem; line-height: 1.4; }
.sm-danger { color: #b42318 !important; }
.sm-legend { list-style: none; margin: 0 0 .6rem; padding: 0; }
.sm-legend button { display: grid; grid-template-columns: auto 1fr; gap: 0 .5rem; align-items: center; width: 100%;
  padding: .4rem .45rem; border: 1px solid transparent; border-radius: .45rem; background: none; text-align: left; cursor: pointer; color: var(--ink); }
.sm-legend button:hover { background: #f2f4f7; }
.sm-legend button.active { border-color: var(--accent); background: #eef0fd; }
.sm-legend small { grid-column: 2; color: var(--muted); }
.sm-swatch { width: 1rem; height: 1rem; border-radius: .25rem; border: 1px solid rgba(0,0,0,.15); }
.sm-card { margin-bottom: 1rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .6rem; background: #f9fafb; }
.sm-card h3 { margin: 0; font-size: 1.1rem; }
.sm-card p { margin: .2rem 0; }
.sm-card ul { margin: .3rem 0 .4rem 1.1rem; padding: 0; font-size: .88rem; }
.sm-card-count { font-weight: 600; }
.sm-props label { display: block; margin-bottom: .55rem; font-size: .88rem; }
.sm-props input:not([type=checkbox]):not([type=color]), .sm-props select { width: 100%; box-sizing: border-box; }
.sm-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; }
.sm-color-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .4rem .6rem; margin-bottom: .4rem; }
.sm-color-row label { margin-bottom: 0; }
.sm-color-row input[type=color] { display: block; width: 3rem; height: 2rem; padding: 0; border: 1px solid var(--line); border-radius: .35rem; }
.sm-swatches { display: flex; flex-wrap: wrap; gap: .25rem; max-width: 12rem; }
.sm-swatches button { width: 1.25rem; height: 1.25rem; border: 1px solid rgba(0,0,0,.15); border-radius: .25rem; cursor: pointer; padding: 0; }
.sm-prop-buttons { display: flex; flex-wrap: wrap; gap: 0 .9rem; margin: .3rem 0 .8rem; }
.sm-prop-buttons .link-button { display: inline; }
.sm-done { width: 100%; }

.sm-foot { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; padding: .4rem 1rem; background: var(--card); border-top: 1px solid var(--line); font-size: .85rem; }
.sm-unsaved { color: #b54708; font-weight: 600; }
.sm-empty { margin: auto; max-width: 30rem; padding: 2rem 1rem; text-align: center; }
.sm-empty img { width: 4rem; height: 4rem; opacity: .7; }

@media (max-width: 900px) {
  .sm-body { flex-direction: column; }
  .sm-tools { width: auto; display: flex; flex-wrap: wrap; gap: .2rem; border-right: 0; border-bottom: 1px solid var(--line); max-height: 7.5rem; }
  .sm-tools h4 { width: 100%; margin: .3rem; }
  .sm-tool { width: auto; }
  .sm-tool span { display: none; }
  .sm-stage { min-height: 50vh; }
  .sm-side { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
}
.sm-field-label { margin: 0 0 .3rem; font-size: .88rem; font-weight: 600; }
.sm-chips { list-style: none; margin: 0 0 .55rem; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.sm-chips li { display: grid; gap: .3rem; padding: .35rem .45rem; border: 1px solid var(--line); border-radius: .45rem;
  background: #f9fafb; font-size: .86rem; }
.sm-chip-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .45rem; min-width: 0; }
.sm-chips li input { width: 100%; box-sizing: border-box; padding: .3rem .45rem; font-size: .85rem; }
.sm-chips li.muted { display: block; border-style: dashed; background: none; }
.sm-chip-head span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-chips button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 .2rem; font-size: .9rem; }
.sm-chips button:hover { color: #b42318; }
.sm-detail { font-style: italic; }
.sm-card-loc { margin-top: .55rem; padding-top: .45rem; border-top: 1px solid var(--line); }
.sm-card-loc p { margin: .1rem 0; }
.sm-change { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem 1rem; padding: .5rem 1rem;
  background: #eef4ff; border-bottom: 1px solid #c7d7fe; font-size: .92rem; }
.sm-change p { margin: 0; }
.sm-change small { color: var(--muted); margin-left: .3rem; }
.sm-change-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; width: 100%; }
.sm-change-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.sm-change-legend span::before { content: ""; width: .9rem; height: .9rem; border-radius: .2rem; border: 2.5px solid; }
.sm-change-legend .sm-added-key::before { border-color: #12b76a; }
.sm-change-legend .sm-changed-key::before { border-color: #f79009; }
.sm-change-legend .sm-removed-key::before { border-color: #98a2b3; border-style: dashed !important; }
.sm-change-mark { fill: none; stroke-width: 3; stroke-dasharray: 7 4; vector-effect: non-scaling-stroke; pointer-events: none;
  animation: sm-march 1.2s linear infinite; }
.sm-change-mark.sm-added { stroke: #12b76a; }
.sm-change-mark.sm-changed { stroke: #f79009; }
@keyframes sm-march { to { stroke-dashoffset: -22; } }
@media (prefers-reduced-motion: reduce) { .sm-change-mark { animation: none; } }
.sm-change-list { margin: 0 0 .8rem 1.1rem; padding: 0; }
.sm-sign-summary p { margin: .2rem 0 .6rem; font-weight: 600; }
.sm-head .sm-search { flex: 1 1 34rem; max-width: 40rem; }
.sm-head .sm-search .loc-pair.filter { width: 100%; }
.sm-safety { cursor: pointer; }
.sm-body.editing .sm-safety { cursor: move; }
.sm-safety.faded { opacity: .6; }
.sm-safety-label { text-anchor: middle; dominant-baseline: hanging; font-weight: 700; fill: #1f2933; paint-order: stroke;
  stroke: #fff; stroke-linejoin: round; pointer-events: none; }
.sm-layers { margin: 0 0 1rem; border: 1px solid var(--line); border-radius: .6rem; background: #f9fafb; }
.sm-layers summary { display: flex; align-items: baseline; gap: .5rem; padding: .5rem .7rem; font-weight: 700; cursor: pointer; }
.sm-layers summary small { color: #b54708; font-weight: 600; }
.sm-layer-list { padding: 0 .7rem .6rem; }
.sm-layer { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: .45rem; padding: .18rem 0; margin: 0;
  font-size: .88rem; cursor: pointer; }
.sm-layer:not(:has(.sm-layer-icon)) { grid-template-columns: auto 1fr auto; }
.sm-layer small { color: var(--muted); font-variant-numeric: tabular-nums; }
.sm-layer.empty { color: var(--muted); }
.sm-layer-icon { width: 1.15rem; height: 1.15rem; }
.sm-layer-head { display: flex; align-items: baseline; justify-content: space-between; margin: .55rem 0 .15rem;
  padding-top: .45rem; border-top: 1px solid var(--line); font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); }
.sm-layer-head .link-button { text-transform: none; letter-spacing: 0; font-size: .82rem; display: inline; margin: 0; }
.sm-new-tab { padding: .35rem .7rem; border: 1px solid var(--line); border-radius: .45rem; background: #fff;
  color: var(--accent); font-weight: 600; cursor: pointer; white-space: nowrap; }
.sm-new-tab:hover { border-color: var(--accent); }
.sm-actions .link-button { white-space: nowrap; }
