/* ── Reset & Variables ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --toolbar-h:  40px;
  --props-w:    330px;
  --board-bg:   #c8c4bc;
  --board-edge: #9e9b93;
  --panel-edge: #9e9b93;
  --int-bg:     transparent;
  --cell-bdr:   #cac7c0;
  --accent:     #007acc;
  --sel-bg:     rgba(0,122,204,.14);
  --canvas-bg:  #d6dce4;
  --tb-bg:      #2d2d30;
  --props-bg:   #f3f3f3;
}

html, body { height: 100%; overflow: hidden; font: 13px/1.4 'Segoe UI', system-ui, sans-serif; }

/* ── Layout ────────────────────────────────────────────────────── */

#app { display: flex; flex-direction: column; height: 100%; background: #1e1e1e; }

#main { display: flex; flex: 1; flex-direction: column; overflow: hidden; }

/* ── Tab bar ────────────────────────────────────────────────────── */

#tab-bar {
  display: flex;
  align-items: stretch;
  background: #252527;
  border-bottom: 1px solid #3a3a3d;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
#tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border: none;
  border-right: 1px solid #3a3a3d;
  background: #2d2d30;
  color: #999;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  flex-shrink: 0;
  outline: none;
}
.tab-item:hover { background: #3a3a3d; color: #ddd; }
.tab-item.active {
  background: #1e1e1e;
  color: #fff;
  border-bottom: 2px solid var(--accent);
}
.tab-item.tab-cutplan { padding-right: 14px; }
.tab-item.tab-cutplan.active { border-bottom-color: #c8a97a; }

.tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 11px;
  opacity: 0.5;
  margin-left: 2px;
  flex-shrink: 0;
}
.tab-close:hover { opacity: 1; background: rgba(255,255,255,0.12); }

.tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
}
.tab-add:hover { color: #fff; background: #3a3a3d; }

/* ── Cut plan panel ─────────────────────────────────────────────── */

#cutplan-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1e1e2e;
  color: #ccc;
}
#cutplan-panel[hidden] { display: none; }

/* When cut plan/cutlist tab is active, hide mobile pages + props */
#app.tab--cutplan #mobile-pages  { display: none; }
#app.tab--cutplan #props-panel   { display: none; }
#app.tab--cutplan #mobile-tabbar { display: none; }
#app.tab--cutplan #cutplan-panel { display: flex; }
#app.tab--cutplan #cutlist-panel { display: flex; }

/* Panel despiece */
#cutlist-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1e1e2e;
  color: #ccc;
}
#cutlist-panel[hidden] { display: none; }

/* Barra superior segunda (optimizador) */
#opt-topbar2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  background: #252537;
  border-bottom: 1px solid #383860;
  flex-shrink: 0;
  flex-wrap: wrap;
  font-size: 12px;
  color: #ccc;
}

/* Barra superior */
#opt-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  background: #252537;
  border-bottom: 1px solid #383860;
  flex-shrink: 0;
  flex-wrap: wrap;
}
#opt-source-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
}


/* Tabla de despiece dentro de la pestaña */
.cl-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 11px;
  color: #ccc;
}
.cl-table th {
  background: #2a2a40;
  padding: 4px 6px;
  text-align: left;
  border-bottom: 1px solid #383860;
  color: #aaa;
  font-weight: 600;
}
.cl-table td {
  padding: 3px 6px;
  border-bottom: 1px solid #2a2a3a;
}
.cl-table tr:last-child td { border-bottom: none; }
.cl-table .cl-group {
  background: #252537;
  font-weight: 700;
  color: #99aacc;
  padding: 5px 6px;
}

/* ── Validación despiece ──────────────────────────────────────── */
.cl-warnings {
  margin-top: 12px;
  padding: 10px 12px;
  background: #2a1a1a;
  border: 1px solid #5a2a2a;
  border-radius: 6px;
  font-size: 11px;
}
.cl-warn-title {
  font-weight: 700;
  color: #e88;
  margin-bottom: 6px;
  font-size: 11px;
}
.cl-warn-error {
  color: #f88;
  padding: 2px 0;
}
.cl-warn-warn {
  color: #ea3;
  padding: 2px 0;
}
.cl-validation-ok {
  margin-top: 10px;
  padding: 6px 10px;
  color: #6a6;
  font-size: 11px;
  border-top: 1px solid #2a2a3a;
}
[data-theme="light"] .cl-warnings { background: #fff0f0; border-color: #e8b8b8; }
[data-theme="light"] .cl-warn-title { color: #c44; }
[data-theme="light"] .cl-warn-error { color: #c33; }
[data-theme="light"] .cl-warn-warn { color: #a80; }
[data-theme="light"] .cl-validation-ok { color: #484; border-top-color: #ddd; }

/* ── Precios en tabla despiece ───────────────────────────────── */
.cl-table .cl-area,
.cl-table .cl-total-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cl-table .cl-price-cell { text-align: right; }
.cl-price {
  width: 62px; padding: 1px 4px; font-size: 11px; text-align: right;
  background: #1e1e30; border: 1px solid #3a3a5a; border-radius: 3px; color: #ddd;
  font-variant-numeric: tabular-nums;
}
.cl-price:focus { border-color: #007acc; outline: none; }
[data-theme="light"] .cl-price { background: #fff; border-color: #bbb; color: #222; }
[data-theme="light"] .cl-price:focus { border-color: #007acc; }

.cl-subtotal-row td {
  border-top: 2px solid #3a3a5a !important;
  font-weight: 700; color: #bcc; padding-top: 6px !important;
}
[data-theme="light"] .cl-subtotal-row td { border-top-color: #ccc !important; color: #333; }

/* ── Resumen presupuesto ─────────────────────────────────────── */
.budget-summary {
  margin-top: 18px; padding: 16px 18px;
  background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 8px;
}
.budget-title {
  font-size: 13px; font-weight: 700; color: #ccd; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.budget-row {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 12px; color: #aab;
}
.budget-row-val { font-variant-numeric: tabular-nums; color: #dde; }
.budget-sep { border-top: 1px solid #3a3a5a; margin: 8px 0; }
.budget-grand {
  display: flex; justify-content: space-between; padding: 8px 0 4px;
  font-size: 14px; font-weight: 700; color: #fff;
}
.budget-grand-val {
  font-variant-numeric: tabular-nums;
  color: #4db8ff;
}
.budget-actions {
  display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap;
}
.budget-actions button {
  font-size: 12px; padding: 5px 14px; border-radius: 4px; cursor: pointer; border: none;
}
.budget-btn-csv {
  background: #2a2a4a; color: #aab;
}
.budget-btn-csv:hover { background: #3a3a5a; }
.budget-btn-pdf {
  background: #007acc; color: #fff;
}
.budget-btn-pdf:hover { background: #0090e8; }
.budget-btn-save {
  background: #16a34a; color: #fff;
}
.budget-btn-save:hover    { background: #15803d; }
.budget-btn-save:disabled { background: #555; color: #aaa; cursor: not-allowed; }

[data-theme="light"] .budget-summary { background: #f5f7fa; border-color: #dde; }
[data-theme="light"] .budget-title { color: #333; }
[data-theme="light"] .budget-row { color: #555; }
[data-theme="light"] .budget-row-val { color: #222; }
[data-theme="light"] .budget-sep { border-top-color: #ccc; }
[data-theme="light"] .budget-grand { color: #111; }
[data-theme="light"] .budget-grand-val { color: #007acc; }
[data-theme="light"] .budget-btn-csv { background: #e8eaee; color: #444; }
[data-theme="light"] .budget-btn-csv:hover { background: #d8dadd; }
[data-theme="light"] .budget-btn-save { background: #16a34a; color: #fff; }
[data-theme="light"] .budget-btn-save:hover { background: #15803d; }

/* ── Diálogo Presupuesto (modal independiente) ────────────────── */
#dlg-budget {
  display: none; border: none; border-radius: 12px; padding: 0;
  background: #1e1e2e; color: #ddd;
  box-shadow: 0 12px 56px rgba(0,0,0,.55);
  width: min(96vw, 720px); max-height: 92vh;
}
#dlg-budget[open] {
  display: flex; flex-direction: column;
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%); margin: 0;
}
#dlg-budget::backdrop { background: rgba(0,0,0,.55); }
[data-theme="light"] #dlg-budget { background: #f8f8fa; color: #222; box-shadow: 0 12px 56px rgba(0,0,0,.25); }

.dlg-budget-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: #14141f; border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
}
[data-theme="light"] .dlg-budget-hdr { background: #ebebef; border-bottom-color: #ddd; }
.dlg-budget-htitle { font-size: 15px; font-weight: 700; color: #fff; }
[data-theme="light"] .dlg-budget-htitle { color: #111; }
.dlg-budget-name {
  flex: 1; font-size: 12px; color: #889;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
[data-theme="light"] .dlg-budget-name { color: #777; }
.dlg-budget-x {
  background: none; border: none; color: #888; cursor: pointer;
  font-size: 16px; padding: 0 6px; line-height: 1;
}
.dlg-budget-x:hover { color: #ddd; }
[data-theme="light"] .dlg-budget-x:hover { color: #111; }

.dlg-budget-body {
  flex: 1; overflow-y: auto; padding: 18px 22px 22px;
  display: flex; flex-direction: column; gap: 14px;
}

.bdg-section {
  background: #14141f; border: 1px solid #2a2a4a; border-radius: 8px;
  padding: 12px 14px;
}
[data-theme="light"] .bdg-section { background: #fff; border-color: #ddd; }
.bdg-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #99a; margin-bottom: 10px;
}
[data-theme="light"] .bdg-section-title { color: #666; }

.bdg-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.bdg-table th {
  text-align: left; font-weight: 600; padding: 4px 8px;
  border-bottom: 1px solid #2a2a4a; color: #aab; font-size: 11px;
}
[data-theme="light"] .bdg-table th { border-bottom-color: #ddd; color: #777; }
.bdg-table td {
  padding: 5px 8px; color: #ccd; border-bottom: 1px solid #20203a;
}
[data-theme="light"] .bdg-table td { color: #333; border-bottom-color: #eee; }
.bdg-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.bdg-table td.cost { font-weight: 600; color: #dde; }
[data-theme="light"] .bdg-table td.cost { color: #111; }
.bdg-table tr:last-child td { border-bottom: none; }
.bdg-table input.bdg-price {
  background: #1e1e2e; border: 1px solid #3a3a5a; border-radius: 4px;
  color: #ccd; font-size: 12px; padding: 2px 6px; width: 60px;
  text-align: right; font-variant-numeric: tabular-nums;
}
[data-theme="light"] .bdg-table input.bdg-price {
  background: #fff; border-color: #ccc; color: #222;
}
.bdg-empty {
  font-size: 12px; color: #889; text-align: center; padding: 14px 0;
}

.bdg-subtotal {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed #2a2a4a;
  font-size: 12px; color: #aab;
}
[data-theme="light"] .bdg-subtotal { border-top-color: #ddd; color: #555; }
.bdg-subtotal-val {
  font-weight: 700; font-variant-numeric: tabular-nums; color: #dde;
}
[data-theme="light"] .bdg-subtotal-val { color: #111; }

.bdg-pro-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; font-size: 12px; color: #aab;
}
[data-theme="light"] .bdg-pro-row { color: #555; }
.bdg-pro-row input[type="number"] {
  background: #1e1e2e; border: 1px solid #3a3a5a; border-radius: 4px;
  color: #ccd; font-size: 12px; padding: 2px 6px;
  text-align: right; font-variant-numeric: tabular-nums;
}
[data-theme="light"] .bdg-pro-row input[type="number"] {
  background: #fff; border-color: #ccc; color: #222;
}
.bdg-pro-val { font-variant-numeric: tabular-nums; color: #dde; font-weight: 600; }
[data-theme="light"] .bdg-pro-val { color: #111; }
.bdg-pro-hint {
  font-size: 11px; color: #778; margin-bottom: 8px;
  padding: 6px 10px; background: rgba(40, 100, 200, .12); border-radius: 4px;
}
[data-theme="light"] .bdg-pro-hint { color: #555; background: rgba(0, 100, 200, .08); }

.bdg-grand {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 18px;
  background: linear-gradient(135deg, #0078d4 0%, #005a9e 100%);
  border-radius: 8px; color: #fff;
  font-size: 16px; font-weight: 700;
  margin-top: 4px;
}
.bdg-grand-val { font-size: 22px; font-variant-numeric: tabular-nums; }

.bdg-actions {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
  margin-top: 4px;
}
.bdg-actions button {
  font-size: 12px; padding: 7px 16px; border-radius: 5px; cursor: pointer;
  border: 1px solid #3a3a5a; background: #2a2a4a; color: #ccd;
  font-family: inherit;
}
.bdg-actions button:hover { background: #3a3a5a; color: #fff; }
.bdg-actions button.primary { background: #007acc; border-color: #007acc; color: #fff; }
.bdg-actions button.primary:hover { background: #0090e8; }
[data-theme="light"] .bdg-actions button { background: #ebebef; border-color: #ccc; color: #333; }
[data-theme="light"] .bdg-actions button:hover { background: #ddd; color: #111; }

/* ── STL export dialog ───────────────────────────────────────── */
.stl-export-dlg { background: #1e1e2e; color: #ddd; border: 1px solid #444; border-radius: 10px; padding: 20px; max-width: 420px; }
.stl-export-dlg::backdrop { background: rgba(0,0,0,.5); }
.stl-scale-btn:hover { background: #3a3a5a !important; border-color: #0078d4 !important; }
[data-theme="light"] .stl-export-dlg { background: #fff; color: #333; border-color: #ccc; }
[data-theme="light"] .stl-scale-btn { background: #f0f0f0 !important; color: #333 !important; border-color: #bbb !important; }
[data-theme="light"] .stl-scale-btn:hover { background: #e0e0e0 !important; border-color: #0078d4 !important; }

/* ── Board catalog picker ────────────────────────────────────── */
.dlg-board-picker { background: #1e1e2e; color: #ddd; border: 1px solid #444; border-radius: 10px; padding: 20px; max-width: 680px; width: 90vw; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; }
.dlg-board-picker::backdrop { background: rgba(0,0,0,.5); }
.board-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; overflow-y: auto; flex: 1; padding: 2px; }
.board-card { display: flex; gap: 8px; padding: 8px; border: 1px solid #3a3a4a; border-radius: 6px; cursor: pointer; transition: border-color .15s, background .15s; }
.board-card:hover { border-color: #0078d4; background: #2a2a3a; }
.board-swatch { width: 48px; height: 48px; border-radius: 4px; flex-shrink: 0; background-size: cover; background-position: center; border: 1px solid #555; }
.board-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.board-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-vendor { font-size: 9px; color: #888; }
.board-meta { font-size: 9px; color: #6a8; }
[data-theme="light"] .dlg-board-picker { background: #fff; color: #333; border-color: #ccc; }
[data-theme="light"] .dlg-board-picker select, [data-theme="light"] .dlg-board-picker input { background: #f5f5f5; color: #333; border-color: #bbb; }
[data-theme="light"] .board-card { border-color: #ddd; }
[data-theme="light"] .board-card:hover { border-color: #0078d4; background: #f0f5ff; }
[data-theme="light"] .board-swatch { border-color: #ccc; }
[data-theme="light"] .board-vendor { color: #888; }

/* ── Herrajes sugeridos ────────────────────────────────────────── */
.cl-hw-title {
  margin-top: 18px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #99aacc;
  text-transform: uppercase;
  letter-spacing: .06em;
}
[data-theme="light"] .cl-hw-title { color: #556; }
.hs-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #2a2a3a;
}
.hs-title {
  font-size: 10px;
  font-weight: 700;
  color: #99aacc;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}
.hs-group { margin-bottom: 14px; }
.hs-group-label {
  font-size: 11px;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 6px;
}
.hs-hint { font-weight: 400; color: #555; margin-left: 4px; }
.hs-cards { display: flex; flex-direction: column; gap: 5px; }
.hs-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: #1e1e2e;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  text-decoration: none;
  transition: border-color .15s;
}
.hs-card:hover { border-color: #4a4a7a; }
.hs-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 4px;
  background: #252537;
  flex-shrink: 0;
}
.hs-no-img {
  width: 42px;
  height: 42px;
  border-radius: 4px;
  background: #252537;
  flex-shrink: 0;
}
.hs-card-body { flex: 1; min-width: 0; }
.hs-name {
  font-size: 10px;
  color: #ccc;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hs-price {
  font-size: 11px;
  font-weight: 700;
  color: #e8c44a;
  margin-top: 3px;
}
.hs-rating {
  font-size: 9px;
  color: #e8c44a;
  margin-top: 1px;
}
.hs-reviews { color: #888; font-size: 9px; }
.hs-source {
  display: inline-block;
  font-size: 8px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.hs-source-amazon { background: #ff9900; color: #111; }
.hs-source-ikea   { background: #0058a3; color: #fff; }

/* ── Botón comprar push-to-open en tabla herrajes ──────────── */
.hw-buy-btn {
  display: inline-block;
  font-size: 9px;
  padding: 2px 7px;
  margin-left: 8px;
  border: 1px solid #4a7a4a;
  border-radius: 4px;
  background: #2a3a2a;
  color: #8fc88f;
  cursor: pointer;
  vertical-align: middle;
  transition: background .15s, border-color .15s;
}
.hw-buy-btn:hover { background: #3a5a3a; border-color: #6aaa6a; }

/* ── Diálogo push-to-open compra ───────────────────────────── */
.pto-buy-dlg {
  border: none;
  border-radius: 10px;
  background: #1a1a2a;
  color: #ccc;
  padding: 0;
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}
.pto-buy-dlg::backdrop { background: rgba(0,0,0,.55); }
.pto-buy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid #2a2a3a;
  position: sticky;
  top: 0;
  background: #1a1a2a;
  z-index: 1;
}
.pto-buy-close {
  background: none; border: none; color: #888; font-size: 20px; cursor: pointer; padding: 0 4px;
}
.pto-buy-close:hover { color: #fff; }
.pto-buy-empty { padding: 20px; color: #888; text-align: center; font-size: 12px; }
.pto-buy-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
}
.pto-buy-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #1e1e2e;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  text-decoration: none;
  transition: border-color .15s;
}
.pto-buy-card:hover { border-color: #4a7a4a; }
.pto-buy-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 4px;
  background: #252537;
  flex-shrink: 0;
}
.pto-buy-no-img {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  background: #252537;
  flex-shrink: 0;
}
.pto-buy-card-body { flex: 1; min-width: 0; }
.pto-buy-name {
  font-size: 11px;
  color: #ddd;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pto-buy-rating {
  font-size: 10px;
  color: #e8c44a;
  margin-top: 2px;
}
.pto-buy-reviews { color: #888; font-size: 9px; }
.pto-buy-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  color: #e8c44a;
}
.pto-buy-source {
  display: inline-block;
  font-size: 8px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.pto-buy-source-amazon { background: #ff9900; color: #111; }
.pto-buy-source-ikea   { background: #0058a3; color: #fff; }

/* ── Light theme overrides ─ */
[data-theme="light"] .hw-buy-btn { background: #e8f4e8; color: #2a6a2a; border-color: #a0d0a0; }
[data-theme="light"] .hw-buy-btn:hover { background: #d0ecd0; }
[data-theme="light"] .pto-buy-dlg { background: #faf9f5; color: #333; }
[data-theme="light"] .pto-buy-header { background: #faf9f5; border-bottom-color: #d4d0c8; }
[data-theme="light"] .pto-buy-card { background: #f0efe8; border-color: #d4d0c8; }
[data-theme="light"] .pto-buy-card:hover { border-color: #a0d0a0; }
[data-theme="light"] .pto-buy-name { color: #333; }
[data-theme="light"] .hs-source-amazon { background: #ff9900; color: #111; }

/* Móvil: apilar columnas */
@media (max-width: 768px) {
  #opt-content { flex-direction: column; }
  #opt-cutlist-section { width: 100%; border-right: none; border-bottom: 1px solid #383860; max-height: 40vh; }
}



/* ── PWA install banner ────────────────────────────────────────── */
#pwa-install-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  background: #1e1e2e; color: #eee;
  padding: 10px 16px;
  box-shadow: 0 -2px 12px rgba(0,0,0,.4);
  font-size: 13px;
}
#pwa-install-banner[hidden] { display: none; }
#pwa-install-banner img { width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0; }
#pwa-install-banner span { flex: 1; }
#pwa-install-btn {
  background: var(--accent, #007acc); color: #fff;
  border: none; border-radius: 6px; padding: 6px 14px;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
#pwa-install-dismiss {
  background: transparent; border: none; color: #aaa;
  font-size: 16px; cursor: pointer; padding: 4px 6px;
  flex-shrink: 0;
}

/* ── Toolbar ───────────────────────────────────────────────────── */

#toolbar {
  display: flex; align-items: center; gap: 4px; padding: 0 8px;
  height: var(--toolbar-h); background: var(--tb-bg); flex-shrink: 0; user-select: none;
  position: relative; z-index: 600;
}
.tb-app-name {
  font-size: 13px; font-weight: 600; color: #c8c8c8;
  letter-spacing: .5px; padding: 0 6px 0 2px; white-space: nowrap; user-select: none;
}
.tb-new-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 6px; padding: 0 10px; height: 30px;
  font-size: 14px; font-weight: 600; line-height: 1;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
}
.tb-new-icon { font-size: 20px; font-weight: 700; }
.tb-new-label { font-size: 13px; }
.tb-new-btn:hover { filter: brightness(1.15); }
.tb-new-btn:active { filter: brightness(0.9); }
.tb-spc  { flex: 1; }
.tb-lbl  { color: #999; font-size: 11px; padding: 0 4px; white-space: nowrap; }
.tb-unit-toggle {
  background: #3a3a3d; color: #ccc; border: 1px solid #555;
  border-radius: 4px; padding: 2px 7px; font-size: 11px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.tb-unit-toggle:hover { background: #555; color: #fff; }
.tb-unit-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tb-unit-toggle:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Botón 3D ──────────────────────────────────────────────────── */
#btn-3d {
  padding: 2px 10px; border: none; border-radius: 3px; font-size: 13px;
  background: transparent; color: #ccc; cursor: pointer; font: inherit; white-space: nowrap;
}
#btn-3d:hover  { background: #4a4a4d; color: #fff; }
#btn-3d:active { background: var(--accent); color: #fff; }

/* ── Separador de menú ─────────────────────────────────────────── */
.tb-drop-sep,
.mb-sep { border: none; border-top: 1px solid #555; margin: 3px 0; }

/* ── Items de menú (botones y links) ───────────────────────────── */
.mb-panel button,
.mb-panel .tb-drop-link {
  padding: 7px 14px; border: none; border-radius: 3px;
  background: transparent; color: #ccc; cursor: pointer;
  font: inherit; font-size: 13px;
  white-space: nowrap; text-align: left; width: 100%;
  display: block; text-decoration: none;
}
.mb-panel button:hover,
.mb-panel .tb-drop-link:hover  { background: #4a4a4d; color: #fff; }
.mb-panel button:active,
.mb-panel .tb-drop-link:active { background: var(--accent); color: #fff; }
.mb-panel button.active { background: var(--accent); color: #fff; }
.mb-panel button.tb-drop-danger { color: #f66; }
.mb-panel button.tb-drop-danger:hover { background: #c0392b; color: #fff; }

/* ══════════════════════════════════════════════════════════════════
   MÓVIL (≤768px): hamburguesa + dropdown con cabeceras de sección
   ══════════════════════════════════════════════════════════════════ */
#btn-hamburger {
  padding: 0 10px; border: none; border-radius: 3px; font-size: 16px;
  background: transparent; color: #ccc; cursor: pointer; font: inherit;
  line-height: 1; align-self: stretch;
}
#btn-hamburger:hover  { background: #4a4a4d; color: #fff; }
#btn-hamburger:active { background: var(--accent); color: #fff; }

/* El nav-dropdown: oculto por defecto en móvil */
.tb-dropdown {
  display: none; flex-direction: column;
  position: absolute; top: var(--toolbar-h); left: 0;
  background: var(--tb-bg); border: 1px solid #555; border-top: none;
  border-radius: 0 0 6px 6px; padding: 4px 0;
  z-index: 900; min-width: 230px;
  box-shadow: 4px 6px 16px rgba(0,0,0,.5);
  max-height: calc(100vh - var(--toolbar-h)); overflow-y: auto;
}
.tb-dropdown.open { display: flex; }

/* ── Menú móvil drill-down (un nivel por pantalla) ─────────────── */
/* En drill-down: ocultar los .mb-group originales */
.tb-dropdown.mb-drilldown > .mb-group { display: none; }

/* Header del drill-down (título + botón cerrar) */
.mb-drill-header {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 6px 10px; border-bottom: 1px solid #444;
}
.mb-drill-header-title {
  font-size: 15px; font-weight: 700; color: #eee;
}
.mb-drill-close {
  background: transparent; border: none; color: #999; cursor: pointer;
  font-size: 18px; padding: 4px 8px; border-radius: 4px; line-height: 1;
}
.mb-drill-close:hover { background: #4a4a4d; color: #fff; }
[data-theme="light"] .mb-drill-header { border-bottom-color: #c4c0b8; }
[data-theme="light"] .mb-drill-header-title { color: #222; }
[data-theme="light"] .mb-drill-close { color: #666; }
[data-theme="light"] .mb-drill-close:hover { background: #cac6be; color: #111; }

/* Botón de vuelta atrás */
.mb-back-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; border: none; border-radius: 0;
  background: transparent; color: var(--accent); cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600;
  width: 100%; text-align: left;
  border-bottom: 1px solid #444;
}
.mb-back-btn:hover { background: #4a4a4d; color: #fff; }
.mb-back-btn:active { background: var(--accent); color: #fff; }
[data-theme="light"] .mb-back-btn { color: var(--accent); border-bottom-color: #c4c0b8; }
[data-theme="light"] .mb-back-btn:hover { background: #cac6be; color: #111; }

/* Título del nivel actual */
.mb-level-title {
  display: block; padding: 8px 14px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .8px;
  color: #888; text-transform: uppercase; pointer-events: none;
}
[data-theme="light"] .mb-level-title { color: #666; }

/* Item de nivel raíz (accede a un grupo) */
/* Items del menú móvil: mismas dimensiones visuales que en desktop
   (padding 7px 14px, font-size 13px) con un min-height suficiente para
   mantener buena área de toque (~40px). */
.mb-root-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; min-height: 40px;
  border: none; border-radius: 3px;
  background: transparent; color: #ccc; cursor: pointer;
  font: inherit; font-size: 13px; width: 100%; text-align: left;
}
.mb-root-item:hover { background: #4a4a4d; color: #fff; }
.mb-root-item:active { background: var(--accent); color: #fff; }
.mb-root-arrow { opacity: .5; font-size: 12px; }
[data-theme="light"] .mb-root-item { color: #333; }
[data-theme="light"] .mb-root-item:hover { background: #cac6be; color: #111; }

/* Items de nivel hijo (clones de .mb-panel buttons) */
.mb-drill-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; min-height: 40px;
  border: none; border-radius: 3px;
  background: transparent; color: #ccc; cursor: pointer;
  font: inherit; font-size: 13px; width: 100%; text-align: left;
  text-decoration: none;
}
.mb-drill-item:hover { background: #4a4a4d; color: #fff; }
.mb-drill-item:active { background: var(--accent); color: #fff; }
.mb-drill-item.tb-drop-danger { color: #f66; }
.mb-drill-item.tb-drop-danger:hover { background: #c0392b; color: #fff; }
[data-theme="light"] .mb-drill-item { color: #333; }
[data-theme="light"] .mb-drill-item:hover { background: #cac6be; color: #111; }

/* Separador dentro del drill-down */
.mb-drill-sep { border: none; border-top: 1px solid #444; margin: 3px 0; }
[data-theme="light"] .mb-drill-sep { border-top-color: #c4c0b8; }

/* Cabecera de sección en móvil (solo cuando NO drill-down, ya no se usa) */
.mb-group::before {
  content: attr(data-label);
  display: none; padding: 8px 14px 2px;
  font-size: 10px; font-weight: 700; letter-spacing: .9px;
  color: #777; text-transform: uppercase; pointer-events: none;
}
/* Separador visual entre grupos en móvil */
.mb-group + .mb-group { border-top: 1px solid #444; padding-top: 2px; margin-top: 2px; }

/* Trigger oculto en móvil (el label lo da ::before) */
.mb-trigger { display: none; }

/* Panel de items: oculto en móvil (drill-down lo reemplaza) */
.mb-panel { display: none; flex-direction: column; }

/* ══════════════════════════════════════════════════════════════════
   DESKTOP (>768px): menubar horizontal clásico
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  #btn-hamburger { display: none; }

  /* El nav se integra inline en el toolbar como barra de menús */
  .tb-dropdown {
    display: flex !important; flex-direction: row; align-items: stretch;
    align-self: stretch;               /* ocupa todo el alto del toolbar */
    position: static; background: transparent; border: none;
    border-radius: 0; padding: 0; box-shadow: none; min-width: 0;
    max-height: none; overflow: visible;
  }

  /* Cada grupo es un ítem de la barra con su propio dropdown */
  .mb-group {
    position: relative; display: flex; align-items: stretch;
  }
  /* Ocultar el ::before en desktop (ya no hace de label) */
  .mb-group::before { display: none; }
  .mb-group + .mb-group { border-top: none; padding-top: 0; margin-top: 0; }

  /* Trigger: el botón real visible en la barra */
  .mb-trigger {
    display: flex; align-items: center;
    padding: 0 11px; font-size: 13px; font-weight: 400;
    background: transparent; color: #ccc; border: none;
    cursor: pointer; white-space: nowrap; border-radius: 3px;
    font: inherit; align-self: stretch;
  }
  .mb-trigger:hover,
  .mb-trigger:focus-visible,
  .mb-group:hover .mb-trigger,
  .mb-group.mb-open .mb-trigger { background: #4a4a4d; color: #fff; outline: none; }

  /* El panel: oculto por defecto */
  .mb-panel {
    display: none; flex-direction: column;
    position: absolute; top: 100%; left: 0;
    background: var(--tb-bg); border: 1px solid #555; border-top: none;
    border-radius: 0 0 6px 6px; padding: 4px 0;
    min-width: 210px; z-index: 910;
    box-shadow: 4px 6px 16px rgba(0,0,0,.5);
  }
  /* Abierto por hover (mouse) O por clase mb-open (teclado) */
  .mb-group:hover .mb-panel,
  .mb-group.mb-open .mb-panel { display: flex; }

  /* Drill-down elements hidden on desktop */
  .mb-drill-level, .mb-back-btn, .mb-root-item, .mb-drill-item, .mb-level-title, .mb-drill-header { display: none !important; }
  .tb-dropdown.mb-drilldown > .mb-group { display: flex; }
}

/* ── Canvas ────────────────────────────────────────────────────── */

#canvas-area {
  flex: 1; overflow: auto; position: relative;
  background-color: #1c1f28;
  background-attachment: local;
  /* Anclamos la escena a la esquina INFERIOR-IZQUIERDA del lienzo:
     - align-items: flex-end → suelo (mundo y=0) abajo; al añadir
       muebles encima crece hacia ARRIBA sin reposicionar lo de abajo.
     - justify-content: flex-start → pared izquierda (mundo x=0) a la
       izquierda; al añadir muebles a la derecha crece hacia ALLÍ sin
       desplazar lo de la izquierda.
     Necesario para la convención Cartesiana del editor. */
  display: flex; align-items: flex-end; justify-content: flex-start;
  outline: none; position: relative;
  -webkit-touch-callout: none;
  user-select: none;
}

#furniture-stage {
  padding: 0;
  position: relative;
  min-width: 100%; min-height: 100%;
}

/* ── Navegador A-Z de propiedades (paralelo al panel) ──────────── */
/* Indicador flotante eliminado — se sustituyó por el modal A-Z. */

.prop-az-popover {
  position: fixed;
  top: 48px; right: 8px;
  /* Tamaño mínimo posible: ajusta al contenido. Cap razonable para no
     desbordar el viewport ni quedarse demasiado estrecho para inputs. */
  width: max-content;
  min-width: 200px;
  max-width: min(320px, calc(100vw - 16px));
  height: auto;
  /* Reservamos 200px para que el teclado A-Z (88px) + nav-bar (48px) + un
     margen no tapen la parte inferior del popover en móvil. */
  max-height: calc(100vh - 200px);
  background: var(--props-bg, #f5f5f5);
  border: 1px solid #bbb;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  display: none;
  flex-direction: column;
  z-index: 1400;
  overflow: hidden;
}
@media (min-width: 768px) {
  .prop-az-popover { max-height: calc(100vh - 60px); }
}
.prop-az-popover--open { display: flex; }
.prop-az-pop-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  background: rgba(0,0,0,.04);
  border-bottom: 1px solid #ddd;
  font: 600 12px system-ui, sans-serif;
}
.prop-az-pop-title { flex: 1; }
.prop-az-pop-scope {
  display: inline-flex;
  background: rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 2px;
  margin-right: 6px;
}
.prop-az-pop-scope[hidden] { display: none; }
.prop-az-scope-opt {
  background: none;
  border: none;
  color: #555;
  font: 600 11px system-ui, sans-serif;
  padding: 3px 10px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 56px;     /* zona táctil decente en móvil */
  min-height: 28px;
}
.prop-az-scope-opt--active {
  background: #007acc;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.prop-az-scope-opt:not(.prop-az-scope-opt--active):hover { color: #007acc; }
.prop-az-pop-close {
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  color: #666;
  padding: 4px 10px;
  min-width: 36px; min-height: 32px;
  border-radius: 6px;
  touch-action: manipulation;
}
.prop-az-pop-close:hover  { color: #000; background: rgba(0,0,0,.05); }
.prop-az-pop-close:active { background: rgba(0,0,0,.1); }
.prop-az-pop-body {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  /* pan-x pan-y permite scroll táctil en AMBOS ejes; sin esto, algunos
     iOS Safari no dejan hacer scroll horizontal con el dedo aunque
     overflow:auto esté activo. */
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
  padding: 4px 4px 8px;
}
.prop-az-empty { color: #888; font-size: 11px; padding: 10px; text-align: center; line-height: 1.4; }

/* Resize handle bottom-right */
.prop-az-pop-resize {
  position: absolute;
  right: 1px; bottom: 1px;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg,
      transparent 0%, transparent 45%,
      rgba(0,0,0,.35) 45%, rgba(0,0,0,.35) 55%,
      transparent 55%, transparent 70%,
      rgba(0,0,0,.35) 70%, rgba(0,0,0,.35) 80%,
      transparent 80%);
  z-index: 10;
}
.prop-az-pop-bar { user-select: none; }
/* Switch más compacto */
.prop-az-pop-scope { padding: 1px; }
.prop-az-scope-opt { padding: 2px 8px; min-width: 48px; min-height: 24px; font-size: 10px; }

/* ── Teclado de letras — tono claro acorde al resto del UI ──── */
.prop-az-kbd2 {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.35);
  z-index: 1500;
  -webkit-tap-highlight-color: transparent;
}
.prop-az-kbd2--show { display: flex; }
.prop-az-kbd2-box {
  background: var(--props-bg, #f5f5f5);
  border: 1px solid #ccc;
  border-radius: 12px;
  padding: 12px;
  width: min(340px, 92vw);
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.prop-az-kbd2-body--grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.prop-az-kbd2-body--list {
  display: flex; flex-direction: column; gap: 5px;
}
.prop-az-kbd2-key {
  background: #fff;
  border: 1px solid #d4d4d4;
  color: #2a2a2a;
  font: 600 16px system-ui, sans-serif;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 44px;
  transition: background .12s, border-color .12s;
}
.prop-az-kbd2-key:active { background: #007acc; color: #fff; border-color: #007acc; }
.prop-az-kbd2-key--hi { background: #e3f2fd; border-color: #007acc; box-shadow: 0 0 0 2px rgba(0,122,204,.25); }
.prop-az-kbd2-key--empty { background: #ececec; color: #b0b0b0; cursor: default; border-color: #e0e0e0; }
.prop-az-kbd2-key--empty:active { background: #ececec; color: #b0b0b0; }
.prop-az-kbd2-key--special { background: #f0f0f0; color: #555; border-color: #d0d0d0; }
.prop-az-kbd2-key--special:disabled { background: #ececec; color: #c0c0c0; cursor: default; }
.prop-az-kbd2-key--close { background: #fbe9e7; color: #b71c1c; border-color: #f0c1bc; }
.prop-az-kbd2-key--close:active { background: #b71c1c; color: #fff; border-color: #b71c1c; }
.prop-az-kbd2-key--section {
  text-align: left;
  padding: 12px 14px;
  font-size: 14px;
  background: #fafafa;
}
.prop-az-kbd2-key--section:active { background: #007acc; color: #fff; border-color: #007acc; }

/* ── Teclado A-Z horizontal (sólo móvil) ──────────────────── */
/* Pestaña lateral OCULTADA: se sustituye por la rueda flotante.
   Se mantiene el HTML/JS por compatibilidad pero nunca se ve. */
.prop-az-kbd-tab { display: none !important; }

/* Teclado: barra horizontal anclada arriba de la mobile-tabbar.
   Se oculta COMPLETAMENTE (display:none) cuando no está abierto, para
   no quedar superpuesto a los botones de la nav-bar inferior. */
.prop-az-kbd {
  position: fixed;
  left: 0; right: 0;
  bottom: 48px;                       /* altura de la mobile-tabbar */
  background: rgba(28,31,40,.96);
  border-top: 1px solid #444;
  z-index: 1310;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 4px 4px env(safe-area-inset-bottom, 4px);
}
.prop-az-kbd.prop-az-kbd--open { display: flex; }

/* Fila superior: indicador con flechas + abrir */
.prop-az-kbd-ind {
  display: flex; align-items: center; gap: 2px;
  padding: 0 4px;
}
.prop-az-kbd-arrow {
  background: transparent; border: none;
  color: #aab5c4; font-size: 18px; font-weight: 700;
  padding: 0 10px;
  border-radius: 6px;
  min-width: 36px; min-height: 30px;
  cursor: pointer;
}
.prop-az-kbd-arrow:active { background: rgba(255,255,255,.12); }
.prop-az-kbd-label {
  flex: 1; min-width: 0;
  background: transparent; border: none;
  color: #fff; font: 600 13px system-ui, sans-serif;
  text-align: center; padding: 0 8px;
  border-radius: 6px; min-height: 30px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.prop-az-kbd-label:active { background: rgba(255,255,255,.12); }

/* Fila de letras */
.prop-az-kbd-keys {
  display: grid;
  grid-template-columns: repeat(13, 1fr);  /* 2 filas × 13 cols */
  gap: 3px;
}
.prop-az-kbd-key {
  background: #353a45; border: 1px solid #3a3f4a;
  color: #e8ecf2; font: 600 12px system-ui, sans-serif;
  padding: 0; height: 30px;
  border-radius: 4px; cursor: pointer;
}
.prop-az-kbd-key:active { background: #444a57; }
.prop-az-kbd-key--empty { background: #2a2e38; color: #4a5260; cursor: default; }
.prop-az-kbd-key--active { background: #007acc; color: #fff; border-color: #007acc; }

/* ── Numpad inline (móvil) ───────────────────────────────────── */
.numpad-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.18);
  z-index: 1700;
  display: none;
  cursor: pointer;        /* iOS necesita cursor:pointer para clicks fiables en divs */
  touch-action: manipulation;
}
.numpad-backdrop--open { display: block; }
.numpad {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #2a2e38;
  color: #e8ecf2;
  border-top: 1px solid #444;
  box-shadow: 0 -4px 20px rgba(0,0,0,.35);
  z-index: 1800;
  display: none;
  padding: 6px 6px env(safe-area-inset-bottom, 6px);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.numpad--open { display: block; }
.numpad-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 6px;
  border-bottom: 1px solid #3a3f4a;
  margin-bottom: 6px;
}
.numpad-label { font: 600 11px system-ui, sans-serif; color: #9ba6b5; flex: 0 0 auto; }
.numpad-value { font: 700 18px ui-monospace, monospace; color: #fff; flex: 1; text-align: right; }
.numpad-close {
  background: transparent; border: none; color: #9ba6b5;
  font-size: 18px; cursor: pointer;
  padding: 4px 10px;
  min-width: 36px; min-height: 32px;
  border-radius: 6px;
  touch-action: manipulation;
}
.numpad-close:active { background: rgba(255,255,255,.12); color: #fff; }
.numpad-fx {
  background: transparent; border: 1px solid #3a3f4a; color: #b0bac8;
  font: 700 12px system-ui, sans-serif; cursor: pointer;
  padding: 4px 8px;
  min-width: 32px; min-height: 28px;
  border-radius: 6px;
  touch-action: manipulation;
}
.numpad-fx:active { background: rgba(255,255,255,.12); color: #fff; }
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  max-width: 360px;
  margin: 0 auto;
}
.numpad-key {
  border: 1px solid #3a3f4a;
  background: #353a45;
  color: #e8ecf2;
  font: 600 17px system-ui, sans-serif;
  padding: 0;
  height: 42px;
  border-radius: 6px;
  cursor: pointer;
}
.numpad-key:active { background: #444a57; }
.numpad-key--util { background: #2f343d; color: #b0bac8; font-size: 14px; }
.numpad-key--ok {
  background: #007acc;
  color: #fff;
  grid-row: span 2;
  height: auto;
}
.numpad-key--ok:active { background: #0066b0; }

/* ── Calculadora (F2) ──────────────────────────────────────────── */

.calc-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 100001;
  display: none;
  cursor: pointer;
  touch-action: manipulation;
}
.calc-backdrop--open { display: block; }
.calc-modal {
  position: fixed;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(320px, calc(100vw - 24px));
  background: #2a2e38;
  color: #e8ecf2;
  border: 1px solid #444;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  z-index: 100002;
  display: none;
  padding: 8px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.calc-modal--open { display: block; }
.calc-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 8px;
  border-bottom: 1px solid #3a3f4a;
}
.calc-label { font: 600 12px system-ui, sans-serif; color: #9ba6b5; flex: 1; }
.calc-close {
  background: transparent; border: none; color: #9ba6b5;
  font-size: 16px; cursor: pointer;
  padding: 2px 8px; min-width: 30px;
  border-radius: 4px;
}
.calc-close:active { background: rgba(255,255,255,.12); color: #fff; }
.calc-display {
  margin: 8px 4px 10px;
  background: #1e2128;
  border: 1px solid #3a3f4a;
  border-radius: 6px;
  padding: 8px 10px;
  text-align: right;
  min-height: 56px;
}
.calc-expr   { font: 600 14px ui-monospace, monospace; color: #b0bac8; min-height: 18px; word-break: break-all; }
.calc-result { font: 700 22px ui-monospace, monospace; color: #fff;    min-height: 26px; margin-top: 2px; }
.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.calc-key {
  border: 1px solid #3a3f4a;
  background: #353a45;
  color: #e8ecf2;
  font: 600 16px system-ui, sans-serif;
  padding: 0;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
}
.calc-key:active { background: #444a57; }
.calc-key--util { background: #2f343d; color: #b0bac8; font-size: 14px; }
.calc-key--op   { background: #3a4452; color: #cfd8e3; }
.calc-key--op:active { background: #4a5566; }
.calc-key--eq   { background: #007acc; color: #fff; }
.calc-key--eq:active { background: #0066b0; }
.calc-actions {
  display: flex; gap: 6px; justify-content: flex-end;
  margin-top: 10px;
  padding: 6px 4px 2px;
  border-top: 1px solid #3a3f4a;
}
.calc-cancel, .calc-ok {
  border: 1px solid #3a3f4a;
  background: #353a45;
  color: #e8ecf2;
  font: 600 13px system-ui, sans-serif;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.calc-ok { background: #007acc; border-color: #006bb0; }
.calc-ok:active     { background: #0066b0; }
.calc-cancel:active { background: #444a57; }

/* ── Properties ────────────────────────────────────────────────── */
/*
 * El panel lateral antiguo (#props-panel) y todo su sistema de docking,
 * floating, resize y zonas de anclaje fueron retirados al migrar al panel
 * rápido configurable (.quick-panel — definido más abajo). Las reglas
 * eliminadas vivían aquí entre 1373 y 1470 aprox.
 *
 * Placeholder de la página móvil de propiedades (#page-props) — invita al
 * usuario a abrir el panel rápido cuando llega a esa pestaña por swipe.
 */
.props-page-empty {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px; text-align: center; color: var(--text-muted, #888);
}
.props-page-empty .btn-primary {
  padding: 10px 24px; font-size: 14px; border-radius: 5px;
}

/* ── Object selector ───────────────────────────────────────────── */
.obj-select-wrap {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px; border-bottom: 1px solid #ddd; margin-bottom: 6px;
}
.obj-select-lbl { font-size: 10px; color: #888; white-space: nowrap; flex-shrink: 0; }
.obj-select {
  flex: 1; min-width: 120px; font-size: 11px; padding: 2px 4px;
  border: 1px solid #ccc; border-radius: 2px; background: #fff;
}
.obj-select-home {
  flex-shrink: 0; width: 24px; height: 24px; padding: 3px;
  border: 1px solid #ccc; border-radius: 3px; background: #f5f5f5;
  cursor: pointer; color: #555; display: flex; align-items: center; justify-content: center;
}
.obj-select-home:hover { background: #e0e0e0; color: #222; }

/* ── Chat con Paco — DESCONECTADO ─────────────────────────────
   El script js/chat.js está comentado en app.php. Esta regla es defensa
   para que aunque alguien rehabilite el script, la burbuja no aparezca.
   Para reactivar: quitar el display:none y descomentar el <script>. */
#paco-fab, #paco-panel { display: none !important; }

#paco-fab {
  position: fixed;
  right: 24px;
  bottom: 84px;
  z-index: 99999;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: #16a34a;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.32), 0 1px 3px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, box-shadow .12s, background .12s;
}
#paco-fab svg { width: 22px; height: 22px; }
#paco-fab:hover  { transform: translateY(-1px); background: #15803d; }
#paco-fab.open   { background: #525252; }
@media (max-width: 768px) {
  #paco-fab { bottom: 130px; }   /* deja sitio al tabbar móvil + fila bug */
}

#paco-panel {
  position: fixed;
  right: 24px;
  bottom: 144px;
  z-index: 99999;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 200px));
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.32), 0 2px 8px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  font: 13px/1.45 'Segoe UI', system-ui, sans-serif;
  color: #222;
}
@media (max-width: 768px) {
  #paco-panel { bottom: 188px; right: 16px; left: 16px; width: auto; }
}
#paco-panel[hidden] { display: none; }

.paco-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
}
.paco-hdr-left { display: flex; align-items: center; gap: 10px; }
.paco-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.paco-hdr-text { display: flex; flex-direction: column; line-height: 1.1; }
.paco-hdr-text strong { font-size: 14px; }
.paco-hdr-sub  { font-size: 11px; opacity: .85; }
.paco-hdr-actions { display: flex; align-items: center; gap: 4px; }
.paco-hdr-btn {
  background: transparent; border: none; cursor: pointer;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: rgba(255,255,255,.85);
}
.paco-hdr-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.paco-hdr-btn svg { width: 16px; height: 16px; }

.paco-close {
  background: transparent; border: none; color: #fff; font-size: 16px;
  cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.paco-close:hover { background: rgba(255,255,255,.18); }

.paco-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: #f5f5f4;
  display: flex; flex-direction: column; gap: 8px;
}
.paco-msg {
  max-width: 82%;
  padding: 8px 11px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.paco-msg--user {
  align-self: flex-end;
  background: #2563eb; color: #fff;
  border-bottom-right-radius: 4px;
}
.paco-msg--bot {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.paco-status {
  align-self: center;
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0 4px;
}
.paco-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f59e0b;
  animation: paco-pulse 1.4s ease-in-out infinite;
}
@keyframes paco-pulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50%       { opacity: 1;   transform: scale(1); }
}
[data-theme="dark"] .paco-status { color: #9ca3af; }

.paco-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.paco-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9ca3af;
  animation: paco-bounce 1.2s infinite ease-in-out both;
}
.paco-typing span:nth-child(2) { animation-delay: .15s; }
.paco-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes paco-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

.paco-form {
  display: flex; align-items: stretch; gap: 6px;
  padding: 8px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}
.paco-input {
  flex: 1;
  border: 1px solid #d4d4d8;
  border-radius: 18px;
  padding: 8px 12px;
  font: inherit;
  outline: none;
}
.paco-input:focus { border-color: #16a34a; }
.paco-input:disabled { background: #f5f5f4; color: #888; }
.paco-send {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: #16a34a; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.paco-send svg { width: 16px; height: 16px; }
.paco-send:hover  { background: #15803d; }
.paco-send:disabled { background: #9ca3af; cursor: default; }

[data-theme="dark"] #paco-panel { background: #1e1e22; color: #e8e8e8; }
[data-theme="dark"] .paco-list  { background: #161618; }
[data-theme="dark"] .paco-msg--bot { background: #2a2a2e; border-color: #3a3a40; color: #e8e8e8; }
[data-theme="dark"] .paco-form  { background: #1e1e22; border-top-color: #3a3a40; }
[data-theme="dark"] .paco-input { background: #2a2a2e; border-color: #3a3a40; color: #e8e8e8; }
[data-theme="dark"] .paco-input:disabled { background: #232328; color: #888; }

/* ── Botón "Guardar como FAQ" tras cada respuesta del bot ────── */
.paco-savefaq {
  align-self: flex-start;
  margin: -2px 0 8px 4px;
  padding: 4px 10px;
  font: 600 11px/1.2 inherit;
  color: #15803d;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  cursor: pointer;
}
.paco-savefaq:hover { background: #d1fae5; }
.paco-savefaq:disabled { cursor: default; opacity: .85; }
.paco-savefaq--done {
  color: #6b7280;
  background: #f3f4f6;
  border-color: #e5e7eb;
}
[data-theme="dark"] .paco-savefaq {
  color: #86efac; background: #14532d33; border-color: #14532d;
}
[data-theme="dark"] .paco-savefaq:hover { background: #14532d66; }
[data-theme="dark"] .paco-savefaq--done {
  color: #9ca3af; background: #2a2a2e; border-color: #3a3a40;
}

/* ── Modal "Guardar como FAQ" ─────────────────────────────────── */
.paco-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.paco-modal {
  width: 100%; max-width: 520px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  max-height: 90vh; overflow: auto;
  font: 14px/1.4 inherit;
}
.paco-modal > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}
.paco-modal-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; color: #6b7280; padding: 0; width: 28px; height: 28px;
}
.paco-modal-close:hover { color: #111; }
.paco-modal > label {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 16px 0;
  font-size: 12px; color: #374151; font-weight: 600;
}
.paco-modal textarea, .paco-modal input[type="text"] {
  font: 13px/1.4 inherit;
  padding: 8px 10px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  resize: vertical;
  outline: none;
  color: #111;
  background: #fff;
}
.paco-modal textarea:focus, .paco-modal input[type="text"]:focus {
  border-color: #16a34a;
}
.paco-modal-row {
  display: flex; gap: 12px;
  padding: 0 16px;
}
.paco-modal-row > label {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 10px;
  font-size: 12px; color: #374151; font-weight: 600;
}
.paco-modal > footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid #e5e7eb;
  margin-top: 14px;
}
.paco-modal-msg { flex: 1; font-size: 12px; color: #6b7280; }
.paco-modal-msg--ok  { color: #15803d; font-weight: 600; }
.paco-modal-msg--err { color: #b91c1c; font-weight: 600; }
.paco-modal-cancel, .paco-modal-save {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #d4d4d8;
  background: #fff;
  font: 600 13px inherit;
  cursor: pointer;
}
.paco-modal-cancel:hover { background: #f3f4f6; }
.paco-modal-save {
  background: #16a34a; color: #fff; border-color: #16a34a;
}
.paco-modal-save:hover    { background: #15803d; }
.paco-modal-save:disabled { background: #9ca3af; border-color: #9ca3af; cursor: default; }

[data-theme="dark"] .paco-modal { background: #1e1e22; color: #e8e8e8; }
[data-theme="dark"] .paco-modal > header,
[data-theme="dark"] .paco-modal > footer { border-color: #3a3a40; }
[data-theme="dark"] .paco-modal > label,
[data-theme="dark"] .paco-modal-row > label { color: #d4d4d8; }
[data-theme="dark"] .paco-modal textarea,
[data-theme="dark"] .paco-modal input[type="text"] {
  background: #2a2a2e; border-color: #3a3a40; color: #e8e8e8;
}
[data-theme="dark"] .paco-modal-cancel {
  background: #2a2a2e; border-color: #3a3a40; color: #e8e8e8;
}
[data-theme="dark"] .paco-modal-cancel:hover { background: #34343a; }

/* ── FABs laterales: ?/Paco/bug anclados al borde derecho ────────── */
/* (El antiguo #btn-3d-fab se eliminó; ahora la vista 3D se gestiona
   desde el view-switcher flotante.) */
@media (min-width: 769px) {
  .tut-fab {
    position: fixed !important;
    right: 0 !important;
    top: calc(50% + 4px) !important;
    bottom: auto !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 16px 0 0 16px !important;
    box-shadow: -2px 2px 8px rgba(0,0,0,.20) !important;
    opacity: .72;
    transition: opacity .15s, transform .12s, box-shadow .12s;
    font-size: 16px !important;
  }
  .tut-fab:hover { opacity: 1; transform: translateX(-2px); }
}

@media (max-width: 768px) {
  #paco-fab,
  .tut-fab,
  .mlbr-fab {
    position: fixed !important;
    right: 0 !important;
    left: auto !important;
    width: auto !important;
    min-width: 44px;
    height: 44px !important;
    padding: 0 14px !important;
    border-top-left-radius: 22px !important;
    border-bottom-left-radius: 22px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    box-shadow: -2px 2px 10px rgba(0,0,0,.32) !important;
    display: flex !important; align-items: center; justify-content: center;
  }

  #paco-fab   { bottom: 116px !important; }
  .tut-fab    { bottom: 168px !important; }
  .mlbr-fab   { bottom: 220px !important; }

  body.prop-az-kbd-open #paco-fab,
  body.prop-az-kbd-open .tut-fab,
  body.prop-az-kbd-open .mlbr-fab { display: none !important; }
  body.mfl-panel-open #paco-fab,
  body.mfl-panel-open .tut-fab,
  body.mfl-panel-open .mlbr-fab { display: none !important; }
}

/* ── Flash de selección desde el selector "Seleccionar" ─────── */
/* Overlay flotante (position:fixed) por encima de todo el mueble */
.flash-ghost {
  pointer-events: none;
  z-index: 9999;
  border-radius: 2px;
  box-sizing: border-box;
  animation: flash-ghost-anim 1.2s ease-out;
}
@keyframes flash-ghost-anim {
  0%   { box-shadow: 0 0 0 3px rgba(255,196,0,.0),  0 0 0 0   rgba(255,196,0,.0);   background: rgba(255,196,0,.0); }
  18%  { box-shadow: 0 0 0 4px rgba(255,196,0,.95), 0 0 32px 12px rgba(255,196,0,.70); background: rgba(255,196,0,.35); }
  55%  { box-shadow: 0 0 0 3px rgba(255,196,0,.6),  0 0 22px 6px  rgba(255,196,0,.35); background: rgba(255,196,0,.18); }
  100% { box-shadow: 0 0 0 0   rgba(255,196,0,.0),  0 0 0 0   rgba(255,196,0,.0);   background: rgba(255,196,0,.0); }
}

/* ── Navegación entre puertas estructurales ─────────────────── */
.sd-nav-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px; margin-bottom: 6px;
  border-bottom: 1px solid #ddd;
}
.sd-nav-lbl { flex: 1; font-size: 10px; color: #888; text-align: center; white-space: nowrap; }
.sd-nav-btn {
  flex-shrink: 0; height: 24px; min-width: 28px; padding: 0 6px;
  border: 1px solid #ccc; border-radius: 3px; background: #f5f5f5;
  color: #555; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.sd-nav-btn:hover { background: #e0e0e0; color: #222; }
.sd-nav-toggle svg { width: 14px; height: 14px; }
[data-theme="dark"] .sd-nav-bar { border-bottom-color: #444; }
[data-theme="dark"] .sd-nav-btn { background: #3a3a3d; border-color: #555; color: #ccc; }
[data-theme="dark"] .sd-nav-btn:hover { background: #484848; color: #fff; }

.prop-project-row {
  background: #f0f4ff;
  border-bottom: 2px solid #b8c8f0;
  margin-bottom: 4px;
}
[data-theme="dark"] .prop-project-row {
  background: #1a2240;
  border-bottom-color: #3a5080;
}
.prop-project-row .prop-row { font-weight: 600; }

/* Selector de mueble del grupo (cabecera del editor) */
.prop-furn-switch-wrap {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  background: #fff7e0;
  border-bottom: 1px solid #e0c878;
  margin-bottom: 4px;
}
[data-theme="dark"] .prop-furn-switch-wrap {
  background: #3a2f15;
  border-bottom-color: #6a5a30;
}
.prop-furn-switch-lbl { font-size: 11px; color: #555; font-weight: 600; }
.prop-furn-switch {
  flex: 1; font-size: 11px; padding: 2px 4px;
  border: 1px solid #ccc; border-radius: 2px; background: #fff;
}

/* Hint cuando el panel está sin mueble enfocado */
.prop-empty-hint {
  padding: 12px 10px;
  font-size: 12px;
  color: #777;
  font-style: italic;
  text-align: center;
}

.prop-section { margin-bottom: 2px; border: 1px solid #ddd; border-radius: 3px; overflow: hidden; }
.prop-section-title {
  padding: 1px 8px; background: #e0e0e0;
  font-size: 11px; font-weight: 700; color: #444; line-height: 1.4;
  cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 5px;
}
.prop-section-title:hover { background: #d4d4d4; }
.prop-section-arrow { font-size: 9px; color: #666; flex-shrink: 0; }
.prop-section-body { display: block; }
.prop-section--collapsed .prop-section-body { display: none; }
.prop-row { display: flex; align-items: center; padding: 3px 8px; border-top: 1px solid #eee; }
.prop-label { flex: 0 0 100px; font-size: 11px; color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-value { flex: 1; font-size: 11px; min-width: 0; overflow-x: auto; }

.prop-value input[type="number"],
.prop-value input[type="text"],
.prop-value select {
  width: 100%; padding: 2px 4px; border: 1px solid #ccc; border-radius: 2px;
  font: inherit; font-size: 11px; background: #fff;
}
.prop-value input:focus, .prop-value select:focus { outline: none; border-color: var(--accent); }

.prop-value input[type="checkbox"] {
  width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent);
}

.prop-value input[type="color"] {
  width: 36px; height: 20px; border: 1px solid #ccc; border-radius: 2px;
  padding: 1px; cursor: pointer; background: none;
}

.btn-group { display: flex; gap: 2px; flex-wrap: nowrap; min-width: min-content; }
.btn-group button {
  flex: 1; padding: 2px 4px; border: 1px solid #ccc; background: #fff;
  border-radius: 2px; font-size: 11px; cursor: pointer; font: inherit; white-space: nowrap;
}
.btn-group button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-group button:hover:not(.active) { background: #e8e8e8; }

.content-btn-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 4px;
  padding: 4px 0;
}
.content-btn {
  padding: 6px 4px; border: 1px solid #ccc; background: #fff;
  border-radius: 4px; font-size: 11px; cursor: pointer; font: inherit;
  text-align: center; transition: background .12s;
}
.content-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.content-btn:hover:not(.active) { background: #e8e8e8; }
[data-theme="dark"] .content-btn { background: #3a3a3d; border-color: #555; color: #ddd; }
[data-theme="dark"] .content-btn:hover:not(.active) { background: #4a4a4d; }

.prop-hint { padding: 8px; font-size: 10px; color: #aaa; font-style: italic; }

.cota-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(20, 100, 220, .85);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
}

.prop-div-btn {
  padding: 2px 7px; border: 1px solid #bbb; background: #f5f5f5;
  border-radius: 2px; font-size: 11px; cursor: pointer; font: inherit;
}
.prop-div-btn:hover { background: #e0e8ff; border-color: var(--accent); }
.prop-div-btn--remove { color: #c00; border-color: #e0aaaa; background: #fff5f5; }
.prop-div-btn--remove:hover { background: #ffe0e0; border-color: #c00; }

/* ── División rápida (botones 0–8 H/V) ──────────────────────────── */
.div-quick-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 0;
}
.div-quick-lbl {
  font-size: 10px;
  font-weight: 600;
  color: #888;
  width: 14px;
  flex-shrink: 0;
  text-align: center;
}
.div-quick-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #f5f5f5;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  line-height: 20px;
  flex-shrink: 0;
}
.div-quick-btn:hover  { background: #e0e8ff; border-color: var(--accent); }
.div-quick-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.div-act-row {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}
.div-apply-btn {
  flex: 1;
  padding: 4px 0;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.div-apply-btn:hover { opacity: .85; }
.div-rem-btn {
  padding: 4px 10px;
  border: 1px solid #c00;
  border-radius: 3px;
  background: #fff5f5;
  color: #c00;
  font-size: 12px;
  cursor: pointer;
}
.div-rem-btn:hover { background: #ffe0e0; }

/* ── Furniture ─────────────────────────────────────────────────── */

.furniture-wrapper {
  position: relative;
  box-shadow: 4px 6px 24px rgba(0,0,0,.4);
  overflow: hidden; /* final clip — prevents overlay doors from bleeding out */
}

.board {
  position: absolute;
  background: linear-gradient(160deg, #9b7530 0%, #7a5c28 55%, #5f4418 100%);
  border: 1.5px solid rgba(0, 0, 0, .55);   /* perímetro del mueble más oscuro */
}
/* El perímetro del mueble (laterales, techo, suelo) por encima de celdas y
   divisores para que el contorno no quede tapado por el background blanco
   de las celdas. Las puertas/cajones (.panel-wrap, has-overlay) usan z-index
   superior y siguen extendiéndose por encima. */
.board[data-board-side="left"],
.board[data-board-side="right"],
.board[data-board-side="top"],
.board[data-board-side="bottom"] {
  z-index: 3;
}

/* Solo se pintan los CANTOS LARGOS de los tableros perimetrales — los cantos
   estrechos quedan abiertos para que las rayas de los paneles colindantes
   continúen sin interrupción y el contacto entre tableros sea limpio.
   El tamaño físico del tablero NO cambia, solo cómo se pinta su borde. */
.board[data-board-side="left"],
.board[data-board-side="right"] {
  /* Laterales (verticales): solo cantos largos = arriba/abajo SIN pintar */
  border-top:    none;
  border-bottom: none;
}
.board[data-board-side="top"],
.board[data-board-side="bottom"] {
  /* Techo y suelo (horizontales): solo cantos largos = izq/dcha SIN pintar */
  border-left:  none;
  border-right: none;
}

/* Excepción: si el tablero sobresale por un lado (voladizo), su canto estrecho
   queda volando — debe pintarse para que no parezca cortado en seco. */
.board.has-left-edge  { border-left:  1.5px solid rgba(0, 0, 0, .55); }
.board.has-right-edge { border-right: 1.5px solid rgba(0, 0, 0, .55); }
.board.plinth     { background: linear-gradient(160deg, #5a4010 0%, #3e2b08 100%); }
.board.top-plinth { background: linear-gradient(160deg, #5a4010 0%, #3e2b08 100%); }
.board.rails      { background: repeating-linear-gradient(45deg, #9b7530, #9b7530 3px, #c9a060 3px, #c9a060 9px); }
.board.leg        { background: linear-gradient(180deg, #5a3a18 0%, #3a2410 100%); border-radius: 2px; }
.board.alero      { outline: 2px dashed rgba(80,140,220,0.6); outline-offset: -2px; }
.board.alero-support { opacity: 0.78; outline: 1px dashed rgba(80,140,220,0.38); outline-offset: -1px; }

.furniture-interior {
  position: absolute;
  background: var(--int-bg);
  overflow: visible; /* overlay doors may extend into board area */
}

/* ── Cells ─────────────────────────────────────────────────────── */

.cell { box-sizing: border-box; min-width: 0; min-height: 0; }

.cell.container { display: flex; position: relative; overflow: visible; }
.cell.container.split-h { flex-direction: column; }
.cell.container.split-v { flex-direction: row;    }

.cell.leaf {
  position: relative;
  /* Sin border individual: el contorno lo dibujan los divisores y el
     perímetro del mueble (.board). Evita el efecto "rayas duplicadas"
     cuando dos celdas adyacentes pintan ambas su lado del divisor. */
  border: none;
  background: var(--int-bg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .08s;
  overflow: hidden; /* default: clip content */
}
.cell.leaf.has-overlay, .cell.has-overlay { overflow: visible; z-index: 2; } /* extend over boards */
.cell.leaf.has-drawer { background: rgba(0,0,0,0.09); }
.cell.leaf:hover     { background: rgba(0,0,0,.07); }

/* Celda sin fondo — antes había un patrón diagonal; ahora se deja sin marca
   visual (la cara trasera del mueble se ve a través). */
.cell.leaf.no-back {
  background-image: none;
}

/* Cuando el fondo del interior lleva textura, las celdas sin color propio son transparentes */
.has-tex-bg .cell.leaf:not([style*="background"]):not(.selected):not(.active) {
  background: transparent;
}
.has-tex-bg .cell.leaf:not([style*="background"]):hover {
  background: rgba(255,255,255,0.18);
}

/* ── Selección — hojas ─────────────────────────────────────────────
   Pseudo-elemento ::after sobrepuesto en color accent — la selección
   queda visible incluso sobre texturas, puertas con color o panel
   ciego. pointer-events:none para no romper clicks. */
.cell.leaf.selected,
.cell.container.selected {
  z-index: 4;
}
.cell.leaf.selected::after,
.cell.container.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sel-bg, rgba(0, 122, 204, .20));
  box-shadow: inset 0 0 0 2px var(--accent, #007acc);
  pointer-events: none;
  z-index: 50;
}
/* Celda activa: marco más grueso + tinte algo más opaco para distinguir
   la "principal" del resto del rango seleccionado. */
.cell.leaf.active,
.cell.container.active {
  z-index: 5;
}
.cell.leaf.active::after,
.cell.container.active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 122, 204, .28);
  box-shadow:
    inset 0 0 0 3px var(--accent, #007acc),
    inset 0 0 0 5px rgba(255, 255, 255, .85);
  pointer-events: none;
  z-index: 51;
}

.badge {
  position: absolute; top: 2px; left: 2px;
  font-size: 9px; padding: 1px 4px; border-radius: 2px; pointer-events: none;
}
.badge-door   { background: #e8f0fe; color: #1a56db; border: 1px solid #9ab; }
.badge-drawer { background: #fff3e0; color: #9c5700; border: 1px solid #d4a860; }

.cell-label {
  font-size: 10px; color: #888; text-align: center; pointer-events: none;
}
.cell-dims {
  position: absolute; bottom: 2px; right: 3px;
  font-size: 9px; color: #555; pointer-events: none; white-space: nowrap;
  text-shadow:
    0 0 3px #fff, 0 0 3px #fff,
    1px 1px 0 #fff, -1px -1px 0 #fff,
    1px -1px 0 #fff, -1px 1px 0 #fff;
}

/* ── Vista lateral ─────────────────────────────────────────────── */

.furniture-wrapper--side .furniture-interior--side {
  position: absolute;
}

/* Badge de orientación en la esquina superior izquierda del mueble girado */
.side-view-badge {
  position: absolute;
  top: 4px; left: 4px;
  background: rgba(255,153,0,.88);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 20;
}

/* ── Vista zenital (planta / top-down) ─────────────────────────── */

.furniture-wrapper--top {
  position: relative;
  box-shadow: 4px 6px 24px rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 2px;
}

/* Flecha indicando el frente del mueble */
.top-view-arrow {
  position: absolute;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 10;
}
.top-view-arrow[data-dir="down"] {
  bottom: 4px; left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid rgba(255,80,80,.85);
}
.top-view-arrow[data-dir="up"] {
  top: 4px; left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid rgba(255,80,80,.85);
}
.top-view-arrow[data-dir="left"] {
  left: 4px; top: 50%;
  transform: translateY(-50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid rgba(255,80,80,.85);
}
.top-view-arrow[data-dir="right"] {
  right: 4px; top: 50%;
  transform: translateY(-50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid rgba(255,80,80,.85);
}

/* Dimensiones en vista zenital */
.top-view-dims {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px; font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

/* Tableros de la carcasa en planta */
.furniture-wrapper--top .board {
  opacity: 0.8;
}

/* Mueble alto en vista zenital: borde azul punteado + tinte */
.furniture-wrapper--top--wall {
  border: 2px dashed rgba(77, 184, 255, 0.75) !important;
  box-shadow: 0 0 0 1px rgba(77,184,255,.2), 4px 6px 24px rgba(0,0,0,.4);
  outline: none;
}
.furniture-wrapper--top--wall::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(77,184,255,.1);
  pointer-events: none;
  z-index: 0;
}
/* Flecha de frente en altos: azul en vez de rojo */
.furniture-wrapper--top--wall .top-view-arrow[data-dir="down"]  { border-top-color:   rgba(77,184,255,.9); }
.furniture-wrapper--top--wall .top-view-arrow[data-dir="up"]    { border-bottom-color: rgba(77,184,255,.9); }
.furniture-wrapper--top--wall .top-view-arrow[data-dir="left"]  { border-right-color:  rgba(77,184,255,.9); }
.furniture-wrapper--top--wall .top-view-arrow[data-dir="right"] { border-left-color:   rgba(77,184,255,.9); }

/* Badge en celda que tiene contenido en otra cara (vista frontal) */
.cell-face-badge {
  position: absolute;
  bottom: 14px; right: 3px;
  background: rgba(255,153,0,.82);
  color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
}
/* ── Etiquetas de celda A1/B2 ──────────────────────────────────── */
.cell-addr-label {
  position: absolute;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  color: rgba(195, 232, 141, .95);
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(195, 232, 141, .3);
  padding: 1px 4px; border-radius: 3px;
  pointer-events: none; z-index: 10; line-height: 1.4;
  white-space: nowrap;
}

.cell-warn-badge {
  position: absolute;
  top: 2px; left: 2px;
  font-size: 12px;
  line-height: 1;
  cursor: help;
  z-index: 5;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
}

/* ── Flechas rojas de conflicto direccional (puertas solapadas) ── */
.cell-conflict-arrow {
  position: absolute;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
  color: #dc2626;
  cursor: help;
  z-index: 6;
  pointer-events: auto;
  filter: drop-shadow(0 0 2px rgba(255,255,255,.9)) drop-shadow(0 1px 2px rgba(0,0,0,.4));
  user-select: none;
  animation: cell-conflict-pulse 1.4s ease-in-out infinite;
}
.cell-conflict-arrow--left   { left:  4px; top: 50%; transform: translateY(-50%); }
.cell-conflict-arrow--right  { right: 4px; top: 50%; transform: translateY(-50%); }
.cell-conflict-arrow--top    { top:    4px; left: 50%; transform: translateX(-50%); }
.cell-conflict-arrow--bottom { bottom: 4px; left: 50%; transform: translateX(-50%); }
@keyframes cell-conflict-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}

/* ── Warnings clickables: cursor pointer + flash al copiar ─────── */
.js-warn-copy { cursor: pointer; }
.cell-warn-badge.js-warn-copy,
.cell-conflict-arrow.js-warn-copy { cursor: pointer; }
.js-warn-copy.warn-copied {
  animation: warn-copied-flash 0.5s ease-out;
}
@keyframes warn-copied-flash {
  0%   { background-color: rgba(120, 200, 120, 0.6); box-shadow: 0 0 0 4px rgba(120, 200, 120, 0.4); }
  100% { background-color: transparent;              box-shadow: 0 0 0 0   rgba(120, 200, 120, 0); }
}

/* ── Interior divider boards ───────────────────────────────────── */

.interior-board {
  flex: 0 0 auto;
  background: linear-gradient(160deg, #9b7530 0%, #7a5c28 55%, #5f4418 100%);
  position: relative;
  z-index: 1;
}
/* Solo se dibuja el borde de los CANTOS LARGOS del tablero — los extremos
   donde el divisor topa con un panel/balda quedan sin línea, así visualmente
   "cierra" sobre el panel al que llega en lugar de mostrar dos rayas duplicadas
   en el contacto. */
.iboard-h {
  width: 100%;          /* height inline */
  border-top:    1px solid rgba(0, 0, 0, .55);
  border-bottom: 1px solid rgba(0, 0, 0, .55);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -1px 0 rgba(0,0,0,.16);
}
.iboard-v {
  height: 100%;         /* width inline */
  border-left:  1px solid rgba(0, 0, 0, .55);
  border-right: 1px solid rgba(0, 0, 0, .55);
  box-shadow:
    inset 1px 0 0 rgba(255,255,255,.10),
    inset -1px 0 0 rgba(0,0,0,.16);
}
.interior-board--selected {
  box-shadow: 0 0 8px 2px rgba(0, 0, 0, .35) inset, 0 0 6px rgba(0, 0, 0, .3);
  position: relative; z-index: 2;
}

/* Balda libre dentro de una celda (cell.freeShelves[]) — mismo aspecto
   que un divisor horizontal pero con cursor pointer y hitbox vertical
   extendido para facilitar la selección. */
.free-shelf {
  background: linear-gradient(160deg, #9b7530 0%, #7a5c28 55%, #5f4418 100%);
  border-top:    1px solid rgba(0, 0, 0, .55);
  border-bottom: 1px solid rgba(0, 0, 0, .55);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -1px 0 rgba(0,0,0,.16);
}
.free-shelf:hover {
  outline: 1px dashed rgba(0, 122, 204, .9);
  outline-offset: 2px;
}
.free-shelf--selected {
  outline: 2px solid #007acc;
  outline-offset: 2px;
  box-shadow: 0 0 8px 2px rgba(0, 122, 204, .45);
  z-index: 5 !important;
}

/* ── Panel wrap (shared by doors and drawers) ───────────────────── */

.panel-wrap {
  position: absolute;
  display: flex;
  gap: 2px;
  pointer-events: none;
}
.panel-wrap.overlay { /* inset set per-side inline */ }
.panel-wrap.inset   { inset: 1px; }  /* small gap from frame */

.door-wrap   { flex-direction: row; }
.drawer-wrap { flex-direction: column; }

/* ── Door panel ─────────────────────────────────────────────────── */

.door-panel {
  flex: 1;
  position: relative;
  background: linear-gradient(160deg, #d4aa70 0%, #b8904a 55%, #9a7030 100%);
  border: 1px solid var(--panel-edge);
  border-radius: 1px;
  box-shadow:
    inset 0 0 0 4px rgba(255,255,255,.07),
    inset 0 0 0 5px rgba(0,0,0,.06),
    2px 2px 5px rgba(0,0,0,.28);
}
/* Recessed inner groove */
.door-panel::after {
  content: '';
  position: absolute;
  inset: 12% 10%;
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 1px;
  box-shadow: inset 0 0 3px rgba(0,0,0,.1);
}

/* ── Puerta con cristal: rejilla de vanos sobre el panel ──────── */
.door-panel--glass::after { display: none; }  /* sin ranura interior cuando es cristal */
.door-panel--glass {
  background: linear-gradient(160deg, #c2a075 0%, #a68653 55%, #8a6830 100%);
}
.glass-grid {
  position: absolute;
  inset: 7%;  /* el marco perimetral de madera */
  display: grid;
  gap: 3px;
  background: rgba(40, 30, 20, .75);  /* peinazos — madera oscura */
  border: 1px solid rgba(0,0,0,.35);
  border-radius: 1px;
  z-index: 0;
  pointer-events: none;
}
.glass-pane {
  background:
    linear-gradient(135deg, rgba(255,255,255,.42) 0%, rgba(210,230,240,.18) 45%, rgba(140,180,200,.32) 100%),
    rgba(195, 220, 230, .35);
  box-shadow:
    inset 1px 1px 3px rgba(255,255,255,.55),
    inset -1px -1px 2px rgba(0,0,0,.18);
}
[data-theme="light"] .glass-grid { background: rgba(60,45,30,.8); }

/* Sección ciega de puerta estructural a nivel de mueble */
.struct-furn-blind {
  flex: 1;
  position: relative;
  border: 1px solid var(--panel-edge);
  border-radius: 1px;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.12), inset -1px -1px 0 rgba(0,0,0,.08);
}

/* ── Acabado espejo ─────────────────────────────────────────────── */
.mirror-panel {
  background: linear-gradient(135deg, #e8eef2 0%, #c5d0d8 18%, #f7f9fb 35%, #adb8c0 52%, #dce3e8 70%, #b0bcc5 85%, #e0e6ea 100%) !important;
  border-color: #a0aab3 !important;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.35),
    inset 0 0 12px rgba(255,255,255,.15),
    2px 2px 5px rgba(0,0,0,.28) !important;
}
.mirror-panel::after {
  border-color: rgba(255,255,255,.25) !important;
  box-shadow: inset 0 0 6px rgba(255,255,255,.12) !important;
}

/* Vertical door handle (tirador) */
.door-handle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: clamp(12px, 22%, 44px);
  background: linear-gradient(to bottom, #bbb 0%, #888 50%, #bbb 100%);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
  z-index: 1;
}
.dh-right { right: 8%; }
.dh-left  { left:  8%; }

/* ── Drawer panel ───────────────────────────────────────────────── */

.drawer-panel {
  flex: 1;
  position: relative;
  background: linear-gradient(160deg, #d4aa70 0%, #b8904a 55%, #9a7030 100%);
  border: 1px solid var(--panel-edge);
  border-radius: 1px;
  box-shadow:
    inset 0 0 0 4px rgba(255,255,255,.07),
    2px 2px 5px rgba(0,0,0,.28);
  overflow: hidden;
}
/* Horizontal drawer handle (tirador horizontal centrado) */
.drawer-handle {
  position: absolute;
  top: 50%;
  left: 20%;
  right: 20%;
  transform: translateY(-50%);
  height: 4px;
  background: linear-gradient(to right, #bbb 0%, #888 50%, #bbb 100%);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
  z-index: 1;
}
/* Handle type variants */
.door-handle.ht-knob {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ccc, #888);
}
.drawer-handle.ht-knob {
  left: 50%; right: auto;
  width: 10px; height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 35%, #ccc, #888);
}
.door-handle.ht-profile {
  width: 2px;
  height: 100%;
  top: 0;
  transform: none;
  border-radius: 0;
  background: linear-gradient(to bottom, #aaa, #777);
}
.drawer-handle.ht-profile {
  left: 0; right: 0;
  height: 2px;
  border-radius: 0;
  background: linear-gradient(to right, #aaa, #777);
}
/* Gola / uñero — escote horizontal en la parte superior del frente
 * (cajón) o vertical en el canto libre (puerta). No es una pieza
 * saliente: representa un hueco rebajado para meter el dedo. Visualmente
 * lo pintamos como una banda oscura con sombra hacia dentro. */
.drawer-handle.ht-gola {
  left: 6% !important;
  right: 6% !important;
  top: 0 !important;
  bottom: auto !important;
  width: auto !important;
  height: 14% !important;
  transform: none !important;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,.32) 70%, rgba(0,0,0,.18) 100%);
  box-shadow: inset 0 -1px 1px rgba(255,255,255,.18), 0 1px 0 rgba(255,255,255,.12);
}
.door-handle.ht-gola {
  width: 14% !important;
  height: 100% !important;
  top: 0 !important;
  bottom: auto !important;
  transform: none !important;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,.32) 70%, rgba(0,0,0,.18) 100%);
  box-shadow: inset -1px 0 1px rgba(255,255,255,.18), 1px 0 0 rgba(255,255,255,.12);
}
/* Concha (cup pull) — forma de cazoleta semicircular vista de frente.
 * Aspect ratio 3:1 (largo : alto) — la cazoleta es un rectángulo bajo
 * con la mitad superior redondeada. */
.door-handle.ht-shell,
.drawer-handle.ht-shell {
  width: clamp(20px, 28%, 64px);
  height: clamp(7px,  10%, 22px);
  left: 50%; right: auto; top: 50%; bottom: auto;
  border-radius: 50% 50% 4px 4px / 90% 90% 14% 14%;
  background: linear-gradient(180deg, #cdcdcd 0%, #8a8a8a 75%, #5e5e5e 100%);
  box-shadow: 0 1px 3px rgba(0,0,0,.5), inset 0 1px 1px rgba(255,255,255,.25);
  transform: translate(-50%, -50%);
}
/* Guide rail lines (visual hint) */
.drawer-rail {
  position: absolute;
  top: 0; bottom: 0;
  left: 4px; right: 4px;
  border-left:  1px solid rgba(0,0,0,.12);
  border-right: 1px solid rgba(0,0,0,.12);
  pointer-events: none;
}

/* ── Front board (organizador frontal) ─────────────────────────── */

.front-board-wrap {
  position: absolute;
  /* posición definida inline según orientación (frontal: bottom; lateral: left/right) */
  pointer-events: none;
}
.front-board-panel {
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #d4aa70 0%, #b8904a 55%, #9a7030 100%);
  border: 1px solid var(--panel-edge);
  border-radius: 1px;
  box-shadow:
    inset 0 0 0 3px rgba(255,255,255,.07),
    2px 2px 5px rgba(0,0,0,.24);
}

/* ── Structural door overlay ────────────────────────────────────── */

.structural-door-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;   /* los clicks van a la celda o al interior */
  z-index: 4;
  /* visual same as regular door-wrap */
  display: flex;
  flex-direction: row;
  gap: 2px;
}

/* ── Structural sliding door overlay ───────────────────────────── */

.structural-sliding-door-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.sliding-panel {
  position: absolute;
  top: 0; bottom: 0;
  background: linear-gradient(160deg, #d4aa70 0%, #b8904a 55%, #9a7030 100%);
  border: 1px solid var(--panel-edge);
  border-radius: 1px;
  box-shadow: 2px 2px 5px rgba(0,0,0,.28);
  overflow: hidden;
}
.sliding-panel::after {
  content: '';
  position: absolute;
  inset: 12% 8%;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 1px;
}
.sliding-panel-back  { left: 0; z-index: 4; }
.sliding-panel-front { right: 0; z-index: 5; }
.sliding-handle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(12px, 28%, 44px);
  height: 4px;
  background: linear-gradient(to right, #bbb 0%, #888 50%, #bbb 100%);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
  z-index: 1;
}

/* ── Acotaciones (cotas) 2D ────────────────────────────────────── */
:root { --dim-color: #000; --dim-line: rgba(0,0,0,.75); }
[data-theme="light"] { --dim-color: #000; --dim-line: rgba(0,0,0,.75); }

.dim-overlay { z-index: 6; }
.dim-h, .dim-v { pointer-events: none; }

.dim-h { display:flex; align-items:center; height:18px; }
.dim-line-h {
  flex:1; height:0;
  border-top:1.5px solid var(--dim-line);
  position:relative;
}
.dim-line-h::before, .dim-line-h::after {
  content:''; position:absolute; top:-5px;
  width:1.5px; height:9px; background:var(--dim-color);
}
.dim-line-h::before { left:0; }
.dim-line-h::after  { right:0; }
/* Ocultar ticks interiores (junto al label) */
.dim-h > .dim-line-h:first-child::after { display:none; }
.dim-h > .dim-line-h:last-child::before { display:none; }

.dim-v { display:flex; flex-direction:column; align-items:center; width:20px; }
.dim-line-v {
  flex:1; width:0;
  border-left:1.5px solid var(--dim-line);
  position:relative;
}
.dim-line-v::before, .dim-line-v::after {
  content:''; position:absolute; left:-4px;
  width:9px; height:1.5px; background:var(--dim-color);
}
.dim-line-v::before { top:0; }
.dim-line-v::after  { bottom:0; }
.dim-v > .dim-line-v:first-child::after { display:none; }
.dim-v > .dim-line-v:last-child::before { display:none; }

.dim-label {
  font:bold 11px/1 'Segoe UI', system-ui, sans-serif;
  color:#000;
  white-space:nowrap;
  flex-shrink:0;
  padding:0 4px;
}
.dim-v .dim-label {
  writing-mode:vertical-rl;
  transform:rotate(180deg);
  padding:4px 0;
}

/* ── Cotas por celda — color más tenue que las exteriores ───────── */
.dim-h.dim-cell .dim-line-h,
.dim-v.dim-cell .dim-line-v {
  border-color: rgba(0, 0, 0, .35);
}
.dim-h.dim-cell .dim-line-h::before,
.dim-h.dim-cell .dim-line-h::after,
.dim-v.dim-cell .dim-line-v::before,
.dim-v.dim-cell .dim-line-v::after {
  background: rgba(0, 0, 0, .35);
}
.dim-h.dim-cell .dim-label,
.dim-v.dim-cell .dim-label {
  color: rgba(0, 0, 0, .55);
  font-weight: normal;
  font-size: 10px;
}

/* ── Guías magnéticas ──────────────────────────────────────────── */

.guide-line {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  transition: opacity .15s;
}
.guide-v {
  top: 0; bottom: 0; width: 1px;
  background: rgba(0, 120, 255, 0.45);
  box-shadow: 0 0 3px rgba(0,100,255,0.3);
}
.guide-h {
  left: 0; right: 0; height: 1px;
  background: rgba(0, 120, 255, 0.45);
  box-shadow: 0 0 3px rgba(0,100,255,0.3);
}
.guide-line.align-guide {
  background: rgba(0, 200, 120, 0.5);
  box-shadow: 0 0 3px rgba(0,180,100,0.3);
  border: none;
}
.guide-line.align-guide.guide-v { background: rgba(0, 200, 120, 0.5); }
.guide-line.align-guide.guide-h { background: rgba(0, 200, 120, 0.5); }
.guide-line.guide-snap {
  background: rgba(255, 80, 0, 0.85) !important;
  box-shadow: 0 0 6px rgba(255,80,0,0.6) !important;
}

/* ── Barra de perchas ──────────────────────────────────────────── */

.hanger-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hanger-bar {
  position: absolute;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom,
    #e8e8e8 0%, #bbb 20%, #888 55%, #aaa 80%, #ddd 100%);
  box-shadow: 0 2px 5px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.5);
  transform: translateY(-50%);
}
.hanger-bracket {
  position: absolute;
  left: 50%;
  background: #999;
  transform: translateX(-50%);
  opacity: 0.6;
}

/* ── Toallero lateral 2D ──────────────────────────────────────── */
.towel-rail-2d {
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}

/* ── Organizador de puerta 2D ─────────────────────────────────── */
.door-org-line {
  z-index: 4;
  opacity: 0.75;
}

/* ── Puerta ciega trasera (indicador 2D) ───────────────────────── */
.back-door-indicator {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.back-door-panel {
  position: absolute;
  inset: 0;
  border: 1.5px dashed rgba(80,140,255,.70);
  border-radius: 1px;
  background: rgba(80,140,255,.07);
}
.back-door-panel::after {
  content: '';
  position: absolute;
  inset: 12% 10%;
  border: 1px dashed rgba(80,140,255,.35);
  border-radius: 1px;
}

/* ── Rueda de apoyo en puerta (indicador 2D) ────────────────────── */
.door-caster-dot {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #888;
  border: 1.5px solid #555;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
  z-index: 5;
  pointer-events: none;
}

/* ── Panel Proyectos Externos ────────────────────────────────────── */

#ext-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1e1e1e;
}
#ext-panel[hidden] { display: none; }

#app.tab--extproj #mobile-pages  { display: none; }
#app.tab--extproj #props-panel   { display: none; }
#app.tab--extproj #mobile-tabbar { display: none; }
#app.tab--extproj #ext-panel     { display: flex; }

.tab-item.tab-extproj.active { border-bottom-color: #4ec9a0; }

/* Catálogo nativo */
#ext-catalog {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.ext-cat-section {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #666; margin-bottom: 14px;
}
.ext-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.ext-card {
  background: #2d2d30;
  border: 1px solid #3a3a3d;
  border-radius: 6px;
  padding: 16px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color .15s, box-shadow .15s;
  user-select: none;
}
.ext-card:hover { border-color: #007acc; box-shadow: 0 2px 10px rgba(0,122,204,.18); }
.ext-card-icon  { font-size: 26px; line-height: 1; }
.ext-card-title { font-size: 13px; font-weight: 600; color: #e0e0e0; }
.ext-card-desc  { font-size: 11px; color: #888; line-height: 1.5; }
.ext-card-tag {
  display: inline-block; font-size: 10px; padding: 2px 8px;
  border-radius: 10px; background: #1a3a5c; color: #5ab0f8; font-weight: 600;
  margin-top: 2px;
}

/* Vista proyecto (iframe) */
#ext-project-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#ext-project-view[hidden] { display: none; }
#ext-project-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: #252527;
  border-bottom: 1px solid #3a3a3d;
  flex-shrink: 0;
}
#btn-ext-back-catalog {
  background: transparent; border: 1px solid #555; color: #aaa;
  padding: 2px 10px; border-radius: 3px; cursor: pointer; font-size: 12px;
}
#btn-ext-back-catalog:hover { background: #3a3a3d; color: #fff; }
#ext-project-label { flex: 1; font-size: 13px; font-weight: 600; color: #ccc; }
#ext-project-iframe {
  flex: 1; border: none; width: 100%; min-height: 0;
}

/* ── Dialogs ───────────────────────────────────────────────────── */

dialog {
  border: none; border-radius: 6px; padding: 0; min-width: 300px;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(0,0,0,.45); }

/* Diálogo Propagación global: forzar centrado en pantalla */
#dlg-global-props[open] {
  position: fixed;
  inset: 0;
  margin: auto;
  width: max-content;
  height: max-content;
}

.dlg-header {
  padding: 11px 16px; background: #2d2d30; color: #eee;
  font-weight: 700; font-size: 13px; border-radius: 6px 6px 0 0;
}

/* ── Explorador de ficheros (dlg-file-browser) ──────────────────────────── */
.dlg-fb {
  background: #252526; color: #eee; border: 1px solid #3a3a3c;
  padding: 0; border-radius: 6px;
  width: 560px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 64px);
  overflow: hidden;
  transition: width .15s ease;
}
/* Cuando el preview está visible, el dialog se ensancha */
.dlg-fb.has-preview { width: 900px; }
/* display:flex y posicionamiento SOLO cuando el dialog está abierto — si no,
   sobreescribiría la regla `dialog:not([open]) { display:none }` del UA y el
   dialog quedaría visible un instante en la esquina antes de que showModal
   lo mueva al top layer. */
.dlg-fb[open] {
  position: fixed !important;
  top: 50% !important; left: 50% !important;
  right: auto !important; bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  margin: 0 !important;
  display: flex; flex-direction: column;
}
.dlg-fb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #2d2d30; border-bottom: 1px solid #3a3a3c;
  flex: 0 0 auto;
}
.dlg-fb-title { font-weight: 600; font-size: 14px; color: #eee; flex: 1; }
.dlg-fb-preview-toggle {
  padding: 4px 10px; font-size: 13px; line-height: 1;
}
.dlg-fb-preview-toggle[aria-pressed="true"] {
  background: #094771; color: #fff; border-color: #094771;
}
/* Móvil/pantallas estrechas: ocultamos el toggle (preview no aplica) */
@media (max-width: 899px) {
  .dlg-fb-preview-toggle { display: none; }
}

/* Tabs de scope (Mis muebles / Catálogo público) */
.dlg-fb-scope {
  display: flex; gap: 2px; padding: 6px 8px 0 8px;
  background: #2a2a2c; border-bottom: 1px solid #3a3a3c;
  flex: 0 0 auto;
}
.dlg-fb-scope-btn {
  background: transparent; color: #aaa; border: 1px solid transparent;
  padding: 6px 12px; border-radius: 4px 4px 0 0; cursor: pointer;
  font-size: 12px; font-weight: 500;
}
.dlg-fb-scope-btn:hover { background: #3a3a3c; color: #ddd; }
.dlg-fb-scope-btn.active {
  background: #1e1e1e; color: #eee;
  border-color: #3a3a3c; border-bottom-color: #1e1e1e;
  position: relative; top: 1px;
}

/* Botón Subir */
.dlg-fb-up {
  padding: 4px 10px; font-size: 12px; white-space: nowrap;
}
.dlg-fb-up:disabled { opacity: .4; cursor: not-allowed; }

/* Body con lista + aside preview */
.dlg-fb-body {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: row;
  background: #1e1e1e;
}
.dlg-fb-main {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
}
.dlg-fb-preview {
  flex: 0 0 340px; min-width: 0; border-left: 1px solid #3a3a3c;
  background: #1c1c1c; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  padding: 14px; overflow: hidden;
}
.dlg-fb-preview[hidden] { display: none; }
.dlg-fb-preview-empty {
  font-size: 12px; color: #777; text-align: center; padding: 20px 10px;
}
.dlg-fb-preview-img {
  max-width: 100%; max-height: 70%; object-fit: contain;
  background: #fff; border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.dlg-fb-preview-meta {
  font-size: 11px; color: #999; text-align: center; line-height: 1.4;
  width: 100%; word-break: break-word;
}

.dlg-fb-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #2a2a2c; border-bottom: 1px solid #3a3a3c;
  flex: 0 0 auto; min-height: 38px;
}
.dlg-fb-breadcrumb {
  flex: 1; min-width: 0; overflow: hidden; white-space: nowrap;
  font-size: 12px; color: #ccc; display: flex; align-items: center; gap: 2px;
}
.dlg-fb-breadcrumb .crumb {
  padding: 4px 8px; border-radius: 4px; cursor: pointer; color: #9cdcfe;
  background: transparent; border: none; font: inherit;
}
.dlg-fb-breadcrumb .crumb:hover { background: #3a3a3c; }
.dlg-fb-breadcrumb .crumb.current { color: #eee; cursor: default; }
.dlg-fb-breadcrumb .sep { color: #666; padding: 0 1px; }
.dlg-fb-mkdir { padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.dlg-fb-searchbar {
  flex: 0 0 auto; padding: 6px 12px; background: #252527;
  border-bottom: 1px solid #3a3a3c;
}
.dlg-fb-search {
  width: 100%; box-sizing: border-box;
  padding: 5px 10px; font-size: 12px;
  background: #1e1e1e; color: #eee;
  border: 1px solid #3a3a3c; border-radius: 4px;
  outline: none;
}
.dlg-fb-search:focus { border-color: #9cdcfe; }
.dlg-fb-search::placeholder { color: #777; }
.dlg-fb-list {
  flex: 1 1 auto; overflow-y: auto; padding: 4px 0;
  background: #1e1e1e; border-bottom: 1px solid #3a3a3c;
}
.dlg-fb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; cursor: pointer; user-select: none;
  border-bottom: 1px solid #262627; min-height: 36px;
}
.dlg-fb-row:hover    { background: #2a2a2c; }
.dlg-fb-row.selected { background: #094771; }
.dlg-fb-row .icon { flex: 0 0 22px; font-size: 16px; text-align: center; }
.dlg-fb-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.dlg-fb-row .meta { flex: 0 0 auto; font-size: 11px; color: #888; }
.dlg-fb-row.folder .name { font-weight: 600; }
.dlg-fb-row.extra .icon { color: #007acc; }
.dlg-fb-row.extra .name { color: #9cdcfe; font-style: italic; }
.dlg-fb-empty { padding: 40px 14px; text-align: center; color: #888; font-size: 12px; }

/* ── Modo grid (tarjetas con miniatura) ───────────────────────────── */
.dlg-fb-list--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px;
  align-content: start;
}
.dlg-fb-card {
  background: #2a2a2c;
  border: 1px solid #3a3a3c;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  outline: none;
  transition: background .12s, border-color .12s;
}
.dlg-fb-card:hover    { background: #333335; border-color: #555; }
.dlg-fb-card:focus    { border-color: #007acc; }
.dlg-fb-card.selected { background: #094771; border-color: #007acc; }
.dlg-fb-card.hidden-by-filter { display: none; }
.dlg-fb-card-thumb {
  width: 100%; aspect-ratio: 1;
  background: #1e1e1e; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.dlg-fb-card-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dlg-fb-card-icon { font-size: 42px; color: #555; }
.dlg-fb-card.folder .dlg-fb-card-icon { font-size: 56px; color: #d6a86b; }
.dlg-fb-card.extra .dlg-fb-card-thumb {
  background: #2a2a2c; border: 2px dashed #555;
}
.dlg-fb-card.extra .dlg-fb-card-icon { font-size: 56px; color: #007acc; }
.dlg-fb-card.extra .dlg-fb-card-name { color: #9cdcfe; font-style: italic; }
.dlg-fb-card-name {
  font-size: 12px; color: #ddd; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dlg-fb-footer {
  padding: 10px 14px; background: #2a2a2c; border-top: 1px solid #3a3a3c;
  flex: 0 0 auto; display: flex; flex-direction: column; gap: 10px;
  /* Safe area para teclados virtuales móvil */
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.dlg-fb-namebox { display: flex; flex-direction: column; gap: 4px; background: transparent; }
.dlg-fb-namelabel { font-size: 11px; color: #bbb; text-transform: uppercase; letter-spacing: .5px; }
.dlg-fb-namebox input {
  padding: 8px 10px; border: 1px solid #444; border-radius: 4px;
  background: #1e1e1e; color: #eee; font-size: 14px;
}
.dlg-fb-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dlg-fb-actions .btn-primary,
.dlg-fb-actions .btn-secondary { min-height: 36px; padding: 6px 14px; }

/* Generador IA de mueble (admin) — dlg-ai-mueble */
.dlg-ai {
  background: #252526 !important; color: #eee !important;
  border: 1px solid #3a3a3c; padding: 0; border-radius: 6px;
  width: 560px; max-width: calc(100vw - 32px);
  overflow: hidden;
}
.dlg-ai[open] {
  position: fixed !important;
  top: 50% !important; left: 50% !important;
  right: auto !important; bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  margin: 0 !important;
  display: flex; flex-direction: column;
}
.dlg-ai-header {
  padding: 10px 14px; background: #2d2d30; border-bottom: 1px solid #3a3a3c;
  display: flex; align-items: center; justify-content: space-between;
}
.dlg-ai-title { font-weight: 600; font-size: 14px; color: #eee; }
.dlg-ai-body  { padding: 14px; display: flex; flex-direction: column; gap: 12px; background: #252526; }
.dlg-ai-field { display: flex; flex-direction: column; gap: 4px; background: transparent; }
.dlg-ai-label { font-size: 11px; color: #bbb; text-transform: uppercase; letter-spacing: .5px; }
.dlg-ai-field textarea {
  padding: 8px 10px; border: 1px solid #444; border-radius: 4px;
  background: #1e1e1e; color: #eee; font-size: 13px;
  resize: vertical; min-height: 90px; font-family: inherit;
}
.dlg-ai-img-tools {
  display: flex; gap: 6px; margin-bottom: 6px;
}
.dlg-ai-img-tools .btn-secondary { padding: 6px 12px; font-size: 12px; }
.dlg-ai-paste {
  position: relative; min-height: 120px;
  border: 1px dashed #555; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: #1c1c1c; cursor: text;
}
.dlg-ai-paste:focus,
.dlg-ai-paste.dragover { border-color: #007acc; outline: none; }
.dlg-ai-paste-hint { font-size: 12px; color: #888; pointer-events: none; }
.dlg-ai-paste img { max-width: 100%; max-height: 220px; object-fit: contain; }
.dlg-ai-clear {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,.6); color: #fff; border: 0;
  border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 12px;
}
.dlg-ai-status {
  font-size: 12px; padding: 8px 10px; border-radius: 4px;
  background: #1c2933; color: #9cdcfe; border: 1px solid #094771;
}
.dlg-ai-status.error { background: #3a1f1f; color: #f88; border-color: #6b2f2f; }
.dlg-ai-stream {
  margin: 0; padding: 8px 10px; max-height: 240px;
  overflow-x: hidden; overflow-y: auto;
  background: #111; color: #ddd; border: 1px solid #333; border-radius: 4px;
  font: 11px/1.45 ui-monospace, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  max-width: 100%; box-sizing: border-box;
}
.dlg-ai-actions {
  padding: 10px 14px; background: #2a2a2c; border-top: 1px solid #3a3a3c;
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Botones admin-only ocultos por defecto; JS los muestra si admin */
.admin-only[hidden] { display: none !important; }

/* Móvil: full-screen */
@media (max-width: 768px) {
  .dlg-ai,
  .dlg-ai[open] {
    width: 100vw !important; height: 100vh !important;
    max-width: 100vw !important; max-height: 100vh !important;
    border-radius: 0 !important; border: none !important;
    margin: 0 !important;
  }
}

/* Confirmación oscura centrada (alternativa a confirm() nativo).
   IMPORTANTE: NO usar el id "dlg-confirm" — ya existe otro sistema con ese
   id que tiene tema light y choca. Este es independiente. */
.dlg-okcancel {
  background: #252526 !important; color: #eee !important;
  border: 1px solid #3a3a3c; padding: 0; border-radius: 6px;
  width: 420px; max-width: calc(100vw - 32px);
  overflow: hidden;
}
.dlg-okcancel[open] {
  position: fixed !important;
  top: 50% !important; left: 50% !important;
  right: auto !important; bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  margin: 0 !important;
}
.dlg-okcancel-header {
  padding: 10px 14px; background: #2d2d30; border-bottom: 1px solid #3a3a3c;
  font-weight: 600; font-size: 14px; color: #eee;
}
.dlg-okcancel-body {
  padding: 16px 14px; font-size: 13px; color: #ddd; line-height: 1.5;
  background: #252526;
}
.dlg-okcancel-actions {
  padding: 10px 14px; background: #2a2a2c; border-top: 1px solid #3a3a3c;
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Móvil: full-screen + filas táctiles más grandes */
@media (max-width: 768px) {
  .dlg-fb,
  .dlg-fb.has-preview {
    width: 100vw !important; height: 100vh !important;
    max-width: 100vw !important; max-height: 100vh !important;
    border-radius: 0 !important; border: none !important;
    margin: 0 !important; inset: 0 !important;
  }
  /* En móvil el preview NO se muestra aunque el toggle estuviera activo */
  .dlg-fb-preview { display: none !important; }
  .dlg-fb-row { min-height: 48px; padding: 10px 14px; }
  .dlg-fb-row .name { font-size: 15px; }
  .dlg-fb-mkdir   { padding: 8px 12px; }
  .dlg-fb-namebox input { font-size: 16px; /* evita zoom iOS */ padding: 10px 12px; }
  .dlg-fb-actions .btn-primary,
  .dlg-fb-actions .btn-secondary { min-height: 44px; flex: 1; }
}
.dlg-body   { padding: 16px; }
.dlg-footer {
  padding: 10px 16px; background: #f5f5f5; border-top: 1px solid #ddd;
  display: flex; justify-content: flex-end; gap: 8px;
  border-radius: 0 0 6px 6px;
}

.form-section {
  font-size: 11px; font-weight: 700; color: #666; text-transform: uppercase;
  letter-spacing: .5px; margin: 12px 0 6px; border-bottom: 1px solid #eee; padding-bottom: 3px;
}
.form-section:first-child { margin-top: 0; }
.form-row { display: flex; align-items: center; margin-bottom: 8px; }
.form-row label { flex: 0 0 180px; font-size: 12px; color: #444; }
.form-row input[type="number"] {
  width: 80px; padding: 4px 6px; border: 1px solid #ccc; border-radius: 3px;
  font: inherit; font-size: 12px;
}
.form-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.form-row input:focus { outline: none; border-color: var(--accent); }

.btn-primary, .btn-secondary {
  padding: 6px 16px; border: none; border-radius: 3px; cursor: pointer; font: inherit; font-size: 12px;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover   { background: #006bb3; }
.btn-secondary { background: #fff; color: #333; border: 1px solid #ccc; }
.btn-secondary:hover { background: #f0f0f0; }
.btn-secondary.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Scrollbar ─────────────────────────────────────────────────── */
#canvas-area::-webkit-scrollbar        { width: 8px; height: 8px; }
#canvas-area::-webkit-scrollbar-track  { background: #d0d0d0; }
#canvas-area::-webkit-scrollbar-thumb  { background: #b0b0b0; border-radius: 4px; }

/* ── Visor 3D acoplado ──────────────────────────────────────────
   Vive dentro de #canvas-area junto al stage 2D y ocupa la misma
   superficie. Se alterna con el view-switcher (2D / Zenital / 3D)
   añadiendo/quitando la clase .view-3d en #canvas-area. */
#canvas-area > #viewer-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 5;
  background: #eceae6;
}
#canvas-area.view-3d > #viewer-host { display: block; }
#canvas-area.view-3d > #furniture-stage { display: none; }
#canvas-area > #viewer-host canvas { display: block; }

/* Botón "Foto al diseño público" — solo aparece si el mueble activo está
   ya compartido por el usuario actual. Se inyecta desde js/app.js. */
.btn-3d-snap-share {
  position: fixed; top: 70px; right: 24px; z-index: 50;
  padding: 9px 14px; border-radius: 999px; border: none;
  background: rgba(0, 122, 204, .92); color: #fff;
  font: 600 .85rem/1 'Segoe UI', system-ui, sans-serif;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  backdrop-filter: blur(6px); transition: background .15s, transform .12s;
}
.btn-3d-snap-share:hover { background: #007acc; transform: translateY(-1px); }
.btn-3d-snap-share:disabled { background: #555; cursor: wait; transform: none; }
@media (max-width: 640px) {
  .btn-3d-snap-share { padding: 8px 10px; font-size: .78rem; }
  .btn-3d-snap-share span { display: none; }
}

/* Overlay del cropper de captura 3D (snap-crop = scc) */
.snap-crop-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(15, 18, 25, .9); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px; gap: 12px;
  font: 14px 'Segoe UI', system-ui, sans-serif; color: #fff;
}
.scc-bar { display: flex; align-items: center; gap: 12px; width: min(900px, 96vw); }
.scc-bar-top { justify-content: space-between; }
.scc-bar-bot {
  background: #1e1e22; border-radius: 10px; padding: 14px 16px;
  flex-direction: column; align-items: stretch; gap: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.scc-hint { font-size: 13px; color: #ddd; opacity: .85; }
.scc-hint kbd { background: #2a2a30; border: 1px solid #444; padding: 0 5px; border-radius: 3px; font-size: 11px; }
.scc-canvas-wrap {
  position: relative; max-width: min(900px, 96vw); max-height: 60vh;
  border-radius: 8px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.6);
  cursor: crosshair; background: #000; line-height: 0;
}
.scc-canvas-wrap canvas {
  display: block;
  max-width: min(900px, 96vw);
  max-height: 60vh;
  width: auto; height: auto;
}
.scc-sel {
  position: absolute;
  border: 2px dashed #fff;
  background: rgba(0, 122, 204, .14);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
  pointer-events: none;
}
.scc-caption { display: flex; flex-direction: column; gap: 6px; }
.scc-caption-label { font-size: 11px; color: #aaa; text-transform: uppercase; letter-spacing: .4px; }
.scc-caption textarea {
  width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid #3a3a3e;
  background: #2a2a2e; color: #fff; font: 14px/1.4 inherit;
  resize: vertical; min-height: 56px; outline: none; transition: border-color .12s;
}
.scc-caption textarea:focus { border-color: #007acc; background: #2a2a30; }
.scc-cover-toggle {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ddd;
  cursor: pointer; user-select: none;
}
.scc-cover-toggle input { accent-color: #007acc; width: 16px; height: 16px; }
.scc-actions { display: flex; gap: 8px; justify-content: flex-end; }
.scc-btn {
  background: #2a2a2e; color: #ddd; border: 1px solid #3a3a3e;
  padding: 9px 18px; border-radius: 6px; cursor: pointer;
  font: 600 13px/1 inherit; transition: background .12s, border-color .12s;
}
.scc-btn:hover { background: #3a3a3e; }
.scc-btn.scc-cancel { background: transparent; }
.scc-btn.scc-ok { background: #007acc; border-color: #007acc; color: #fff; }
.scc-btn.scc-ok:hover { background: #0090ee; }
.scc-btn:disabled { opacity: .55; cursor: wait; }
.scc-bar-top .scc-btn.scc-cancel {
  background: transparent; border: 1px solid #555;
  padding: 6px 12px; font-size: 18px; line-height: 1;
}

/* ── Editor de mesa (PLANK + three.js) ───────────────────────────
   Mismo patrón que viewer-host pero con z-index inferior para que NUNCA
   pueda solaparse encima del visor 3D si ambos quedan visibles por un
   bug. La regla `[hidden]` del UA y `display: none` por defecto garantizan
   que mientras la tab activa no sea kind='mesa' el host no existe en el
   árbol de pintado. */
#canvas-area > #mesa-editor-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 4;
  background: #1a1a22;
  pointer-events: auto;
}
#canvas-area.view-mesa > #mesa-editor-host { display: block; }
#canvas-area.view-mesa > #furniture-stage  { display: none; }
#canvas-area.view-mesa > #viewer-host      { display: none; }
#canvas-area > #mesa-editor-host canvas    { display: block; }

/* ── Element Detail Dialog ─────────────────────────────────────── */
#dlg-element-detail { border: none; border-radius: 6px; padding: 0; background: #1e1e22; max-width: 98vw; max-height: 96vh; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; }
#dlg-element-detail::backdrop { background: rgba(0,0,0,.65); }
#dlg-element-detail .dlg-header { border-radius: 6px 6px 0 0; }
#ed-viewer-host { width: 84vw; height: 78vh; position: relative; display: flex; }
#ed-viewer-host canvas { flex: 1 1 0; min-width: 0; }
.ed-info-panel {
  position: absolute; top: 10px; right: 10px; z-index: 10;
  width: 300px; max-height: calc(78vh - 30px); overflow-y: auto;
  background: rgba(30,30,34,.92); border-radius: 8px; padding: 14px 16px;
  font: 12px/1.5 'Segoe UI', system-ui, sans-serif; color: #ddd;
}
.ed-info-panel h3 { margin: 0 0 8px; font-size: 15px; color: #fff; border-bottom: 1px solid #444; padding-bottom: 6px; }
.ed-info-panel h4 { margin: 12px 0 6px; font-size: 12px; color: #90caf9; text-transform: uppercase; letter-spacing: 0.5px; }
.ed-info-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.ed-info-table td { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.ed-info-table td:first-child { color: #aaa; white-space: nowrap; padding-right: 10px; }
.ed-info-table td:last-child { color: #eee; text-align: right; }
.ed-steps { margin: 0; padding-left: 18px; font-size: 11px; }
.ed-steps li { margin-bottom: 4px; color: #ccc; }
.btn-detail {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid #555; border-radius: 4px;
  background: #333; color: #ccc; font-size: 11px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-detail:hover { background: #444; border-color: #2196f3; color: #fff; }

/* ── 3D Animation UI ───────────────────────────────────────────── */
.v3d-anim-ui {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 10; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 8px;
}
.v3d-anim-btn {
  padding: 7px 18px; border: none; border-radius: 6px; cursor: pointer;
  background: rgba(30,30,30,.82); color: #eee;
  font: 13px/1 'Segoe UI', system-ui, sans-serif;
  transition: background .15s;
}
.v3d-anim-btn:hover { background: rgba(60,60,60,.92); }
.v3d-anim-btn--active { background: rgba(180,100,20,.90); color: #fff; }
.v3d-anim-btn--active:hover { background: rgba(200,120,30,.95); }
.v3d-explode-wrap {
  display: flex; align-items: center; gap: 6px;
  background: rgba(30,30,30,.82); border-radius: 6px; padding: 5px 12px;
}
.v3d-explode-label {
  font: 13px/1 'Segoe UI', system-ui, sans-serif; color: #eee; white-space: nowrap;
}
.v3d-explode-slider {
  width: 100px; accent-color: var(--accent);
}

#canvas-area::-webkit-scrollbar-thumb:hover { background: #999; }

/* ── Mobile pages — desktop defaults ──────────────────────────── */

#mobile-pages  { display: flex; flex: 1; overflow: hidden; }
/* En escritorio los wrappers son flex containers que replican el comportamiento anterior */
#page-design   { display: flex; flex: 1; overflow: hidden; position: relative; }
/* #page-props ya no se muestra en escritorio (el editor de propiedades es
   ahora el panel flotante ⚡). En móvil el media query lo restaura a flex. */
#page-props    { display: none; overflow: hidden; }
#page-props.docked-left { order: -1; }
#page-3d       { display: none; }
#mobile-tabbar {
  display: none;
  flex-shrink: 0;
  height: 48px;
  background: var(--tb-bg);
  border-top: 1px solid #444;
}
.mobile-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: #bbb;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 0;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-tab.active { color: var(--accent); background: rgba(0,122,204,.15); }
.mobile-tab:hover  { color: #eee; background: rgba(255,255,255,.08); }
.mobile-tab:active { background: rgba(255,255,255,.12); }
.mobile-tab-icon { font-size: 18px; line-height: 1; }
.mobile-tab-lbl  { font-size: 10px; line-height: 1; font-weight: 500; }
/* En móvil ya no usamos el panel lateral de propiedades — el navegador
   A-Z + popover lo sustituye. Ocultamos su botón de la nav-bar para no
   dejar acceso a una página vacía. */
.mobile-tab[data-page="1"] { display: none; }

/* ── Multi-furniture workspace ─────────────────────────────────── */

.furn-container {
  position: absolute;
  cursor: default;
}
@keyframes furn-flash-anim {
  0%   { outline: 4px solid transparent;       box-shadow: 0 0 0   0 rgba(255, 149, 0, 0); }
  10%  { outline: 4px solid #ff9500;           box-shadow: 0 0 24px 6px rgba(255, 149, 0, 0.65); }
  30%  { outline: 4px solid rgba(255,149,0,0); box-shadow: 0 0 0   0 rgba(255, 149, 0, 0); }
  50%  { outline: 4px solid #ff9500;           box-shadow: 0 0 24px 6px rgba(255, 149, 0, 0.65); }
  70%  { outline: 4px solid rgba(255,149,0,0); box-shadow: 0 0 0   0 rgba(255, 149, 0, 0); }
  90%  { outline: 4px solid #ff9500;           box-shadow: 0 0 24px 6px rgba(255, 149, 0, 0.55); }
  100% { outline: 4px solid transparent;       box-shadow: 0 0 0   0 rgba(255, 149, 0, 0); }
}
.furn-container.furn-flash {
  animation: furn-flash-anim 1.1s ease-out forwards;
  outline-offset: 2px;
  z-index: 50;   /* eleva el mueble flasheado por si lo tapan otros */
}
/* Mueble ocultado porque tapaba al activo. */
.furn-container.furn-hidden-by-active {
  display: none !important;
}
/* Marca flotante en el lienzo: hay muebles ocultos por el activo. */
.stage-hidden-marker {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 50;
  padding: 6px 10px;
  background: rgba(20,20,20,.78);
  color: #fff;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.stage-hidden-marker:hover { background: rgba(0,122,204,.92); }
.stage-hidden-marker--revealed { opacity: .55; }
/* Foco del mueble — todo gris, distinguidos solo por intensidad/grosor.
   - Activo: halo fino y sutil.
   - Multi-seleccionado: halo más marcado (ligeramente más grueso y oscuro). */
.furn-container.active > .furniture-wrapper {
  box-shadow:
    0 0 0 2px rgba(0, 122, 204, .9),
    0 0 0 6px rgba(0, 122, 204, .25),
    4px 6px 24px rgba(0, 0, 0, .35);
}
.furn-container.furn-selected > .furniture-wrapper,
.furn-container.active.furn-selected > .furniture-wrapper {
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, .35),
    2px 4px 14px rgba(0,0,0,.35);
}

/* ── Nombre del mueble (etiqueta bajo el wrapper) ─────────────── */
.furn-name-lbl {
  /* Absolute para no añadir altura al .furn-container — si lo hiciera,
     al anclar el contenedor con `bottom` la etiqueta se quedaría al pie
     del lienzo y empujaría visualmente el mueble hacia arriba. La
     anchura se fija inline desde renderer.js (igual al wrapper). */
  position: absolute;
  top: 100%;
  left: 0;
  text-align: center;
  font-size: 11px;
  color: #666;
  padding: 3px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  user-select: none;
}
.furn-container.active .furn-name-lbl { color: #007acc; font-weight: 600; }

.furn-coords-lbl {
  /* Pintada por encima del mueble (bottom:100% del container) para no
     solaparse con .furn-name-lbl, que vive debajo (top:100%). */
  position: absolute;
  bottom: 100%;
  left: 0;
  text-align: center;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #888;
  padding: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.furn-container.active .furn-coords-lbl { color: #007acc; font-weight: 600; }

/* ── Submodule (módulo adjunto a otro mueble) ──────────────────── */
.furn-container.furn-submodule {
  cursor: move;
}
.furn-container.furn-submodule > .furniture-wrapper {
  outline: 2px dashed rgba(0, 200, 120, 0.55);
  outline-offset: 3px;
}
/* Impedir selección de celdas en submodule */
.furn-container.furn-submodule .cell,
.furn-container.furn-submodule .board {
  pointer-events: none;
}
/* Tooltip visual al pasar el ratón */
.furn-container.furn-submodule::after {
  content: attr(data-furn-name) ' · doble clic para editar';
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 200;
}
.furn-container.furn-submodule:hover::after {
  opacity: 1;
}

/* ── Rubber-band de selección ──────────────────────────────────── */
.rubber-band {
  position: absolute;
  border: 1px dashed #007acc;
  background: rgba(0, 122, 204, 0.08);
  pointer-events: none;
  z-index: 100;
}

/* ── Botones de mueble en el panel de propiedades ─────────────── */
.prop-furn-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.prop-icon-btn {
  width: 24px; height: 24px; padding: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border, #555); border-radius: 4px;
  background: var(--bg2, #3a3a3a); color: var(--fg, #ccc);
  cursor: pointer; font-size: 13px; line-height: 1;
}
.prop-icon-btn:hover { background: var(--accent, #007acc); color: #fff; border-color: var(--accent, #007acc); }

.prop-furn-btn {
  width: 26px; height: 26px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #555;
  background: #3a3a3d;
  color: #ccc;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}
.prop-furn-btn svg { width: 14px; height: 14px; }
.prop-furn-btn:hover { background: #007acc; border-color: #007acc; color: #fff; }
.prop-furn-btn--active { background: #1a5c8c; border-color: #007acc; color: #7ec8ff; }
.prop-furn-btn--del { border-color: #884444; background: #553333; color: #faa; }
.prop-furn-btn--del:hover { background: #cc0000; border-color: #cc0000; color: #fff; }
.prop-furn-btn--accent { border-color: #2a6b3a; background: #1e4a28; color: #7ed99a; }
.prop-furn-btn--accent:hover { background: #27ae60; border-color: #27ae60; color: #fff; }

.prop-multi-note {
  font-size: 10px; color: #888; background: #f5f0e8;
  border: 1px solid #ddd; border-radius: 3px;
  padding: 4px 8px; margin-bottom: 6px; line-height: 1.4;
}

.prop-stability-warn {
  background: #4a2800;
  border: 1px solid #c67800;
  border-radius: 4px;
  color: #ffb94a;
  font-size: 11px;
  line-height: 1.5;
  padding: 6px 8px;
  margin-top: 6px;
}
.prop-stability-warn strong { color: #ffca70; }
[data-theme="light"] .prop-stability-warn {
  background: #fff3e0;
  border-color: #e8a000;
  color: #7a4500;
}
[data-theme="light"] .prop-stability-warn strong { color: #5a3000; }

/* ── Modal propiedades de mueble ───────────────────────────────── */
#dlg-furn-modal {
  border: none; border-radius: 12px; padding: 0;
  width: min(480px, 96vw);
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
}
#dlg-furn-modal::backdrop { background: rgba(0,0,0,.45); }
.dlg-furn-inner {
  display: flex; flex-direction: column;
  max-height: 90vh;
}
.dlg-furn-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--tb-bg); border-bottom: 1px solid #444;
  flex-shrink: 0;
}
.dlg-furn-title { font-size: 15px; font-weight: 600; color: #eee; }
#dlg-furn-body  {
  flex: 1; overflow-y: auto; padding: 6px;
  background: var(--props-bg);
}
/* En móvil: pantalla casi completa */
@media (max-width: 768px) {
  #dlg-furn-modal {
    width: 100vw; max-width: 100vw;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    margin: auto auto 0;
  }
  .dlg-furn-inner { max-height: 92vh; }
}

/* ── Menú contextual ───────────────────────────────────────────── */
#ctx-menu {
  display: none;
  position: fixed;
  z-index: 9000;
  background: #2c2c2c;
  border: 1px solid #555;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  padding: 5px 0;
  min-width: 200px;
  -webkit-user-select: none;
  user-select: none;
}
#ctx-menu.ctx-visible { display: block; }
.ctx-item {
  display: block;
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid #3c3c3c;
  color: #eee;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.ctx-item:last-child { border-bottom: none; }
.ctx-item:active    { background: #007acc; color: #fff; }
.ctx-item--active   { color: #7cf; }
.ctx-item--active::before { content: '✓  '; }
.ctx-item--danger   { color: #f88; }
.ctx-item--danger:active { background: #c00; color: #fff; }
.ctx-sep { height: 1px; background: #444; margin: 4px 0; }
.ctx-label { padding: 4px 18px 2px; font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: .05em; }

/* ── Herrajes dialog ───────────────────────────────────────────── */
#dlg-hardware {
  max-width: 90vw; max-height: 88vh;
  display: flex; flex-direction: column;
}
#hw-config { padding: 8px 14px; flex-shrink: 0; border-bottom: 1px solid #e0e0e0; }
#hardware-body { overflow-y: auto; flex: 1; padding: 0; }
#hardware-body table { border-collapse: collapse; width: 100%; font-size: 12px; }

/* ── Despiece dialog ───────────────────────────────────────────── */
#dlg-cutlist { border: none; border-radius: 6px; padding: 0; max-width: 90vw; max-height: 88vh; }
#dlg-cutlist::backdrop { background: rgba(0,0,0,.5); }
#cutlist-body { overflow-y: auto; max-height: 75vh; padding: 0; }
#cutlist-body table { border-collapse: collapse; width: 100%; font-size: 12px; }
#cutlist-body th { background: #e0e0e0; padding: 5px 10px; text-align: left; position: sticky; top: 0; }
#cutlist-body td { padding: 4px 10px; border-bottom: 1px solid #eee; white-space: nowrap; }
#cutlist-body tr:hover td { background: #f5f5f5; }
#cutlist-body .cl-group { background: #f0f0f0; font-weight: 700; font-size: 11px;
  padding: 3px 10px; letter-spacing: .3px; color: #555; }

/* ── Estado vacío (sin muebles) ─────────────────────────────────── */

#canvas-empty-state {
  position: absolute;
  top: 50%; left: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%);
  width: min(90%, 420px); height: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 12px; pointer-events: auto;
  background: #252527;
  border-radius: 20px;
  padding: 40px 48px;
  box-shadow: 0 4px 40px rgba(0,0,0,.5);
  border: 1px solid #3a3a3d;
  z-index: 5;
}
#canvas-empty-state[hidden] { display: none; }
.empty-state-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: #666; font-size: 16px;
  cursor: pointer; line-height: 1; padding: 2px 4px; border-radius: 4px;
  transition: background .12s, color .12s;
}
.empty-state-close:hover { background: rgba(255,255,255,.1); color: #ccc; }
.empty-state-icon { width: 120px; height: 120px; object-fit: contain; font-size: 56px; line-height: 1; color: #8a90a8; }
.empty-state-title { font-size: 28px; font-weight: 700; color: #d8dcec; margin: 0; }
.empty-state-desc { font-size: 14px; color: #9a9fb0; text-align: center; line-height: 1.6; margin: 0; }
.empty-state-btn {
  margin-top: 8px;
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 10px 28px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .1s;
}
.empty-state-btn:hover { background: #0090e8; }
.empty-state-btn:active { transform: scale(.97); }
.empty-state-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.empty-state-link {
  background: none; border: none; color: #7a80a0; font-size: 13px; cursor: pointer;
  text-decoration: underline; font-family: inherit; padding: 0;
  transition: color .12s;
}
.empty-state-link:hover { color: var(--accent); }
.empty-state-hint { font-size: 11px; color: #9a9fb0; margin: 0; }
#empty-state-recent { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; }
#empty-state-recent[hidden] { display: none; }
.empty-recent-title { font-size: 11px; color: #9a9fb0; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 2px; }
.empty-recent-item {
  background: none; border: 1px solid #c8cce0; border-radius: 6px;
  color: var(--accent); font-size: 13px; cursor: pointer; font-family: inherit;
  padding: 5px 18px; width: 260px; text-align: left;
  transition: background .12s, border-color .12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.empty-recent-item:hover { background: rgba(0,122,204,.08); border-color: var(--accent); }

/* ── Galería de tipos de mueble ─────────────────────────────────── */

#dlg-furn-gallery {
  background: #1e1e2e;
  max-width: min(740px, 96vw); width: min(740px, 96vw);
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  margin: 0; max-height: 92vh; height: 92vh; overflow: hidden;
}
#dlg-furn-gallery[open] {
  display: flex; flex-direction: column;
}
#dlg-furn-gallery::backdrop { background: rgba(0,0,0,.6); }
#furn-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  grid-auto-rows: 160px;
  gap: 10px; padding: 14px;
  flex: 1; overflow-y: auto;
  background: #1e1e2e;
}
/* Paso 2: variaciones — botón volver ocupa toda la fila */
.furn-gallery-back {
  grid-column: 1 / -1;
  padding: 6px 8px; font-size: 12px; font-weight: 600; color: #8888aa;
  cursor: pointer; border-bottom: 1px solid #2a2a3a; margin-bottom: 2px;
  transition: color .12s;
}
.furn-gallery-back:hover { color: var(--accent); }
.furn-preset-card {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: #24243a; border: 1.5px solid #3a3a58; border-radius: 8px;
  padding: 12px 6px 8px; cursor: pointer;
  transition: border-color .15s, background .15s;
  color: #fff;
}
.furn-preset-card:hover { border-color: var(--accent); background: #1d2840; color: #fff; }
.furn-preset-card.dragging { opacity: .35; }

/* Presets guardados en BD: borde distinto + ✕ delete en esquina */
.furn-preset-card--user { position: relative; border-style: dashed; }
.furn-preset-card--user:hover { border-style: solid; }
.furn-preset-icon--thumb {
  width: 52px; height: 52px; background: #f5f1e8; border-radius: 4px; overflow: hidden;
}
.furn-preset-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; padding: 0;
  background: rgba(220, 60, 60, .85); color: #fff;
  border: none; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1;
  display: none;
}
.furn-preset-card--user:hover .furn-preset-del { display: block; }
.furn-preset-del:hover { background: rgb(220, 60, 60); }
.furn-gallery-presets-sep {
  grid-column: 1 / -1;
  font-size: 11px; font-weight: 600; color: #888;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 8px 4px 4px;
  border-top: 1px dashed #444;
  margin-top: 4px;
}
[data-theme="light"] .furn-gallery-presets-sep { color: #666; border-top-color: #c4c0b8; }

/* ── Barra "Baldas internas" en la galería de variaciones ───────── */
.furn-gallery-shelfbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; margin: 4px 0 8px;
  background: #1d2540; border: 1px solid #3a3a58; border-radius: 6px;
}
.furn-gallery-shelfbar-lbl {
  font-size: 12px; font-weight: 600; color: #bbbbd8; margin-right: 4px;
}
.furn-gallery-shelfbar-opt {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid #3a3a58; border-radius: 14px;
  cursor: pointer; user-select: none;
  font-size: 12px; color: #bbbbd8;
  transition: all .12s;
}
.furn-gallery-shelfbar-opt input { display: none; }
.furn-gallery-shelfbar-opt:hover { border-color: var(--accent); color: #fff; }
.furn-gallery-shelfbar-opt.active {
  background: var(--accent); border-color: var(--accent); color: #1a1a2a; font-weight: 700;
}
[data-theme="light"] .furn-gallery-shelfbar { background: #ece8e0; border-color: #c4c0b8; }
[data-theme="light"] .furn-gallery-shelfbar-lbl { color: #444; }
[data-theme="light"] .furn-gallery-shelfbar-opt { border-color: #c4c0b8; color: #555; }
[data-theme="light"] .furn-gallery-shelfbar-opt.active { color: #fff; }

/* ── Barra "Zócalo / Retranqueo" en cocina-bajo ─────────────────── */
.furn-gallery-plinthbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px; margin: 0 0 8px;
  background: #1d2540; border: 1px solid #3a3a58; border-radius: 6px;
}
.furn-gallery-plinthbar-num {
  width: 64px; padding: 4px 6px;
  background: #0f1428; border: 1px solid #3a3a58; border-radius: 4px;
  color: #e8e8f0; font-size: 12px; font-variant-numeric: tabular-nums;
  text-align: right;
}
.furn-gallery-plinthbar-num:focus { outline: none; border-color: var(--accent); }
.furn-gallery-plinthbar-unit { font-size: 11px; color: #7a7a98; }
[data-theme="light"] .furn-gallery-plinthbar { background: #ece8e0; border-color: #c4c0b8; }
[data-theme="light"] .furn-gallery-plinthbar-num {
  background: #fff; border-color: #c4c0b8; color: #222;
}
[data-theme="light"] .furn-gallery-plinthbar-unit { color: #888; }
.furn-preset-icon { width: 52px; height: 52px; flex-shrink: 0; }
.furn-preset-icon svg { width: 100%; height: 100%; display: block; }
.furn-preset-name { font-size: 11px; font-weight: 600; color: #bbbbd8; text-align: center; line-height: 1.3; }
.furn-preset-dims { font-size: 9.5px; color: #5a5a78; text-align: center; font-variant-numeric: tabular-nums; }

/* ── Wizard de nuevo mueble ─────────────────────────────────────── */
.wiz-modal {
  min-width: 460px; max-width: 580px; width: 92%;
  display: flex; flex-direction: column; max-height: 88vh;
}
.wiz-body {
  flex: 1; overflow-y: auto; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 0;
}
.wiz-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-top: 1px solid #333; flex-shrink: 0;
}
.wiz-err { color: #f77; font-size: 12px; flex: 1; text-align: center; min-height: 16px; }
.wiz-hint { font-size: 12px; color: #666; margin: 0 0 14px; line-height: 1.5; }
.wiz-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.wiz-row label { font-size: 12px; color: #aaa; flex: 0 0 150px; }
.wiz-row input[type=number], .wiz-row input[type=text] {
  width: 90px; padding: 5px 8px; background: #2a2a3a;
  border: 1px solid #444; color: #eee; border-radius: 4px; font-size: 13px;
}
.wiz-row input[type=text] { width: 100%; flex: 1; }
.wiz-toggle { display: flex; gap: 6px; }
.wiz-toggle button {
  padding: 4px 16px; border-radius: 4px; border: 1.5px solid #444;
  background: transparent; color: #aaa; cursor: pointer; font-size: 12px;
  transition: all .12s; font-family: inherit;
}
.wiz-toggle button.active {
  border-color: var(--accent); background: var(--accent); color: #fff;
}
.wiz-section { border-left: 2px solid #333; padding-left: 12px; margin: 10px 0 4px; }
.wiz-breadcrumb {
  font-size: 11px; color: #556; background: #1a1a28; border-radius: 4px;
  padding: 4px 8px; margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wiz-content-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 6px;
}
.wiz-content-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border-radius: 6px; border: 1.5px solid #3a3a58;
  background: #24243a; color: #9898b8; cursor: pointer; font-size: 11px;
  transition: border-color .12s, background .12s; font-family: inherit;
}
.wiz-content-btn.active { border-color: var(--accent); background: #1c2040; color: #cce; }
.wiz-content-btn:hover { border-color: var(--accent); }
.wiz-content-btn svg { width: 32px; height: 32px; }
.wiz-sizes-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
  margin-top: 8px;
}
.wiz-sizes-grid label { font-size: 12px; color: #888; }
.wiz-sizes-grid input {
  padding: 4px 8px; background: #2a2a3a; border: 1px solid #444;
  color: #eee; border-radius: 4px; font-size: 12px; width: 80px;
}
.furn-preset-card--wizard {
  border-color: #5a9a5a;
  background: #1a2a1a;
  color: #7acc7a;
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
}
.furn-preset-card--wizard .furn-preset-icon { width: 36px; height: 36px; flex-shrink: 0; }
.furn-preset-card--wizard .furn-preset-name { font-size: 12px; font-weight: 700; color: #7acc7a; text-align: left; }
.furn-preset-card--wizard .furn-preset-dims { font-size: 10px; color: #4a7a4a; text-align: left; }
.furn-preset-card--wizard:hover { background: #1e301e; border-color: #7acc7a; }
[data-theme="light"] .furn-preset-card--wizard { background: #edfaed; border-color: #4a8a4a; color: #2a6a2a; }
[data-theme="light"] .furn-preset-card--wizard:hover { background: #ddf0dd; }
[data-theme="light"] .wiz-modal { background: #fff; color: #222; }
[data-theme="light"] .wiz-body { background: #f8f8f8; }
[data-theme="light"] .wiz-row input[type=number], [data-theme="light"] .wiz-row input[type=text] {
  background: #fff; border-color: #ccc; color: #222;
}
[data-theme="light"] .wiz-content-btn { background: #eee; color: #555; border-color: #ccc; }
[data-theme="light"] .wiz-content-btn.active { background: #ddeeff; }
[data-theme="light"] .wiz-sizes-grid input { background: #fff; border-color: #ccc; color: #222; }
[data-theme="light"] .wiz-breadcrumb { background: #e8e8f8; color: #889; }
[data-theme="light"] .wiz-section { border-color: #ddd; }

/* ── Wizard: modo editor interactivo ────────────────────────────── */
.wiz-modal--editor {
  min-width: min(92vw, 900px);
  max-width: min(98vw, 1100px);
  width: 92vw;
  height: 88vh;
}
.wiz-body--editor {
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  gap: 0;
}
.wiz-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a40;
  flex-shrink: 0;
}
.wiz-undo-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid #3a3a55;
  border-radius: 4px;
  background: #22223a;
  color: #bbc;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.wiz-undo-btn:hover:not(:disabled) { background: #2e2e50; color: #dde; }
.wiz-undo-btn:disabled { opacity: .35; cursor: default; }
.wiz-undo-btn svg { flex-shrink: 0; }
[data-theme="light"] .wiz-editor-toolbar { background: #eef; border-bottom-color: #ddd; }
[data-theme="light"] .wiz-undo-btn { background: #e8e8f0; border-color: #ccc; color: #555; }
[data-theme="light"] .wiz-undo-btn:hover:not(:disabled) { background: #dde; color: #333; }
.wiz-editor {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.wiz-editor-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111118;
  overflow: hidden;
  border-right: 1px solid #2a2a40;
  position: relative;
}
.wiz-editor-props {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--props-bg, #f3f3f3);
}
.wiz-editor-props .wiz-row label { flex: 0 0 100px; }
.wiz-editor-props .wiz-toggle button { padding: 4px 8px; }
.wiz-editor-hint {
  font-size: 12px; color: #556; text-align: center;
  margin-top: 16px; margin-bottom: 8px; padding: 0 16px; line-height: 1.6;
}
[data-theme="light"] .wiz-modal--editor { background: #fff; }
[data-theme="light"] .wiz-editor-preview { background: #f0f0f8; border-right-color: #ddd; }
[data-theme="light"] .wiz-editor-props { background: var(--props-bg, #f3f3f3); }
[data-theme="light"] .wiz-editor-hint { color: #556; }

/* Botón "← Volver" / "← Vista general" en propiedades del wizard */
.wiz-prop-back {
  display: flex; align-items: center; gap: 4px;
  width: 100%; padding: 8px 12px; margin-bottom: 8px;
  background: #1a1a2e; border: 1px solid #2a2a40; border-radius: 6px;
  color: #8888cc; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .12s, color .12s; font-family: inherit;
}
.wiz-prop-back:hover { background: #22224a; color: #aac; }
[data-theme="light"] .wiz-prop-back { background: #eef; border-color: #ccc; color: #558; }
[data-theme="light"] .wiz-prop-back:hover { background: #dde; color: #336; }

/* ── Wizard editor: layout móvil ─────────────────────────────── */
.wiz-editor--mobile {
  flex-direction: column;
  position: relative;
}
.wiz-editor--mobile .wiz-editor-preview {
  flex: 1; border-right: none; border-bottom: 1px solid #2a2a40;
}
.wiz-editor--mobile .wiz-editor-props {
  position: absolute; inset: 0; width: 100%; z-index: 10;
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.wiz-editor--mobile.wiz-editor--show-props .wiz-editor-props {
  transform: translateX(0);
}
[data-theme="light"] .wiz-editor--mobile .wiz-editor-preview { border-bottom-color: #ddd; }

/* ── Mobile layout ─────────────────────────────────────────────── */

@media (max-width: 768px) {

  .tb-desktop-only { display: none !important; }

  /* Mobile tabbar visible en móvil */
  #mobile-tabbar { display: flex; }

  /* Toolbar: compacto en móvil */
  #toolbar { padding: 0 6px; gap: 2px; }
  #btn-hamburger { font-size: 20px; padding: 0 12px; min-height: 44px; }
  .tb-new-btn { padding: 0; width: 32px; height: 32px; justify-content: center; }
  .tb-new-label { display: none; }
  .tb-dropdown { min-width: 0; width: 100%; right: 0; border-radius: 0; border-left: none; border-right: none; }
  .mb-panel button { padding: 9px 16px; font-size: 15px; }
  .mb-panel .tb-drop-link { padding: 9px 16px; font-size: 15px; }
  .mb-root-item, .mb-drill-item { padding: 12px 16px; font-size: 15px; min-height: 44px; }
  .mb-back-btn { padding: 10px 16px; min-height: 44px; }
  #zoom-label, #status-label { display: none; }

  /* Contenedor de páginas: scroll horizontal con snap, ocupa TODO el espacio restante */
  #mobile-pages {
    flex-direction: row;
    min-height: 0;
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #mobile-pages::-webkit-scrollbar { display: none; }

  /* Cada página: ancho 100vw, altura completa — usar IDs para ganar al especificidad desktop */
  #page-design, #page-props, #page-3d {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  /* Página de propiedades: permite scroll vertical del contenido */
  #page-props {
    overflow-y: auto;
  }

  /* Visor 3D inline: ocupa toda la página */
  #viewer-host-mobile {
    flex: 1;
    width: 100%;
    position: relative;
    display: block;
    background: #1a1a1a;
    min-height: 0;
  }

  /* Canvas: fill la página; touch-action: none para capturar pinch manualmente
     y detectar swipes horizontales desde JS para pasar de página */
  #canvas-area {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
  }

  /* En móvil el panel no flota — se integra en el flujo normal de la página */
  #props-panel, #props-panel.floating {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 0 !important;
    border-left: none !important;
    resize: none !important;
    box-shadow: none !important;
    display: flex;
    flex-direction: column;
  }
  /* Nunca colapsar en móvil */
  #props-panel.props-collapsed #props-content,
  #props-panel.props-collapsed #props-resize-handle {
    display: flex !important;
  }
  #props-panel.props-collapsed #props-content { display: flex !important; flex-direction: column; }

  /* Ocultar controles de dock/float en móvil, pero mostrar botón cerrar */
  .props-header-btns { display: none !important; }
  .props-close-btn   { display: block !important; margin-left: auto; }
  .dock-zone         { display: none !important; }

  /* En móvil la barra es un poco más alta */
  #mobile-tabbar { height: 56px; }
  .mobile-tab-icon { font-size: 20px; }

  /* Dialogs: pantalla completa en móvil (solo cuando están abiertos) */
  dialog[open] {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    inset: 0 !important;
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #dlg-cutlist  { max-height: 100vh; }
  #cutlist-body { max-height: calc(100vh - 80px); }
  #dlg-hardware { display: none !important; }

  /* Tipografía y controles más grandes para dedos */
  html, body { font-size: 15px; }
  .prop-row   { padding: 6px 10px; }
  .prop-label { flex: 0 0 100px; font-size: 13px; }
  .prop-value input[type="number"],
  .prop-value input[type="text"],
  .prop-value select { font-size: 14px; padding: 4px 6px; }
  .prop-value input[type="checkbox"] { width: 18px; height: 18px; }
  .prop-value input[type="color"]    { width: 44px; height: 28px; }
  .prop-section-title { padding: 5px 10px; font-size: 13px; }
  .btn-group button   { padding: 5px 8px;  font-size: 13px; }
  .prop-hint          { font-size: 12px; }
  .obj-select         { font-size: 13px; padding: 4px 6px; }

  /* Botones de añadir/eliminar mueble: área de toque amplia */
  .prop-furn-actions  { gap: 8px; margin-top: 10px; }
  .prop-furn-btn      { width: 36px; height: 36px; }
  .prop-furn-btn svg  { width: 18px; height: 18px; }

  /* Modales: pantalla completa en móvil */
  .modal-box, .modal-box--gallery {
    min-width: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .modal-box--gallery {
    height: 100vh !important;
  }
  .wiz-modal--editor {
    height: 100vh !important;
  }
  .modal-overlay {
    align-items: flex-end;
  }
  .cloud-gallery {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* ── Tablero encimera ────────────────────────────────────────────── */
.tabletop-board {
  position: absolute;
  background: linear-gradient(180deg, #c8a96e 0%, #a07840 40%, #b89050 100%);
  border: 1px solid #7a5c28;
  border-radius: 2px;
  box-sizing: border-box;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tabletop-board.active {
  box-shadow: 0 0 10px 3px rgba(0, 0, 0, .3) inset;
}
.tabletop-label {
  font-size: 10px;
  color: rgba(0,0,0,0.55);
  pointer-events: none;
  white-space: nowrap;
  font-weight: 500;
}


/* ── Fondo MDF del mueble (se extiende T/2 dentro de los tableros) ── */
.furn-back-panel {
  position: absolute;
  background-color: #9b7530;  /* mismo default que la carcasa — sobreescrito inline */
  z-index: 0;
  pointer-events: none;
}

/* ── Panel trasero/lateral ───────────────────────────────────────── */
.back-panel {
  position: absolute;
  background: transparent;
  border: none;
  border-radius: 2px;
  opacity: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 0;
}
.back-panel.rear {
  opacity: 0.35;
  border: 1px dashed rgba(150,120,60,.5);
}
.back-panel.active {
  box-shadow: 0 0 10px 3px rgba(0, 0, 0, .3) inset;
  opacity: 0.8;
}
.back-panel.rear.active {
  opacity: 0.65;
}

/* ── Galería de texturas ─────────────────────────────────────────── */
.dlg-textures {
  width: min(90vw, 680px);
  max-height: 80vh;
  border: none;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
.dlg-textures::backdrop { background: rgba(0,0,0,0.45); }

.dlg-textures-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  padding: 12px;
  overflow-y: auto;
  max-height: calc(80vh - 52px);
}

.tex-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  border: 2px solid transparent;
  overflow: hidden;
  transition: border-color .15s, transform .1s;
}
.tex-thumb:hover { border-color: var(--accent); transform: scale(1.04); }
.tex-thumb--none {
  background: var(--int-bg);
  border: 2px dashed #bbb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #888;
  text-align: center;
  line-height: 1.3;
}
.tex-thumb-lbl {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 9px;
  padding: 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* ── Selector de textura (en panel de propiedades) ───────────────── */
.tex-picker {
  display: flex;
  align-items: center;
  gap: 5px;
}
.tex-swatch {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  border: 1px solid #bbb;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.tex-swatch--none {
  background: var(--int-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 14px;
}
.tex-pick-btn {
  font-size: 11px;
  padding: 3px 7px;
  border: 1px solid #bbb;
  border-radius: 3px;
  background: #f5f5f5;
  cursor: pointer;
  white-space: nowrap;
}
.tex-pick-btn:hover { background: #e8e8e8; }
.tex-clear-btn {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid #e0a0a0;
  border-radius: 3px;
  background: #fff0f0;
  color: #c44;
  cursor: pointer;
}
.tex-clear-btn:hover { background: #fdd; }
.tex-name-lbl {
  font-size: 10px;
  color: #666;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Modal genérico (cloud save/load) ─────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.modal-box {
  background: #fff; border-radius: 6px; min-width: 420px; max-width: 600px;
  box-shadow: 0 8px 40px rgba(0,0,0,.35); display: flex; flex-direction: column;
  max-height: 80vh;
}
.modal-hdr {
  padding: 11px 16px; background: #2d2d30; color: #eee;
  font-weight: 700; font-size: 13px; border-radius: 6px 6px 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-close, .modal-refresh {
  background: none; border: none; color: #bbb; font-size: 16px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.modal-close:hover, .modal-refresh:hover { color: #fff; }
.modal-sync {
  background: none; border: 1px solid #555; border-radius: 4px;
  color: #8cf; font-size: 11px; cursor: pointer; padding: 2px 8px;
  margin-right: 6px;
}
.modal-sync:hover { background: #2a4a6a; }
.modal-sync:disabled { opacity: .5; cursor: default; }
.modal-body { overflow-y: auto; padding: 8px 0; }

/* Lista de archivos cloud */
.cloud-list { min-height: 60px; }
.cloud-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px; border-bottom: 1px solid #f0f0f0;
}
.cloud-row:last-child { border-bottom: none; }
.cloud-row:hover { background: #f7f7f7; }
.cloud-name { font-size: 13px; font-weight: 500; flex: 1; }
.cloud-ext  { font-size: 11px; color: #999; }
.cloud-date { font-size: 11px; color: #888; white-space: nowrap; }
.cloud-btn-load {
  padding: 3px 10px; border: 1px solid var(--accent); border-radius: 3px;
  background: #fff; color: var(--accent); font-size: 11px; cursor: pointer; white-space: nowrap;
}
.cloud-btn-load:hover { background: var(--accent); color: #fff; }
.cloud-btn-del {
  padding: 3px 7px; border: 1px solid #e0aaaa; border-radius: 3px;
  background: #fff; color: #c44; font-size: 11px; cursor: pointer;
}
.cloud-btn-del:hover { background: #fdd; }

/* ── Galería de proyectos cloud ──────────────────────────────────── */
.modal-box--gallery { min-width: 600px; max-width: 90vw; height: 80vh; }

/* ── Scope bar (Catálogo / Mis muebles) ──────────────────────── */
.gallery-scope-bar {
  display: flex; gap: 0; border-bottom: 1px solid #444;
  background: #1e1e1e;
}
.gallery-scope-btn {
  flex: 1; padding: 7px 0; border: none; background: transparent;
  color: #888; cursor: pointer; font: inherit; font-size: 13px;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.gallery-scope-btn:hover { color: #ccc; background: #2a2a2a; }
.gallery-scope-btn.active { color: #fff; border-bottom-color: var(--accent); background: #252525; }
[data-theme="light"] .gallery-scope-bar { background: #e8e4dc; border-bottom-color: #c4c0b8; }
[data-theme="light"] .gallery-scope-btn { color: #777; }
[data-theme="light"] .gallery-scope-btn:hover { color: #333; background: #dcd8d0; }
[data-theme="light"] .gallery-scope-btn.active { color: #111; border-bottom-color: var(--accent); background: #f0ece4; }

/* ── Barra de filtro por categoría ────────────────────────────── */
.gallery-filter-bar {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 8px 14px 4px; background: #252525; border-bottom: 1px solid #444;
}
.gallery-filter-btn {
  padding: 3px 11px; border-radius: 20px; border: 1px solid #555;
  background: transparent; color: #aaa; cursor: pointer;
  font-size: 12px; font: inherit; white-space: nowrap;
  transition: background .12s, color .12s;
}
.gallery-filter-btn:hover { background: #3a3a3d; color: #fff; }
.gallery-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.gallery-empty {
  grid-column: 1/-1; padding: 24px; text-align: center; color: #666; font-size: 13px;
}
[data-theme="light"] .gallery-filter-bar { background: #e0dcd4; border-bottom-color: #c4c0b8; }
[data-theme="light"] .gallery-filter-btn { color: #555; border-color: #b8b4ac; }
[data-theme="light"] .gallery-filter-btn:hover { background: #cac6be; color: #111; }

/* ── Input de búsqueda en galerías cloud ─────────────────────── */
.cloud-search-wrap {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px 4px; background: #252525; border-bottom: 1px solid #444;
}
[data-theme="light"] .cloud-search-wrap { background: #e0dcd4; border-bottom-color: #c4c0b8; }
.cloud-search-input {
  flex: 1; min-width: 0; padding: 7px 12px 7px 32px;
  border: 1px solid #444; border-radius: 6px;
  background: #1e1e1e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cline x1='10.2' y1='10.2' x2='14' y2='14'/%3E%3C/svg%3E") 10px center no-repeat;
  color: #ddd; font: 13px/1.4 'Segoe UI', system-ui, sans-serif;
  outline: none; transition: border-color .15s;
}
.cloud-search-input::placeholder { color: #777; }
.cloud-search-input:focus { border-color: var(--accent); }
[data-theme="light"] .cloud-search-input {
  background-color: #fff; border-color: #ccc; color: #222;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cline x1='10.2' y1='10.2' x2='14' y2='14'/%3E%3C/svg%3E");
}
[data-theme="light"] .cloud-search-input::placeholder { color: #999; }
.gallery-sort-btn {
  flex-shrink: 0; padding: 6px 10px; border-radius: 6px; border: 1px solid #555;
  background: transparent; color: #aaa; cursor: pointer;
  font: 12px/1.3 'Segoe UI', system-ui, sans-serif; white-space: nowrap;
  transition: background .12s, color .12s;
}
.gallery-sort-btn:hover { background: #3a3a3d; color: #fff; }
[data-theme="light"] .gallery-sort-btn { color: #555; border-color: #b8b4ac; }
[data-theme="light"] .gallery-sort-btn:hover { background: #cac6be; color: #111; }

.cloud-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: min-content;
  align-content: start;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: #1e1e1e;
}
.cloud-sort-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 14px; background: #181818; border-bottom: 1px solid #333;
  font: 12px/1 'Segoe UI', system-ui, sans-serif;
}
.cloud-sort-lbl { color: #aaa; margin-right: 4px; }
.cloud-sort-btn {
  padding: 5px 10px; border: 1px solid #444; border-radius: 4px;
  background: #2a2a2a; color: #ddd; cursor: pointer; font-size: 12px;
  transition: background .12s, border-color .12s;
}
.cloud-sort-btn:hover { background: #3a3a3a; border-color: #666; }
.cloud-sort-btn--active {
  background: var(--accent, #c66); border-color: var(--accent, #c66); color: #fff;
}
.cloud-card {
  background: #2d2d30;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, transform .1s;
  position: relative;
}
.cloud-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cloud-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(0,122,204,.35); }
.cloud-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #f5f1e8;
  overflow: hidden;
}
.cloud-thumb {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.cloud-card-del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.6); border: none; border-radius: 3px;
  color: #ccc; font-size: 11px; cursor: pointer;
  padding: 1px 5px; opacity: 0; transition: opacity .15s;
}
.cloud-thumb-wrap:hover .cloud-card-del { opacity: 1; }
.cloud-card-del:hover { background: #c44; color: #fff; }

/* ── Papelera ── */
.modal-trash {
  background: none; border: none; cursor: pointer;
  font-size: 16px; padding: 2px 6px; border-radius: 4px; color: #aaa;
  transition: color .15s, background .15s;
}
.modal-trash:hover { color: #fff; background: rgba(255,255,255,.12); }

.trash-gallery { gap: 12px; }
.trash-card { position: relative; }
.trash-card .cloud-thumb-wrap { pointer-events: none; }

.trash-card-actions {
  display: flex; gap: 4px; padding: 4px 4px 2px;
  justify-content: space-between;
}
.trash-restore-btn {
  flex: 1; font-size: 11px; padding: 3px 6px;
  background: #2a7a2a; color: #d4f5d4; border: none;
  border-radius: 4px; cursor: pointer; transition: background .15s;
}
.trash-restore-btn:hover { background: #3a9a3a; }
.trash-del-btn {
  font-size: 11px; padding: 3px 7px;
  background: rgba(180,40,40,.7); color: #fcc; border: none;
  border-radius: 4px; cursor: pointer; transition: background .15s;
}
.trash-del-btn:hover { background: #c33; }

.trash-empty-btn {
  font-size: 11px; padding: 2px 8px; margin-right: 8px;
  background: rgba(180,40,40,.6); color: #fcc; border: none;
  border-radius: 4px; cursor: pointer; transition: background .15s;
}
.trash-empty-btn:hover { background: #c33; color: #fff; }

/* ── Botón lupa (zoom) para galerías ── */
.ml-zoom-btn {
  position: absolute; bottom: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #eee;
  border: none; cursor: zoom-in;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s, transform .1s;
  z-index: 3;
}
.cloud-card:hover  .ml-zoom-btn { opacity: 1; }
.ml-zoom-btn:hover  { background: var(--accent, #c49850); color: #111; }
.ml-zoom-btn:active { transform: scale(.92); }
.ml-zoom-btn[hidden] { display: none !important; }

/* ── Lightbox (dialog nativo → top-layer, siempre por encima de todo) ── */
dialog.ml-lightbox {
  border: none; padding: 24px;
  background: rgba(0,0,0,.88);
  max-width: 100vw; max-height: 100vh;
  width: 100vw; height: 100vh;
  cursor: zoom-out;
  overflow: hidden;
}
dialog.ml-lightbox[open] {
  display: flex; align-items: center; justify-content: center;
  animation: mlLbFade .15s ease;
}
dialog.ml-lightbox::backdrop {
  background: rgba(0,0,0,.6);
}
.ml-lightbox img {
  max-width: 95vw; max-height: 95vh; object-fit: contain;
  border-radius: 8px; background: #fff;
  box-shadow: 0 16px 48px rgba(0,0,0,.8);
  cursor: default;
}
.ml-lightbox-close {
  position: fixed; top: 16px; right: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-size: 22px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.ml-lightbox-close:hover { background: var(--accent, #c49850); color: #111; border-color: var(--accent, #c49850); }
@keyframes mlLbFade { from { opacity: 0 } to { opacity: 1 } }
.cloud-card-name {
  font-size: 11px; font-weight: 600; color: #ccc;
  padding: 5px 7px 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cloud-card-date { font-size: 10px; color: #666; padding: 0 7px 6px; }
.cloud-badge-local { font-size: 10px; margin-left: 4px; opacity: .7; }
.cloud-badge-own { color: #f0c040; font-size: 11px; margin-right: 3px; }

/* ── Optimizer (inline panel) ────────────────────────────────────── */

#opt-body {
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 0;
  min-height: 0;
  color: #ccc;
}
#opt-body input[type="number"], #opt-body input[type="text"] {
  background: #1e1e2e;
  color: #ccc;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 2px 4px;
}
#opt-body input[type="checkbox"] { accent-color: var(--accent); }
#opt-body label { color: #ccc; }
#opt-results {
  border-top: 1px solid #383860;
  padding-top: 14px;
}
.opt-config-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.opt-config-label {
  font-size: 12px;
  color: #999;
  min-width: 110px;
}
.opt-group-row {
  border: 1px solid #383860;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: #252537;
}
.opt-group-title {
  font-weight: 600;
  font-size: 12px;
  color: #ccc;
}
.opt-group-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.opt-group-fields input, .opt-group-fields select {
  background: #1e1e2e;
  color: #ccc;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 2px 4px;
}
.opt-boards-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.opt-board-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.opt-board-card svg {
  width: 100%;
  height: auto;
  display: block;
}
.opt-board-lbl {
  font-size: 12px;
  font-weight: 600;
  color: #aaa;
}
.opt-result-group {
  margin-bottom: 14px;
}
.opt-result-group-header {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #ccc;
  padding: 6px 10px;
  background: #252537;
  border-radius: 4px;
}
.opt-grain-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #7a5a2a;
  background: #f0e2c0;
  border: 1px solid #c8a97a;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.opt-total-box {
  background: #007acc;
  color: #fff;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}
.opt-warning {
  color: #c55;
  font-size: 12px;
  padding: 6px 10px;
  background: #fff0f0;
  border-radius: 4px;
}
#btn-opt-run {
  align-self: flex-start;
  margin-top: 4px;
}

/* ── Herrajes dialog ─────────────────────────────────────────────── */
#dlg-hardware {
  width: min(96vw, 820px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: none;
  border-radius: 6px;
  overflow: hidden;
}
#dlg-hardware::backdrop { background: rgba(0,0,0,.5); }
#hw-config {
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}
#hardware-body {
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 0;
}
.hw-group-header {
  padding: 8px 14px;
  font-weight: 700;
  font-size: 12px;
  background: #f0f0f0;
  border-bottom: 1px solid #ddd;
  color: #333;
}
.hw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.hw-table th {
  background: #e8e8e8;
  padding: 5px 10px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.hw-table td {
  padding: 4px 10px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.hw-table tfoot td { border-top: 2px solid #ddd; border-bottom: none; }
.hw-price {
  width: 68px;
  font-size: 12px;
  text-align: right;
}
.hw-total { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hw-subtotal-lbl { text-align: right; font-weight: 600; color: #555; }
.hw-subtotal-val { text-align: right; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hw-grand-total-box {
  background: #007acc;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 16px;
  text-align: right;
}
.hw-tools-sep {
  background: #f5f0e8;
  color: #8a6a30;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px !important;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.hw-tool-row { background: #fdfaf4; }
.hw-tool-row td { color: #7a5a20; }

/* ── Instrucciones de montaje ───────────────────────────────────── */

#dlg-assembly[open] {
  width: min(96vw, 1100px);
  height: min(92vh, 780px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: none;
  border-radius: 6px;
  overflow: hidden;
  background: #fafaf7;
}
#dlg-assembly::backdrop { background: rgba(0,0,0,.5); }
#asm-config {
  padding: 10px 16px;
  border-bottom: 1px solid #e0ddd0;
  background: #f4f0e4;
}
#asm-body {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
}
#asm-sidebar {
  background: #efebdc;
  border-right: 1px solid #d8d3c0;
  overflow-y: auto;
  padding: 10px 0;
}
.asm-step-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  font: 500 12px/1.3 sans-serif;
  color: #3a3a35;
  text-align: left;
  cursor: pointer;
  transition: background .1s;
}
.asm-step-btn:hover { background: #e6e0c6; }
.asm-step-btn.active {
  background: #faf6e8;
  border-left-color: #c07a20;
  color: #000;
  font-weight: 600;
}
.asm-step-btn-num {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #d6cfb0;
  font: 700 13px sans-serif;
  color: #2a2a25;
}
.asm-step-btn.active .asm-step-btn-num {
  background: #c07a20;
  color: #fff;
}
#asm-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #fff;
}
#asm-stage-content {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 28px;
}
.asm-step-hdr {
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 2px solid #1a1a1a;
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.asm-step-hdr .asm-num {
  font: 900 40px/1 sans-serif;
  color: #c07a20;
}
.asm-step-hdr h2 {
  margin: 0;
  font: 700 18px/1.2 sans-serif;
  color: #1a1a1a;
}
.asm-step-body {
  font: 14px/1.55 sans-serif;
  color: #2a2a2a;
  margin: 0 0 14px;
}
.asm-step-body strong { color: #1a1a1a; }
.asm-svg-wrap {
  background: #fbfbf7;
  border: 1px solid #e0dcc8;
  border-radius: 4px;
  padding: 10px;
  margin: 14px 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.asm-svg-wrap.two-col {
  grid-template-columns: 1fr 1fr;
}
.asm-svg-wrap svg {
  width: 100%;
  height: auto;
  max-height: 300px;
  display: block;
}
.asm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.asm-chip {
  display: inline-block;
  padding: 3px 10px;
  background: #f0ead4;
  border: 1px solid #d6cfa8;
  border-radius: 12px;
  font: 500 11px sans-serif;
  color: #4a4020;
}
.asm-chip.hw { background: #e4e8ee; border-color: #c0c6d0; color: #2a3848; }
.asm-tips, .asm-warnings {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 4px;
  font: 13px/1.45 sans-serif;
}
.asm-tips {
  background: #eef6ea;
  border-left: 3px solid #5a8a3a;
  color: #304830;
}
.asm-warnings {
  background: #fbebd0;
  border-left: 3px solid #c08020;
  color: #603820;
}
.asm-tips ul, .asm-warnings ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.asm-tips li, .asm-warnings li { margin: 3px 0; }
.asm-section-lbl {
  font: 600 11px/1 sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8a7a3a;
  margin: 14px 0 4px;
}
#asm-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid #e0ddd0;
  background: #f4f0e4;
}
#asm-nav-pos {
  font: 600 12px sans-serif;
  color: #5a5a55;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  #asm-body { grid-template-columns: 1fr; }
  #asm-sidebar { display: none; }
}

@media print {
  #dlg-assembly { width: 100%; height: auto; max-height: none; box-shadow: none; }
  #asm-sidebar, #asm-nav, #asm-config, .dlg-header { display: none !important; }
  #asm-body { grid-template-columns: 1fr; }
  .asm-step-hdr { break-before: page; }
  .asm-step-hdr:first-of-type { break-before: auto; }
}

/* ── Electrodomésticos ────────────────────────────────────────────── */

.appliance-block {
  position: absolute;
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.18);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.18);
  transition: box-shadow 0.15s, border-color 0.15s;
  user-select: none;
}
.appliance-block:hover {
  box-shadow: 0 0 0 2px #007acc44, 1px 2px 8px rgba(0,0,0,0.22);
}
.appliance-block.active {
  border-color: #007acc;
  box-shadow: 0 0 0 2px #007acc88, 1px 2px 8px rgba(0,0,0,0.22);
}

.appliance-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.52);
  color: #fff;
  font-size: 10px;
  padding: 3px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
}
.appliance-icon {
  font-size: 14px;
  line-height: 1;
}
.appliance-dims {
  font-size: 9px;
  opacity: 0.78;
  font-variant-numeric: tabular-nums;
}

/* ── Dialog de selección de electrodoméstico ─────────────────────── */

#dlg-appliances {
  border: none;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  padding: 0;
  min-width: 320px;
  max-width: 480px;
}
#dlg-appliances::backdrop { background: rgba(0,0,0,0.35); }

.app-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
}
.app-card:hover {
  background: #e8f4ff;
  border-color: #007acc;
  box-shadow: 0 0 0 2px #007acc33;
}
.app-card-icon { font-size: 28px; line-height: 1; }
.app-card-name { font-size: 12px; font-weight: 600; color: #333; text-align: center; }
.app-card-dims { font-size: 10px; color: #888; font-variant-numeric: tabular-nums; }

/* ── Cell popover ──────────────────────────────────────────────── */

#cell-popover {
  position: fixed;
  z-index: 300;
  background: #f3f3f3;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
  min-width: 210px;
  font: 12px/1.4 'Segoe UI', system-ui, sans-serif;
  user-select: none;
}

.cpop-section-hdr {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #444;
  background: #e8e5e0;
  border-bottom: 1px solid #ddd;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cpop-section-hdr::before { content: '▾'; font-size: 10px; }

.cpop-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }

.cpop-row { display: flex; align-items: center; gap: 6px; }
.cpop-lbl { flex: 0 0 46px; font-size: 11px; color: #555; }

.cpop-nums { display: flex; gap: 3px; }
.cpop-num {
  width: 22px; height: 22px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  color: #333;
  font: 11px/1 inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}
.cpop-num:hover { background: #e8f0ff; border-color: var(--accent); }
.cpop-num.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.cpop-btn-primary {
  flex: 2;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font: 13px/1.4 inherit;
  font-weight: 600;
}
.cpop-btn-primary:hover { background: #0088e8; }
.cpop-btn-danger {
  padding: 5px 10px;
  background: #fff;
  color: #c03030;
  border: 1px solid #e05050;
  border-radius: 4px;
  cursor: pointer;
  font: 12px/1.4 inherit;
}
.cpop-btn-danger:hover { background: #fff0f0; }

/* ── Cell popover — dimensiones y material ─────────────────────── */

.cpop-section + .cpop-section { border-top: 1px solid #ddd; }

.cpop-dim-inp {
  width: 64px;
  padding: 2px 4px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font: 12px/1.4 inherit;
  text-align: right;
}
.cpop-dim-inp:focus { outline: none; border-color: var(--accent); }
.cpop-unit { font-size: 10px; color: #999; }

.cpop-color-inp {
  width: 28px; height: 22px;
  border: 1px solid #ccc; border-radius: 3px;
  padding: 1px; cursor: pointer;
  flex-shrink: 0;
}
.cpop-tex-sw {
  width: 28px; height: 22px;
  border: 1px solid #ccc; border-radius: 3px;
  background-size: cover; background-position: center;
  cursor: pointer; flex-shrink: 0;
  position: relative;
}
.cpop-tex-sw::after {
  content: '…';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: rgba(0,0,0,.4);
  background: rgba(255,255,255,.55);
  border-radius: 2px;
}
.cpop-tex-sw.has-tex::after { display: none; }

.cpop-tex-name {
  font-size: 10px;
  color: #bbb;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cpop-btn-eq {
  padding: 0 6px;
  height: 22px;
  background: #f0f0f0;
  color: #444;
  border: 1px solid #bbb;
  border-radius: 4px;
  cursor: pointer;
  font: 13px/1 inherit;
  flex-shrink: 0;
}
.cpop-btn-eq:hover { background: #e4e4e4; }

.cpop-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 4px 6px 4px;
  cursor: grab;
}
.cpop-grip {
  color: #666;
  font-size: 14px;
  padding-left: 2px;
  pointer-events: none;
}
.cpop-title {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #888;
  padding-left: 6px;
}

/* Footer con botones de acción */
.cpop-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px 8px;
  border-top: 1px solid #3a3a3a;
  margin-top: 2px;
}
/* Botones footer del popover — base compartida */
.cpop-footer button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid #555;
  background: #3a3a3a;
  color: #bbb;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.cpop-footer button svg {
  width: 17px;
  height: 17px;
  display: block;
  flex-shrink: 0;
}
.cpop-footer button:hover { background: #505050; color: #fff; }

.cpop-btn-open:hover  { color: #7ec8e3; }
.cpop-btn-save:hover  { color: #8ec07c; }
.cpop-btn-undo:hover  { color: #f0b060; }

.cpop-btn-add {
  background: #2a7a2a;
  border-color: #2a7a2a;
  color: #fff;
}
.cpop-btn-add:hover { background: #1e5c1e; color: #fff; }

.cpop-btn-props.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.cpop-btn-3d {
  width: auto;
  padding: 0 10px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font: 11px/1.6 inherit;
  font-weight: 600;
}
.cpop-btn-3d:hover { background: #0088e8; }
.cpop-btn-close {
  margin-left: auto;
  padding: 3px 7px;
  background: transparent;
  color: #aaa;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font: 13px/1.4 inherit;
}
.cpop-btn-close:hover { background: #c0392b; color: #fff; }

/* Panel de propiedades oculto por defecto */
#props-panel.props-hidden {
  display: none;
}
#props-panel.props-collapsed #props-content,
#props-panel.props-collapsed #props-resize-handle {
  display: none;
}
#props-panel.props-collapsed.floating {
  height: auto !important;
  resize: none;
  min-height: 0;
}

/* ── Cell popover — secciones colapsables ──────────────────────── */
.cpop-section-hdr { cursor: pointer; user-select: none; }
.cpop-section-hdr::before { content: '▾'; font-size: 10px; margin-right: 4px; display: inline-block; }
.cpop-section.collapsed .cpop-section-hdr::before { content: '▸'; }
.cpop-section.collapsed .cpop-body { display: none; }

/* ── Maqueta a escala ──────────────────────────────────────────── */
#dlg-maqueta { padding: 0; max-width: 820px; width: 95vw; border-radius: 10px; border: 1px solid #3a3a3d; background: #252527; color: #e0e0e0; display: flex; flex-direction: column; max-height: 92vh; margin: auto; }
#dlg-maqueta::backdrop { background: rgba(0,0,0,.6); }
.maq-inner { display: flex; flex-direction: column; min-height: 0; overflow: hidden; flex: 1; }
.maq-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #3a3a3d; flex-shrink: 0; }
.maq-title { font-weight: 700; font-size: 14px; }
.maq-body { overflow-y: auto; padding: 16px 18px; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.maq-footer { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid #3a3a3d; flex-shrink: 0; flex-wrap: wrap; }
#maq-3d-wrap { border-radius: 8px; overflow: hidden; background: #141416; border: 1px solid #3a3a3d; flex-shrink: 0; }
#maq-3d { width: 100%; height: 260px; display: block; }
.maq-section { display: flex; flex-direction: column; gap: 8px; }
.maq-section--half { flex: 1; }
.maq-row { display: flex; gap: 16px; }
.maq-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #888; }
.maq-label-sm { font-size: 11px; color: #888; white-space: nowrap; }
.maq-tabs { display: flex; gap: 6px; }
.maq-tab { padding: 6px 16px; border-radius: 6px; border: 1px solid #3a3a3d; background: transparent; color: #bbb; cursor: pointer; font: 12px/1 inherit; transition: all .15s; }
.maq-tab.active { background: #007acc; color: #fff; border-color: #007acc; }
.maq-scales { display: flex; gap: 6px; flex-wrap: wrap; }
.maq-scale-btn { padding: 5px 12px; border-radius: 6px; border: 1px solid #3a3a3d; background: transparent; color: #bbb; cursor: pointer; font: 12px/1 inherit; transition: all .15s; display: flex; align-items: center; }
.maq-scale-btn.active { background: #c49850; color: #111; border-color: #c49850; font-weight: 700; }
.maq-input { background: #1e1e20; border: 1px solid #3a3a3d; border-radius: 6px; color: #e0e0e0; padding: 5px 10px; font: 13px inherit; width: 80px; }
.maq-dims-box { background: #1e1e20; border: 1px solid #3a3a3d; border-radius: 8px; padding: 16px 20px; }
.maq-dims-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #888; margin-bottom: 12px; }
.maq-dims-values { display: flex; gap: 32px; margin-bottom: 10px; }
.maq-dim { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.maq-dim-num { font-size: 2rem; font-weight: 800; color: #c49850; line-height: 1; }
.maq-dim-unit { font-size: 11px; color: #888; }
.maq-dim-lbl { font-size: 12px; color: #bbb; margin-top: 2px; }
.maq-dims-note { font-size: 11px; color: #666; }
.maq-table-wrap { overflow-x: auto; max-height: 220px; overflow-y: auto; border: 1px solid #3a3a3d; border-radius: 6px; }
.maq-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.maq-table th { background: #2d2d30; padding: 6px 10px; text-align: left; font-weight: 600; color: #bbb; position: sticky; top: 0; }
.maq-table td { padding: 5px 10px; border-top: 1px solid #333; }
.maq-table tr:hover td { background: rgba(255,255,255,.03); }
.maq-boards-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.maq-boards-row .maq-input { width: 70px; }
.maq-btn-sec { background: #3a3a3d; border: 1px solid #555; border-radius: 6px; color: #e0e0e0; padding: 5px 12px; font: 12px inherit; cursor: pointer; }
.maq-btn-remove { background: transparent; border: none; color: #888; cursor: pointer; font-size: 14px; padding: 2px 6px; }
.maq-btn-remove:hover { color: #e74c3c; }
.maq-assembly { background: #1e1e20; border: 1px solid #3a3a3d; border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.maq-assembly-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.maq-asm-item { display: flex; gap: 10px; align-items: flex-start; font-size: 12px; color: #ccc; line-height: 1.4; }
.maq-asm-icon { font-size: 20px; flex-shrink: 0; }
.maq-footer .maq-btn-icon { margin-right: 4px; }
.maq-footer .maq-btn-text { white-space: nowrap; }
@media (max-width: 500px) { .maq-assembly-grid { grid-template-columns: 1fr; } .maq-row { flex-direction: column; } .maq-footer { padding: 10px 12px; gap: 6px; justify-content: center; } .maq-footer .btn-primary, .maq-footer .btn-secondary { flex: 0 0 auto; min-width: 0; font-size: 13px; padding: 8px 10px; text-align: center; } .maq-footer .maq-btn-icon { margin-right: 0; font-size: 16px; } .maq-footer .maq-btn-text { display: none; } }

/* ════════════════════════════════════════════════════════════════
   TEMA CLARO — overrides sobre el tema oscuro base
   ════════════════════════════════════════════════════════════════ */

/* Variables de chrome que usan var() */
[data-theme="light"] { --tb-bg: #e4e0d8; }

[data-theme="light"] body { background-color: #f0f0e8; }
/* #app transparente — el papel del body se ve a través */
[data-theme="light"] #app { background: transparent; }

/* ── Tab bar ── */
[data-theme="light"] #tab-bar { background: #e4e0d8; border-bottom-color: #c8c4bc; }
[data-theme="light"] .tab-item { background: #dedad2; color: #555; border-right-color: #c8c4bc; }
[data-theme="light"] .tab-item:hover { background: #cac6be; color: #222; }
[data-theme="light"] .tab-item.active { background: #f0f0e8; color: #111; }
[data-theme="light"] .tab-close:hover { background: rgba(0,0,0,.1); }
[data-theme="light"] .tab-add { color: #666; }
[data-theme="light"] .tab-add:hover { color: #111; background: #cac6be; }

/* ── Toolbar buttons ── */
[data-theme="light"] #btn-hamburger,
[data-theme="light"] #btn-3d { color: #444; }
[data-theme="light"] #btn-hamburger:hover,
[data-theme="light"] #btn-3d:hover { background: #cac6be; color: #111; }
[data-theme="light"] .tb-app-name { color: #333; }
[data-theme="light"] .tb-lbl { color: #666; }
[data-theme="light"] .tb-unit-toggle { background: #dedad2; color: #444; border-color: #b8b4ac; }
[data-theme="light"] .tb-unit-toggle:hover { background: #cac6be; color: #111; }
[data-theme="light"] .tb-unit-toggle:disabled { opacity: 0.35; }

/* ── Dropdown / Menubar ── */
[data-theme="light"] .tb-dropdown { background: #e8e4dc; border-color: #c4c0b8; }
[data-theme="light"] .mb-panel { background: #e8e4dc; border-color: #c4c0b8; }
[data-theme="light"] .tb-drop-sep { border-top-color: #c4c0b8; }
[data-theme="light"] .mb-group::before { color: #555; }
[data-theme="light"] .mb-trigger { color: #333; }
[data-theme="light"] .mb-trigger:hover,
[data-theme="light"] .mb-trigger:focus-visible,
[data-theme="light"] .mb-group.mb-open .mb-trigger { background: #cac6be; color: #111; }
[data-theme="light"] .mb-panel button,
[data-theme="light"] .mb-panel .tb-drop-link { color: #333; }
[data-theme="light"] .mb-panel button:hover,
[data-theme="light"] .mb-panel .tb-drop-link:hover { background: #cac6be; color: #111; }

/* ── Mobile tabbar ── */
[data-theme="light"] #mobile-tabbar { border-top-color: #c8c4bc; }
[data-theme="light"] .mobile-tab { color: #555; }
[data-theme="light"] .mobile-tab:hover { color: #222; background: rgba(0,0,0,.06); }
[data-theme="light"] .mobile-tab:active { background: rgba(0,0,0,.1); }

/* ── Paneles oscuros: cutplan / cutlist / optimizer ── */
[data-theme="light"] #cutplan-panel,
[data-theme="light"] #cutlist-panel { background: #fafaf6; color: #333; }
[data-theme="light"] #opt-topbar,
[data-theme="light"] #opt-topbar2 { background: #eceae4; border-bottom-color: #d4d0c8; color: #444; }
[data-theme="light"] #opt-body { color: #333; }
[data-theme="light"] #opt-body input[type="number"],
[data-theme="light"] #opt-body input[type="text"] { background: #fff; color: #333; border-color: #bbb; }
[data-theme="light"] #opt-body label { color: #333; }
[data-theme="light"] #opt-results { border-top-color: #d4d0c8; }
[data-theme="light"] .opt-config-label { color: #666; }
[data-theme="light"] .opt-group-row { border-color: #d4d0c8; background: #eceae4; }
[data-theme="light"] .opt-group-title { color: #333; }
[data-theme="light"] .opt-group-fields input,
[data-theme="light"] .opt-group-fields select { background: #fff; color: #333; border-color: #bbb; }
[data-theme="light"] .opt-result-group-header { color: #333; background: #eceae4; }
[data-theme="light"] .opt-board-lbl { color: #555; }

/* ── Tablas en paneles oscuros ── */
[data-theme="light"] .cl-table { color: #333; }
[data-theme="light"] .cl-table th { background: #eceae4; border-bottom-color: #d4d0c8; color: #444; }
[data-theme="light"] .cl-table td { border-bottom-color: #e4e2dc; }
[data-theme="light"] .cl-table .cl-group { background: #e4e2dc; color: #334; }
[data-theme="light"] .hs-section { border-top-color: #d4d0c8; }
[data-theme="light"] .hs-title { color: #556; }
[data-theme="light"] .hs-group-label { color: #444; }
[data-theme="light"] .hs-hint { color: #999; }
[data-theme="light"] .hs-card { background: #f0efe8; border-color: #d4d0c8; }
[data-theme="light"] .hs-card:hover { border-color: #b0a898; }
[data-theme="light"] .hs-img,
[data-theme="light"] .hs-no-img { background: #e4e2dc; }
[data-theme="light"] .hs-name { color: #333; }
[data-theme="light"] .hs-price { color: #b06000; }

/* ── Panel proyectos externos ── */
[data-theme="light"] #ext-panel { background: #fafaf6; }
[data-theme="light"] .ext-cat-section { color: #666; }
[data-theme="light"] .ext-card { background: #f0ece4; border-color: #d4d0c8; }
[data-theme="light"] .ext-card-title { color: #222; }
[data-theme="light"] .ext-card-desc { color: #666; }
[data-theme="light"] .ext-card-tag { background: #dce8f8; color: #1a5c9c; }
[data-theme="light"] #ext-project-bar { background: #eceae4; border-bottom-color: #d4d0c8; }
[data-theme="light"] #btn-ext-back-catalog { border-color: #bbb; color: #555; }
[data-theme="light"] #btn-ext-back-catalog:hover { background: #d8d4cc; color: #222; }
[data-theme="light"] #ext-project-label { color: #333; }

/* ── Menú contextual ── */
[data-theme="light"] #ctx-menu { background: #f0ece4; border-color: #c4c0b8; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
[data-theme="light"] .ctx-item { color: #222; border-bottom-color: #e0dcd4; }
[data-theme="light"] .ctx-sep { background: #d4d0c8; }
[data-theme="light"] .ctx-label { color: #888; }
[data-theme="light"] .ctx-item--active { color: var(--accent); }
[data-theme="light"] .ctx-item--danger { color: #c00; }

/* ── Cabeceras de diálogos ── */
[data-theme="light"] .dlg-header { background: #e4e0d8; color: #222; }
[data-theme="light"] .dlg-furn-header { border-bottom-color: #c4c0b8; }
[data-theme="light"] .dlg-furn-title { color: #222; }
[data-theme="light"] .modal-hdr { background: #e4e0d8; color: #222; }
[data-theme="light"] .modal-close,
[data-theme="light"] .modal-refresh { color: #666; }
[data-theme="light"] .modal-close:hover,
[data-theme="light"] .modal-refresh:hover { color: #111; }
[data-theme="light"] .modal-sync { border-color: #bbb; color: var(--accent); }

/* ── Galería de tipos de mueble ── */
[data-theme="light"] #dlg-furn-gallery { background: #f0ece4; }
[data-theme="light"] #furn-gallery-grid { background: #f0ece4; }
[data-theme="light"] .furn-preset-card { background: #e8e4dc; border-color: #c8c4bc; color: #555; }
[data-theme="light"] .furn-preset-card:hover { border-color: var(--accent); background: #dce8f8; color: #222; }
[data-theme="light"] .furn-preset-name { color: #333; }
[data-theme="light"] .furn-preset-dims { color: #888; }
[data-theme="light"] .furn-gallery-back { color: #666; border-bottom-color: #d0ccc4; }
[data-theme="light"] .furn-gallery-back:hover { color: var(--accent); }
[data-theme="light"] .furn-preset-empty-btn { color: #666; border-color: #c8c4bc; }

/* ── Galería cloud ── */
[data-theme="light"] .cloud-gallery { background: #f0ece4; }
[data-theme="light"] .cloud-card { background: #e8e4dc; }
[data-theme="light"] .cloud-card-name { color: #333; }
[data-theme="light"] .cloud-card-date { color: #888; }

/* ── Botones de mueble en propiedades (dark en panel claro) ── */
[data-theme="light"] .prop-furn-btn { background: #e8e4dc; border-color: #b8b4ac; color: #444; }

/* ── Popover footer (botones dark) ── */
[data-theme="light"] .cpop-footer { border-top-color: #d4d0c8; }
[data-theme="light"] .cpop-footer button { background: #e8e4dc; border-color: #c4c0b8; color: #555; }
[data-theme="light"] .cpop-footer button:hover { background: #d4d0c8; color: #111; }

/* ── Maqueta dialog ── */
[data-theme="light"] #dlg-maqueta { background: #f0ece4; border-color: #c8c4bc; color: #333; }
[data-theme="light"] .maq-header { border-bottom-color: #c8c4bc; }
[data-theme="light"] .maq-footer { border-top-color: #c8c4bc; }
[data-theme="light"] .maq-label,
[data-theme="light"] .maq-label-sm { color: #666; }
[data-theme="light"] .maq-tab { border-color: #c8c4bc; color: #555; }
[data-theme="light"] .maq-scale-btn { border-color: #c8c4bc; color: #555; }
[data-theme="light"] .maq-input { background: #fff; border-color: #c8c4bc; color: #333; }
[data-theme="light"] .maq-dims-box { background: #e8e4dc; border-color: #c8c4bc; }
[data-theme="light"] .maq-dims-note { color: #777; }
[data-theme="light"] .maq-table-wrap { border-color: #c8c4bc; }
[data-theme="light"] .maq-table th { background: #e4e0d8; color: #444; }
[data-theme="light"] .maq-table td { border-top-color: #e0dcd4; }
[data-theme="light"] .maq-btn-sec { background: #e8e4dc; border-color: #c8c4bc; color: #333; }
[data-theme="light"] .maq-assembly { background: #e8e4dc; border-color: #c8c4bc; }
[data-theme="light"] .maq-asm-item { color: #444; }

/* ── No me cabe dialog ── */
#dlg-resize-fit {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%); margin: 0;
}
.resize-fit-current {
  font-size: 13px; font-weight: 700; color: var(--accent);
  margin: 0 0 12px; letter-spacing: .3px;
}
.rsz-lock-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #bbb; margin-bottom: 14px; cursor: pointer;
}
.rsz-lock-label input { accent-color: var(--accent); }
.rsz-grid {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 8px 10px; align-items: center;
}
.rsz-grid label { font-size: 12px; color: #ccc; }
.rsz-grid input[type="number"] {
  width: 100%; padding: 5px 8px; border-radius: 4px;
  border: 1px solid #555; background: #2a2a2d; color: #eee;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.rsz-unit { font-size: 11px; color: #888; }
.rsz-fixed { font-size: 11px; color: #888; margin: 14px 0 4px; }
[data-theme="light"] .rsz-grid label { color: #444; }
[data-theme="light"] .rsz-grid input[type="number"] { background: #fff; border-color: #ccc; color: #222; }
[data-theme="light"] .rsz-lock-label { color: #555; }
[data-theme="light"] .rsz-fixed { color: #666; }

/* ── PWA banner ── */
[data-theme="light"] #pwa-install-banner { background: #e4e0d8; color: #333; box-shadow: 0 -2px 12px rgba(0,0,0,.12); }

/* ── Canvas en modo claro — papel milimetrado cálido ── */
[data-theme="light"] #canvas-area {
  background-color: #f0f0e8;
}

/* ── Texto del empty-state en modo claro ── */
[data-theme="light"] .empty-state-title { color: #2a3048; }
[data-theme="light"] .empty-state-desc  { color: #5a6080; }
[data-theme="light"] .empty-state-icon  { color: #8090b8; }
[data-theme="light"] .empty-state-link  { color: #5a6080; }
[data-theme="light"] .empty-state-hint  { color: #8090b8; }
[data-theme="light"] .empty-state-close { color: #aaa; }
[data-theme="light"] .empty-state-close:hover { background: rgba(0,0,0,.07); color: #555; }

/* ════════════════════════════════════════════════════════════════
   SUBMENÚ DESPLEGABLE
   ════════════════════════════════════════════════════════════════ */

/* ── Etiqueta de sección en menú desplegable ──────────────────── */
.tb-drop-label {
  display: block; padding: 6px 14px 3px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  color: #888; text-transform: uppercase; pointer-events: none;
}
[data-theme="light"] .tb-drop-label { color: #999; }

/* ── Submenú flotante ─────────────────────────────────────────── */
.tb-has-submenu { position: relative; }
.tb-submenu-toggle {
  display: flex !important; align-items: center; justify-content: space-between;
  width: 100%;
}
.tb-submenu-arrow { opacity: .6; }
.tb-submenu {
  position: absolute;
  top: 0; left: 100%;
  display: flex; flex-direction: column;
  background: #2d2d30;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 0;
  min-width: 190px;
  box-shadow: 4px 6px 18px rgba(0,0,0,.55);
  z-index: 200;
}
.tb-submenu[hidden] { display: none; }
.tb-submenu button {
  padding: 7px 14px; border: none; border-radius: 3px;
  background: transparent; color: #ccc; cursor: pointer; font: inherit; font-size: 13px;
  white-space: nowrap; text-align: left; width: 100%;
}
.tb-submenu button:hover  { background: #4a4a4d; color: #fff; }
.tb-submenu button:active { background: var(--accent); color: #fff; }
[data-theme="light"] .tb-submenu {
  background: #e8e4dc; border-color: #c4c0b8;
}
[data-theme="light"] .tb-submenu button { color: #333; }
[data-theme="light"] .tb-submenu button:hover { background: #cac6be; color: #111; }

/* ── Diálogo de confirmación genérico ─────────────────────────── */
#dlg-confirm {
  display: none; border: none; border-radius: 14px; padding: 0;
  background: #2d2d30; color: #ccc; box-shadow: 0 8px 48px rgba(0,0,0,.55);
  width: min(96vw, 400px);
}
#dlg-confirm[open] {
  display: flex; flex-direction: column;
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%); margin: 0;
}
#dlg-confirm::backdrop { background: rgba(0,0,0,.55); }
[data-theme="light"] #dlg-confirm { background: #f0ece4; color: #222; box-shadow: 0 8px 48px rgba(0,0,0,.22); }
.dlg-confirm-hdr {
  display: flex; align-items: center; gap: 10px;
  background: #252527; border-bottom: 1px solid #3a3a3d;
  padding: 12px 16px; flex-shrink: 0;
}
[data-theme="light"] .dlg-confirm-hdr { background: #e4e0d8; border-bottom-color: #c8c4bc; }
.dlg-confirm-htitle { flex: 1; font-size: 14px; font-weight: 700; color: #ddd; }
[data-theme="light"] .dlg-confirm-htitle { color: #222; }
.dlg-confirm-x {
  background: none; border: none; color: #888; cursor: pointer;
  font-size: 16px; padding: 0 4px; line-height: 1;
}
.dlg-confirm-x:hover { color: #ddd; }
[data-theme="light"] .dlg-confirm-x:hover { color: #111; }
.dlg-confirm-body { padding: 20px; font-size: 13px; line-height: 1.6; }
.dlg-confirm-body p { margin: 0; }
.dlg-confirm-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid #3a3a3d; flex-shrink: 0;
  background: #252527;
}
[data-theme="light"] .dlg-confirm-footer { background: #e4e0d8; border-top-color: #c8c4bc; }
.dlg-confirm-footer button {
  padding: 7px 18px; border-radius: 6px; border: 1px solid #555; font-size: 13px;
  background: #3a3a3d; color: #ccc; cursor: pointer; font-family: inherit;
}
.dlg-confirm-footer button:hover { background: #484848; color: #fff; }
[data-theme="light"] .dlg-confirm-footer button { background: #dedad2; border-color: #bbb; color: #333; }
[data-theme="light"] .dlg-confirm-footer button:hover { background: #cac6be; }
.dlg-confirm-danger { background: #c0392b !important; border-color: #c0392b !important; color: #fff !important; }
.dlg-confirm-danger:hover { filter: brightness(1.15); }

/* ── Estado vacío: tarjeta centrada sobre papel milimetrado ── */
[data-theme="light"] #canvas-empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(90%, 420px);
  height: auto;
  background: #fff;
  border-radius: 20px;
  padding: 40px 48px;
  box-shadow: 0 4px 32px rgba(0,0,0,.12);
  border: 1px solid rgba(80,110,160,.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

/* ── Modo embed (iframe desde landing.html) ─────────────────────── */
.embed-mode #toolbar,
.embed-mode #tab-bar,
.embed-mode #mobile-tabbar,
.embed-mode #pwa-install-banner { display: none !important; }
.embed-mode .props-header-btns,
.embed-mode #btn-props-close,
.embed-mode #props-actions-bar { display: none !important; }
/* En embed, mostrar solo Encimera + Despiece + Plano en prop-furn-actions */
.embed-mode .prop-furn-actions .prop-furn-btn:not(.prop-furn-btn--tabletop):not(.prop-furn-btn--cutlist):not(.prop-furn-btn--cutplan) { display: none !important; }
.embed-mode #empty-state-open,
.embed-mode .empty-state-hint { display: none !important; }

/* En embed, dejar espacio al final del panel para no tapar con los botones flotantes */
.embed-mode #props-content { padding-bottom: 68px; }

/* Barra flotante embed (3D + abrir app) */
#embed-cta-bar {
  display: none;
  position: fixed; bottom: 16px; right: 16px; z-index: 9000;
  align-items: center; gap: 8px;
}
.embed-mode #embed-cta-bar { display: flex !important; }

#embed-3d-btn {
  background: #2d2d30; color: #fff; font-weight: 700; font-size: 13px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid rgba(255,255,255,.15);
  cursor: pointer; transition: background .2s, box-shadow .2s; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
#embed-3d-btn:hover { background: #3e3e42; box-shadow: 0 4px 14px rgba(0,0,0,.45); }

#embed-open-btn {
  background: linear-gradient(135deg, #007acc, #0090ee);
  color: #fff !important; font-weight: 700; font-size: 13px;
  padding: 10px 18px; border-radius: 8px;
  text-decoration: none !important; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 16px rgba(0,122,204,.45);
  border: none; cursor: pointer; transition: transform .2s, box-shadow .2s;
  white-space: nowrap;
}
#embed-open-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,122,204,.6);
}

/* ── Modo nosave (desde landing móvil) ──────────────────────────── */
.nosave-mode #btn-save,
.nosave-mode #btn-save-as,
.nosave-mode #pab-btn-save,
.nosave-mode #pab-btn-save-as { display: none !important; }

/* Admin viendo el mueble de otro usuario: oculta Guardar (deja Guardar como). */
.admin-readonly-mode #btn-save,
.admin-readonly-mode #pab-btn-save,
.admin-readonly-mode #btn-save-preset { display: none !important; }

/* Banner amarillo de solo lectura — pegado a la barra superior del editor. */
#admin-readonly-banner {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(180deg, #fde68a 0%, #f59e0b 100%);
  color: #1f1300; font: 600 13px/1.2 'Segoe UI', system-ui, sans-serif;
  border-bottom: 1px solid #b45309;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
#admin-readonly-banner a {
  color: #1f1300; text-decoration: underline; font-weight: 600;
}
#admin-readonly-banner .pill {
  background: rgba(0,0,0,.18); color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; letter-spacing: .04em;
}

/* ── Dialog: Disclaimer ─────────────────────────────────────────── */
#dlg-disclaimer {
  max-width: 520px;
  width: 92vw;
  border: none;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  background: var(--bg-panel, #fff);
  color: var(--text, #1a1a1a);
}
#dlg-disclaimer::backdrop {
  background: rgba(0,0,0,.65);
}
.disclaimer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border, #d0d0d0);
}
.disclaimer-header-icon {
  font-size: 22px;
  line-height: 1;
}
.disclaimer-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.disclaimer-body {
  padding: 16px 18px;
  font-size: 13.5px;
  line-height: 1.6;
}
.disclaimer-body p { margin: 0 0 10px; }
.disclaimer-body p:last-child { margin-bottom: 0; }
.disclaimer-body ul {
  margin: 6px 0 10px 18px;
  padding: 0;
}
.disclaimer-body ul li { margin-bottom: 4px; }
.disclaimer-warning {
  background: #fff3cd;
  color: #7a5800;
  border-left: 4px solid #f0a500;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 12px;
}
[data-theme="dark"] .disclaimer-warning {
  background: #3a2e00;
  color: #ffd966;
  border-left-color: #f0a500;
}
.disclaimer-footer {
  padding: 12px 18px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border, #d0d0d0);
}
#btn-disclaimer-accept {
  background: #007acc;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#btn-disclaimer-accept:hover { background: #0090ee; }
#btn-disclaimer-info {
  background: none;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text, #333);
}
#btn-disclaimer-info:hover { background: var(--bg-hover, #f0f0f0); }

/* ══════════════════════════════════════════════════════════════════
   UNDO / REDO — feedback visual
   ══════════════════════════════════════════════════════════════════ */

/* Botones deshabilitados */
.mb-panel button:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Badge contador */
.undo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  font-size: 10px; font-weight: 700; line-height: 1;
  color: #fff; background: var(--accent, #0078d4); border-radius: 8px;
  margin-left: 6px; vertical-align: middle;
}

/* Toast */
#undo-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 8px 18px; border-radius: 6px;
  background: rgba(30,30,30,.88); color: #eee;
  font-size: 13px; pointer-events: none;
  opacity: 0; transition: opacity .25s ease;
  z-index: 9999;
}
#undo-toast.undo-toast-show { opacity: 1; }
#undo-toast.undo-toast-hide { opacity: 0; }
[data-theme="light"] #undo-toast { background: rgba(50,50,50,.85); color: #fff; }

/* ── Auth UI ────────────────────────────────────────────────────────────────── */
.tb-auth-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 3px 12px; font-size: 12px; font-family: inherit; cursor: pointer;
  font-weight: 600; margin-left: 6px;
}
.tb-auth-btn:hover { filter: brightness(1.15); }

.tb-user-avatar {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  margin-left: 6px; font-family: inherit;
  overflow: hidden; padding: 0;
}
.tb-user-avatar:hover { filter: brightness(1.15); }
.tb-user-avatar > img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 50%;
}

#user-menu { position: relative; display: inline-flex; }
.user-dropdown {
  position: absolute; top: 34px; right: 0; min-width: 160px;
  background: #2d2d30; border: 1px solid #444; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 10050;
  padding: 6px 0; font-size: 13px;
}
[data-theme="light"] .user-dropdown { background: #f0ece4; border-color: #c8c4bc; }
.user-dd-name {
  padding: 8px 14px; font-weight: 700; color: #eee; border-bottom: 1px solid #444;
  font-size: 13px;
}
[data-theme="light"] .user-dd-name { color: #222; border-bottom-color: #c8c4bc; }
.user-dd-item {
  display: block; width: 100%; padding: 8px 14px; border: none; background: none;
  color: #ccc; text-align: left; cursor: pointer; font-family: inherit; font-size: 13px;
  text-decoration: none;
  box-sizing: border-box;
}
.user-dd-item:hover { background: #3a3a3d; color: #fff; }
[data-theme="light"] .user-dd-item { color: #333; }
[data-theme="light"] .user-dd-item:hover { background: #dedad2; }

/* Auth dialog */
#dlg-auth {
  background: #1e1e2e; border: 1px solid #444; border-radius: 12px;
  padding: 0; width: min(380px, 92vw); color: #eee;
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  margin: 0;
}
#dlg-auth::backdrop { background: rgba(0,0,0,.6); }
[data-theme="light"] #dlg-auth { background: #f0ece4; border-color: #c8c4bc; color: #222; }

.auth-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 0;
}
.auth-tabs { display: flex; gap: 4px; }
.auth-tab {
  background: none; border: none; color: #888; font-size: 14px; font-weight: 600;
  cursor: pointer; padding: 6px 12px; border-radius: 6px; font-family: inherit;
}
.auth-tab.active { color: #fff; background: var(--accent); }
.auth-tab:hover:not(.active) { color: #ccc; }
[data-theme="light"] .auth-tab { color: #888; }
[data-theme="light"] .auth-tab.active { color: #fff; }
.auth-x {
  background: none; border: none; color: #888; font-size: 18px; cursor: pointer;
  padding: 2px 6px;
}
.auth-x:hover { color: #fff; }

.auth-form {
  display: flex; flex-direction: column; gap: 10px; padding: 18px;
}
.auth-form input {
  padding: 10px 12px; border-radius: 8px; border: 1px solid #444;
  background: #2a2a3a; color: #eee; font-size: 14px; font-family: inherit;
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
[data-theme="light"] .auth-form input { background: #e4e0d8; border-color: #c0bcb4; color: #222; }
[data-theme="light"] .auth-form input:focus { border-color: var(--accent); }

.auth-submit {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px; font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: inherit; margin-top: 4px;
}
.auth-submit:hover { filter: brightness(1.1); }

.auth-pwd-wrap {
  position: relative; display: flex;
}
.auth-pwd-wrap input { flex: 1; padding-right: 38px; }
.auth-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px;
  padding: 2px; opacity: .5; line-height: 1;
}
.auth-eye:hover { opacity: 1; }

.auth-remember {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: #999; cursor: pointer;
}
.auth-remember input { accent-color: var(--accent); }
[data-theme="light"] .auth-remember { color: #666; }

.auth-link {
  font-size: 12px; color: var(--accent); text-align: center; text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

.auth-hint {
  font-size: 13px; color: #999; margin: 0; line-height: 1.4;
}
[data-theme="light"] .auth-hint { color: #666; }

.auth-ok {
  color: #5a5; font-size: 13px; padding: 0 18px 14px; text-align: center;
}

.auth-error {
  color: #e55; font-size: 12px; padding: 0 18px 14px; text-align: center;
}

/* ── Tablet táctil (iPad, Surface, etc.) ──────────────────────────
   Pantallas anchas pero con pointer grueso: subir fuentes base y
   darkened colors en etiquetas pequeñas para que sean legibles. */
@media (pointer: coarse) and (min-width: 769px) {
  html, body { font-size: 15px; }
  #toolbar { font-size: 14px; }
  .mb-trigger, .mb-panel button, .tb-submenu button { font-size: 14px; padding: 8px 12px; }
  .cell-label { font-size: 13px; color: #444; }
  .cell-dims  { font-size: 12px; color: #333; }
  .dim-label  { font-size: 11px; }
  .tabletop-label { font-size: 12px; color: rgba(0,0,0,0.75); }
  .board-name { font-size: 13px; }
  .board-vendor, .board-meta { font-size: 11px; }
}

/* Zonas arrastrables con el dedo: bloquear gestos nativos del navegador
   para que pointer events gestionen el drag sin competir con el scroll. */
.cell, .appliance-block, .furn-submodule, .furn-sidemodule, .furn-container { touch-action: none; }

/* ── Panel MFL flotante ───────────────────────────────────────────── */

/* ── Consola flotante MFL — look terminal ──────────────────────── */
.mfl-term {
  position: fixed;
  z-index: 600;
  /* Posición por defecto: esquina inferior-derecha, no a pantalla completa */
  bottom: 80px; right: 20px;
  width: min(560px, calc(100vw - 32px));
  height: min(420px, calc(100vh - 200px));
  background: #0e0e10;
  color: #d4d4d4;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.25);
  font: 13px/1.45 'Consolas', 'Menlo', 'Liberation Mono', monospace;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.mfl-term.mfl-panel--open { display: flex; }
.mfl-term.mfl-panel--free:not(.mfl-panel--open) { display: none; }

@media (max-width: 700px) {
  .mfl-term { left: 8px; right: 8px; bottom: 8px; width: auto; height: 60vh; }
}

.mfl-term-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: #1a1a1f;
  border-bottom: 1px solid #2a2a2e;
  user-select: none;
}
.mfl-term-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ff5f57;
  flex-shrink: 0;
}
.mfl-term-dot--y { background: #febc2e; }
.mfl-term-dot--g { background: #28c840; }
.mfl-term-title {
  font-size: 11px; color: #8a8a8a; text-transform: uppercase; letter-spacing: .08em;
  margin-left: 6px;
}
.mfl-term-close {
  margin-left: auto;
  background: transparent; border: none; cursor: pointer;
  color: #6a6a6a; font-size: 14px;
  padding: 0 6px;
}
.mfl-term-close:hover { color: #e55; }

.mfl-term-out {
  flex: 1; min-height: 0;
  margin: 0; padding: 8px 10px;
  background: transparent;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: inherit;
  font: inherit;
}
.mfl-term-out:focus { outline: none; }
.mfl-term-out::-webkit-scrollbar { width: 8px; }
.mfl-term-out::-webkit-scrollbar-thumb { background: #2a2a2e; border-radius: 4px; }
.mfl-term-out::-webkit-scrollbar-thumb:hover { background: #3a3a3e; }

/* Tipos de líneas en el flujo */
.mfl-term-line          { color: #d4d4d4; }
.mfl-term-line--in      { color: #e0e0e0; }
.mfl-term-line--out     { color: #aedb8b; }     /* verde claro: resultado */
.mfl-term-line--err     { color: #ff8a8a; }     /* rojo */
.mfl-term-line--ok      { color: #8ad6c8; }     /* turquesa: confirmación */
.mfl-term-line--sys     { color: #6a6a6a; font-style: italic; }

.mfl-term-prompt {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 6px 10px;
  border-top: 1px solid #2a2a2e;
  background: #131316;
}
.mfl-term-caret {
  color: #6cb6ff;
  font-weight: 700;
  padding-top: 2px;
  user-select: none;
}
.mfl-term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f0f0f0;
  font: inherit;
  resize: none;
  min-height: 18px;
  max-height: 160px;
  padding: 2px 0;
}
.mfl-term-run {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: 30px; height: 26px;
  font-size: 12px;
  flex-shrink: 0;
}
.mfl-term-run:hover { background: #1d4ed8; }
.mfl-term-run:active { transform: scale(.96); }

/* Rueda lateral de navegación de historial (sólo móvil) */
.mfl-term-wheel {
  display: none;
  width: 32px;
  background: rgba(255,255,255,.04);
  border-left: 1px solid #2a2a2e;
  color: #6a6a8a;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
}
.mfl-term-wheel:active { background: rgba(255,255,255,.1); color: #c0c0d8; }

/* ── Modo móvil: panel reducido a 3 líneas, input + rueda ───── */
@media (max-width: 768px) {
  .mfl-term {
    bottom: env(safe-area-inset-bottom, 0) !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;       /* lo dicta el contenido del input */
    border-radius: 12px 12px 0 0;
    transform: none !important;
  }
  .mfl-term .mfl-term-out { display: none; }
  .mfl-term .mfl-term-caret { display: none; }
  .mfl-term .mfl-term-prompt {
    align-items: stretch;
    gap: 0;
    padding: 6px 6px 8px;
  }
  .mfl-term .mfl-term-input {
    width: 100%;
    /* 3 líneas: 14 px × 1.4 line-height × 3 + 12 px padding ≈ 70 px */
    height: calc(14px * 1.4 * 3 + 12px);
    max-height: calc(14px * 1.4 * 3 + 12px);
    min-height: calc(14px * 1.4 * 3 + 12px);
    font-size: 14px;
    line-height: 1.4;
    padding: 6px 8px;
    background: #1a1a20;
    border-radius: 4px 0 0 4px;
    resize: none;
  }
  .mfl-term .mfl-term-wheel { display: flex; }
  .mfl-term .mfl-term-run {
    width: 40px; height: auto;
    border-radius: 0 4px 4px 0;
    margin-left: -1px;
  }
  .mfl-term .mfl-term-resize { display: none; }
}

/* Handle de redimensionado: pequeño triángulo en la esquina inf. dcha */
.mfl-term-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 18px; height: 18px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg,
      transparent 0%, transparent 50%,
      #6a6a6a 50%, #6a6a6a 60%,
      transparent 60%, transparent 70%,
      #6a6a6a 70%, #6a6a6a 80%,
      transparent 80%);
  opacity: .55;
  z-index: 10;
}
.mfl-term-resize:hover { opacity: 1; }

/* ── Panel MFL clásico (mantenido por si algún flow viejo lo usa) ── */
.mfl-panel:not(.mfl-term) {
  position: fixed;
  top: 40px;
  right: 0;
  width: 420px;
  height: calc(100% - 40px);
  background: #1e1e1e;
  border-left: 1px solid #3a3a3d;
  display: flex;
  flex-direction: column;
  z-index: 600;
  transform: translateX(100%);
  transition: transform .22s ease;
  font-size: 13px;
}
.mfl-panel--open { transform: translateX(0); }

/* Cuando el usuario lo arrastra, deja de usar transform/animación.
   Si está movido pero cerrado → ocultar con display:none. */
.mfl-panel--free { transform: none !important; transition: none !important; }
.mfl-panel--free:not(.mfl-panel--open) { display: none; }

[data-theme="light"] .mfl-panel {
  background: #f8f8f8;
  border-left-color: #d0d0d0;
}

/* Header */
.mfl-panel-header {
  display: flex;
  align-items: center;
  background: #252527;
  border-bottom: 1px solid #3a3a3d;
  flex-shrink: 0;
}
[data-theme="light"] .mfl-panel-header {
  background: #ebebeb;
  border-bottom-color: #ccc;
}

.mfl-panel-tabs { display: flex; flex: 1; }

.mfl-panel-title {
  flex: 1; padding: 0 16px;
  font-size: 13px; font-weight: 600; color: #ddd;
  display: flex; align-items: center;
}
[data-theme="light"] .mfl-panel-title { color: #1a1a2e; }

.mfl-tab {
  padding: 0 16px;
  height: 36px;
  border: none;
  background: none;
  color: #999;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.mfl-tab:hover       { color: #ccc; }
.mfl-tab.active      { color: #e0e0e0; border-bottom-color: var(--accent); }
[data-theme="light"] .mfl-tab         { color: #777; }
[data-theme="light"] .mfl-tab:hover   { color: #333; }
[data-theme="light"] .mfl-tab.active  { color: #222; }

.mfl-panel-close {
  width: 36px; height: 36px;
  border: none; background: none;
  color: #888; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s;
}
.mfl-panel-close:hover { color: #e55; }

/* Body */
.mfl-panel-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.mfl-pane          { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.mfl-pane--hidden  { display: none !important; }

/* ── Consola ──────────────────────────────────────────────────── */

.mfl-console-hint {
  padding: 8px 12px;
  font-size: 11.5px;
  color: #777;
  border-bottom: 1px solid #333;
  line-height: 1.6;
}
.mfl-console-hint code {
  background: #2d2d30; color: #9cdcfe;
  padding: 1px 5px; border-radius: 3px; font-size: 11px;
}
.mfl-console-hint kbd {
  background: #333; color: #ccc;
  padding: 1px 5px; border-radius: 3px; font-size: 11px;
  border: 1px solid #555;
}
[data-theme="light"] .mfl-console-hint { color: #666; border-bottom-color: #ddd; }
[data-theme="light"] .mfl-console-hint code { background: #e8e8e8; color: #0070c1; }
[data-theme="light"] .mfl-console-hint kbd  { background: #eee; color: #444; border-color: #bbb; }

.mfl-console-history {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mfl-history-entry {
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
}
.mfl-history-ok    { background: rgba(80,180,80,.12); border-left: 3px solid #5a5; }
.mfl-history-query { background: rgba(80,140,220,.12); border-left: 3px solid #6aa; }
.mfl-history-error {
  background: rgba(220,60,60,.16);
  border-left: 3px solid #e55;
  animation: mfl-flash 0.45s ease-out;
}
@keyframes mfl-flash {
  0%   { background: rgba(220,60,60,.45); }
  100% { background: rgba(220,60,60,.16); }
}

.mfl-history-cmd {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  white-space: pre-wrap; word-break: break-all;
  color: #9cdcfe; font-size: 12px; margin: 0;
}
.mfl-history-ok    .mfl-history-cmd { color: #b5e28c; }
.mfl-history-error .mfl-history-cmd { color: #f78c8c; }
[data-theme="light"] .mfl-history-cmd { color: #0070c1; }

.mfl-history-detail {
  font-size: 11px; color: #888; margin-top: 3px;
  white-space: pre-wrap; word-break: break-all;
}
.mfl-history-error .mfl-history-detail { color: #e88; }
[data-theme="light"] .mfl-history-detail { color: #999; }

.mfl-console-input-wrap {
  display: flex;
  flex-direction: column;
  border-top: 1px solid #333;
  padding: 6px 8px 8px;
  gap: 6px;
}
[data-theme="light"] .mfl-console-input-wrap { border-top-color: #ddd; }

.mfl-console-input {
  width: 100%;
  background: #2d2d30;
  border: 1px solid #444;
  border-radius: 4px;
  color: #d4d4d4;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  padding: 7px 9px;
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}
.mfl-console-input:focus { outline: none; border-color: var(--accent); }
[data-theme="light"] .mfl-console-input {
  background: #fff; border-color: #bbb; color: #222;
}

.mfl-run-btn {
  align-self: flex-end;
  padding: 5px 14px;
  background: var(--accent);
  border: none; border-radius: 4px;
  color: #fff; cursor: pointer; font-size: 12px;
  transition: opacity .15s;
}
.mfl-run-btn:hover { opacity: .85; }

/* ── Editor MFL completo ──────────────────────────────────────── */

.mfl-editor-toolbar {
  display: flex;
  gap: 6px;
  padding: 7px 8px;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}
[data-theme="light"] .mfl-editor-toolbar { border-bottom-color: #ddd; }

.mfl-editor-toolbar button {
  padding: 4px 12px;
  background: #333;
  border: 1px solid #444; border-radius: 4px;
  color: #ccc; cursor: pointer; font-size: 12px;
  transition: background .15s;
}
.mfl-editor-toolbar button:hover { background: #3e3e42; }
[data-theme="light"] .mfl-editor-toolbar button {
  background: #eee; border-color: #bbb; color: #444;
}
[data-theme="light"] .mfl-editor-toolbar button:hover { background: #ddd; }

.mfl-apply-btn {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
.mfl-apply-btn:hover { opacity: .85; }

.mfl-editor-errors {
  display: none;
  background: rgba(220,60,60,.12);
  border-bottom: 1px solid rgba(220,60,60,.3);
  color: #f78c8c;
  font-size: 12px;
  padding: 7px 10px;
  white-space: pre-wrap;
  word-break: break-all;
  flex-shrink: 0;
  max-height: 120px;
  overflow-y: auto;
}
[data-theme="light"] .mfl-editor-errors { color: #c00; background: rgba(220,0,0,.07); }

.mfl-editor-area {
  flex: 1;
  width: 100%;
  background: #1e1e1e;
  border: none;
  color: #d4d4d4;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  padding: 10px 12px;
  resize: none;
  line-height: 1.7;
}
.mfl-editor-area:focus { outline: none; }
[data-theme="light"] .mfl-editor-area { background: #fff; color: #222; }

/* ── Cell Carousel ─────────────────────────────────────────────────────── */
.ccarousel {
  position: fixed;
  inset: 0;
  z-index: 9500;
  pointer-events: none;   /* el overlay no bloquea el fondo */
}
.ccarousel-bd { display: none; }   /* sin fondo */
.ccarousel-panel {
  position: fixed;
  top: 80px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
  pointer-events: auto;
  border-radius: 10px;
  box-shadow: 0 6px 28px rgba(0,0,0,.32);
  background: var(--props-bg, #f3f3f3);
  user-select: none;
}
.ccarousel-topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  background: var(--toolbar-bg, #2d2d2f);
  border-radius: 10px 10px 0 0;
  cursor: grab;
}
.ccarousel-topbar:active { cursor: grabbing; }
.ccarousel-prev,
.ccarousel-next,
.ccarousel-x {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.ccarousel-prev:hover,
.ccarousel-next:hover,
.ccarousel-x:hover { background: rgba(255,255,255,.28); }
.ccarousel-prev:disabled,
.ccarousel-next:disabled { opacity: .28; cursor: default; }
.ccarousel-home { margin-left: auto; font-size: 15px; }
.ccarousel-x    { font-size: 13px; }

/* Fichero de tarjetas */
.ccarousel-stage {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  gap: 4px;
  scrollbar-width: thin;
  padding: 0 8px 8px;
}

.ccarousel-card {
  border-radius: 8px;
  background: var(--props-bg, #f3f3f3);
  box-shadow: 0 2px 6px rgba(0,0,0,.14);
  overflow: hidden;
  flex-shrink: 0;
  transition: box-shadow .2s;
}
.ccarousel-card[data-pos="active"] {
  box-shadow: 0 4px 18px rgba(0,0,0,.22);
}

/* Cabecera — siempre visible, actúa como botón */
.ccarousel-card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #333);
  background: var(--props-bg, #f3f3f3);
  user-select: none;
  transition: background .15s, color .15s;
}
.ccarousel-card[data-pos="active"] .ccarousel-card-hdr {
  background: var(--accent, #3b82f6);
  color: #fff;
}
.ccarousel-card-arrow {
  font-size: 16px;
  line-height: 1;
  transition: transform .28s;
  flex-shrink: 0;
}
.ccarousel-card[data-pos="active"] .ccarousel-card-arrow {
  transform: rotate(90deg);
}

/* Cuerpo — animación con grid trick (height 0 ↔ auto sin JS) */
.ccarousel-card-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .28s ease;
}
.ccarousel-card[data-pos="active"] .ccarousel-card-body {
  grid-template-rows: 1fr;
}
.ccarousel-card-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 14px;
}
.ccarousel-card[data-pos="active"] .ccarousel-card-inner {
  padding: 4px 14px 14px;
}

/* Quitar chrome de .prop-section dentro del carrusel */
.ccarousel-card .prop-section       { border: none; margin: 0; border-radius: 0; overflow: visible; }
.ccarousel-card .prop-section-title { display: none; }
.ccarousel-card .prop-section-body  { display: block !important; }
.ccarousel-card .prop-section-body > .prop-row:first-child { border-top: none; }

/* Sugerencia de uso */
.ccarousel-tip {
  font-size: 11px;
  color: var(--text-muted, #999);
  letter-spacing: .04em;
  padding: 0 10px 8px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════
   Modo lápiz — vista 2D como dibujo a mano alzada
   Activa con la clase .pencil-mode en <html>.
   Aplasta colores y texturas a papel blanco con trazos de grafito.
   ══════════════════════════════════════════════════════════════════ */

.pencil-mode #canvas-area {
  background-color: #f8f5ed;          /* papel marfil */
  background-image:
    linear-gradient(rgba(0,0,0,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.025) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px;
}

/* Todas las reglas se ANCLAN a #canvas-area para no afectar el visor 3D,
   panel de propiedades, diálogos, ni catálogos. */

.pencil-mode #canvas-area .furniture-wrapper,
.pencil-mode #canvas-area .furniture-wrapper * {
  background: transparent !important;
  background-image: none !important;
  background-color: transparent !important;
  filter: none !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

/* Tableros / paneles / fondo: relleno papel + borde grafito.
   Aplicamos el filter SVG SOLO a piezas grandes (paneles del frente,
   puertas, fondo). Los .board del perímetro y los divisores son finos y
   con el filter se desplazan fuera de su caja, así que solo ponemos border. */
.pencil-mode #canvas-area .board,
.pencil-mode #canvas-area .furn-back-panel,
.pencil-mode #canvas-area .interior-board {
  background-color: #fdfaf2 !important;
  border: 1.4px solid #2b2826 !important;
  border-radius: 0 !important;
}
.pencil-mode #canvas-area .panel-wrap,
.pencil-mode #canvas-area .door-panel,
.pencil-mode #canvas-area .drawer-front,
.pencil-mode #canvas-area .cell-leaf,
.pencil-mode #canvas-area .struct-furn-blind,
.pencil-mode #canvas-area .zone-overlay,
.pencil-mode #canvas-area .glass-grid > * {
  background-color: #fdfaf2 !important;
  border: 1.4px solid #2b2826 !important;
  border-radius: 0 !important;
  filter: url(#pencil-rough) !important;
}

.pencil-mode #canvas-area .board.plinth,
.pencil-mode #canvas-area .board.top-plinth,
.pencil-mode #canvas-area .board.rails,
.pencil-mode #canvas-area .board.leg {
  background: #fdfaf2 !important;
}

.pencil-mode #canvas-area .door-handle,
.pencil-mode #canvas-area .drawer-handle {
  background: #2b2826 !important;
  border: 1.2px solid #2b2826 !important;
  filter: url(#pencil-rough) !important;
}

.pencil-mode #canvas-area .divider,
.pencil-mode #canvas-area .h-divider,
.pencil-mode #canvas-area .v-divider {
  background-color: #2b2826 !important;
  filter: url(#pencil-rough) !important;
}

.pencil-mode #canvas-area .dim-line,
.pencil-mode #canvas-area .dim-label,
.pencil-mode #canvas-area .cell-addr-label,
.pencil-mode #canvas-area .cell-dims {
  color: #2b2826 !important;
  background: transparent !important;
  font-family: 'Caveat', 'Comic Sans MS', cursive !important;
  filter: none !important;
}

.pencil-mode #canvas-area .door-panel--glass {
  background: rgba(255,255,255,0.4) !important;
}

#btn-pencil-mode.active {
  background: #2b2826;
  color: #fdfaf2;
}

/* ── View switcher flotante (2D / Zenital / 3D) ─────────────────── */
.view-switcher {
  position: fixed;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  padding: 3px;
  gap: 2px;
  user-select: none;
  touch-action: none;
}
.view-switcher.dragging { opacity: .85; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
body.dark .view-switcher { background: #262626; border-color: #3a3a3a; }
.vsw-handle {
  background: transparent;
  border: none;
  cursor: grab;
  color: #aaa;
  font-size: 14px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  touch-action: none;
}
.vsw-handle:active { cursor: grabbing; }
body.dark .vsw-handle { color: #777; }
.vsw-buttons { display: flex; gap: 2px; }
.vsw-btn {
  background: #f5f5f5;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #333;
  min-width: 64px;
  justify-content: center;
  font-family: inherit;
}
.vsw-btn:hover  { background: #e8e8e8; border-color: #c0c0c0; }
.vsw-btn:active { background: #ddd; }
body.dark .vsw-btn        { background: #1f1f1f; color: #ddd; border-color: #3a3a3a; }
body.dark .vsw-btn:hover  { background: #333; }
.vsw-icon { font-size: 13px; line-height: 1; }
.vsw-sep {
  width: 1px;
  background: #d8d8d8;
  margin: 2px 4px;
  align-self: stretch;
}
body.dark .vsw-sep { background: #3a3a3a; }
.vsw-face-btn { min-width: 32px; padding: 5px 8px; font-size: 14px; }
.vsw-face-btn.active {
  background: #2b6cb0;
  color: #fff;
  border-color: #2b6cb0;
}
.vsw-face-btn.active:hover { background: #2c5d99; border-color: #2c5d99; }
body.dark .vsw-face-btn.active        { background: #3b82f6; border-color: #3b82f6; color: #fff; }
body.dark .vsw-face-btn.active:hover  { background: #2563eb; border-color: #2563eb; }
@media (max-width: 720px) {
  .vsw-btn { font-size: 11px; padding: 5px 8px; min-width: 54px; }
  .vsw-face-btn { min-width: 28px; padding: 5px 6px; }
  .vsw-handle { padding: 0 3px; font-size: 12px; }
}

/* ── ViewCube (3D) ──────────────────────────────────────────────── */
/* Widget flotante dentro del visor 3D: cubo CSS-3D con 6 caras
   etiquetadas + 12 aristas + 8 esquinas clicables, botón Home y
   toggle Perspectiva/Ortográfica. */
.viewcube {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  user-select: none;
  touch-action: none;
  font-family: inherit;
}
.viewcube .vc-handle {
  cursor: grab;
  color: #888;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 1px;
  padding: 1px 6px;
  background: rgba(255,255,255,.6);
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.08);
}
.viewcube .vc-handle:active { cursor: grabbing; }
.viewcube.dragging { opacity: .85; }

.vc-stage {
  width: 96px;
  height: 96px;
  perspective: 360px;
  position: relative;
}
.vc-cube {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  top: 50%;
  left: 50%;
  margin-left: -32px;
  margin-top: -32px;
  transform-style: preserve-3d;
  transform: rotateX(-22deg) rotateY(35deg);
}
.vc-face {
  position: absolute;
  width: 64px;
  height: 64px;
  background: rgba(245,243,238,.92);
  border: 1px solid #b8b3a8;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-rows: 1fr 2fr 1fr;
  box-sizing: border-box;
  backface-visibility: hidden;
}
.vc-face-front  { transform: translateZ(32px); }
.vc-face-back   { transform: rotateY(180deg) translateZ(32px); }
.vc-face-right  { transform: rotateY( 90deg) translateZ(32px); }
.vc-face-left   { transform: rotateY(-90deg) translateZ(32px); }
.vc-face-top    { transform: rotateX( 90deg) translateZ(32px); }
.vc-face-bottom { transform: rotateX(-90deg) translateZ(32px); }

.vc-zone {
  cursor: pointer;
}
.vc-zone:hover {
  background: rgba(33, 150, 243, .35);
}
.vc-zone.vc-z-face {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #4a4439;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.vc-zone.vc-z-face:hover {
  color: #0d47a1;
}

.vc-controls {
  display: flex;
  gap: 4px;
}
.vc-btn {
  background: rgba(255,255,255,.85);
  border: 1px solid #c8c4ba;
  border-radius: 5px;
  width: 28px;
  height: 24px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  padding: 0;
}
.vc-btn:hover { background: #f0eee8; border-color: #a8a496; }
.vc-btn.vc-active {
  background: #2196f3;
  border-color: #1976d2;
  color: #fff;
}

body.dark .vc-face        { background: rgba(38,38,38,.92); border-color: #4a4a4a; }
body.dark .vc-zone.vc-z-face { color: #d8d3c8; }
body.dark .vc-zone.vc-z-face:hover { color: #64b5f6; }
body.dark .viewcube .vc-handle { background: rgba(38,38,38,.6); border-color: #3a3a3a; color: #999; }
body.dark .vc-btn { background: rgba(38,38,38,.85); border-color: #4a4a4a; color: #ddd; }
body.dark .vc-btn:hover { background: #333; }

/* ── Widget zenital (rotación del mueble seleccionado) ──────────── */
/* Disco flotante dentro del canvas en vista de planta. Análogo al
   viewcube, pero rota el MUEBLE (no la cámara) en pasos de 90°. */
.zenithal-orbit {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  user-select: none;
  touch-action: none;
  font-family: inherit;
}
.zenithal-orbit[hidden] { display: none; }
.zenithal-orbit .zo-handle {
  cursor: grab;
  color: #888;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 1px;
  padding: 1px 6px;
  background: rgba(255,255,255,.6);
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.08);
}
.zenithal-orbit .zo-handle:active { cursor: grabbing; }
.zenithal-orbit.dragging { opacity: .85; }

.zo-dial {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(245,243,238,.92);
  border: 1px solid #b8b3a8;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  cursor: grab;
}
.zo-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px dashed rgba(0,0,0,.18);
  pointer-events: none;
}
/* Wrapper que ocupa el disco completo y gira sobre su centro. El triángulo
   real va dentro, anclado abajo, así rotation=0 → flecha hacia abajo (sur),
   que es la convención del frente en buildTopView (rot 0 → frente abajo). */
.zo-arrow {
  position: absolute;
  inset: 6px;
  pointer-events: none;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  transition: transform 140ms ease-out;
}
.zo-arrow::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 22px solid #d32f2f;  /* triángulo apuntando hacia abajo */
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}
.zo-label {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: #4a4439;
  letter-spacing: .5px;
  pointer-events: none;
}

.zo-controls {
  display: flex;
  gap: 4px;
}
.zenithal-orbit .zo-btn {
  background: rgba(255,255,255,.85);
  border: 1px solid #c8c4ba;
  border-radius: 5px;
  width: 28px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  padding: 0;
}
.zenithal-orbit .zo-btn:hover { background: #f0eee8; border-color: #a8a496; }

body.dark .zo-dial { background: rgba(38,38,38,.92); border-color: #4a4a4a; }
body.dark .zo-ring { border-color: rgba(255,255,255,.18); }
body.dark .zo-label { color: #d8d3c8; }
body.dark .zenithal-orbit .zo-handle { background: rgba(38,38,38,.6); border-color: #3a3a3a; color: #999; }
body.dark .zenithal-orbit .zo-btn { background: rgba(38,38,38,.85); border-color: #4a4a4a; color: #ddd; }
body.dark .zenithal-orbit .zo-btn:hover { background: #333; }

/* ── Quick Panel — ventana flotante configurable ──────────────────────── */

.quick-panel {
  position: fixed;
  z-index: 9000;
  min-width: 280px;
  min-height: 240px;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--bg, #fff);
  color: var(--text, #222);
  border: 1px solid var(--border, #bbb);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  font-size: 13px;
}

.quick-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 10px;
  background: var(--bg-alt, #f0eee8);
  border-bottom: 1px solid var(--border, #ddd);
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.quick-panel__title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text, #333);
}

.quick-panel__actions {
  display: flex;
  gap: 4px;
}

.quick-panel__btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 7px;
  line-height: 1;
  color: var(--text-muted, #666);
}

.quick-panel__btn:hover {
  border-color: var(--border, #ccc);
  background: rgba(0, 0, 0, 0.04);
}

.quick-panel__body {
  flex: 1;
  overflow: auto;
  padding: 6px;
  background: var(--bg, #fff);
}

.quick-panel__empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted, #999);
  font-size: 12px;
}

.quick-panel__placeholder {
  background: var(--bg-alt, #faf9f6);
  border-style: dashed !important;
}

.quick-panel__hint {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-muted, #999);
  font-style: italic;
}

body.dark .quick-panel {
  background: #1e1e1e;
  border-color: #3a3a3a;
  color: #e0e0e0;
}

body.dark .quick-panel__header {
  background: #2a2a2a;
  border-bottom-color: #3a3a3a;
}

body.dark .quick-panel__btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #4a4a4a;
}

body.dark .quick-panel__placeholder {
  background: #232323;
}

/* ── Configurador del Quick Panel ───────────────────────────────────── */

#dlg-quick-panel-config.qp-cfg {
  padding: 0;
  border: 1px solid var(--border, #ccc);
  border-radius: 8px;
  background: var(--bg, #fff);
  color: var(--text, #222);
  min-width: 640px;
  max-width: 820px;
  max-height: 80vh;
  overflow: hidden;
}

.qp-cfg__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #ddd);
  font-weight: 600;
  font-size: 14px;
}

.qp-cfg__btn-icon {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted, #888);
}

.qp-cfg__desc {
  padding: 10px 16px 4px;
  font-size: 12px;
  color: var(--text-muted, #666);
}

.qp-cfg__body {
  display: flex;
  gap: 12px;
  padding: 8px 16px 12px;
  align-items: stretch;
}

.qp-cfg__col {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.qp-cfg__col-header {
  font-weight: 600;
  font-size: 12px;
  padding: 6px 8px;
  background: var(--bg-alt, #f5f5f5);
  border: 1px solid var(--border, #ddd);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

.qp-cfg__list {
  flex: 1;
  min-height: 340px;
  font-size: 13px;
  border: 1px solid var(--border, #ddd);
  border-radius: 0 0 4px 4px;
  padding: 4px;
}

.qp-cfg__mid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}

.qp-cfg__mid .qp-cfg__btn {
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff);
  border-radius: 4px;
  cursor: pointer;
}

.qp-cfg__footer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border, #ddd);
  background: var(--bg-alt, #fafafa);
}

.qp-cfg__btn-primary {
  padding: 6px 18px;
  background: var(--accent, #5a8cb8);
  color: #fff;
  border: 1px solid var(--accent, #5a8cb8);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.qp-cfg__btn-secondary {
  padding: 6px 14px;
  background: var(--bg, #fff);
  color: var(--text, #333);
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

body.dark #dlg-quick-panel-config.qp-cfg {
  background: #1e1e1e;
  color: #e0e0e0;
  border-color: #3a3a3a;
}

body.dark .qp-cfg__col-header,
body.dark .qp-cfg__footer { background: #2a2a2a; border-color: #3a3a3a; }

body.dark .qp-cfg__list { background: #232323; color: #e0e0e0; border-color: #3a3a3a; }

/* Drag&drop de secciones dentro del Quick Panel */
.quick-panel .prop-section { transition: outline 0.08s; }
.quick-panel .qp-dragging   { opacity: 0.4; }
.quick-panel .qp-drop-before { box-shadow: 0 -3px 0 0 var(--accent, #5a8cb8); }
.quick-panel .qp-drop-after  { box-shadow: 0  3px 0 0 var(--accent, #5a8cb8); }
.quick-panel .prop-section-title { cursor: grab; }
.quick-panel .prop-section-title:active { cursor: grabbing; }

/* ── Diseñador del Quick Panel (estilo VB Form Designer) ───────────── */

#dlg-quick-panel-config.qp-cfg--designer[open] {
  min-width: 320px;
  min-height: 280px;
  width: 1000px;
  height: 700px;
  max-width: 98vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  resize: both;
  overflow: hidden;
}

.qp-des__body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.qp-des__toolbox {
  width: 220px;
  border-right: 1px solid var(--border, #ddd);
  background: var(--bg-alt, #fafafa);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.qp-des__tb-header {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-muted, #666);
  background: var(--bg-alt, #f0eee8);
  border-bottom: 1px solid var(--border, #ddd);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.qp-des__tb-header-lbl {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qp-des__tb-sort {
  flex: 0 0 auto;
  border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff);
  color: var(--text-muted, #666);
  border-radius: 3px;
  font: 600 10px/1 inherit;
  letter-spacing: 0.5px;
  padding: 3px 6px;
  cursor: pointer;
  user-select: none;
}
.qp-des__tb-sort:hover { background: rgba(0,0,0,.04); color: var(--text, #333); }
.qp-des__tb-sort--on {
  background: var(--accent, #5a8cb8);
  border-color: var(--accent, #5a8cb8);
  color: #fff;
}
body.dark .qp-des__tb-sort { background: #1e1e1e; border-color: #444; color: #ccc; }
body.dark .qp-des__tb-sort:hover { background: rgba(255,255,255,.06); color: #fff; }
body.dark .qp-des__tb-sort--on { background: var(--accent, #5a8cb8); border-color: var(--accent, #5a8cb8); color: #fff; }

.qp-des__tb-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.qp-des__tb-group {
  margin-bottom: 6px;
}

.qp-des__tb-grouphdr {
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: transparent;
}

.qp-des__tb-item {
  padding: 5px 10px 5px 18px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  color: var(--text, #333);
}

.qp-des__tb-item:hover {
  background: rgba(90, 140, 184, 0.12);
}

.qp-des__tb-item--used {
  color: var(--text-muted, #aaa);
  cursor: not-allowed;
  font-style: italic;
}

.qp-des__tb-item--used:hover { background: transparent; }

.qp-des__canvas {
  flex: 1;
  position: relative;
  background: #fff;
  background-image:
    linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: auto;
  outline: none;
}

.qp-des-section {
  position: absolute;
  background: var(--bg-alt, #f6f4ee);
  border: 1px solid #a8a496;
  border-radius: 3px;
  overflow: hidden;
  cursor: move;
  user-select: none;
  box-sizing: border-box;
}

.qp-des-section--sel {
  border-color: var(--accent, #5a8cb8);
  box-shadow: 0 0 0 1px var(--accent, #5a8cb8);
  z-index: 10;
}

.qp-des-section__title {
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,.05);
  border-bottom: 1px solid rgba(0,0,0,.08);
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 6px;
}
.qp-des-section__title-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qp-des-section__size {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  color: var(--text-muted, #888);
  pointer-events: none;
}
/* En modo acordeón la sección es 22 px — el label de tamaño se queda
   encima de los checks "celda/mueble/zona" del acc-hdr. Lo ocultamos
   porque tampoco se pueden redimensionar secciones colapsadas. */
.qp-des-section--editor .qp-des-section__size { display: none; }

/* Tres checks "celda / mueble / zona" — inline en la cabecera de cada
   sección del canvas (tras el nombre, alineados a la derecha). Indican
   en qué contexto del host la sección se incluye en el render. */
.qp-des-section__fires {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
  pointer-events: auto;
}
.qp-des-section__fire {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: normal;
  color: var(--text-muted, #666);
  cursor: pointer;
  user-select: none;
}
.qp-des-section__fire input {
  margin: 0;
  cursor: pointer;
  width: 11px;
  height: 11px;
}
body.dark .qp-des-section__fire { color: #bbb; }

.qp-des-handle {
  position: absolute;
  width: 8px; height: 8px;
  background: #fff;
  border: 1px solid var(--accent, #5a8cb8);
  z-index: 11;
}

.qp-des-handle--nw { left: -4px;  top: -4px;    cursor: nwse-resize; }
.qp-des-handle--n  { left: 50%;   top: -4px;    margin-left:-4px; cursor: ns-resize; }
.qp-des-handle--ne { right: -4px; top: -4px;    cursor: nesw-resize; }
.qp-des-handle--e  { right: -4px; top: 50%;     margin-top:-4px;  cursor: ew-resize; }
.qp-des-handle--se { right: -4px; bottom: -4px; cursor: nwse-resize; }
.qp-des-handle--s  { left: 50%;   bottom: -4px; margin-left:-4px; cursor: ns-resize; }
.qp-des-handle--sw { left: -4px;  bottom: -4px; cursor: nesw-resize; }
.qp-des-handle--w  { left: -4px;  top: 50%;     margin-top:-4px;  cursor: ew-resize; }

.qp-cfg__counter {
  font-size: 12px;
  color: var(--text-muted, #888);
  padding: 0 8px;
}

body.dark .qp-des__toolbox { background: #232323; border-right-color: #3a3a3a; }
body.dark .qp-des__tb-header { background: #2a2a2a; border-bottom-color: #3a3a3a; color: #ccc; }
body.dark .qp-des__tb-item { color: #e0e0e0; }
body.dark .qp-des__tb-item:hover { background: rgba(90,140,184,.18); }
body.dark .qp-des__canvas { background: #1a1a1a; background-image:
  linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
  linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); }
body.dark .qp-des-section { background: #2a2a2a; border-color: #4a4a4a; color: #e0e0e0; }
body.dark .qp-des-section__title { background: rgba(255,255,255,.05); border-bottom-color: rgba(255,255,255,.08); }

/* Contenido real de las secciones dentro del diseñador (preview disabled) */
.qp-des-section__content {
  position: absolute;
  left: 0; right: 0;
  top: 22px;       /* debajo del título del diseñador (~22px) */
  bottom: 0;
  overflow: hidden;
  padding: 4px;
  font-size: 11px;
  background: #fff;
}

/* Checkbox absoluto en la esquina superior derecha, justo debajo de la
   barra de título del diseñador. NO desplaza nada (z-index alto, position
   absoluta). Pequeño y sin texto. */
.qp-des-section__hdr-toggle {
  position: absolute;
  right: 4px;
  top: 24px;          /* 22 (título) + 2 de margen */
  z-index: 12;
  margin: 0;
  cursor: pointer;
  pointer-events: auto;
}

.qp-des-section__content .prop-section {
  border: none;
  background: transparent;
  margin: 0;
}

.qp-des-section__content .prop-section-body {
  display: block !important;
}

.qp-des-section__hint {
  padding: 8px;
  color: var(--text-muted, #aaa);
  font-style: italic;
  font-size: 11px;
}

body.dark .qp-des-section__content { background: #232323; }

.qp-des__tb-search {
  margin: 6px 8px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  background: #fff;
  color: var(--text, #222);
}
.qp-des__tb-search:focus { outline: none; border-color: var(--accent, #5a8cb8); }

body.dark .qp-des__tb-search { background: #1e1e1e; color: #e0e0e0; border-color: #3a3a3a; }

.quick-panel__canvas {
  position: relative;
  /* width/height los setea paintQuickPanel según maxRight/maxBottom de las secciones */
}

/* ── Pestañas del Quick Panel ─────────────────────────────────────── */
.quick-panel__tabs {
  display: flex;
  border-bottom: 1px solid var(--border, #ddd);
  background: var(--bg-alt, #f0eee8);
  flex-shrink: 0;
}
.quick-panel__tab {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border, #ddd);
  cursor: pointer;
  color: var(--text-muted, #666);
  border-bottom: 2px solid transparent;
}
.quick-panel__tab:last-child { border-right: none; }
.quick-panel__tab:hover { background: rgba(0,0,0,.04); }
.quick-panel__tab--active {
  background: var(--bg, #fff);
  color: var(--text, #333);
  border-bottom-color: var(--accent, #5a8cb8);
  font-weight: 600;
}
body.dark .quick-panel__tabs { background: #2a2a2a; border-bottom-color: #3a3a3a; }
body.dark .quick-panel__tab { color: #ccc; border-right-color: #3a3a3a; }
body.dark .quick-panel__tab:hover { background: rgba(255,255,255,.06); }
body.dark .quick-panel__tab--active { background: #1e1e1e; color: #fff; }

/* ── Pestañas del diseñador (en el diálogo) ──────────────────────── */
.qp-des__tabs {
  display: flex;
  border-bottom: 1px solid var(--border, #ddd);
  background: var(--bg-alt, #f0eee8);
  flex-shrink: 0;
}
.qp-des__tab {
  flex: 1;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border, #ddd);
  cursor: pointer;
  color: var(--text-muted, #666);
  border-bottom: 2px solid transparent;
}
.qp-des__tab:last-child { border-right: none; }
.qp-des__tab:hover { background: rgba(0,0,0,.04); }
.qp-des__tab--active {
  background: var(--bg, #fff);
  color: var(--text, #333);
  border-bottom-color: var(--accent, #5a8cb8);
  font-weight: 600;
}
body.dark .qp-des__tabs { background: #2a2a2a; border-bottom-color: #3a3a3a; }
body.dark .qp-des__tab { color: #ccc; border-right-color: #3a3a3a; }
body.dark .qp-des__tab:hover { background: rgba(255,255,255,.06); }
body.dark .qp-des__tab--active { background: #1e1e1e; color: #fff; }

/* Título de cada sección en el panel rápido (modo uso). Se añade vía JS
   solo cuando showHeader=true. Equivalente al qp-des-section__title del
   diseñador para que las posiciones coincidan. */
.quick-panel__sec-title {
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,.05);
  border-bottom: 1px solid rgba(0,0,0,.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.dark .quick-panel__sec-title { background: rgba(255,255,255,.05); border-bottom-color: rgba(255,255,255,.08); }

/* Sin cabecera: cuerpo de la sección sin reservar 22px arriba */
.quick-panel__sec--no-header .prop-section-body { padding-top: 0; }

/* Diseñador: ocultar el título "[Mueble] X" y subir el contenido a top:0
   cuando el check está desmarcado. Así el diseñador y producción coinciden
   en la posición del primer campo. */
.qp-des-section--no-header .qp-des-section__title { display: none; }
.qp-des-section--no-header .qp-des-section__content { top: 0; }

/* Pestañas del diseñador con botones secundarios (✏/✕) y + para añadir. */
.qp-des__tab-wrap {
  display: flex;
  align-items: stretch;
  border-right: 1px solid var(--border, #ddd);
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted, #666);
}
.qp-des__tab-wrap--active {
  background: var(--bg, #fff);
  color: var(--text, #333);
  border-bottom-color: var(--accent, #5a8cb8);
}
.qp-des__tab-wrap .qp-des__tab {
  border: none; border-right: none; border-bottom: none;
  flex: 0 1 auto;
}
.qp-des__tab-wrap--active .qp-des__tab { font-weight: 600; }
.qp-des__tab-mini {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text-muted, #888);
}
.qp-des__tab-mini:hover { color: var(--text, #333); background: rgba(0,0,0,.06); }
.qp-des__tab-add {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted, #888);
}
.qp-des__tab-add:hover { background: rgba(0,0,0,.04); color: var(--text, #333); }
/* Botón "A–Z" alineado al final de la barra de pestañas del diseñador.
   Pulsación one-shot: reordena alfabéticamente las secciones del tab
   activo y las recoloca en cascada. */
.qp-des__tab-sort {
  margin-left: auto;
  margin-right: 6px;
  align-self: center;
  flex: 0 0 auto;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #ccc);
  color: var(--text-muted, #666);
  border-radius: 3px;
  font: 600 10px/1 inherit;
  letter-spacing: 0.5px;
  padding: 4px 7px;
  cursor: pointer;
  user-select: none;
}
.qp-des__tab-sort:hover {
  background: var(--accent, #5a8cb8);
  border-color: var(--accent, #5a8cb8);
  color: #fff;
}
body.dark .qp-des__tab-sort { background: #1e1e1e; border-color: #444; color: #ccc; }
body.dark .qp-des__tab-sort:hover { background: var(--accent, #5a8cb8); border-color: var(--accent, #5a8cb8); color: #fff; }
.qp-des__tab-rename {
  border: 1px solid var(--accent, #5a8cb8);
  background: var(--bg, #fff);
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 500;
  min-width: 80px;
}
body.dark .qp-des__tab-wrap { color: #ccc; border-right-color: #3a3a3a; }
body.dark .qp-des__tab-wrap--active { background: #1e1e1e; color: #fff; }
body.dark .qp-des__tab-mini:hover { background: rgba(255,255,255,.08); color: #fff; }
body.dark .qp-des__tab-add:hover { background: rgba(255,255,255,.06); color: #fff; }
body.dark .qp-des__tab-rename { background: #1e1e1e; color: #e0e0e0; }

/* ── Modo editor (acordeón) en panel rápido y diseñador ────────────── */

/* Cabecera con flecha que añadimos en producción cuando mode=editor */
.quick-panel__sec-title--toggle {
  cursor: pointer;
  user-select: none;
}
.quick-panel__sec-arrow { font-size: 9px; color: var(--text-muted, #666); }

/* Sección colapsada: oculta cualquier contenido bajo la cabecera —
   body real y el hint de placeholder ("Selecciona un mueble."). */
.quick-panel__sec--collapsed .prop-section-body,
.quick-panel__sec--collapsed .quick-panel__hint { display: none !important; }

/* Diseñador: cabecera acordeón debajo del título "[Mueble] X" */
.qp-des-section__acc-hdr {
  position: absolute;
  left: 0; right: 0;
  top: 0;              /* en modo editor no hay título encima */
  height: 22px;
  padding: 4px 6px;
  font-size: 11px;
  background: rgba(0,0,0,.03);
  border-bottom: 1px solid rgba(0,0,0,.06);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
}
.qp-des-section__acc-arrow { font-size: 9px; color: var(--text-muted, #666); flex: 0 0 auto; }
.qp-des-section__acc-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cuando hay acc-hdr el content empieza más abajo */
.qp-des-section--editor .qp-des-section__content { top: 44px; }
.qp-des-section--editor.qp-des-section--no-header .qp-des-section__content { top: 22px; }
.qp-des-section--editor.qp-des-section--no-header .qp-des-section__acc-hdr  { top: 0; }
.qp-des-section--editor.qp-des-section--collapsed .qp-des-section__content  { display: none; }

body.dark .qp-des-section__acc-hdr { background: rgba(255,255,255,.04); border-bottom-color: rgba(255,255,255,.08); }

/* Modo acordeón en el diseñador: la sección SIEMPRE se ve al alto del
   header (22 px). No hay contenido que mostrar ahí — solo flecha + nombre.
   La expansión real solo ocurre en producción. */
.qp-des-section--editor { height: 22px !important; }
.qp-des-section--editor .qp-des-section__content { display: none; }
.quick-panel__sec--collapsed { height: auto !important; }

/* Hacer la barra de pestañas del diseñador wrap si no cabe el selector
   de modo y los botones cuando hay muchas pestañas */
.qp-des__tabs { flex-wrap: wrap; }

/* Rubber-band: rectángulo de selección múltiple en el canvas del diseñador */
.qp-des__rubber {
  position: absolute;
  border: 1px dashed var(--accent, #5a8cb8);
  background: rgba(90, 140, 184, 0.10);
  pointer-events: none;
  z-index: 50;
  box-sizing: border-box;
}

/* Wrap con scroll alrededor del canvas del diseñador. El canvas mantiene
   el tamaño exacto del panel rápido en producción para WYSIWYG. */
.qp-des__canvas-wrap {
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: var(--bg-alt, #ececec);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}
.qp-des__canvas-wrap .qp-des__canvas {
  flex: 0 0 auto;
  border: 1px solid var(--border, #ccc);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
body.dark .qp-des__canvas-wrap { background: #161616; }


/* ── Barra de operaciones de celda (bajo el toolbar) ─────────────── */
#cell-ops-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #ece8de;
  border-bottom: 1px solid #c4c0b8;
  flex-shrink: 0;
}
body.dark #cell-ops-bar {
  background: #2a2a2c;
  border-bottom-color: #1f1f21;
}
.cell-op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #444;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
body.dark .cell-op-btn { color: #ccc; }
.cell-op-btn svg { width: 24px; height: 24px; display: block; }
.cell-op-btn:hover { background: rgba(0,0,0,.06); border-color: #b8b4ac; }
body.dark .cell-op-btn:hover { background: rgba(255,255,255,.06); border-color: #555; }
.cell-op-btn[disabled],
.cell-op-btn.is-disabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Popover con miniaturas de opciones */
.cell-ops-popover {
  background: #f9f7f1;
  border: 1px solid #aaa;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 10px 12px 12px;
  min-width: 200px;
  max-width: 360px;
}
body.dark .cell-ops-popover {
  background: #252526;
  border-color: #3a3a3c;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.cell-ops-popover-hdr {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #d8d4cc;
}
body.dark .cell-ops-popover-hdr { color: #aaa; border-bottom-color: #3a3a3c; }
.cell-ops-popover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
}
.cell-ops-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: #fff;
  border: 1px solid #c8c4bc;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .12s, transform .08s, background .12s;
}
body.dark .cell-ops-card { background: #1e1e1f; border-color: #3a3a3c; }
.cell-ops-card:hover { border-color: #2563eb; transform: translateY(-1px); }
.cell-ops-card-lbl {
  font-size: 11px;
  color: #666;
  font-weight: 500;
  line-height: 1;
}
body.dark .cell-ops-card-lbl { color: #bbb; }

/* En móvil reducimos altura para no comer canvas */
@media (max-width: 720px) {
  #cell-ops-bar { padding: 3px 6px; gap: 3px; }
  .cell-op-btn { width: 30px; height: 30px; }
  .cell-op-btn svg { width: 20px; height: 20px; }
}
