/* ============================================================
   REPLIKA EDITOR — piel del editor de capas (paso 5 · Diseño)

   Tres zonas: barra superior, cuerpo (rail de herramientas · lienzo ·
   panel derecho) y nada más. El lienzo es un contenedor recortado con el
   documento dentro, posicionado en absoluto y escalado por transform: el
   zoom y el desplazamiento no tocan el layout, así que mover la portada
   no obliga a recalcular la página entera.

   El editor ocupa SIEMPRE toda la sección: no hay modo ventana ni botón
   para alternar. A cambio, la barra de pasos se oculta y la navegación
   hacia atrás y hacia delante vive dentro de la propia barra del editor.
   ============================================================ */

/* El panel de Diseño rompe el tope de 980px del resto de pasos y sangra
   hasta los bordes del área de contenido: el editor necesita todo el ancho
   que haya, y con el margen de siempre se quedaba en una columna estrecha. */
#cvPanelDesign {
  max-width: none;
  width: auto;
  margin-inline: calc(-1 * var(--content-pad-x, 24px));
  padding-bottom: 0;
}

/* ---- El editor llena la sección ----
   `flex: 1` solo reparte hueco si el contenedor tiene un alto DEFINIDO, y en
   este shell no lo había: body es una rejilla con `min-height`, así que la fila
   crecía con el contenido y nadie ponía techo. Se fija la columna principal a
   la ventana mientras se edita. Va sobre .app-main y no sobre .content para no
   depender del alto real de la barra superior, que en móvil crece con el área
   segura del dispositivo.

   La cadena de `min-height: 0` hasta .rke es la otra mitad imprescindible: sin
   ella un hijo flexible nunca encoge por debajo de su contenido, la columna
   crece y vuelve el scroll (y con él, el hueco sobrante). */
/* OJO con el `:not([hidden])` de estos selectores. La clase `is-editing` no se
   quita al cambiar de sección (así se recupera el estado al volver), y sin ese
   filtro pasaban dos cosas: el `display: flex` de abajo le ganaba al
   `.cover-view[hidden] { display: none }` de app.css —misma especificidad, hoja
   posterior— y el editor se quedaba flotando encima de Agent X o de Inicio; y
   además .app-main seguía clavada a 100dvh en vistas que sí necesitan crecer. */
.app-main:has(.cover-view.is-editing:not([hidden])) { height: 100dvh; }
.app-main:has(.cover-view.is-editing:not([hidden])) > .content {
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}
/* Salvo en móvil, donde ese hueco de abajo es la barra de pestañas: el editor
   llega justo hasta ella, no por debajo. */
@media (max-width: 640px) {
  .app-main:has(.cover-view.is-editing:not([hidden])) > .content {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
  }
}

.cover-view.is-editing {
  flex: 1 1 auto;
  min-height: 0;
  display: flex; flex-direction: column;
  animation: none;              /* la entrada 'rise' desplaza el lienzo al medir */
}
.cover-view.is-editing #cvPanelDesign {
  flex: 1 1 auto;
  min-height: 0;
  display: flex; flex-direction: column;
}
.cover-view.is-editing .rke { flex: 1 1 auto; min-height: 0; }

/* Todo el chrome del paso se recoge: cabecera de la sección, barra de pasos y
   pista. Son ~180px que el lienzo aprovecha mejor, y el editor ya trae su
   propia navegación (Volver a Editar · Continuar a Exportar). */
.cover-view.is-editing .cvx-head,
.cover-view.is-editing .cvw,
.cover-view.is-editing .cvw-hint { display: none; }

/* Sin barra de pasos encima, el aire superior de .content sobra. En ≤640px NO
   se toca: ahí la píldora de proyecto flota bajo la barra superior y ese hueco
   es justo lo que evita que tape la barra del editor (regla propia con 56px
   literales, que sigue mandando sobre esta variable). */
.content:has(> .cover-view.is-editing:not([hidden])) { --content-pad-t: 0px; }

.rke {
  display: flex; flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  overflow: hidden;
  contain: layout paint;
}

/* ---------- barra superior ----------
   Tres zonas: identidad + salida a la izquierda, controles al centro y las
   acciones que sacan del paso a la derecha. Los botones NO van sueltos: cada
   familia (historial, zoom, ayudas de vista) vive en su propia píldora, que es
   lo que hace legible una barra con doce iconos. */
.rke-bar {
  flex: none;
  display: flex; align-items: center; gap: 14px;
  height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}
.rke-bar-l { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 0; }
.rke-bar-c { display: flex; align-items: center; gap: 8px; flex: none; }
.rke-bar-r { display: flex; align-items: center; gap: 8px; flex: 1 1 0; justify-content: flex-end; }

.rke-id { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.rke-brand {
  font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: .16em; text-transform: uppercase; color: var(--text-secondary);
  white-space: nowrap;
}
.rke-docsize {
  font-size: 0.62rem; color: var(--text-faint); white-space: nowrap;
  padding: 2px 7px; border-radius: var(--radius-full);
  background: var(--bg-subtle); border: 1px solid var(--border-subtle);
}
.rke-bar-sep { width: 1px; height: 20px; background: var(--border-subtle); flex: none; }

/* Volver: texto además de icono. Es la única salida hacia atrás que queda
   visible, así que no puede depender de que se adivine una flecha. */
.rke-back {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px 0 10px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
  background: transparent; color: var(--text-secondary);
  font-family: inherit; font-size: 0.78rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; flex: none;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.rke-back svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rke-back:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }

/* Píldora de grupo: fondo hundido y los botones dentro, sin bordes propios */
.rke-grp {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.rke-ib {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: var(--radius-full);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.rke-ib svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rke-ib:hover { background: var(--surface); color: var(--text); }
.rke-ib:disabled { opacity: .28; cursor: default; }
.rke-ib:disabled:hover { background: transparent; color: var(--text-secondary); }
.rke-ib.is-on { background: var(--text); color: var(--bg); }
/* variante pequeña, para las rejillas de iconos del panel de propiedades */
.rke-ib-s {
  width: 27px; height: 27px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
}
.rke-ib-s svg { width: 14px; height: 14px; }
.rke-ib-s:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.rke-zval {
  min-width: 50px; height: 28px; padding: 0 4px;
  border: 0; border-radius: var(--radius-full);
  background: transparent; color: var(--text);
  font-family: var(--font-mono); font-size: 0.68rem; cursor: pointer;
  transition: background var(--dur-fast);
}
.rke-zval:hover { background: var(--surface); }

.rke-go {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 8px 0 16px;
  border: 0; border-radius: var(--radius-full);
  background: var(--text); color: var(--bg);
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex: none;
  transition: opacity var(--dur-fast), transform var(--dur-fast) var(--ease-out-cine);
}
.rke-go:hover { opacity: .9; transform: translateX(1px); }
.rke-go svg {
  width: 24px; height: 24px; padding: 4px; flex: none;
  border-radius: 50%; background: color-mix(in srgb, var(--bg) 18%, transparent);
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- cuerpo ---------- */
.rke-body {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 296px;
}

.rke-tools {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0;
  border-right: 1px solid var(--border-subtle);
  background: var(--surface);
}
.rke-tool {
  position: relative;
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.rke-tool svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rke-tool:hover { background: var(--surface-hover); color: var(--text); }
.rke-tool.is-on { background: var(--text); color: var(--bg); }
.rke-tool-sep { width: 18px; height: 1px; background: var(--border-subtle); margin: 5px 0; flex: none; }

/* Etiqueta al pasar el ratón: el rail es solo iconos y a 34px no cabe texto,
   pero sin nombre nadie adivina "elipse" de un óvalo. */
.rke-tool::after {
  content: attr(title);
  position: absolute; left: calc(100% + 8px); top: 50%;
  transform: translateY(-50%) translateX(-4px);
  padding: 4px 9px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg);
  font-size: 0.7rem; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none; z-index: 5;
  transition: opacity var(--dur-fast), transform var(--dur-fast) var(--ease-out-cine);
}
.rke-tool:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ---------- lienzo ---------- */
.rke-canvas {
  position: relative;
  overflow: hidden;
  min-width: 0; min-height: 0;
  /* damero: se ve por donde el documento sea transparente */
  background-color: #1e1e1e;
  background-image:
    linear-gradient(45deg, #262626 25%, transparent 25%, transparent 75%, #262626 75%),
    linear-gradient(45deg, #262626 25%, transparent 25%, transparent 75%, #262626 75%);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
  touch-action: none;
  cursor: default;
}
.rke-canvas.is-draw { cursor: crosshair; }
.rke-canvas.is-pan { cursor: grab; }

.rke-doc {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  overflow: hidden;               /* lo que sobresale de la mesa no se ve ni se exporta */
  background: #000;
  /* sin isolation, mix-blend-mode de las capas se mezclaría con el damero
     del fondo en vez de con las capas de abajo */
  isolation: isolate;
}


.rke-layer {
  position: absolute;
  transform-origin: center center;
  will-change: transform;
}
.rke-layer > img,
.rke-layer > svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.rke-layer > img { object-fit: fill; }
.rke-layer-t {
  display: flex; flex-direction: column; justify-content: flex-start;
  white-space: pre; overflow: visible;
  -webkit-user-select: none; user-select: none;
}
.rke-line { display: block; }

/* Escribiendo sobre el lienzo: aquí sí hay cursor y selección, y el salto de
   línea lo hace el navegador (fuera del modo edición se pinta línea a línea
   con el reparto medido, que es el que se exporta). */
.rke-layer-t.is-editing {
  display: block;
  white-space: pre-wrap; word-break: normal;
  -webkit-user-select: text; user-select: text;
  cursor: text;
  outline: 2px dashed color-mix(in srgb, var(--ink-000, #fff) 78%, transparent);
  outline-offset: 6px;
  caret-color: currentColor;
}
.rke-layer-t.is-editing:focus { outline-style: solid; }
/* la caja de selección estorba mientras se escribe: el contorno ya la sustituye */
.rke-canvas:has(.rke-layer-t.is-editing) .rke-sel { display: none; }

/* guías de alineación mientras se arrastra */
.rke-guides { position: absolute; inset: 0; pointer-events: none; }
.rke-guide { position: absolute; background: #FF3B6B; }
.rke-guide-v { top: 0; bottom: 0; width: 2px; margin-left: -1px; }
.rke-guide-h { left: 0; right: 0; height: 2px; margin-top: -1px; }

.rke-gridlines {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.16) 1px, transparent 1px);
  background-size: 10% 10%;
}
.rke-gridlines[hidden] { display: none; }

/* ---------- caja de selección ----------
   Vive fuera del documento escalado: así los tiradores miden siempre lo
   mismo en pantalla, tanto al 8% como al 400%. */
.rke-sel {
  position: absolute;
  transform-origin: center center;
  pointer-events: none;
  outline: 1.5px solid var(--ink-000, #fff);
  outline-offset: 0;
}
/* Halo oscuro por fuera, para que el marco blanco se lea también sobre una
   foto clara. Iba como box-shadow, que en esta app no pinta nada: hay un
   `box-shadow: none !important` global. */
.rke-sel::before {
  content: "";
  position: absolute; inset: -2.5px;
  border: 1px solid rgba(0,0,0,.45);
  pointer-events: none;
}
.rke-sel[hidden] { display: none; }
.rke-sel.is-locked { outline-style: dashed; }
.rke-sel.is-locked .rke-h { display: none; }

.rke-h {
  position: absolute;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  background: #fff; border: 1px solid #111; border-radius: 2px;
  pointer-events: auto;
}
.rke-h-nw { left: 0; top: 0; cursor: nwse-resize; }
.rke-h-n  { left: 50%; top: 0; cursor: ns-resize; }
.rke-h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.rke-h-e  { left: 100%; top: 50%; cursor: ew-resize; }
.rke-h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.rke-h-s  { left: 50%; top: 100%; cursor: ns-resize; }
.rke-h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.rke-h-w  { left: 0; top: 50%; cursor: ew-resize; }
.rke-h-rot {
  left: 50%; top: -26px;
  width: 12px; height: 12px; border-radius: 50%;
  cursor: grab;
}

.rke-drop {
  position: absolute; inset: 14px;
  display: grid; place-items: center;
  border: 2px dashed rgba(255,255,255,.5); border-radius: var(--radius-lg);
  background: rgba(8,8,10,.55);
  color: #fff; font-size: var(--fs-body-s);
  pointer-events: none;
}
.rke-drop[hidden] { display: none; }

/* ---------- panel derecho ----------
   Va por bloques con cabecera, no como una lista corrida de controles: antes
   todo tenía el mismo peso visual y no se veía dónde acababa una cosa y
   empezaba la siguiente. Cada bloque = un titular en mono + su contenido,
   separados por una línea de pelo. */
.rke-side {
  border-left: 1px solid var(--border-subtle);
  background: var(--surface);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 0 28px;
  display: flex; flex-direction: column;
  min-width: 0;
}
/* El panel es la caja que se desplaza; sus bloques miden lo que midan. Sin
   esto, el flex los encoge y la lista de capas se quedaba a 0 de alto. */
.rke-side > * { flex: 0 0 auto; }

.rke-block {
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.rke-block-h {
  margin: 0;
  font-family: var(--font-mono); font-size: 0.58rem;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-faint);
}

.rke-quick-row { display: flex; flex-wrap: wrap; gap: 6px; }

.rke-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
  background: var(--bg-subtle); color: var(--text-secondary);
  font-family: inherit; font-size: 0.75rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast),
              border-color var(--dur-fast), transform var(--dur-fast) var(--ease-out-cine);
}
.rke-chip:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.rke-chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }
.rke-chip svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rke-chip-x:hover { color: var(--error); border-color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); }
.rke-chip-w { align-self: flex-start; }

/* ---------- controles de formulario ----------
   Un solo lenguaje para select, número, texto y color: misma altura, mismo
   fondo hundido y el mismo aro al enfocar. Antes cada uno traía su estilo
   nativo y el panel parecía cosido a trozos. */
.rke-selw { position: relative; display: block; min-width: 0; }
.rke-chev {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; pointer-events: none; color: var(--text-faint);
}
.rke-chev svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.rke-sel-in, .rke-in, .rke-ta, .rke-color {
  width: 100%;
  border: 1px solid var(--border-subtle); border-radius: 8px;
  background: var(--bg-subtle); color: var(--text);
  font-family: inherit; font-size: 0.76rem;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.rke-sel-in:hover, .rke-in:hover, .rke-ta:hover, .rke-color:hover { border-color: var(--border-strong); }
.rke-sel-in:focus-visible, .rke-in:focus-visible, .rke-ta:focus-visible {
  outline: none; border-color: var(--text);
}
.rke-sel-in {
  height: 30px; padding: 0 26px 0 9px;
  -webkit-appearance: none; appearance: none;
  cursor: pointer; text-transform: capitalize;
}
.rke-sel-in:disabled { opacity: .4; cursor: default; }
.rke-in { height: 30px; padding: 0 8px; font-family: var(--font-mono); font-size: 0.72rem; }
.rke-in:disabled { opacity: .4; }
/* las flechas nativas del input number roban 20px y casi nunca se usan */
.rke-in::-webkit-outer-spin-button, .rke-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rke-in[type="number"] { -moz-appearance: textfield; }
.rke-ta { min-height: 52px; padding: 7px 9px; line-height: 1.45; resize: vertical; }
.rke-color { height: 30px; padding: 3px; cursor: pointer; }
.rke-color::-webkit-color-swatch-wrapper { padding: 0; }
.rke-color::-webkit-color-swatch { border: 0; border-radius: 5px; }

.rke-duo { display: flex; gap: 6px; }
.rke-duo > * { flex: 1 1 0; min-width: 0; }

/* ---------- deslizadores ----------
   Mismo dibujo que el zoom de Imagen Premium: raíl fino, pulgar sólido. Los
   nativos de cada navegador eran tres estilos distintos en el mismo panel. */
.rke-sl { display: flex; align-items: center; gap: 8px; }
.rke-sl input[type="range"] { flex: 1 1 auto; min-width: 0; }
/* El valor es un campo, no una etiqueta: se puede teclear un número exacto.
   Se disimula (sin fondo ni borde) hasta que lo tocas, para que siga leyéndose
   como la lectura del deslizador y no como un formulario más. */
.rke-num {
  flex: 0 0 46px; width: 46px;
  padding: 3px 4px;
  text-align: right;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 0.68rem;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.rke-num:hover { background: var(--bg-subtle); border-color: var(--border-subtle); color: var(--text); }
.rke-num:focus {
  outline: none;
  background: var(--bg-subtle); border-color: var(--text); color: var(--text);
}
.rke-num::-webkit-outer-spin-button, .rke-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rke-num[type="number"] { -moz-appearance: textfield; }
.rke-side input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 16px; background: transparent; cursor: pointer;
}
.rke-side input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: var(--radius-full); background: var(--border);
}
.rke-side input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; margin-top: -4.5px;
  border: 0; border-radius: 50%; background: var(--text);
  transition: transform var(--dur-fast);
}
.rke-side input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.18); }
.rke-side input[type="range"]:disabled::-webkit-slider-thumb { background: var(--text-faint); }
.rke-side input[type="range"]::-moz-range-track {
  height: 3px; border-radius: var(--radius-full); background: var(--border);
}
.rke-side input[type="range"]::-moz-range-progress {
  height: 3px; border-radius: var(--radius-full); background: var(--text-muted);
}
.rke-side input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text);
}
.rke-side input[type="range"]:focus-visible {
  outline: 2px solid var(--border-strong); outline-offset: 4px; border-radius: var(--radius-full);
}

/* ---------- lista de capas ---------- */
.rke-list {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 32vh; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -4px; padding: 0 4px;
}
.rke-item {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 7px;
  border: 1px solid transparent; border-radius: 9px;
  color: var(--text-secondary); font-size: 0.76rem;
  cursor: pointer; touch-action: none;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.rke-item:hover { background: var(--surface-hover); color: var(--text); }
.rke-item.is-sel {
  background: color-mix(in srgb, var(--text) 9%, transparent);
  border-color: var(--border-strong); color: var(--text);
}
.rke-item-n { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rke-rename {
  width: 100%; height: 22px; padding: 0 5px;
  border: 1px solid var(--text); border-radius: 5px;
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 0.76rem;
}
.rke-th {
  width: 26px; height: 26px; flex: none;
  border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border-subtle); background: var(--bg-subtle);
  display: grid; place-items: center;
}
.rke-th img { width: 100%; height: 100%; object-fit: cover; }
.rke-th-t { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text); }
.rke-th-s { border-width: 2px; }
/* La portada se lee como el suelo de la pila, no como una capa cualquiera */
.rke-item.is-base .rke-item-n { color: var(--text); font-weight: 550; }

.rke-mini {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-faint); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.rke-mini svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rke-mini:hover { background: var(--bg-subtle); color: var(--text); }
.rke-mini-x:hover { color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); }

/* ---------- propiedades ---------- */
.rke-props { display: flex; flex-direction: column; gap: 14px; }
.rke-empty { margin: 2px 0; font-size: 0.78rem; color: var(--text-muted); }
.rke-group { display: flex; flex-direction: column; gap: 8px; }
.rke-group + .rke-group { padding-top: 13px; border-top: 1px solid var(--border-subtle); }
.rke-glbl {
  margin: 0 0 1px;
  font-family: var(--font-mono); font-size: 0.56rem;
  letter-spacing: .16em; text-transform: uppercase; color: var(--text-faint);
}

.rke-row { display: flex; align-items: center; gap: 10px; }
.rke-row-l {
  flex: 0 0 60px; min-width: 0;
  font-size: 0.72rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rke-row > *:not(.rke-row-l) { flex: 1 1 auto; min-width: 0; }

.rke-btns { display: flex; flex-wrap: wrap; gap: 5px; }
.rke-btns .rke-chip { padding: 5px 10px; min-width: 34px; justify-content: center; }
.rke-presets { display: flex; flex-wrap: wrap; gap: 5px; }
.rke-presets .rke-chip { padding: 4px 9px; font-size: 0.7rem; }
.rke-acts { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 13px; border-top: 1px solid var(--border-subtle); }

/* ---------- responsive ----------
   Por debajo de 1100px el panel derecho se estrecha; por debajo de 860 el
   editor pasa a columna (lienzo arriba, controles abajo), que es lo único
   usable con el dedo. */
@media (max-width: 1100px) {
  .rke-body { grid-template-columns: 46px minmax(0, 1fr) 258px; }
  .rke-row-l { flex-basis: 52px; }
  .rke-block { padding: 12px 11px 14px; }
  /* el nombre del documento es lo primero que sobra cuando falta ancho */
  .rke-docsize { display: none; }
}
@media (max-width: 860px) {
  .rke-body {
    grid-template-columns: 46px minmax(0, 1fr);
    grid-template-rows: minmax(240px, 1fr) minmax(0, 46%);
  }
  .rke-tools { grid-row: 1; grid-column: 1; }
  .rke-canvas { grid-row: 1; grid-column: 2; }
  .rke-side {
    grid-row: 2; grid-column: 1 / -1;
    border-left: 0; border-top: 1px solid var(--border-subtle);
  }
  .rke-list { max-height: 26vh; }
  /* el rail no tiene sitio a la derecha para su etiqueta */
  .rke-tool::after { display: none; }

  /* La barra pasa a dos filas: identidad y acciones arriba, controles abajo
     centrados. Antes envolvía sin orden y los grupos quedaban descolgados. */
  .rke-bar { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  .rke-bar-l { order: 1; flex: 1 1 auto; }
  .rke-bar-r { order: 2; flex: 0 0 auto; }
  .rke-bar-c {
    order: 3; width: 100%; justify-content: center; gap: 6px;
    padding-top: 8px; border-top: 1px solid var(--border-subtle);
  }
  .rke-brand { display: none; }        /* el título lo da la propia sección */
  .rke-back { padding: 0 12px 0 9px; }
}
@media (max-width: 420px) {
  .rke-back span { display: none; }    /* a 375px solo cabe la flecha */
  .rke-back { width: 32px; padding: 0; justify-content: center; }
  .rke-go { padding: 0 6px 0 12px; font-size: 0.78rem; }
}

/* En claro el lienzo sigue siendo oscuro (es el estándar de cualquier
   editor: el gris neutro no falsea el color de la obra), pero el resto del
   chrome usa los tokens del tema. */

