/* RÜM Canvas 2D · planta → modelo BIM (assets/js/rum_canvas_plan.js). Tokens --cv-* de rum_canvas.css.
   Plan: RUM_Tools/2d_docs/PLAN_CANVAS.md, specs 28–35. */

#cv-bim[hidden], #cv-bim-go[hidden] { display: none; }
#cv-bim .cv-ico { width: 17px; height: 17px; }

#cv-bim-body { display: grid; gap: 16px; }
.cv-bim-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cv-bim-stats > div {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--cv-rule);
  border-radius: 10px;
  background: var(--cv-paper-2);
}
.cv-bim-stats b { font-family: var(--cv-display); font-size: 24px; font-weight: 500; line-height: 1.1; color: var(--cv-ink); }
.cv-bim-stats span { font-size: 12.5px; color: var(--cv-ink-2); }
.cv-bim-stats small { font-size: 11.5px; line-height: 1.35; color: var(--cv-muted); }

.cv-bim-rooms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cv-bim-rooms li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--cv-rule); font-size: 13px; }
.cv-bim-rooms li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-bim-rooms li b { font-weight: 600; font-variant-numeric: tabular-nums; }

.cv-bim-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.cv-bim-unit { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cv-muted); }
.cv-bim-unit .cv-input { width: 100%; }
.cv-bim-check { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.cv-bim-check input { accent-color: var(--cv-ink); }
.cv-bim-actions { display: flex; gap: 8px; }
#cv-bim-body .cv-note--warn ul { margin: 6px 0 0; padding-left: 18px; }

@media (max-width: 640px) {
  .cv-bim-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cv-bim-grid { grid-template-columns: 1fr; }
  #cv-bim span { display: none; }
}

/* ---------- Fase 3b/3c: plumillas, tipos de línea, escala, reglas, pantallas chicas (specs 41–46) ---------- */

.cv-style { max-width: calc(100% - 150px); overflow-x: auto; scrollbar-width: none; }
.cv-style::-webkit-scrollbar { display: none; }
.cv-style > * { flex: none; }

.cv-pen {
  min-width: 32px;
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cv-ink-2);
  font: 600 11px/1 var(--cv-sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cv-dash {
  width: 38px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cv-ink);
  cursor: pointer;
}
.cv-dash svg { width: 26px; height: 8px; }
.cv-scale {
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cv-ink-2);
  font: 600 12px/1 var(--cv-sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cv-pen:hover, .cv-dash:hover, .cv-scale:hover { background: var(--cv-paper-2); }
.cv-pen.active, .cv-dash.active, .cv-scale.active { background: var(--cv-paper-2); box-shadow: inset 0 0 0 1.5px var(--cv-ink); color: var(--cv-ink); }
.cv-pen:focus-visible, .cv-dash:focus-visible, .cv-scale:focus-visible { outline: 2px solid var(--cv-ink); outline-offset: 1px; }

/* Con una planta elegida, la barra sólo muestra su escala. */
.cv-style__scale { display: none; align-items: center; gap: 2px; }
.cv-style.is-scale > :not(.cv-style__scale) { display: none; }
.cv-style.is-scale .cv-style__scale { display: flex; }
.cv-style__label { margin: 0 6px 0 4px; font: 600 10px/1 var(--cv-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--cv-label); }

#cv-rulers.active { background: var(--cv-ink); color: #fff; }

/* «Planta» en la barra de arriba (spec 41). */
#cv-plan-top .cv-ico, #cv-ins-top .cv-ico { width: 17px; height: 17px; }
/* «Escuadras» prendido: se nota que la regla está sobre el lienzo (spec 52). */
#cv-ins-top.is-on { background: var(--cv-ink); border-color: var(--cv-ink); color: #fff; }

/* Barra de herramientas en pantallas bajas (laptop, tablet acostada): cabe sin desplazarse. */
@media (min-width: 761px) and (max-height: 900px) {
  .cv-tools { gap: 0; padding: 5px; max-height: calc(100% - 96px); }
  .cv-tool { width: 36px; height: 36px; }
  .cv-tools hr { margin: 3px auto; }
}
@media (min-width: 761px) and (max-height: 720px) {
  .cv-tool { width: 32px; height: 32px; border-radius: 8px; }
  .cv-tool kbd { display: none; }
}

/* Tablet y celular (spec 46): blancos de toque más grandes y nada que se desborde. */
@media (pointer: coarse) {
  .cv-swatch { width: 30px; height: 30px; }
  .cv-width, .cv-pen, .cv-dash, .cv-scale { min-height: 36px; }
  #cv-bim-modal .cv-modal__card { max-height: calc(100dvh - 24px); overflow-y: auto; }
}
@media (max-width: 760px) {
  .cv-style { max-width: calc(100% - 20px); }
  #cv-plan-top span:not(.cv-ico) { display: inline; }
  .cv-bim-rooms { grid-template-columns: 1fr; }
  /* El aviso va arriba de las dos barras de abajo: no tapa las herramientas. */
  .cv-toast { bottom: 128px; }
}

/* Regla y escuadras (specs 48–50): barrita sobre las esquinas de abajo. */
.cv-ins-bar {
  position: absolute;
  left: 50%;
  bottom: 124px;   /* arriba del aviso */
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 24px);
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  background: #fff;
  border: 1px solid var(--cv-rule);
  border-radius: 999px;
  box-shadow: var(--cv-float);
}
.cv-ins-bar[hidden], .cv-app.is-meeting .cv-ins-bar { display: none; }
.cv-ins-bar::-webkit-scrollbar { display: none; }
.cv-ins-bar button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cv-ink-2);
  font: 600 12px/1 var(--cv-sans);
  white-space: nowrap;
  cursor: pointer;
}
.cv-ins-bar button .cv-ico { width: 16px; height: 16px; }
.cv-ins-bar button:hover { background: var(--cv-paper-2); }
.cv-ins-bar button.active { background: var(--cv-ink); color: #fff; }
.cv-ins-bar [data-ins-off] { padding: 0 8px; }
.cv-ins-sep { flex: none; width: 1px; height: 20px; margin: 0 4px; background: var(--cv-rule); }
@media (max-width: 760px) { .cv-ins-bar { bottom: 186px; } }
