@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg:        #10141A;
  --bg-panel:  #161C24;
  --bg-raised: #1C2530;
  --line:      #2A3644;
  --line-dim:  #1E2731;
  --text:      #E7EDF3;
  --text-dim:  #8496A6;
  --accent:    #4E8FC2;   /* cyanotype / blueprint blue */
  --accent-2:  #C08B4E;   /* oak / material brass */
  --good:      #5FB98C;
  --bad:       #D9705B;

  --font-display: 'Space Grotesk', -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background:
    linear-gradient(var(--line-dim) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--line-dim) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 28px;
}

.sheet {
  max-width: 1040px;
  margin: 0 auto;
}

/* ---------- Titleblock ---------- */

.titleblock {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  margin-bottom: 22px;
}

.titleblock__mark { flex: none; }
.titleblock__text { flex: 1; min-width: 0; }

.titleblock h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text);
}

.titleblock__sub { color: var(--accent); font-weight: 500; }

.titleblock__meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin: 3px 0 0;
  letter-spacing: 0.02em;
}

.titleblock__status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
  box-shadow: 0 0 0 3px transparent;
  transition: background 0.2s, box-shadow 0.2s;
}
.dot--ok  { background: var(--good); box-shadow: 0 0 0 3px rgba(95,185,140,0.18); }
.dot--bad { background: var(--bad);  box-shadow: 0 0 0 3px rgba(217,112,91,0.18); }

/* ---------- Nav / back links (shared across pages) ---------- */

.back-link {
  text-decoration: none;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 8px 12px;
  background: var(--bg-raised);
  font-family: var(--font-mono);
  font-size: 12px;
  transition: border-color 0.15s, color 0.15s;
}
.back-link:hover { color: var(--accent); border-color: var(--accent); }
.back-link--home { flex: none; }

.nav-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ---------- Layout ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 20px;
}
.panel--wide { grid-column: 1 / -1; }

.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--accent);
  opacity: 0.7;
}
.panel::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.panel::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.panel__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.panel__index { font-family: var(--font-mono); font-size: 11px; color: var(--accent-2); letter-spacing: 0.08em; }
.panel h2 { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin: 0; flex: 1; }
.panel__hint { font-size: 11px; color: var(--text-dim); }
.panel__body-text { color: var(--text-dim); font-size: 12.5px; line-height: 1.6; margin: 0 0 16px; }
.panel__body-text code { color: var(--accent); font-family: var(--font-mono); }

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  padding: 10px 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { color: var(--text-dim); cursor: not-allowed; opacity: 0.5; }
.btn::before { content: "▸ "; color: var(--accent-2); }

.btn--primary {
  width: auto;
  text-decoration: none;
  display: inline-block;
  border-color: var(--accent);
  color: var(--accent);
}
.btn--primary::before { content: none; }
.btn--primary:hover { background: var(--bg-raised); }

/* ---------- Status page: result summary + JSON output ---------- */

.summary {
  display: flex;
  gap: 28px;
  padding: 14px 0 18px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 16px;
}
.summary__stat { display: flex; flex-direction: column; gap: 2px; }
.summary__value { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--accent); }
.summary__label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }

.json-out {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line-dim);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.json-out .k { color: var(--accent); }
.json-out .s { color: var(--accent-2); }
.json-out .n { color: var(--good); }

.footer { text-align: center; margin-top: 22px; padding-top: 14px; }

/* ---------- Home page: project list ---------- */

.home-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.home-toolbar .panel__head { margin-bottom: 0; flex: 1; }
.home-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.home-toolbar-actions .btn { width: auto; white-space: nowrap; }

.home-list { list-style: none; margin: 0; padding: 0; }
.home-list__empty { padding: 24px 4px; color: var(--text-dim); font-style: italic; font-size: 13px; }

.home-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line-dim);
  color: var(--text);
  transition: color 0.15s;
  cursor: pointer;
}
.home-list__row:last-child { border-bottom: none; }
.home-list__row:hover { color: var(--accent); }

.home-list__name-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.home-list__name { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.home-list__meta { display: flex; gap: 18px; font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }

.rename-btn {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.1s;
}
.home-list__row:hover .rename-btn { opacity: 1; }
.rename-btn:hover { color: var(--accent); }

.delete-btn {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}
.home-list__row:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--bad); }

.export-btn {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}
.home-list__row:hover .export-btn { opacity: 1; }
.export-btn:hover { color: var(--accent); }
.export-btn:disabled { opacity: 0.4; cursor: wait; }

.name-edit-input {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--accent);
  padding: 3px 6px;
  min-width: 160px;
}
.name-edit-input:focus-visible { outline: none; }

/* ---------- Floor plan page ---------- */

.fp-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.fp-header-actions .btn { width: auto; }
.fp-header-actions .btn::before { content: none; }

.photo-mode-btn { cursor: pointer; border-color: var(--accent); color: var(--accent); }
.photo-mode-btn:hover { background: var(--accent); color: var(--bg); }

/* Photo mode: full-screen canvas, everything else hidden */
.photo-mode .titleblock,
.photo-mode .editor-tree,
.photo-mode .editor-inspector,
.photo-mode .editor-statusbar { display: none !important; }
.photo-mode .editor-layout { grid-template-columns: 1fr !important; }
.photo-mode .editor-scene { position: fixed; inset: 0; z-index: 1000; }
.photo-mode #scene3d-canvas { width: 100% !important; height: 100% !important; }

.photo-mode-exit {
  display: none;
  position: absolute;
  top: 14px; right: 14px;
  z-index: 1001;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 7px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.photo-mode-exit:hover { background: rgba(0,0,0,0.8); }
.photo-mode .photo-mode-exit { display: block; }

.photo-inspector {
  display: none;
}
.photo-mode .photo-inspector {
  display: flex;
  position: absolute;
  top: 54px;
  right: 14px;
  width: 192px;
  z-index: 1002;
  background: rgba(12, 16, 24, 0.86);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 14px;
  flex-direction: column;
  backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  pointer-events: auto;
}
.photo-inspector__label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.photo-inspector__presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.photo-preset-btn {
  flex: 1 1 auto;
  padding: 4px 7px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 2px;
  transition: background 0.1s, color 0.1s;
}
.photo-preset-btn:hover { background: var(--bg-panel); color: var(--text); }
.photo-preset-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.photo-inspector__slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.photo-inspector__slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.fp-input {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 8px 10px;
  width: 100%;
}
.fp-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.fp-list { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--text-dim); }
.fp-list li { padding: 7px 0; border-bottom: 1px solid var(--line-dim); display: flex; justify-content: space-between; gap: 8px; cursor: pointer; }
.fp-list li:hover { color: var(--accent); }
.fp-list li.is-selected { color: var(--accent); }
.fp-list__empty { color: var(--text-dim) !important; font-style: italic; cursor: default; }
.fp-list__empty:hover { color: var(--text-dim) !important; }

/* Tree — matches native SceneTree's header/section-label/row pattern */
.tree-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.tree-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 10px 0 4px;
}
.tree-icon { font-size: 10px; opacity: 0.8; }

.tree-body { padding-bottom: 6px; }

.tree-toolbar { padding: 0 4px 8px; }
.btn-mini {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--line);
  padding: 5px 9px;
  width: 100%;
  cursor: pointer;
  text-align: left;
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 4px;
  cursor: pointer;
  border-bottom: none !important;
  border-radius: 3px;
}
.tree-row:hover { color: var(--accent); background: var(--line-dim); }
.tree-row.is-selected { color: var(--accent); background: rgba(78, 143, 194, 0.12); }
.tree-row__icon { font-size: 10px; width: 14px; text-align: center; opacity: 0.8; flex: none; }
.tree-row__text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.tree-row__title { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row__subtitle { font-size: 10px; color: var(--text-dim); }

/* Wall rows own the chevron slot; nested rows (Zone, cabinets) indent
   instead, to keep the same left edge the native tree uses. */
.tree-row--wall { padding-left: 4px; }
.tree-indent-1 { padding-left: 24px; }
.tree-indent-2 { padding-left: 40px; }
p.tree-indent-1, p.tree-indent-2 { margin: 2px 0; }

.tree-chevron {
  flex: none;
  width: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 9px;
  padding: 0;
  text-align: center;
}
.tree-chevron:hover { color: var(--accent); }

.tree-eye {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
}
.tree-eye:hover { color: var(--accent); }
.tree-eye[data-state="ghosted"] { opacity: 0.5; }
.tree-eye[data-state="hidden"] { opacity: 0.3; }

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 640px;
  background:
    linear-gradient(var(--line-dim) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, var(--line-dim) 1px, transparent 1px) 0 0 / 20px 20px,
    var(--bg);
  cursor: default;
}

.fp-zoom-hint {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 10.5px;
  color: var(--text-dim);
  background: rgba(16, 20, 26, 0.8);
  padding: 4px 8px;
  border: 1px solid var(--line);
  pointer-events: none;
}

/* Cabinet move handle — see scene3d.html for the pointer-events split that
   makes this "intercept only the dot, pass everything else to the camera"
   without any manual hit-testing. */
.handle-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.handle-dot {
  position: absolute;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.14), 0 2px 7px rgba(0,0,0,0.32);
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
}
.handle-dot::after {
  content: '';
  position: absolute;
  inset: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-6 -6 12 12' fill='none' stroke='%230a84ff' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M-1-4L-4 0L-1 4M1-4L4 0L1 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}
.handle-dot--vert {
  cursor: ns-resize;
}
.handle-dot--vert::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-6 -6 12 12' fill='none' stroke='%230a84ff' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M-4-1L0-4L4-1M-4 1L0 4L4 1'/%3E%3C/svg%3E");
}
.handle-dot:hover, .handle-dot.is-dragging {
  box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,0.5);
}
/* Object (imported 3D model) move handles — letter labels matching macOS */
.handle-dot--obj {
  background: #fff;
  cursor: move;
  display: flex; align-items: center; justify-content: center;
}
.handle-dot--obj::after {
  /* Base .handle-dot::after is position:absolute with inset:4px — that takes it
     out of flex flow and breaks centering. Reset to participate in the parent's
     display:flex so align-items/justify-content actually center the letter. */
  position: static;
  inset: unset;
  background-image: none;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  font-size: 11px; font-weight: 700;
  color: #e07b1a;
  line-height: 1;
}
/* macOS mapping: worldX→"X", worldZ→"Y", vertical→"Z" */
#scene3d-handle-obj-x::after { content: 'X'; cursor: ew-resize; }
#scene3d-handle-obj-z::after { content: 'Y'; cursor: ew-resize; }
#scene3d-handle-obj-y::after { content: 'Z'; cursor: ns-resize; }
.handle-dot--obj:hover, .handle-dot--obj.is-dragging {
  box-shadow: 0 0 0 2px #e07b1a, 0 2px 8px rgba(0,0,0,0.5);
}
@media (max-width: 980px) {
  .titleblock { flex-wrap: wrap; }
}

/* ---------- Editor shell: matches the native macOS room editor's layout —
   toolbar / [tree 240px | scene flexible | inspector 340px] / status bar.
   Used by floorplan.html and scene3d.html so every editor-style page
   looks and behaves the same way, same as the native app does across
   its own editors. ---------- */

.sheet--wide { max-width: none; width: 100%; }

.editor-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 340px;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  min-height: 640px;
}

.editor-tree, .editor-inspector {
  padding: 16px;
  overflow-y: auto;
}
.editor-tree { border-right: 1px solid var(--line); }
.editor-inspector { border-left: 1px solid var(--line); }

/* Add-cabinet menu (scene3d.html) — lives inline in the header row itself,
   between the title and the nav links (see scene3d.html), not a separate
   toolbar bar. */
.cabinet-menu { position: relative; flex: none; }
#cabinet-menu-btn { width: auto; }
#cabinet-menu-btn.is-armed {
  background: var(--accent);
  color: #0d1218;
  border-color: var(--accent);
}
#cabinet-menu-btn.is-armed::before { content: none; }

.cabinet-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  width: 220px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 6px 0;
}
.cabinet-menu__section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 8px 14px 6px;
}

/* Construction style — a single-select radio list of three named presets
   (EU-Frameless / US-Frameless / US-Face Frame), matching native's
   CabinetStylePreset exactly, not two separate market/style pickers. */
.cabinet-menu__preset {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  background: none;
  border: none;
  padding: 6px 14px;
  cursor: pointer;
}
.cabinet-menu__preset:hover { background: var(--line-dim); }
.cabinet-menu__radio {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--text-dim);
}
.cabinet-menu__preset.is-selected .cabinet-menu__radio { background: var(--accent); border-color: var(--accent); }
.cabinet-menu__preset.is-selected { color: var(--accent); }

.cabinet-menu__divider { border-top: 1px solid var(--line); margin: 8px 0; }
.cabinet-menu__type {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  background: none;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
}
.cabinet-menu__type:hover { background: var(--line-dim); color: var(--accent); }
.cabinet-menu__type.is-selected { background: var(--accent); color: #0d1218; }
.cabinet-menu__help {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 8px 14px 4px;
}

.cabinet-toolbar__hint {
  flex: none;
  font-size: 11.5px;
  color: var(--accent);
  font-style: italic;
}

.editor-scene {
  position: relative;
  background: var(--bg);
  min-width: 0; /* let the grid track shrink properly with a canvas inside */
}

.editor-statusbar {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-top: none;
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--bg-panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.statusbar-hint {
  opacity: 0.42;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 16px;
}

.editor-section {
  margin-bottom: 22px;
}
.editor-section:last-child { margin-bottom: 0; }

.editor-section__title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}

.inspector-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-dim);
  font-size: 12px;
}
.inspector-row:last-child { border-bottom: none; }
.inspector-row__label { color: var(--text-dim); }
.inspector-row__value { color: var(--text); font-family: var(--font-mono); }

.inspector-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.inspector-header__title { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.inspector-header__subtitle { font-size: 11px; color: var(--text-dim); }

.inspector-empty {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
}

.inspector-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.5;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.inspector-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 10px 0 4px;
}
.inspector-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 3px 6px;
}
.inspector-input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.inspector-row__unit { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

.plan-name-input {
  display: block;
  margin: 4px 0 0 -7px; /* negative margin offsets the input's own padding so the text sits flush under the h1 */
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  padding: 3px 6px;
  max-width: 320px;
  width: calc(100% + 7px);
}
.plan-name-input:hover { border-color: var(--line); }
.plan-name-input:focus-visible { outline: none; border-color: var(--accent); color: var(--text); background: var(--bg); }

@media (max-width: 980px) {
  .editor-layout { grid-template-columns: 200px 1fr; }
  .editor-inspector { display: none; } /* collapses to tree + scene on narrow viewports */
}
@media (max-width: 720px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-tree { border-right: none; border-bottom: 1px solid var(--line); }
}

/* ---------- App shell: floorplan.html / scene3d.html only. True
   full-bleed — no page padding, no centered card, no max-width, fills the
   entire viewport height via flex so the editor reads as an app window,
   not a content page with a boxed widget sitting inside it. ---------- */

body.app-shell {
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell .sheet--wide {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
}

.app-shell .titleblock {
  margin-bottom: 0;
  flex: none;
  border-left: none;
  border-right: none;
  border-top: none;
}

.app-shell .editor-layout {
  flex: 1;
  min-height: 0;
  border-left: none;
  border-right: none;
  border-top: none;
}

.app-shell .editor-statusbar {
  flex: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

/* ---------- 3D view page ---------- */

#scene3d-canvas { display: block; width: 100%; height: 100%; min-height: 640px; }

/* ---------- Buttons: full-width primary, destructive ---------- */

.btn--full { width: 100%; text-align: center; }

.btn--destructive {
  width: 100%;
  text-align: left;
  color: var(--bad);
  border-color: var(--bad);
}
.btn--destructive:hover:not(:disabled) { background: rgba(217,112,91,0.08); border-color: var(--bad); color: var(--bad); }
.btn--destructive::before { content: none; }

/* ---------- Cabinet editor page ---------- */

/* Toolbar — context-sensitive strip between titleblock and editor-layout */
.ce-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
  min-height: 38px;
  overflow-x: auto;
}
.ce-toolbar-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.ce-toolbar-btn:hover { border-color: var(--accent); color: var(--accent); }
.ce-toolbar-btn.is-destructive { color: var(--bad); border-color: transparent; }
.ce-toolbar-btn.is-destructive:hover { border-color: var(--bad); }
.ce-toolbar-sep { width: 1px; height: 18px; background: var(--line); flex: none; margin: 0 4px; }
.ce-toolbar-hint { font-size: 11px; color: var(--text-dim); }

/* Tree eye / visibility button — always visible, 3 states */
.tree-eye-btn {
  flex: none;
  margin-left: auto;
  background: none;
  border: none;
  padding: 0 5px;
  cursor: pointer;
  line-height: 0;
  display: flex;
  align-items: center;
  color: var(--text-dim);
}
.tree-eye-btn svg { display: block; }
.tree-eye-btn.vis-visible  { color: var(--accent); opacity: 1; }
.tree-eye-btn.vis-ghosted  { color: var(--text-dim); opacity: 0.65; }
.tree-eye-btn.vis-hidden   { color: var(--text-dim); opacity: 0.65; }
.tree-eye-btn:hover { opacity: 1 !important; color: var(--text); }

/* Opening tree indentation */
.tree-indent-1 { padding-left: 22px; }
.tree-indent-2 { padding-left: 36px; }
.tree-indent-3 { padding-left: 50px; }
.tree-indent-4 { padding-left: 64px; }

#ce-canvas { display: block; width: 100%; height: 100%; }

.ce-dim-input {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 4px 6px;
  width: 80px;
  text-align: right;
}
.ce-dim-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.ce-preset-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  background: none;
  border: none;
  padding: 6px 0;
  cursor: pointer;
}
.ce-preset-btn:hover { color: var(--accent); }
.ce-preset-btn.is-active { color: var(--accent); }

.ce-preset-radio {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid var(--text-dim);
}
.ce-preset-btn.is-active .ce-preset-radio { background: var(--accent); border-color: var(--accent); }

/* ============================================================
   Modal (reusable — openModal / closeModal in app.js)
   ============================================================ */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
body.modal-open { overflow: hidden; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 420px; max-width: 100%;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}
.modal--sm { width: 360px; }
.modal--obj-library { width: 760px; max-width: 96vw; max-height: 92vh; }

/* Object library search + filter */
.obj-lib-search {
  display: block; width: 100%; box-sizing: border-box;
  background: var(--bg-raised); border: 1px solid var(--line);
  color: var(--text); font-family: var(--font-mono); font-size: 12px;
  padding: 6px 10px; border-radius: 4px; margin-bottom: 12px;
}
.obj-lib-search:focus { outline: none; border-color: var(--accent); }
.obj-lib-filter {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px;
}
.obj-lib-cat {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  font-family: var(--font-display); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 3px; cursor: pointer;
}
.obj-lib-cat:hover { border-color: var(--accent); color: var(--accent); }
.obj-lib-cat.is-active { background: var(--accent); border-color: var(--accent); color: #0d1218; }

/* Object library model grid */
.obj-lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px; overflow-y: auto; max-height: 56vh;
}
.obj-lib-card {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 5px; padding: 0;
  text-align: left; cursor: pointer; transition: border-color 0.1s;
  overflow: hidden; display: flex; flex-direction: column;
}
.obj-lib-card:hover { border-color: var(--accent); }
.obj-lib-card__thumb {
  display: block; width: 100%; aspect-ratio: 1;
  background: var(--bg);
  overflow: hidden;
}
.obj-lib-card__thumb img {
  width: 100%; height: 100%; object-fit: contain;
  display: block;
}
.obj-lib-card__name {
  display: block; color: var(--text); font-family: var(--font-display);
  font-size: 12px; font-weight: 600; line-height: 1.3;
  padding: 8px 10px 2px;
}
.obj-lib-card__cat {
  display: block; color: var(--text-dim); font-family: var(--font-mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0 10px 8px;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-header h2 {
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  letter-spacing: 0.01em; margin: 0; color: var(--text);
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 20px; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 24px;
}
.modal-body > p {
  margin: 0 0 10px; font-size: 13px; line-height: 1.6; color: var(--text-dim);
}
.modal-body > p:last-child { margin-bottom: 0; }

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}

/* ---- Settings sections ---- */

.settings-section { display: flex; flex-direction: column; gap: 10px; }

.settings-section__label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); margin: 0;
  font-family: var(--font-mono);
}

.settings-row { display: flex; flex-direction: column; gap: 6px; }
.settings-row--toggle {
  flex-direction: row; align-items: flex-start;
  justify-content: space-between; gap: 16px;
}
.settings-row__label { font-size: 13px; margin: 0 0 2px; color: var(--text); }
.settings-hint { font-size: 11px; color: var(--text-dim); margin: 0; line-height: 1.5; }

/* Unit picker */
.unit-picker { display: flex; gap: 4px; }
.unit-picker__btn {
  padding: 5px 14px; border-radius: 6px;
  border: 1px solid var(--line);
  background: none; color: var(--text-dim);
  font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.unit-picker__btn:hover { border-color: var(--accent); color: var(--text); }
.unit-picker__btn.is-active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* Toggle switch */
.toggle {
  position: relative; display: inline-block;
  width: 40px; height: 22px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle__track {
  position: absolute; inset: 0; border-radius: 11px;
  background: var(--line); cursor: pointer;
  transition: background 0.2s;
}
.toggle__track::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%; background: var(--text-dim);
  top: 3px; left: 3px; transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle__track { background: var(--accent); }
.toggle input:checked + .toggle__track::before {
  transform: translateX(18px); background: #fff;
}

/* Settings link list */
.settings-links {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.settings-link {
  display: block; padding: 11px 14px;
  font-size: 13px; font-family: var(--font-mono);
  color: var(--text); text-decoration: none;
  background: none; border: none; border-bottom: 1px solid var(--line);
  cursor: pointer; text-align: left; width: 100%;
  transition: background 0.12s, color 0.12s;
}
.settings-link:last-child { border-bottom: none; }
.settings-link:hover { background: var(--bg-raised); color: var(--accent); }

/* Settings button in header */
.settings-btn {
  text-decoration: none;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 8px 12px;
  background: var(--bg-raised);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.settings-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   Inspector: editable fields + section titles
   ============================================================ */

.inspector-section-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim);
  margin: 14px 0 2px; font-family: var(--font-mono);
}

.inspector-edit-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-dim);
  font-size: 12px;
}
.inspector-edit-row .inspector-row__label { flex: 1; min-width: 0; }

.inspector-edit-input {
  width: 84px; flex-shrink: 0;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono); font-size: 12px;
  text-align: right;
  padding: 2px 6px;
  border-radius: 3px;
}
.inspector-edit-input:focus { outline: none; border-color: var(--accent); }
.inspector-edit-input.is-invalid { border-color: var(--bad); color: var(--bad); }

/* Inspector action buttons (Duplicate / Remove row) */
.inspector-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.inspector-actions .btn {
  flex: 1; width: auto;
  text-align: center;
  padding: 7px 8px;
  font-size: 12px;
}
.inspector-actions .btn::before { content: none; }
.modal-footer .btn::before { content: none; }
.modal-footer .btn { width: auto; gap: 8px; }

/* Swing / door-type picker (cabinet editor) */
.swing-picker {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.swing-btn {
  padding: 6px 14px; border-radius: 6px;
  border: 1px solid var(--line);
  background: none; color: var(--text-dim);
  font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.swing-btn:hover { border-color: var(--accent); color: var(--text); }
.swing-btn.is-selected {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ============================================================
   Viewer mode — boards & board detail
   ============================================================ */

.viewer-main {
  padding: 24px 28px 40px;
}

.viewer-boards-header {
  display: flex;
  align-items: baseline;
  margin-bottom: 20px;
  gap: 10px;
}

.viewer-boards-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* Boards grid (viewer home) */
.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 260px));
  gap: 20px;
}

/* Board card */
.board-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.board-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  border-color: var(--accent);
}
.board-card__thumb {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.board-card__type-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 8px;
  position: absolute;
  bottom: 0; left: 0; right: 0;
}
.board-card__badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.38);
  color: rgba(255,255,255,0.88);
  backdrop-filter: blur(4px);
}
.board-card__empty-icon {
  font-size: 32px;
  opacity: 0.28;
}
.board-card__info {
  padding: 12px 14px 14px;
}
.board-card__name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 3px;
}
.board-card__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin: 0;
}

/* Board viewer empty state */
.viewer-empty {
  grid-column: 1 / -1;
  padding: 60px 0;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
}
.viewer-empty__icon {
  font-size: 40px;
  display: block;
  margin-bottom: 14px;
  opacity: 0.22;
}

/* Viewer-board mode: hide all editor-only chrome on scene3d.html */
.viewer-board .cabinet-menu,
.viewer-board #obj-lib-btn,
.viewer-board .cabinet-toolbar__hint,
.viewer-board .back-link--home,
.viewer-board #modal-obj-library,
.viewer-board #scene3d-handle-overlay,
.viewer-board #btn-duplicate-cabinet,
.viewer-board #btn-remove-cabinet,
.viewer-board #btn-duplicate-obj,
.viewer-board #btn-remove-obj,
.viewer-board .inspector-actions,
.viewer-board .editor-inspector a.btn--full,
.viewer-board .inspector-hint { display: none !important; }

/* Recently viewed section (viewer home) */
.viewer-recent {
  margin-bottom: 28px;
}
.viewer-section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}
.recent-boards-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.recent-board-chip {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-panel);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.recent-board-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Board detail — items grid */
.board-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.board-section-header {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, rgba(255,255,255,0.38));
  padding: 10px 0 4px;
  border-top: 1px solid var(--line, rgba(255,255,255,0.08));
  margin-top: 8px;
}
.board-section-header:first-child { margin-top: 0; border-top: none; }

.board-item-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.board-item-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  border-color: var(--accent);
}
.board-item-card__thumb {
  height: 180px;
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.board-item-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.board-item-card__thumb-icon {
  font-size: 40px;
  opacity: 0.22;
}
.board-item-card__type-tag {
  position: absolute;
  top: 8px; left: 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.80);
  backdrop-filter: blur(4px);
  text-transform: uppercase;
}
.board-item-card__cta {
  position: absolute;
  bottom: 8px; right: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}
.board-item-card:hover .board-item-card__cta { opacity: 1; }
.board-item-card__info {
  padding: 12px 14px 14px;
}
.board-item-card__name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 3px;
}
.board-item-card__date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin: 0;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0,0,0,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: lightbox-in 0.18s ease;
}
.lightbox[hidden] { display: none !important; }
@keyframes lightbox-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.lightbox__close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.lightbox__close:hover { background: rgba(255,255,255,0.22); }
.lightbox__caption {
  position: absolute;
  top: 20px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 13px;
  color: rgba(255,255,255,0.65);
  pointer-events: none;
}
.lightbox__img-wrap {
  max-width: 90vw;
  max-height: 88vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox__img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
