/* ==========================================================================
   Bancada — Panel "Ambiente" (`js/ui/ambiente.js`)

   Dos mitades: la PLANTA manda y ocupa todo lo que puede; el 3D y la ficha del
   mueble van a la derecha, en una columna angosta y callada.

   Tiene que entrar en una pantalla de taller de 1366 × 768 con el dock puesto:
   ahí quedan 1066 px de ancho y unos 640 de alto. Por eso las dos barras de
   arriba son bajas, la columna de la derecha mide 300 px y NADA scrollea para
   el costado.

   Todos los colores salen de tokens.css. Lo que falta se deriva con color-mix.
   ========================================================================== */

/* Varios elementos del panel son flex o grid: sin esto, [hidden] no alcanza. */
.amb [hidden],
.amb-ficha [hidden] { display: none !important; }

.amb {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--paper);
}

/* ==========================================================================
   Estado vacío: las cuatro formas, grandes

   Es lo primero que ve el carpintero y lo único que hay en la pantalla. Un
   clic y el ambiente ya está hecho.
   ========================================================================== */
.amb-formas {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* «safe»: si el contenido no entra, arranca desde arriba en vez de cortarse por los dos
     lados (lo de arriba no se alcanza ni con la barra de desplazamiento). */
  justify-content: safe center;
  gap: var(--s6);
  padding: var(--s7) var(--s6);
  padding-bottom: calc(var(--s6) + 4px);
}
.amb-formas__cabecera { text-align: center; }
.amb-formas__titulo {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -.026em;
  line-height: var(--lh-tight);
  margin: 0;
}
.amb-formas__bajada {
  font-size: var(--fs-md);
  color: var(--ink-3);
  margin: var(--s2) 0 0;
}

.amb-formas__grilla {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: var(--s4);
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.amb-forma {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s5) var(--s4) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  cursor: pointer;
  text-align: center;
  transition: box-shadow var(--t) var(--ease-out), border-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.amb-forma:hover {
  border-color: var(--acc-line);
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
}
.amb-forma:focus-visible { outline: none; border-color: var(--acc); box-shadow: var(--ring); }

.amb-forma__dibujo {
  display: block;
  width: 108px;
  height: 108px;
  border-radius: var(--r);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
}
.amb-forma__dibujo svg { width: 100%; height: 100%; display: block; }

.amb-forma__piso { fill: var(--paper-3); stroke: none; }
.amb-forma__pared { fill: none; stroke: var(--ink-2); stroke-width: 2.6; }
.amb-forma:hover .amb-forma__pared { stroke: var(--acc); }

.amb-forma__nombre {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 640;
  color: var(--ink);
  letter-spacing: -.012em;
}
.amb-forma__desc {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  line-height: var(--lh-snug);
  max-width: 26ch;
}

/* ==========================================================================
   La pantalla de trabajo
   ========================================================================== */
.amb-trabajo {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* ---- Las dos barras de arriba ------------------------------------------- */
.amb__barra {
  display: flex;
  align-items: flex-end;
  gap: var(--s3);
  flex-wrap: wrap;
  padding: var(--s2) var(--s4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.amb__barra--2 { align-items: center; padding: 8px var(--s4); }

.amb__barra-label {
  font-size: var(--fs-xs);
  font-weight: 680;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding-bottom: 9px;
}

/* ---- Los cuatro dibujitos de forma, chicos ------------------------------ */
.amb__formas {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.amb__forma-chica {
  width: 34px;
  height: 34px;
  padding: 3px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.amb__forma-chica svg { width: 100%; height: 100%; display: block; }
.amb__forma-chica:hover { background: var(--paper-2); }
.amb__forma-chica:focus-visible { outline: none; box-shadow: var(--ring); }
.amb__forma-chica[aria-pressed="true"] { background: var(--acc-soft); }
.amb__forma-chica[aria-pressed="true"] .amb-forma__pared { stroke: var(--acc); }

/* ---- Los largos de cada pared ------------------------------------------- */
.amb__paredes {
  display: flex;
  align-items: flex-end;
  gap: var(--s2);
  flex-wrap: wrap;
  min-width: 0;
}
.amb__pared { width: 116px; gap: 3px; }
.amb__pared .campo__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Toque de 36 px como mínimo también en los largos y el techo. */
.amb__pared .input { height: 36px; }
.amb__pared .input::-webkit-outer-spin-button,
.amb__pared .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amb__pared .input { -moz-appearance: textfield; appearance: textfield; }
.amb__pared .campo__ayuda { display: none; }

/* La pared que se está trabajando: el aviso del sobrante habla de ésta y en la
   planta tiene su línea marcada. Acá se repite la misma marca, en el campo. */
.amb__pared--activa .campo__label { color: var(--acc-ink); }
.amb__pared--activa .input {
  border-color: var(--acc-line);
  background: var(--acc-soft);
}
.amb__pared--techo { margin-left: var(--s3); }
/* El desplome de cada pared: un campo con la etiqueta más tenue que el largo, que
   es el que se usa siempre. */
.amb__pared--desplome .campo__label { color: var(--ink-3); }
/* Toque de 36 px como mínimo (los campos de largo heredan 34). */
.amb__pared--desplome .input { height: 36px; }
/* El desplome es un número de dos o tres cifras: un campo angosto, pegado al largo de SU pared, para
   que las cuatro paredes y el techo entren en una sola fila y la planta no pierda una fila de alto. */
.amb__pared.amb__pared--desplome { width: 84px; }
.amb__pared--desplome.amb__pared--activa .campo__label { color: var(--acc-ink); }

/* ---- Los tres niveles --------------------------------------------------- */
.amb__niveles,
.amb-ficha__niveles {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.amb__nivel {
  height: 32px;
  min-width: 66px;
  padding: 0 12px;
  border: 0;
  border-radius: calc(var(--r-sm) - 1px);
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}
.amb__nivel:hover { background: var(--paper-2); color: var(--ink-2); }
.amb__nivel:focus-visible { outline: none; box-shadow: var(--ring); }
.amb__nivel[aria-pressed="true"] {
  background: var(--acc-soft);
  border: 1px solid var(--acc-line);
  color: var(--acc-ink);
  font-weight: 640;
}

/* ---- El interruptor de las medidas ------------------------------------- */
.amb__switch {
  display: flex;
  align-items: center;
  gap: var(--s2);
  cursor: pointer;
  padding: 0 2px;
}
.amb__switch-txt {
  font-size: var(--fs-xs);
  font-weight: 560;
  color: var(--ink-3);
  white-space: nowrap;
}
.amb__switch:hover .amb__switch-txt { color: var(--ink-2); }

/* ==========================================================================
   Cuerpo: planta a la izquierda, 3D y ficha a la derecha
   ========================================================================== */
.amb__cuerpo {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.amb__izq {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: var(--s3);
  gap: var(--s2);
}

.amb__lienzo {
  position: relative;
  flex: 1;
  min-height: 200px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--plan-bg);
  overflow: hidden;
}
.amb-planta {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Sin esto, en una notebook con pantalla táctil arrastrar un mueble scrollea
     la pantalla en vez de mover el mueble. */
  touch-action: none;
}
.amb-planta:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--acc); }
.amb-planta--moviendo { cursor: grabbing !important; }

/* ---- La tira de los que faltan poner ----------------------------------- */
.amb__pendientes {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  min-height: 30px;
}
.amb__pendientes-label {
  font-size: var(--fs-xs);
  font-weight: 680;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.amb__pendiente {
  height: 30px;
  padding: 0 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.amb__pendiente:hover { border-color: var(--acc); border-style: solid; color: var(--acc-ink); background: var(--acc-soft); }
.amb__pendiente:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--acc); }

/* ---- Los avisos -------------------------------------------------------- */
.amb__avisos {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-height: 34%;
  overflow: auto;
}
.amb__avisos:empty { display: none; }
.amb__avisos .aviso { font-size: var(--fs-sm); }

.amb-avisos-lista {
  margin: 0;
  padding-left: var(--s5);
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  color: var(--ink-2);
}

/* ==========================================================================
   Columna de la derecha
   ========================================================================== */
.amb__lado {
  width: 300px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}

/* El 3D: el mismo marco del panel de Mueble (styles/escena3d.css). */
.amb__lado .escena {
  flex: none;
  height: 38%;
  min-height: 150px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.amb__lado .escena canvas { display: block; width: 100%; height: 100%; }

/* ---- La ficha del mueble ----------------------------------------------- */
.amb-ficha {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s3) var(--s4) var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.amb-ficha__cabecera { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.amb-ficha__titulo {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 640;
  letter-spacing: -.012em;
  color: var(--ink);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.amb-ficha__tipo { font-size: var(--fs-xs); color: var(--ink-3); }

.amb-ficha__vacio {
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  color: var(--ink-3);
  margin: 0;
}
.amb-ficha__nota {
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  color: var(--ink-3);
  margin: 0;
}
.amb-ficha__resumen { display: flex; flex-direction: column; }

.amb-ficha__niveles { width: 100%; }
.amb-ficha__niveles .amb__nivel { flex: 1; min-width: 0; padding: 0 4px; font-size: var(--fs-xs); }

.amb-ficha__medidas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s2);
}
.amb-ficha__medidas .input { height: 34px; }
/* En 300 px de columna entran tres medidas, pero no tres medidas MÁS la
   flechita de arriba-abajo que dibuja Chrome: con ella, un ancho de 1.000 se
   ve "100" y el carpintero cree que el programa le comió un número. Se teclea
   o se usan las flechas del teclado, que es lo que hace todo el mundo. */
.amb-ficha__medidas .input::-webkit-outer-spin-button,
.amb-ficha__medidas .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amb-ficha__medidas .input { -moz-appearance: textfield; appearance: textfield; }
.amb-ficha .campo__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Los anchos de plaza: un atajo, no una lista de opciones. */
.amb-ficha__anchos { display: flex; flex-wrap: wrap; gap: 4px; }
.amb-ficha__ancho {
  height: 26px;
  min-width: 42px;
  padding: 0 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  cursor: pointer;
}
.amb-ficha__ancho:hover { border-color: var(--acc); color: var(--acc-ink); }
.amb-ficha__ancho:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--acc); }
.amb-ficha__ancho[aria-pressed="true"] {
  background: var(--acc-soft);
  border-color: var(--acc-line);
  color: var(--acc-ink);
  font-weight: 680;
}
/* La tira de medidas de colchón de la cama: un control principal, con toque de 36 px. */
.amb-ficha__ancho--toque { height: 36px; min-width: 44px; padding: 0 10px; font-size: var(--fs-sm); }

/* ---- Las tres placas --------------------------------------------------- */
.amb-ficha__mats { display: flex; flex-direction: column; gap: 6px; }
.amb-ficha__mat { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.amb-ficha__mat-label {
  width: 58px;
  flex: none;
  font-size: var(--fs-xs);
  font-weight: 620;
  color: var(--ink-3);
}
.amb-ficha__mat-control { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.amb-ficha__mat-control .select { flex: 1; min-width: 0; height: 32px; font-size: var(--fs-sm); }
.select--chico { height: 32px; font-size: var(--fs-sm); }

.amb-ficha__link {
  align-self: flex-start;
  border: 0;
  background: transparent;
  padding: 2px 0;
  font-family: inherit;
  font-size: var(--fs-xs);
  color: var(--acc-ink);
  text-decoration: underline;
  text-decoration-color: var(--acc-line);
  text-underline-offset: 2px;
  cursor: pointer;
}
.amb-ficha__link:hover { color: var(--acc); }
.amb-ficha__link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ---- El rincón: lo que se ofrece cuando el mueble está contra la esquina ----
   El selector de mano viene del panel del Mueble con sus estilos puestos
   (`modulo.css`); acá sólo se lo hace entrar en el ancho de la ficha. */
.amb-ficha__rincon {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--acc-line);
  border-radius: var(--r);
  background: var(--acc-soft);
}
.amb-ficha__rincon-txt {
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  color: var(--acc-ink);
}
.amb-ficha .mano { gap: 6px; }
.amb-ficha .mano__opcion { min-height: 78px; font-size: var(--fs-xs); padding: 6px 4px; }
.amb-ficha .mano__dibujo { width: 42px; height: 42px; }
.amb-ficha .mano__pie { font-size: var(--fs-xs); }
.amb-ficha .mano__pie span { min-width: 0; }

.amb-ficha__acciones {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
}
/* Los botones del editor van en su propia fila, bajo la línea que ya trae la ficha: sin una segunda línea divisoria. */
.amb-ficha__acciones--editor {
  flex-wrap: wrap;
  border-top: 0;
  padding-top: 0;
}

/* El contador de "muebles iguales": el mismo de la tarjeta de Mueble, chico. */
.contador--chico { height: 32px; }
.contador--chico .contador__btn { width: 30px; }
.contador--chico .contador__valor { min-width: 28px; font-size: var(--fs-sm); }

/* ==========================================================================
   Diálogos: elegir un mueble y elegir un electrodoméstico
   ========================================================================== */
.amb-elegir { display: flex; flex-direction: column; gap: var(--s3); }
.amb-elegir__fila { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.amb-elegir__nota {
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  color: var(--ink-3);
  margin: 0;
  max-width: 72ch;
}
.amb-elegir__fam { margin: var(--s2) 0 0; }

/* El esquinero va primero cuando la pared tiene rincón: es lo que se está
   buscando en ese momento, no un mueble más del catálogo. */
.amb-elegir__fam--rincon { margin-top: 0; color: var(--acc-ink); }
.amb-elegir__item--rincon {
  border-color: var(--acc-line);
  background: var(--acc-soft);
}
.amb-elegir__item--rincon .amb-elegir__ico { background: var(--acc-soft-2); color: var(--acc-ink); }

.amb-elegir__anchos { display: flex; flex-wrap: wrap; gap: 4px; }
.amb-elegir__ancho {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  color: var(--ink-3);
  cursor: pointer;
}
.amb-elegir__ancho:hover { border-color: var(--acc); color: var(--acc-ink); }
.amb-elegir__ancho:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--acc); }
.amb-elegir__ancho[aria-pressed="true"] {
  background: var(--acc-soft);
  border-color: var(--acc-line);
  color: var(--acc-ink);
  font-weight: 680;
}
/* Los botones de a uno de los diálogos de colchón y de «Columna o viga»: toque de 36 px. */
.amb-elegir__ancho--toque { height: 36px; }

.amb-elegir__grilla {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
  gap: var(--s2);
}
.amb-elegir__item {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 var(--s2);
  padding: 10px var(--s3);
  min-height: 56px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease-out);
}
.amb-elegir__item:hover { border-color: var(--acc); box-shadow: var(--sh-1); }
.amb-elegir__item:focus-visible { outline: none; border-color: var(--acc); box-shadow: var(--ring); }
.amb-elegir__ico {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--acc-soft);
  color: var(--acc-ink);
}
.amb-elegir__nombre {
  font-size: var(--fs-base);
  font-weight: 620;
  color: var(--ink);
  line-height: var(--lh-tight);
}
.amb-elegir__desc {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  line-height: var(--lh-snug);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Los grupos del diálogo «Electrodoméstico» y las familias del tipo de ambiente:
   el que corresponde al lugar va marcado y primero. */
.amb-elegir__fam--tipo { color: var(--acc-ink); }
.amb-elegir__fam--otros { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); }
.amb-elegir__campos { display: flex; flex-direction: column; gap: var(--s3); }
.amb-elegir__campos .campo { min-width: 120px; flex: 1 1 120px; }
.amb-elegir input[aria-invalid="true"] { border-color: var(--bad); }

/* ==========================================================================
   Estado vacío, primer paso: «¿Qué ambiente es?»
   ========================================================================== */
.amb-tipos {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-content: safe center;
  gap: var(--s6);
  padding: var(--s7) var(--s6);
}
.amb-tipos__grilla {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s4);
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}
.amb-tipo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s5) var(--s4) var(--s4);
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  cursor: pointer;
  text-align: center;
  transition: box-shadow var(--t) var(--ease-out), border-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.amb-tipo:hover {
  border-color: var(--acc-line);
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
}
.amb-tipo:focus-visible { outline: none; border-color: var(--acc); box-shadow: var(--ring); }
.amb-tipo__dibujo {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: var(--r);
  background: var(--acc-soft);
  color: var(--acc-ink);
  border: 1px solid var(--line);
}
.amb-tipo__dibujo svg { width: 40px; height: 40px; display: block; }

/* El segundo paso: la forma que propone el tipo va marcada, y se puede volver. */
.amb-forma { position: relative; }
.amb-forma--sugerida { border-color: var(--acc-line); background: var(--acc-soft); }
.amb-forma__sugerida {
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--acc-ink);
  background: var(--acc-soft-2);
  border-radius: var(--r-sm);
  padding: 2px 8px;
}
.amb-formas__volver {
  align-self: center;
  min-height: 36px;
  padding: 0 var(--s4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-3);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.amb-formas__volver:hover { border-color: var(--acc); color: var(--acc-ink); }
.amb-formas__volver:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--acc); }

/* ==========================================================================
   Plano · 3D

   Con «3D», el lienzo de la izquierda es del 3D grande y la planta queda de
   miniatura abajo a la izquierda: una foto viva, que sigue dibujándose (nunca
   `display:none`). La columna de la derecha pasa a ser el panel «Estilo del
   ambiente», con dos pestañas: Estilo y Ficha.

   Todos los colores salen de tokens.css. Las muestras de las paletas son datos
   y llegan por la variable `--muestra`.
   ========================================================================== */

/* Plano · 3D: el mismo control segmentado de los niveles. */
.amb__vista .amb__nivel { min-width: 58px; }

/* ---- La planta: todo el lienzo en «Plano», miniatura en «3D» ------------- */
.amb__planta {
  position: absolute;
  inset: 0;
}
.amb--3d .amb__planta {
  inset: auto;
  left: 12px;
  bottom: 12px;
  width: 188px;
  height: 128px;
  z-index: 3;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--plan-bg);
  box-shadow: var(--sh-2);
  overflow: hidden;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.amb--3d .amb__planta:hover { border-color: var(--acc); box-shadow: var(--sh-3); }
/* La miniatura no se agarra: un clic en cualquier lado vuelve al plano. */
.amb--3d .amb-planta { pointer-events: none; }

.amb-mini__velo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.amb-mini__velo:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--acc); }
.amb-mini__pie {
  width: 100%;
  padding: 4px 8px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  font-size: var(--fs-xs);
  font-weight: 560;
  text-align: left;
  color: var(--ink-2);
  white-space: nowrap;
}
.amb-mini__velo:hover .amb-mini__pie { color: var(--acc-ink); }

/* ---- El 3D grande ------------------------------------------------------- */
.amb--3d .amb__lienzo > .escena {
  position: absolute;
  inset: 0;
  height: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
}
.amb--3d .amb__lienzo > .escena canvas { display: block; width: 100%; height: 100%; }

/* Lo que se hace con el 3D grande va flotando encima, como la barrita del 3D
   chico: misma caja, mismo vidrio. En «Plano» no existe. */
.amb3d__acciones,
.amb3d__camara { display: none; }
.amb--3d .escena__acciones { display: none; }

.amb--3d .amb3d__acciones,
.amb--3d .amb3d__camara {
  display: flex;
  position: absolute;
  z-index: 2;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(3px);
  box-shadow: var(--sh-1);
}
.amb--3d .amb3d__acciones { top: 10px; right: 10px; gap: 4px; }
.amb--3d .amb3d__camara { right: 10px; bottom: 10px; gap: 2px; }

.amb3d__btn { height: 32px; font-size: var(--fs-sm); padding: 0 11px; }
.amb3d__camara .btn { height: 28px; }
.amb3d__camara .btn[aria-pressed="true"] {
  background: var(--acc-soft);
  color: var(--acc-ink);
}
.amb3d__sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--line);
}
.amb3d__vistas { display: inline-flex; gap: 2px; }
.amb3d__vista {
  height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: calc(var(--r-sm) - 1px);
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}
.amb3d__vista:hover { background: var(--paper-2); color: var(--ink-2); }
.amb3d__vista:focus-visible { outline: none; box-shadow: var(--ring); }
.amb3d__vista[aria-pressed="true"] {
  background: var(--acc-soft);
  color: var(--acc-ink);
  box-shadow: inset 0 0 0 1px var(--acc-line);
}

/* ---- Pantalla completa --------------------------------------------------
   Sólo queda el dibujo, la cámara y la salida. El respaldo (cuando el
   navegador no deja pasar a pantalla completa de verdad) es el mismo lienzo
   ocupando la ventana entera. */
.escena--pc { border: 0; border-radius: 0; }
.escena--pc .amb3d__acciones .btn:not(.amb3d__pantalla) { display: none; }
.escena--overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 900;
  width: auto !important;
  height: auto !important;
  border: 0;
  border-radius: 0;
}

/* ==========================================================================
   Las pestañas y el panel de estilo
   ========================================================================== */
.amb-pestanas,
.amb-est { display: none; }

.amb--3d .amb-pestanas {
  display: flex;
  flex: none;
  gap: 2px;
  padding: var(--s2) var(--s3) 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.amb-pest {
  flex: 1;
  height: 34px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 620;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}
.amb-pest:hover { background: var(--paper-2); color: var(--ink-2); }
.amb-pest:focus-visible { outline: none; box-shadow: var(--ring); }
.amb-pest[aria-selected="true"] {
  color: var(--acc-ink);
  border-bottom-color: var(--acc);
}

.amb--3d .amb-est {
  display: block;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--s3) var(--s3) var(--s5) var(--s4);
}
/* Una sola de las dos a la vez. */
.amb--3d[data-pestana="estilo"] .amb__lado > .amb-ficha { display: none; }
.amb--3d[data-pestana="ficha"] .amb-est { display: none; }

/* ---- Secciones ---------------------------------------------------------- */
.amb-estilo { display: flex; flex-direction: column; }
.amb-estilo__sec {
  padding: var(--s3) 0;
  border-top: 1px solid var(--line);
}
.amb-estilo__sec:first-child { padding-top: 0; border-top: 0; }
.amb-estilo__cab {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.amb-estilo__titulo {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 680;
  color: var(--ink);
}
.amb-estilo__nota {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-align: right;
  line-height: var(--lh-snug);
}
.amb-estilo__pregunta {
  margin: 0 0 6px;
  font-size: var(--fs-xs);
  font-weight: 620;
  color: var(--ink-3);
}
.amb-estilo__fila,
.amb-muestras {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--s2);
}
.amb-estilo__ayuda {
  margin: 0 0 var(--s2);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  color: var(--ink-3);
}
.amb-estilo__nombre {
  margin: 0 0 var(--s2);
  font-size: var(--fs-xs);
  font-weight: 560;
  color: var(--ink-2);
}
.amb-estilo__sep { height: 1px; margin: var(--s3) 0; background: var(--line); }
.amb-estilo__quitar {
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}

/* ---- Estilos listos ----------------------------------------------------- */
.amb-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: var(--s2);
}
.amb-preset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 6px 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  font-family: inherit;
  cursor: pointer;
  min-width: 0;
}
.amb-preset:hover { border-color: var(--acc); }
.amb-preset:focus-visible { outline: none; border-color: var(--acc); box-shadow: var(--ring); }
.amb-preset[aria-pressed="true"] {
  border-color: var(--acc);
  background: var(--acc-soft);
  box-shadow: 0 0 0 2px var(--acc-soft-2);
}
.amb-preset__puntos {
  display: flex;
  height: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  overflow: hidden;
}
.amb-preset__punto { flex: 1; background: var(--muestra); }
.amb-preset__nombre {
  font-size: var(--fs-xs);
  font-weight: 620;
  color: var(--ink-2);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.amb-preset[aria-pressed="true"] .amb-preset__nombre { color: var(--acc-ink); }

/* ---- Muestras de color -------------------------------------------------- */
.amb-muestra {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--muestra);
  box-shadow: inset 0 0 0 2px var(--surface-2);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.amb-muestra:hover { transform: scale(1.1); }
.amb-muestra:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}
.amb-muestra[aria-pressed="true"] {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

/* ---- Chips: opciones de una sola marca --------------------------------- */
.amb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--ink-2);
  cursor: pointer;
}
.amb-chip__txt {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.amb-chip:hover { border-color: var(--acc); color: var(--acc-ink); }
.amb-chip:focus-visible,
.amb-chip:focus-within { outline: none; border-color: var(--acc); box-shadow: var(--ring); }
.amb-chip[aria-pressed="true"],
.amb-chip--on {
  border-color: var(--acc-line);
  background: var(--acc-soft);
  color: var(--acc-ink);
  font-weight: 640;
}
.amb-paredes__punto {
  flex: none;
  width: 11px;
  height: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

/* «Otro…»: el selector de color del sistema, atrás del chip. */
.amb-otro { position: relative; overflow: hidden; }
.amb-otro__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.amb-otro__punto {
  flex: none;
  width: 12px;
  height: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: conic-gradient(var(--bad), var(--warn), var(--ok), var(--steel), var(--bad));
}
.amb-otro--con-color .amb-otro__punto { background-image: none; }

/* ---- Interruptores ------------------------------------------------------ */
.amb-sw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 5px 0;
  cursor: pointer;
}
.amb-sw__txt {
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--ink-2);
}
.amb-sw--apagado { opacity: .5; cursor: default; }
.amb-sw--apagado .switch input { cursor: default; }

/* El interruptor que hace de título de su sección (la bacha): ocupa todo el
   renglón de la cabecera y el texto se lee como un título. */
.amb-sw--cab { flex: 1; padding: 0; }
.amb-sw--cab .amb-sw__txt { font-weight: 680; color: var(--ink); }

/* La sección a la que se llega tocando algo del dibujo: se destaca un instante
   para que se vea dónde cayó el scroll. */
.amb-estilo__sec--destacada {
  border-radius: var(--r-sm);
  animation: amb-destello 1.5s var(--ease) both;
}
@keyframes amb-destello {
  0%, 65% { background-color: var(--acc-soft-2); box-shadow: 0 0 0 8px var(--acc-soft-2); }
  100% { background-color: transparent; box-shadow: 0 0 0 8px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .amb-estilo__sec--destacada {
    animation: none;
    background-color: var(--acc-soft-2);
    box-shadow: 0 0 0 8px var(--acc-soft-2);
  }
}

/* ---- Bacha -------------------------------------------------------------- */
.amb-flecha {
  width: 38px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
}
.amb-flecha:hover { border-color: var(--acc); color: var(--acc-ink); }
.amb-flecha:focus-visible { outline: none; border-color: var(--acc); box-shadow: var(--ring); }
.amb-flecha:disabled {
  opacity: .4;
  cursor: default;
  border-color: var(--line-2);
  color: var(--ink-3);
}
/* Las flechas de la ficha de un hueco (el anafe…): más grandes que las de la
   bacha, que viven en un panel aparte. */
.amb-ficha__correr { display: flex; flex-wrap: wrap; gap: 4px; }
.amb-flecha.amb-flecha--ficha { width: 44px; height: 36px; font-size: var(--fs-sm); }
.amb-bacha__dist {
  margin-left: 4px;
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
/* Con dos bachas: elegir cuál se maneja, y sumar la segunda. */
.amb-bacha__otra { align-self: flex-start; min-height: 36px; margin-top: var(--s2); }
.amb-bacha__elegir .amb-chip { height: 36px; padding: 0 14px; }
/* Lo que separa a un mueble de la pared (isla o península), en su ficha. */
.amb-ficha__isla { display: flex; flex-direction: column; gap: var(--s3); }
.amb-ficha__isla .amb__nivel { height: 36px; }

/* Un enlace chico, como «Cargar o editar placas» de la ficha. */
.amb-link {
  align-self: flex-start;
  margin: 0 0 var(--s1);
  padding: 2px 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-xs);
  color: var(--acc-ink);
  text-decoration: underline;
  text-decoration-color: var(--acc-line);
  text-underline-offset: 2px;
  cursor: pointer;
}
.amb-link:hover { color: var(--acc); }
.amb-link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ==========================================================================
   Pantallas angostas (la notebook de taller, 1366 y menos)
   ========================================================================== */
@media (max-width: 1180px) {
  .amb__lado { width: 268px; }
  .amb__pared { width: 104px; }
  .amb__nivel { min-width: 58px; padding: 0 9px; }
  /* Con el lienzo más angosto la cámara no entra al lado de la miniatura:
     se apoya arriba de ella. */
  .amb--3d .amb3d__camara { bottom: 152px; }
}

/* Más angosto que esto las dos mitades no caben una al lado de la otra: el 3D
   pasa abajo de la planta, apoyado a la ficha, y nada scrollea para el costado. */
@media (max-width: 900px) {
  .amb__cuerpo { flex-direction: column; }
  .amb__lado {
    width: auto;
    flex-direction: row;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 46%;
  }
  .amb__lado .escena {
    width: 44%;
    height: auto;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .amb__izq { min-height: 240px; }
}

/* Alto chico: la planta se queda con lo que hay y el 3D se achica. */
@media (max-height: 720px) {
  .amb__lado .escena { height: 32%; min-height: 128px; }
  .amb--3d .amb__planta { width: 156px; height: 106px; }
}

/* Las dos pantallas de elegir (qué ambiente es y cómo es el lugar) se compactan antes, con una
   ventana de hasta 800 px de alto: una pantalla de 1366×768 con la barra de tareas deja poco más
   de 720 px y el botón «Cambiar el ambiente» quedaba cortado contra la barra de estado. */
@media (max-height: 800px) {
  .amb-formas, .amb-tipos { justify-content: flex-start; padding-top: var(--s5); }
  .amb-forma__dibujo { width: 88px; height: 88px; }
}

/* Angosto y bajo a la vez: la cámara se apoya arriba de la miniatura chica. */
@media (max-width: 1180px) and (max-height: 720px) {
  .amb--3d .amb3d__camara { bottom: 126px; }
}

/* La barra de cámara (con «Girar solo», «Ver herrajes» y las tres vistas) mide ~600 px con texto: en un
   lienzo de ~570 px (1200 de ventana) se salía por la izquierda. Antes que las demás, queda con los dibujitos. */
@media (max-width: 1259px) {
  .amb--3d .amb3d__camara .btn__txt { display: none; }
}

/* Con la ventana angosta los botones flotantes del 3D quedan sólo con el
   dibujito (cada uno trae su título). En pantalla completa «Salir» se lee. */
@media (max-width: 1180px) {
  .amb--3d .amb3d__acciones .btn__txt,
  .amb--3d .amb3d__camara .btn__txt { display: none; }
  .amb--3d .escena--pc .amb3d__acciones .btn__txt { display: inline; }
}
