:root {
  --naranja: #f77f00; --naranja-hondo: #f26400; --naranja-suave: #fff1e3;
  --noche: #141719; --grafito: #1f2326; --papel: #f6f6f4; --borde: #e3e3df;
  --texto: #1f2326; --apagado: #6b7075; --rojo: #c62828; --verde: #2e7d32;
  --radio: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--papel); color: var(--texto); font: 15px/1.5 Inter, system-ui, sans-serif; }
h1, h2, h3 { font-family: Poppins, Inter, sans-serif; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
a { color: var(--naranja-hondo); }
code { background: #eceae6; padding: .1em .35em; border-radius: 4px; font-size: .9em; }
.apagado { color: var(--apagado); }
.chico { font-size: .85rem; }
.ok { background: #e8f5e9; color: var(--verde); padding: .6rem .8rem; border-radius: 8px; }
.error { background: #fdecea; color: var(--rojo); padding: .6rem .8rem; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--naranja); outline-offset: 2px; }

/* barra superior */
.barra { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.5rem; padding: .55rem 1.25rem; background: var(--noche); color: #fff; flex-wrap: wrap; }
.barra-marca { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 600; }
.barra-marca img { height: 26px; }
.barra-marca span { color: var(--naranja); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.barra nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.barra nav a { color: #cfd2d4; text-decoration: none; font-weight: 500; }
.barra nav a:hover { color: #fff; }
.barra-acciones { display: flex; align-items: center; gap: .75rem; }
.barra-acciones form { margin: 0; }
.estado { font-size: .8rem; padding: .2rem .6rem; border-radius: 99px; white-space: nowrap; }
.estado.pendiente { background: #4a3315; color: #ffc27a; }
.estado.al-dia { background: #1f3b24; color: #9be0a3; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--borde); background: #fff; color: var(--texto); padding: .55rem 1rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #c9c9c4; }
.btn.principal { background: var(--naranja); border-color: var(--naranja); color: #fff; }
.btn.principal:hover { background: var(--naranja-hondo); }
.btn.texto { background: none; border: none; color: inherit; opacity: .8; }
.btn.peligro { color: var(--rojo); }
.btn.grande { width: 100%; padding: .8rem; font-size: 1rem; }
.btn.chico { padding: .35rem .7rem; font-size: .85rem; }
.btn.texto.chico { padding: .3rem .4rem; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-icono { border: none; background: none; cursor: pointer; padding: .35rem .45rem; border-radius: 6px; color: var(--apagado); font-size: 1rem; line-height: 1; }
.btn-icono:hover { background: #eceae6; color: var(--texto); }
.btn-icono.peligro:hover { color: var(--rojo); background: #fdecea; }

/* estructura */
.contenido { max-width: 980px; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; }
.encabezado { margin-bottom: 1.5rem; }
.volver { font-size: .9rem; text-decoration: none; }
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem 1.25rem; margin-bottom: 1rem; }

/* formularios */
label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: .85rem; }
input:not([type=checkbox]):not([type=color]):not([type=file]), textarea, select {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid #d6d6d1; border-radius: 7px; font: inherit; font-weight: 400; background: #fff; color: var(--texto);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--naranja); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }
.ayuda { display: block; font-weight: 400; color: var(--apagado); font-size: .8rem; margin-top: .2rem; }
label.casilla { display: flex; align-items: center; gap: .5rem; }
fieldset { border: 1px solid var(--borde); }
legend { font-weight: 600; font-family: Poppins, sans-serif; padding: 0 .3rem; }
.etiqueta { display: block; font-weight: 500; font-size: .9rem; margin-bottom: .35rem; }

/* acceso */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--noche); }
.tarjeta-acceso { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 2rem; }
.logo-acceso { height: 34px; background: var(--noche); padding: .5rem .8rem; border-radius: 8px; margin-bottom: 1.25rem; }
.tarjeta-acceso h1 { font-size: 1.3rem; }
.qr { display: block; margin: .5rem auto 1rem; border: 1px solid var(--borde); border-radius: 8px; }
.pasos-config { padding-left: 1.2rem; }

/* tablero */
.titulo-grupo { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--apagado); font-weight: 600; margin: 1.5rem 0 .6rem; }
.rejilla-paginas { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; }
.tarjeta-pagina { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; color: var(--texto); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.tarjeta-pagina:hover { border-color: var(--naranja); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.tarjeta-pagina img, .tarjeta-pagina .sin-foto { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; background: #eceae6; display: block; }
.tarjeta-pagina .texto-tarjeta { display: flex; flex-direction: column; gap: .15rem; padding: .75rem .9rem .85rem; }
.tarjeta-pagina .ruta { font-size: .78rem; color: var(--apagado); font-family: ui-monospace, monospace; }
.tarjeta-pagina .ir { color: var(--naranja-hondo); font-weight: 600; font-size: .88rem; margin-top: .25rem; }
.lista-fijas { list-style: none; padding: 0; margin: 0; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); }
.lista-fijas li + li { border-top: 1px solid var(--borde); }
.lista-fijas a { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem .9rem; color: var(--texto); text-decoration: none; }
.lista-fijas a:hover { background: var(--papel); }
.lista-fijas .ruta { color: var(--apagado); font-family: ui-monospace, monospace; font-size: .8rem; }

/* editor de una página: lista o formulario a la izquierda, vista previa en vivo a la derecha */
body.con-editor { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 440px) 1fr; }
.lado { display: flex; flex-direction: column; min-height: 0; background: #fff; border-right: 1px solid var(--borde); }
.lado-cabeza { padding: .8rem 1.1rem .75rem; border-bottom: 1px solid var(--borde); }
.lado-titulo { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; margin-top: .15rem; }
.lado-titulo h1 { font-size: 1.25rem; margin: 0; }
.guardado { font-size: .8rem; color: var(--apagado); white-space: nowrap; }
.guardado.listo { color: var(--verde); }
.guardado.esperando { color: #9a6200; }
.guardado.mal { color: var(--rojo); font-weight: 600; }
.lado-cuerpo { flex: 1; overflow-y: auto; padding: .9rem 1.1rem 2rem; }
.solo-movil { display: none; }

.fila-seo { display: block; width: 100%; text-align: left; border: 1px solid var(--borde); background: var(--papel); border-radius: 8px; padding: .6rem .75rem; cursor: pointer; font: inherit; color: inherit; }
.fila-seo:hover { border-color: var(--naranja); }
.fila-seo strong { display: block; font-size: .9rem; }
.fila-seo span { display: block; color: var(--apagado); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista-etiqueta { margin: 1.1rem 0 .4rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--apagado); font-weight: 600; }
.filas { list-style: none; margin: 0 0 .8rem; padding: 0; }
.fila { display: flex; align-items: center; gap: .3rem; border-radius: 8px; padding: .2rem .2rem .2rem 0; }
.fila:hover { background: var(--papel); }
.fila.oculto .fila-abrir { opacity: .5; }
.fila.arrastrando { opacity: .4; }
.fila.sobre { box-shadow: inset 0 3px 0 var(--naranja); }
.asa { cursor: grab; color: #b3b3ad; font-size: 1.05rem; padding: .3rem .15rem .3rem .3rem; user-select: none; }
.fila-abrir { flex: 1; min-width: 0; display: flex; align-items: center; gap: .65rem; border: none; background: none; padding: .2rem; text-align: left; cursor: pointer; font: inherit; color: inherit; border-radius: 6px; }
.fila-abrir img, .miniatura-vacia { width: 52px; height: 38px; flex: none; border-radius: 5px; object-fit: cover; background: #eceae6; }
.miniatura-vacia { display: grid; place-items: center; color: var(--apagado); font-size: .9rem; }
.fila-texto { min-width: 0; }
.fila-texto strong { display: block; font-size: .9rem; font-weight: 600; }
.fila-texto span { display: block; color: var(--apagado); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marca-oculto { font-size: .7rem; background: #eceae6; padding: .1rem .45rem; border-radius: 99px; color: var(--apagado); }
.agregar-bloque { width: 100%; border-style: dashed; }
.apagado-icono { opacity: .5; }

.detalle-cabeza { position: sticky; top: -.9rem; z-index: 2; background: #fff; margin: -.9rem -1.1rem 1rem; padding: .6rem 1.1rem .7rem; border-bottom: 1px solid var(--borde); }
.volver-lista { padding: .2rem 0; font-size: .85rem; color: var(--naranja-hondo); opacity: 1; }
.detalle-titulo { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.detalle-titulo h2 { font-size: 1.05rem; margin: 0; }
.detalle-acciones { display: flex; gap: .1rem; }
.nota-oculto { background: #eceae6; padding: .5rem .7rem; border-radius: 7px; font-size: .85rem; }
.formulario label, .formulario .campo { margin-bottom: 1rem; }

.campo-imagen { display: flex; gap: .75rem; align-items: center; }
.miniatura { width: 132px; height: 88px; flex: none; padding: 0; border: 1px dashed #c9c9c4; border-radius: 8px; background: #eceae6; overflow: hidden; cursor: pointer; color: var(--apagado); font: inherit; font-size: .8rem; }
.miniatura:hover { border-color: var(--naranja); }
.miniatura img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imagen-datos { min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.ruta-imagen { font-size: .8rem; color: var(--apagado); font-family: ui-monospace, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.botones-imagen { display: flex; gap: .3rem; }

.lista-campo { margin: 0 0 1.1rem; }
.elemento { border: 1px solid var(--borde); border-radius: 8px; margin-bottom: .4rem; background: #fff; }
.elemento.abierto { border-color: #d0cfca; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.elemento-cabeza { display: flex; align-items: center; gap: .25rem; padding: .3rem .4rem; cursor: pointer; border-radius: 8px; }
.elemento-cabeza:hover { background: var(--papel); }
.elemento-mini { width: 40px; height: 30px; flex: none; border-radius: 4px; object-fit: cover; background: #eceae6; }
.numero { width: 22px; text-align: center; color: var(--apagado); font-size: .85rem; flex: none; }
.elemento-nombre { flex: 1; min-width: 0; font-size: .88rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: .3rem; }
.elemento-cabeza .btn-icono { padding: .3rem .35rem; font-size: .85rem; }
.flecha { color: var(--apagado); width: 1rem; text-align: center; }
.elemento-cuerpo { padding: .8rem .8rem .1rem; border-top: 1px solid var(--borde); background: #fcfcfb; border-radius: 0 0 8px 8px; }

.escenario { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #e9e8e4; }
.escenario-barra { display: flex; align-items: center; gap: .8rem; padding: .45rem 1rem; border-bottom: 1px solid var(--borde); background: #f3f2ef; }
.direccion { flex: 1; font-size: .8rem; color: var(--apagado); font-family: ui-monospace, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segmentos { display: inline-flex; background: #e2e1dd; border-radius: 8px; padding: 2px; }
.segmentos button { border: none; background: none; padding: .3rem .7rem; border-radius: 6px; font: inherit; font-size: .82rem; cursor: pointer; color: var(--apagado); }
.segmentos button.activo { background: #fff; color: var(--texto); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.marco { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; }
.marco iframe.detras { position: absolute; visibility: hidden; }
.marco iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.marco.telefono { padding: 1rem 0; }
.marco.telefono iframe { border-radius: 18px; box-shadow: 0 0 0 8px #1f2326, 0 12px 30px rgba(0,0,0,.25); }
.pista { margin: 0; padding: .35rem 1rem; font-size: .78rem; color: var(--apagado); background: #f3f2ef; border-top: 1px solid var(--borde); }

/* diálogos: agregar sección y biblioteca de imágenes */
.dialogo { width: min(560px, 94vw); max-height: 86vh; border: none; border-radius: 14px; padding: 0; }
.dialogo.ancho { width: min(900px, 94vw); }
.dialogo::backdrop { background: rgba(20, 23, 25, .6); }
.dialogo-cabeza { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: .8rem; padding: .9rem 1.1rem; background: #fff; border-bottom: 1px solid var(--borde); }
.dialogo-cabeza strong { flex: 1; }
.dialogo-cabeza .subir { margin: 0; }
.tipos { padding: .5rem; }
.tipos button { display: block; width: 100%; text-align: left; border: none; background: none; padding: .7rem .8rem; border-radius: 8px; cursor: pointer; font: inherit; color: inherit; }
.tipos button:hover { background: var(--naranja-suave); }
.tipos span { display: block; color: var(--apagado); font-size: .85rem; }
.biblioteca-rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; padding: 1rem 1.1rem; }
.biblioteca-rejilla > p { grid-column: 1 / -1; margin: 0; }
.biblioteca-rejilla button { border: 2px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer; background: #eceae6; aspect-ratio: 4 / 3; }
.biblioteca-rejilla button:hover { border-color: var(--naranja); }
.biblioteca-rejilla img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* marca */
.colores { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; }
.color { display: flex; align-items: center; gap: .6rem; margin: 0; }
.color input { width: 44px; height: 36px; border: 1px solid var(--borde); border-radius: 6px; padding: 2px; background: #fff; cursor: pointer; }
.color span { flex: 1; }

/* versiones */
.lista-versiones { list-style: none; padding: 0; }
.lista-versiones li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.lista-versiones form { margin: 0; }

/* aviso flotante */
.aviso-flotante { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); background: var(--noche); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; }
.aviso-flotante.visible { opacity: 1; transform: translate(-50%, 0); }
.aviso-flotante.mal { background: var(--rojo); }

@media (max-width: 900px) {
  body.con-editor { height: auto; overflow: visible; }
  .editor { display: block; }
  .escenario { display: none; }
  .lado { border-right: none; }
  .lado-cuerpo { overflow: visible; }
  .solo-movil { display: inline-flex; margin-top: .6rem; }
  .detalle-cabeza { position: static; }
}

@media (max-width: 640px) {
  .barra { gap: .6rem; padding: .6rem .9rem; }
  .barra nav { order: 3; flex-basis: 100%; gap: .8rem; font-size: .9rem; }
  .barra-acciones { margin-left: auto; }
  .barra-acciones .estado { display: none; }
  .contenido { padding: 1.25rem .9rem 4rem; }
}
