/* Home Map passive viewer (Phase 1). */

.hm-versions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.hm-versions__label {
  color: var(--ink-muted);
  font-size: 13px;
}

.hm-chip {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  font-size: 13px;
  color: var(--ink-muted);
}

.hm-chip--active {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--ink-muted);
}

.hm-viewer {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.hm-toolbar {
  display: none; /* superseded by hm-canvas-bar in V1 */
}

.hm-canvas {
  position: relative;
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  overflow: hidden;
}

.hm-layers {
  display: none; /* superseded by hm-workspace__panel in V1 */
}

.hm-svg.is-dragging {
  cursor: grabbing;
}

.hm-pdf-notice {
  position: absolute;
  inset: auto 16px 16px 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  box-shadow: var(--shadow-1);
}

.hm-pdf-notice p {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-size: 13px;
}

.hm-layers {
  grid-column: 2;
  align-self: start;
  min-width: 160px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  background: var(--surface);
}

.hm-layers__title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.hm-layers__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hm-layers__list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.hm-status {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.hm-status--neutral a {
  color: var(--ink);
}

.hm-room__measure {
  paint-order: stroke;
  stroke: var(--surface, #fff);
  stroke-width: 0.4px;
}

/* --- Editor island (Phase 2) --- */

.hm-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.hm-editor__toolbar {
  display: none; /* superseded by hm-tool-rail in V1 */
}

.hm-editor__canvas {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  overflow: hidden;
}

.hm-editor__svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  cursor: crosshair;
}

.hm-editor__svg.is-panning {
  cursor: grabbing;
}

.hm-editor__side {
  display: contents; /* panels moved into hm-inspector by V1 layout */
}

.hm-editor__panel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  background: var(--surface);
}

.hm-editor__panel h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.hm-editor__status {
  font-size: 13px;
  color: var(--ink-muted);
  min-height: 18px;
}

.hm-editor__status.is-error {
  color: var(--danger, #c0392b);
}

.hm-editor__btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.hm-editor__btn.is-active {
  background: var(--surface-2);
  border-color: var(--ink-muted);
  color: var(--ink);
}

.hm-editor__rooms {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hm-editor__rooms li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.hm-room__vertex {
  fill: #3b6cff;
  cursor: grab;
}

.hm-room__vertex--locked {
  fill: #b26a00;
  cursor: not-allowed;
}

.hm-wall__line {
  cursor: pointer;
}

.hm-wall--locked .hm-wall__line {
  cursor: not-allowed;
}

.hm-editor__layers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.hm-editor__layers label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.hm-editor__layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hm-editor__layer-name {
  flex: 1 1 auto;
  min-width: 0;
}

.hm-editor__selection {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hm-editor__selection .hm-editor__btn {
  align-self: flex-start;
}

.hm-room__poly.is-selected {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.18);
  stroke: var(--primary, #F2A938);
}

/* Markers (Phase 4) */
.hm-marker__dot {
  fill: #3b6cff;
  stroke: #ffffff;
  stroke-width: 0.4;
  paint-order: stroke;
}

.hm-marker__glyph {
  fill: #ffffff;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
}

.hm-marker__label {
  pointer-events: none;
}

.hm-marker--electrical_socket .hm-marker__dot,
.hm-marker--electrical_switch .hm-marker__dot,
.hm-marker--light_point .hm-marker__dot,
.hm-marker--junction_box .hm-marker__dot,
.hm-marker--internet_rj45 .hm-marker__dot {
  fill: #c2410c;
}

.hm-marker--water_point .hm-marker__dot,
.hm-marker--drain .hm-marker__dot,
.hm-marker--hvac_vent .hm-marker__dot {
  fill: #0e7490;
}

.hm-marker--note .hm-marker__dot,
.hm-marker--photo .hm-marker__dot,
.hm-marker--equipment .hm-marker__dot,
.hm-marker--other .hm-marker__dot {
  fill: #4b5563;
}

.hm-marker--locked .hm-marker__dot {
  stroke: #b26a00;
  stroke-width: 0.8;
  cursor: not-allowed;
}

.hm-marker.is-selected .hm-marker__dot {
  stroke: #10204a;
  stroke-width: 1;
}

/* Openings (Phase 6) — doors/windows interrupt the wall; fireplace/chimney are
   attached symbols (block/hatch), never a gap. */
.hm-opening__cut {
  /* The white "cut" sits over the wall to read as an interruption. */
  pointer-events: none;
}

.hm-opening__frame {
  stroke: #1b66c9;
  pointer-events: none;
}

.hm-opening--window .hm-opening__frame {
  stroke: #2563eb;
}

.hm-opening--garage_door .hm-opening__frame {
  stroke: #0f766e;
}

.hm-opening--arch .hm-opening__frame,
.hm-opening--open_passage .hm-opening__frame {
  stroke: #94a3b8;
  stroke-dasharray: 2 2;
}

.hm-opening__block {
  fill: rgba(148, 114, 77, 0.22);
  stroke: #7c5c3b;
}

.hm-opening--ventilation .hm-opening__block,
.hm-opening--other .hm-opening__block {
  fill: rgba(75, 85, 99, 0.18);
  stroke: #4b5563;
}

.hm-opening__label {
  pointer-events: none;
}

.hm-opening.is-locked .hm-opening__frame,
.hm-opening.is-locked .hm-opening__block {
  stroke: #b26a00;
}

.hm-layers__bg {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.hm-editor__links {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.hm-editor__links li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* --- Technical networks (Phase 5) --- */
.hm-layers__title--sub {
  margin-top: 10px;
}

/* Per-network colour conventions (electrical amber, water blue, gas yellow…).
   The data-network group sets --hm-net-color; edges and node dots inherit it.
   Certainty is expressed with dash pattern + opacity, never colour alone. */
[data-network="electrical"] { --hm-net-color: #d97706; }
[data-network="water"] { --hm-net-color: #2563eb; }
[data-network="drainage"] { --hm-net-color: #78716c; }
[data-network="network_rj45"] { --hm-net-color: #7c3aed; }
[data-network="hvac"] { --hm-net-color: #0d9488; }
[data-network="gas"] { --hm-net-color: #ca8a04; }
[data-network="solar"] { --hm-net-color: #ea580c; }
[data-network="other"] { --hm-net-color: #64748b; }

/* Nodes */
.hm-net-node {
  cursor: pointer;
}
.hm-net-node__dot {
  fill: var(--hm-net-color, #0f766e);
  stroke: #ffffff;
  stroke-width: 1.5;
}
.hm-net-node__glyph {
  fill: #ffffff;
  font-weight: 700;
  pointer-events: none;
}
.hm-net-node__icon {
  pointer-events: none;
}
.hm-marker__icon {
  pointer-events: none;
}
.hm-net-node__label {
  fill: #10204a;
  font-weight: 600;
  pointer-events: none;
}

/* Edges */
.hm-net-edge {
  fill: none;
  stroke: var(--hm-net-color, #0f766e);
}
.hm-net-edge__stub {
  fill: none;
  stroke: #6b7280;
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}
.hm-net-edge__q {
  fill: #6b7280;
  font-weight: 700;
}

/* Certainty promise — confirmed vs everything-less-than-confirmed must never
   look the same. Confirmed = solid; inferred/unknown/planned = dashed + muted;
   abandoned = faint + dotted. */
.hm-net--confirmed {
  opacity: 1;
}
.hm-net--inferred {
  stroke-dasharray: 8 5;
  opacity: 0.95;
}
.hm-net--unknown {
  stroke-dasharray: 2 6;
  opacity: 0.9;
}
.hm-net--planned {
  stroke-dasharray: 10 6;
  opacity: 0.8;
}
.hm-net--abandoned {
  stroke-dasharray: 1 7;
  opacity: 0.55;
}
.hm-net-node.hm-net--inferred .hm-net-node__dot {
  stroke-dasharray: 3 2;
}
.hm-net-node.hm-net--unknown .hm-net-node__dot,
.hm-net-node.hm-net--planned .hm-net-node__dot {
  opacity: 0.85;
}
.hm-net-node.hm-net--abandoned {
  opacity: 0.55;
}

/* ---- Trace focus mode ---------------------------------------------------
   When a path is active the whole route becomes the visual focus: everything
   not on the path is dimmed, and path nodes/edges are amplified (thicker stroke
   + halo + stronger rings). Confidence styling is preserved — path edges keep
   their certainty colour and dash pattern, so confirmed vs inferred/unknown/
   planned stay distinguishable while all read clearly as "selected path".
   Pure viewer state; no geometry is mutated. */

/* Dim non-path content while a trace is active. */
.hm-svg.hm-trace-active [data-layer] {
  opacity: 0.35;
}
.hm-svg.hm-trace-active .hm-net-edge:not(.hm-trace-path) {
  opacity: 0.12;
}
.hm-svg.hm-trace-active
  .hm-net-node:not(.hm-trace-path):not(.hm-trace-source):not(.hm-trace-target) {
  opacity: 0.16;
}

/* Path edges: thick + glowing halo, certainty colour/dash retained. */
.hm-net-edge.hm-trace-path {
  opacity: 1;
  stroke-width: 7;
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.9));
}
/* Path nodes: full opacity + a stronger amber ring for intermediates. */
.hm-net-node.hm-trace-path {
  opacity: 1;
}
.hm-net-node.hm-trace-path .hm-net-node__dot {
  stroke: #f59e0b;
  stroke-width: 3;
  filter: drop-shadow(0 0 3px rgba(245, 158, 11, 0.85));
}
/* Source and target are distinct from intermediate path nodes and from each
   other: green source, red target. */
.hm-net-node.hm-trace-source .hm-net-node__dot {
  stroke: #16a34a;
  stroke-width: 4;
  filter: drop-shadow(0 0 5px rgba(22, 163, 74, 0.95));
}
.hm-net-node.hm-trace-target .hm-net-node__dot {
  stroke: #dc2626;
  stroke-width: 4;
  filter: drop-shadow(0 0 5px rgba(220, 38, 38, 0.95));
}
/* Keep source/target labels readable even when their group is dimmed. */
.hm-net-node.hm-trace-source,
.hm-net-node.hm-trace-target {
  opacity: 1;
}

.hm-trace {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--accent-tint-bg);
  border: 1px solid var(--accent-tint-border);
  border-radius: var(--r-sm);
  font-size: 13px;
  flex-shrink: 0;
}
.hm-trace__text {
  flex: 1;
  color: var(--ink-muted);
}

/* Linked-equipment affordance: a small teal badge + native <title> tooltip on
   markers/openings that have an Asset behind them. Sensitive device metadata is
   never shown here — only on the equipment detail page. */
.hm-marker__equip {
  fill: #0f766e;
  stroke: #ffffff;
  stroke-width: 0.6;
  pointer-events: none;
}
.hm-marker--has-equipment .hm-marker__dot {
  stroke: #0f766e;
}
.hm-opening--has-equipment .hm-opening__frame,
.hm-opening--has-equipment .hm-opening__block {
  stroke: #0f766e;
}

/* Editor: linked-equipment list rows with an "open" link + remove. */
.hm-editor__link-row {
  display: inline;
}
.hm-editor__link-row a {
  color: #0f766e;
  text-decoration: underline;
}
.hm-editor__link-role {
  color: var(--text-muted, #64748b);
}

/* Room-focused embed on the Space detail page — smaller, read-only. */
.hm-viewer--embed .hm-canvas {
  min-height: 300px;
}
.hm-viewer--embed .hm-svg {
  height: 48vh;
  max-height: 480px;
}
/* "Continues outside this room" affordance for clipped/leaving edges. */
.hm-net-edge--continues line {
  stroke-dasharray: 4 3;
  opacity: 0.85;
}
.hm-net-edge__beyond {
  fill: var(--surface, #fff);
  stroke: var(--hm-net-color, #0f766e);
  stroke-width: 1.5;
}

/* Home Map — Yolumna V1 workspace (viewer + editor). */

/* Full-bleed content area when Home Map page is active */
.app-content:has(.hm-page) {
  width: 100%;
  max-width: none;
  padding: 12px clamp(12px, 2vw, 20px) 12px;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h));
  max-height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
  box-sizing: border-box;
}

.hm-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 0;
}

.hm-page__bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.hm-page__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hm-page__meta {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.hm-page__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hm-page__save-status {
  font-size: 13px;
  color: var(--ink-muted);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.hm-page__save-status.is-error {
  color: var(--rose);
  border-color: rgba(var(--rose-rgb), 0.35);
}

.hm-page__versions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0 2px;
  flex-shrink: 0;
}

.hm-page__archive,
.hm-page__reset {
  flex-shrink: 0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.hm-banner {
  flex-shrink: 0;
  margin: 6px 0 0;
}

/* —— Workspace shell —— */
.hm-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(320px, 30vw);
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin-top: 6px;
}

.hm-workspace--editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-top: 0;
}

.hm-workspace__body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) min(320px, 30vw);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.hm-workspace__canvas-col,
.hm-workspace__canvas {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.hm-workspace__panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  max-height: 100%;
}

/* —— Canvas —— */
.hm-viewer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

.hm-canvas {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-1, 0 1px 3px rgba(0,0,0,0.08));
}

[data-theme="light"],
.ps-paper {
  --hm-canvas-bg: #F4F0E8;
  --hm-grid-line: rgba(42, 38, 34, 0.045);
  --hm-grid-major: rgba(42, 38, 34, 0.085);
  --hm-wall-stroke: #2A2622;
  --hm-room-fill: rgba(249, 246, 240, 0.94);
  --hm-room-stroke: rgba(61, 56, 50, 0.22);
  --hm-label-fill: #2A2622;
  --hm-label-area-fill: #6B6560;
  --hm-measure-fill: #8A8580;
  --hm-measure-opacity: 0.62;
  --hm-bg-opacity: 0.30;
  --hm-bg-filter: saturate(0.75) contrast(0.9);
  --hm-marker-label-opacity: 0;
  --hm-net-opacity: 0.78;
  --hm-opening-detail: rgba(61, 56, 50, 0.55);
  /* Object symbol palette (shared <symbol> art, warm architectural read) */
  --hm-sym-line: #4A4440;
  --hm-sym-fabric: #E9E1D3;
  --hm-sym-fabric-2: #DBD0BC;
  --hm-sym-wood: #D9C29A;
  --hm-sym-wood-2: #B99A6B;
  --hm-sym-white: #FBF9F4;
  --hm-sym-metal: #D7D9DC;
  --hm-sym-water: rgba(116, 166, 190, 0.35);
  --hm-sym-green: #B9CDA0;
  --hm-sym-green-2: #7E9962;
  --hm-sym-tech: #C9CCD2;
  --hm-sym-amber: #D99A3D;
  --hm-sym-soil: #C9A97E;
  /* Floor material palette (shared <pattern> defs, warm architectural read) */
  --hm-mat-wood-light: #EFE4D0;
  --hm-mat-wood-oak: #E4CCA5;
  --hm-mat-wood-dark: #B18E63;
  --hm-mat-wood-line: rgba(96, 74, 52, 0.28);
  --hm-mat-wood-dark-line: rgba(58, 42, 28, 0.35);
  --hm-mat-tile-light: #F1EEE7;
  --hm-mat-tile-grey: #DDDDD8;
  --hm-mat-tile-line: rgba(84, 84, 80, 0.24);
  --hm-mat-marble: #F2F0EC;
  --hm-mat-marble-vein: rgba(138, 140, 152, 0.4);
  --hm-mat-terrazzo: #EDEAE2;
  --hm-mat-terrazzo-chip: rgba(122, 110, 98, 0.42);
  --hm-mat-terrazzo-chip-2: rgba(176, 130, 96, 0.4);
  --hm-mat-concrete: #E3E1DD;
  --hm-mat-concrete-fleck: rgba(90, 90, 90, 0.22);
  --hm-mat-carpet-light: #EAE3D7;
  --hm-mat-carpet-dark: #C9BCAC;
  --hm-mat-carpet-dot: rgba(92, 80, 66, 0.2);
  --hm-mat-rug: #E0D2C4;
  --hm-mat-rug-line: rgba(152, 104, 78, 0.3);
  --hm-mat-grass: #CFE0B6;
  --hm-mat-grass-blade: rgba(94, 134, 70, 0.55);
  --hm-mat-gravel: #E7E3DA;
  --hm-mat-gravel-stone: rgba(122, 116, 104, 0.42);
  --hm-mat-deck: #DAB98B;
  --hm-mat-deck-line: rgba(112, 80, 48, 0.42);
  --hm-mat-water: #BFDCE8;
  --hm-mat-water-wave: rgba(58, 122, 152, 0.45);
  --hm-mat-water-glint: rgba(255, 255, 255, 0.55);
  /* Outdoor surfaces (V3 Outdoor Mode) */
  --hm-mat-grass-light: #DCE8C8;
  --hm-mat-grass-dry: #DBD9AE;
  --hm-mat-grass-dry-blade: rgba(140, 130, 74, 0.55);
  --hm-mat-paver: #DFD9CE;
  --hm-mat-paver-line: rgba(100, 92, 80, 0.32);
  --hm-mat-drive: #DCDAD4;
  --hm-mat-drive-line: rgba(96, 94, 88, 0.3);
  --hm-mat-drive-fleck: rgba(90, 90, 90, 0.2);
  --hm-mat-asphalt: #C6C7C9;
  --hm-mat-asphalt-fleck: rgba(70, 72, 76, 0.3);
  --hm-mat-deck-dark: #A67C4E;
  --hm-mat-deck-dark-line: rgba(64, 44, 24, 0.45);
  --hm-mat-patio: #E9E2D3;
  --hm-mat-patio-line: rgba(120, 108, 88, 0.3);
  --hm-mat-sand: #F0E3C4;
  --hm-mat-sand-dot: rgba(160, 134, 82, 0.4);
  --hm-mat-soil: #D5BC9C;
  --hm-mat-soil-dot: rgba(110, 78, 46, 0.4);
  --hm-mat-hedge: #B7CFA0;
  --hm-mat-hedge-leaf: rgba(74, 110, 56, 0.5);
  /* Outdoor zone chrome (border + label styling) */
  --hm-outdoor-stroke: rgba(110, 118, 96, 0.55);
  --hm-outdoor-pool-stroke: #7FB3C8;
  --hm-outdoor-pool-inner: rgba(255, 255, 255, 0.65);
  /* Depth (V3 polish): soft shadows lift walls and objects off the floor */
  --hm-depth-wall: drop-shadow(0 0.6px 1.2px rgba(20, 16, 12, 0.22));
  --hm-depth-object: drop-shadow(0 0.5px 1px rgba(20, 16, 12, 0.18));
  /* Label cards (V4): translucent information cards behind names */
  --hm-labelcard-bg: rgba(252, 250, 245, 0.72);
  --hm-labelcard-shadow: drop-shadow(0 0.6px 1.4px rgba(20, 16, 12, 0.14));
  --hm-labelcard-name: #2A2622;
  --hm-labelcard-meta: #6B6560;
  --hm-labelcard-outdoor-bg: rgba(252, 250, 245, 0.42);
  --hm-labelcard-outdoor-name: rgba(58, 62, 48, 0.82);
  --hm-labelcard-outdoor-meta: rgba(90, 94, 78, 0.7);
}

/* The drawing palette follows the paper, not the app theme: dark paper gets the dark
   material and furniture palette (the light .ps-paper block above would otherwise win). */
[data-theme="dark"],
.ps-paper[data-drawing-theme="dark"] {
  --hm-canvas-bg: #1E2433;
  --hm-grid-line: rgba(255, 255, 255, 0.035);
  --hm-grid-major: rgba(255, 255, 255, 0.065);
  --hm-wall-stroke: #C8CDD8;
  --hm-room-fill: rgba(42, 48, 64, 0.88);
  --hm-room-stroke: rgba(168, 175, 190, 0.22);
  --hm-label-fill: #E8E4EA;
  --hm-label-area-fill: #A0A7B3;
  --hm-measure-fill: #7A8394;
  --hm-measure-opacity: 0.55;
  --hm-bg-opacity: 0.20;
  --hm-bg-filter: brightness(0.45) saturate(0.65) contrast(0.85);
  --hm-marker-label-opacity: 0;
  --hm-net-opacity: 0.72;
  --hm-opening-detail: rgba(168, 175, 190, 0.6);
  --hm-sym-line: #A8AFBE;
  --hm-sym-fabric: #3A4152;
  --hm-sym-fabric-2: #454D61;
  --hm-sym-wood: #55483A;
  --hm-sym-wood-2: #6E5C46;
  --hm-sym-white: #4A5164;
  --hm-sym-metal: #575F71;
  --hm-sym-water: rgba(116, 166, 190, 0.28);
  --hm-sym-green: #4A5A44;
  --hm-sym-green-2: #7E9962;
  --hm-sym-tech: #4E5566;
  --hm-sym-amber: #F2A938;
  --hm-sym-soil: #5A4A38;
  /* Floor materials — muted so dark mode stays crisp, never muddy */
  --hm-mat-wood-light: #3E3A33;
  --hm-mat-wood-oak: #494033;
  --hm-mat-wood-dark: #362F26;
  --hm-mat-wood-line: rgba(206, 196, 178, 0.16);
  --hm-mat-wood-dark-line: rgba(206, 196, 178, 0.14);
  --hm-mat-tile-light: #333A48;
  --hm-mat-tile-grey: #2F3542;
  --hm-mat-tile-line: rgba(200, 205, 216, 0.16);
  --hm-mat-marble: #363C4A;
  --hm-mat-marble-vein: rgba(200, 205, 216, 0.24);
  --hm-mat-terrazzo: #343A48;
  --hm-mat-terrazzo-chip: rgba(200, 205, 216, 0.3);
  --hm-mat-terrazzo-chip-2: rgba(226, 178, 132, 0.28);
  --hm-mat-concrete: #313742;
  --hm-mat-concrete-fleck: rgba(200, 205, 216, 0.18);
  --hm-mat-carpet-light: #3A3F4D;
  --hm-mat-carpet-dark: #2C313D;
  --hm-mat-carpet-dot: rgba(200, 205, 216, 0.16);
  --hm-mat-rug: #413B44;
  --hm-mat-rug-line: rgba(216, 178, 156, 0.22);
  --hm-mat-grass: #33422F;
  --hm-mat-grass-blade: rgba(142, 182, 118, 0.4);
  --hm-mat-gravel: #383D48;
  --hm-mat-gravel-stone: rgba(200, 205, 216, 0.26);
  --hm-mat-deck: #46392A;
  --hm-mat-deck-line: rgba(222, 190, 148, 0.26);
  --hm-mat-water: #24384A;
  --hm-mat-water-wave: rgba(112, 172, 204, 0.42);
  --hm-mat-water-glint: rgba(196, 228, 244, 0.4);
  /* Outdoor surfaces — muted, never neon in dark mode */
  --hm-mat-grass-light: #38452F;
  --hm-mat-grass-dry: #45432E;
  --hm-mat-grass-dry-blade: rgba(196, 186, 122, 0.4);
  --hm-mat-paver: #3A3E48;
  --hm-mat-paver-line: rgba(200, 205, 216, 0.2);
  --hm-mat-drive: #33373F;
  --hm-mat-drive-line: rgba(200, 205, 216, 0.2);
  --hm-mat-drive-fleck: rgba(200, 205, 216, 0.16);
  --hm-mat-asphalt: #272B33;
  --hm-mat-asphalt-fleck: rgba(200, 205, 216, 0.22);
  --hm-mat-deck-dark: #3D3123;
  --hm-mat-deck-dark-line: rgba(222, 190, 148, 0.24);
  --hm-mat-patio: #3B3F49;
  --hm-mat-patio-line: rgba(200, 205, 216, 0.18);
  --hm-mat-sand: #4A4234;
  --hm-mat-sand-dot: rgba(226, 202, 148, 0.32);
  --hm-mat-soil: #3E332A;
  --hm-mat-soil-dot: rgba(214, 178, 138, 0.3);
  --hm-mat-hedge: #2F4230;
  --hm-mat-hedge-leaf: rgba(150, 196, 130, 0.36);
  /* Outdoor zone chrome */
  --hm-outdoor-stroke: rgba(168, 178, 152, 0.4);
  --hm-outdoor-pool-stroke: #4E7C94;
  --hm-outdoor-pool-inner: rgba(196, 228, 244, 0.35);
  /* Depth — darker canvas needs stronger, cooler shadows to read */
  --hm-depth-wall: drop-shadow(0 0.6px 1.4px rgba(0, 0, 0, 0.5));
  --hm-depth-object: drop-shadow(0 0.5px 1.2px rgba(0, 0, 0, 0.4));
  /* Label cards (V4) */
  --hm-labelcard-bg: rgba(30, 36, 51, 0.68);
  --hm-labelcard-shadow: drop-shadow(0 0.6px 1.6px rgba(0, 0, 0, 0.45));
  --hm-labelcard-name: #E8E4EA;
  --hm-labelcard-meta: #A0A7B3;
  --hm-labelcard-outdoor-bg: rgba(30, 36, 51, 0.38);
  --hm-labelcard-outdoor-name: rgba(214, 222, 204, 0.82);
  --hm-labelcard-outdoor-meta: rgba(170, 180, 160, 0.68);
}

.hm-canvas {
  background:
    repeating-linear-gradient(0deg, transparent, transparent 47px, var(--hm-grid-major) 48px),
    repeating-linear-gradient(90deg, transparent, transparent 47px, var(--hm-grid-major) 48px),
    repeating-linear-gradient(0deg, transparent, transparent 11px, var(--hm-grid-line) 12px),
    repeating-linear-gradient(90deg, transparent, transparent 11px, var(--hm-grid-line) 12px),
    var(--hm-canvas-bg, var(--surface-2));
}

[data-hm-background] {
  opacity: var(--hm-bg-opacity, 0.3);
  filter: var(--hm-bg-filter, none);
}

.hm-wall__line {
  stroke: var(--hm-wall-stroke, #2A2622);
  stroke-linecap: square;
  stroke-linejoin: miter;
  pointer-events: stroke;
  /* V3 polish: soft cast shadow separates walls from floor materials. */
  filter: var(--hm-depth-wall, none);
}

.hm-wall--locked .hm-wall__line {
  stroke: var(--primary, #F2A938);
  stroke-dasharray: 6 4;
}

.hm-wall__measure,
.hm-room__measure {
  fill: var(--hm-measure-fill);
  font-size: 0.72em;
  font-weight: 500;
  opacity: var(--hm-measure-opacity, 0.62);
  paint-order: stroke;
  stroke: var(--hm-canvas-bg);
  stroke-width: 4px;
  pointer-events: none;
}

.hm-room {
  cursor: pointer;
}

.hm-room__poly {
  fill: var(--hm-room-fill);
  stroke: var(--hm-room-stroke);
  stroke-linejoin: round;
  transition: fill 0.12s ease, stroke 0.12s ease;
}

/* Floor material underlay: the pattern polygon paints the surface while the
   base polygon above turns transparent and keeps hover/selection behaviour. */
.hm-room__material {
  stroke: none;
  pointer-events: none;
}

.hm-room__poly--material {
  fill: transparent;
}

.hm-room:hover .hm-room__poly:not(.is-selected) {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.06);
  stroke: rgba(var(--primary-rgb, 242, 169, 56), 0.35);
}

.hm-room__label {
  fill: var(--hm-label-fill);
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: none;
  /* V3 polish: subtle halo keeps names readable over busy floor patterns. */
  paint-order: stroke;
  stroke: var(--hm-canvas-bg, #F4F0E8);
  stroke-width: 3px;
  stroke-opacity: 0.6;
  stroke-linejoin: round;
}

.hm-room__area {
  font-size: 0.78em;
  font-weight: 500;
  fill: var(--hm-label-area-fill, var(--ink-muted));
}

.hm-room__poly.is-selected {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.16);
  stroke: var(--primary, #F2A938);
  stroke-width: 1.75px;
}

/* —— Outdoor areas (V3 Outdoor Mode) —— terrain zones painted below the
   building. Same underlay pattern as room materials: the material polygon
   paints the surface, the base polygon carries border + interaction. */
.hm-outdoor {
  cursor: pointer;
}

.hm-outdoor__material {
  stroke: none;
  pointer-events: none;
}

.hm-outdoor__poly {
  fill: var(--hm-outdoor-zone-fill, rgba(110, 118, 96, 0.1));
  stroke: var(--hm-outdoor-stroke);
  stroke-linejoin: round;
  transition: fill 0.12s ease, stroke 0.12s ease;
}

.hm-outdoor__poly--material {
  fill: transparent;
}

.hm-outdoor:hover .hm-outdoor__poly:not(.is-selected) {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.06);
  stroke: rgba(var(--primary-rgb, 242, 169, 56), 0.4);
}

.hm-outdoor__poly.is-selected {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.14);
  stroke: var(--primary, #F2A938);
  stroke-width: 1.75px;
}

/* Pool: coping border + waterline for a real "pool" read, not a blue box. */
.hm-outdoor--pool .hm-outdoor__poly {
  stroke: var(--hm-outdoor-pool-stroke);
  stroke-width: 3px;
}

.hm-outdoor--pool .hm-outdoor__poly.is-selected {
  stroke: var(--primary, #F2A938);
}

.hm-outdoor__pool-inner {
  fill: none;
  stroke: var(--hm-outdoor-pool-inner);
  pointer-events: none;
}

.hm-outdoor__label {
  fill: var(--hm-label-fill);
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.85;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--hm-canvas-bg);
  stroke-width: 3px;
  stroke-opacity: 0.55;
}

.hm-outdoor__area {
  font-size: 0.78em;
  font-weight: 500;
  fill: var(--hm-label-area-fill, var(--ink-muted));
}

/* --- Label cards (V4): refined name + area information cards ------------- */

.hm-labelcard {
  pointer-events: none;
}

.hm-labelcard__bg {
  fill: var(--hm-labelcard-bg);
  filter: var(--hm-labelcard-shadow);
}

.hm-labelcard__name {
  fill: var(--hm-labelcard-name);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.hm-labelcard__meta {
  fill: var(--hm-labelcard-meta);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Outdoor labels stay quieter than room labels: the zone itself is the
   primary visual cue, the text is a soft annotation. */
.hm-labelcard--outdoor .hm-labelcard__bg {
  fill: var(--hm-labelcard-outdoor-bg);
  filter: none;
}

.hm-labelcard--outdoor .hm-labelcard__name {
  fill: var(--hm-labelcard-outdoor-name);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.hm-labelcard--outdoor .hm-labelcard__meta {
  fill: var(--hm-labelcard-outdoor-meta);
}

/* Adaptive visibility (V4): at low effective zoom (dashboard preview, far
   zoom-out) only the name survives; the m² line returns at medium zoom. The
   card chrome is dropped too (it would be sized for two lines) — a halo
   keeps the bare name readable instead. */
[data-hm-zoom="low"] .hm-labelcard__meta,
[data-hm-zoom="low"] .hm-labelcard__bg {
  display: none;
}

[data-hm-zoom="low"] .hm-labelcard__name {
  paint-order: stroke;
  stroke: var(--hm-canvas-bg, #F4F0E8);
  stroke-width: 3px;
  stroke-opacity: 0.6;
  stroke-linejoin: round;
}

.hm-room__vertex {
  fill: var(--primary, #F2A938);
  stroke: var(--surface, #fff);
  stroke-width: 1.5;
  cursor: grab;
}

.hm-room__vertex--locked {
  fill: #b26a00;
  cursor: not-allowed;
}

/* Markers — compact, secondary until selected/hovered */
.hm-svg .hm-marker__dot,
.hm-editor__svg .hm-marker__dot {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.88);
  stroke: var(--surface, #fff);
  stroke-width: 1;
  paint-order: stroke;
}

.hm-svg .hm-marker--electrical_socket .hm-marker__dot,
.hm-svg .hm-marker--electrical_switch .hm-marker__dot,
.hm-svg .hm-marker--light_point .hm-marker__dot,
.hm-svg .hm-marker--junction_box .hm-marker__dot,
.hm-svg .hm-marker--internet_rj45 .hm-marker__dot,
.hm-editor__svg .hm-marker--electrical_socket .hm-marker__dot,
.hm-editor__svg .hm-marker--electrical_switch .hm-marker__dot,
.hm-editor__svg .hm-marker--light_point .hm-marker__dot,
.hm-editor__svg .hm-marker--junction_box .hm-marker__dot,
.hm-editor__svg .hm-marker--internet_rj45 .hm-marker__dot {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.92);
}

.hm-svg .hm-marker--water_point .hm-marker__dot,
.hm-svg .hm-marker--drain .hm-marker__dot,
.hm-svg .hm-marker--hvac_vent .hm-marker__dot,
.hm-editor__svg .hm-marker--water_point .hm-marker__dot,
.hm-editor__svg .hm-marker--drain .hm-marker__dot,
.hm-editor__svg .hm-marker--hvac_vent .hm-marker__dot {
  fill: #4A8F96;
}

.hm-svg .hm-marker--note .hm-marker__dot,
.hm-svg .hm-marker--photo .hm-marker__dot,
.hm-svg .hm-marker--equipment .hm-marker__dot,
.hm-svg .hm-marker--other .hm-marker__dot,
.hm-editor__svg .hm-marker--note .hm-marker__dot,
.hm-editor__svg .hm-marker--photo .hm-marker__dot,
.hm-editor__svg .hm-marker--equipment .hm-marker__dot,
.hm-editor__svg .hm-marker--other .hm-marker__dot {
  fill: #6B6560;
}

.hm-svg .hm-marker__glyph,
.hm-editor__svg .hm-marker__glyph {
  fill: #fff;
  font-weight: 700;
  font-size: 0.72em;
  pointer-events: none;
}

.hm-svg .hm-marker__label,
.hm-editor__svg .hm-marker__label {
  fill: var(--hm-label-fill);
  font-size: 0.75em;
  opacity: var(--hm-marker-label-opacity, 0);
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.hm-svg .hm-marker.is-selected .hm-marker__label,
.hm-svg .hm-marker:hover .hm-marker__label,
.hm-editor__svg .hm-marker.is-selected .hm-marker__label,
.hm-editor__svg .hm-marker:hover .hm-marker__label {
  opacity: 1;
}

.hm-svg .hm-marker.is-selected .hm-marker__dot,
.hm-editor__svg .hm-marker.is-selected .hm-marker__dot {
  stroke: var(--primary, #F2A938);
  stroke-width: 2;
}

/* Openings — architectural, theme-aware */
.hm-opening__frame {
  stroke: var(--hm-wall-stroke);
  pointer-events: none;
}

.hm-opening__cut {
  stroke: var(--hm-canvas-bg);
  pointer-events: none;
}

/* Door leaf + swing arc (architectural convention). */
.hm-opening__leaf {
  stroke: var(--hm-wall-stroke);
  pointer-events: none;
}

.hm-opening__arc {
  fill: none;
  stroke: var(--hm-opening-detail);
  stroke-dasharray: 4 3;
  pointer-events: none;
}

/* Window glass: thin double lines at the wall faces. */
.hm-opening__glass {
  fill: none;
  stroke: var(--hm-opening-detail);
  pointer-events: none;
}

/* Sliding door: two offset half-leaves. */
.hm-opening__slide {
  stroke: var(--hm-opening-detail);
  pointer-events: none;
}

.hm-opening__hatch {
  stroke: rgba(124, 92, 59, 0.6);
  pointer-events: none;
}

.hm-opening.is-selected .hm-opening__frame,
.hm-opening.is-selected .hm-opening__leaf {
  stroke: var(--primary, #F2A938);
}

.hm-opening.is-locked .hm-opening__leaf {
  stroke: #b26a00;
}

.hm-opening__block {
  fill: rgba(148, 114, 77, 0.16);
  stroke: rgba(124, 92, 59, 0.55);
}

[data-theme="dark"] .hm-opening__block {
  fill: rgba(148, 114, 77, 0.12);
  stroke: rgba(180, 150, 110, 0.45);
}

.hm-opening__label {
  fill: var(--hm-measure-fill);
  font-size: 0.72em;
  opacity: 0.75;
  pointer-events: none;
}

.hm-opening.is-selected .hm-opening__block {
  stroke: var(--primary, #F2A938);
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.18);
}

/* —— Placed objects (furniture / exterior / technical symbols) —— */
.hm-object use {
  pointer-events: none;
  /* V3 polish: consistent soft shadow grounds every symbol on the plan. */
  filter: var(--hm-depth-object, none);
}

.hm-object {
  cursor: pointer;
}

.hm-object--locked {
  cursor: not-allowed;
}

.hm-object__outline {
  fill: none;
  stroke: var(--primary, #F2A938);
  stroke-dasharray: 6 4;
  pointer-events: none;
}

.hm-svg .hm-object:hover use,
.hm-editor__svg .hm-object:hover use {
  opacity: 0.85;
}

/* —— Object transform handles (editor selection chrome) —— */
.hm-thandle__box {
  fill: none;
  stroke: var(--primary, #F2A938);
  pointer-events: none;
}

.hm-thandle__stem {
  stroke: var(--primary, #F2A938);
  pointer-events: none;
}

.hm-thandle {
  fill: var(--surface, #FFFFFF);
  stroke: var(--primary, #F2A938);
  filter: drop-shadow(0 1px 1.5px rgba(20, 16, 12, 0.28));
  transition: fill 0.1s ease;
}

.hm-thandle:hover {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.25);
}

.hm-thandle--rotate {
  fill: var(--primary, #F2A938);
  stroke: var(--surface, #FFFFFF);
}

.hm-thandle--rotate:hover {
  fill: var(--primary, #F2A938);
  filter: drop-shadow(0 1px 3px rgba(20, 16, 12, 0.4));
}

.hm-thandle__hint {
  fill: var(--hm-label-fill, #2A2622);
  paint-order: stroke;
  stroke: var(--hm-canvas-bg, #F4F0E8);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

/* —— Floor material picker (room selection panel) —— */
.hm-mat-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hm-mat-picker__group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  margin: 8px 0 2px;
}

.hm-mat-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}

.hm-mat-swatch {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--ink-muted);
  text-align: center;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.hm-mat-swatch:hover:not(:disabled) {
  border-color: rgba(var(--primary-rgb), 0.4);
  color: var(--ink);
}

.hm-mat-swatch.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  color: var(--ink);
}

.hm-mat-swatch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hm-mat-swatch__art {
  display: block;
  width: 100%;
  height: 30px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--hm-canvas-bg);
}

.hm-mat-swatch__art--none {
  background:
    linear-gradient(
      to top right,
      transparent calc(50% - 1px),
      var(--ink-dim) calc(50% - 1px),
      var(--ink-dim) calc(50% + 1px),
      transparent calc(50% + 1px)
    ),
    var(--hm-room-fill, #F9F6F0);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.hm-mat-swatch__label {
  font-size: 10px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* —— Object library palette (editor right panel) —— */
.hm-objects__search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
}

.hm-objects__search:focus {
  outline: none;
  border-color: rgba(var(--primary-rgb), 0.5);
}

.hm-objects__body {
  max-height: 340px;
  overflow-y: auto;
  padding-right: 2px;
}

.hm-objects__category {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  margin: 10px 0 6px;
}

.hm-objects__category:first-child {
  margin-top: 0;
}

.hm-objects__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}

.hm-objects__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--ink-muted);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.hm-objects__item:hover {
  border-color: rgba(var(--primary-rgb), 0.4);
  color: var(--ink);
}

.hm-objects__item.is-active {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
}

.hm-objects__thumb {
  width: 44px;
  height: 34px;
  overflow: visible;
}

.hm-objects__name {
  font-size: 10.5px;
  line-height: 1.25;
  text-align: center;
}

/* Networks — muted, non-neon */
.hm-svg .hm-net-edge,
.hm-editor__svg .hm-net-edge {
  opacity: var(--hm-net-opacity, 0.78);
}

.hm-svg .hm-net-node__dot,
.hm-editor__svg .hm-net-node__dot {
  opacity: var(--hm-net-opacity, 0.78);
}

.hm-svg .hm-net-node__label,
.hm-editor__svg .hm-net-node__label {
  fill: var(--hm-label-area-fill);
  font-size: 0.72em;
  opacity: var(--hm-marker-label-opacity, 0);
  pointer-events: none;
}

.hm-svg .hm-net-node.is-selected .hm-net-node__label,
.hm-svg .hm-net-node:hover .hm-net-node__label,
.hm-editor__svg .hm-net-node.is-selected .hm-net-node__label,
.hm-editor__svg .hm-net-node:hover .hm-net-node__label {
  opacity: 1;
}

.hm-canvas-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.hm-svg,
.hm-editor__svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  cursor: grab;
}

.hm-svg.is-dragging,
.hm-editor__svg.is-panning {
  cursor: grabbing;
}

.hm-editor__svg {
  cursor: crosshair;
}

.hm-canvas-bar--top {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
}

.hm-canvas-bar--bottom {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.hm-view-mode {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.hm-view-mode--active {
  color: var(--primary);
  border-color: rgba(var(--primary-rgb), 0.4);
  background: rgba(var(--primary-rgb), 0.1);
}

.hm-level-select summary,
.hm-level-label {
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
  list-style: none;
  padding: 4px 8px;
  border-radius: var(--r-xs);
}

.hm-level-select summary::-webkit-details-marker { display: none; }

.hm-level-select__menu {
  position: absolute;
  margin: 6px 0 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-2);
  min-width: 180px;
  z-index: 5;
}

.hm-level-select__menu a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  font-size: 13px;
  color: var(--ink);
}

.hm-level-select__menu a[aria-current="page"] {
  background: var(--nav-active-bg);
  color: var(--primary);
}

.hm-zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.hm-zoom-btn:hover {
  background: var(--overlay-hover-strong);
}

.hm-zoom-btn--text {
  font-size: 12px;
  min-width: auto;
}

.hm-zoom-label {
  min-width: 48px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}

/* —— Right panels —— */
.hm-panel {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.hm-panel__title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hm-panel__subtitle {
  margin: 12px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}

.hm-panel__cta {
  width: 100%;
  margin-top: 12px;
}

.hm-overview {
  margin: 0;
}

.hm-overview__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.hm-overview__row:last-child {
  border-bottom: 0;
}

.hm-overview__row dt {
  font-size: 12px;
  color: var(--ink-dim);
}

.hm-overview__row dd {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hm-overview__value {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.hm-overview__sub {
  font-size: 13px;
  color: var(--ink-muted);
}

.hm-layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hm-layer-list__label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
}

.hm-layer-list__label:hover {
  background: var(--overlay-hover);
}

.hm-layer-list__icon svg,
.hm-tool-rail__btn svg,
.hm-zoom-btn svg {
  width: 18px;
  height: 18px;
  max-width: 18px;
  max-height: 18px;
  flex: 0 0 18px;
}

.hm-layer-list__name {
  flex: 1;
}

.hm-layer-list__lock {
  font-size: 12px;
  opacity: 0.7;
}

/* —— Tool rail (editor) —— */
.hm-tool-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  align-self: stretch;
}

.hm-tool-rail__inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hm-tool-rail__group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  padding: 8px 4px 4px;
}

.hm-tool-rail__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.hm-tool-rail__btn:hover {
  background: var(--overlay-hover);
  color: var(--ink);
}

.hm-tool-rail__btn.is-active {
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.35);
  color: var(--primary);
}

.hm-tool-rail__btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Smart drawing assist */
.hm-drawing-mode {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.hm-drawing-mode__hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-muted);
}

.hm-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.hm-segmented__btn {
  border: 0;
  border-radius: var(--r-xs);
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
}

.hm-segmented__btn:hover {
  color: var(--ink);
  background: var(--overlay-hover-strong);
}

.hm-segmented__btn.is-active {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.14);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.25);
}

.hm-smart__path {
  stroke: var(--primary, #F2A938);
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.hm-smart__preview {
  stroke: rgba(var(--primary-rgb, 242, 169, 56), 0.75);
  stroke-dasharray: 6 4;
  stroke-linecap: round;
  pointer-events: none;
}

.hm-smart__guide {
  stroke: rgba(var(--primary-rgb, 242, 169, 56), 0.55);
  stroke-dasharray: 4 6;
  pointer-events: none;
}

.hm-smart__segment-hit {
  stroke: rgba(var(--primary-rgb, 242, 169, 56), 0.45);
  pointer-events: none;
}

.hm-smart__vertex,
.hm-smart__ghost {
  fill: var(--primary, #F2A938);
  pointer-events: none;
}

.hm-smart__ghost {
  fill: rgba(var(--primary-rgb, 242, 169, 56), 0.35);
  stroke: var(--primary, #F2A938);
  stroke-width: 1.5;
}

.hm-smart__snap-halo,
.hm-smart__close-hint {
  fill: none;
  stroke: var(--primary, #F2A938);
  stroke-width: 2;
  opacity: 0.85;
  pointer-events: none;
}

.hm-smart__close-hint {
  stroke-dasharray: 4 3;
  opacity: 0.55;
}

.hm-smart__label {
  fill: var(--primary, #F2A938);
  font-size: 11px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--hm-canvas-bg, var(--surface));
  stroke-width: 3px;
  pointer-events: none;
}

.hm-inspector {
  gap: 10px;
}

.hm-inspector .hm-editor__panel {
  border: 0;
  padding: 0;
  background: transparent;
}

.hm-inspector .hm-editor__panel + .hm-editor__panel {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.hm-inspector .hm-editor__panel h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin-bottom: 10px;
}

.hm-banner {
  margin: 8px 0 0;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  background: var(--accent-tint-bg);
  border: 1px solid var(--accent-tint-border);
  color: var(--ink-muted);
}

.hm-banner a {
  color: var(--ink);
  font-weight: 500;
}

.hm-empty {
  padding: 32px 24px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.hm-empty--inline {
  margin: 12px 0;
}

.hm-empty h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.hm-empty p {
  margin: 0 0 16px;
  color: var(--ink-muted);
  font-size: 14px;
}

.hm-editor__fallback {
  padding: 24px;
  color: var(--ink-muted);
  text-align: center;
}

/* Legacy viewer grid — keep for embed */
.hm-viewer--embed .hm-canvas {
  min-height: 300px;
}

@media (max-width: 980px) {
  .hm-workspace {
    grid-template-columns: 1fr;
  }

  .hm-workspace__body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(280px, 50vh) auto;
  }

  .hm-tool-rail {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .hm-tool-rail__inner {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .hm-workspace__panel {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .hm-page__bar {
    flex-direction: column;
  }

  .hm-canvas-bar--bottom {
    left: 12px;
    transform: none;
    right: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* —— Focus mode (distraction-free map workspace) —— */
body.hm-focus-active {
  overflow: hidden;
}

.hm-page.hm-focus-mode {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  padding: 8px 12px 10px;
  margin: 0;
  background: var(--bg);
  box-sizing: border-box;
  overflow: hidden;
}

.hm-page.hm-focus-mode .hm-focus-hide {
  display: none !important;
}

.hm-page.hm-focus-mode .hm-page__bar {
  padding: 6px 0 8px;
  flex-shrink: 0;
}

.hm-page.hm-focus-mode .hm-page__intro {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.hm-page.hm-focus-mode .hm-page__title {
  font-size: 18px;
}

.hm-page.hm-focus-mode .hm-page__meta {
  margin: 0;
  font-size: 13px;
}

.hm-page.hm-focus-mode .hm-workspace,
.hm-page.hm-focus-mode .hm-workspace__body {
  flex: 1;
  min-height: 0;
  margin-top: 4px;
}

.hm-page.hm-focus-mode .hm-workspace--editor {
  flex: 1;
  min-height: 0;
}

.hm-focus-toggle[aria-pressed="true"] {
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.35);
  color: var(--primary);
}

@media (max-width: 980px) {
  .hm-page.hm-focus-mode .hm-workspace__panel {
    max-height: min(40vh, 320px);
    overflow: auto;
  }
}

