:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fffefb;
  --surface-2: #f1eee6;
  --surface-3: #e9e5da;
  --ink: #1d2420;
  --ink-2: #4f5751;
  --ink-3: #868b84;
  --line: #e5e1d7;
  --line-strong: #cec8b9;
  --accent: #2f6a4f;
  --accent-hover: #285b44;
  --accent-ink: #ffffff;
  --accent-soft: #e3eee7;
  --sun: #e39b2d;
  --sun-soft: #fbefd9;
  --glass: #4f93d1;
  --wall: #26302b;
  --floor: #fbfaf6;
  --good: #2f7d32;
  --ok: #9a6a00;
  --poor: #b4443a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(40, 36, 20, 0.05), 0 10px 30px rgba(40, 36, 20, 0.07);
  --shadow-sm: 0 1px 2px rgba(40, 36, 20, 0.08);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --panel-w: 400px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111412;
    --surface: #181c19;
    --surface-2: #20251f;
    --surface-3: #2a302a;
    --ink: #eef0ea;
    --ink-2: #b7bdb4;
    --ink-3: #848b82;
    --line: #2a302b;
    --line-strong: #3d453e;
    --accent: #79c19c;
    --accent-hover: #8fd0ae;
    --accent-ink: #0d1912;
    --accent-soft: #1d3127;
    --sun: #f0b350;
    --sun-soft: #3a2f1c;
    --glass: #7db5e8;
    --wall: #e6e9e2;
    --floor: #1e231f;
    --good: #6cc070;
    --ok: #e0b04a;
    --poor: #ec7a6f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111412;
  --surface: #181c19;
  --surface-2: #20251f;
  --surface-3: #2a302a;
  --ink: #eef0ea;
  --ink-2: #b7bdb4;
  --ink-3: #848b82;
  --line: #2a302b;
  --line-strong: #3d453e;
  --accent: #79c19c;
  --accent-hover: #8fd0ae;
  --accent-ink: #0d1912;
  --accent-soft: #1d3127;
  --sun: #f0b350;
  --sun-soft: #3a2f1c;
  --glass: #7db5e8;
  --wall: #e6e9e2;
  --floor: #1e231f;
  --good: #6cc070;
  --ok: #e0b04a;
  --poor: #ec7a6f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: 100dvh;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 28px 28px;
  scrollbar-width: thin;
}

.stage-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 20px;
  gap: 14px;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 20px;
  background: var(--surface-2);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
}
.stage.editing { touch-action: none; }
.stage > canvas, .stage > svg { position: absolute; inset: 0; width: 100%; height: 100%; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; min-height: 100dvh; }
  .panel { display: contents; }
  .brand { order: 0; }
  .stage-wrap { order: 1; padding: 0 16px; }
  .stage { flex: none; height: 56vh; min-height: 320px; max-height: 560px; }
  .stepper { order: 2; padding: 16px 16px 0 !important; }
  .panel-body { order: 3; overflow: visible; padding: 8px 16px 40px; }
}

/* ---------- Brand ---------- */

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px 10px;
}
@media (max-width: 860px) { .brand { padding: 14px 16px 12px; } }
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font: 500 22px/1 var(--serif);
  letter-spacing: -0.01em;
}
.mark { width: 28px; height: 28px; }
.mark-sun { fill: var(--sun); }
.mark-leaf { fill: var(--accent); }
.mark-vein { stroke: var(--surface); stroke-width: 1.6; stroke-linecap: round; fill: none; }
.brand-tools { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Stepper ---------- */

.stepper {
  display: flex;
  gap: 4px;
  padding: 10px 28px 6px;
}
.step-dot {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.step-dot::before {
  content: "";
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  transition: background 0.2s;
}
.step-dot.done::before { background: var(--accent); opacity: 0.45; }
.step-dot.current::before { background: var(--accent); }
.step-dot.current { color: var(--ink); }
.step-dot:disabled { cursor: default; }
.step-dot:not(:disabled):hover { color: var(--ink); }

/* ---------- Panel typography ---------- */

.panel h2 {
  margin: 22px 0 6px;
  font: 500 30px/1.15 var(--serif);
  letter-spacing: -0.015em;
}
.lede { margin: 0 0 22px; color: var(--ink-2); }
.panel h3 {
  margin: 26px 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fine { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.fine a { color: inherit; }
.muted { color: var(--ink-3); }
.note { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-2); }
.error { margin: 10px 0 0; font-size: 13.5px; color: var(--poor); }

/* ---------- Controls ---------- */

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.row.tight { gap: 8px; }

input[type="text"], input[type="search"], input[type="number"], input[type="date"], select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.unit-input { position: relative; }
.unit-input input { padding-right: 34px; }
.unit-input::after {
  content: attr(data-unit);
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--ink-3);
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.small { height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn.danger { color: var(--poor); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

.actions {
  position: sticky;
  bottom: -28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 28px -28px -28px;
  padding: 16px 28px 22px;
  background: linear-gradient(to bottom, transparent, var(--surface) 30%);
}
@media (max-width: 860px) { .actions { position: static; margin: 28px 0 0; padding: 0; background: none; } }

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg.full { display: flex; width: 100%; }
.seg-sm button { height: 26px; padding: 0 10px; font-size: 12.5px; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Cards & lists ---------- */

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card + .card { margin-top: 10px; }

.place-card { display: grid; gap: 10px; padding: 18px; background: var(--surface-2); border: 0; }
.place-name { font-weight: 600; line-height: 1.35; }
.place-meta { font-size: 13px; color: var(--ink-3); }
.sun-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.sun-fact { padding: 10px; border-radius: 10px; background: var(--surface); }
.sun-fact b { display: block; font: 500 17px/1.2 var(--serif); }
.sun-fact span { font-size: 12px; color: var(--ink-3); }

.choices { display: grid; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--line-strong); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.choice-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); color: var(--accent); }
.choice[aria-pressed="true"] .choice-icon { background: var(--surface); }
.choice-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.choice b { display: block; font-weight: 600; }
.choice small { color: var(--ink-3); font-size: 13px; }

.results-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.result-btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
  font-size: 13.5px;
  line-height: 1.4;
}
.result-btn:hover { border-color: var(--accent); }

.dropzone {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 26px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }
.dropzone b { color: var(--ink); }
.dropzone svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.steps-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: s; }
.steps-list li { position: relative; padding-left: 34px; color: var(--ink-3); font-size: 14px; }
.steps-list li::before {
  counter-increment: s;
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-3);
}
.steps-list li.active { color: var(--ink); }
.steps-list li.active::before { background: var(--accent); color: var(--accent-ink); }
.steps-list li.done::before { content: "✓"; background: var(--accent-soft); color: var(--accent); }
.steps-list li.done { color: var(--ink-2); }

.photo-ref { position: relative; margin: 0 0 6px; }
.photo-ref img { display: block; width: 100%; border-radius: var(--radius); }
.photo-ref svg { position: absolute; top: 0; left: 0; width: 100%; aspect-ratio: auto; height: calc(100% - 26px); overflow: hidden; border-radius: var(--radius); }
.photo-ref polygon { fill: none; stroke: #fff; stroke-dasharray: 8 6; }
.photo-ref rect { fill: rgba(20, 24, 22, 0.72); }
.photo-ref text { fill: #fff; font-weight: 600; text-anchor: middle; dominant-baseline: central; letter-spacing: 0.04em; }
.photo-ref figcaption { height: 26px; padding-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.win-list { display: grid; gap: 8px; }
.win-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
}
.win-item[aria-pressed="true"] { border-color: var(--glass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--glass) 18%, transparent); }
.win-badge {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 8px;
  background: color-mix(in srgb, var(--glass) 16%, transparent);
  color: var(--glass);
  font-size: 12px; font-weight: 600;
}
.win-item small { display: block; color: var(--ink-3); font-size: 12.5px; }
.win-editor { margin-top: 12px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.win-editor .field:last-child { margin-bottom: 0; }

.empty-hint {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 14px;
  text-align: center;
}

/* plants */
.plant-search { position: relative; }
.plant-search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.plant-search input { padding-left: 36px; }
.catalog { margin-top: 8px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); scrollbar-width: thin; }
.catalog-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; }
.catalog-item:last-child { border-bottom: 0; }
.catalog-item:hover { background: var(--surface-2); }
.catalog-item .names { flex: 1; min-width: 0; }
.catalog-item b { display: block; font-weight: 500; }
.catalog-item i { display: block; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-item .add { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--accent); font-size: 18px; line-height: 1; }
.catalog-item.added .add { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 13px; }

.need {
  flex: none;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink-2);
}
.need.sun { background: var(--sun-soft); color: color-mix(in srgb, var(--sun) 70%, var(--ink)); }

.my-plants { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.my-plant { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.my-plant .names { flex: 1; min-width: 0; }
.my-plant b { font-weight: 500; }
.pin-badge {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12.5px; font-weight: 600;
}
.remove { border: 0; background: none; color: var(--ink-3); width: 28px; height: 28px; border-radius: 50%; font-size: 18px; line-height: 1; }
.remove:hover { background: var(--surface-3); color: var(--ink); }

/* results */
.controls { display: grid; gap: 12px; }
.controls .label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.rec {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.rec + .rec { margin-top: 10px; }
.rec:hover { border-color: var(--line-strong); }
.rec[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rec .pin-badge { grid-row: span 3; margin-top: 2px; }
.rec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rec-name { font: 500 17px/1.3 var(--serif); }
.rec-where { font-size: 14px; color: var(--ink); }
.rec-light { font-size: 13px; color: var(--ink-3); }
.rec-why { grid-column: 2; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.verdict { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.verdict::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.verdict.great { color: var(--good); }
.verdict.ok { color: var(--ok); }
.verdict.poor { color: var(--poor); }

/* ---------- Stage chrome ---------- */

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--ink-3);
  pointer-events: none;
}
.stage-empty b { display: block; margin-bottom: 4px; font: 500 22px/1.2 var(--serif); color: var(--ink-2); }
.stage-empty svg { width: 120px; height: 120px; margin-bottom: 14px; opacity: 0.9; }

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 300px);
  padding: 7px 14px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
  pointer-events: none;
}

.stage-busy {
  position: absolute;
  right: 16px;
  top: 92px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
  pointer-events: none;
}
.stage-busy::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tip {
  position: absolute;
  z-index: 3;
  min-width: 180px;
  max-width: 260px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
}
.tip b { display: block; font-weight: 600; margin-bottom: 2px; }
.tip .fits { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--ink-2); }

.legend {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 2;
  width: 250px;
  padding: 10px 12px 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  font-size: 11.5px;
  color: var(--ink-3);
  pointer-events: none;
}
.legend-title { font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.legend-bar { height: 8px; border-radius: 4px; }
.legend-ticks { position: relative; height: 16px; margin-top: 4px; }
.legend-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.legend-bar { position: relative; }
.legend-bar i { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--surface); }

/* svg */
.wall { fill: none; stroke: var(--wall); stroke-width: 6; stroke-linejoin: round; stroke-linecap: round; }
.wall-hit { fill: none; stroke: transparent; stroke-width: 22; cursor: copy; pointer-events: stroke; }
.wall-hit:hover + .wall-hover, .wall-hover.on { stroke: var(--accent); }
.wall-hover { fill: none; stroke: transparent; stroke-width: 6; stroke-linecap: round; pointer-events: none; }
.win-line { stroke: var(--surface); stroke-width: 8; stroke-linecap: butt; }
.win-glass { stroke: var(--glass); stroke-width: 4; stroke-linecap: butt; }
.win-hit { stroke: transparent; stroke-width: 24; cursor: grab; pointer-events: stroke; }
.win-sel .win-glass { stroke-width: 6; }
.win-handle { fill: var(--surface); stroke: var(--glass); stroke-width: 2; cursor: ew-resize; }
.win-tag { fill: var(--glass); font: 600 11px var(--sans); }
.wall-label { fill: var(--ink-3); font: 500 11px var(--sans); letter-spacing: 0.04em; text-transform: uppercase; }
.dim-label { fill: var(--ink-3); font: 500 11px var(--sans); }
.floor { fill: var(--floor); }

.compass { cursor: grab; }
.compass-ring { fill: color-mix(in srgb, var(--surface) 92%, transparent); stroke: var(--line-strong); stroke-width: 1; }
.compass-tick { stroke: var(--ink-3); stroke-width: 1; }
.compass-needle { fill: var(--poor); }
.compass-needle-s { fill: var(--ink-3); opacity: 0.5; }
.compass-n { fill: var(--ink); font: 700 11px var(--sans); }
.compass-help { fill: var(--ink-3); font: 500 10px var(--sans); }

.sun-path { fill: none; stroke: var(--sun); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; opacity: 0.8; }
.sun-ring { fill: none; stroke: var(--line-strong); stroke-width: 1; opacity: 0.5; }
.sun-ray { stroke: var(--sun); stroke-width: 1.5; stroke-dasharray: 4 5; opacity: 0.6; }
.sun-disc { fill: var(--sun); stroke: var(--surface); stroke-width: 3; }
.sun-glow { fill: var(--sun); opacity: 0.18; }
.sun-label { fill: var(--ink-2); font: 500 11px var(--sans); }

.pin { cursor: pointer; }
.pin circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.pin text { fill: var(--accent-ink); font: 600 11.5px var(--sans); }
.pin-shadow { fill: rgba(0, 0, 0, 0.16); }
.pin.sel circle { stroke-width: 3; }
.pin-label rect { fill: var(--surface); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15)); }
.pin-label text { fill: var(--ink); font: 500 12px var(--sans); }
.probe { fill: none; stroke: var(--ink); stroke-width: 1.5; opacity: 0.7; }

.trace-line { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.trace-open { fill: none; }
.trace-preview { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 5; }
.vertex { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; cursor: move; }
.vertex.first { fill: var(--accent); cursor: pointer; }
.scale-edge { stroke: var(--sun); stroke-width: 5; stroke-linecap: round; }
.scale-tag rect { fill: var(--sun); }
.scale-tag text { fill: #fff; font: 600 12px var(--sans); }

.quad { fill: none; stroke: #fff; stroke-width: 2; stroke-dasharray: 6 5; filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.6)); }
.quad-edge-label rect { fill: rgba(20, 24, 22, 0.72); }
.quad-edge-label text { fill: #fff; font: 600 11px var(--sans); letter-spacing: 0.04em; text-transform: uppercase; }
.corner { cursor: move; }
.corner circle.hit { fill: transparent; }
.corner circle.dot { fill: var(--accent); stroke: #fff; stroke-width: 3; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4)); }
.photo-frame { fill: none; stroke: rgba(255, 255, 255, 0.6); stroke-width: 1; }

/* ---------- Time bar ---------- */

.timebar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px 10px 10px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.play {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--sun-soft);
  color: color-mix(in srgb, var(--sun) 75%, var(--ink));
}
.play:hover { filter: brightness(0.97); }
.play svg { width: 18px; height: 18px; fill: currentColor; }
.play .i-pause { display: none; }
.play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }
.time-track { flex: 1; min-width: 120px; }
.time-ends { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.time-readout { min-width: 132px; }
.time-now { font: 500 18px/1.2 var(--serif); }
.time-sun { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.layer-toggle { flex: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--track, var(--line)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track, var(--line)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--sun);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line-strong);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sun);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line-strong);
}

@media (max-width: 860px) {
  .stage-wrap { gap: 10px; }
  .timebar { flex-wrap: wrap; gap: 10px 12px; padding: 10px 12px; }
  .time-track { order: 3; flex-basis: 100%; }
  .time-readout { flex: 1; min-width: 0; }
  .time-sun { white-space: normal; line-height: 1.35; }
  .legend { width: calc(100% - 104px); max-width: 250px; top: 12px; left: 12px; font-size: 11px; }
  .stage-hint { max-width: calc(100% - 150px); left: auto; right: 12px; transform: none; text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Furniture, placement, compass marks ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dropzone.compact { margin-top: 12px; padding: 14px 16px; gap: 2px; }
.furn-badge { background: var(--surface-3); color: var(--ink-2); }
.furn polygon { fill: color-mix(in srgb, var(--wall) 14%, var(--surface)); stroke: var(--wall); stroke-width: 1.5; stroke-linejoin: round; opacity: 0.92; }
.furn text { fill: var(--ink-2); font: 500 11px var(--sans); pointer-events: none; }
.furn:not(.static) { cursor: move; touch-action: none; }
.furn.static { pointer-events: none; }
.furn.static polygon { opacity: 0.7; }
.furn.sel polygon { stroke: var(--accent); stroke-width: 2.5; }
.furn-stem { stroke: var(--accent); stroke-width: 1.5; }
.furn-size { fill: var(--accent); stroke: var(--surface); stroke-width: 2; cursor: nwse-resize; touch-action: none; }
.furn-rot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; cursor: grab; touch-action: none; }

.pin { touch-action: none; cursor: grab; }
.pin.manual circle { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.pin.manual text { fill: var(--accent); }
.best-ghost { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }
.best-link { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 4; opacity: 0.7; }
.rec-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.muted-link { color: var(--ink-3); font-weight: 500; }

.cmark { fill: var(--poor); stroke: #fff; stroke-width: 2; }
.cmark.c { fill: var(--ink); }
.cmark-line { stroke: var(--poor); stroke-width: 2.5; }

/* ---------- 3D ---------- */
.stage > canvas.stage-3d { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage > canvas.stage-3d:active { cursor: grabbing; }
.view-toggle { position: absolute; left: 14px; bottom: 14px; z-index: 3; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow-sm); }
.view-toggle button { min-width: 52px; }

.rec-height { grid-column: 2; display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.rec-height .unit-input { width: 92px; }
.rec-height input { height: 32px; font-size: 13.5px; }

.site-card { display: grid; gap: 10px; margin-top: 12px; padding: 14px; }
.site-map { display: block; width: 100%; height: 190px; border-radius: 10px; border: 1px solid var(--line); }
.align-block { margin: 0 0 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }

/* ---------- Rooms ---------- */
.roombar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: none; }
.room-tab { flex: none; height: 32px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.room-tab:hover { color: var(--ink); border-color: var(--line-strong); }
.room-tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.room-tab.add { border-style: dashed; color: var(--accent); }
.other-room polygon { fill: transparent; stroke: var(--wall); stroke-width: 3; opacity: 0.45; cursor: pointer; }
.other-room:hover polygon { opacity: 0.8; }
.other-room text { fill: var(--ink-2); font: 600 12px var(--sans); pointer-events: none; }

.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18); }

.toggle small { display: block; margin-top: 1px; font-size: 12px; color: var(--ink-2); }
.bay-pane { stroke-width: 3; }
.bulge-handle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; cursor: grab; opacity: 0.8; }
.bulge-handle.curved { fill: var(--accent); }
.bulge-handle:hover { opacity: 1; }
.scale-edge { fill: none; }
#reset { position: relative; }
#reset.armed { background: var(--poor); color: var(--accent-ink); border-color: transparent; }
#reset.armed::after {
  content: 'Click again to start over';
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20;
  white-space: nowrap; font-size: 12px; padding: 4px 8px; border-radius: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm);
}
