/* Houses plan editor: the editing layer over the plan, its tools and the furniture palette. Tokens from styles.css. */

/* The layer covers the plan overlay exactly (same box, same viewBox) and takes the pointer; the overlay below draws. */
.hs-plan-edit { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; user-select: none; -webkit-user-select: none; }
.hs-plan-edit * { vector-effect: non-scaling-stroke; }
.hs-plan-edit .he-hit { fill: transparent; stroke: none; }
.he-frame { fill: none; stroke: var(--border-strong); stroke-width: 1px; stroke-dasharray: 5 4; pointer-events: none; }
.he-size { fill: var(--text-muted); font-family: var(--font-label); pointer-events: none; }
.he-grip { touch-action: none; }
.he-grip rect { fill: var(--bg-card); stroke: var(--text); stroke-width: 1.5px; }
.he-grip:hover rect { fill: var(--primary); stroke: var(--primary); }
.he-grip-e { cursor: ew-resize; }
.he-grip-s { cursor: ns-resize; }
.he-grip-se { cursor: nwse-resize; }
.he-room { fill: transparent; stroke: none; cursor: move; }
.he-room.selected { stroke: var(--primary); stroke-width: 2.5px; touch-action: none; }
.he-room.invalid { stroke: var(--danger); stroke-width: 2.5px; stroke-dasharray: 6 4; }
.he-handle { touch-action: none; }
.he-handle rect:not(.he-hit), .he-handle circle:not(.he-hit) { fill: var(--bg-card); stroke: var(--primary); stroke-width: 2px; }
.he-handle:hover rect:not(.he-hit), .he-handle:hover circle:not(.he-hit), .he-handle.active rect:not(.he-hit), .he-handle.active circle:not(.he-hit) { fill: var(--primary); }
.he-edge-h { cursor: ns-resize; }
.he-edge-v { cursor: ew-resize; }
.he-corner { cursor: move; }
.he-opening { fill: transparent; stroke: none; cursor: grab; touch-action: none; }
.he-opening:hover, .he-opening.selected { stroke: var(--primary); stroke-width: 1.5px; stroke-dasharray: 3 3; }
.he-piece { cursor: grab; outline: none; touch-action: none; }
.he-piece:active { cursor: grabbing; }
.he-footprint { fill: var(--primary-bg); fill-opacity: .92; stroke: var(--primary); stroke-width: 1.5px; }
.he-kind-flat .he-footprint { fill-opacity: .45; stroke-dasharray: 5 3; }
.he-back { fill: none; stroke: var(--primary); stroke-width: 3px; stroke-linecap: round; }
.he-piece text { fill: var(--text); font-family: var(--font-body); font-weight: 600; pointer-events: none; paint-order: stroke; stroke: var(--bg-card); stroke-width: 3px; stroke-linejoin: round; }
.he-piece.selected .he-footprint, .he-piece:focus-visible .he-footprint { stroke: var(--text); stroke-width: 3px; }
.he-piece.outside .he-footprint { stroke: var(--danger); stroke-dasharray: 6 4; }
.he-ghost { fill: var(--primary-bg); fill-opacity: .7; stroke: var(--primary); stroke-width: 2px; stroke-dasharray: 6 4; pointer-events: none; }
.he-ghost.bad { fill: transparent; stroke: var(--danger); }
.hs-stage.he-drop-active { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Tools above the drawing: house size, room shape, history. Their height never changes with the selection, so the
   drawing does not move under the pointer. */
.he-tools { display: grid; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg-card); }
.he-tools-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.he-size-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.hs-page .he-size-form label { margin: 0; font-size: 12px; color: var(--text-muted); }
.he-size-form input[type="number"] { width: 92px; margin: 0; padding: 8px 10px; }
.he-check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.hs-page .he-check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--primary); }
.he-tools .button { font-size: 12px; padding: 8px 12px; border: 1px solid var(--border); }
.he-tools .button[aria-pressed="true"] { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
.he-history { margin-left: auto; display: flex; gap: 6px; }
.he-room-tools { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border); }
.he-room-tools strong { font-size: 13px; margin-right: 6px; overflow-wrap: anywhere; flex: 1 1 180px; min-width: 0; }

/* Under the drawing: what the last action did, what is wrong with the plan, and the pieces placed by hand. */
.he-status { display: grid; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--bg-card); }
.he-notice { font-size: 12px; line-height: 1.6; color: var(--text-muted); margin: 0; overflow-wrap: anywhere; }
.he-issues { margin: 0; padding: 8px 12px 8px 28px; font-size: 12px; line-height: 1.6; color: var(--text); background: var(--primary-bg); border-left: 2px solid var(--danger); }
.he-on-plan { padding-top: 12px; border-top: 1px solid var(--border); }
.he-on-plan-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.he-on-plan-heading h3 { font-size: 15px; }
.he-on-plan .form-note { margin-top: 6px; }
.he-placed { list-style: none; margin: 10px 0 0; padding: 2px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.he-placed:empty { display: none; }
.he-placed-button { width: 100%; min-height: 44px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px 12px; text-align: left; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--bg-card); color: var(--text); font: inherit; cursor: pointer; }
.he-placed-button span { font-size: 13px; overflow-wrap: anywhere; }
.he-placed-button small { font-size: 11px; color: var(--text-muted); }
.he-placed-button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-bg); }
.he-placed-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.he-piece-panel { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--bg-subtle); }
.he-piece-panel strong { font-size: 13px; overflow-wrap: anywhere; flex: 1 1 160px; min-width: 0; }
.hs-page .he-piece-panel label { margin: 0; font-size: 12px; color: var(--text-muted); }
.he-piece-panel select { width: auto; max-width: 100%; margin: 0; }
.he-piece-panel .button { font-size: 12px; padding: 8px 12px; }

/* Furniture palette: the Collection as draggable cards. A strip under the drawing by default; a column beside it
   on a wide screen, as in the Package Builder. */
.he-furnish { border-top: 1px solid var(--border); min-width: 0; }
.he-furnish-inner { padding: 16px 20px; }
/* No house, or a new one being set up: the stage is empty and the editing tools have nothing to work on. */
.hs-workspace:has(> .hs-stage-empty) :is(.he-tools, .he-status, .he-furnish) { display: none; }
.he-furnish-heading h3 { font-size: 17px; margin-top: 6px; }
.he-furnish-heading h3 .optional { font-size: 10px; font-family: var(--font-label); color: var(--text-muted); margin-left: 6px; }
.he-help { font-size: 12px; line-height: 1.6; color: var(--text-muted); margin: 8px 0 12px; max-width: 720px; }
.he-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.he-filters input { flex: 2 1 200px; min-width: 0; margin: 0; }
.he-filters select { flex: 1 1 160px; min-width: 0; margin: 0; }
#he-load-status { font-size: 12px; line-height: 1.5; margin: 10px 0 0; overflow-wrap: anywhere; }
#he-retry { margin-top: 8px; }
.he-products { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px 4px; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.he-products:empty { display: none; }
.he-products:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.he-product { flex: 0 0 248px; display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--card-radius-sm); background: var(--bg-card); cursor: grab; scroll-snap-align: start; min-width: 0; }
.he-product:hover { border-color: var(--primary); }
.he-product:active { cursor: grabbing; }
.he-product-photo { flex: 0 0 48px; width: 48px; height: 56px; display: grid; place-items: center; overflow: hidden; background: var(--bg-subtle); color: var(--text-muted); font-size: 9px; line-height: 1.3; text-align: center; }
.he-product-photo img { width: 100%; height: 100%; object-fit: contain; }
.he-product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.he-product-info h4 { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.he-product-info p { font-size: 11px; line-height: 1.4; color: var(--text-muted); overflow-wrap: anywhere; margin: 0; }
.he-product .he-add { flex: 0 0 auto; min-width: 44px; padding: 8px 10px; font-size: 12px; }

@media (min-width: 1180px) {
  /* The drawing and the Collection share a row; everything else in the workspace keeps its full width. */
  .hs-workspace:has(> .he-furnish:not([hidden])):not(:has(> .hs-stage-empty)) { display: grid; grid-template-columns: minmax(0, 1fr) 272px; }
  .hs-workspace:has(> .he-furnish:not([hidden])):not(:has(> .hs-stage-empty)) > * { grid-column: 1 / -1; min-width: 0; }
  .hs-workspace:has(> .he-furnish:not([hidden])):not(:has(> .hs-stage-empty)) > .hs-stage { grid-column: 1; }
  .hs-workspace:has(> .he-furnish:not([hidden])):not(:has(> .hs-stage-empty)) > .he-furnish { grid-column: 2; position: relative; border-top: 0; border-left: 1px solid var(--border); background: var(--bg-card); }
  /* The column is as tall as the drawing and scrolls inside: it adds no height of its own to the row. */
  .he-furnish-inner { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 14px; overflow: hidden; }
  /* The line under the filters already says how to place a piece; the column keeps its height for the list. */
  .he-help { display: none; }
  .he-filters { margin-top: 10px; }
  .he-filters input, .he-filters select { flex: 1 1 100%; }
  .he-products { flex: 1; min-height: 0; flex-direction: column; overflow-x: hidden; overflow-y: auto; padding: 10px 4px 2px 2px; overscroll-behavior: contain; scroll-snap-type: none; }
  .he-product { flex: 0 0 auto; }
}
@media (max-width: 600px) {
  .he-tools, .he-status { padding-left: 16px; padding-right: 16px; }
  .he-furnish-inner { padding: 16px; }
  .he-history { margin-left: 0; }
  .he-product { flex-basis: 232px; }
  .he-placed { grid-template-columns: 1fr; }
}
