/* Site Planner v2 – loaded after styles.css, scoped to .sp2 */
.sp2 { --brand: #58afca; --brand-dark: #3f7889; --accent: #e7a83b; --danger: #a83c3c;
  display: grid; grid-template-columns: 300px minmax(0, 1fr) 310px; grid-template-areas: "steps steps steps" "left work right";
  min-height: 0; background: #edf5f7; }
.sp2 button { font: inherit; }
.sp2 .sp-visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; border: 0 !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }

/* Steps */
.sp2 .sp-steps { grid-area: steps; margin: 0; padding: 0; list-style: none; }
.sp2 .sp-steps li { border-right: 1px solid var(--line); }
.sp2 .sp-steps li:last-child { border-right: 0; }
.sp2 .sp-steps button { display: grid; grid-template-columns: 32px 1fr; gap: 1px 10px; width: 100%; padding: 12px 18px; border: 0; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.sp2 .sp-steps button:hover { background: #f4fafb; }
.sp2 .sp-steps span { grid-row: 1 / 3; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #e7f1f4; color: var(--brand-dark); font-weight: 900; }
.sp2 .sp-steps strong { color: var(--ink); font-size: 14px; }
.sp2 .sp-steps small { font-size: 12px; line-height: 1.3; }
.sp2 .sp-steps li.active span { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px rgba(88,175,202,.2); }
.sp2 .sp-steps li.complete span { background: #4b9d68; color: #fff; }
.sp2 .sp-steps li.complete span::after { content: "✓"; position: absolute; }
.sp2 .sp-steps li.complete span { position: relative; color: transparent; }
.sp2 .sp-steps li.complete span::after { color: #fff; }

/* Sidebars */
.sp2 .sp-left { grid-area: left; }
.sp2 .sp-right { grid-area: right; border-right: 0; border-left: 1px solid var(--line); }
.sp2 .planner-sidebar { padding: 14px; gap: 12px; max-height: calc(100vh - var(--sp-top, 80px) - 8px); overflow: auto; position: sticky; top: var(--sp-top, 80px); align-self: start; }
.sp2 .planner-panel { gap: 10px; padding: 14px; }
.sp2 .planner-panel h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.sp2 .planner-panel input[type="range"] { padding: 0; border: 0; accent-color: var(--brand-dark); }
.sp2 .planner-panel input[type="checkbox"] { accent-color: var(--brand-dark); }
.sp2 .sp-hint { font-size: 13px; }
.sp2 .sp-sub { color: var(--ink); font-size: 13px; }
.sp2 .sp-badge { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 11px; background: #e7f1f4; color: var(--brand-dark); font-size: 12px; }
.sp2 .sp-link { padding: 0; border: 0; background: none; color: var(--brand-dark); font-weight: 800; font-size: 13px; text-decoration: underline; cursor: pointer; justify-self: start; }
.sp2 .sp-drop { display: grid; gap: 6px; padding: 12px; border: 1px dashed var(--brand); border-radius: 8px; background: #f5fbfc; }
.sp2 .sp-drop small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.sp2 .sp-upload-btn, .sp2 .sp-open-btn { cursor: pointer; }
.sp2 .planner-panel label.button { display: inline-flex; color: #fff; font-size: 12px; }
.sp2 .planner-panel label.button.secondary { color: var(--brand-dark); }
.sp2 .sp-scale summary, .sp2 .sp-details summary { cursor: pointer; color: var(--brand-dark); font-size: 13px; font-weight: 900; }
.sp2 .sp-scale summary span { color: var(--muted); font-weight: 600; }
.sp2 .sp-scale[open], .sp2 .sp-details[open] { display: grid; gap: 8px; }
.sp2 .sp-file-actions .button { flex: 1 1 auto; }
.sp2 .sp-save-status { margin: 0; color: var(--muted); font-size: 12px; }
.sp2 .sp-save-status[data-kind="ok"]::before { content: "✓ "; color: #4b9d68; font-weight: 900; }
.sp2 .sp-save-status[data-kind="warn"] { color: #8a4b1c; font-weight: 700; }
.sp2 .sp-search input { padding: 9px 11px; }
.sp2 .planner-filters { gap: 6px; }
.sp2 .planner-filters button { padding: 6px 10px; font-size: 12px; }
.sp2 .planner-filters button.active, .sp2 .sp-products button.active { border-color: var(--brand); background: #e7f5f8; box-shadow: inset 0 0 0 1px var(--brand); }
.sp2 .sp-products { max-height: 46vh; min-height: 180px; }
.sp2 .sp-products button { grid-template-columns: 52px 1fr; grid-template-rows: auto auto auto; gap: 1px 10px; min-height: 56px; padding: 8px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.sp2 .sp-products button:hover { border-color: var(--brand); }
.sp2 .sp-products img { grid-row: 1 / 4; width: 50px; height: 44px; }
.sp2 .sp-products span { font-size: 10px; }
.sp2 .sp-products em { grid-column: 2; }
.sp2 .sp-products button.active::after { content: "Placing – click the plan"; grid-column: 2; color: #2c7c48; font-size: 11px; font-weight: 800; }

/* Selected item panel */
.sp2 [data-selected-panel] { border-color: var(--brand); box-shadow: 0 0 0 1px rgba(88,175,202,.25); }
.sp2 .sp-selected-head { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; }
.sp2 .sp-selected-head img { width: 54px; height: 46px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.sp2 .sp-selected-head div { display: grid; }
.sp2 .sp-selected-head strong { font-size: 14px; }
.sp2 .sp-selected-head span { color: var(--brand-dark); font-weight: 800; font-size: 13px; }
.sp2 .sp-row { display: grid; grid-template-columns: 1fr 84px; gap: 8px; align-items: end; }
.sp2 .sp-num input { padding: 7px 8px; }
.sp2 .sp-btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
.sp2 .sp-danger { color: var(--danger) !important; }
.sp2 .sp-ok { color: #2c7c48 !important; font-weight: 700; }

/* Item list */
.sp2 .sp-item-list { display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.sp2 .sp-item-list button { display: grid; grid-template-columns: 34px 74px 1fr; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid transparent; border-radius: 6px; background: #f7fbfc; color: var(--ink); text-align: left; cursor: pointer; font-size: 13px; }
.sp2 .sp-item-list button:hover { border-color: var(--line); }
.sp2 .sp-item-list button.active { border-color: var(--accent); background: #fff8ea; }
.sp2 .sp-item-list i { display: grid; place-items: center; height: 20px; border-radius: 10px; background: rgb(var(--rgb)); color: #fff; font-style: normal; font-size: 9px; font-weight: 900; }
.sp2 .sp-item-list span { overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.sp2 .sp-send-steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }

/* Workspace */
.sp2 .sp-workspace { grid-area: work; display: flex; flex-direction: column; min-width: 0; position: sticky; top: var(--sp-top, 80px); align-self: start; height: calc(100vh - var(--sp-top, 80px) - 8px); min-height: 560px; }
.sp2 .sp-toolbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; user-select: none; -webkit-user-select: none; }
.sp2 .sp-toolbar-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sp2 .sp-exports { display: flex; gap: 6px; flex-wrap: wrap; }
.sp2 .sp-title { display: grid; gap: 0; min-width: 140px; }
.sp2 .sp-title strong { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sp2 .sp-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sp2 .sp-group { display: flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #f7fbfc; }
.sp2 .sp-tool { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; min-width: 46px; padding: 4px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 10px; font-weight: 800; cursor: pointer; }
.sp2 .sp-tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sp2 .sp-tool:hover:not(:disabled) { background: #e7f1f4; }
.sp2 .sp-tool[aria-pressed="true"] { background: var(--brand-dark); color: #fff; }
.sp2 .sp-tool:disabled { opacity: .35; cursor: not-allowed; }
.sp2 .sp-size { display: flex; align-items: center; gap: 4px; padding: 0 6px; color: var(--muted); font-size: 10px; font-weight: 800; }
.sp2 .sp-size input { width: 70px; accent-color: var(--brand-dark); }
.sp2 .sp-placing { position: absolute; z-index: 5; left: 50%; top: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 20px); padding: 6px 6px 6px 12px; border: 1px solid #f0d9a8; border-radius: 8px; background: #fff8ea; color: #6b4b12; font-size: 13px; line-height: 1.3; box-shadow: 0 4px 14px rgba(20,48,57,.14); }
.sp2 .sp-placing[hidden] { display: none; }
.sp2 .sp-stage { flex: 1; min-height: 0; margin: 12px; cursor: default; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; background: #e9f1f3; }
.sp2 .sp-stage:focus-visible { box-shadow: 0 0 0 3px rgba(88,175,202,.45); }
.sp2 .sp-stage[data-tool="place"], .sp2 .sp-stage[data-tool="measure"] { cursor: crosshair; }
.sp2 .sp-stage[data-tool="pan"] { cursor: grab; }
.sp2 .sp-stage.sp-drop-target { box-shadow: inset 0 0 0 3px var(--brand); }
.sp2 .sp-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 4px 24px rgba(20,48,57,.14); background: #fff; }
.sp2 .sp-world > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: fill; background: #fff; pointer-events: none; }
.sp2 .sp-world > img.is-hidden { display: none; }
.sp2 .sp-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sp2 .sp-hit { cursor: move; }
.sp2 .sp-handle { cursor: grab; }
.sp2 .planner-empty { z-index: 3; pointer-events: none; }
.sp2 .planner-empty label { pointer-events: auto; justify-self: center; margin-top: 6px; cursor: pointer; }
.sp2 .sp-drop-hint { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(88,175,202,.18); color: var(--ink); font-size: 20px; font-weight: 900; pointer-events: none; }
.sp2 .sp-drop-hint[hidden] { display: none; }
.sp2 .sp-zoom { position: absolute; right: 10px; bottom: 10px; z-index: 4; display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.95); box-shadow: 0 4px 14px rgba(20,48,57,.12); }
.sp2 .sp-zoom button { min-width: 34px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-weight: 900; font-size: 16px; cursor: pointer; }
.sp2 .sp-zoom button:hover { background: #e7f1f4; }
.sp2 .sp-zoom span { min-width: 46px; color: var(--muted); font-size: 12px; text-align: center; }
.sp2 .sp-help { position: absolute; left: 10px; bottom: 10px; z-index: 4; max-width: calc(100% - 260px); padding: 5px 9px; border-radius: 6px; background: rgba(255,255,255,.9); color: var(--muted); font-size: 11px; line-height: 1.35; }
.sp2 .sp-help .sp-link { font-size: 11px; }

.sp-ghost { position: fixed; z-index: 1000; display: grid; place-items: center; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 3px solid #fff; border-radius: 50%; background: rgb(var(--rgb)); color: #fff; font: 900 9px Arial, sans-serif; box-shadow: 0 6px 18px rgba(0,0,0,.28); pointer-events: none; }
.sp-toast { position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: min(560px, calc(100vw - 24px)); padding: 11px 16px; border-radius: 8px; background: #203f4a; color: #fff; font-size: 14px; box-shadow: 0 12px 32px rgba(15,38,45,.3); }
.sp-toast[hidden] { display: none; }
.sp-toast[data-kind="warn"] { background: #7a4512; }
.sp-toast button { flex: none; padding: 5px 10px; border: 1px solid rgba(255,255,255,.5); border-radius: 6px; background: transparent; color: #fff; font-weight: 800; cursor: pointer; }
.sp-dialog { max-width: 520px; border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; color: var(--ink); }
.sp-dialog::backdrop { background: rgba(20,48,57,.4); }
.sp-dialog h2 { margin: 0 0 10px; }
.sp-dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 16px; font-size: 14px; }
.sp-dialog dt { font-weight: 800; }
.sp-dialog dd { margin: 0; color: var(--muted); }

/* Medium screens: 2 columns, right panel moves under the canvas */
@media (max-width: 1360px) {
  .sp2 { grid-template-columns: 300px minmax(0, 1fr); grid-template-areas: "steps steps" "left work" "right right"; }
  .sp2 .sp-right { position: static; max-height: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); border-left: 0; border-top: 1px solid var(--line); }
}

/* Phones / small tablets */
@media (max-width: 880px) {
  .sp2 { grid-template-columns: 1fr; grid-template-areas: "steps" "work" "left" "right"; }
  .sp2 .sp-steps { position: static; grid-template-columns: repeat(4, 1fr); }
  .sp2 .sp-steps button { grid-template-columns: 1fr; justify-items: center; padding: 8px 4px; text-align: center; }
  .sp2 .sp-steps span { grid-row: auto; width: 26px; height: 26px; }
  .sp2 .sp-steps strong { font-size: 11px; line-height: 1.2; }
  .sp2 .sp-steps small { display: none; }
  .sp2 .planner-sidebar { position: static; max-height: none; overflow: visible; }
  .sp2 .sp-workspace { position: relative; top: 0; height: 78vh; min-height: 460px; }
  .sp2 .sp-stage { margin: 6px; min-height: 0; }
  .sp2 .sp-toolbar { padding: 8px; flex-direction: row; align-items: center; }
  .sp2 .sp-title strong { max-width: 150px; font-size: 14px; }
  .sp2 .sp-placing { top: 6px; font-size: 12px; }
  .sp2 .sp-tools { gap: 4px; }
  .sp2 .sp-tool { min-width: 40px; padding: 4px; }
  .sp2 .sp-tool span { display: none; }
  .sp2 .sp-size { display: none; }
  .sp2 .sp-exports .button { min-height: 32px; padding: 0 8px; font-size: 11px; }
  .sp2 .sp-help { display: none; }
  .sp2 .sp-products { max-height: none; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 70%); overflow-x: auto; overflow-y: hidden; min-height: 0; padding-bottom: 6px; scroll-snap-type: x proximity; }
  .sp2 .sp-products button { scroll-snap-align: start; touch-action: pan-x; }
  .sp2 .sp-right { grid-template-columns: 1fr; }
  .sp-toast { bottom: 84px; }
}

@media print {
  .sp2 .sp-steps, .sp2 .sp-toolbar, .sp2 .sp-zoom, .sp2 .sp-help, .sp2 .sp-placing { display: none !important; }
  .sp2 .sp-workspace { position: static; height: 80vh; }
}

/* Override generic .planner-toolbar rules from styles.css */
.sp2 .sp-toolbar .sp-toolbar-top { display: flex; }
.sp2 .sp-toolbar .sp-title { display: grid; gap: 0; }
.sp2 .sp-toolbar .sp-group { display: flex; }
.sp2 .sp-toolbar .sp-tool span { color: inherit; font-size: 10px; }
.sp2 .sp-toolbar .sp-title span { font-size: 12px; }
.sp2 .sp-help[hidden] { display: none; }
@media (max-width: 880px) {
  .sp2 .sp-workspace { height: auto; min-height: 0; }
  .sp2 .sp-stage { flex: none; height: min(64vh, 118vw); }
  .sp2 .sp-toolbar-top { flex-wrap: wrap; }
  .sp2 .sp-toolbar .sp-size { display: flex; padding: 0 4px; }
  .sp2 .sp-toolbar .sp-size input { width: 56px; }
  .sp2 .sp-zoom button { min-width: 40px; height: 36px; }
}

/* styles.css gives every <section> vertical padding; the planner sections need none */
section.sp2, .sp2 section.sp-workspace { padding: 0; }
.sp2 { align-content: start; }

/* Finish step */
.sp2 .sp-finish { border-color: var(--brand); }
.sp2 .sp-finish-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp2 .sp-big { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 58px; padding: 8px; font-size: 14px; line-height: 1.2; text-align: center; cursor: pointer; }
.sp2 .sp-big small { font-size: 11px; font-weight: 600; opacity: .85; }
.sp2 .sp-quote-form { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f7fbfc; }
.sp2 .sp-quote-form[hidden] { display: none; }
.sp2 .sp-quote-form h3 { margin: 0; color: var(--ink); font-size: 15px; }
.sp2 .sp-quote-form [aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(168,60,60,.15); }
.sp2 .sp-hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.sp2 .sp-small { font-size: 12px; }
.sp2 .sp-result { display: grid; gap: 6px; padding: 12px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
.sp2 .sp-result[hidden] { display: none; }
.sp2 .sp-result[data-kind="ok"] { border: 1px solid #a8d2b1; background: #f2faf4; color: #1f5a33; }
.sp2 .sp-result[data-kind="error"] { border: 1px solid #e6c19a; background: #fff6ec; color: #7a4512; }
.sp2 .sp-result b[data-ref] { font-size: 15px; letter-spacing: .02em; user-select: all; }
.sp2 .sp-fallback[open] .sp-send-steps { margin-top: 4px; }
@media (max-width: 1360px) and (min-width: 881px) { .sp2 .sp-finish-actions { grid-template-columns: 1fr; } }

/* ---- v3: levels, element library, attributes, photos, cables, layers, map ---- */
.sp2 .sp-ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sp2 .sp-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp2 textarea[data-edit-note] { resize: vertical; min-height: 52px; }
/* levels */
.sp2 .sp-levels-box { display: grid; gap: 6px; }
.sp2 .sp-level-list { display: grid; gap: 4px; }
.sp2 .sp-level-row { display: grid; grid-template-columns: 26px 1fr auto 24px; gap: 6px; align-items: center; padding: 3px; border: 1px solid transparent; border-radius: 6px; }
.sp2 .sp-level-row.active { border-color: var(--brand); background: #f1f9fb; }
.sp2 .sp-level-row input { padding: 5px 7px; font-size: 13px; }
.sp2 .sp-level-row span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.sp2 .sp-level-go, .sp2 .sp-level-del { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); font-size: 12px; font-weight: 900; cursor: pointer; }
.sp2 .sp-level-row.active .sp-level-go { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.sp2 .sp-level-del { border: 0; background: transparent; color: var(--muted); font-size: 18px; }
.sp2 .sp-level-del:hover:not(:disabled) { color: var(--danger); }
.sp2 .sp-level-del:disabled { opacity: .3; cursor: default; }
.sp2 .sp-level-tabs { display: flex; flex: 1; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.sp2 .sp-level-tabs button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px 8px 0 0; background: #f7fbfc; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.sp2 .sp-level-tabs button[aria-selected="true"] { border-color: var(--brand); background: #fff; color: var(--ink); box-shadow: inset 0 -3px 0 var(--brand); }
.sp2 .sp-level-tabs small { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #e7f1f4; color: var(--brand-dark); font-size: 10px; }
.sp2 .sp-level-tabs .sp-level-add { border-style: dashed; color: var(--brand-dark); }
.sp2 .sp-bg-actions { display: flex; flex-wrap: wrap; gap: 6px; }
/* element library */
.sp2 .sp-cat { display: flex; align-items: center; gap: 7px; margin: 8px 0 2px; color: var(--ink); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; }
.sp2 .sp-cat:first-child { margin-top: 0; }
.sp2 .sp-cat i { width: 10px; height: 10px; border-radius: 3px; background: rgb(var(--rgb)); }
.sp2 .sp-cat small { color: var(--muted); font-weight: 700; }
.sp2 .sp-products button { position: relative; }
.sp2 .sp-tile { grid-row: 1 / 4; display: grid; place-items: center; width: 50px; height: 44px; border-radius: 8px; background: rgb(var(--rgb)); color: #fff; }
.sp2 .sp-tile .sp-ico { width: 26px; height: 26px; }
.sp2 .sp-badge-ico { position: absolute; left: 40px; top: 36px; display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; background: rgb(var(--rgb)); color: #fff; }
.sp2 .sp-badge-ico .sp-ico { width: 13px; height: 13px; stroke-width: 2.4; }
.sp2 .sp-more-filters summary { font-size: 12px; }
.sp2 .sp-selected-head .sp-tile { width: 54px; height: 46px; }
/* attributes + photos */
.sp2 .sp-attrs { display: grid; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdfe; }
.sp2 .sp-attrs[open] { gap: 8px; }
.sp2 .sp-photos { display: grid; gap: 6px; }
.sp2 .sp-photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sp2 .sp-photo-grid figure { position: relative; margin: 0; }
.sp2 .sp-photo-grid figure > button:first-child { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; cursor: zoom-in; }
.sp2 .sp-photo-grid img { display: block; width: 100%; height: 62px; object-fit: cover; }
.sp2 .sp-photo-del { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 900; line-height: 1; cursor: pointer; }
.sp2 .sp-photo-add { display: grid; place-items: center; align-content: center; height: 64px; border: 1px dashed var(--brand); border-radius: 6px; background: #f5fbfc; color: var(--brand-dark); font-size: 11px; font-weight: 800; cursor: pointer; }
.sp2 .sp-photo-add span { font-size: 20px; line-height: 1; }
/* cable runs */
.sp2 .sp-runs { display: grid; gap: 4px; }
.sp2 .sp-run { display: grid; grid-template-columns: 14px 1fr; gap: 0 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); text-align: left; font-size: 13px; font-weight: 800; cursor: pointer; }
.sp2 .sp-run i { grid-row: 1 / 3; width: 14px; height: 4px; border-radius: 2px; background: rgb(var(--rgb)); }
.sp2 .sp-run span { color: var(--muted); font-size: 11px; font-weight: 600; }
.sp2 .sp-cable-hit { cursor: pointer; }
.sp2 .sp-stage[data-tool="cable"] { cursor: crosshair; }
.sp2 .sp-stage[data-tool="cable"] .sp-hit { cursor: pointer; }
/* element list + layers */
.sp2 .sp-layers { display: flex; flex-wrap: wrap; gap: 4px; }
.sp2 .sp-layers:empty { display: none; }
.sp2 .sp-layers button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-size: 11px; font-weight: 800; cursor: pointer; }
.sp2 .sp-layers button i { width: 9px; height: 9px; border-radius: 50%; background: rgb(var(--rgb)); }
.sp2 .sp-layers button[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; opacity: .65; }
.sp2 .sp-layers button[aria-pressed="false"] i { background: transparent; box-shadow: inset 0 0 0 2px rgb(var(--rgb)); }
.sp2 .sp-layers small { color: var(--muted); }
.sp2 .sp-item-list { max-height: 340px; }
.sp2 .sp-item-list .sp-cat { margin: 6px 0 0; font-size: 11px; }
.sp2 .sp-item-list button { grid-template-columns: 26px 64px 1fr auto; }
.sp2 .sp-item-list button i { width: 24px; height: 24px; border-radius: 50%; }
.sp2 .sp-item-list button i .sp-ico { width: 14px; height: 14px; stroke-width: 2.4; }
.sp2 .sp-item-list button.is-off { opacity: .5; }
.sp2 .sp-item-list em { padding: 1px 6px; border-radius: 8px; background: #eef2f3; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 800; white-space: nowrap; }
.sp2 .sp-item-list em[data-status="remove"] { background: #fbe5e2; color: #a5321f; }
.sp2 .sp-item-list em[data-status="relocate"] { background: #fdf1dc; color: #7a4f0a; }
.sp-ghost .sp-ico, .sp-ghost svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* map dialog */
.sp-map-dialog { width: min(1040px, calc(100vw - 24px)); max-width: none; padding: 16px 18px; }
.sp-map-head { display: flex; align-items: center; justify-content: space-between; }
.sp-map-head h2 { margin: 0; font-size: 19px; }
.sp-x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eef5f7; color: var(--ink); font-size: 22px; cursor: pointer; }
.sp-map-search { display: flex; gap: 8px; margin: 12px 0 6px; }
.sp-map-search input { flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.sp-map-results { display: grid; gap: 3px; max-height: 120px; overflow: auto; margin-bottom: 6px; }
.sp-map-results:empty { display: none; }
.sp-map-results button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); text-align: left; font-size: 12px; cursor: pointer; }
.sp-map-results button.active { border-color: var(--brand, #58afca); background: #eef8fb; }
.sp-map-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0; color: var(--muted); font-size: 13px; }
.sp-seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #f7fbfc; }
.sp-seg button { min-width: 34px; padding: 5px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-weight: 800; cursor: pointer; }
.sp-seg button[aria-pressed="true"] { background: #3f7889; color: #fff; }
.sp-map-canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; border: 1px solid var(--line); border-radius: 8px; background: #dfe7ea; cursor: grab; touch-action: none; }
.sp-map-canvas[hidden] { display: none; }
.sp-map-status { min-height: 1.3em; margin: 6px 0; font-size: 13px; color: var(--muted); }
.sp-map-status[data-kind="warn"] { color: #8a4b1c; font-weight: 700; }
.sp-map-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.sp-photo-dialog { max-width: min(980px, calc(100vw - 24px)); }
.sp-photo-dialog img { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 6px; }
.sp-photo-dialog p { color: var(--ink); font-size: 14px; }
@media (max-width: 880px) {
  .sp2 .sp-level-tabs { order: 3; flex-basis: 100%; }
  .sp2 .sp-row2 { grid-template-columns: 1fr; }
}
.sp-map-dialog { max-height: calc(100vh - 24px); overflow: auto; }
.sp-map-canvas { width: auto; max-width: 100%; max-height: calc(100vh - 330px); min-height: 220px; margin: 0 auto; }
/* the photo picker lives outside .sp2 (next to the dialogs) */
input[data-photo-input] { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; pointer-events: none; }

/* ===== v4: simple mode, natural page scrolling, photo markers ===== */
/* Simple (default) vs Advanced tools */
.sp2:not(.sp-pro) [data-pro-only] { display: none !important; }
.sp2.sp-pro [data-simple-only] { display: none !important; }
.sp2 .sp-steps { display: grid; grid-template-columns: repeat(3, 1fr); }
.sp2 .sp-pro-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px 0 8px; border: 1px solid var(--line); border-radius: 17px; background: #fff; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.sp2 .sp-pro-toggle i { position: relative; width: 30px; height: 18px; border-radius: 9px; background: #c9d6db; transition: background .15s; }
.sp2 .sp-pro-toggle i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.sp2 .sp-pro-toggle[aria-pressed="true"] { border-color: var(--brand); color: var(--brand-dark); }
.sp2 .sp-pro-toggle[aria-pressed="true"] i { background: var(--brand-dark); }
.sp2 .sp-pro-toggle[aria-pressed="true"] i::after { transform: translateX(12px); }

/* No nested scroll panes: the page scrolls wherever the pointer is. Only the plan stays in view. */
.sp2 .planner-sidebar { position: static; max-height: none; overflow: visible; }
.sp2 .sp-products { max-height: none; min-height: 0; overflow: visible; }
.sp2 .sp-item-list { max-height: none; overflow: visible; }
.sp2 .sp-stage { touch-action: pan-y; }
.sp2 .sp-stage.is-active, .sp2 .sp-stage[data-tool="place"], .sp2 .sp-stage[data-tool="measure"] { touch-action: none; }
.sp2 .sp-wheel-hint { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 10px 16px; border-radius: 8px; background: rgba(32,63,74,.88); color: #fff; font-size: 14px; font-weight: 700; pointer-events: none; }
.sp2 .sp-wheel-hint[hidden] { display: none; }
.sp2 .sp-wheel-hint kbd { padding: 1px 6px; border: 1px solid rgba(255,255,255,.6); border-radius: 4px; font: inherit; }

/* Friendly empty state */
.sp2 .planner-empty .sp-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; pointer-events: auto; }
.sp2 .planner-empty .sp-empty-actions .button { cursor: pointer; }
.sp2 .planner-empty small { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Simple picker: big photo cards, two per row */
.sp2:not(.sp-pro) .sp-products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sp2:not(.sp-pro) .sp-products > h3, .sp2:not(.sp-pro) .sp-products > p { grid-column: 1 / -1; }
.sp2:not(.sp-pro) .sp-products button { display: grid; grid-template-columns: 1fr; grid-template-rows: auto; justify-items: center; align-content: start; gap: 4px; min-height: 0; padding: 10px 8px; text-align: center; cursor: pointer; }
.sp2:not(.sp-pro) .sp-products button img, .sp2:not(.sp-pro) .sp-products button .sp-tile { grid-row: auto; width: 100%; height: 82px; object-fit: contain; }
.sp2:not(.sp-pro) .sp-products .sp-badge-ico, .sp2:not(.sp-pro) .sp-products button > span { display: none; }
.sp2:not(.sp-pro) .sp-products strong { font-size: 13px; line-height: 1.25; }
.sp2:not(.sp-pro) .sp-products em { grid-column: auto; font-size: 12px; }
.sp2:not(.sp-pro) .sp-products button.active::after { grid-column: auto; content: "Now click the plan"; }
.sp2:not(.sp-pro) .planner-filters button { padding: 8px 12px; font-size: 13px; }
.sp2:not(.sp-pro) .sp-bg-actions .button { min-height: 42px; font-size: 14px; }
.sp2:not(.sp-pro) .sp-tool { min-width: 58px; padding: 6px 8px; font-size: 11px; }
.sp2:not(.sp-pro) .sp-tool svg { width: 20px; height: 20px; }
.sp2 .sp-finish-actions .sp-big:first-child { order: -1; }

/* Element list with product photos */
.sp2 .sp-item-list button { grid-template-columns: 34px 64px 1fr auto; }
.sp2 .sp-item-list .sp-li-thumb { width: 32px; height: 32px; border: 2px solid rgb(var(--rgb)); border-radius: 50%; background: #fff; object-fit: cover; }
.sp2 .sp-item-list .sp-li-thumb.sq { border-radius: 8px; }

/* Zoom (varifocal / PTZ) */
.sp2 .sp-zoom-val { align-self: end; min-width: 52px; padding-bottom: 6px; color: var(--ink); font-weight: 800; font-size: 13px; text-align: right; }
.sp2 .sp-zoom-ends { display: flex; justify-content: space-between; margin-top: -6px; color: var(--muted); font-size: 11px; }
.sp2 .sp-spec-line { font-size: 12px; }

@media (max-width: 880px) {
  .sp2 .sp-steps { grid-template-columns: repeat(3, 1fr); }
  .sp2 .sp-products button { touch-action: pan-x pan-y; }
  .sp2.sp-pro .sp-products { overflow-x: auto; overflow-y: hidden; }
  .sp2:not(.sp-pro) .sp-products { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-columns: auto; overflow: visible; scroll-snap-type: none; }
  .sp2:not(.sp-pro) .sp-products button { touch-action: manipulation; }
  .sp2 .sp-pro-toggle { min-height: 30px; padding: 0 8px 0 6px; font-size: 11px; }
  .sp2 .sp-toolbar-top { flex-wrap: wrap; }
}
@media (pointer: coarse) {
  .sp2 .sp-stage:not(.is-active):not([data-tool="place"])::after { content: "Tap the plan to edit it"; position: absolute; z-index: 4; left: 50%; top: 8px; transform: translateX(-50%); padding: 4px 10px; border-radius: 12px; background: rgba(255,255,255,.92); color: var(--muted); font-size: 12px; font-weight: 700; pointer-events: none; }
}
