/* ============================================================
   Home Designer — app.css  (editor + shared)
   ============================================================ */
:root {
  --bg: #E9E1D2;
  --panel: #F3EDDF;
  --canvas: #EDE6D6;
  --ink: #26221B;
  --muted: #5A5344;
  --line: #C9BFA9;
  --brass: #B08D4F;
  --brass-dark: #8A6D38;
  --accent: #B3542E;
  --white: #FBF8F1;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--brass); color: var(--white); }

/* ---------- editor layout ---------- */
body.editor { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.workspace { flex: 1; display: flex; min-height: 0; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand {
  font-family: 'Cormorant Garamond', serif; font-weight: 700; font-size: 20px;
  color: var(--ink); text-decoration: none; letter-spacing: 0.3px; white-space: nowrap;
}
.brand-mark { color: var(--brass-dark); }
.name-input {
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; background: transparent; color: var(--ink);
  padding: 6px 8px; border-radius: 6px; width: 200px;
}
.name-input:hover, .name-input:focus { border-color: var(--line); background: var(--white); outline: none; }
.topbar-group { display: flex; align-items: center; gap: 6px; }
.topbar-group.grow { flex: 1; }
.mini-label { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.mini-label select {
  font-family: inherit; font-size: 12px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink);
}

.btn {
  font-family: inherit; font-weight: 600; font-size: 13px;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--white); color: var(--ink);
  transition: all .12s;
}
.btn:hover { border-color: var(--brass); color: var(--brass-dark); }
.btn.solid { background: var(--brass-dark); border-color: var(--brass-dark); color: var(--white); }
.btn.solid:hover { background: #75592B; color: var(--white); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: #99361A; border-color: #C9A093; }
.btn.danger:hover { background: #F4E2DB; border-color: #99361A; }

/* left toolbar */
.toolbar {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto;
}
.tool-btn {
  width: 40px; height: 40px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  transition: all .12s;
}
.tool-btn svg { width: 21px; height: 21px; }
.tool-btn:hover { background: var(--white); color: var(--ink); border-color: var(--line); }
.tool-btn.active { background: var(--brass-dark); color: var(--white); border-color: var(--brass-dark); }
.tool-btn.toggle.active { background: #DCCFB2; color: var(--ink); border-color: var(--brass); }
.toolbar-sep { width: 26px; height: 1px; background: var(--line); margin: 6px 0; }

/* canvas */
.canvas-wrap { flex: 1; position: relative; min-width: 0; display: flex; flex-direction: column; }
#plan-svg { flex: 1; width: 100%; height: 100%; background: var(--canvas); touch-action: none; display: block; }
.statusbar {
  display: flex; gap: 18px; align-items: center;
  padding: 5px 14px; font-size: 11px; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--line);
  font-family: 'Space Mono', monospace;
}
.status-hint { margin-left: auto; opacity: 0.75; font-family: 'Manrope', sans-serif; }
.status-hint-dyn { color: var(--accent); font-weight: 700; font-family: 'Manrope', sans-serif; }
.props-body input[type="range"] { flex: 1; accent-color: var(--brass-dark); }

/* right sidebar */
.sidebar {
  width: 265px; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
}
.panel { padding: 14px; border-bottom: 1px solid var(--line); }
.panel h3 {
  margin: 0 0 10px; font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--brass-dark); font-family: 'Space Mono', monospace; font-weight: 700;
}
.lib-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.lib-tab {
  font-family: inherit; font-size: 11px; font-weight: 600; padding: 4px 9px;
  border-radius: 20px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); cursor: pointer;
}
.lib-tab.active { background: var(--brass-dark); color: var(--white); border-color: var(--brass-dark); }
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lib-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  font-family: inherit; text-align: left; padding: 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--white); cursor: pointer;
  transition: all .12s;
}
.lib-item:hover { border-color: var(--brass); transform: translateY(-1px); }
.lib-preview { width: 100%; height: 46px; display: block; background: var(--canvas); border-radius: 5px; border: 1px solid rgba(0,0,0,.08); }
.lib-name { font-size: 11.5px; font-weight: 600; }
.lib-size { font-size: 10px; color: var(--muted); font-family: 'Space Mono', monospace; }

.lib-add-btn { width: 100%; margin-top: 10px; }
.lib-add-form { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.lib-add-form.open { display: block; }
.lib-add-form label { display: flex; align-items: center; gap: 7px; font-size: 12px; margin-bottom: 8px; color: var(--muted); }
.lib-add-form input[type="text"] { flex: 1; min-width: 0; font-family: inherit; font-size: 12.5px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.lib-add-form input[type="number"] { width: 62px; font-family: inherit; font-size: 12.5px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.lib-add-form input[type="color"] { width: 44px; height: 26px; padding: 1px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.lib-add-form .u { font-size: 10.5px; color: var(--muted); }
.lib-empty { font-size: 12px; color: var(--muted); grid-column: 1 / -1; padding: 6px 2px; }

/* properties */
.props-body label { display: flex; align-items: center; gap: 7px; font-size: 12px; margin-bottom: 8px; color: var(--muted); }
.props-body input[type="text"], .props-body input[type="number"], .props-body select {
  font-family: inherit; font-size: 12.5px; padding: 5px 7px; flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink);
}
.props-body input[type="number"] { width: 62px; flex: none; }
.props-body .u { font-size: 10.5px; color: var(--muted); }
.prop-row { display: flex; gap: 12px; }
.prop-title { font-weight: 800; font-size: 13.5px; margin-bottom: 10px; }
.prop-hint { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 10px; opacity: .85; }
.prop-static { font-size: 13px; margin-bottom: 8px; }
.prop-actions { display: flex; gap: 6px; margin-top: 6px; }
.chk { cursor: pointer; }
.chk input { accent-color: var(--brass-dark); }

/* ---------- responsive / mobile ---------- */
@media (max-width: 900px) {
  .sidebar { width: 225px; }
  .status-hint { display: none; }
  .name-input { width: 120px; }
}
@media (max-width: 700px) {
  .workspace { flex-direction: column; }
  .toolbar {
    flex-direction: row; order: 2; border-right: none; border-top: 1px solid var(--line);
    overflow-x: auto; overflow-y: hidden; padding: 6px 8px; flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
  }
  .toolbar-sep { width: 1px; height: 26px; margin: 0 6px; flex-shrink: 0; }
  .tool-btn { flex-shrink: 0; }
  .sidebar { width: 100%; order: 3; max-height: 42vh; }
  .canvas-wrap { order: 1; min-height: 44vh; }
  .topbar { gap: 6px; padding: 6px 8px; }
  .brand { font-size: 17px; }
  .name-input { width: 90px; font-size: 13px; padding: 5px 6px; }
  .btn { padding: 7px 10px; font-size: 12px; }
  .mini-label { display: none; }          /* snap & units still reachable via defaults */
  .statusbar { gap: 10px; }
  #status-pos { display: none; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
/* touch devices: larger targets regardless of screen width */
@media (pointer: coarse) {
  .tool-btn { width: 44px; height: 44px; }
  .btn { padding: 9px 14px; }
  .lib-item { padding: 10px; }
  .props-body input[type="number"], .props-body input[type="text"], .props-body select,
  .lib-add-form input[type="number"], .lib-add-form input[type="text"] { padding: 8px; font-size: 14px; }
}
