:root {
  color-scheme: light;
  --paper: #f5f1e9; --surface: #fffcf6; --ink: #242520; --muted: #68675c;
  --line: #dfd9cd; --accent: #84372f; --pale: #f1e2d7; --deep: #272922;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper); color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible { outline: 3px solid #be6350; outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
[hidden] { display: none !important; }
.page-width { width: min(1480px, calc(100% - 88px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--line); }
.mast-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand svg { color: var(--accent); flex: none; width: 24px; height: 30px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 12px; letter-spacing: .17em; }
.brand span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.studio-back { display:flex; align-items:center; gap:5px; padding:6px 0; color:var(--accent); font-size:12px; font-weight:650; text-decoration:none; white-space:nowrap; }
.studio-back:hover { text-decoration:underline; }
.studio-back:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.studio-back svg { flex:none; }
@media (pointer:coarse) { .studio-back { min-height:44px; } }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; padding: 31px 0 25px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .16em; margin: 0 0 8px; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; margin: 0; }
h1 { font-size: clamp(39px, 5vw, 76px); letter-spacing: -.066em; line-height: 1.04; }
.intro-copy { margin: 11px 0 0; color: var(--muted); font-size: 15px; }
.facts { display: flex; gap: 23px; padding-bottom: 5px; flex-shrink: 0; }
.facts div { padding-left: 19px; border-left: 1px solid var(--line); }
.facts strong { display: block; font-size: 21px; font-weight: 650; white-space: nowrap; }
.facts small { font-size: 11px; font-weight: 550; }
.facts span { display: block; font-size: 11px; margin-top: 3px; color: var(--muted); }
.studio { display: grid; grid-template-columns: minmax(0,1fr) minmax(255px, 294px); align-items: start; gap: 17px; }
.workspace, .guide { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.toolbar { min-height: 61px; display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; gap: 10px; }
.mode-switch, .level-switch { display: flex; gap: 2px; padding: 3px; background: #efebe2; border-radius: 9px; }
.mode-switch button, .level-switch button, .plan-button {
  border: 0; background: transparent; border-radius: 7px; font-size: 12px; font-weight: 650; padding: 8px 12px; min-height: 36px; white-space: nowrap;
}
.mode-switch button[aria-pressed="true"], .plan-button[aria-pressed="true"] { background: var(--deep); color: white; }
.mode-switch button:hover:not([aria-pressed="true"]), .level-switch button:hover:not([aria-pressed="true"]), .plan-button:hover:not([aria-pressed="true"]) { background: #e6dfd3; }
.plan-button { border: 1px solid var(--line); }
.stage { position: relative; height: clamp(460px, 58vh, 720px); background: #e6e7df; overflow: hidden; isolation: isolate; }
#scene, #plan { display: block; width: 100%; height: 100%; touch-action: none; }
#scene { cursor: grab; background: linear-gradient(#c7d2cf, #e8e7db 65%, #d2d5bf); }
#scene:active { cursor: grabbing; }
#plan { background: #f2eee5; touch-action: pan-y; }
#plan text { font-family: inherit; fill: #383831; paint-order: stroke; stroke: #f2eee5; stroke-width: 3px; stroke-linejoin: round; }
#plan .room-marker { cursor: pointer; }
#plan .room-marker circle { fill: #a45445; stroke: #f8f1e8; stroke-width: .23; }
#plan .room-marker:focus circle, #plan .room-marker:hover circle { fill: #4e2b24; }
#plan .room-marker text { stroke: #f7f3e9; stroke-width: .43; }
.view-label { position: absolute; left: 14px; top: 14px; display: flex; gap: 8px; align-items: center; border-radius: 7px; padding: 8px 10px; color: var(--deep); background: #fffcf3ea; border: 1px solid #ffffff9e; pointer-events: none; box-shadow: 0 2px 10px #40382514; }
.view-label span { color: var(--accent); font-size: 10px; font-weight: 750; }
.view-label strong { font-size: 12px; }
.reset-view, .orbit-controls button, .fullscreen-button, .viewer-actions button, .cancel-placement {
  border: 1px solid #ffffff8a; color: white; background: #252923de; border-radius: 8px; width: 43px; height: 43px; font-size: 21px; font-weight: 520;
}
.reset-view:hover, .orbit-controls button:hover, .fullscreen-button:hover, .viewer-actions button:hover, .cancel-placement:hover { background: #47483c; }
.stage-tools { position:absolute; top:14px; right:14px; display:flex; gap:5px; }
.fullscreen-button { display:flex; align-items:center; justify-content:center; gap:7px; width:auto; padding:0 12px; font-size:11px; font-weight:650; }
.fullscreen-button svg { flex:none; }
.stage-controls { pointer-events: none; position: absolute; bottom: 14px; right: 14px; left: 14px; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.stage-controls button { pointer-events: auto; touch-action: none; }
.hint { font-size: 11px; font-weight: 600; color: white; background: #252923dd; border-radius: 6px; padding: 8px 10px; text-align: right; margin-left: auto; }
.orbit-controls { display: flex; gap: 4px; }
.stage-right { margin-left:auto; display:flex; flex-direction:column; align-items:flex-end; gap:7px; }
.viewer-actions { display:flex; gap:6px; }
.viewer-actions button, .cancel-placement { width:auto; min-width:64px; padding:0 12px; font-size:12px; font-weight:650; }
.viewer-actions button[aria-expanded=true] { background:var(--accent); }
.joystick { position:relative; flex:none; width:106px; height:106px; padding:0; border:1px solid #fffcf3a0; border-radius:50%; color:#fff; background:#1c252856; cursor:grab; user-select:none; -webkit-touch-callout:none; }
.joystick:active { cursor:grabbing; }
.joystick::before, .joystick::after { content:""; position:absolute; top:50%; left:50%; background:#fffaf24d; pointer-events:none; }
.joystick::before { width:65%; height:1px; transform:translate(-50%,-50%); }
.joystick::after { width:1px; height:65%; transform:translate(-50%,-50%); }
.joystick span { position:absolute; z-index:1; top:calc(50% - 18px); left:calc(50% - 18px); width:36px; height:36px; border-radius:50%; border:1px solid #fffcf3bd; background:#fff9eb96; box-shadow:0 2px 9px #1d242256; pointer-events:none; }
.fallback { position: absolute; bottom: 12px; right: 12px; left: 12px; background: var(--deep); color: white; padding: 10px; border-radius: 6px; font-size: 12px; }
.caption { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); padding: 11px 14px; min-height: 40px; font-size: 11px; }
.units { white-space: nowrap; }
.guide { padding: 16px; }
.guide-head { min-height: 173px; }
.guide h2 { font-size: 27px; letter-spacing: -.04em; line-height: 1.08; }
.guide-head > p:not(.eyebrow) { margin: 9px 0 13px; min-height: 48px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.start-walk { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 42px; border: 0; background: var(--accent); color: #fff; padding: 10px 12px; border-radius: 8px; font-size: 12px; font-weight: 650; }
.start-walk:hover { background: #6f2d26; }
.start-walk span { font-size: 17px; }
.level-switch { margin: 13px 0 8px; }
.level-switch button { flex: 1; padding-inline: 7px; }
.level-switch button[aria-pressed="true"] { background: white; box-shadow: 0 1px 4px #50443322; }
.rooms { display: grid; grid-template-columns: 1fr; }
.room { display: flex; justify-content: space-between; align-items: center; gap: 5px; border: 0; border-bottom: 1px solid #eae4d9; padding: 8px 6px; background: transparent; min-height: 32px; text-align: left; font-size: 12px; }
.room span:first-child { font-weight: 650; }
.room span:last-child { color: var(--muted); font-size: 10px; white-space: nowrap; }
.room:hover, .room[aria-current="location"] { background: var(--pale); color: #6e2e26; }
.guide-foot { margin-top: 11px; color: var(--muted); font-size: 10px; }
footer { display: flex; justify-content: space-between; gap: 16px; margin: 13px 0 26px; color: var(--muted); font-size: 11px; }
footer p { margin: 0; }
@media (max-width: 1060px) {
  .page-width { width: calc(100% - 48px); }
  .studio { grid-template-columns: minmax(0,1fr) 255px; }
  .guide { padding: 13px; }
  .stage { height: clamp(420px, 56vh, 690px); }
}
@media (max-width: 790px) {
  .page-width { width: calc(100% - 28px); }
  .mast-inner { min-height: 57px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 15px; padding: 21px 0 16px; }
  .facts { gap: 15px; padding: 0; }
  .facts div { padding-left: 10px; }
  .facts strong { font-size: 17px; }
  .intro-copy { margin-top: 7px; font-size: 14px; }
  .studio { grid-template-columns: minmax(0,1fr); gap: 11px; }
  .stage { height: clamp(358px, 52svh, 570px); }
  .rooms { grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .guide-head { min-height: 0; }
  .guide-head > p:not(.eyebrow) { min-height: 0; }
  footer { flex-direction: column; gap: 5px; line-height: 1.5; }
}
@media (max-width: 420px) {
  .page-width { width: calc(100% - 20px); }
  .toolbar { padding-inline: 7px; gap: 5px; }
  .mode-switch button, .plan-button { font-size: 11px; padding-inline: 8px; }
  .rooms { grid-template-columns: 1fr; }
  .units { display: none; }
}
@media (pointer: coarse) {
  .mode-switch button, .plan-button, .level-switch button, .room { min-height: 44px; }
  .orbit-controls button, .reset-view { width:45px; height:45px; }
  .fullscreen-button, .viewer-actions button, .cancel-placement { min-height:45px; }
}

.sidebar-tabs, .design-tabs { display:flex; padding:3px; gap:2px; border-radius:9px; background:#efebe2; margin-bottom:16px; }
.sidebar-tabs button, .design-tabs button { min-height:36px; flex:1; padding:6px 7px; border:0; border-radius:7px; background:transparent; font-weight:700; font-size:12px; }
.sidebar-tabs button[aria-pressed=true] { background:var(--deep); color:#fff; }
.design-tabs { margin:12px 0; }
.design-tabs button[aria-pressed=true] { background:#fff; box-shadow:0 1px 4px #50443322; }
.field-label { display:block; margin:0 0 6px; color:var(--muted); font-size:11px; font-weight:700; }
#design-panel select { width:100%; min-height:40px; background:#fffdf7; border:1px solid var(--line); border-radius:7px; color:var(--ink); font:inherit; font-size:13px; padding:8px; }
#design-panel h3 { margin:0 0 6px; font-size:13px; }
#paint-name { margin:0 0 9px; color:var(--muted); font-size:12px; }
.swatches { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; }
.swatch { aspect-ratio:1.2; min-height:39px; padding:0; border:1px solid #1919142c; border-radius:7px; background:var(--swatch); }
.swatch[aria-pressed=true] { outline:2px solid var(--accent); outline-offset:1px; }
.custom-color { display:flex; justify-content:space-between; align-items:center; padding:12px 0 7px; font-size:12px; }
.custom-color input { width:44px; height:32px; border:1px solid var(--line); border-radius:5px; padding:2px; background:white; cursor:pointer; }
.text-button { background:none; border:0; color:var(--accent); padding:6px 1px; font-size:11px; font-weight:700; text-decoration:underline; text-underline-offset:2px; }
.design-status { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:10px; padding-top:8px; border-top:1px solid var(--line); font-size:11px; color:var(--muted); line-height:1.4; }
.catalog { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; margin-top:9px; }
.catalog-card { padding:6px; text-align:left; min-width:0; border:1px solid var(--line); background:#f8f4ec; border-radius:7px; }
.catalog-card:hover { border-color:#a86050; background:#f2e7dc; }
.catalog-card canvas { width:100%; aspect-ratio:1.5; display:block; margin-bottom:3px; }
.catalog-card strong { display:block; font-size:11px; line-height:1.22; }
.catalog-card span { display:block; margin-top:3px; font-size:10px; color:var(--muted); }
.check { display:flex; gap:6px; align-items:center; margin-top:10px; font-size:12px; }
.check input { accent-color:var(--accent); }
.placed-list { margin:10px 0 12px; border-block:1px solid var(--line); padding:8px 0; }
.placed-list summary { cursor:pointer; font-size:12px; font-weight:650; }
.placed-list[open] #placed { margin-top:7px; }
#placed { display:grid; gap:4px; font-size:11px; color:var(--muted); }
#placed button, .item-tools button { min-height:33px; text-align:left; padding:5px 7px; border:1px solid var(--line); background:#fffdf7; border-radius:6px; font-size:11px; }
#placed button[aria-pressed=true], .item-tools button[aria-pressed=true] { background:var(--pale); border-color:#bb8b7d; }
.item-tools { display:flex; flex-wrap:wrap; gap:4px; margin-top:7px; }
#plan .item-marker { cursor:pointer; }
#plan .item-marker rect { fill:#8c4f42; fill-opacity:.45; stroke:#713629; stroke-width:.21; }
#plan .item-marker[aria-pressed=true] rect { fill:#a45445; stroke-width:.34; }
#plan.placing { cursor:crosshair; }
.sr-only { position:absolute; height:1px; width:1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
@media(max-width:790px) {
  .swatches { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .swatch { aspect-ratio:auto; height:49px; }
  .catalog { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media(pointer:coarse) {
  .sidebar-tabs button, .design-tabs button, #placed button, .item-tools button, .text-button { min-height:44px; }
}

@media(max-width:790px) {
  .studio.designing .workspace { position:sticky; top:0; z-index:5; box-shadow:0 5px 14px #352c231a; }
  .studio.designing .stage { height:clamp(225px,34svh,356px); }
  .studio.designing .guide { scroll-margin-top:calc(clamp(225px,34svh,356px) + 108px); }
}

body.viewer-open { overflow:hidden; overscroll-behavior:none; }
body.viewer-open > .masthead, body.viewer-open .intro, body.viewer-open footer { visibility:hidden; }
.studio.expanded { display:block; position:fixed; inset:0; width:100%; height:100vh; height:100dvh; z-index:1000; background:var(--deep); }
.studio.expanded .workspace { display:flex; flex-direction:column; position:static; width:100%; height:100%; border:0; border-radius:0; box-shadow:none; }
.studio.expanded .toolbar { flex:none; padding-top:calc(9px + env(safe-area-inset-top)); padding-left:max(12px, env(safe-area-inset-left)); padding-right:max(12px, env(safe-area-inset-right)); }
.studio.expanded .stage { flex:1; height:auto; min-height:0; }
.studio.expanded .stage-controls { bottom:calc(16px + env(safe-area-inset-bottom)); left:max(16px, env(safe-area-inset-left)); right:max(16px, env(safe-area-inset-right)); }
.studio.expanded .stage-tools { right:max(14px, env(safe-area-inset-right)); }
.studio.expanded .view-label { left:max(14px, env(safe-area-inset-left)); }
.studio.expanded .caption, .studio.expanded:not(.panel-open) .guide { display:none; }
.studio.expanded .guide {
  position:absolute; z-index:2; bottom:calc(105px + env(safe-area-inset-bottom)); right:max(16px, env(safe-area-inset-right));
  width:min(330px,calc(100% - 32px)); max-height:calc(100% - 182px); overflow:auto;
  overscroll-behavior:contain; touch-action:pan-y; box-shadow:0 10px 40px #21241f4d;
}
.close-guide { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:0 0 9px auto; padding:5px 8px; min-height:36px; border:1px solid var(--line); border-radius:7px; background:#fffcf6; font-size:12px; }
.close-guide span { font-size:17px; }
.stage[data-mode=walk] { touch-action:none; }
@media (max-width:790px) {
  .studio.expanded .guide { left:max(10px, env(safe-area-inset-left)); right:max(10px, env(safe-area-inset-right)); width:auto; max-height:42%; bottom:calc(100px + env(safe-area-inset-bottom)); }
  .studio.expanded.panel-open .joystick { visibility:hidden; }
}
@media (max-width:470px) {
  .fullscreen-button { width:44px; padding:0; }
  #fullscreen-label { display:none; }
  .view-label { max-width:calc(100% - 127px); }
}
@media (max-height:500px) {
  .studio.expanded .joystick { width:90px; height:90px; }
  .studio.expanded .guide { bottom:calc(84px + env(safe-area-inset-bottom)); max-height:calc(100% - 151px); }
}


.intro-tools { display:flex; flex-wrap:wrap; gap:7px; margin-top:13px; }
.intro-tools button { min-height:38px; padding:7px 12px; border:1px solid var(--accent); border-radius:7px; background:var(--accent); color:#fff; font-size:12px; font-weight:650; }
.intro-tools button:last-child { color:var(--accent); background:var(--surface); }
.intro-tools button:hover { filter:brightness(.94); }
.room-set { margin:7px 0 10px; padding:8px; background:var(--pale); border-radius:7px; }
.room-set p { margin:0 0 7px; color:var(--muted); font-size:11px; line-height:1.45; }
.room-set-button { width:100%; min-height:36px; padding:7px; border:0; border-radius:6px; background:var(--accent); color:white; font-size:12px; font-weight:650; }
.room-set-button:hover { filter:brightness(.92); }
.catalog-card .place-label { color:var(--accent); font-weight:750; }
#plan .item-marker.sample rect { fill:#7f826e; stroke:#585c4a; }
#plan .item-marker[aria-pressed=true] rect { fill:#a45445; stroke:#713629; }
@media (max-width:470px) {
  .viewer-actions { gap:4px; }
  .viewer-actions button { min-width:45px; padding-inline:8px; font-size:11px; }
}
@media (pointer:coarse) {
  .intro-tools button, .room-set-button, .placed-list summary { min-height:44px; }
  .placed-list summary { padding-top:11px; }
}
