:root {
  color-scheme: light;
  --bg-canvas: #F4F3EF;
  --bg-panel: #FFFFFF;
  --bg-subtle: #F8F8F5;
  --bg-hover: #EFEFE9;
  --bg-cinema: #141518;
  --border: #E5E5E0;
  --border-strong: #D4D3CC;
  --ink: #18181B;
  --secondary: #52525B;
  --muted: #8E8E93;
  --brand: #18181B;
  --brand-hover: #27272A;
  --send: var(--brand);
  --send-hover: var(--brand-hover);
  --green: #059669;
  --green-bg: #ECFDF5;
  --green-border: #A7F3D0;
  --amber: #D97706;
  --amber-bg: #FFFBEB;
  --amber-border: #FDE68A;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --red-border: #FECACA;
  --blue: #2563EB;
  --blue-bg: #EFF6FF;
  --blue-border: #BFDBFE;
  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow-sm: 0 4px 12px rgba(24, 24, 27, 0.07);
  --shadow-md: 0 10px 28px rgba(24, 24, 27, 0.12);
  --shadow-lg: 0 20px 56px rgba(24, 24, 27, 0.18);
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 13.5px/1.6 var(--sans);
  background: var(--bg-canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
h1, h2, h3, h4, p { margin: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D8D7D0; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #B8B7AE; }

.icon { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle; }
.icon.sm { width: 14px; height: 14px; }
.mono { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.nums { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.secondary { color: var(--secondary); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.trim { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-panel); color: var(--ink); font-size: 12.5px; font-weight: 550;
  white-space: nowrap; text-decoration: none; transition: all 140ms ease;
}
.btn:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--border-strong); }
.btn.primary { background: var(--brand); color: #FFF; border-color: var(--brand); }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.emerald { background: var(--brand); color: #FFF; border-color: var(--brand); }
.btn.emerald:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.emerald-soft { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.btn.emerald-soft:hover:not(:disabled) { background: #D1FAE5; }
.btn.danger-soft { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.btn.danger-soft:hover:not(:disabled) { background: #FEE2E2; }
.btn.danger { background: var(--red); color: #FFF; border-color: var(--red); }
.btn.danger:hover:not(:disabled) { background: #B91C1C; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--secondary); padding: 0 8px; }
.btn.ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--ink); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.lg { height: 38px; padding: 0 16px; font-size: 13px; border-radius: 10px; }
.btn.full { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--secondary);
  flex: none; transition: all 140ms ease;
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--ink); }
.icon-btn.bordered { border-color: var(--border); background: var(--bg-panel); }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 6px; }
.icon-btn.danger:hover:not(:disabled) { background: var(--red-bg); color: var(--red); }

/* Badges & Pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 550; white-space: nowrap;
  background: var(--bg-subtle); color: var(--secondary); border: 1px solid var(--border);
}
.badge.green { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.badge.amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-border); }
.badge.red { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.badge.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); }
.badge.dark { background: rgba(20, 21, 24, 0.78); color: #F4F4F5; border-color: rgba(255, 255, 255, 0.14); backdrop-filter: blur(8px); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* =========================================================
   GLOBAL SINGLE-ROW 52PX HEADER
   ========================================================= */
.shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 52px;
  flex: none;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto minmax(200px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-center { display: flex; align-items: center; justify-content: center; }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }

.brand-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 6px 4px 4px;
  border-radius: 8px; border: 0; background: transparent; font-weight: 700; font-size: 13.5px;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--ink); color: #FFF;
  display: grid; place-items: center; flex: none;
}
.topbar-sep { width: 1px; height: 18px; background: var(--border); flex: none; }
.project-title-btn {
  border: 0; background: transparent; padding: 4px 6px; border-radius: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--ink); max-width: 170px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-title-btn:hover { background: var(--bg-hover); }

/* 4-Stage Pill Stepper */
.stepper {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 999px; background: var(--bg-subtle); border: 1px solid var(--border);
}
.step-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px; border-radius: 999px; border: 0;
  background: transparent; color: var(--secondary); font-size: 12px; font-weight: 550;
  white-space: nowrap; transition: all 140ms ease;
}
.step-pill:hover:not(:disabled):not(.active) { background: var(--bg-hover); color: var(--ink); }
.step-pill.active { background: var(--ink); color: #FFF; box-shadow: var(--shadow-xs); }
.step-pill .step-num { font-size: 10.5px; opacity: 0.65; font-family: var(--mono); }
.step-pill.done .step-check {
  width: 15px; height: 15px; border-radius: 50%; background: var(--green-bg); color: var(--green);
  display: grid; place-items: center;
}
.step-pill.done .step-check .icon { width: 10px; height: 10px; }

.avatar {
  width: 29px; height: 29px; border-radius: 50%;
  background: var(--bg-subtle); border: 1px solid var(--border-strong);
  display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--ink); flex: none;
}

/* =========================================================
   WORKSPACE SPLIT PANE (65% CANVAS / 35% EDITORIAL AI)
   ========================================================= */
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}
.workspace.swapped { flex-direction: row-reverse; }

.canvas-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(#D5D4CC 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: hidden;
}

/* Divider + Centered Edge Collapse Handle */
.resizer {
  width: 1px;
  background: var(--border);
  position: relative;
  flex: none;
  cursor: col-resize;
  z-index: 25;
}
.resizer::before {
  content: '';
  position: absolute;
  inset: 0 -6px;
}
.resizer:hover, body.resizing .resizer { background: var(--ink); }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }

.edge-collapse-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 22px; height: 46px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--secondary);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  padding: 0;
  transition: all 150ms ease;
}
.edge-collapse-btn:hover {
  background: var(--ink); color: #FFF; border-color: var(--ink);
  width: 24px; height: 52px;
}

.edge-expand-btn {
  position: absolute;
  top: 50%; right: 0;
  transform: translateY(-50%);
  z-index: 28;
  width: 26px; height: 56px;
  border-radius: 12px 0 0 12px;
  border: 1px solid var(--border-strong);
  border-right: 0;
  background: var(--bg-panel);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  display: grid; place-items: center;
  padding: 0;
  transition: all 150ms ease;
}
.workspace.swapped .edge-expand-btn {
  right: auto; left: 0;
  border-radius: 0 12px 12px 0;
  border-right: 1px solid var(--border-strong);
  border-left: 0;
}
.edge-expand-btn:hover { background: var(--ink); color: #FFF; border-color: var(--ink); }

.side-pane {
  flex: none;
  width: var(--side-w, 380px);
  min-width: 310px;
  max-width: 520px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  z-index: 15;
}
.workspace.collapsed .side-pane,
.workspace.collapsed .resizer { display: none; }

/* =========================================================
   LEFTMOST 256PX HISTORY PROJECT DRAWER
   ========================================================= */
.drawer-backdrop {
  position: fixed; inset: 52px 0 0 0; z-index: 40;
  background: rgba(24, 24, 27, 0.22);
  backdrop-filter: blur(1px);
}
.project-drawer {
  position: fixed; top: 52px; bottom: 0; left: 0; width: 264px; z-index: 45;
  background: var(--bg-panel); border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.project-drawer.pinned {
  position: relative; top: auto; bottom: auto; left: auto; flex: none;
  box-shadow: none; z-index: 20;
}
.drawer-edge-btn {
  position: absolute; top: 50%; right: -12px; transform: translateY(-50%);
  width: 22px; height: 46px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg-panel);
  color: var(--secondary); box-shadow: var(--shadow-sm);
  display: grid; place-items: center; padding: 0; z-index: 48;
  transition: all 150ms ease;
}
.drawer-edge-btn:hover { background: var(--brand); color: #FFF; border-color: var(--brand); }
.drawer-top { padding: 14px; border-bottom: 1px solid var(--border); }
.drawer-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.drawer-label { padding: 4px 8px; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.proj-card {
  width: 100%; text-align: left; padding: 10px 11px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
  display: flex; flex-direction: column; gap: 4px; transition: all 140ms ease;
}
.proj-card:hover { background: var(--bg-subtle); border-color: var(--border); }
.proj-card.active { background: var(--ink); color: #FFF; border-color: var(--ink); }
.proj-card.active .muted, .proj-card.active .secondary { color: rgba(255, 255, 255, 0.68); }
.proj-card .badge { height: 19px; font-size: 10.5px; }
.proj-card.active .badge { background: rgba(255, 255, 255, 0.14); color: #FFF; border-color: transparent; }
.drawer-foot {
  padding: 12px 14px; border-top: 1px solid var(--border); background: var(--bg-subtle);
  display: flex; align-items: center; gap: 10px;
}

/* =========================================================
   CANVAS HUD & FLOATING CONTROLS (STAGE 01 - 03)
   ========================================================= */
.canvas-hud-top {
  position: absolute; top: 12px; left: 14px; right: 14px; z-index: 12;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.canvas-hud-top > * { pointer-events: auto; }
.hud-group { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }

.hud-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
  font-size: 12px; font-weight: 550; color: var(--ink); white-space: nowrap;
}
.hud-pill:hover { background: #FFF; border-color: var(--border-strong); }
.hud-pill.audit { color: var(--ink); }
.hud-pill.audit .ok-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.hud-pill.audit .warn-text { color: var(--amber); }

.canvas-hud-bottom {
  position: absolute; bottom: 14px; left: 14px; right: 14px; z-index: 12;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  pointer-events: none;
}
.canvas-hud-bottom > * { pointer-events: auto; }
.hud-bottom-left { justify-self: start; display: flex; align-items: center; gap: 6px; }
.hud-bottom-center { justify-self: center; }
.hud-bottom-right { justify-self: end; display: flex; align-items: center; gap: 6px; }

/* Frosted Glass Floating View Dock */
.view-dock {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.view-dock button {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px; border-radius: 999px; border: 0;
  background: transparent; color: var(--secondary); font-size: 12px; font-weight: 550;
  white-space: nowrap; transition: all 140ms ease;
}
.view-dock button:hover:not(.active) { background: var(--bg-subtle); color: var(--ink); }
.view-dock button.active { background: var(--ink); color: #FFF; }

/* Makit-style Precision Scale & Zoom Pill */
.scale-pill {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px 0 10px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
  font-size: 11.5px; color: var(--secondary);
}
.scale-pill .dim-readout { padding-right: 6px; border-right: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.scale-pill button {
  height: 24px; min-width: 24px; padding: 0 5px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink); font-size: 11.5px; font-weight: 550;
}
.scale-pill button:hover { background: var(--bg-hover); }

.lock-hint {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px);
  border: 1px solid var(--border); font-size: 11.5px; color: var(--secondary);
}

/* Popovers (Room Switcher, Audit Details, Add Furniture) */
.popover {
  position: absolute; z-index: 22;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  padding: 6px; min-width: 220px;
}
.popover-head { padding: 6px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.popover-item {
  width: 100%; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 9px; border-radius: 8px; border: 0; background: transparent; font-size: 12.5px;
}
.popover-item:hover { background: var(--bg-subtle); }
.popover-item.active { background: var(--blue-bg); color: var(--blue); font-weight: 600; }

/* Professional Left-Docked Furniture Library Panel (Stage 03) */
.furn-lib-panel {
  position: absolute; top: 54px; left: 14px; bottom: 58px; width: 268px; z-index: 20;
  background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; overflow: hidden;
}
.furn-lib-head {
  padding: 11px 12px 9px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; flex: none;
}
.furn-lib-tabs {
  display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px;
}
.furn-lib-tab {
  height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-subtle); color: var(--secondary); font-size: 11px; font-weight: 550;
  white-space: nowrap; flex: none; transition: all 130ms ease;
}
.furn-lib-tab:hover { border-color: var(--border-strong); color: var(--ink); }
.furn-lib-tab.active { background: var(--brand); color: #FFF; border-color: var(--brand); }
.furn-lib-grid {
  flex: 1; min-height: 0; overflow-y: auto; padding: 10px;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; align-content: start;
}
.furn-lib-card {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel);
  padding: 8px; text-align: left; display: flex; flex-direction: column; gap: 6px;
  transition: all 140ms ease;
}
.furn-lib-card:hover {
  border-color: var(--brand); background: var(--bg-subtle);
  transform: translateY(-1px); box-shadow: var(--shadow-xs);
}
.furn-lib-thumb {
  height: 54px; border-radius: 6px; background: var(--bg-canvas);
  border: 1px solid var(--border); display: grid; place-items: center; padding: 6px;
}
.furn-lib-thumb svg { width: 100%; height: 100%; display: block; }
.furn-lib-name { font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.furn-lib-dim { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }

/* Stage Viewport */
.stage-area {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.plan-wrap {
  position: absolute; inset: 54px 20px 58px 20px;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.floor-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.floor-svg .furn-obj { cursor: grab; transition: opacity 150ms ease; }
.floor-svg .furn-obj:active { cursor: grabbing; }
.floor-svg .furn-obj:hover .furn-body { stroke: var(--blue); stroke-width: 55; }
.floor-svg .door-hit { cursor: pointer; }
.floor-svg .door-hit:hover .door-ring { stroke: var(--blue); }

/* 3D Model Host */
.model-anchor { position: absolute; inset: 0; }
.model-cover {
  position: absolute; inset: 0; display: grid; place-items: center; background: #EAE9E4;
}
.model-cover img { width: 100%; height: 100%; object-fit: contain; }
.model-anchor.ready .model-cover,
.model-anchor.ready .fallback-pick { display: none; }
#model-host { position: fixed; z-index: 4; overflow: hidden; background: transparent; }
#model-host iframe { width: 100%; height: 100%; border: 0; display: block; }
.fallback-pick {
  position: absolute; top: 61%; left: 44%; transform: translate(-50%, -50%);
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid #FFF;
  background: var(--blue); color: #FFF; box-shadow: var(--shadow-sm); z-index: 6;
}

/* Proximity Floating Furniture Property Card + PS Color Picker */
.furn-card {
  position: absolute; z-index: 18; width: 266px;
  background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-md); padding: 12px;
  transform: translateY(-50%);
}
.ps-picker { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 10px; }
.ps-sv-box {
  position: relative; width: 100%; height: 118px; border-radius: 8px;
  overflow: hidden; cursor: crosshair; touch-action: none;
  border: 1px solid rgba(0,0,0,0.12);
  background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent);
}
.ps-sv-cursor {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #FFF; box-shadow: 0 0 0 1px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%); pointer-events: none;
}
.ps-hue-row { display: flex; align-items: center; gap: 8px; }
.ps-preview-dot {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.16); flex: none;
}
.ps-hue-slider {
  flex: 1; height: 10px; border-radius: 999px; appearance: none; -webkit-appearance: none;
  background: linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
  outline: none; cursor: pointer;
}
.ps-hue-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #FFF; border: 1.5px solid #18181B; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.ps-inputs-row { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 4px; }
.ps-field { display: flex; flex-direction: column; gap: 2px; }
.ps-field span { font-size: 9.5px; color: var(--muted); text-align: center; font-weight: 600; }
.ps-field input {
  width: 100%; height: 24px; padding: 0 4px; border-radius: 5px;
  border: 1px solid var(--border-strong); background: var(--bg-subtle);
  font-size: 11px; font-family: var(--mono); text-align: center;
}
.ps-field input:focus { outline: none; border-color: var(--ink); background: #FFF; }
.swatches { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.swatch {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.16);
  padding: 0; background: var(--sw);
}
.swatch.active { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Stage 01 Hero & Uploaded Floorplan */
.hero-stage {
  position: absolute; inset: 0; background: #1D1E21;
  display: flex; align-items: center; justify-content: center;
}
.hero-stage img { width: 100%; height: 100%; object-fit: cover; }
.hero-stage.contain img { object-fit: contain; background: #EAE9E4; }
.hero-overlay-caption {
  position: absolute; left: 20px; bottom: 62px; z-index: 8;
  padding: 12px 16px; border-radius: 12px;
  background: rgba(20, 21, 24, 0.72); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14); color: #FFF; max-width: 380px;
}
.hero-overlay-caption h2 { font-size: 16px; font-weight: 650; margin-bottom: 2px; }
.hero-overlay-caption p { font-size: 12px; color: rgba(255, 255, 255, 0.78); }

.uploaded-sheet-wrap {
  position: absolute; inset: 54px 28px 54px 28px;
  display: flex; align-items: center; justify-content: center;
}
.uploaded-sheet {
  position: relative; max-width: 100%; max-height: 100%;
  background: #FFF; border-radius: 12px; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); padding: 12px;
  display: flex; align-items: center; justify-content: center;
}
.uploaded-sheet img { max-height: calc(100dvh - 180px); width: auto; object-fit: contain; border-radius: 6px; display: block; }
.span-callout {
  position: absolute; left: 40.5%; top: 61.5%; width: 17.5%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: 0; padding: 0; cursor: pointer; z-index: 4;
}
.span-bracket {
  width: 100%; height: 12px; position: relative;
  display: flex; align-items: center;
}
.span-bracket::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 3px;
  background: #DC2626; border-radius: 2px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}
.span-end {
  position: absolute; top: 0; bottom: 0; width: 3px; background: #DC2626; border-radius: 2px;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}
.span-end.l { left: 0; }
.span-end.r { right: 0; }
.span-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px;
  border-radius: 999px; background: #DC2626; color: #FFFFFF;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35);
}
.span-callout.pulse .span-tag {
  animation: spanPulse 0.9s ease 2;
}
@keyframes spanPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.22); }
}
.blur-pin {
  position: absolute; top: 56%; left: 50%; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber);
  font-size: 11.5px; font-weight: 600; box-shadow: var(--shadow-sm);
  animation: pulseRing 2s infinite;
}
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(217, 119, 6, 0); }
}

/* =========================================================
   STAGE 04: DARK CINEMA STAGE (ONLY 16:9 STAGE IS DARK!)
   ========================================================= */
.stage04-wrap {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--bg-panel);
}
.stage04-bar {
  height: 46px; flex: none; padding: 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
}
.cinema-stage {
  flex: 1; min-height: 0; position: relative;
  background: var(--bg-cinema);
  display: flex; align-items: center; justify-content: center;
  padding: 18px 22px; overflow: hidden;
}
.cinema-frame {
  position: relative; width: 100%; height: 100%; max-width: 1040px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; overflow: hidden; background: #0E0F11;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.cinema-frame img, .cinema-frame video {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.cinema-frame img.variant-alt { filter: saturate(0.88) brightness(1.06) contrast(1.02); }

/* Before/After Compare Slider inside Stage 04 */
.compare-wrap { position: relative; width: 100%; height: 100%; overflow: hidden; }
.compare-after { position: absolute; inset: 0; }
.compare-before { position: absolute; inset: 0; overflow: hidden; }
.compare-divider {
  position: absolute; top: 0; bottom: 0; width: 2px; background: #FFF;
  box-shadow: 0 0 10px rgba(0,0,0,0.6); pointer-events: none;
}
.compare-handle {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 30px; height: 30px; border-radius: 50%; background: #FFF; color: var(--ink);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4); pointer-events: none;
}
.compare-range {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; z-index: 5;
}

.cinema-badges-top {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
.cinema-badges-top > * { pointer-events: auto; }

.cinema-subtitle {
  position: absolute; left: 50%; bottom: 48px; transform: translateX(-50%);
  max-width: 84%; padding: 7px 14px; border-radius: 8px;
  background: rgba(14, 15, 17, 0.78); backdrop-filter: blur(8px);
  color: #F4F4F5; font-size: 12.5px; text-align: center; pointer-events: none;
}

/* Mini Camera Radar PiP */
.pip-radar {
  position: absolute; right: 14px; bottom: 14px; z-index: 7;
  width: 142px; background: rgba(20, 21, 24, 0.84); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px;
  padding: 6px; color: #E4E4E7; box-shadow: var(--shadow-md);
}
.pip-radar-head { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px; margin-bottom: 4px; color: #A1A1AA; }
.pip-radar svg { width: 100%; height: 92px; display: block; border-radius: 6px; background: rgba(255, 255, 255, 0.04); }

.redraw-scrim {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(20, 21, 24, 0.72); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: #FFF; font-size: 13px; font-weight: 550;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.22); border-top-color: #FFF;
  animation: spin 0.8s linear infinite;
}
.spinner.dark { border-color: var(--border); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Light Bottom Thumbnail Strip */
.thumb-strip {
  height: 86px; flex: none; padding: 8px 14px;
  display: flex; align-items: center; gap: 10px; overflow-x: auto;
  background: var(--bg-panel); border-top: 1px solid var(--border);
}
.thumb-card {
  flex: none; width: 122px; padding: 4px; border-radius: 9px;
  border: 1.5px solid var(--border); background: var(--bg-panel);
  text-align: left; display: flex; flex-direction: column; gap: 4px;
  transition: all 140ms ease; position: relative;
}
.thumb-card:hover { border-color: var(--border-strong); }
.thumb-card.active { border-color: var(--ink); box-shadow: var(--shadow-xs); }
.thumb-media {
  height: 44px; border-radius: 5px; overflow: hidden; background: var(--bg-subtle);
  display: grid; place-items: center; position: relative;
}
.thumb-media img { width: 100%; height: 100%; object-fit: cover; }
.thumb-media.video-tile { background: var(--bg-cinema); color: #FFF; }
.thumb-check {
  position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--green); color: #FFF; display: grid; place-items: center; font-size: 10px;
}
.thumb-meta { display: flex; align-items: center; justify-content: space-between; font-size: 11px; padding: 0 2px; }

/* =========================================================
   RIGHT PANE: MAKIT.BUILD EDITORIAL AI CHAT FEEL
   ========================================================= */
.side-header {
  height: 46px; flex: none; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--border); background: var(--bg-panel);
}
.side-header-title {
  display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; min-width: 0;
}
.side-scroll {
  flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.side-scroll > * { flex-shrink: 0; }

/* Editorial AI Stream (No heavy bubbles, no avatars!) */
.ai-entry {
  display: flex; flex-direction: column; gap: 7px;
  color: var(--ink); font-size: 13.5px; line-height: 1.65;
}
.ai-speaker {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 650; color: var(--secondary);
  letter-spacing: 0.01em;
}
.ai-speaker-dot {
  width: 16px; height: 16px; border-radius: 5px;
  background: var(--brand); color: #FFF;
  display: grid; place-items: center; font-size: 10px;
}
.side-tabs {
  display: inline-flex; padding: 2px; border-radius: 8px;
  background: var(--bg-subtle); border: 1px solid var(--border); gap: 2px;
}
.side-tab {
  height: 26px; padding: 0 10px; border-radius: 6px; border: 0;
  background: transparent; color: var(--secondary); font-size: 12px; font-weight: 550;
  transition: all 130ms ease;
}
.side-tab.active { background: #FFF; color: var(--ink); box-shadow: var(--shadow-xs); }
.log-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 9px; background: var(--bg-subtle);
  border: 1px solid var(--border); font-size: 12px; color: var(--ink);
}
.ai-entry p { color: #27272A; }
.ai-entry strong { color: var(--ink); font-weight: 650; }
.ai-next { font-size: 13px; color: #27272A; }
.ai-actions-row {
  display: flex; align-items: center; gap: 4px; margin-top: -2px;
}
.ai-ghost-icon {
  width: 24px; height: 24px; border-radius: 6px; border: 0; background: transparent;
  color: var(--muted); display: grid; place-items: center; padding: 0;
}
.ai-ghost-icon:hover { background: var(--bg-subtle); color: var(--ink); }

.user-entry {
  align-self: flex-end; max-width: 88%;
  padding: 8px 12px; border-radius: 12px 12px 3px 12px;
  background: var(--bg-canvas); color: var(--ink); font-size: 13px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

.sys-log-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border-radius: 8px; background: var(--bg-subtle);
  border: 1px solid var(--border); font-size: 12px; color: var(--secondary);
}

/* Embedded Clean Structured Card inside Editorial Chat */
.embed-card {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-panel); overflow: hidden;
}
.embed-card.accent-border { border-color: var(--ink); border-width: 1.5px; }
.embed-card-head {
  padding: 10px 13px; background: var(--bg-subtle); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12.5px; font-weight: 600;
}
.embed-card-body { padding: 12px 13px; display: flex; flex-direction: column; gap: 11px; }

/* Clean Data Table inside Embedded Card (like Makit.build screenshot) */
.kv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kv-table tr { border-bottom: 1px solid var(--border); }
.kv-table tr:last-child { border-bottom: 0; }
.kv-table td { padding: 8px 12px; vertical-align: top; }
.kv-table td:first-child { color: var(--secondary); width: 38%; }
.kv-table td:last-child { color: var(--ink); font-weight: 550; text-align: right; }

/* Flat Lightweight Demand Chips */
.chip-group { display: flex; flex-direction: column; gap: 6px; }
.chip-group-label { font-size: 12px; font-weight: 600; color: var(--secondary); }
.chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-btn {
  height: 28px; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg-panel);
  color: var(--secondary); font-size: 12px; font-weight: 500;
  transition: all 130ms ease;
}
.chip-btn:hover { border-color: var(--border-strong); color: var(--ink); background: var(--bg-subtle); }
.chip-btn.selected { background: var(--ink); color: #FFF; border-color: var(--ink); }
.chip-btn.soft-selected { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); font-weight: 600; }
.chip-btn.custom-add { border-style: dashed; color: var(--muted); }
.chip-btn.custom-add:hover { border-color: var(--brand); color: var(--ink); }
.card-note-tip {
  font-size: 11.5px; color: var(--secondary); background: var(--bg-subtle);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; line-height: 1.5;
}

/* Upload Dropzone */
.upload-box {
  width: 100%; padding: 20px 14px; border-radius: 12px;
  border: 1.5px dashed var(--border-strong); background: var(--bg-subtle);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  transition: all 150ms ease;
}
.upload-box:hover { border-color: var(--ink); background: #F1F0EA; }
.upload-icon-circle {
  width: 38px; height: 38px; border-radius: 10px; background: var(--ink); color: #FFF;
  display: grid; place-items: center; margin-bottom: 2px;
}

/* Color Palette Strip */
.palette-bar { display: flex; gap: 5px; margin-top: 4px; }
.palette-chip {
  flex: 1; height: 22px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, 0.08);
  position: relative;
}

/* Signature Makit.build Bottom Composer Box */
.composer-dock {
  flex: none; padding: 10px 14px 14px; background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.quick-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.quick-pill {
  height: 25px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-subtle);
  color: var(--secondary); font-size: 11.5px;
}
.quick-pill:hover { border-color: var(--border-strong); color: var(--ink); background: var(--bg-hover); }

.composer-box {
  border: 1px solid var(--border-strong); border-radius: 15px;
  background: var(--bg-panel); padding: 10px 10px 8px 12px;
  box-shadow: var(--shadow-xs); transition: border-color 140ms ease, box-shadow 140ms ease;
}
.composer-box:focus-within {
  border-color: #A1A1AA;
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06);
}
.composer-quote {
  display: inline-flex; align-items: center; gap: 5px;
  margin-bottom: 6px; padding: 2px 8px; border-radius: 6px;
  background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border);
  font-size: 11.5px; font-weight: 550;
}
.composer-box textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  font-size: 13px; line-height: 1.5; min-height: 42px; max-height: 120px; padding: 0;
}
.composer-box textarea::placeholder { color: #A1A1AA; }
.composer-foot {
  display: flex; align-items: center; justify-content: space-between; margin-top: 6px;
}
.composer-tools { display: flex; align-items: center; gap: 2px; }
.send-btn {
  width: 30px; height: 30px; border-radius: 999px; border: 0;
  background: var(--send); color: #FFF;
  display: grid; place-items: center; padding: 0; transition: background 140ms ease;
}
.send-btn:hover:not(:disabled) { background: var(--send-hover); }

/* =========================================================
   STAGE 03 CORRECTION MODE (RIGHT PANE OVERLAY + RED BOX)
   ========================================================= */
.corr-toolbar {
  padding: 8px 14px; background: var(--bg-subtle); border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
}
.seg-mini {
  display: inline-flex; padding: 2px; border-radius: 7px;
  background: #E8E7E1; gap: 2px;
}
.seg-mini button {
  height: 24px; padding: 0 8px; border-radius: 5px; border: 0;
  background: transparent; color: var(--secondary); font-size: 11.5px; font-weight: 550;
}
.seg-mini button.active { background: #FFF; color: var(--ink); box-shadow: var(--shadow-xs); }

.corr-canvas-box {
  position: relative; width: 100%; height: 260px;
  background: #ECEBE5; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; cursor: crosshair; touch-action: none;
}
.corr-canvas-box svg { width: 100%; height: 100%; display: block; }
.corr-inline-form {
  padding: 11px 12px; border-radius: 10px;
  border: 1.5px solid var(--red-border); background: #FFF9F9;
  display: flex; flex-direction: column; gap: 9px;
}
.issue-row {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--bg-panel);
  cursor: pointer; transition: all 140ms ease;
}
.issue-row:hover { border-color: var(--red); background: var(--bg-subtle); }
.issue-row.active { border-color: var(--red); background: var(--red-bg); }
.issue-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: #FFF;
  font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; margin-top: 1px;
}

/* =========================================================
   STAGE 04 RIGHT PANEL INLINE REFERENCE PICKER & GATE 3
   ========================================================= */
.inline-ref-panel {
  padding: 12px; border-radius: 11px; border: 1px solid var(--border-strong);
  background: var(--bg-subtle); display: flex; flex-direction: column; gap: 10px;
}
.audit-chat-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.audit-chat-row:last-child { border-bottom: 0; }
.gate3-top {
  flex: none; padding: 12px 16px; background: var(--bg-subtle);
  border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px;
}
.inline-video-panel {
  padding: 12px; border-radius: 12px; border: 1.5px solid var(--ink);
  background: var(--bg-panel); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 10px;
}
.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.preset-card {
  padding: 7px 8px; border-radius: 8px; border: 1px solid var(--border); background: #FFF;
  text-align: left; display: flex; flex-direction: column; gap: 5px;
}
.preset-card.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.preset-bars { display: flex; width: 100%; height: 10px; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.preset-bars span { flex: 1; display: block; height: 100%; }

.gate3-foot {
  flex: none; padding: 12px 16px 14px; background: var(--bg-subtle);
  border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px;
}
.progress-track { width: 100%; height: 6px; border-radius: 999px; background: #E4E4DF; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--ink); transition: width 260ms ease; }
.progress-fill.done { background: var(--green); }

/* =========================================================
   JOB LOADING CARD (STAGE 03 / 04)
   ========================================================= */
.job-card {
  width: min(440px, calc(100% - 32px)); background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md);
  padding: 24px; display: flex; flex-direction: column; gap: 16px;
}
.job-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.job-list li {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted);
}
.job-list li.done { color: var(--green); }
.job-list li.active { color: var(--ink); font-weight: 600; }
.job-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--bg-subtle);
  border: 1px solid var(--border); display: grid; place-items: center; font-size: 11px; flex: none;
}
.job-list li.done .job-dot { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.job-list li.active .job-dot { background: var(--ink); border-color: var(--ink); color: #FFF; }

/* =========================================================
   INPUTS, DIALOGS, DRAG OVERLAY, TOAST & PRINT
   ========================================================= */
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--bg-panel); padding: 7px 10px; font-size: 13px;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); }

#drag-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(24, 24, 27, 0.28); backdrop-filter: blur(3px);
  display: grid; place-items: center; pointer-events: none;
}
.drag-card {
  background: #FFF; border: 2px dashed var(--ink); border-radius: 18px;
  padding: 36px 48px; text-align: center; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.drag-icon {
  width: 48px; height: 48px; border-radius: 12px; background: var(--bg-subtle);
  display: grid; place-items: center; margin-bottom: 4px;
}
.drag-icon svg { width: 24px; height: 24px; }

#dialog {
  width: min(490px, calc(100% - 28px)); max-height: calc(100dvh - 40px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--bg-panel); color: var(--ink); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
#dialog.wide { width: min(780px, calc(100% - 28px)); }
#dialog::backdrop { background: rgba(24, 24, 27, 0.42); backdrop-filter: blur(2px); }
.dialog-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.dialog-head h2 { font-size: 15px; font-weight: 650; }
.dialog-body { padding: 16px 18px; overflow-y: auto; max-height: calc(100dvh - 170px); }
.dialog-foot {
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg-subtle);
  display: flex; justify-content: flex-end; gap: 8px;
}

.room-check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 8px; }
.room-check-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 9px; border: 1px solid var(--border); cursor: pointer; font-size: 12.5px;
}
.room-check-item:has(:checked) { background: var(--bg-subtle); border-color: var(--ink); font-weight: 550; }
.room-check-item input { accent-color: var(--ink); margin: 0; }

.compare-swing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.compare-swing-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--bg-subtle); }

#toast {
  position: fixed; top: 62px; left: 50%; transform: translate(-50%, -8px); z-index: 70;
  padding: 8px 16px; border-radius: 999px; background: var(--ink); color: #FFF;
  font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: all 180ms ease;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }
#toast.success { background: var(--green); }
#toast.warn { background: var(--amber); }

/* PDF Print Layout */
.pdf-sheet {
  background: #FFF; border: 1px solid var(--border); border-radius: 10px; padding: 22px;
  display: flex; flex-direction: column; gap: 16px; font-size: 12.5px;
}
.pdf-room-row { display: grid; grid-template-columns: 200px 1fr; gap: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.pdf-room-row img { width: 100%; border-radius: 6px; border: 1px solid var(--border); }

/* =========================================================
   HOME PAGE
   ========================================================= */
.home-shell {
  height: 100dvh; display: flex; flex-direction: column;
  background: #FFFFFF; color: var(--ink); overflow: hidden; position: relative;
}
.home-topbar {
  height: 54px; flex: none; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); background: #FFFFFF;
}
.home-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 28px 32px 110px;
}
.home-inner { max-width: 1220px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.home-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.home-tabs { display: flex; align-items: center; gap: 6px; }
.home-tab {
  height: 34px; padding: 0 15px; border-radius: 999px; border: 0;
  background: transparent; color: var(--secondary); font-size: 13.5px; font-weight: 550;
  transition: all 140ms ease;
}
.home-tab:hover { background: var(--bg-subtle); color: var(--ink); }
.home-tab.active { background: var(--bg-hover); color: var(--ink); font-weight: 650; }
.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.home-card {
  position: relative; aspect-ratio: 4 / 4.4; border-radius: 18px; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-canvas);
  text-align: left; padding: 0; display: flex; flex-direction: column;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.home-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.home-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.home-card.contain img { object-fit: contain; padding: 14px; background: #F7F6F2; }
.home-card-scrim {
  position: absolute; inset: auto 0 0 0; padding: 36px 14px 13px;
  background: linear-gradient(to top, rgba(20, 21, 24, 0.82) 0%, rgba(20, 21, 24, 0.35) 60%, transparent 100%);
  color: #FFFFFF; display: flex; flex-direction: column; gap: 3px;
}
.home-card-title { font-size: 14px; font-weight: 650; color: #FFF; line-height: 1.3; }
.home-card-sub { font-size: 11.5px; color: rgba(255, 255, 255, 0.8); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.home-card-badge {
  position: absolute; top: 11px; left: 11px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); backdrop-filter: blur(8px);
  box-shadow: var(--shadow-xs);
}
.home-card-new {
  border: 1.5px dashed var(--border-strong); background: var(--bg-subtle);
  align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center;
}
.home-card-new:hover { border-color: var(--brand); background: #F0EFEA; }
.home-floating-dock {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30;
  width: min(640px, calc(100% - 32px));
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: 0 12px 36px rgba(24, 24, 27, 0.14);
  padding: 6px 8px 6px 10px; display: flex; align-items: center; gap: 8px;
}
.home-floating-dock input {
  flex: 1; border: 0; outline: 0; background: transparent; font-size: 13.5px; color: var(--ink);
  min-width: 0;
}
.home-floating-dock input::placeholder { color: #9CA3AF; }

/* =========================================================
   STAGE 03 SUB-STEPPER & 3D WHITE-BOX CLAY MODEL
   ========================================================= */
.substep-bar {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
  white-space: nowrap; flex-shrink: 0;
}
.substep-btn {
  height: 26px; padding: 0 11px; border-radius: 999px; border: 0;
  background: transparent; color: var(--secondary); font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; transition: all 140ms ease;
  white-space: nowrap; flex-shrink: 0;
}
.substep-btn.active { background: var(--brand); color: #FFF; }
.substep-btn.done { color: var(--green); }

.clay-stage {
  position: absolute; inset: 54px 20px 58px 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 42%, #FFFFFF 0%, #EFECE5 100%);
  border-radius: 16px; border: 1px solid var(--border); overflow: hidden;
}
.clay-svg { width: 100%; height: 100%; max-width: 820px; max-height: 100%; display: block; }
.clay-legend {
  position: absolute; left: 16px; bottom: 14px;
  display: flex; align-items: center; gap: 12px; padding: 6px 12px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border: 1px solid var(--border); font-size: 11.5px; color: var(--secondary);
}
.clay-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; vertical-align: -1px; }

/* Confirm ② Camera Preview Cards */
.cam-preview-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.cam-preview-card {
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  border-radius: 11px; border: 1.5px solid var(--border); background: var(--bg-panel);
  cursor: pointer; transition: all 140ms ease;
}
.cam-preview-card:has(:checked) { border-color: var(--brand); background: var(--bg-subtle); }
.cam-thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: 7px; overflow: hidden;
  background: #1B1C20; display: grid; place-items: center;
}
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cam-thumb-tag {
  position: absolute; top: 6px; right: 6px; padding: 2px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 600; backdrop-filter: blur(6px);
}
.cam-thumb-tag.custom { background: rgba(5, 150, 105, 0.9); color: #FFF; }
.cam-thumb-tag.ai { background: rgba(24, 24, 27, 0.78); color: #F4F4F5; }

/* Multi-Camera Saved Chips */
.saved-cam-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.saved-cam-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px;
  border-radius: 7px; border: 1px solid var(--border); background: var(--bg-subtle);
  font-size: 11.5px; color: var(--ink);
}
.saved-cam-chip button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 0 2px; font-size: 12px; line-height: 1;
}
.saved-cam-chip button:hover { color: var(--red); }

/* Stage 03 Layer Switcher (MEP & Ceiling) */
.canvas-hud-sub {
  position: absolute; top: 54px; left: 50%; transform: translateX(-50%); z-index: 11;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.mep-filter-bar {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px); border: 1px solid var(--border);
  box-shadow: var(--shadow-xs); white-space: nowrap; flex-shrink: 0;
}
.mep-filter-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
  border-radius: 999px; border: 0; background: transparent; color: var(--secondary);
  font-size: 11.5px; font-weight: 550; cursor: pointer; transition: all 120ms ease;
  white-space: nowrap; flex-shrink: 0;
}
.mep-filter-btn:hover { color: var(--ink); background: var(--bg-subtle); }
.mep-filter-btn.active { background: var(--brand); color: #FFFFFF; }
.mep-dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.mep-node { cursor: pointer; transition: opacity 140ms ease; }
.mep-node:hover { opacity: 0.85; }
.ceil-zone { cursor: pointer; transition: fill-opacity 140ms ease; }
.ceil-zone:hover { fill-opacity: 0.24 !important; }
.layer-legend-pill {
  display: inline-flex; align-items: center; gap: 10px; height: 32px; padding: 0 12px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(8px);
  border: 1px solid var(--border); font-size: 11.5px; color: var(--secondary);
}

@media print {
  @page { size: A4; margin: 12mm; }
  body > * { display: none !important; }
  body > #print-plan { display: block !important; }
  .pdf-sheet { border: 0; padding: 0; }
}

@media (max-width: 1200px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .project-title-btn { max-width: 120px; }
  .step-pill { padding: 0 9px; font-size: 11.5px; }
  .lock-hint { display: none; }
}
