:root {
  --bg: #f4f2ec; --panel: #ffffff; --ink: #202923; --muted: #5d675f; --line: #dedfd7;
  --accent: #2f7a5a; --accent-soft: #e4f0e8; --danger: #b43a24;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
button, .button, .as-button, summary {
  font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 11px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover:not(:disabled), .button:hover, summary:hover, .as-button:hover { border-color: #b9bcb2; }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed=true], button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; background: #fff; }
input[type=range] { padding: 0; width: 100%; accent-color: var(--accent); }
input[type=color] { padding: 0; width: 34px; height: 30px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 3; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 19px; letter-spacing: -.02em; color: var(--accent); }
.brand input { border-color: transparent; font-weight: 600; width: 200px; }
.brand input:hover, .brand input:focus { border-color: var(--line); }
.tabs { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 10px; }
.tabs button { border: 0; background: none; padding: 6px 14px; }
.tabs button[aria-selected=true] { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 240px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 10; }
.menu-list button, .menu-list .as-button { border: 0; justify-content: flex-start; }
.menu-list button:hover, .menu-list .as-button:hover { background: var(--bg); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }
.support { color: #a3364b; border-color: #efc9d1; }

main { flex: 1; display: grid; grid-template-columns: var(--tools-w, 200px) 1fr var(--inspector-w, 270px); min-height: 0; }
.tools, .inspector { background: var(--panel); overflow-y: auto; padding: 12px; }
.tools { border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.inspector { border-left: 1px solid var(--line); }
.tools h3, .inspector h3 { margin: 10px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tools h3:first-child, .inspector h3:first-child { margin-top: 0; }
.tool { justify-content: flex-start; width: 100%; }
.tool .ic { width: 20px; text-align: center; }
.stage { position: relative; min-width: 0; min-height: 0; }
#view { position: absolute; inset: 0; touch-action: none; }
#view canvas { display: block; width: 100%; height: 100%; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label { position: absolute; transform: translate(-50%, -50%); background: rgba(255,255,255,.88); padding: 2px 7px; border-radius: 6px; font-size: 12px; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.12); text-align: center; line-height: 1.25; }
.label small { color: var(--muted); display: block; }
.label.measure { background: var(--accent); color: #fff; font-weight: 600; }
.hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; background: rgba(32,41,35,.82); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; max-width: calc(100% - 24px); text-align: center; pointer-events: none; }
.hint:empty { display: none; }
.toast { position: absolute; z-index: 3; top: 12px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15); max-width: 90%; }
.toast input { width: 100%; margin-top: 6px; font-size: 12px; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.swatch { width: 100%; aspect-ratio: 1; border-radius: 8px; border: 2px solid transparent; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatch[aria-pressed=true] { border-color: var(--accent); background-clip: padding-box; outline: 2px solid #fff; outline-offset: -4px; }
.field { display: grid; gap: 3px; margin: 8px 0; }
.field > span { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.lamp-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.lamp-row span { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.danger { color: var(--danger); }
.big-number { font-size: 22px; font-weight: 600; }
.soon { background: var(--accent-soft); border-radius: 10px; padding: 10px; }

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .tools { flex-direction: row; align-items: center; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .tools .swatches { grid-template-columns: repeat(15, 30px); }
  .tools .field { margin: 0; min-width: 120px; }
  .hint { top: 8px; bottom: auto; font-size: 12px; }
  .tools h3 { display: none; }
  .tool { width: auto; flex: 0 0 auto; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); max-height: 28vh; }
  .brand input { width: 130px; }
  #wall-modes button { padding: 6px 8px; }
}
/* Furnish: product shelf, product details and shopping list */
body[data-tab=furnish] main { grid-template-columns: var(--shelf-w, 320px) 1fr var(--inspector-w, 280px); }
body[data-tab=furnish] .tools { padding: 0; gap: 0; }
.shelf-head { position: sticky; top: 0; background: var(--panel); padding: 10px 10px 8px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; z-index: 1; }
.shelf-head input[type=search] { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 3px 9px; border-radius: 999px; font-size: 12px; }
.shelf { display: grid; gap: 6px; padding: 8px 10px 14px; }
.card { display: grid; grid-template-columns: 72px 1fr; gap: 9px; align-items: center; text-align: left; white-space: normal; padding: 6px; border-radius: 10px; }
.card img { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 6px; }
.card-text { display: grid; gap: 1px; min-width: 0; line-height: 1.25; }
.card-text strong { font-size: 13px; }
.card .price { font-weight: 600; margin-top: 2px; }
.card[aria-pressed=true] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.card[aria-pressed=true] .muted { color: var(--muted); }
.product-photo { width: 100%; max-height: 170px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.buy { justify-content: center; width: 100%; font-weight: 600; }
.disclosure { margin: 6px 0; }
dialog.shop-list { border: 0; border-radius: 14px; padding: 0; width: min(720px, 96vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.shop-list::backdrop { background: rgba(20,25,22,.45); }
.shop-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; max-height: 92vh; overflow: auto; }
.shop-body header { display: flex; align-items: center; justify-content: space-between; }
.shop-body h2 { margin: 0; font-size: 18px; }
.shop-body .close { border: 0; }
.shop-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.shop-lines li { display: grid; grid-template-columns: 56px 1fr auto auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.shop-lines img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 6px; }
.shop-sum { font-weight: 600; white-space: nowrap; }
.shop-total { display: flex; justify-content: space-between; font-size: 16px; margin: 6px 0 0; }
/* Ready rooms */
dialog.starters { border: 0; border-radius: 16px; padding: 0; width: min(640px, 96vw); max-height: 94vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.starters::backdrop { background: rgba(20,25,22,.45); }
.start-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; max-height: 94vh; overflow: auto; }
.start-body header { display: flex; align-items: center; justify-content: space-between; }
.start-body h2 { margin: 0; font-size: 20px; }
.start-body .close { border: 0; }
.steps { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: step; flex-wrap: wrap; }
.steps li { counter-increment: step; background: var(--accent-soft); border-radius: 999px; padding: 4px 12px 4px 6px; font-size: 13px; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; margin-right: 6px; }
.starter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.starter { flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; border-radius: 12px; white-space: normal; text-align: left; }
.starter:hover { border-color: var(--accent); background: var(--accent-soft); }
.starter-ic { font-size: 26px; line-height: 1.2; }
.start-more { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; }
.tips { background: var(--accent-soft); border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
.tips ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.size-row .field { margin: 4px 0; }
.size-row input { width: 100%; }
[hidden] { display: none !important; }

dialog.upload { border: 0; border-radius: 14px; padding: 0; width: min(760px, 96vw); max-height: 94vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.upload::backdrop { background: rgba(20,25,22,.45); }
.upload-body { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; max-height: 94vh; overflow: auto; }
.upload-body header { display: flex; align-items: center; justify-content: space-between; }
.upload-body h2 { margin: 0; font-size: 18px; }
.upload-body .close { border: 0; }
.upload-body footer { display: flex; justify-content: flex-end; gap: 8px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 16px; border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; text-align: center; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.up-preview { background: #f0efe9; border-radius: 10px; overflow: hidden; display: flex; justify-content: center; }
.up-preview canvas { max-width: 100%; max-height: 46vh; cursor: crosshair; display: block; }
.up-scale { border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 6px; }
.up-scale legend { font-weight: 600; padding: 0 4px; }

@media (max-width: 860px) {
  body[data-tab=furnish] main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 32%) 1fr auto; }
  body[data-tab=furnish] .inspector { max-height: 20vh; }
  .shelf-head { padding: 6px 8px; gap: 6px; }
  .shelf { padding: 6px 8px 10px; gap: 5px; }
  .card { padding: 4px; gap: 6px; }
  .card-text > span.small:not(.muted) { display: none; }
  body[data-tab=furnish] .tools { flex-direction: column; align-items: stretch; overflow-y: auto; padding: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; }
  .chip { flex: 0 0 auto; }
  .shelf { grid-template-columns: 1fr 1fr; }
  .card { grid-template-columns: 52px 1fr; }
  .card img { width: 52px; height: 52px; }
  .shop-lines li { grid-template-columns: 44px 1fr auto; }
  .shop-lines li .button { grid-column: 2 / -1; justify-content: center; }
  .shop-lines img { width: 44px; height: 44px; }
}

/* Exit, camera and walk controls, panel resizing */
.exit { border-color: transparent; color: var(--muted); padding: 6px 8px; }
.exit:hover { color: var(--ink); }
.camera-pad, .walk-pad { position: absolute; right: 12px; top: 12px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.1); display: grid; gap: 6px; z-index: 2; }
.camera-pad[hidden], .walk-pad[hidden] { display: none; }
/* The camera box folds into a small button in the corner and opens out of it again. */
.camera-pad { padding-top: 22px; transform-origin: top right; transition: transform .28s cubic-bezier(.3,.7,.2,1), opacity .22s ease; }
.camera-pad .pad-close { position: absolute; top: 2px; right: 4px; border: 0; background: none; padding: 0 6px; font-size: 14px; line-height: 18px; color: var(--muted); min-width: 0; }
.camera-pad .pad-close:hover { color: var(--ink); }
body.cam-folded .camera-pad { transform: scale(.12); opacity: 0; pointer-events: none; }
.camera-open { position: absolute; right: 12px; top: 12px; z-index: 2; width: 40px; height: 40px; justify-content: center; padding: 0; border-radius: 12px; font-size: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.1); opacity: 0; transform: scale(.6); pointer-events: none; transition: opacity .2s ease .12s, transform .2s ease .12s; }
body.cam-folded .camera-open { opacity: 1; transform: none; pointer-events: auto; }
body[data-view=plan] .camera-open, body[data-view=walk] .camera-open { display: none; }
.pad-row { display: flex; gap: 4px; }
.pad-row button { flex: 1; justify-content: center; min-width: 38px; padding: 6px 8px; }
.pad-row button[data-cam=left], .pad-row button[data-cam=right], .pad-row button[data-cam=in], .pad-row button[data-cam=out] { font-size: 17px; line-height: 1; }
.pad-help { margin: 0; font-size: 11px; color: var(--muted); text-align: center; }
.pad-grid { display: grid; grid-template-columns: repeat(3, 46px); gap: 4px; justify-content: center; }
.pad-grid button { height: 42px; justify-content: center; font-size: 16px; touch-action: none; user-select: none; }
.walk-pad > button { justify-content: center; }
.resizer { position: absolute; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2; touch-action: none; }
.resizer.left { left: -4px; }
.resizer.right { right: -4px; }
.resizer:hover, .resizer:active { background: rgba(47,122,90,.25); }
body[data-view=walk] #wall-modes { display: none; }
.angle-row input[type=range] { flex: 3; }
.angle-row .deg { flex: 1; display: flex; align-items: center; gap: 2px; }
.angle-row .deg input { width: 100%; }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #fff; }
.shop-lines li.opened { opacity: .7; }
.shop-how { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-top: 10px; line-height: 1.45; }
.shop-how .row { margin-top: 8px; }
.shop-how .row > * { flex: 0 0 auto; }
@media (max-width: 860px) {
  .resizer { display: none; }
  .camera-pad { right: 8px; top: 8px; padding: 6px; }
  .pad-help { display: none; }
  .pad-row button { min-width: 34px; padding: 5px 6px; }
}
.walk-pad { top: auto; bottom: 56px; }
body[data-view=walk] .hint { display: none; }
.toast { padding-right: 36px; }
.toast-close { position: absolute; top: 5px; right: 5px; border: 0; padding: 2px 7px; font-size: 13px; color: var(--muted); background: none; }
.time-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.time-presets button { justify-content: center; }
.remove-line { border-color: transparent; color: var(--muted); padding: 6px 8px; }
.remove-line:hover { color: var(--danger); }
/* My homes */
dialog.homes { border: 0; border-radius: 16px; padding: 0; width: min(760px, 96vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.homes::backdrop { background: rgba(20,25,22,.45); }
.homes-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; max-height: 92vh; overflow: auto; }
.homes-body header { display: flex; align-items: center; justify-content: space-between; }
.homes-body h2 { margin: 0; font-size: 20px; }
.homes-body .close { border: 0; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.home-card { border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.home-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.home-open { border: 0; padding: 0; flex-direction: column; align-items: flex-start; gap: 2px; white-space: normal; text-align: left; }
.home-open img, .home-noimg { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-size: 30px; }
.home-card .row button { flex: 1; justify-content: center; padding: 4px 6px; font-size: 12px; }
.home-new { align-items: center; justify-content: center; font-size: 26px; min-height: 150px; border-style: dashed; white-space: normal; }
.home-new strong { font-size: 14px; }

/* Furniture still loading in a saved home */
.scene-loading { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2; padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.92); box-shadow: 0 2px 10px rgba(0,0,0,.12); font-size: 13px; color: #3c4038; pointer-events: none; }
.scene-loading::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border: 2px solid #9aa391; border-top-color: transparent; border-radius: 50%; vertical-align: -1px; animation: scene-spin .8s linear infinite; }
@keyframes scene-spin { to { transform: rotate(360deg); } }

/* Paint tab: the left panel only explains; the right panel paints what you clicked. */
.paint-steps { margin: 4px 0 10px; padding-left: 20px; line-height: 1.5; font-size: 13px; }
.paint-steps li { margin-bottom: 6px; }
