/* MesekaBook — estilos propios (sin Tailwind)
   El color de cada libro (--acc) tiñe la interfaz; applyTheme() en util.js calcula
   las variantes con contraste suficiente (--acc-strong para fondos con texto blanco,
   --acc-ink para texto sobre tonos claros). */
:root {
  --acc: #f43f82;
  --acc-strong: #c8306a;
  --acc-ink: #a8215a;
  --acc-soft: #fff3f8;
  --acc-soft-2: #ffe4ee;
  --acc-line: #ffb8d2;
  --bg: #fff6f9;

  --lila-50: #f8f5ff;
  --lila-100: #ede5ff;
  --lila-200: #d9c8ff;
  --lila-600: #6d3fd6;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-300: #fcd34d;
  --amber-800: #92400e;
  --mint-50: #ecfdf5;
  --mint-200: #a7f3d0;
  --mint-700: #047857;
  --rose-50: #fff1f2;
  --rose-600: #e11d48;
  --rose-700: #be123c;

  --ink: #2a1b26;
  --ink-2: #3f3140;
  --muted: #6b5a69;
  --line: #eadde4;
  --paper: #fffdf9;
  --surface: #ffffff;
  --surface-2: #f4eef2;
  --surface-3: #faf7f9;
  --surface-hover: #ebe2e8;
  --placeholder: #8a7887;
  --acc-soft-l: #fff3f8;
  --acc-soft-2-l: #ffe4ee;
  --acc-line-l: #ffb8d2;
  --acc-ink-l: #a8215a;
  --acc-raw: #f43f82;
  --shadow: 0 12px 30px -14px rgba(90, 30, 60, 0.3);
  --shadow-sm: 0 2px 8px -4px rgba(90, 30, 60, 0.25);

  --font: 'Quicksand', 'Zen Maru Gothic', system-ui, sans-serif;
  --display: 'Fredoka', 'Zen Maru Gothic', system-ui, sans-serif;
  --hand: 'Caveat', 'Zen Maru Gothic', cursive;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html[data-theme='dark'] {
  color-scheme: dark;
  --ink: #f8eef5;
  --ink-2: #e6d9e3;
  --muted: #b9a8b6;
  --line: #3b2f3f;
  --surface: #221a27;
  --surface-2: #2e2434;
  --surface-3: #2a2030;
  --surface-hover: #382d3f;
  --placeholder: #9a8a98;
  --shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 2px 10px -4px rgba(0, 0, 0, 0.6);
  --amber-50: #2c2214;
  --amber-100: #3a2c12;
  --amber-300: #7a5a17;
  --amber-800: #fcd88a;
  --mint-50: #12291f;
  --mint-200: #1f5a40;
  --mint-700: #8ae6bd;
  --lila-50: #241c38;
  --lila-100: #2e2448;
  --lila-200: #4b3a78;
  --lila-600: #c4b2ff;
  --rose-50: #36161f;
  --rose-700: #ff8fa6;
}
/* El papel del libro y las tarjetas siguen siendo papel claro también en modo oscuro */
.page-face, .mobile-book, .cover-preview, .mini, .lightbox-card img, .admin-item img {
  color-scheme: light;
  --ink: #2a1b26;
  --ink-2: #3f3140;
  --muted: #6b5a69;
  --line: #eadde4;
  --acc-soft: var(--acc-soft-l);
  --acc-soft-2: var(--acc-soft-2-l);
  --acc-line: var(--acc-line-l);
  --acc-ink: var(--acc-ink-l);
  --rose-700: #be123c;
  color: var(--ink-2);
}
html[data-theme='dark'] .btn-danger, html[data-theme='dark'] .slot-tools button.del { color: #2a0d15; }
html[data-theme='dark'] .page-face .slot-tools button.del { color: #fff; }
html[data-theme='dark'] .toast.success { background: #0f5d45; }
html[data-theme='dark'] .toast.error { background: #8f1d34; color: #fff; }
html[data-theme='dark'] .btn-amber { background: #fbbf24; color: #2a1b06; }
html[data-theme='dark'] .washi { filter: saturate(1.1) brightness(1.05); }
html, body { margin: 0; }
html { scrollbar-color: var(--acc-line) transparent; accent-color: var(--acc-strong); }
body {
  font-family: var(--font);
  font-size: 1rem;
  color: var(--ink-2);
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(color-mix(in srgb, var(--acc-line) 70%, transparent) 1.2px, transparent 1.4px);
  background-size: 26px 26px;
  overflow-x: hidden;
  caret-color: var(--acc-strong);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--acc-soft-2); color: var(--ink); }
h1, h2, h3, h4 { font-family: var(--display); color: var(--ink); margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--acc-ink); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
.ico { flex: none; display: block; }

:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--acc-strong);
  outline-offset: 2px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.78rem; }
.bold { font-weight: 700; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 0.75rem; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- Botones ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  min-height: 2.75rem;
  padding: 0.6rem 1.05rem;
  font: 700 0.92rem/1.1 var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: transform 0.15s var(--ease), background-color 0.15s, box-shadow 0.15s, filter 0.15s;
  color: var(--ink-2);
  background: var(--surface);
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { color: #fff; background: var(--acc-strong); box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--acc-strong) 80%, transparent); }
.btn-primary:hover { filter: brightness(0.93); }
.btn-lila { color: #fff; background: var(--lila-600); }
.btn-lila:hover { filter: brightness(0.93); }
.btn-amber { color: #fff; background: #b45309; }
.btn-amber:hover { filter: brightness(0.93); }
.btn-soft, .btn-pink-soft { background: var(--acc-soft); border-color: var(--acc-line); color: var(--acc-ink); }
.btn-soft:hover, .btn-pink-soft:hover { background: var(--acc-soft-2); }
.btn-mint { background: var(--mint-50); border-color: var(--mint-200); color: var(--mint-700); }
.btn-ghost { background: var(--surface-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { background: var(--rose-700); color: #fff; }
.btn-danger:hover { filter: brightness(0.93); }
.btn-danger-soft { background: var(--rose-50); color: var(--rose-700); }
.btn-sm { min-height: 2.5rem; padding: 0.45rem 0.8rem; font-size: 0.85rem; border-radius: 12px; }
.btn-lg { min-height: 3.2rem; padding: 0.85rem 1.4rem; font-size: 1rem; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 2.75rem; min-height: 2.75rem; padding: 0; border-radius: 999px; }
@media (pointer: coarse) { .btn, .btn-sm { min-height: 2.75rem; } }

/* ---------- Tarjetas y campos ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card.soft { box-shadow: var(--shadow-sm); }
label.lbl { display: block; font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 0.35rem; }
.field, select.field, textarea.field {
  width: 100%;
  font: 600 1rem/1.3 var(--font);
  color: var(--ink);
  min-height: 2.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field::placeholder { color: var(--placeholder); }
.field:hover { border-color: var(--acc-line); }
.field:focus { border-color: var(--acc-strong); box-shadow: 0 0 0 3px var(--acc-soft-2); }
textarea.field { resize: vertical; min-height: 4.4rem; }
input[type='color'].field { padding: 0.25rem; cursor: pointer; }
input[type='range'] { width: 100%; accent-color: var(--acc-strong); min-height: 1.6rem; }
input[type='checkbox'] { accent-color: var(--acc-strong); width: 1.15rem; height: 1.15rem; flex: none; }
.check { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 0.92rem; cursor: pointer; user-select: none; min-height: 2.75rem; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; line-height: 1.45; }
.err { color: var(--rose-700); font-weight: 700; font-size: 0.9rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--acc-soft-2);
  color: var(--acc-ink);
  white-space: nowrap;
}
.chip .ico { width: 14px; height: 14px; }
.chip.lila { background: var(--lila-50); color: var(--lila-600); border: 1px solid var(--lila-200); }
.chip.amber { background: var(--amber-100); color: var(--amber-800); border: 1px solid var(--amber-300); }
.chip.mint { background: var(--mint-50); color: var(--mint-700); border: 1px solid var(--mint-200); }
.chip.gray { background: var(--surface-2); color: var(--muted); }

/* ---------- Cinta washi ---------- */
.washi {
  position: absolute;
  width: 4.2rem;
  height: 1.15rem;
  z-index: 6;
  pointer-events: none;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0 6px, transparent 6px 12px),
    color-mix(in srgb, var(--acc) 55%, transparent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  clip-path: polygon(3% 0, 97% 4%, 100% 50%, 96% 100%, 2% 96%, 0 50%);
}
.washi.lila { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0 6px, transparent 6px 12px), rgba(167, 139, 250, 0.55); }

/* ---------- Avisos ---------- */
#toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; left: 1.2rem; z-index: 200; display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; pointer-events: none; }
.toast {
  max-width: 24rem;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 0.8rem 1rem;
  border-radius: 16px;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.3s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: #047857; }
.toast.error { background: var(--rose-700); }

/* ---------- Diálogos ---------- */
dialog.dlg {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 1.5rem;
  width: min(30rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  box-shadow: 0 30px 60px -20px rgba(40, 15, 30, 0.45);
  color: var(--ink-2);
}
dialog.dlg[open] { animation: dlgIn 0.28s var(--ease); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
dialog.dlg.full { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; padding: 0; background: var(--bg); }
dialog.dlg.dark { background: transparent; border: 0; box-shadow: none; padding: 0; width: min(70rem, calc(100vw - 1rem)); overflow: visible; }
dialog::backdrop { background: rgba(30, 12, 25, 0.55); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.dlg-head h3 { font-size: 1.25rem; display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Inicio ---------- */
.home { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 3rem 1rem; }
.home-inner { width: 100%; max-width: 60rem; display: flex; flex-direction: column; gap: 1.4rem; }
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 2.5rem; align-items: center; padding: 0.5rem 0 1rem; }
.hero h1 { font-size: clamp(2.8rem, 7vw, 4.4rem); letter-spacing: -0.02em; margin-bottom: 1rem; }
.hero h1 span { color: var(--acc-strong); }
.hero p { color: var(--muted); font-size: 1.08rem; line-height: 1.6; max-width: 30rem; }
.hero .lead-hand { font-family: var(--hand); font-size: 1.6rem; color: var(--acc-ink); margin-bottom: 0.4rem; display: block; }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 1.5rem; text-align: center; }
  .hero p { margin: 0 auto; }
}
.hero-art { position: relative; height: 19rem; }
.mini {
  position: absolute;
  width: 15.5rem;
  aspect-ratio: 16 / 10;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 30px -18px rgba(90, 30, 60, 0.45), 0 1px 0 rgba(0, 0, 0, 0.04);
  overflow: hidden;
  border: 1px solid var(--line);
  transition: transform 0.5s var(--ease);
}
.mini .fest { height: 26%; background: var(--c, var(--acc)); position: relative; }
.mini .fest::after { content: ''; position: absolute; left: 0; right: 0; bottom: -9px; height: 18px; background: radial-gradient(circle at 9px 0, var(--c, var(--acc)) 9px, transparent 9.5px) repeat-x; background-size: 18px 18px; }
.mini .msg { font-family: var(--hand); font-size: 1.35rem; color: var(--ink); padding: 1rem 1rem 0; line-height: 1.1; }
.mini .sig { position: absolute; right: 0.8rem; bottom: 0.55rem; font-family: var(--hand); font-size: 1.05rem; color: var(--muted); }
.mini.m1 { --c: #ff8fb8; left: 6%; top: 12%; transform: rotate(-7deg); }
.mini.m2 { --c: #b9a2ff; left: 30%; top: 30%; transform: rotate(4deg); z-index: 2; }
.mini.m3 { --c: #ffc27a; left: 12%; top: 52%; transform: rotate(-2deg); z-index: 3; }
.hero-art:hover .m1 { transform: rotate(-10deg) translate(-8px, -6px); }
.hero-art:hover .m2 { transform: rotate(6deg) translate(8px, -4px); }
.mini-wrap { position: absolute; inset: 0; }
.mini-tape { position: absolute; }
@media (max-width: 760px) { .hero-art { height: 15rem; max-width: 22rem; margin: 0 auto; width: 100%; } .mini { width: 12.5rem; } }

.icon-tile { width: 2.9rem; height: 2.9rem; border-radius: 16px; background: var(--acc-soft-2); color: var(--acc-ink); display: flex; align-items: center; justify-content: center; flex: none; }
.icon-tile.lila { background: var(--lila-100); color: var(--lila-600); }
.icon-tile.amber { background: var(--amber-100); color: var(--amber-800); }
.book-list { display: flex; flex-direction: column; gap: 0.5rem; }
.book-list a { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; min-height: 3rem; padding: 0.7rem 0.95rem; border-radius: 14px; background: var(--acc-soft); border: 1px solid var(--acc-soft-2); text-decoration: none; color: var(--ink); font-weight: 700; }
.book-list a:hover { border-color: var(--acc-line); }

.link-box { display: flex; gap: 0.5rem; align-items: stretch; }
.link-box input { flex: 1; min-width: 0; font: 600 0.85rem ui-monospace, Consolas, monospace; padding: 0.55rem 0.75rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-3); color: var(--ink-2); }
.link-card { padding: 1.1rem; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 0.6rem; box-shadow: var(--shadow-sm); }
.link-card h3 { display: flex; align-items: center; gap: 0.5rem; }
.link-card.admin { border-color: var(--amber-300); background: var(--amber-50); }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1rem;
}
.topbar-inner { max-width: 80rem; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.topbar h2 { font-size: 1.15rem; }
.status-line { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; }
.intro { max-width: 46rem; margin: 1.1rem auto 0; padding: 0 1rem; text-align: center; color: var(--muted); line-height: 1.55; }
.intro strong { color: var(--ink); }
.notice { max-width: 46rem; margin: 1rem auto 0; padding: 0.8rem 1rem; border-radius: 16px; background: var(--amber-50); border: 1px solid var(--amber-300); color: var(--amber-800); font-weight: 700; font-size: 0.9rem; text-align: center; display: flex; align-items: center; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.notice.lila { background: var(--lila-50); border-color: var(--lila-200); color: var(--lila-600); }

.tabs { display: flex; gap: 0.3rem; padding: 0.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; scrollbar-width: none; box-shadow: var(--shadow-sm); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { appearance: none; border: 0; background: transparent; font: 700 0.9rem var(--font); color: var(--muted); min-height: 2.75rem; padding: 0.5rem 0.95rem; border-radius: 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 0.45rem; }
.tabs button:hover { color: var(--ink); background: var(--surface-3); }
.tabs button.on { background: var(--acc-soft-2); color: var(--acc-ink); }
.tabs .count { display: inline-block; min-width: 1.3rem; padding: 0 0.35rem; border-radius: 999px; background: var(--amber-300); color: var(--amber-800); font-size: 0.75rem; }

.page { max-width: 80rem; margin: 0 auto; padding: 1.2rem 1rem 3rem; }

/* ---------- Libro 3D ---------- */
.stage { display: flex; flex-direction: column; align-items: center; padding: 1.6rem 0.75rem 1rem; }
.book-scene { perspective: 2200px; width: 100%; display: flex; justify-content: center; }
.book-3d { position: relative; width: 920px; max-width: 94vw; height: 590px; transform-style: preserve-3d; transition: transform 0.75s var(--ease); }
.book-3d.state-cover { transform: translateX(-25%); }
.book-3d.state-back { transform: translateX(25%); }
.sheet { position: absolute; top: 0; left: 50%; width: 50%; height: 100%; transform-origin: left center; transform-style: preserve-3d; transition: transform 0.9s cubic-bezier(0.645, 0.045, 0.355, 1); }
.sheet.flipped { transform: rotateY(-180deg); }
.page-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--paper); overflow: hidden; display: flex; flex-direction: column; border: 1px solid #efe2e8; }
.page-front { border-radius: 4px 18px 18px 4px; box-shadow: inset 14px 0 24px -14px rgba(100, 60, 80, 0.25), 4px 10px 24px rgba(110, 50, 85, 0.16); }
.page-back { transform: rotateY(180deg); border-radius: 18px 4px 4px 18px; box-shadow: inset -14px 0 24px -14px rgba(100, 60, 80, 0.25), -4px 10px 24px rgba(110, 50, 85, 0.16); }
.corner { position: absolute; bottom: 0; width: 52px; height: 52px; z-index: 15; cursor: pointer; transition: width 0.2s var(--ease), height 0.2s var(--ease); border: 0; padding: 0; }
.corner-right { right: 0; background: linear-gradient(135deg, transparent 50%, var(--acc-soft-2) 50%); border-bottom-right-radius: 18px; }
.corner-left { left: 0; background: linear-gradient(225deg, transparent 50%, var(--acc-soft-2) 50%); border-bottom-left-radius: 18px; }
.corner:hover, .corner:focus-visible { width: 66px; height: 66px; }
.corner-right:hover { background: linear-gradient(135deg, transparent 50%, var(--acc-line) 50%); }
.corner-left:hover { background: linear-gradient(225deg, transparent 50%, var(--acc-line) 50%); }

.mobile-book { width: 100%; max-width: 28rem; min-height: 30rem; background: var(--paper); border-radius: 22px; border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 22px 40px -18px rgba(110, 40, 80, 0.32), 0 4px 0 -1px #fff, 0 5px 0 0 var(--line), 0 8px 0 -1px #fff, 0 9px 0 0 var(--line); }
.mobile-book > * { flex: 1; }
.flip-next { animation: flipNext 0.38s var(--ease); }
.flip-prev { animation: flipPrev 0.38s var(--ease); }
@keyframes flipNext { 45% { transform: perspective(900px) rotateY(-14deg) scale(0.98); opacity: 0.7; } }
@keyframes flipPrev { 45% { transform: perspective(900px) rotateY(14deg) scale(0.98); opacity: 0.7; } }

.book-nav { margin-top: 1.6rem; display: flex; align-items: center; justify-content: center; gap: 0.7rem; }
.book-nav .indicator { padding: 0.55rem 1rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.85rem; font-weight: 700; color: var(--muted); min-width: 9rem; text-align: center; }
.book-hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.75rem; text-align: center; }

/* Página interior */
.inner-page { height: 100%; padding: 1.1rem 1.1rem 0.6rem; display: flex; flex-direction: column; gap: 0.6rem; background: var(--paper); }
.slots { flex: 1; display: flex; flex-direction: column; gap: 0.85rem; min-height: 0; }
.slot { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.slot.empty { border: 2px dashed var(--acc-soft-2); border-radius: 16px; background: color-mix(in srgb, var(--acc-soft) 60%, transparent); align-items: center; justify-content: center; gap: 0.4rem; color: var(--acc-ink); font-size: 0.85rem; font-weight: 700; padding: 0.5rem; text-align: center; }
button.slot.empty { appearance: none; font-family: var(--font); cursor: pointer; transition: background-color 0.15s, border-color 0.15s; }
button.slot.empty:hover { background: var(--acc-soft-2); border-color: var(--acc-line); }
.slot-frame { position: relative; flex: 1; min-height: 0; display: flex; }
.slot-frame .washi { top: -0.45rem; left: calc(50% - 2.1rem); transform: rotate(-2.5deg); }
.slot:nth-child(2) .slot-frame .washi { transform: rotate(3deg); left: calc(50% - 1.6rem); }
.slot-card { position: relative; flex: 1; min-height: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: 0 6px 14px -10px rgba(90, 30, 60, 0.45); cursor: zoom-in; padding: 0; appearance: none; display: block; width: 100%; transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.slot-card img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.slot-card:hover { transform: translateY(-2px) rotate(-0.4deg); box-shadow: 0 12px 22px -12px rgba(90, 30, 60, 0.5); }
.slot.stuck .slot-frame { animation: stickIn 0.9s var(--ease) both; }
.slot.stuck .washi { animation: tapeIn 0.5s 0.55s var(--ease) both; }
@keyframes stickIn { 0% { transform: translateY(-18px) rotate(-4deg) scale(1.06); opacity: 0; } 60% { transform: translateY(2px) rotate(0.6deg) scale(1); opacity: 1; } }
@keyframes tapeIn { from { opacity: 0; transform: translateY(-8px) rotate(-12deg) scaleX(0.6); } }
.slot-meta { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.3rem 0.2rem 0; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.slot-meta .who { color: var(--acc-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-tools { position: absolute; top: 0.4rem; right: 0.4rem; display: flex; gap: 0.3rem; z-index: 7; }
.slot-tools button { width: 2.25rem; height: 2.25rem; border-radius: 999px; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); background: #fff; color: var(--ink-2); }
.slot-tools button.del { background: var(--rose-700); color: #fff; }
.slot-tools .chip { box-shadow: var(--shadow-sm); background: #fff; }
.pageno { text-align: center; font-size: 0.78rem; font-weight: 700; color: var(--muted); border-top: 1px solid var(--line); padding-top: 0.4rem; font-variant-numeric: tabular-nums; }

/* Portada */
.cover { height: 100%; width: 100%; position: relative; overflow: hidden; padding: 2rem 1.7rem 1.4rem; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; background-size: cover; background-position: center; }
.cover .veil { position: absolute; inset: 0; pointer-events: none; }
.cover > :not(.veil) { position: relative; z-index: 1; }
.cover > .tapes { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.cover .tapes .washi:first-child { top: 0.9rem; left: -0.6rem; transform: rotate(-32deg); width: 5.4rem; }
.cover .tapes .washi:last-child { top: 0.9rem; right: -0.6rem; transform: rotate(32deg); width: 5.4rem; }
.cover .cover-bottom { width: 100%; display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; opacity: 0.85; padding-top: 0.9rem; border-top: 1px solid rgba(120, 90, 110, 0.25); }
.cover .cake { width: 5.4rem; height: 5.4rem; border-radius: 24px; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; margin: 0 auto 1.1rem; box-shadow: 0 10px 20px -12px rgba(90, 30, 60, 0.45); transform: rotate(-4deg); }
.cover .sub { display: inline-block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.35rem 0.85rem; border-radius: 999px; color: #fff; margin-bottom: 0.9rem; }
.cover .ttl { font-size: 2.05rem; font-weight: 700; line-height: 1.1; margin-bottom: 0.7rem; overflow-wrap: anywhere; text-wrap: balance; }
.cover .ded { font-size: 0.92rem; line-height: 1.55; max-width: 18rem; margin: 0 auto; white-space: pre-line; overflow-wrap: anywhere; }

.backcover { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1.7rem; gap: 0.9rem; }
.backcover .big { color: var(--acc-strong); }

/* ---------- Lightbox ---------- */
.lightbox-card { background: var(--surface); border-radius: 24px; padding: 0.8rem; position: relative; }
.lightbox-card img { width: 100%; max-height: 74vh; object-fit: contain; border-radius: 14px; background: #faf7f9; }
.lightbox-meta .who { color: var(--acc-ink); }
.lightbox-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.75rem 0.4rem 0.1rem; }
.lightbox-meta .who { font-family: var(--hand); font-size: 1.55rem; color: var(--acc-ink); line-height: 1; }

/* ---------- Editor ---------- */
.editor { min-height: 100%; display: flex; flex-direction: column; }
.editor-top { position: sticky; top: 0; z-index: 8; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 0.55rem 0.9rem; }
.editor-body { flex: 1; width: 100%; max-width: 80rem; margin: 0 auto; padding: 0.9rem; display: grid; grid-template-columns: 1fr 21rem; grid-template-areas: 'canvas tools' 'save tools'; gap: 1rem; align-items: start; }
.editor-body .canvas-wrap { grid-area: canvas; }
.editor-body .tool-panel { grid-area: tools; }
.editor-body .save-bar { grid-area: save; }
@media (max-width: 900px) {
  .editor-body { grid-template-columns: 1fr; grid-template-areas: 'canvas' 'tools' 'save'; padding: 0.6rem; gap: 0.75rem; }
  .editor-body .canvas-wrap { position: sticky; top: 3.7rem; z-index: 6; }
  .hide-narrow { display: none; }
}
.canvas-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 0.45rem; box-shadow: var(--shadow); }
.canvas-wrap canvas { width: 100%; height: auto; aspect-ratio: 16 / 10; display: block; border-radius: 13px; touch-action: none; background: #fff; }
.tool-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; box-shadow: var(--shadow-sm); }
.tool-panel .tabs { box-shadow: none; background: var(--surface-3); }
.tool-panel .tabs button { flex: 1; justify-content: center; }
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.tool-grid button { appearance: none; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; min-height: 3.6rem; padding: 0.45rem 0.3rem; font: 700 0.82rem var(--font); color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem; }
.tool-grid button.on { border-color: var(--acc-strong); background: var(--acc-soft); color: var(--acc-ink); }
.palette { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.45rem; }
.palette button { aspect-ratio: 1; min-width: 2.1rem; border-radius: 999px; border: 2px solid rgba(0, 0, 0, 0.08); cursor: pointer; padding: 0; }
.palette button.on { outline: 3px solid var(--acc-strong); outline-offset: 2px; }
.palette label { aspect-ratio: 1; border-radius: 999px; border: 2px dashed var(--muted); color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; position: relative; }
.palette label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sec-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.45rem; }
.save-bar { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: flex-end; box-shadow: var(--shadow-sm); }

.fx-grid { --fx: #8b5cf6; --fx-text: #4a2c40; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; }
@media (max-width: 380px) { .fx-grid { grid-template-columns: repeat(4, 1fr); } }
.fx-grid button { appearance: none; border: 1.5px solid var(--line); background: #fffdf9; border-radius: 12px; padding: 0.35rem 0.1rem 0.3rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; min-height: 3.6rem; color: #4a2c40; }
.fx-grid button.on { border-color: var(--acc-strong); box-shadow: 0 0 0 2px var(--acc-soft-2); }
.fx-name { font: 700 0.68rem/1.1 var(--font); color: #6b5a69; text-align: center; }
.fx-ag { font: 800 1.35rem/1.1 'Nunito', sans-serif; color: var(--fx-text); position: relative; }
.fx-paralela { text-shadow: 3px 3px 0 var(--fx); }
.fx-brillo { text-shadow: 0 0 8px var(--fx), 0 0 14px var(--fx); }
.fx-eco { text-shadow: 2px 2px 0 color-mix(in srgb, var(--fx) 60%, transparent), 4px 4px 0 color-mix(in srgb, var(--fx) 35%, transparent), 6px 6px 0 color-mix(in srgb, var(--fx) 18%, transparent); }
.fx-contorno { -webkit-text-stroke: 3px var(--fx); paint-order: stroke fill; }
.fx-fondo { background: color-mix(in srgb, var(--fx) 70%, transparent); padding: 0 0.3rem; border-radius: 6px; }
.fx-desalineado { text-shadow: none; }
.fx-desalineado::after { content: 'Ag'; position: absolute; left: 3px; top: 3px; color: transparent; -webkit-text-stroke: 1.5px var(--fx); }
.fx-sinrelleno { color: transparent; -webkit-text-stroke: 1.5px var(--fx-text); }
.fx-neon { color: color-mix(in srgb, var(--fx) 25%, #fff); text-shadow: 0 0 4px var(--fx), 0 0 10px var(--fx), 0 0 16px var(--fx); }
.fx-distorsion { text-shadow: -2px 0 0 #00d4ff, 2px 0 0 #ff2d95; }

.theme-toggle { position: fixed; top: 0.9rem; right: 0.9rem; z-index: 60; }
.topbar .theme-toggle, .gift-bar .theme-toggle { position: static; }

/* ---------- Panel del organizador ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: 1rem; }
.admin-item { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; box-shadow: var(--shadow-sm); }
.admin-item.pending { border: 2px solid var(--amber-300); background: var(--amber-50); }
.admin-item img { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #faf7f9; border-radius: 12px; cursor: zoom-in; }
.admin-item .who { font-weight: 700; font-size: 0.88rem; color: var(--acc-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phase-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.phase-pick button { appearance: none; border: 1.5px solid var(--line); background: var(--surface); border-radius: 16px; padding: 0.8rem 0.5rem; cursor: pointer; font: 700 0.9rem var(--font); color: var(--muted); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.phase-pick button.on { border-color: var(--acc-strong); background: var(--acc-soft); color: var(--acc-ink); }
@media (max-width: 560px) { .phase-pick { grid-template-columns: 1fr; } .phase-pick button { flex-direction: row; justify-content: center; } }
.cover-editor { display: grid; grid-template-columns: 19rem 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 800px) { .cover-editor { grid-template-columns: 1fr; } }
.cover-preview { width: 100%; max-width: 19rem; aspect-ratio: 460 / 590; border-radius: 6px 18px 18px 6px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); margin: 0 auto; background: #fff; }
.section-title { display: flex; align-items: center; gap: 0.5rem; font-size: 1.15rem; }

/* ---------- Entrega a la idol ---------- */
.gift { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 5rem; }
.gift-bar { position: fixed; bottom: 1rem; left: 0; right: 0; z-index: 60; display: flex; justify-content: center; gap: 0.5rem; pointer-events: none; }
.gift-bar > * { pointer-events: auto; box-shadow: var(--shadow); }
.gift-preview { position: fixed; top: 0.9rem; left: 0.9rem; z-index: 60; }
.gift-intro { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.3rem; padding: 2rem 1rem; text-align: center; }
.gift-intro h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); letter-spacing: -0.02em; }
.gift-intro .lead-hand { font-family: var(--hand); font-size: 1.8rem; color: var(--acc-ink); }
.gift-box { position: relative; width: 8.5rem; height: 7rem; margin-bottom: 0.4rem; }
.gift-box .box { position: absolute; left: 0.75rem; right: 0.75rem; bottom: 0; height: 4.8rem; border-radius: 10px; background: var(--acc); box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.08), 0 18px 30px -16px color-mix(in srgb, var(--acc-strong) 70%, transparent); }
.gift-box .band { position: absolute; left: calc(50% - 0.55rem); width: 1.1rem; bottom: 0; height: 4.8rem; background: rgba(255, 255, 255, 0.85); }
.gift-box .lid-wrap { position: absolute; left: 0; right: 0; top: 0; height: 2.6rem; animation: lid 2.6s var(--ease) infinite; transform-origin: 50% 100%; }
.gift-box .lid { position: absolute; left: 0; right: 0; bottom: 0; height: 1.6rem; border-radius: 8px; background: color-mix(in srgb, var(--acc) 82%, #fff); }
.gift-box .lid::after { content: ''; position: absolute; left: calc(50% - 0.55rem); width: 1.1rem; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.85); }
.gift-box .bow { position: absolute; left: calc(50% - 1.6rem); top: -0.5rem; width: 3.2rem; height: 1.6rem; }
.gift-box .bow::before, .gift-box .bow::after { content: ''; position: absolute; top: 0; width: 1.6rem; height: 1.5rem; border: 0.42rem solid #fff; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; }
.gift-box .bow::before { left: 0; transform: rotate(-20deg); }
.gift-box .bow::after { right: 0; transform: rotate(20deg); }
@keyframes lid { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(-7px) rotate(-4deg); } 90% { transform: translateY(-2px) rotate(2deg); } }
.signatures { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.2rem 1rem; max-width: 40rem; }
.signatures span { font-family: var(--hand); font-size: 1.5rem; color: var(--acc-ink); opacity: 0; animation: sigIn 0.6s var(--ease) forwards; }
@keyframes sigIn { from { opacity: 0; transform: translateY(8px) rotate(-3deg); } to { opacity: 1; transform: none; } }
.count-big { font-family: var(--display); font-size: clamp(3.5rem, 12vw, 6rem); font-weight: 700; color: var(--acc-strong); line-height: 1; font-variant-numeric: tabular-nums; }

.confetti { position: fixed; top: -12px; z-index: 300; pointer-events: none; border-radius: 2px; animation: confettiFall 2.8s ease-out forwards; }
@keyframes confettiFall { from { transform: translateY(-20px) rotate(0deg); opacity: 0.95; } to { transform: translateY(100vh) rotate(540deg); opacity: 0; } }

.progress { width: 100%; height: 0.6rem; border-radius: 999px; background: var(--acc-soft-2); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--acc-strong); transition: width 0.3s var(--ease); }
.spinner { width: 2rem; height: 2rem; border-radius: 999px; border: 3px solid var(--acc-soft-2); border-top-color: var(--acc-strong); animation: spin 0.8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { min-height: 70vh; display: flex; flex-direction: column; gap: 0.8rem; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; }

@media (max-width: 480px) {
  .stage { padding: 1rem 0.6rem 0.5rem; }
  .book-nav { gap: 0.4rem; margin-top: 1.2rem; }
  .book-nav .indicator { min-width: 0; padding: 0.5rem 0.7rem; font-size: 0.8rem; }
  .book-nav .btn { padding: 0.55rem 0.75rem; }
  .card { padding: 1.15rem; border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
