:root {
  --bg: #f6f1ea;
  --panel: #fffdf9;
  --line: #e7ddd0;
  --ink: #2f2923;
  --muted: #857869;
  --accent: #e0662f;
  --accent-soft: #fbe4d8;
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }

button, .button {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
button:hover, .button:hover { border-color: #cdbca8; background: #fff; }
button:disabled { opacity: .4; cursor: default; }
button.ghost { background: transparent; }
button.danger { color: #b3261e; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.logo {
  width: 34px; height: 34px; border-radius: 9px;
  background:
    linear-gradient(90deg, transparent 45%, rgba(255,255,255,.7) 45% 55%, transparent 55%),
    linear-gradient(0deg, transparent 45%, rgba(255,255,255,.7) 45% 55%, transparent 55%),
    linear-gradient(135deg, #e0662f, #d9a066);
}
.actions { display: flex; gap: 6px; }
.segmented { display: flex; background: #efe7dc; padding: 3px; border-radius: 10px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; }
.segmented button.active { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 250px 1fr 270px;
  min-height: 0;
}
.sidebar { overflow-y: auto; padding: 14px; background: var(--panel); }
.sidebar.left { border-right: 1px solid var(--line); }
.sidebar.right { border-left: 1px solid var(--line); }
.sidebar section { margin-bottom: 22px; }
.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0; line-height: 1.4; }

.catalog { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.catalog button {
  display: flex; align-items: center; gap: 7px;
  text-align: left; font-size: 12px; padding: 6px 7px;
}
.catalog .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(0,0,0,.15); }

.ideas { display: flex; flex-direction: column; gap: 8px; }
.idea {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: #fff;
  font-size: 12px; line-height: 1.4;
}
.idea.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.idea h3 { font-size: 13px; margin: 0 0 3px; }
.idea p { margin: 0 0 6px; color: var(--muted); }
.idea details { margin: 0 0 6px; color: var(--ink); }
.idea summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.idea ul { margin: 4px 0; padding-left: 16px; }
.idea .seats { color: var(--ink); }
.idea button { width: 100%; }

.item-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.item-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: 7px; cursor: pointer;
}
.item-list li:hover { background: #f4ede4; }
.item-list li.active { background: var(--accent-soft); }
.item-list .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.photo { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.photo img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.photo span { font-size: 10px; padding: 3px; color: var(--muted); }

.stage { display: flex; min-width: 0; min-height: 0; gap: 10px; padding: 10px; }
.pane {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.layout[data-mode='2d'] .pane-3d, .layout[data-mode='3d'] .pane-2d { display: none; }
.pane-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.pane-bar label { display: flex; align-items: center; gap: 4px; color: var(--muted); cursor: pointer; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { padding: 4px 9px; font-size: 12px; border-radius: 999px; }
.pane-body { flex: 1; min-height: 0; position: relative; }
#view3d canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.plan2d { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; background: #f3ede4; }
.plan2d .item { cursor: grab; }
.plan2d .item:hover { filter: brightness(1.06); }
.plan2d .item-label {
  font-size: .085px; text-anchor: middle; fill: #2f2923; pointer-events: none;
  paint-order: stroke; stroke: rgba(255,253,249,.85); stroke-width: .02px;
}
.plan2d .wall-label { font-size: .09px; text-anchor: middle; fill: #857869; dominant-baseline: middle; }
.plan2d .dim-line { stroke: #857869; stroke-width: .008; }
.plan2d .dim-text { font-size: .1px; text-anchor: middle; fill: #5d5247; dominant-baseline: middle; }
.plan2d .compass-n { font-size: .06px; text-anchor: middle; fill: #4a4540; font-weight: 700; }
.plan2d .sel-box { fill: none; stroke: var(--accent); stroke-width: .012; stroke-dasharray: .04 .025; pointer-events: none; }
.plan2d .sel-stem { stroke: var(--accent); stroke-width: .01; }
.plan2d .handle { fill: #fff; stroke: var(--accent); stroke-width: .014; }
.plan2d .handle.rotate { cursor: alias; }
.plan2d .handle.resize { cursor: nwse-resize; }
.plan2d .clearance line { stroke: var(--accent); stroke-width: .007; stroke-dasharray: .03 .02; }
.plan2d .clearance text {
  font-size: .08px; text-anchor: middle; fill: var(--accent); font-weight: 600;
  paint-order: stroke; stroke: #fff; stroke-width: .02px;
}

.inspector-empty { font-size: 13px; color: var(--muted); line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.field input[type='text'] { width: 100%; }
input[type='text'], input[type='number'] {
  font: inherit; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 7px; background: #fff; width: 100%;
}
input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid3 label, .grid2 label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.unit { display: flex; align-items: center; gap: 3px; font-size: 11px; }
.colors { display: flex; gap: 10px; margin: 8px 0 12px; }
.colors label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
input[type='color'] { width: 34px; height: 26px; border: 1px solid var(--line); border-radius: 6px; padding: 1px; background: #fff; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 11px; background: #efe7dc; border-radius: 999px; padding: 2px 8px; color: var(--muted); margin-bottom: 8px; }

.shortcuts dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12px; margin: 0; }
.shortcuts dt { font-weight: 600; white-space: nowrap; }
.shortcuts dd { margin: 0; color: var(--muted); }

.lightbox {
  position: fixed; inset: 0; background: rgba(20,16,12,.8);
  display: flex; align-items: center; justify-content: center; z-index: 10; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 10px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 210px 1fr; }
  .sidebar.right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
  .stage { flex-direction: column; }
}
