/* ==========================================================================
   Kuldip Vadera Residence — Bespoke Architectural Studio Viewer Styles
   Modern Web Guidance Compliant:
   - color-scheme + <meta> :has() + light-dark()
   - Accessible focusgroup tabs + hidden="until-found" zero-styled tabpanel
   - accent-color + @supports fallback for brand-consistent forms
   - content-visibility: auto + contain-intrinsic-size on 3D viewport
   ========================================================================== */

:root {
  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }

  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }

  /* Architectural Studio Palette via light-dark() */
  --bg-page: light-dark(#f6f3ee, #12110f);
  --bg-surface: light-dark(#ffffff, #1b1916);
  --bg-surface-alt: light-dark(#f1ece4, #23201c);
  --bg-elevated: light-dark(#fcfaf7, #27241f);
  --bg-viewport: light-dark(#ebe5db, #181613);
  --bg-hud: light-dark(rgba(255, 253, 249, 0.88), rgba(22, 20, 17, 0.86));

  --border-subtle: light-dark(#e4ddd2, #312c26);
  --border-strong: light-dark(#cfc5b6, #494138);

  --text-primary: light-dark(#1a1714, #f3eee6);
  --text-secondary: light-dark(#595147, #b3a99b);
  --text-muted: light-dark(#766d61, #8e8477);

  /* Brand Accent (>= 5.5:1 contrast in BOTH light and dark modes!) */
  --brand-accent: light-dark(#9a4f23, #e48e52);
  --brand-accent-hover: light-dark(#7d3e19, #f0a46e);
  --brand-accent-soft: light-dark(rgba(154, 79, 35, 0.11), rgba(228, 142, 82, 0.16));
  --brand-accent-ring: light-dark(rgba(154, 79, 35, 0.32), rgba(228, 142, 82, 0.36));
  --brand-on-accent: light-dark(#ffffff, #18120c);

  /* Semantic Architectural Category Colors (2D SVG Floor Plan) */
  --cat-living: light-dark(#efe6d8, #332a20);
  --cat-bedroom: light-dark(#e7e3ec, #2d2834);
  --cat-wet: light-dark(#dce9ec, #203136);
  --cat-service: light-dark(#ede6d5, #322c1e);
  --cat-outdoor: light-dark(#e3ebe0, #233022);
  --cat-ots: light-dark(#cde8f2, #173745);
  --cat-circulation: light-dark(#e7e3de, #2c2925);
  --cat-sacred: light-dark(#f6e6cf, #3c2e1c);

  --svg-wall: light-dark(#24201c, #dfd7cb);
  --svg-furniture-stroke: light-dark(#6c6256, #a99f91);
  --svg-furniture-fill: light-dark(rgba(120, 108, 94, 0.10), rgba(210, 198, 180, 0.12));
  --svg-column-fill: light-dark(#b33c26, #f06d52);
  --svg-column-reconciled: light-dark(#1f659c, #5cb2f2);
  --svg-skylight-stroke: light-dark(#0e6b82, #55c4de);
  --svg-skylight-fill: light-dark(rgba(25, 145, 175, 0.22), rgba(75, 195, 224, 0.22));
  --svg-label: light-dark(#1c1814, #f5efe6);
  --svg-sublabel: light-dark(#5b5247, #b7aca0);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: light-dark(0 1px 3px rgba(26, 23, 20, 0.06), 0 1px 4px rgba(0, 0, 0, 0.35));
  --shadow-md: light-dark(0 8px 24px rgba(26, 23, 20, 0.08), 0 10px 28px rgba(0, 0, 0, 0.45));

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Brand-Consistent Forms (modern-web-guidance: accent-color + @supports fallback)
   ========================================================================== */

input[type="range"],
input[type="checkbox"] {
  accent-color: var(--brand-accent);
  color-scheme: light dark;
}

input[type="range"] {
  width: 100%;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

@supports not (accent-color: var(--brand-accent)) {
  input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg-surface);
    display: inline-grid;
    place-content: center;
  }

  input[type="checkbox"]:checked {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
  }

  input[type="checkbox"]:checked::after {
    content: "";
    width: 0.45rem;
    height: 0.25rem;
    border-left: 2px solid var(--brand-on-accent);
    border-bottom: 2px solid var(--brand-on-accent);
    transform: rotate(-45deg) translate(1px, -1px);
  }

  input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 999px;
    background: var(--border-subtle);
  }

  input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand-accent);
    border: 2px solid var(--bg-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }

  input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand-accent);
    border: 2px solid var(--bg-surface);
  }
}

/* ==========================================================================
   App Shell & Studio Header
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.studio-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1.25rem;
  padding: 0.85rem 1.4rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--brand-accent-soft);
  color: var(--brand-accent);
  border: 1px solid var(--border-subtle);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(1rem, 1.35vw, 1.22rem);
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.title-spec {
  font-weight: 450;
  color: var(--text-secondary);
}

.brand-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.22rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.compass-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-weight: 560;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.compass-badge svg {
  color: var(--brand-accent);
}

.meta-divider {
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.quick-floor-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.32rem;
  padding: 0.22rem;
  border-radius: 999px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
}

.floor-pill {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  font-size: 0.79rem;
  font-weight: 550;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.floor-pill:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.floor-pill.is-active {
  background: var(--brand-accent);
  color: var(--brand-on-accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.42rem 0.82rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 560;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.theme-toggle:hover {
  border-color: var(--brand-accent);
  background: var(--bg-surface-alt);
}

.theme-icon {
  display: inline-flex;
  align-items: center;
  color: var(--brand-accent);
}

.theme-toggle[data-effective-theme="dark"] .theme-icon-moon {
  display: none;
}

.theme-toggle[data-effective-theme="light"] .theme-icon-sun {
  display: none;
}

/* ==========================================================================
   Accessible Tabs (modern-web-guidance: focusgroup + ::after border-block-end
   + zero-styled [role="tabpanel"] in single grid cell for hidden="until-found")
   ========================================================================== */

.tabs-bar-wrap {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding-inline: 1.4rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.tablist {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

[role="tab"] {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.82rem 1.05rem;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 560;
  white-space: nowrap;
  transition: color 140ms ease;
}

[role="tab"]:hover {
  color: var(--text-primary);
}

[role="tab"][aria-selected="true"] {
  color: var(--text-primary);
  font-weight: 650;
}

[role="tab"][aria-selected="true"] svg {
  color: var(--brand-accent);
}

/* Forced Colors safe active tab indicator via ::after border-block-end */
[role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline: 0.45rem;
  inset-block-end: 0;
  border-block-end: 3px solid var(--brand-accent);
}

/* CRITICAL: NO gap between panels, and ZERO padding/border/margin/background on [role="tabpanel"]! */
.tab-panels {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0;
}

[role="tabpanel"] {
  grid-area: 1 / 1;
  min-width: 0;
}

[role="tabpanel"][hidden="until-found"] {
  pointer-events: none;
}

.panel-body {
  max-width: 1640px;
  width: 100%;
  margin-inline: auto;
  padding: 1.15rem 1.4rem 1.6rem;
}

/* ==========================================================================
   Panel 1: 3D Interactive Model
   ========================================================================== */

.panel-3d-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: 1.15rem;
  align-items: start;
}

.viewport-column {
  min-width: 0;
}

/* modern-web-guidance: efficient-background-processing */
.viewport-3d-shell {
  content-visibility: auto;
  contain-intrinsic-size: auto none auto 640px;
  position: relative;
  width: 100%;
  height: clamp(540px, 74vh, 800px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-viewport);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

#three-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.viewport-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-hud);
  backdrop-filter: blur(8px);
  z-index: 6;
  transition: opacity 220ms ease;
}

.viewport-overlay[hidden] {
  display: none;
}

.loader-card {
  text-align: center;
  padding: 1.5rem 2rem;
  max-width: 340px;
  width: 90%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.loader-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--brand-accent);
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-title {
  margin: 0;
  font-weight: 640;
  font-size: 0.95rem;
}

.loader-subtitle {
  margin: 0.3rem 0 0.85rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.loader-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-surface-alt);
  overflow: hidden;
}

.loader-bar-fill {
  height: 100%;
  width: 12%;
  background: var(--brand-accent);
  border-radius: 999px;
  transition: width 160ms ease;
}

.viewport-error-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg-hud);
  backdrop-filter: blur(10px);
  z-index: 8;
}

.viewport-error-banner[hidden] {
  display: none;
}

.error-card {
  max-width: 560px;
  background: var(--bg-surface);
  border: 1.5px solid var(--brand-accent);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow-md);
}

.error-card h2 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  color: var(--brand-accent);
}

.error-card p {
  margin: 0.45rem 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.code-snippet {
  margin: 0.75rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
}

.viewport-hud-top {
  position: absolute;
  top: 0.85rem;
  inset-inline: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 4;
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  background: var(--bg-hud);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--text-primary);
}

.hud-chip-muted {
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2f9e5b;
}

.hud-chip-muted.is-paused .status-dot {
  background: var(--text-muted);
}

.viewport-hud-bottom {
  position: absolute;
  bottom: 0.85rem;
  inset-inline: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
  z-index: 4;
}

.camera-presets {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.34rem;
  border-radius: var(--radius-md);
  background: var(--bg-hud);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.preset-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  padding: 0.34rem 0.68rem;
  border-radius: var(--radius-sm);
  font-size: 0.77rem;
  font-weight: 560;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.preset-btn:hover {
  background: var(--bg-surface-alt);
}

.preset-btn.is-active {
  background: var(--brand-accent);
  color: var(--brand-on-accent);
}

.preset-btn-ghost {
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.viewport-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--bg-hud);
  padding: 0.16rem 0.62rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

/* Sidebar Control Cards */
.controls-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.control-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow-sm);
}

.control-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.control-card-head h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 660;
  letter-spacing: -0.01em;
}

.control-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-accent-soft);
  color: var(--brand-accent);
  font-size: 0.72rem;
  font-weight: 620;
  white-space: nowrap;
  flex-shrink: 0;
}

.control-desc {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.cutaway-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.48rem;
}

.cutaway-btn {
  text-align: left;
  padding: 0.58rem 0.68rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  transition: border-color 140ms ease, background-color 140ms ease, transform 120ms ease;
}

.cutaway-btn strong {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-primary);
}

.cutaway-btn span {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.cutaway-btn:hover {
  border-color: var(--brand-accent);
}

.cutaway-btn.is-active {
  background: var(--brand-accent-soft);
  border-color: var(--brand-accent);
}

.cutaway-btn.is-active strong {
  color: var(--brand-accent);
}

.slider-group + .slider-group {
  margin-top: 0.95rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-subtle);
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.slider-label-row label {
  font-size: 0.8rem;
  font-weight: 600;
}

.slider-label-row output {
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: var(--brand-accent);
  font-weight: 620;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.69rem;
  color: var(--text-muted);
  margin-top: 0.18rem;
}

.text-action-btn {
  border: 0;
  background: transparent;
  color: var(--brand-accent);
  font-size: 0.77rem;
  font-weight: 600;
  padding: 0.15rem 0.3rem;
}

.text-action-btn:hover {
  text-decoration: underline;
}

.layer-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.42rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 130ms ease;
}

.layer-row:hover {
  border-color: var(--border-strong);
}

.layer-row-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.layer-name {
  font-size: 0.8rem;
  font-weight: 560;
}

.layer-code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Panel 2: Interactive 2D Floor Plans
   ========================================================================== */

.panel-2d-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.plan-toolbar,
.compare-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.7rem 0.95rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.segmented-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--bg-surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.seg-btn,
.mode-btn,
.filter-chip {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 580;
  transition: background-color 140ms ease, color 140ms ease;
}

.seg-btn:hover,
.mode-btn:hover,
.filter-chip:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.seg-btn.is-active,
.mode-btn.is-active,
.filter-chip.is-active {
  background: var(--brand-accent);
  color: var(--brand-on-accent);
}

.plan-overlay-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.inline-slider {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 560;
}

.inline-slider input[type="range"] {
  width: 112px;
}

.inline-slider output {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  min-width: 2.6rem;
  color: var(--brand-accent);
  font-weight: 600;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.8rem;
  font-weight: 550;
  cursor: pointer;
}

.plan-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 1.02fr) minmax(340px, 0.98fr);
  gap: 1.15rem;
  align-items: start;
}

.svg-stage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}

.svg-stage-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.svg-stage-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 680;
}

.svg-stage-header p {
  margin: 0.15rem 0 0;
  font-size: 0.77rem;
  color: var(--text-secondary);
}

.scale-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.svg-canvas-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem;
}

#floorplan-svg {
  width: 100%;
  max-width: 510px;
  height: auto;
  max-height: 76vh;
  display: block;
  user-select: none;
}

/* Interactive SVG Room Styling */
.svg-room-group {
  cursor: pointer;
  outline: none;
}

.svg-room-shape {
  stroke: var(--border-strong);
  stroke-width: 3;
  transition: filter 130ms ease, stroke 130ms ease, stroke-width 130ms ease, opacity 130ms ease;
}

.svg-room-group[data-category="living"] .svg-room-shape { fill: var(--cat-living); }
.svg-room-group[data-category="bedroom"] .svg-room-shape { fill: var(--cat-bedroom); }
.svg-room-group[data-category="wet"] .svg-room-shape { fill: var(--cat-wet); }
.svg-room-group[data-category="service"] .svg-room-shape { fill: var(--cat-service); }
.svg-room-group[data-category="outdoor"] .svg-room-shape { fill: var(--cat-outdoor); }
.svg-room-group[data-category="ots"] .svg-room-shape { fill: var(--cat-ots); }
.svg-room-group[data-category="circulation"] .svg-room-shape { fill: var(--cat-circulation); }
.svg-room-group[data-category="sacred"] .svg-room-shape { fill: var(--cat-sacred); }

.svg-room-group:hover .svg-room-shape,
.svg-room-group:focus-visible .svg-room-shape {
  stroke: var(--brand-accent);
  stroke-width: 7.5;
  filter: brightness(0.96);
}

.svg-room-group.is-selected .svg-room-shape {
  stroke: var(--brand-accent);
  stroke-width: 11;
  fill-opacity: 0.94;
}

.svg-room-label {
  fill: var(--svg-label);
  font-family: var(--font-sans);
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.svg-room-dim {
  fill: var(--svg-sublabel);
  font-family: var(--font-mono);
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
}

.svg-wall {
  stroke: var(--svg-wall);
  stroke-linecap: square;
  pointer-events: none;
}

.svg-wall-partition {
  stroke: var(--brand-accent);
  stroke-dasharray: 12 6;
  pointer-events: none;
}

.svg-wall-railing {
  stroke: var(--svg-skylight-stroke);
  pointer-events: none;
}

.svg-furniture {
  fill: var(--svg-furniture-fill);
  stroke: var(--svg-furniture-stroke);
  stroke-width: 3.2;
  pointer-events: none;
}

.svg-ots-dash {
  fill: none;
  stroke: var(--svg-skylight-stroke);
  stroke-width: 3.5;
  stroke-dasharray: 14 10;
  pointer-events: none;
}

.svg-column {
  fill: var(--svg-column-fill);
  stroke: #ffffff;
  stroke-width: 2.5;
}

.svg-column.is-reconciled {
  fill: var(--svg-column-reconciled);
}

.svg-skylight-poly {
  fill: var(--svg-skylight-fill);
  stroke: var(--svg-skylight-stroke);
  stroke-width: 5.5;
  pointer-events: none;
}

.svg-audit-pin {
  cursor: pointer;
}

.svg-audit-pin circle {
  fill: var(--brand-accent);
  stroke: var(--bg-surface);
  stroke-width: 4.5;
  transition: transform 140ms ease;
}

.svg-audit-pin text {
  fill: var(--brand-on-accent);
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 750;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.svg-dim-line {
  stroke: var(--text-muted);
  stroke-width: 2.5;
}

.svg-dim-text {
  fill: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  text-anchor: middle;
}

.svg-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem 0.9rem;
  margin-top: 0.72rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.svg-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

.swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
}

.swatch-living { background: var(--cat-living); }
.swatch-bedroom { background: var(--cat-bedroom); }
.swatch-wet { background: var(--cat-wet); }
.swatch-service { background: var(--cat-service); }
.swatch-outdoor { background: var(--cat-outdoor); }
.swatch-ots { background: var(--cat-ots); }
.swatch-sacred { background: var(--cat-sacred); }

/* Room Inspector Sidebar */
.inspector-column {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.inspector-floor-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.68rem 0.78rem;
  box-shadow: var(--shadow-sm);
}

.stat-tile span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-tile strong {
  display: block;
  margin-top: 0.18rem;
  font-size: 0.88rem;
  font-weight: 660;
}

.room-inspector-card,
.room-directory-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.inspector-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.inspector-head h3 {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.inspector-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.spec-cell {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.52rem 0.65rem;
}

.spec-cell dt {
  font-size: 0.69rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.spec-cell dd {
  margin: 0.16rem 0 0;
  font-size: 0.84rem;
  font-weight: 620;
}

.spec-cell-wide {
  grid-column: 1 / -1;
}

.inspector-summary {
  margin: 0 0 0.9rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.audit-block {
  background: var(--brand-accent-soft);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--brand-accent);
  border-radius: var(--radius-sm);
  padding: 0.78rem 0.9rem;
}

.audit-block h4 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.audit-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  font-size: 0.81rem;
  color: var(--text-primary);
}

.inspector-actions {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.48rem 0.92rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-accent);
  background: var(--brand-accent);
  color: var(--brand-on-accent);
  font-size: 0.8rem;
  font-weight: 620;
}

.primary-btn:hover {
  background: var(--brand-accent-hover);
}

.room-directory-card h3 {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
  font-weight: 650;
}

.room-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.room-chip {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  padding: 0.3rem 0.62rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 550;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.room-chip:hover {
  border-color: var(--brand-accent);
}

.room-chip.is-active {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  color: var(--brand-on-accent);
}

/* ==========================================================================
   Panel 3: CAD vs. 3D Visual Compare
   ========================================================================== */

.panel-compare-layout {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.compare-mode-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--bg-surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.compare-summary-strip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--brand-accent);
  border-radius: var(--radius-md);
  padding: 0.68rem 1rem;
}

.compare-summary-strip p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.compare-split-stage {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.compare-split-stage[hidden],
.compare-side-stage[hidden] {
  display: none;
}

.compare-split-frame {
  position: relative;
  width: 100%;
  height: clamp(440px, 66vh, 720px);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-viewport);
  border: 1px solid var(--border-subtle);
  cursor: ew-resize;
  user-select: none;
  touch-action: none;
}

.compare-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.compare-layer-right {
  background: #ece7df;
}

.compare-layer-left {
  background: #ffffff;
  clip-path: inset(0 50% 0 0);
}

.compare-layer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.6rem;
  pointer-events: none;
}

.compare-tag {
  position: absolute;
  top: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  background: rgba(20, 18, 16, 0.8);
  color: #ffffff;
  pointer-events: none;
}

.compare-tag-left { left: 0.85rem; }
.compare-tag-right { right: 0.85rem; }

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  margin-left: -1.5px;
  background: var(--brand-accent);
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
}

.compare-handle-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-accent);
  color: var(--brand-on-accent);
  border: 2.5px solid #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.compare-slider-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 0.8rem;
  padding-inline: 0.2rem;
}

.compare-slider-bar label {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.compare-slider-bar output {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--brand-accent);
  font-weight: 640;
  min-width: 3.1rem;
  text-align: right;
}

.compare-side-stage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.side-card {
  margin: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.side-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.72rem 0.95rem;
  border-bottom: 1px solid var(--border-subtle);
}

.side-card-head h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 640;
}

.side-img-box {
  height: clamp(380px, 58vh, 620px);
  display: grid;
  place-items: center;
  background: #ece7df;
  padding: 0.45rem;
}

.side-img-cad {
  background: #ffffff;
}

.side-img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   Panel 4: 3D Render Gallery & Native <dialog> Lightbox
   ========================================================================== */

.panel-gallery-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gallery-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.8rem 1.2rem;
}

.gallery-header h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 680;
}

.gallery-header p {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.22rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.05rem;
}

.gallery-card {
  margin: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-accent);
  box-shadow: var(--shadow-md);
}

.gallery-thumb-btn {
  border: 0;
  padding: 0;
  background: var(--bg-viewport);
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  position: relative;
  display: block;
}

.gallery-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 240ms ease;
}

.gallery-card:hover .gallery-thumb-btn img {
  transform: scale(1.025);
}

.gallery-zoom-pill {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(18, 16, 14, 0.76);
  color: #ffffff;
}

.gallery-card-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gallery-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.gallery-card-body h3 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 660;
}

.gallery-card-sub {
  margin: 0;
  font-size: 0.77rem;
  color: var(--brand-accent);
  font-weight: 560;
}

.gallery-card-caption {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.48;
}

/* Native <dialog> Lightbox */
.gallery-lightbox {
  max-width: min(1240px, 95vw);
  width: 95vw;
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.gallery-lightbox::backdrop {
  background: rgba(12, 11, 9, 0.78);
  backdrop-filter: blur(6px);
}

.lightbox-shell {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.lightbox-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.lightbox-header h2 {
  margin: 0.22rem 0 0;
  font-size: 1.05rem;
}

.lightbox-header p {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.lightbox-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.icon-btn {
  padding: 0.38rem 0.72rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-alt);
  font-size: 0.8rem;
  font-weight: 580;
}

.icon-btn:hover {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
}

.icon-btn-close {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  color: var(--brand-on-accent);
}

.icon-btn-close:hover {
  background: var(--brand-accent-hover);
  color: var(--brand-on-accent);
}

.lightbox-media {
  flex: 1;
  min-height: 0;
  background: #141210;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  overflow: hidden;
}

.lightbox-media img {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-caption {
  margin: 0;
  padding: 0.85rem 1.2rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Footer & Responsive Breakpoints
   ========================================================================== */

.studio-footer {
  margin-top: auto;
  padding: 0.75rem 1.4rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 1120px) {
  .panel-3d-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .controls-sidebar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .plan-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 780px) {
  .studio-header {
    padding: 0.75rem 0.9rem;
  }

  .tabs-bar-wrap {
    padding-inline: 0.75rem;
  }

  .panel-body {
    padding: 0.9rem 0.85rem 1.3rem;
  }

  .viewport-3d-shell {
    height: 480px;
  }

  .compare-side-stage {
    grid-template-columns: minmax(0, 1fr);
  }

  .inspector-floor-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .gallery-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
