:root {
  --ink: #e8f0eb;
  --muted: #9aa8a4;
  --deep: #0b1417;
  --panel: rgba(15, 27, 30, 0.78);
  --line: rgba(222, 239, 231, 0.13);
  --accent: #b9ed9d;
  --accent-dark: #618c64;
  --warm: #f6cc90;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--deep);
}

* { box-sizing: border-box; }
html, body, #appShell { width: 100%; min-height: 100%; margin: 0; overflow: hidden; }
body { background: #0b1417; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { height: 100dvh; min-height: 0; position: relative; background: radial-gradient(circle at 50% 12%, #38584f 0%, #172c2f 31%, #0b1519 70%); }
.topbar { position: absolute; z-index: 20; inset: 0 0 auto; height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(8, 17, 20, .78), rgba(8, 17, 20, .12)); backdrop-filter: blur(12px); }
.brand { display: inline-flex; gap: 11px; align-items: center; letter-spacing: .11em; }
.brand strong { display: block; font-size: 12px; line-height: 1.1; letter-spacing: .18em; }
.brand small { display: block; margin-top: 4px; font-size: 9px; letter-spacing: .22em; color: #8fa69d; }
.brand-mark { position: relative; display: grid; width: 28px; height: 28px; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); gap: 2px; transform: rotate(45deg); }
.brand-mark i { display: block; border: 1px solid var(--accent); opacity: .95; }
.brand-mark i:nth-child(2) { background: var(--accent); }
.brand-mark i:nth-child(3) { background: rgba(185,237,157,.2); }
.topbar-center { position: absolute; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 9px; font-size: 11px; letter-spacing: .06em; color: #dce9df; white-space: nowrap; }
.topbar-center .muted { color: #7f938b; }
.status-dot { width: 7px; height: 7px; display: inline-block; background: #b9ed9d; box-shadow: 0 0 14px #b9ed9d; border-radius: 50%; }
.slash { color: #64766f; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-button, .text-button { cursor: pointer; border: 1px solid var(--line); background: rgba(11,22,25,.38); transition: border .18s ease, color .18s ease, background .18s ease; }
.icon-button:hover, .text-button:hover { background: rgba(185,237,157,.11); border-color: rgba(185,237,157,.55); color: var(--accent); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.text-button { height: 36px; border-radius: 18px; padding: 0 14px; font-size: 10px; letter-spacing: .08em; }

.stage { position: absolute; inset: 0; overflow: hidden; }
#sceneCanvas { display: block; width: 100%; height: 100%; outline: 0; touch-action: none; cursor: grab; }
#sceneCanvas:active { cursor: grabbing; }
.scene-vignette { pointer-events: none; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 36%, rgba(5, 13, 15, .18) 76%, rgba(5, 13, 15, .6) 100%); }
.scene-title { position: absolute; pointer-events: none; top: 122px; left: 31px; text-shadow: 0 2px 24px rgba(5,15,17,.5); }
.scene-title p, .eyebrow { margin: 0; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.scene-title h1 { margin: 10px 0 0; font-size: clamp(25px, 2.4vw, 37px); font-weight: 350; line-height: 1.05; letter-spacing: -.04em; }

.hint-chip { position: absolute; z-index: 4; left: 31px; bottom: 28px; display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 13px 0 8px; border: 1px solid rgba(223,239,232,.14); background: rgba(10,21,23,.61); border-radius: 18px; backdrop-filter: blur(12px); font-size: 10px; color: #dbe8df; transition: opacity .35s ease, transform .35s ease; }
.hint-chip.is-hidden { opacity: 0; transform: translateY(6px); pointer-events: none; }
.hint-icon { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(185,237,157,.16); color: var(--accent); font-size: 12px; }

.control-panel, .navigator-panel, .source-plan, .object-card, .guide-card { z-index: 8; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 20px 70px rgba(0,0,0,.18); backdrop-filter: blur(16px); }
.control-panel { position: absolute; right: 26px; top: 106px; width: 270px; max-height: calc(100dvh - 122px); overflow-y: auto; border-radius: 16px; padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.panel-heading h2, .object-card h2, .guide-card h2 { margin: 6px 0 0; font-size: 20px; line-height: 1.1; font-weight: 450; letter-spacing: -.025em; }
.model-note { margin: 11px 0 0; color: #aebfb5; font-size: 10px; line-height: 1.45; }
.layer-list { margin-top: 12px; display: grid; }
.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 39px; cursor: pointer; font-size: 11px; color: #d7e3dc; }
.switch-row > span { display: flex; align-items: center; gap: 9px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row b { position: relative; width: 28px; height: 16px; border-radius: 20px; background: #53645e; transition: background .2s ease; }
.switch-row b:after { content: ""; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; border-radius: 50%; background: #dbe7df; transition: transform .2s ease, background .2s ease; }
.switch-row input:checked + b { background: #86be75; }
.switch-row input:checked + b:after { transform: translateX(12px); background: white; }
.layer-icon { display: inline-block; width: 13px; height: 13px; border: 1px solid #98aca4; opacity: .8; }
.layer-icon.furniture { border-radius: 2px; box-shadow: inset 0 -4px #98aca4; }
.layer-icon.finish { border-radius: 50%; border-width: 2px; }
.layer-icon.walls { border-width: 2px 1px; }
.layer-icon.ceiling { transform: rotate(45deg); width: 10px; height: 10px; }
.layer-icon.measure { position: relative; height: 1px; border: 0; background: #98aca4; }
.layer-icon.measure:before, .layer-icon.measure:after { content:""; position:absolute; top:-3px; height:7px; width:1px; background:#98aca4; }
.layer-icon.measure:before { left:0; }.layer-icon.measure:after { right:0; }
.layer-icon.cutaway { border-radius: 50% 50% 0 0; border-bottom: 0; }
.panel-separator { height: 1px; background: var(--line); margin: 13px 0; }
.mode-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #d7e3dc; }
.mode-toggle { display: inline-flex; align-items: center; cursor: pointer; gap: 6px; padding: 3px 7px; border-radius: 13px; border: 1px solid rgba(185,237,157,.3); background: rgba(185,237,157,.06); font-size: 9px; color: var(--accent); }
.mode-toggle i { width: 8px; height: 8px; border-radius: 50%; background: #f6cc90; box-shadow: 0 0 10px #f6cc90; }
.panel-actions { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.outline-button { min-height: 34px; padding: 4px 7px; cursor: pointer; border: 1px solid rgba(220,239,229,.15); border-radius: 7px; background: rgba(8,18,20,.23); color: #c4d3ca; font-size: 9px; line-height: 1.2; transition: .2s ease; }
.outline-button:hover { color: var(--accent); border-color: rgba(185,237,157,.6); background: rgba(185,237,157,.09); }
.outline-button span { margin-right: 4px; color: var(--accent); }

.navigator-panel { position: absolute; top: 268px; left: 30px; width: 157px; border-radius: 12px; padding: 15px 12px 10px; }
.view-list { margin-top: 9px; }
.view-button { position: relative; width: 100%; border: 0; background: transparent; color: #aebdb4; text-align: left; padding: 8px 7px; cursor: pointer; border-radius: 5px; font-size: 11px; transition: .18s ease; }
.view-button span { display: inline-block; width: 26px; font-size: 8px; color: #687972; }
.view-button:hover, .view-button.is-active { color: var(--accent); background: rgba(185,237,157,.1); }
.view-button.is-active:after { content:""; position: absolute; right: 7px; top: 50%; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); transform: translateY(-50%); box-shadow: 0 0 8px var(--accent); }

.source-plan { position: absolute; left: 30px; bottom: 76px; width: 174px; padding: 9px; border-radius: 11px; }
.source-plan-head { display: flex; justify-content: space-between; margin: 1px 2px 7px; font-size: 8px; letter-spacing: .09em; color: #8da299; }
.source-plan img { display: block; width: 100%; aspect-ratio: 1.52; object-fit: cover; opacity: .9; border-radius: 4px; filter: saturate(.8) contrast(1.04); }
.source-plan p { margin: 7px 2px 1px; color: #a2b3ab; font-size: 8px; line-height: 1.35; }

.object-card, .guide-card { position: absolute; left: 50%; bottom: 29px; width: min(390px, calc(100vw - 42px)); border-radius: 15px; padding: 21px; transform: translate(-50%, calc(100% + 40px)); opacity: 0; pointer-events: none; transition: transform .32s cubic-bezier(.2,.85,.2,1), opacity .2s ease; }
.object-card.is-open, .guide-card.is-open { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.object-card { border-top-color: rgba(185,237,157,.45); }
.card-close { position: absolute; top: 12px; right: 13px; width: 26px; height: 26px; padding: 0; border: 0; background: transparent; color: #aec0b7; cursor: pointer; font-size: 23px; font-weight: 200; line-height: 1; }
.card-close:hover { color: var(--accent); }
.item-description { margin: 12px 34px 13px 0; color: #c5d1ca; font-size: 12px; line-height: 1.48; }
.item-meta { display: grid; grid-template-columns: 1.18fr 1fr 1fr; gap: 8px; padding: 11px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.item-meta div { min-width: 0; }
.item-meta span { display: block; margin-bottom: 4px; color: #8fa198; font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.item-meta strong { display: block; overflow-wrap: anywhere; color: #e1ebe4; font-size: 10px; font-weight: 500; line-height: 1.3; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.action-button { cursor: pointer; border: 1px solid rgba(185,237,157,.44); border-radius: 7px; padding: 8px 10px; background: rgba(185,237,157,.1); color: var(--accent); font-size: 10px; transition: .18s ease; }
.action-button:hover { background: rgba(185,237,157,.22); transform: translateY(-1px); }
.estimate-note { margin: 11px 0 0; color: #889a92; font-size: 9px; line-height: 1.35; }

.guide-card { width: min(430px, calc(100vw - 42px)); }
.guide-card > p:last-child { margin: 14px 0 0; color: #9caea5; font-size: 10px; line-height: 1.45; }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.guide-grid div { display: flex; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line); border-radius: 7px; }
.guide-key { display: grid; place-items: center; flex: 0 0 auto; min-width: 29px; height: 22px; padding: 0 5px; border: 1px solid rgba(185,237,157,.3); border-radius: 4px; color: var(--accent); font-size: 9px; }
.guide-grid p { margin: 0; color: #becbc4; font-size: 10px; line-height: 1.25; }
.mobile-guide { display: none; }
.toast { position: absolute; z-index: 16; left: 50%; top: 96px; max-width: min(360px, calc(100vw - 36px)); padding: 9px 13px; border: 1px solid rgba(185,237,157,.35); border-radius: 18px; background: rgba(10,22,23,.84); color: #dcebe1; font-size: 10px; text-align: center; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; transition: .22s ease; backdrop-filter: blur(12px); }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

.mobile-only { display: none; }
button:focus-visible, input:focus-visible + b, #sceneCanvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 920px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex; }
  .topbar { height: 64px; padding: 0 17px; }
  .brand-mark { width: 24px; height: 24px; }
  .topbar-center { display: none; }
  .topbar-actions .icon-button { width: 34px; height: 34px; }
  .guide-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 16px; }
  .guide-button .mobile-only { display: block; }
  .scene-title { top: 91px; left: 18px; }
  .scene-title p { font-size: 8px; }.scene-title h1 { font-size: 25px; }
  .hint-chip { left: 17px; bottom: 82px; height: 30px; padding-right: 10px; font-size: 9px; }
  .hint-icon { width: 18px; height: 18px; }
  .control-panel { position: absolute; z-index: 22; top: auto; right: 0; bottom: 0; width: 100%; max-height: min(77dvh, 590px); overflow: auto; border-radius: 20px 20px 0 0; padding: 21px 20px calc(24px + env(safe-area-inset-bottom)); transform: translateY(105%); opacity: 0; pointer-events: none; transition: .3s cubic-bezier(.2,.85,.2,1); }
  .control-panel.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .close-panel { align-items: center; justify-content: center; padding: 0; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: #cedbd3; font-size: 24px; line-height: 1; }
  .switch-row { min-height: 44px; font-size: 12px; }
  .navigator-panel, .source-plan { display: none; }
  .object-card, .guide-card { z-index: 23; bottom: 72px; max-height: calc(100dvh - 145px); overflow-y: auto; padding: 18px; }
  .object-card.is-open, .guide-card.is-open { transform: translate(-50%, 0); }
  .item-description { font-size: 11px; }
  .mobile-toolbar { position: absolute; z-index: 17; right: 14px; bottom: calc(13px + env(safe-area-inset-bottom)); align-items: center; gap: 6px; padding: 5px; border: 1px solid var(--line); border-radius: 17px; background: rgba(9,19,22,.78); box-shadow: 0 12px 30px rgba(0,0,0,.18); backdrop-filter: blur(16px); }
  .mobile-toolbar button { min-width: 58px; height: 31px; border: 0; border-radius: 12px; background: transparent; color: #d6e2da; font-size: 9px; cursor: pointer; }
  .mobile-toolbar button:active { background: rgba(185,237,157,.18); color: var(--accent); }
  .mobile-toolbar span { margin-right: 3px; color: var(--accent); font-size: 11px; }
  .mobile-views { position: absolute; z-index: 21; left: 0; right: 0; bottom: 0; flex-direction: column; gap: 11px; padding: 9px 18px calc(21px + env(safe-area-inset-bottom)); border-radius: 19px 19px 0 0; background: rgba(15, 28, 30, .97); border-top: 1px solid var(--line); transform: translateY(105%); transition: .28s cubic-bezier(.2,.85,.2,1); }
  .mobile-views.is-open { transform: translateY(0); }
  .sheet-handle { align-self: center; width: 36px; height: 3px; border-radius: 3px; background: #6a7973; }
  .sheet-title { display: flex; justify-content: space-between; align-items: center; color: #e0ebe4; font-size: 13px; }
  .sheet-title button { border: 0; background: transparent; color: #d5e0da; font-size: 24px; }
  .mobile-view-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .mobile-view-grid button { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: rgba(185,237,157,.05); color: #cfdbd3; font-size: 11px; }
  .mobile-guide { display: block; }
}

@media (max-width: 470px) {
  .app-shell { min-height: 0; }
  .topbar-actions .desktop-only { display: none; }
  .scene-title { top: 83px; }.scene-title h1 { font-size: 23px; }
  .hint-chip { max-width: 235px; bottom: 71px; }
  .item-meta { grid-template-columns: 1.22fr .94fr .94fr; }
  .item-meta strong { font-size: 9px; }
  .guide-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { *, *:before, *:after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; } }

/* Keep view buttons clickable when the viewport is too short for the plan card. */
@media (min-width: 921px) and (max-height: 820px) {
  .source-plan { display: none; }
  .navigator-panel { z-index: 9; max-height: calc(100dvh - 285px); overflow-y: auto; }
}
@media (min-width: 921px) and (max-height: 650px) {
  .scene-title { display: none; }
  .navigator-panel { top: 100px; max-height: calc(100dvh - 115px); }
}
