:root{
  --bg:#0b1220; --bg-alt:#0e1626;
  --card:rgba(255,255,255,.06); --card-strong:rgba(255,255,255,.12);
  --text:#e6eef8; --muted:#a9b4c2;
  --accent:#0ea5e9; --accent-2:#22d3ee;
  --danger:#ef4444; --success:#22c55e; --warning:#f59e0b;
  --shadow:0 16px 48px rgba(0,0,0,.38);
  --radius:18px; --radius-sm:12px;
}

[data-theme="light"]{
  --bg:#f6f8fb; --bg-alt:#eef2f7;
  --card:rgba(0,0,0,.04); --card-strong:rgba(0,0,0,.08);
  --text:#0b1220; --muted:#374151; --shadow:0 16px 48px rgba(0,0,0,.15);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,"Helvetica Neue",Arial,"Noto Sans",sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(34,211,238,.16), transparent 60%),
    radial-gradient(1200px 600px at 110% 10%, rgba(14,165,233,.18), transparent 60%),
    radial-gradient(800px 400px at 50% 120%, rgba(255,255,255,.05), transparent 70%),
    var(--bg);
  color:var(--text);
}

img{max-width:100%; height:auto; display:block}
a{color:var(--accent); text-decoration:none}
a:hover{text-decoration:underline}

/* ===== Header ===== */
.app-header{
  position: sticky;
  top: 0;
  z-index: 10000;
  isolation: isolate;
  display: grid;
  grid-template-columns: 1fr auto; /* ✅ antes: 1fr auto auto */
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,0)), var(--bg);
  backdrop-filter: blur(8px);
  border-bottom: 0;
}
.menu-open .app-header{ z-index: 10001; }
.nav-menu-wrap{ position: relative; z-index: 10002; }
.nav-menu{ z-index: 10003; }
#settingsMenuBtn{ position: relative; z-index: 10004; }
.canvas-stage{ border-top-color: transparent; }

.title.brand{display:flex; align-items:center; gap:10px; position:static; min-height:64px} /* ✅ antes: position:relative */
#appLogo{
  height:clamp(56px,9vw,80px);
  width:clamp(56px,9vw,80px);
  object-fit:contain;
  border-radius:0;
  box-shadow:none;
  background:transparent;
  border:0;
}
#appLogo.heat{
  filter:
    url(#heat-waves)
    drop-shadow(0 0 6px rgba(255,255,255,.35))
    drop-shadow(0 0 16px rgba(34,211,238,.35));
}
/* clamp ordenado correctamente (antes el min era mayor que el max) */
.brand-neon{font-weight:800; font-size:clamp(2rem,3.6vw,2.4rem); letter-spacing:.2px; color:#000; animation:hue 12s linear infinite, glow 3.2s ease-in-out infinite}
@keyframes hue{from{filter:hue-rotate(0)}to{filter:hue-rotate(360deg)}}
@keyframes glow{0%,100%{text-shadow:0 0 6px rgba(255,255,255,.25),0 0 14px rgba(34,211,238,.55)}50%{text-shadow:0 0 10px rgba(255,255,255,.5),0 0 24px rgba(167,139,250,.7)}}
.brand-gap{width:clamp(16px,3vw,36px)}

.tagline{position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); display:flex; align-items:center; gap:10px; white-space:nowrap; pointer-events:none}

.tag-logo{
  height:calc(2.15em * 1.25);
  width:calc(2.15em * 1.25);
  object-fit:contain;
  margin-right:calc(.32em * 2);
  transform-origin:center center;
  animation:sway 5.5s ease-in-out infinite;
  /* halo suave */
  filter:
    drop-shadow(0 0 6px rgba(255,255,255,.35))
    drop-shadow(0 0 16px rgba(34,211,238,.35));
}

.tag-gap{display:inline-block; width:clamp(10px,3vw,40px)}

.glyph{display:inline-block; line-height:1; transform-origin:center bottom}
.frag-silver{font-size:2rem; color:#cfd3d6; opacity:.9; animation:wave 3.8s ease-in-out infinite; text-shadow:0 0 6px rgba(255,255,255,.18)}
.frag-white{font-size:2rem; color:#fff; opacity:.95; animation:wave 3.8s ease-in-out infinite; text-shadow:0 0 8px rgba(255,255,255,.25)}
.sun-i{font-weight:900; font-size:2.2rem; color:#fff; text-shadow:0 0 8px rgba(255,255,255,.7),0 0 22px rgba(255,255,255,.55),0 0 40px rgba(207,229,248,.5)}
.orb-blue{font-weight:900; font-size:2.35rem; color:#bfe5ff; text-shadow:0 0 8px rgba(180,215,255,.9),0 0 22px rgba(80,160,255,.85),0 0 40px rgba(40,120,255,.7)}
.orb-black{font-weight:900; font-size:2rem; color:#000; text-shadow:0 0 8px rgba(255,255,255,.45),0 0 22px rgba(190,190,190,.35),0 0 40px rgba(130,130,130,.3)}
.rotate-z{animation:tiltZ 5s ease-in-out infinite alternate}
.orb-dawn{font-weight:900; font-size:2.35rem; color:#ffd1b1; animation:dawnGlow 6s ease-in-out infinite}
@keyframes tiltZ{from{transform:rotate(-6deg)}to{transform:rotate(6deg)}}
@keyframes sway{
  0%{transform:rotate(-3deg)}
  50%{transform:rotate(3deg)}
  100%{transform:rotate(-3deg)}
}

@keyframes wave{0%,100%{transform:translateY(0);opacity:.6}50%{transform:translateY(-3px);opacity:.85}}
@keyframes dawnGlow{
  0%{color:#ffd1b1;text-shadow:0 0 8px rgba(255,180,80,.95),0 0 24px rgba(255,140,0,.8),0 0 40px rgba(255,100,0,.65)}
  25%{color:#ffc2ef;text-shadow:0 0 8px rgba(255,0,128,.95),0 0 24px rgba(255,80,160,.8),0 0 40px rgba(255,0,120,.6)}
  50%{color:#ffd9e6;text-shadow:0 0 8px rgba(255,70,160,.95),0 0 24px rgba(255,20,100,.8),0 0 40px rgba(255,50,140,.6)}
  75%{color:#d6f1ff;text-shadow:0 0 8px rgba(120,180,255,.95),0 0 24px rgba(70,140,255,.8),0 0 40px rgba(40,120,255,.6)}
  100%{color:#ffd1b1;text-shadow:0 0 8px rgba(255,180,80,.95),0 0 24px rgba(255,140,0,.8),0 0 40px rgba(255,100,0,.65)}
}

@media (max-width:920px){
  .app-header{grid-template-columns:1fr auto; grid-auto-rows:auto}
  .title.brand{grid-column:1/-1; flex-wrap:wrap}
  .tagline{position:static; transform:none; order:3; margin:2px auto 0; text-align:center}
}

/* ===== Nav + botones ===== */
.nav{display:flex; gap:8px; align-items:center; flex-wrap:nowrap; overflow-x:auto;padding-right:6px; -webkit-overflow-scrolling:touch; scrollbar-width:none}
.nav::-webkit-scrollbar{ display:none; }

@media (max-width:980px){
  .nav{ display:flex; gap:6px; margin-left:auto; }
  .nav-link{ padding:8px; }
  .nav .square, .nav .eye{ width:32px; height:32px; }
}

.nav-link{padding:8px 10px; border-radius:10px; color:var(--text)}
.nav-link.active, .nav-link:hover{background:var(--card); text-decoration:none}

/* Botón “ojo” */
.nav .eye{border:1px solid var(--card-strong); background:var(--card)}
.nav .eye[aria-pressed="true"]{outline:2px dashed var(--accent)}
/* ===== Menú de Ajustes (nav) ===== */
.nav-menu-wrap{ position:relative; }
.nav .square{
  width:34px; height:34px; padding:0;
  display:inline-grid; place-items:center;
  border:1px solid var(--card-strong); background:var(--card); border-radius:10px;
}
#orderPanelsBtn{
  display:inline-grid;
  place-items:center;
  line-height:1;
  text-align:center;
  padding:0;
}
#studioImportBtn{
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #ffffff;
  border: 1px solid var(--card-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-weight: 800;
}
#studioImportBtn:hover{
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  filter: brightness(1.05);
  text-decoration: none;
}

.nav-menu{
  position:absolute; right:0; top:calc(100% + 10px);
  display:none; min-width:240px;
  background:var(--bg); border:1px solid var(--card-strong); border-radius:12px;
  box-shadow:var(--shadow); padding:10px;
  z-index:150;
}

.nav-menu.open{ display:block; animation:menuIn .12s ease-out; }
@keyframes menuIn{ from{ transform:translateY(-4px); opacity:0 } to{ transform:translateY(0); opacity:1 } }
.nav-menu .item{
  width:100%; display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:var(--bg-alt); border:1px solid var(--card-strong);
  border-radius:10px; padding:10px 12px; color:var(--text); font-weight:700; cursor:pointer;
  transition: box-shadow .14s ease, transform .12s ease, background .14s ease, border-color .14s ease;
}
.nav-menu .item + .item{ margin-top:8px; }
.nav-menu .item .k{ opacity:.6; font-size:12px; }

.nav-menu .item:hover,
.nav-menu .item:focus-visible{
  text-decoration:none;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,.25),
              0 0 0 1px var(--accent) inset,
              0 0 18px rgba(14,165,233,.38);
  background: linear-gradient(180deg, var(--bg-alt), rgba(255,255,255,.02));
  border-color: var(--accent);
  outline: none;
}

/* 🆕 ON = esquinas redondeadas (sin línea/halo extra) */
body.panels-glow .float-panel{
  border-radius: var(--radius);
  border-color: var(--card-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
  background-clip: padding-box;
}

/* ===== Botones ===== */
.actions{display:flex; gap:8px}
.btn{
  border:none; border-radius:12px; padding:10px 14px; background:var(--accent); color:white; font-weight:700;
  box-shadow:var(--shadow); cursor:pointer; transition:transform .1s ease, filter .15s ease;
}
.btn:hover{filter:brightness(1.05)}
.btn:active{transform:translateY(1px) scale(.995)}
.btn.ghost{background:var(--card); color:var(--text); box-shadow:none; border:1px solid var(--card-strong)}
.btn.small{padding:6px 10px; border-radius:8px; font-size:12px}
.btn.success{background:var(--success)}
.btn.danger{background:var(--danger)}
.btn.warn{background:var(--warning)}
#modal .book-form .actions{
  align-items:center;
  flex-wrap:nowrap;
}

/* ===== Workspace + Stage ===== */
.app-shell{width:100%; max-width:100vw; margin:4px auto 90px auto; padding-inline:10px}
.is-crear .app-shell{
  margin:0 !important;
  padding:0 !important;
  max-width:100vw;
}
@media (min-width: 981px){
  .is-crear .app-shell{
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

.is-crear .workspace{
  height: calc(100vh - (var(--hdrH, 0px) + var(--ftrH, 0px)));
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: center;
}
.is-crear .canvas-stage{
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
.is-crear #mandala{
  width: min(96vw, calc(100vh - (var(--hdrH, 0px) + var(--ftrH, 0px)) - 16px));
  max-width: 2400px;
  min-width: 280px;
  height: auto;
}

.workspace{
  position:relative;
  height:calc(100vh - 120px);
  display:flex; align-items:flex-start; justify-content:center;
  padding-top:4px; padding-bottom:8px;
}

.canvas-stage{position:relative; background:var(--bg-alt); border:1px solid var(--card-strong); border-radius:16px; box-shadow:var(--shadow); padding:8px}
.canvas-stage .hint{position:absolute; left:12px; top:12px; font-size:12px; color:var(--muted); background:rgba(0,0,0,.35); border:1px solid var(--card-strong); padding:4px 8px; border-radius:8px; pointer-events:none}
canvas{display:block; width:100%; height:auto}
#mandala{
  aspect-ratio: 1 / 1;
  width: min(92vw, calc(100vh - 180px));
  max-width: 2400px;
  min-width: 320px;
}

/* Ocultar paneles en modo visualización */
.panels-hidden .float-panel{display:none !important}
.panels-hidden #animDock{ display:none !important; }

/* ===== Float panels ===== */
.float-panel{
  position:fixed; z-index:55; width:420px; max-width:46vw;
  background:var(--bg);
  border:1px solid var(--card-strong); border-radius:0px; box-shadow:var(--shadow)
}

/* +10px solo para Archivo, Pincel y Contorno+Simetría */
#p-file, #p-brush, #p-advanced { width: 430px; }

.float-panel.front, .float-panel.is-front{ z-index:90; }
.fp-head{
  cursor:move; padding:8px 12px; font-weight:800; color:var(--text);
  border-bottom:1px solid var(--card-strong);
  background:var(--bg-alt);
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  user-select:none;
}
.fp-body{
  padding:8px 10px; display:grid; gap:10px;
  max-height:calc(100vh - 220px);
  overflow:auto;
  overflow-x:hidden;
}
@media (max-width:720px){
  .fp-head{ padding:6px 10px; }
  .fp-body{ padding:8px; gap:8px; }
}

.float-panel.dragging{opacity:.98}
@media (max-width:720px){
  .float-panel{ width: min(92vw, 520px); max-width: 92vw; }
  #p-file, #p-brush, #p-advanced { width: auto; }
}

/* Utilidades */
.row{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.row.between{ justify-content:space-between; }
.compact-inline{ gap:8px; }
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

.group{background:transparent; border:0; padding:0}
.field{display:grid; gap:8px; min-width:0}
label{font-size:14px; color:var(--muted)}
input,select,textarea{
  background:var(--bg-alt); border:1px solid var(--card-strong); color:var(--text);
  border-radius:12px; padding:10px 12px; width:100%;
}

/* ===== Sliders compactos con valor ===== */
.slider{display:grid; grid-template-columns:1fr auto; align-items:center; gap:8px}
.slider output{
  min-width:44px; text-align:right; font-variant-numeric:tabular-nums;
  background:var(--bg-alt); border:1px solid var(--card-strong); border-radius:8px; padding:6px 8px;
}

/* ===== Botones tipo herramienta ===== */
.toolbar{display:flex; gap:8px; flex-wrap:wrap}
.tool{
  padding:6px 10px; border:1px solid var(--card-strong);
  background:#0f1a2d;
  color:#ffffff; border-radius:8px; cursor:pointer; font-weight:700;
}
.tool.active{outline:2px dashed var(--accent)}
.tool{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.btn.square{ width:34px; height:34px; padding:0; display:inline-grid; place-items:center; }
.color-tools-row{ display:flex; gap:8px; align-items:center; flex-wrap:nowrap; overflow:hidden; }
.color-history{ display:flex; gap:6px; overflow:hidden; }
.color-dot{
  width:18px; height:18px; border-radius:50%;
  border:1px solid var(--card-strong); flex:0 0 auto; cursor:pointer;
}
.color-dot:active{ transform:scale(.96); }

/* ===== Paleta 20×12 ===== */
.palette-grid{
  display:grid;
  grid-template-columns:repeat(20, 15px);
  gap:4px;
  justify-content:center;
}

.palette-swatch{
  width:15px; height:15px; border-radius:3px;
  border:1px solid var(--card-strong);
  cursor:pointer; transition:transform .05s ease;
}
.palette-swatch:hover{transform:scale(1.15)}
.pb-split{display:grid; grid-template-columns:1fr 1fr; gap:12px}
.pb-col{display:grid; gap:12px; min-width:0}

/* ===== Capas ===== */
#p-layers .fp-body{overflow-x:hidden}
.layer-list{display:grid; gap:8px}
.layer{
  background:var(--bg-alt); border:1px solid var(--card-strong); border-radius:10px; padding:8px 10px
}
.layer.grid-3x3{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  grid-template-rows:repeat(3, auto);
  gap:8px 10px; align-items:center;
}
.layer .cell{min-width:0;}
.layer .cell.span-2{grid-column:span 2;}
.layer .cell.right{justify-self:end;}
.layer .name{font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.layer .btns, .layer .top, .layer .bottom{display:flex; gap:6px; flex-wrap:wrap}
.layer input[type="range"]{min-width:120px; width:100%}
.small-note{font-size:12px; color:var(--muted)}
.layer.drag-over{ outline:2px dashed var(--accent); }

/* ===== Skins grid ===== */
.skins-grid{
  display:grid; grid-template-columns:repeat(auto-fill, minmax(140px,1fr)); gap:10px
}
.skin-card{
  border:1px solid var(--card-strong); border-radius:12px; padding:10px; cursor:pointer; background:var(--bg-alt)
}
.skin-card:hover{outline:2px dashed var(--accent)}
.skin-sample{height:34px; border-radius:8px; margin-top:8px}

/* ===== Chips/Previews opcionales para patrón de trazo ===== */
.pattern-preview{ display:flex; gap:6px; flex-wrap:wrap }
.pattern-chip{
  padding:4px 8px; border-radius:8px; border:1px solid var(--card-strong);
  background:var(--bg-alt); font-size:12px;
}

/* ===== Toast & modal ===== */
.toast{
  position:fixed; left:50%; top:50%;
  transform: translate(-50%, -50%);
  z-index:80;
  background: rgba(0,0,0,.92); border:1px solid var(--card-strong);

  border-radius:14px; padding:12px 16px;
  opacity:0; pointer-events:none; transition:opacity .25s;
  max-width:min(92vw, 520px); text-align:center;
}
canvas{ touch-action: none; }

.toast.show{opacity:1; pointer-events:auto}

.modal{position:fixed; inset:0; display:grid; place-items:center; background:rgba(0,0,0,.5); z-index:10110}
.modal.hidden{display:none}
.modal-content{width:min(720px,92vw); background:var(--bg); border-radius:var(--radius); border:1px solid var(--card-strong); padding:18px; box-shadow:var(--shadow); transform:translateY(6px)}
#modal:has(.book-wizard){
  overflow:auto;
  place-items:start center;
  padding-top:calc(var(--hdrH, 0px) + 14px);
  padding-right:12px;
  padding-bottom:calc(var(--ftrH, 0px) + 14px);
  padding-left:12px;
}

#modal:has(.book-wizard) .modal-content{
  margin:0 auto;
  transform:none;
}
/* Si el JS la pone “ancha”, usará width inline (min(1100px,96vw)). */

/* ===== Footer ===== */
.footer{
  background:linear-gradient(0deg, rgba(0,0,0,.35), rgba(0,0,0,0)), var(--bg);
  border-top:1px solid var(--card-strong); padding:10px 16px;
  display:flex; align-items:center; justify-content:space-between; gap:8px; color:var(--muted);
  box-shadow:0 -12px 28px rgba(0,0,0,.22); position:fixed; bottom:0; left:0; right:0; z-index:50
}
.footer strong{color:var(--text)}
.footer .sep{opacity:.6}
.footer .btn.ghost{padding:6px 10px; border-radius:8px}

/* ===== Overlays base ===== */
/* Centro absoluto dentro del footer fijo */
.footer{ position:fixed; } /* ya lo tienes, recordatorio */
.footer-center{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  z-index:1;
}

/* Botón-ícono en reposo: sin cápsula visual (integrado en el footer) */
.footer-logo-btn{
  display:inline-grid; place-items:center;
  padding:0; border-radius:12px;
  border:1px solid transparent;
  background:transparent;
  transition: box-shadow .14s ease, transform .08s ease, filter .14s ease, border-color .12s ease, background-color .12s ease;
  text-decoration:none;
}

.footer-logo-btn:hover,
.footer-logo-btn:focus-visible{
  text-decoration:none;
  transform: translateY(-1px);
  background: var(--bg-alt);
  border-color: var(--accent);
  box-shadow:
    0 8px 24px rgba(0,0,0,.25),
    0 0 0 1px var(--accent) inset,
    0 0 18px rgba(14,165,233,.38);
  outline: none;
}


/* 1/3 más grande, pero SIN pasarse del alto del footer (—8px de aire) */
.footer-logo{
  height: min(calc(2.15em * 1.25 * 1.3333), calc(var(--ftrH, 60px) - 8px));
  width:  min(calc(2.15em * 1.25 * 1.3333), calc(var(--ftrH, 60px) - 8px));
  margin:0;
  object-fit:contain;
}


.overlay{position:fixed; inset:0; background:rgba(0,0,0,.65); display:none; align-items:center; justify-content:center; z-index:10120}
.overlay .box{background:var(--bg); border:1px solid var(--card-strong); border-radius:12px; padding:16px; width:min(980px,94vw); max-height:92vh; overflow:auto; box-shadow:var(--shadow)}
/* Más ancho y un poco menos alto solo para #coherenciaOverlay */
#coherenciaOverlay .box{
  width: min(1100px, 96vw);
  max-height: 86vh;
}

/* Abre overlays con ancla #id sin JS (como en GUI‑on) */
.overlay:target{ display:flex; }
/* Abre el overlay de Coherencia Universal con el checkbox (evita conflictos con el router hash) */
#coherenciaToggle:checked + #coherenciaOverlay{ display:flex; }
/* Coherencia Universal + Licencia MIT: mismo estilo y justificado */
#coherenciaOverlay .coher-text,
#licenseOverlay #licenseBody,
#licenseOverlay pre.small{
  /* Igual que MIT: respeta saltos y altura de línea */
  white-space: pre-wrap;
  line-height: 1.45;

  /* Justificado */
  text-align: justify;
  text-justify: inter-word; /* donde esté soportado */
  hyphens: auto;            /* usa diccionarios según <html lang="..."> */

  /* Limpio */
  margin: 0;
}
#coherenciaBody{
  white-space: pre-wrap;
  line-height: 1.45;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  margin: 0;
}

/* Justificar texto en Coherencia Universal + Licencia MIT, preservando saltos (pre-wrap) */
#coherenciaOverlay .coher-text{
  text-align: justify;
  text-justify: inter-word;
  font-family: inherit;
  margin: 0;
}

#licenseOverlay #licenseBody{
  text-align: justify;
  text-justify: inter-word;
  font-family: inherit;
  margin: 0;
}

/* ===================================================================== */
/* ==================   AÑADIDOS PARA TUS NUEVAS VISTAS   ============== */
/* ===================================================================== */

/* —— Galería 5×N —— */
.gallery-grid{display:grid; grid-template-columns:repeat(10,minmax(0,1fr)); gap:8px}
@media (max-width:1200px){ .gallery-grid{grid-template-columns:repeat(8,minmax(0,1fr));} }
@media (max-width:980px){  .gallery-grid{grid-template-columns:repeat(6,minmax(0,1fr));} }
@media (max-width:720px){  .gallery-grid{grid-template-columns:repeat(4,minmax(0,1fr));} }
@media (max-width:460px){  .gallery-grid{grid-template-columns:repeat(2,minmax(0,1fr));} }
.gallery-scroll{ max-height: calc(100vh - 180px); overflow:auto; }

.gallery-card{
  border:1px solid var(--card-strong); border-radius:12px; padding:10px;
  background:var(--bg-alt); display:grid; gap:8px;
}
.gallery-thumb{
  width:100%; aspect-ratio:1/1; object-fit:cover;
  border-radius:8px; border:1px solid var(--card-strong);
}
.gallery-title{font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
/* — Botón y panel de metadatos por tarjeta — */
.gallery-meta-btn{
  position:absolute; top:8px; left:56px; z-index:2;
  width:36px; height:36px;
  padding:0; display:inline-grid; place-items:center;
  border-radius:8px;
  border:1px solid var(--card-strong); background:var(--bg-alt);
  font-size:18px; line-height:1; cursor:pointer;
}

.gallery-meta-btn:hover{ filter:brightness(1.08); }

.gallery-meta-pop{
  position:absolute; left:8px; right:8px; top:34px; z-index:3;
  background:var(--bg); border:1px solid var(--card-strong);
  border-radius:10px; box-shadow:var(--shadow);
  padding:10px; display:none;
}
.gallery-meta-pop .field{ display:grid; gap:6px; margin-bottom:8px; }
.gallery-meta-pop .row{ display:flex; gap:8px; justify-content:flex-end; }
.gallery-meta-pop .small-note{ opacity:.9; }

/* === Selección + Orden + Drag&Drop en Galería === */
.gallery-card{ position: relative; }
.gallery-card.selected{
  outline: 2px solid var(--accent);
  outline-offset: 0;
  box-shadow: 0 0 0 2px rgba(14,165,233,.25) inset;
}

/* Check de selección */
.gallery-check{
  position:absolute;
  top:8px;
  left:8px;
  z-index:2;
  width:18px;
  height:18px;
  display:grid;
  place-items:center;
}

.gallery-check input{
  appearance:none;
  -webkit-appearance:none;
  width:18px;
  height:18px;
  margin:0;
  padding:0;
  box-sizing:border-box;
  border-radius:6px;
  border:1px solid var(--card-strong);
  background:var(--bg-alt);
  display:grid;
  place-items:center;
  line-height:1;
  cursor:pointer;
  transition:filter .12s, background .12s, border-color .12s;
}

.gallery-check input:hover{
  filter:brightness(1.08);
}

.gallery-check input::before{
  content:"✓";
  display:block;
  font-size:12px;
  line-height:1;
  font-weight:800;
  color:var(--bg);
  transform:scale(0);
  transition:transform .12s ease-in-out;
}

.gallery-check input:checked{
  background:var(--accent);
  border-color:var(--accent);
}

.gallery-check input:checked::before{
  transform:scale(1);
}

/* Badge de orden */
.gallery-order{
  position:absolute; top:8px; right:8px; z-index:2;
  min-width:22px; height:22px; padding:0 6px; display:inline-grid; place-items:center;
  border-radius:999px;
  font-size:12px; font-weight:800; color:var(--bg);
  background:linear-gradient(180deg, var(--accent), var(--accent-2));
  border:1px solid var(--card-strong);
  box-shadow: var(--shadow);
}

/* Placeholder durante el drag */
.gallery-card.placeholder{
  border:1px dashed var(--accent);
  background:transparent;
  visibility:visible;
}

/* Fantasma que se mueve con el dedo */
.drag-ghost{
  position:fixed; left:0; top:0; z-index:9999;
  pointer-events:none;
  box-shadow: 0 18px 40px rgba(0,0,0,.40);
  transform: translate3d(0,0,0);
  opacity:.98;
  border-radius:12px;
}

/* —— Creador de Libros (modal grande) —— */
#modal .book-form .grid-2{display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px}
#modal .book-form .grid-3{display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px}

/* checkbox currado */
#modal .book-form input[type="checkbox"]{
  appearance:none; -webkit-appearance:none; width:18px; height:18px;
  border-radius:6px; border:1px solid var(--card-strong); background:var(--bg-alt);
  display:inline-grid; place-items:center; transition:filter .12s, background .12s, border-color .12s;
}
#modal .book-form input[type="checkbox"]:hover{filter:brightness(1.08)}
#modal .book-form input[type="checkbox"]::before{
  content:"✓"; transform:scale(0); transition:transform .12s ease-in-out;
  font-weight:800; color:var(--bg); line-height:1;
}
#modal .book-form input[type="checkbox"]:checked{
  background:var(--accent); border-color:var(--accent);
}
#modal .book-form input[type="checkbox"]:checked::before{transform:scale(1)}

/* ===== +Importar (Studio): grid fijo 4×4 sin scroll ===== */
.imp-modal-wrap{ position:relative; }
.imp-nav{
  position:absolute; top:6px; right:6px;
  display:flex; gap:6px; align-items:center; z-index:1;
}
.imp-grid-4x4{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, auto);
  gap: 12px;
}
.imp-grid-4x4 .gp-card img{
  aspect-ratio:1/1; object-fit:cover;
}

#modal .book-form .select-card{
  border:1px solid var(--card-strong); border-radius:10px; padding:8px;
  background:var(--bg-alt); display:grid; gap:6px; cursor:pointer;
}
#modal .book-form .select-card img{
  width:100%; aspect-ratio:1/1; object-fit:cover; border-radius:8px; border:1px solid var(--card-strong);
}
/* === Creador de Libro: grid estricto 4×8 === */
#modal .book-form .book-grid,
#modal .book-form.book-grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  grid-template-rows: repeat(8, auto);
  gap: 10px 12px;
  align-items: start;
}

/* Inputs del panel de libro */
#modal .book-form input[type="text"],
#modal .book-form input[type="email"],
#modal .book-form input[type="date"],
#modal .book-form textarea{
  width:100%;
}
#modal .book-form textarea{ min-height: 68px; resize: vertical; }

/* —— Paso 2 (book-step2): selects al 20% del ancho —— */
#modal .book-form.book-step2 select{
  width: 20% !important;
  min-width: 120px;
}

/* Mantener en línea dentro de filas compactas */
#modal .book-form.book-step2 .row.nowrap > select{
  width: 20% !important;
}
#modal .book-form.book-step2 input[type="number"].tight{
  width: 20% !important;
  min-width: 120px;
}
#modal .book-form.book-step2{
  column-gap: 8px;
  row-gap: 10px;
}

/* Da un pelín más de aire antes de la columna 4 */
#modal .book-form.book-step2 > [style*="grid-column:4"]{
  margin-left: 6px;
}

/* —— Utilidades grid genéricas —— */
.grid{display:grid; gap:12px}
.grid.cols-2{grid-template-columns:repeat(2, minmax(0,1fr))}
.grid.cols-3{grid-template-columns:repeat(3, minmax(0,1fr))}
.grid.cols-5{grid-template-columns:repeat(5, minmax(0,1fr))}

/* ===================================================================== */
/* ==================   LAYOUT ARCHIVO (2 columnas)  =================== */
/* ===================================================================== */
.file-grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px 12px;
  align-items:center;
}
.file-grid .fullw{ width:100%; }

/* —— Accesibilidad —— */
@media (prefers-reduced-motion: reduce){
  .brand-neon, .rotate-z, .frag-silver, .frag-white, .orb-dawn{animation:none}
}
/* ===== Contorno+Simetría (grid 4×7 con separador central) ===== */
.adv-grid-4x7{
  --adv-gap-h: 12px;
  --adv-shift: 12px;
  display:grid;
  grid-template-columns: 1fr 1fr 1.1429fr minmax(0, 0.8571fr);
  grid-template-rows: repeat(7, auto);
  gap: 10px var(--adv-gap-h);
  align-items:center;
  position:relative;
}

.adv-grid-4x7 > *{ min-width:0; }
.adv-grid-4x7::before{
  content:"";
  position:absolute; top:0; bottom:0;
  left: calc(50% - var(--adv-shift));
  width:0;
  border-left:1px solid var(--card-strong);
  pointer-events:none;
}
.adv-grid-4x7 > [style*="grid-column:3"]{
  transform: translateX(calc(-1 * var(--adv-shift)));
}
.adv-grid-4x7 > [style*="grid-column:4"]{
  transform: translateX(var(--adv-shift));
}

/* Fila accesible para checkbox + etiqueta (se apila si no cabe) */
.check-row{
  display:grid;
  grid-template-columns:auto 1fr;
  align-items:center;
  gap:8px;
  white-space:normal;
}
.adv-grid-4x7 .check-row > label{
  font-size:13px;
  line-height:1.25;
  min-width:0;
}

/* (retrocompat de utilidades que ya tenías) */
.adv-col{ display:grid; gap:10px; }
.num, select.num{
  width:76px; height:38px; padding:6px;
  text-align:center;
  font-variant-numeric:tabular-nums;
  border-radius:8px;
}

.adv-grid-4x7 input[type="range"]{ width:100%; }
input[type="color"].color-full{
  -webkit-appearance: none;
  appearance: none;
  width:38px; height:38px;
  border-radius:8px;
  padding:0; border:none; background:none;
  display:inline-block;
}
input[type="color"].color-full::-webkit-color-swatch-wrapper{
  padding:0; border-radius:8px;
}
input[type="color"].color-full::-webkit-color-swatch{
  border:1px solid var(--card-strong);
  border-radius:8px;
}
input[type="color"].color-full::-moz-color-swatch{
  border:1px solid var(--card-strong);
  border-radius:8px;
}

.slider-line{
  display:grid; grid-template-columns:1fr auto; gap:8px; align-items:center;
}
.slider-line .num{
  width:76px; height:38px; padding:6px; text-align:center;
}

.row.nowrap{
  flex-wrap: nowrap;
  white-space: nowrap;
}
@media (max-width: 720px){
  #modal .book-form.book-step2 .row.nowrap{
    white-space: normal !important;
    flex-wrap: wrap !important;
  }
  #modal .book-form.book-step2 select,
  #modal .book-form.book-step2 .row.nowrap > select,
  #modal .book-form.book-step2 input[type="number"].tight{
    width: 100% !important;
    min-width: 0 !important;
  }
  #modal .book-form.book-step2{
    display: grid;
    grid-template-columns: 1fr !important;
    grid-auto-flow: row;
  }
  #modal .book-form.book-step2 > *{
    grid-column: auto !important;
    grid-row: auto !important;
    margin-left: 0 !important;
    width: 100% !important;
  }
}

/* 🆕 Toggle chips encima del lienzo */
.canvas-stage{ position:relative; }
.stage-toggles{
  position:absolute; left:12px; right:12px; top:-10px;
  display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:8px;
  pointer-events:auto;
}
.tab-toggle{
  position:relative; display:grid; place-items:center;
  padding:6px 10px; border:1px solid var(--card-strong); border-radius:999px;
  background:linear-gradient(180deg, var(--bg), rgba(255,255,255,.02));
  box-shadow:var(--shadow); font-weight:800; font-size:13px; color:var(--text);
  cursor:pointer; user-select:none;
}
.tab-toggle input{
  position:absolute; inset:0; appearance:none; -webkit-appearance:none; opacity:0; cursor:pointer;
}
.tab-toggle span{ pointer-events:none; }
.tab-toggle:hover{ filter:brightness(1.05); }
.tab-toggle input:checked + span{
  outline:2px solid var(--accent); outline-offset:-2px; border-radius:999px;
  box-shadow:0 0 18px rgba(14,165,233,.35) inset;
}

/* ✅ Evita que el dropdown se recorte por overflow-x de la barra */
.menu-open .nav{ overflow:visible; }
.menu-open .nav-menu{ z-index:10050; }
.nav-menu{ max-width:min(92vw, 360px); }

/* Solo visible en la vista Crear — robusto */
.only-crear{ display:none; }
.is-crear .only-crear{ display:initial; }
#orderPanelsBtn.only-crear{ display:none !important; }
.is-crear #orderPanelsBtn.only-crear{ display:inline-grid !important; }
.is-crear .float-panel.only-crear{ display:block; }

/* Checks dentro del menú Paneles */
.nav-menu .item.chk{
  display:flex; align-items:center; gap:10px; justify-content:flex-start;
  font-weight:700; background:var(--bg-alt); border:1px solid var(--card-strong);
  border-radius:10px; padding:10px 12px;
}
.nav-menu .item.chk + .item.chk{ margin-top:8px; }
.nav-menu .item.chk input{ width:auto; }

/* ===== HUD Studio (mínimo) ===== */
.studio-hud{
  position:absolute;
  right:12px; top:12px;
  z-index:60;
  background:var(--bg);
  border:1px solid var(--card-strong);
  border-radius:12px;
  box-shadow:var(--shadow);
  padding:10px;
  min-width:240px;
  max-width:min(92vw, 380px);
}
.studio-hud h4{ margin:0 0 8px; }
.studio-hud .layer-row{ display:grid; grid-template-columns:auto 1fr auto; gap:8px; align-items:center; margin:6px 0; }
.studio-toolbar{
  position:absolute; left:12px; top:12px; z-index:60;
  display:flex; gap:8px;
}
.studio-plus{ font-size:24px; font-weight:900; width:40px; height:40px; padding:0; display:grid; place-items:center; }

/* ====== Studio fullscreen ====== */
.only-studio{ display:none !important; }
.is-studio .only-studio{ display:inline-flex !important; }
.is-studio .app-shell{
  margin: 0 !important;
  padding: 0 !important;
  max-width: 100vw;
}
.is-studio .workspace{
  height: calc(100vh - (var(--hdrH, 0px) + var(--ftrH, 0px)));
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: center;
}
.is-studio .canvas-stage{
  width: 100%;
  height: 100%;
  outline: 1px dashed rgba(255,255,255,.14);
  outline-offset: 0;
  display: grid;
  place-items: center;
}
#studioImportNotice{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--hdrH, 0px) + 8px);
  z-index: 80;
  background: rgba(0,0,0,.92);
  border: 1px solid var(--card-strong);
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 700;
}

@media (max-width:720px){
  .adv-grid-4x7{
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    gap: 10px 12px;
  }
  .adv-grid-4x7::before{ display:none; }
  .adv-grid-4x7 > *{
    transform: none !important;
    grid-column: auto !important;
    grid-row: auto !important;
    min-width: 0;
  }
}

/* Centrar menú Paneles en móvil */
@media (max-width: 720px){
  #panelsMenu{
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
    min-width: 260px;
    z-index: 99999;
  }
}
/* Animación para el emoji de "dedo señalando" con pulso */
.emoji.pulse {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Animación para el emoji de "guiño" */
.emoji.wink {
  animation: wink 2s infinite;
}

@keyframes wink {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-5deg);
  }
  100% {
    transform: rotate(0deg);
  }
}
/* === Fix móvil: evitar solapamiento del icono central del footer === */
@media (max-width: 640px){
  .footer-left{
    /* Reserva espacio para el logotipo centrado (usa la altura del footer) */
    padding-right: calc(var(--ftrH, 60px) + 12px);
    max-width: calc(50% - 8px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .footer-right{
    max-width: calc(50% - 8px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
/* ===== Crear libro — wizard estilo Ensayonesa ===== */
.book-wizard{
  --bw-text: var(--ink, var(--text, #f8fafc));
  --bw-muted: var(--muted, rgba(203,213,225,.78));
  --bw-border: rgba(148,163,184,.28);
  --bw-border-strong: rgba(148,163,184,.45);
  --bw-accent: var(--primary, #38bdf8);
  --bw-accent-soft: rgba(56,189,248,.35);
  --bw-shell:
    radial-gradient(circle at 0% 0%, rgba(56,189,248,.16), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(129,140,248,.14), transparent 42%),
    linear-gradient(145deg, rgba(15,23,42,.96), rgba(15,23,42,.88));
  --bw-card:
    radial-gradient(circle at 0% 0%, rgba(255,255,255,.08), transparent 48%),
    linear-gradient(145deg, rgba(15,23,42,.98), rgba(15,23,42,.9));
  color: var(--bw-text);
  width: min(1040px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.book-wizard-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:16px 18px;
  border-radius:24px;
  border:1px solid var(--bw-border-strong);
  background: var(--bw-shell);
  box-shadow:
    0 22px 60px rgba(0,0,0,.42),
    inset 0 1px 0 rgba(255,255,255,.05);
}

.book-wizard-title{
  margin:0;
  font-size:1.12rem;
  line-height:1.2;
}

.book-wizard-subtitle{
  margin:6px 0 0;
  color:var(--bw-muted);
  font-size:.86rem;
  line-height:1.5;
  max-width:60ch;
}

.book-wizard-badges{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:8px;
}

.book-stat{
  min-width:108px;
  padding:10px 12px;
  border-radius:18px;
  border:1px solid var(--bw-border);
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.1), transparent 55%),
    rgba(15,23,42,.72);
  box-shadow:
    0 10px 26px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.04);
  display:flex;
  flex-direction:column;
  gap:3px;
}

.book-stat-label{
  font-size:.7rem;
  color:var(--bw-muted);
  text-transform:uppercase;
  letter-spacing:.08em;
}

.book-stat-value{
  font-size:.95rem;
  color:var(--bw-text);
}

.book-wizard-tabs{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:8px;
  padding:6px;
  border-radius:20px;
  border:1px solid var(--bw-border);
  background:
    radial-gradient(circle at 0% 0%, rgba(148,163,184,.12), transparent 55%),
    rgba(15,23,42,.78);
  box-shadow:0 14px 34px rgba(0,0,0,.26);
}

.book-wizard-tab{
  border:0;
  border-radius:999px;
  padding:10px 14px;
  background:transparent;
  color:var(--bw-muted);
  font-size:.82rem;
  font-weight:600;
  cursor:pointer;
  transition:
    background .18s ease,
    color .18s ease,
    transform .08s ease,
    box-shadow .18s ease;
}

.book-wizard-tab:hover{
  transform:translateY(-1px);
}

.book-wizard-tab.is-active{
  color:#03111d;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.28), transparent 55%),
    linear-gradient(145deg, #67e8f9, #38bdf8);
  box-shadow:
    0 10px 28px rgba(56,189,248,.28),
    inset 0 1px 0 rgba(255,255,255,.35);
}

.book-wizard-progress{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.book-step-label{
  font-size:.74rem;
  color:var(--bw-muted);
}

.book-progress-bar{
  position:relative;
  height:6px;
  border-radius:999px;
  overflow:hidden;
  border:1px solid var(--bw-border);
  background:rgba(15,23,42,.82);
  box-shadow:0 8px 20px rgba(0,0,0,.24);
}

.book-progress-fill{
  position:absolute;
  inset:0 auto 0 0;
  height:100%;
  width:50%;
  border-radius:inherit;
  background:linear-gradient(90deg, #22d3ee, #38bdf8, #818cf8);
  box-shadow:0 0 22px var(--bw-accent-soft);
  transition:width .25s ease;
}

.book-step-panel{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.book-layout{
  display:grid;
  gap:14px;
}

.book-layout-2{
  grid-template-columns:repeat(2, minmax(0,1fr));
}

.book-layout-3{
  grid-template-columns:repeat(3, minmax(0,1fr));
}

.book-card{
  border-radius:24px;
  border:1px solid var(--bw-border);
  background:var(--bw-card);
  box-shadow:
    0 18px 46px rgba(0,0,0,.34),
    inset 0 1px 0 rgba(255,255,255,.04);
  padding:16px;
  overflow:hidden;
}

.book-card-head{
  margin-bottom:12px;
}

.book-card-title{
  margin:0;
  font-size:1rem;
  line-height:1.2;
}

.book-card-copy{
  margin:6px 0 0;
  color:var(--bw-muted);
  font-size:.8rem;
  line-height:1.45;
}

.book-card-body{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.book-grid-2{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:12px;
}

.book-field{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:0;
}

.book-field.is-span-2,
.book-check-grid.is-span-2{
  grid-column:1 / -1;
}

.book-label{
  font-size:.78rem;
  color:var(--bw-muted);
}

.book-hint{
  font-size:.72rem;
  color:var(--bw-muted);
  line-height:1.45;
}

.book-input,
.book-select,
.book-textarea,
.book-number,
.book-color{
  width:100%;
  border-radius:14px;
  border:1px solid var(--bw-border);
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.08), transparent 55%),
    linear-gradient(145deg, rgba(15,23,42,.98), rgba(15,23,42,.9));
  color:var(--bw-text);
  padding:10px 12px;
  box-shadow:
    0 10px 24px rgba(0,0,0,.24),
    inset 0 1px 0 rgba(255,255,255,.03);
  transition:
    border-color .16s ease,
    box-shadow .16s ease,
    transform .08s ease;
}

.book-input:focus,
.book-select:focus,
.book-textarea:focus,
.book-number:focus,
.book-color:focus{
  outline:none;
  border-color:var(--bw-accent);
  box-shadow:
    0 0 0 1px rgba(56,189,248,.22),
    0 0 24px var(--bw-accent-soft);
}

.book-textarea{
  min-height:120px;
  resize:vertical;
}

.book-number{
  max-width:140px;
}

.book-color{
  min-height:42px;
  padding:6px;
}

.book-check-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:10px;
}

.book-check{
  display:flex;
  align-items:center;
  gap:10px;
  min-height:44px;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid var(--bw-border);
  background:
    radial-gradient(circle at 0% 0%, rgba(255,255,255,.06), transparent 55%),
    rgba(15,23,42,.62);
  cursor:pointer;
}

.book-check input{
  width:16px;
  height:16px;
  accent-color:var(--bw-accent);
  flex:none;
}

.book-inline-stats{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.book-wizard-nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  border-radius:20px;
  border:1px solid var(--bw-border);
  background:
    radial-gradient(circle at 0% 0%, rgba(148,163,184,.1), transparent 55%),
    rgba(15,23,42,.72);
  box-shadow:0 14px 34px rgba(0,0,0,.22);
}

.book-nav-note{
  max-width:64ch;
  color:var(--bw-muted);
  font-size:.82rem;
  line-height:1.5;
}

.book-nav-actions{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:8px;
}

@media (max-width: 920px){
  .book-layout-2,
  .book-layout-3{
    grid-template-columns:1fr;
  }
}

@media (max-width: 720px){
  .book-wizard-header,
  .book-wizard-nav{
    flex-direction:column;
    align-items:stretch;
  }

  .book-wizard-badges,
  .book-nav-actions{
    justify-content:flex-start;
  }

  .book-wizard-tabs{
    grid-template-columns:1fr;
  }

  .book-grid-2,
  .book-check-grid{
    grid-template-columns:1fr;
  }

  .book-field.is-span-2,
  .book-check-grid.is-span-2{
    grid-column:auto;
  }

  .book-number{
    max-width:none;
  }
}
/* ===== Pulido final: libro + shell + selector de idioma ===== */

/* 1) Libro: ocultar solo visualmente el título base del modal
   (se mantiene para accesibilidad porque aria-labelledby sigue apuntando a él) */
#modal:has(.book-wizard) #modal-title{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
}

/* 2) Header + footer sincronizados con el tema/skin actual */
body #siteHeader.brand-header,
body #siteFooter.brand-footer{
  backdrop-filter: blur(10px) saturate(1.08) !important;
}

body #siteHeader.brand-header{
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,0)),
    linear-gradient(180deg, var(--bg-alt), var(--bg)) !important;
  border-bottom:1px solid var(--card-strong) !important;
  box-shadow:0 14px 32px rgba(0,0,0,.24) !important;
  color:var(--text) !important;
}

body #siteFooter.brand-footer{
  background:
    linear-gradient(0deg, rgba(255,255,255,.06), rgba(255,255,255,0)),
    linear-gradient(180deg, var(--bg-alt), var(--bg)) !important;
  border-top:1px solid var(--card-strong) !important;
  box-shadow:0 -14px 32px rgba(0,0,0,.24) !important;
  color:var(--muted) !important;
}

body #siteHeader.brand-header .nav-link,
body #siteHeader.brand-header .nav-link:visited{
  color:var(--text) !important;
}

body #siteHeader.brand-header .nav-link.active,
body #siteHeader.brand-header .nav-link:hover{
  background:var(--card) !important;
}

body #siteHeader.brand-header .square,
body #siteHeader.brand-header .eye,
body #siteHeader.brand-header .icon-button{
  background:var(--card) !important;
  border-color:var(--card-strong) !important;
  color:var(--text) !important;
}

body #siteFooter.brand-footer .btn.ghost{
  background:var(--card) !important;
  border:1px solid var(--card-strong) !important;
  color:var(--text) !important;
}

body #siteFooter.brand-footer strong,
body #siteFooter.brand-footer .f-left-row1,
body #siteFooter.brand-footer .f-left-row2{
  color:inherit !important;
}

/* 3) Selector de idioma bonito y acorde al tema */
#modal:has(.lang-picker) .modal-actions{
  display:none;
}

.lang-picker{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.lang-picker-copy{
  margin:0;
  color:var(--muted);
  font-size:.86rem;
  line-height:1.5;
}

.lang-picker-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:10px;
}

.lang-option{
  position:relative;
  display:block;
  cursor:pointer;
}

.lang-option input{
  position:absolute;
  inset:0;
  opacity:0;
  cursor:pointer;
}

.lang-option-ui{
  min-height:72px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:4px;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--card-strong);
  background:
    radial-gradient(circle at 0% 0%, rgba(255,255,255,.08), transparent 55%),
    linear-gradient(145deg, var(--bg-alt), var(--bg));
  box-shadow:var(--shadow);
  transition:
    transform .08s ease,
    filter .15s ease,
    border-color .15s ease,
    box-shadow .15s ease;
}

.lang-option:hover .lang-option-ui{
  transform:translateY(-1px);
  filter:brightness(1.05);
  border-color:var(--accent);
}

.lang-option input:focus-visible + .lang-option-ui{
  outline:2px solid var(--accent);
  outline-offset:2px;
}

.lang-option input:checked + .lang-option-ui{
  border-color:var(--accent);
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow:
    0 14px 30px rgba(0,0,0,.26),
    0 0 0 1px var(--accent) inset;
}

.lang-option-code{
  font-size:.72rem;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--muted);
}

.lang-option-name{
  font-size:.92rem;
  font-weight:800;
  color:var(--text);
}

.lang-option input:checked + .lang-option-ui .lang-option-code,
.lang-option input:checked + .lang-option-ui .lang-option-name{
  color:#03111d;
}

.lang-picker-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
}

@media (max-width: 820px){
  .lang-picker-grid{
    grid-template-columns:repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 560px){
  .lang-picker-grid{
    grid-template-columns:1fr;
  }
}