/* =========================================================
   Nuestra Biblioteca — hoja de estilos
   Estética zen: papel washi con fibra, tinta sumi, índigo ai,
   un toque de bermellón (el sello hanko) y pétalos de sakura.
   Mucho aire entre las cosas (間, ma) y movimientos lentos,
   como de respiración. Nada de tonos café.
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  /* 白練 shironeri — papel de seda, neutro */
  --paper:      #f4f3ef;
  --surface:    #fbfbf9;
  --surface-2:  #ecebe6;
  /* 墨 sumi — tinta */
  --ink:        #26282d;
  --ink-soft:   #4f535b;
  --muted:      #8b8e95;
  --line:       #dfddd6;
  --line-soft:  #e9e7e1;
  /* 藍 ai — índigo: el color de lo que se toca */
  --accent:     #3e5c7e;
  --accent-ink: #ffffff;
  --accent-soft:#e1e7ee;
  /* 朱 shu — bermellón del sello; también marca lo que falta */
  --shu:        #c4533a;
  /* 桜 sakura */
  --petal:      #e4a9b1;
  --petal-soft: #f6e8ea;
  --alert:      #c4533a;
  /* 苔 koke — musgo: lo que ya tienen */
  --good:       #6b8a5e;
  --good-soft:  #e5ebe0;
  --warn:       #c9a24a;

  --shadow-sm:  0 1px 1px rgba(28, 32, 40, .04);
  --shadow-md:  0 1px 2px rgba(28, 32, 40, .06), 0 8px 18px rgba(28, 32, 40, .07);
  --shadow-lg:  0 2px 8px rgba(28, 32, 40, .08), 0 26px 52px rgba(28, 32, 40, .16);
  --grain:      .55;

  /* Windows trae Yu Mincho y Yu Gothic; macOS, Hiragino. Sin descargas. */
  --mincho: "Yu Mincho", YuMincho, "Hiragino Mincho ProN", "Shippori Mincho",
            "Noto Serif JP", "Noto Serif CJK JP", "Songti SC", Georgia, serif;
  --gothic: "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", "Noto Sans JP",
            "Noto Sans CJK JP", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Curva de "respiración": entra rápido y se posa despacio. */
  --calma: cubic-bezier(.2, .7, .2, 1);

  --r-xs: 3px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;

  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* 夜 yoru — noche: tinta azulada, sin marrones */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #111316;
    --surface:    #181b1f;
    --surface-2:  #22262b;
    --ink:        #e9e7e2;
    --ink-soft:   #b9bbc0;
    --muted:      #7f838b;
    --line:       #2b2f35;
    --line-soft:  #1f2227;
    --accent:     #9fb6d3;
    --accent-ink: #10151c;
    --accent-soft:#1f2835;
    --shu:        #e0765d;
    --petal:      #d79aa3;
    --petal-soft: #2a2226;
    --alert:      #e0765d;
    --good:       #93b486;
    --good-soft:  #1c2620;
    --warn:       #d4b36a;
    --shadow-sm:  0 1px 1px rgba(0, 0, 0, .25);
    --shadow-md:  0 1px 2px rgba(0, 0, 0, .3), 0 8px 18px rgba(0, 0, 0, .3);
    --shadow-lg:  0 2px 8px rgba(0, 0, 0, .4), 0 26px 52px rgba(0, 0, 0, .55);
    --grain:      .35;
  }
}

:root[data-theme="dark"] {
  --paper:      #111316;
  --surface:    #181b1f;
  --surface-2:  #22262b;
  --ink:        #e9e7e2;
  --ink-soft:   #b9bbc0;
  --muted:      #7f838b;
  --line:       #2b2f35;
  --line-soft:  #1f2227;
  --accent:     #9fb6d3;
  --accent-ink: #10151c;
  --accent-soft:#1f2835;
  --shu:        #e0765d;
  --petal:      #d79aa3;
  --petal-soft: #2a2226;
  --alert:      #e0765d;
  --good:       #93b486;
  --good-soft:  #1c2620;
  --warn:       #d4b36a;
  --shadow-sm:  0 1px 1px rgba(0, 0, 0, .25);
  --shadow-md:  0 1px 2px rgba(0, 0, 0, .3), 0 8px 18px rgba(0, 0, 0, .3);
  --shadow-lg:  0 2px 8px rgba(0, 0, 0, .4), 0 26px 52px rgba(0, 0, 0, .55);
  --grain:      .35;
}

/* =========================================================
   Estilo CLÁSICO (el de siempre para todos los usuarios)
   Papel blanco cálido, tinta azul oscuro, verde biblioteca y un
   toque burdeos. Títulos en tipografía de libro. Sin tonos café.
   Los bloques de arriba son el estilo ZEN (premium).
   Se aplica con <html data-estilo="clasico">; va después de los
   bloques zen para ganarles con la misma especificidad.
   ========================================================= */
:root[data-estilo="clasico"] {
  --paper:      #f7f6f2;
  --surface:    #ffffff;
  --surface-2:  #efeee9;
  --ink:        #1d2330;
  --ink-soft:   #454c5a;
  --muted:      #858a94;
  --line:       #dedcd6;
  --line-soft:  #e9e8e3;
  --accent:     #2d5a4c;   /* verde biblioteca */
  --accent-ink: #ffffff;
  --accent-soft:#e2ece7;
  --shu:        #8e2f3c;   /* burdeos: marca lo que falta y los detalles */
  --petal:      #c9a0a8;
  --petal-soft: #f3eaeb;
  --alert:      #a83a44;
  --good:       #2d6a4f;
  --good-soft:  #e1eee6;
  --warn:       #b8913a;
  --grain:      .25;
  --mincho: "Palatino Linotype", "Book Antiqua", Palatino, "Iowan Old Style", Georgia, serif;
  --gothic: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root[data-estilo="clasico"]:not([data-theme="light"]) {
    --paper:      #14171c;
    --surface:    #1b1f26;
    --surface-2:  #242932;
    --ink:        #ecebe7;
    --ink-soft:   #bfc2c8;
    --muted:      #858a94;
    --line:       #2e333c;
    --line-soft:  #21252c;
    --accent:     #7fbfa6;
    --accent-ink: #0f1a16;
    --accent-soft:#1c2a25;
    --shu:        #d8808b;
    --petal-soft: #2a2124;
    --alert:      #e0848d;
    --good:       #7fbf9b;
    --good-soft:  #1b2a22;
  }
}
:root[data-estilo="clasico"][data-theme="dark"] {
  --paper:      #14171c;
  --surface:    #1b1f26;
  --surface-2:  #242932;
  --ink:        #ecebe7;
  --ink-soft:   #bfc2c8;
  --muted:      #858a94;
  --line:       #2e333c;
  --line-soft:  #21252c;
  --accent:     #7fbfa6;
  --accent-ink: #0f1a16;
  --accent-soft:#1c2a25;
  --shu:        #d8808b;
  --petal-soft: #2a2124;
  --alert:      #e0848d;
  --good:       #7fbf9b;
  --good-soft:  #1b2a22;
}

/* Lo que es solo del estilo zen, se esconde en el clásico */
[data-estilo="clasico"] :is(.petalos, .enzan, .tab-kanji, .seal, .brand-enso) { display: none !important; }
[data-estilo="zen"] .brand-clasico { display: none !important; }
[data-estilo="clasico"] body { background: var(--paper); }
[data-estilo="clasico"] :is(.topbar-title, .sheet h2, .l-heroe h1, .empty h3, .card-title) { letter-spacing: .01em; }
.brand-clasico { width: 36px; height: 36px; flex: none; color: var(--accent); stroke-width: 1.7; }
.l-marca .brand-clasico { width: 32px; height: 32px; }

/* Números de los pasos de la página de inicio: romanos en un círculo
   (clásico) o un sello bermellón con kanji (zen). */
.paso-num {
  display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 14px;
  border-radius: 50%; border: 1.5px solid var(--shu); color: var(--shu);
  font: 500 15px/1 var(--mincho); letter-spacing: .04em;
}
[data-estilo="zen"] .paso-num {
  border: 0; border-radius: 4px; background: var(--shu); color: #fff8f4;
  font-size: 18px; transform: rotate(-4deg);
}
/* Los números de los pasos: romanos en vez de kanji */
[data-estilo="clasico"] .paso-num::before { content: attr(data-romano); }
[data-estilo="zen"] .paso-num::before { content: attr(data-kanji); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  /* Un rubor de sakura en la esquina, como luz de mañana sobre el papel. */
  background:
    radial-gradient(900px 520px at 105% -8%, var(--petal-soft), transparent 62%),
    radial-gradient(700px 480px at -10% 110%, var(--accent-soft), transparent 60%),
    var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 15px/1.7 var(--gothic);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
/* Fibra de papel washi: ruido muy suave encima de todo el fondo. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .46 0 0 0 0 .5 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: var(--petal-soft); }

:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Pétalos de sakura ---------- */
.petalos {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.petalo {
  position: absolute; top: -40px; left: var(--x);
  animation: caer var(--d) linear var(--delay) infinite;
}
.petalo i {
  display: block; width: var(--s); height: calc(var(--s) * .78);
  background: linear-gradient(135deg, var(--petal), color-mix(in srgb, var(--petal) 55%, #fff));
  border-radius: 100% 0 100% 0 / 100% 0 100% 0;
  opacity: .62;
  animation: mecer calc(var(--d) / 4) ease-in-out var(--delay) infinite alternate;
}
@keyframes caer {
  to { transform: translate3d(var(--viento), 112vh, 0); }
}
@keyframes mecer {
  from { transform: rotate(-35deg) translateX(-14px) rotateY(0deg); }
  to   { transform: rotate(40deg)  translateX(14px)  rotateY(160deg); }
}

/* ---------- Shell ---------- */
.app { position: relative; z-index: 1; min-height: 100%; display: flex; }
.sidebar { display: none; }
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 14px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(120%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .4s;
}
.topbar.is-stuck { border-bottom-color: var(--line-soft); }
.topbar-title {
  margin: 0; flex: 1; min-width: 0;
  font: 500 23px/1.3 var(--mincho);
  letter-spacing: .08em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions { display: flex; gap: 6px; align-items: center; }

/* 判子 hanko — el sello con el kanji de cada sección */
.seal {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 4px;
  background: var(--shu); color: #fff8f4;
  font: 600 17px/1 var(--mincho);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, #fff 22%, transparent);
  transform: rotate(-4deg);
}
.seal:empty { display: none; }
.seal.is-stamping { animation: sellar .7s var(--calma); }
@keyframes sellar {
  0%   { transform: scale(1.7) rotate(-14deg); opacity: 0; }
  55%  { transform: scale(.94) rotate(-3deg);  opacity: 1; }
  100% { transform: scale(1) rotate(-4deg); }
}

.view { flex: 1; padding: 2px 20px 34px; }
.view:focus { outline: none; }

/* Al entrar a una sección, las cosas brotan como tinta en papel. */
.view.is-entering > *,
.view.is-entering .grid > *,
.view.is-entering .cards > *,
.view.is-entering .titles > * {
  animation: brotar .8s var(--calma) both;
}
.view.is-entering > *:nth-child(2) { animation-delay: .06s; }
.view.is-entering > *:nth-child(3) { animation-delay: .12s; }
.view.is-entering > *:nth-child(n+4) { animation-delay: .18s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(1)  { animation-delay: .10s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(2)  { animation-delay: .14s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(3)  { animation-delay: .18s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(4)  { animation-delay: .22s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(5)  { animation-delay: .26s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(6)  { animation-delay: .30s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(7)  { animation-delay: .34s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(8)  { animation-delay: .38s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(9)  { animation-delay: .42s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(10) { animation-delay: .46s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(11) { animation-delay: .50s; }
.view.is-entering :is(.grid, .cards, .titles) > *:nth-child(n+12) { animation-delay: .54s; }
@keyframes brotar {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* ---------- Navegación inferior (móvil) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(120%) blur(14px);
  border-top: 1px solid var(--line-soft);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; border: 0; background: none; color: var(--muted);
  font-size: 10.5px; font-weight: 500; letter-spacing: .08em;
  padding: 6px 2px; transition: color .3s;
}
.tab svg { width: 21px; height: 21px; transition: transform .4s var(--calma); }
.tab.is-active { color: var(--accent); }
.tab.is-active svg { transform: translateY(-1px); }
.tab-kanji { display: none; }
/* Una pincelada bermellón sobre la pestaña activa */
.tab-dot {
  position: absolute; top: 0; left: 50%; width: 22px; height: 2px;
  margin-left: -11px; border-radius: 2px; background: var(--shu);
  transform: scaleX(0); transition: transform .5s var(--calma);
}
.tab.is-active .tab-dot { transform: scaleX(1); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--r-full); padding: 9px 18px;
  font-weight: 500; font-size: 13.5px; letter-spacing: .04em;
  transition: transform .2s var(--calma), background .3s, border-color .3s, box-shadow .3s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 24%, transparent);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn-ghost { background: none; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--alert); border-color: color-mix(in srgb, var(--alert) 26%, var(--line)); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.btn-icon svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .4; pointer-events: none; }

/* ---------- Buscador ---------- */
.search {
  position: relative; display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-full); padding: 0 16px;
  transition: border-color .3s, box-shadow .4s;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  padding: 12px 10px; font-size: 16px; letter-spacing: .02em;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-clear { border: 0; background: none; color: var(--muted); padding: 4px; display: flex; }
.search-clear svg { width: 15px; height: 15px; }

/* ---------- Chips / filtros ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 16px 20px 4px;
  margin: 0 -20px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: transparent;
  color: var(--ink-soft); border-radius: var(--r-full);
  padding: 7px 16px; font-size: 12.5px; font-weight: 500;
  letter-spacing: .04em; white-space: nowrap; transition: .3s;
}
.chip:hover { border-color: var(--muted); }
.chip.is-active {
  background: var(--accent-soft); border-color: var(--accent);
  color: color-mix(in srgb, var(--accent) 80%, var(--ink));
}
.chip-count { opacity: .5; margin-left: 6px; }

/* ---------- Grilla de libros ---------- */
.shelf-meta {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 24px 0 16px; color: var(--muted);
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
}
.shelf-meta strong { color: var(--ink-soft); font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(102px, 1fr));
  gap: 28px 16px;
}
@media (min-width: 480px) { .grid { grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); } }

.book {
  text-align: left; border: 0; background: none; padding: 0; width: 100%;
  display: flex; flex-direction: column;   /* igual que .cover-option: el <button> mide bien */
}
.cover {
  position: relative; aspect-ratio: 2 / 3; width: 100%;
  border-radius: var(--r-xs);
  overflow: hidden; background: var(--surface-2);
  box-shadow: var(--shadow-md);
  transition: transform .6s var(--calma), box-shadow .6s var(--calma);
}
/* Al pasar el mouse el libro se levanta apenas y una franja de luz cruza
   la portada una sola vez, lenta, como un reflejo sobre el papel. */
.book:hover .cover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.book:active .cover { transform: translateY(-1px); transition-duration: .15s; }
.book .cover::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.22) 50%, transparent 65%);
  transform: translateX(-120%);
}
@media (hover: hover) {
  .book:hover .cover::before { transform: translateX(120%); transition: transform .8s var(--calma); }
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(28, 32, 40, .10);
  background: linear-gradient(90deg, rgba(0,0,0,.14) 0, rgba(0,0,0,.02) 5px, transparent 11px);
}
.cover-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  justify-content: space-between; padding: 14px 11px 12px 13px;
  color: #f3f2ef;
}
.cover-fallback .cf-title {
  font: 500 12.5px/1.45 var(--mincho); letter-spacing: .04em;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-fallback .cf-author { font-size: 9.5px; opacity: .72; letter-spacing: .06em; }
.book-title {
  margin: 12px 0 3px; font: 500 13px/1.45 var(--mincho); letter-spacing: .03em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-author {
  color: var(--muted); font-size: 11px; letter-spacing: .03em;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- Biblioteca: buscador + filtros ---------- */
.lib-herramientas { display: flex; gap: 8px; align-items: stretch; }
.lib-herramientas .search { flex: 1; min-width: 0; }
.btn-filtros { flex: none; gap: 8px; padding: 0 16px; position: relative; }
.btn-filtros svg { width: 17px; height: 17px; transition: transform .5s var(--calma); }
.btn-filtros.is-open { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-filtros.is-open svg { transform: rotate(90deg); }
.btn-filtros.is-on:not(.is-open) { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.btn-filtros-n {
  display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--shu); color: #fff;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0;
  animation: brotar .4s var(--calma);
}
@media (max-width: 420px) { .btn-filtros-txt { display: none; } .btn-filtros { padding: 0 13px; } }

/* El panel se despliega con grid 0fr -> 1fr: suave y sin medir alturas. */
.panel-filtros {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .55s var(--calma), opacity .4s, margin .55s var(--calma);
  opacity: 0; margin-top: 0;
}
.panel-filtros.is-open { grid-template-rows: 1fr; opacity: 1; margin-top: 12px; }
.panel-filtros-dentro {
  overflow: hidden; min-height: 0;
  display: grid; gap: 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 0 18px;
  transition: padding .55s var(--calma);
}
.panel-filtros.is-open .panel-filtros-dentro { padding: 18px; }
.panel-filtros:not(.is-open) .panel-filtros-dentro { border-color: transparent; }
@media (min-width: 760px) {
  .panel-filtros-dentro { grid-template-columns: 1fr 1fr; gap: 20px 28px; }
  .panel-filtros-dentro > .filtro-grupo:first-child { grid-column: 1 / -1; }
}
.filtro-grupo h4 {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px; font: 600 10.5px/1 var(--gothic);
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
.filtro-grupo h4::before {
  content: ""; width: 10px; height: 1.5px; border-radius: 2px; background: var(--shu); opacity: .8;
}
.filtro-opciones { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-sm { padding: 5px 12px; font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ver-todos {
  border: 0; background: none; color: var(--accent); font-size: 12px; font-weight: 500;
  padding: 5px 6px; letter-spacing: .02em;
}
.ver-todos:hover { text-decoration: underline; text-underline-offset: 3px; }
.seg-orden { max-width: 460px; }

/* Filtros activos: pastillas que se quitan con ✕ */
.filtros-activos { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; }
.pastilla {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 80%, var(--ink));
  border-radius: var(--r-full); padding: 5px 8px 5px 12px;
  font-size: 12px; font-weight: 500; letter-spacing: .02em;
  animation: brotar .45s var(--calma) both;
  transition: background .3s, border-color .3s;
}
.pastilla svg { width: 12px; height: 12px; opacity: .7; }
.pastilla:hover { border-color: var(--accent); }
.pastilla:hover svg { opacity: 1; }
.limpiar-todo {
  border: 0; background: none; color: var(--muted); font-size: 12px;
  padding: 5px 6px; text-decoration: underline; text-underline-offset: 3px;
}
.limpiar-todo:hover { color: var(--alert); }

.meta-orden {
  border: 0; background: none; padding: 0; color: var(--muted);
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  border-bottom: 1px dotted currentColor; transition: color .3s;
}
.meta-orden:hover { color: var(--accent); }

/* Separadores de estantería: la letra en mincho, con un trazo fino */
.estante + .estante { margin-top: 34px; }
.estante-letra {
  display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 16px; font: 500 22px/1 var(--mincho); color: var(--ink);
  letter-spacing: .04em;
}
.estante-letra::after {
  content: ""; flex: 1; height: 1px; align-self: center;
  background: linear-gradient(90deg, var(--line), transparent);
}
.estante-letra small {
  font: 500 11px/1 var(--gothic); color: var(--muted); letter-spacing: .08em;
}
.estante-letra span { color: var(--shu); }

/* Vista de lista */
.lista-libros {
  display: grid; gap: 1px;
  background: var(--line-soft); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); overflow: hidden;
}
.fila-libro {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 0; padding: 10px 14px;
  transition: background .3s;
}
.fila-libro:hover { background: var(--surface-2); }
.fila-portada { flex: none; width: 34px; }
.fila-portada .cover { box-shadow: var(--shadow-sm); }
.fila-portada .cover-fallback { padding: 4px; }
.fila-portada .cf-title, .fila-portada .cf-author { display: none; }
.fila-cuerpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.fila-titulo {
  font: 500 14.5px/1.4 var(--mincho); letter-spacing: .03em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fila-meta {
  color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fila-dueno {
  flex: none; font-size: 11px; color: var(--ink-soft);
  background: var(--petal-soft); border-radius: var(--r-full); padding: 3px 10px;
}
.view.is-entering .lista-libros > * { animation: brotar .6s var(--calma) both; }

/* Botones de vista en la barra superior */
.vista-toggle { display: flex; gap: 2px; background: var(--surface-2); border-radius: var(--r-full); padding: 3px; }
.vista-toggle .btn-icon { width: 32px; height: 32px; color: var(--muted); }
.vista-toggle .btn-icon.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.vista-toggle .btn-icon svg { width: 16px; height: 16px; }

/* ---------- Tarjetas de colección ---------- */
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 18px;
  transition: transform .5s var(--calma), border-color .3s, box-shadow .5s var(--calma);
}
button.card:hover { border-color: var(--muted); transform: translateY(-2px); box-shadow: var(--shadow-md); }
button.card:active { transform: scale(.995); }
.card-body { flex: 1; min-width: 0; }
.card-title { font: 500 16.5px/1.35 var(--mincho); letter-spacing: .05em; margin: 0 0 5px; }
.card-sub { color: var(--muted); font-size: 12.5px; }
.card-sub .missing { color: var(--alert); font-weight: 600; }
.card-sub strong { color: var(--ink-soft); }
.card-chevron { color: var(--muted); flex: none; opacity: .6; transition: transform .5s var(--calma); }
button.card:hover .card-chevron { transform: translateX(3px); }
.card-chevron svg { width: 16px; height: 16px; }

/* El anillo de progreso se traza como un ensō, de un solo gesto. */
.ring { flex: none; position: relative; width: 54px; height: 54px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.ring .ring-bg { stroke: var(--line); }
.ring .ring-fg { stroke: var(--accent); transition: stroke-dashoffset .8s var(--calma); }
.view.is-entering .ring-fg { animation: trazar 1.6s var(--calma) .15s both; }
@keyframes trazar { from { stroke-dashoffset: 138.2; } }
.ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600; letter-spacing: -.01em; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.ring.is-complete .ring-fg { stroke: var(--good); }

/* ---------- Lista de títulos de una colección ---------- */
.titles { display: grid; gap: 1px; margin-top: 6px;
  background: var(--line-soft); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); overflow: hidden; }
.title-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 0;
  padding: 14px 16px; transition: background .3s;
}
.title-row:hover { background: var(--surface-2); }
.title-row.is-owned { background: color-mix(in srgb, var(--good-soft) 60%, var(--surface)); }
.tick {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); display: grid; place-items: center;
  color: transparent; background: none;
  transition: transform .4s var(--calma), border-color .3s;
}
.title-row:not(.is-owned):hover .tick { border-color: var(--good); transform: scale(1.08); }
.tick svg { width: 12px; height: 12px; stroke-width: 2.4; }
.is-owned .tick { border-color: var(--good); background: var(--good); color: #fff; }
.title-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.title-row-name { display: block; font: 500 14.5px/1.4 var(--mincho); letter-spacing: .03em; }
.is-owned .title-row-name { color: var(--ink-soft); }
.title-row-author { display: block; color: var(--muted); font-size: 11.5px; }
.title-row-num {
  flex: none; font-size: 16px; color: var(--shu); opacity: .55;
  min-width: 18px; text-align: right; transition: opacity .3s, transform .4s var(--calma);
}
.title-row:hover .title-row-num { opacity: 1; transform: rotate(90deg); }

/* ---------- Resultados de búsqueda de libros ---------- */
.results { display: grid; gap: 10px; margin-top: 18px; }
.result {
  display: flex; gap: 14px; width: 100%; text-align: left; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px;
  transition: transform .4s var(--calma), border-color .3s, box-shadow .4s;
  animation: brotar .6s var(--calma) both;
}
.result:nth-child(2) { animation-delay: .04s; }
.result:nth-child(3) { animation-delay: .08s; }
.result:nth-child(4) { animation-delay: .12s; }
.result:nth-child(n+5) { animation-delay: .16s; }
.result:hover { border-color: var(--muted); box-shadow: var(--shadow-md); }
.result:active { transform: scale(.995); }
.result-cover {
  flex: none; width: 46px; aspect-ratio: 2/3; border-radius: var(--r-xs);
  overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-sm);
  position: relative;
}
.result-cover img { width: 100%; height: 100%; object-fit: cover; }
.result-body { flex: 1; min-width: 0; padding-top: 2px; display: flex; flex-direction: column; align-items: flex-start; }
.result-title { display: block; font: 500 14.5px/1.4 var(--mincho); letter-spacing: .03em; }
.result-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.result-state { flex: none; align-self: center; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; letter-spacing: .04em;
  padding: 5px 11px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink-soft);
}
.badge svg { width: 11px; height: 11px; stroke-width: 2.4; }
.badge-owned { background: var(--good-soft); color: var(--good); }
.badge-add { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 85%, var(--ink)); }

/* ---------- Portadas: elegir, subir, quitar ---------- */
.cover-row { display: flex; gap: 14px; align-items: flex-start; }
.cover-thumb { flex: none; width: 66px; }
.cover-thumb .cover { box-shadow: var(--shadow-sm); }
.cover-row-actions { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 7px; align-content: flex-start; }
.cover-row-actions .btn { flex: 0 1 auto; }

.cover-pane {
  margin-top: 14px; padding: 14px;
  background: var(--surface-2); border-radius: var(--r-md);
}
.cover-url-label {
  display: block; margin: 20px 0 7px;
  font-size: 12px; color: var(--muted); letter-spacing: .03em;
}
.cover-options {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 14px 10px;
}
/* Ojo: un <button> con un hijo que usa aspect-ratio no suma bien la altura
   del resto; con flex-column se calcula bien y el pie no se sale de la caja. */
.cover-option {
  border: 0; background: none; padding: 0; text-align: left;
  display: flex; flex-direction: column; gap: 7px; width: 100%;
}
.cover-option .cover {
  box-shadow: var(--shadow-sm);
  outline: 2px solid transparent; outline-offset: 2px;
  transition: outline-color .25s, transform .5s var(--calma);
}
.cover-option:hover .cover { transform: translateY(-2px); }
.cover-option.is-chosen .cover { outline-color: var(--accent); }
.cover-option-meta {
  font-size: 10px; line-height: 1.35;
  color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.detail-cover {
  position: relative; border: 0; background: none; padding: 0;
  flex: none; width: 108px; display: block;
}
.cover-edit-hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 5px 4px; font-size: 10px; font-weight: 500; letter-spacing: .06em;
  color: #fff; background: rgba(20, 24, 32, .5);
  backdrop-filter: blur(2px);
  border-radius: 0 0 var(--r-xs) var(--r-xs);
  opacity: 0; transition: opacity .3s;
}
.detail-cover:hover .cover-edit-hint,
.detail-cover:focus-visible .cover-edit-hint { opacity: 1; }
.cover-edit-hint svg { width: 12px; height: 12px; }
@media (hover: none) { .cover-edit-hint { opacity: 1; } }

/* ---------- Mejorar portadas ---------- */
.chip-accion { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.chip-accion svg { width: 13px; height: 13px; }

.mejora-progreso { display: grid; gap: 8px; margin-bottom: 18px; }
.mejora-progreso span#mejoraTxt { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.mejora-barra { height: 3px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.mejora-barra span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--petal), var(--shu));
  transition: width .8s var(--calma);
}
.mejora-progreso.is-listo .mejora-barra span { background: var(--good); }

.mejora-lista { display: grid; gap: 8px; }
.mejora-fila {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 14px; transition: border-color .3s, opacity .3s, background .3s;
  animation: brotar .6s var(--calma) both;
}
.mejora-fila:hover { border-color: var(--muted); }
.mejora-fila.is-marcada {
  border-color: color-mix(in srgb, var(--good) 55%, var(--line));
  background: color-mix(in srgb, var(--good-soft) 55%, var(--surface));
}
.mejora-par { flex: none; display: flex; align-items: center; gap: 8px; }
.mejora-antes, .mejora-despues { width: 46px; }
.mejora-antes .cover { box-shadow: var(--shadow-sm); }
.mejora-antes .cover-fallback { padding: 4px; }
.mejora-antes .cf-title, .mejora-antes .cf-author { display: none; }
.mejora-despues .cover { box-shadow: var(--shadow-md); }
.mejora-flecha { color: var(--shu); font-size: 14px; }
.mejora-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mejora-titulo { font: 500 14px/1.35 var(--mincho); letter-spacing: .03em; }
.mejora-autor { font-size: 11.5px; color: var(--muted); }
.mejora-fila .tick { color: transparent; }
.mejora-fila.is-marcada .tick { border-color: var(--good); background: var(--good); color: #fff; }
.mejora-acciones { position: sticky; bottom: calc(-28px - var(--safe-b)); margin: 20px -22px calc(-28px - var(--safe-b)); padding: 14px 22px calc(18px + var(--safe-b)); background: var(--paper); border-top: 1px solid var(--line-soft); }
@media (min-width: 700px) { .mejora-acciones { bottom: -28px; margin-bottom: -28px; padding-bottom: 18px; } }

/* Sugerencia de portada plana en la ficha de un libro nuevo */
.sugerencia-plana {
  display: flex; align-items: center; gap: 12px; margin-top: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  background: var(--petal-soft); border: 1px solid color-mix(in srgb, var(--petal) 45%, transparent);
  animation: brotar .6s var(--calma) both;
}
.sugerencia-plana .cover { flex: none; width: 40px; box-shadow: var(--shadow-sm); }
.sugerencia-texto { flex: 1; font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }

/* ---------- Otras formas de agregar ---------- */
.otras-formas {
  margin-top: 36px; padding-top: 26px;
  border-top: 1px solid var(--line-soft);
}
.otras-formas > h3, .settings-group > h3 {
  display: flex; align-items: center; gap: 10px;
  font: 600 10.5px/1 var(--gothic); text-transform: uppercase;
  letter-spacing: .2em; color: var(--muted); margin: 0 0 14px;
}
/* Pequeño trazo bermellón delante de cada encabezado de sección */
.otras-formas > h3::before, .settings-group > h3::before {
  content: ""; width: 14px; height: 1.5px; border-radius: 2px; background: var(--shu); opacity: .8;
}

/* Campo para pegar el enlace de una tienda: misma familia que el buscador */
.enlace {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-full); padding: 4px 4px 4px 16px;
  transition: border-color .3s, box-shadow .4s;
}
.enlace:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.enlace > svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.enlace input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink);
  padding: 9px 8px; font-size: 14px; letter-spacing: .01em;
}
.enlace input::placeholder { color: var(--muted); }
.enlace .btn { flex: none; padding: 8px 18px; }

/* Lo que la app entendió del enlace */
.lectura {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin-top: 10px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
  animation: brotar .5s var(--calma) both;
}
.lectura-tienda {
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.lectura-titulo {
  flex-basis: 100%; order: -1;
  font: 500 15px/1.4 var(--mincho); letter-spacing: .03em; color: var(--ink);
}
.lectura-isbn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--good); font-variant-numeric: tabular-nums;
}
.lectura-isbn svg { width: 13px; height: 13px; stroke-width: 2.4; }
.lectura.is-mala {
  flex-wrap: nowrap; align-items: flex-start;
  border-left-color: var(--alert); font-size: 12.5px; color: var(--ink-soft);
}
.lectura.is-mala svg { width: 16px; height: 16px; flex: none; color: var(--alert); margin-top: 2px; }

/* ---------- Estados vacíos y carga ---------- */
.empty { text-align: center; padding: 64px 22px; color: var(--muted); }
.empty-art {
  position: relative;
  width: 54px; height: 54px; margin: 12px auto 30px; color: var(--muted);
}
.empty-art svg { width: 100%; height: 100%; stroke-width: 1.1; opacity: .7; }
/* Ensō alrededor del ícono, respirando despacio */
.empty-art::before {
  content: ""; position: absolute; inset: -18px; border-radius: 50%;
  border: 2px solid var(--petal); border-right-color: transparent;
  transform: rotate(-40deg);
  animation: respirar 7s ease-in-out infinite;
}
@keyframes respirar {
  0%, 100% { transform: rotate(-40deg) scale(1);    opacity: .9; }
  50%      { transform: rotate(-28deg) scale(1.06); opacity: .5; }
}
.empty h3 {
  font: 500 18px/1.5 var(--mincho); letter-spacing: .08em;
  color: var(--ink); margin: 0 0 8px;
}
.empty p { margin: 0 auto 22px; max-width: 30ch; font-size: 13px; line-height: 1.8; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--line); border-top-color: var(--shu);
  animation: spin 1.1s cubic-bezier(.5, .15, .5, .85) infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 28px; color: var(--muted); font-size: 12.5px; letter-spacing: .04em;
}
.loading-row .spinner { margin: 0; }

/* ---------- Hoja modal ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16, 19, 24, .34);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .35s ease;
}
@keyframes fade { from { opacity: 0 } }
.sheet {
  position: relative; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 28px 22px calc(28px + var(--safe-b));
  animation: rise .55s var(--calma);
}
/* Asa para arrastrar, en bermellón suave */
.sheet::before {
  content: ""; position: absolute; top: 9px; left: 50%; width: 36px; height: 3px;
  margin-left: -18px; border-radius: 3px; background: var(--line);
}
@keyframes rise { from { transform: translateY(28px); opacity: 0 } }
.sheet-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: var(--surface-2); color: var(--ink-soft);
  display: grid; place-items: center;
  transition: transform .5s var(--calma), background .3s;
}
.sheet-close:hover { transform: rotate(90deg); }
.sheet-close svg { width: 15px; height: 15px; }
.sheet h2 {
  font: 500 20px/1.4 var(--mincho); letter-spacing: .06em;
  margin: 0 0 6px; padding-right: 40px; overflow-wrap: break-word;
}
.sheet-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }

@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--r-lg); max-height: 84vh; padding-bottom: 28px; }
  .sheet::before { display: none; }
  @keyframes rise { from { transform: translateY(16px) scale(.98); opacity: 0 } }
}

/* ---------- Detalle de libro ---------- */
.detail-head { display: flex; gap: 20px; margin-bottom: 20px; }
.detail-cover .cover { box-shadow: var(--shadow-md); }
.detail-info { flex: 1; min-width: 0; padding-top: 2px; }
.detail-info h2 { padding-right: 34px; overflow-wrap: anywhere; }
.detail-info .by { color: var(--ink-soft); font-size: 13.5px; margin: 2px 0 14px; }
.meta-list { display: grid; gap: 7px; font-size: 12.5px; }
.meta-list div { display: flex; gap: 10px; }
.meta-list dt { color: var(--muted); min-width: 68px; }
.meta-list dd { margin: 0; color: var(--ink-soft); }
.sheet-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 24px; }
.sheet-actions .btn { flex: 1; min-width: 130px; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 18px; }
.field label, .field > label {
  display: block; font-size: 10.5px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 13px; font-size: 16px; outline: none;
  transition: border-color .3s, box-shadow .4s;
}
.field textarea { min-height: 78px; resize: vertical; font-size: 15px; line-height: 1.65; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 7px; line-height: 1.65; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ---------- Ajustes ---------- */
.settings-group { margin-bottom: 30px; }
.settings-group > h3 { margin: 0 0 12px; padding: 0 3px; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 13px;
  padding: 15px 16px; border-bottom: 1px solid var(--line-soft);
  width: 100%; text-align: left; background: none;
  border-left: 0; border-right: 0; border-top: 0;
  transition: background .3s;
}
button.row:hover { background: var(--surface-2); }
.row:last-child { border-bottom: 0; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { display: block; font-weight: 500; font-size: 14px; }
.row-sub { display: block; color: var(--muted); font-size: 12px; line-height: 1.55; }
.row-val { color: var(--muted); font-size: 12.5px; flex: none; }
.row svg.chev { width: 15px; height: 15px; color: var(--muted); flex: none; opacity: .6; transition: transform .5s var(--calma); }
button.row:hover svg.chev { transform: translateX(3px); }
.row > .dot { align-self: flex-start; margin-top: 7px; }
.panel-pad { padding: 16px; }
.panel-label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 8px 2px; letter-spacing: .03em; }
.panel-pad .seg + .panel-label { margin-top: 16px; }

.seg { display: flex; background: var(--surface-2); border-radius: var(--r-full); padding: 3px; gap: 2px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: var(--r-full);
  padding: 8px 10px; font-size: 12.5px; font-weight: 500; color: var(--muted);
  letter-spacing: .04em; transition: .3s;
}
.seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Estado de sincronización ---------- */
.sync-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: var(--r-full); padding: 6px 12px;
  letter-spacing: .04em;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--good); }
.dot.off { background: var(--muted); }
.dot.err { background: var(--alert); }
.dot.busy { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3 } }

/* ---------- Avisos ---------- */
.toasts {
  position: fixed; z-index: 90; left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 16px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--paper);
  padding: 11px 20px 11px 16px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 500; letter-spacing: .03em;
  box-shadow: var(--shadow-md);
  animation: toastIn .5s var(--calma);
  max-width: 100%;
}
.toast::before {
  content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--petal);
}
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; filter: blur(3px); } }
.toast.is-out { animation: toastOut .3s forwards; }
@keyframes toastOut { to { transform: translateY(6px); opacity: 0 } }

/* ---------- Escritorio ---------- */
@media (min-width: 900px) {
  .tabbar { display: none; }
  .main { padding-bottom: 0; }
  .toasts { bottom: 26px; left: 276px; }
  .sidebar {
    display: flex; flex-direction: column; flex: none; width: 260px;
    border-right: 1px solid var(--line-soft);
    padding: 30px 16px 20px; gap: 34px;
    position: sticky; top: 0; height: 100vh; overflow: hidden;
    background: color-mix(in srgb, var(--surface) 55%, transparent);
  }
  .brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
  .brand strong { display: block; font: 500 15.5px/1.4 var(--mincho); letter-spacing: .08em; }
  .brand-sub { font-size: 11.5px; color: var(--muted); letter-spacing: .04em; }
  .side-nav { display: grid; gap: 2px; }
  .side-nav .tab {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 13px; border-radius: var(--r-sm); font-size: 13.5px;
    letter-spacing: .05em; transition: background .3s, color .3s;
  }
  .side-nav .tab:hover { background: color-mix(in srgb, var(--surface-2) 80%, transparent); }
  .side-nav .tab.is-active { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 80%, var(--ink)); }
  .side-nav .tab-kanji {
    display: block; margin-left: auto;
    font: 500 14px/1 var(--mincho); color: var(--muted); opacity: .45;
    transition: color .3s, opacity .3s;
  }
  .side-nav .tab.is-active .tab-kanji { color: var(--shu); opacity: 1; }
  .side-nav .tab-dot {
    top: 50%; left: 0; width: 2px; height: 18px; margin: -9px 0 0;
    transform: scaleY(0);
  }
  .side-nav .tab.is-active .tab-dot { transform: scaleY(1); }
  .side-foot { position: relative; z-index: 1; margin-top: auto; padding: 0 8px; }
  .view { max-width: 1060px; padding: 2px 34px 48px; }
  .topbar { padding: 30px 34px 16px; }
  .topbar-title { font-size: 27px; }
  .seal { width: 34px; height: 34px; font-size: 19px; }
  .chips { padding-left: 34px; padding-right: 34px; margin: 0 -34px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 34px 22px; }
}

/* ---------- Ensō de la marca ---------- */
.brand-enso { width: 40px; height: 40px; flex: none; color: var(--ink); }
.brand-enso .enso-trazo {
  stroke-width: 2.8; stroke-dasharray: 100; stroke-dashoffset: 0;
  animation: enso 2.2s var(--calma) .2s both;
}
.brand-enso .enso-kanji {
  fill: var(--shu); stroke: none;
  font: 600 14px var(--mincho);
  animation: fade 1.2s ease 1.4s both;
}
@keyframes enso { from { stroke-dashoffset: 100; } }

/* ---------- 遠山 Montañas lejanas al pie de la barra lateral ---------- */
.enzan {
  position: absolute; left: 0; right: 0; bottom: 0; height: 170px;
  pointer-events: none;
}
.enzan svg { width: 100%; height: 100%; }
.enzan .sol   { fill: var(--petal); stroke: none; opacity: .4; }
:root[data-theme="dark"] .enzan .sol { opacity: .28; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .enzan .sol { opacity: .28; } }
.enzan .cerro { stroke: none; fill: var(--accent); }
.enzan .c3 { opacity: .08; }
.enzan .c2 { opacity: .13; }
.enzan .c1 { opacity: .2; }
/* Neblina que pasa despacio entre los cerros */
.enzan .kiri {
  position: absolute; left: -60%; bottom: 44px; width: 220%; height: 34px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--paper) 85%, transparent) 30%,
              transparent 50%, color-mix(in srgb, var(--paper) 80%, transparent) 75%, transparent);
  filter: blur(6px);
  animation: neblina 38s ease-in-out infinite alternate;
}
@keyframes neblina { to { transform: translateX(26%); } }

/* =========================================================
   Página de inicio (quien no ha entrado)
   ========================================================= */
.landing { position: relative; z-index: 1; min-height: 100%; }
.landing section, .l-cabecera, .l-pie { max-width: 1080px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }

.l-cabecera {
  position: sticky; top: 0; z-index: 20; max-width: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 16px; padding-bottom: 14px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(120%) blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .4s;
}
.l-cabecera.is-stuck { border-bottom-color: var(--line-soft); }
@media (min-width: 1120px) { .l-cabecera { padding-left: calc((100% - 1040px) / 2); padding-right: calc((100% - 1040px) / 2); } }
.l-marca { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.l-marca strong { font: 500 19px/1 var(--mincho); letter-spacing: .1em; }
.l-marca .brand-enso { width: 34px; height: 34px; }

/* Héroe */
.l-heroe {
  display: grid; gap: 40px; align-items: center;
  padding-top: 40px; padding-bottom: 60px;
}
/* En escritorio el texto va arriba (no centrado con la tarjeta, que es más
   alta): el título y el botón se ven sin bajar. Es el foco de la página. */
@media (min-width: 900px) {
  .l-heroe { grid-template-columns: 1.15fr .85fr; gap: 64px; align-items: start; padding-top: 30px; padding-bottom: 80px; }
  .l-heroe-texto { padding-top: 26px; }
}
.l-heroe-texto { animation: brotar 1s var(--calma) both; }
.l-sobre {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 18px;
  font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--shu);
}
.l-sobre::before { content: ""; width: 18px; height: 1.5px; background: var(--shu); }
.l-heroe h1 {
  margin: 0 0 18px; font: 500 clamp(34px, 6vw, 60px)/1.12 var(--mincho);
  letter-spacing: .04em; color: var(--ink); text-wrap: balance;
}
.l-bajada { margin: 0 0 28px; font-size: 16px; line-height: 1.85; color: var(--ink-soft); max-width: 46ch; }
.l-acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.l-cta { padding: 13px 26px; font-size: 15px; }
.l-nota { margin: 16px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .03em; }

/* La biblioteca de ejemplo */
.l-muestra {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 18px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 380px; justify-self: center;
  transform: rotate(1.2deg);
  animation: brotar 1.2s var(--calma) .25s both;
}
.l-muestra-cab { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.l-muestra-cab strong { display: block; font: 500 15.5px/1.3 var(--mincho); }
.l-muestra-cab small { font-size: 11.5px; color: var(--muted); }
.l-avatar-mini { display: flex; flex: none; }
.l-avatar-mini i {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font: 500 13px/1 var(--mincho); font-style: normal; color: #fff;
  background: var(--accent); border: 2px solid var(--surface);
}
.l-avatar-mini i + i { margin-left: -9px; background: var(--shu); }
.l-cifras {
  display: flex; gap: 16px; padding: 10px 0 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line-soft); font-size: 12px; color: var(--muted);
}
.l-cifras strong { color: var(--ink); font-size: 13px; }
.l-grupo {
  display: flex; align-items: baseline; gap: 8px; margin: 12px 0 8px;
  font: 600 10.5px/1 var(--gothic); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
}
.l-grupo small { font-weight: 400; letter-spacing: .02em; text-transform: none; color: var(--muted); font-size: 11px; }
.l-muestra-libros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.l-libro { position: relative; display: flex; flex-direction: column; gap: 7px; }
.l-marca-libro { font-size: 10.5px; letter-spacing: .02em; line-height: 1.3; }
.l-marca-libro.es-tiene { color: var(--good); }
.l-marca-libro.es-deseo { color: var(--shu); }
.l-muestra-pie {
  margin: 16px 0 0; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); font-size: 12px; color: var(--ink-soft); line-height: 1.5;
}

/* Portadas dibujadas: tres diseños de libro con tipografía de verdad */
.pd {
  position: relative; aspect-ratio: 2 / 3; border-radius: 2px 4px 4px 2px;
  background: var(--pd-fondo); color: var(--pd-tinta);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 9px; text-align: center; overflow: hidden;
  box-shadow: var(--shadow-md), inset 4px 0 6px -3px rgba(0,0,0,.35);
}
.pd-titulo { font: 500 12.5px/1.25 var(--mincho); letter-spacing: .02em; }
.pd-filete { width: 26px; height: 1px; background: currentColor; opacity: .7; }
.pd-autor { font: 400 8.5px/1.2 var(--gothic); letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
/* Marco: doble filete alrededor, como las ediciones de tapa dura */
.pd-marco::before {
  content: ""; position: absolute; inset: 6px; pointer-events: none;
  border: 1px solid currentColor; opacity: .45;
  box-shadow: inset 0 0 0 2px var(--pd-fondo), inset 0 0 0 3px color-mix(in srgb, var(--pd-tinta) 40%, transparent);
}
/* Franja: banda de color al pie, estilo colección de bolsillo */
.pd-franja { justify-content: flex-start; padding-top: 22px; }
.pd-franja::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 14%; height: 16%;
  background: var(--pd-tinta); opacity: .92;
}
/* El autor va sobre la franja, en el color del fondo */
.pd-franja .pd-autor {
  position: absolute; left: 0; right: 0; bottom: 14%; height: 16%; z-index: 1;
  display: grid; place-items: center; color: var(--pd-fondo); opacity: 1; font-weight: 600;
}
/* Minimal: fondo claro y tipografía grande */
.pd-minimal { justify-content: flex-end; align-items: flex-start; text-align: left; padding: 12px 10px 14px; }
.pd-minimal .pd-titulo { font-size: 15px; line-height: 1.1; }
.pd-minimal .pd-filete { width: 18px; }

/* Secciones */
.l-seccion { padding-top: 56px; padding-bottom: 56px; border-top: 1px solid var(--line-soft); }
.l-seccion h2, .l-final h2 {
  margin: 0 0 30px; font: 500 clamp(24px, 4vw, 32px)/1.3 var(--mincho); letter-spacing: .06em; text-align: center;
}
.l-pasos { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
@media (min-width: 760px) { .l-pasos { grid-template-columns: repeat(3, 1fr); } }
.l-pasos li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 24px 22px;
}
.l-pasos h3 { margin: 0 0 8px; font: 500 17px/1.4 var(--mincho); letter-spacing: .05em; }
.l-pasos p { margin: 0; font-size: 13.5px; line-height: 1.8; color: var(--ink-soft); }

.l-juntos { display: grid; gap: 24px; align-items: center; }
@media (min-width: 760px) { .l-juntos { grid-template-columns: 1.4fr 1fr; } }
.l-juntos h2 { text-align: left; margin-bottom: 12px; }
.l-juntos p { margin: 0; font-size: 15px; line-height: 1.85; color: var(--ink-soft); max-width: 52ch; }
.l-avatares { display: flex; align-items: center; justify-content: center; }
.l-avatares span {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font: 500 24px/1 var(--mincho); color: #fff; border: 3px solid var(--paper);
  background: var(--accent);
}
.l-avatares span + span { margin-left: -16px; background: var(--shu); }
.l-avatares small {
  margin-left: 14px; padding: 8px 14px; border-radius: var(--r-full);
  border: 1.5px dashed var(--line); color: var(--muted); font-size: 12.5px;
}

.l-planes { display: grid; gap: 16px; max-width: 760px; margin: 0 auto; }
@media (min-width: 640px) { .l-planes { grid-template-columns: 1fr 1fr; } }
.l-plan {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 26px 24px;
}
.l-plan.es-destacado { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); box-shadow: var(--shadow-md); }
.l-plan h3 { margin: 0 0 6px; font: 600 12px/1 var(--gothic); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.l-precio { margin: 0 0 18px; font: 500 30px/1.2 var(--mincho); color: var(--ink); }
.l-precio small { font: 400 12px var(--gothic); color: var(--muted); }
.l-plan ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.l-plan li { font-size: 13.5px; color: var(--ink-soft); padding-left: 20px; position: relative; }
.l-plan li::before { content: "✓"; position: absolute; left: 0; color: var(--good); }

.l-final { padding-top: 60px; padding-bottom: 70px; text-align: center; border-top: 1px solid var(--line-soft); }
.l-pie { padding-top: 20px; padding-bottom: 40px; text-align: center; font-size: 12px; color: var(--muted); }

/* Hoja de entrar */
.l-aviso-prueba {
  margin: 0 0 18px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--petal-soft); font-size: 12.5px; line-height: 1.6; color: var(--ink-soft);
}
.l-google { gap: 10px; padding: 12px; font-size: 14px; }
.l-g { width: 18px; height: 18px; }
.l-o { display: flex; align-items: center; gap: 12px; margin: 20px 0 16px; color: var(--muted); font-size: 12px; }
.l-o::before, .l-o::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.l-enviado { text-align: center; padding: 10px 6px 4px; }
.l-sobre-icono {
  display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 24px;
}
.l-enviado h2 { padding-right: 0; }
.l-enviado p { font-size: 14px; line-height: 1.7; color: var(--ink-soft); }

/* Campo del enlace: "bookito.cl/" fijo + lo que escribe el usuario */
.enlace-slug {
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .3s, box-shadow .4s;
}
.enlace-slug:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.enlace-slug span { padding: 0 0 0 13px; color: var(--muted); font-size: 15px; white-space: nowrap; }
.field .enlace-slug input { border: 0; box-shadow: none; background: none; padding-left: 1px; }
.field .enlace-slug input:focus { box-shadow: none; }
.slug-estado.ok { color: var(--good); }
.slug-estado.mal { color: var(--alert); }

/* Barra del cupo del plan gratis (Ajustes → Tu biblioteca) */
.cupo { display: block; height: 4px; margin-top: 6px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.cupo i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s var(--calma); }

/* Selector de estilo (Ajustes → Apariencia) */
.estilos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.estilo {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 12px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color .3s, box-shadow .3s;
}
.estilo:hover { border-color: var(--muted); }
.estilo.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.estilo-muestra { display: flex; width: 100%; height: 26px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-soft); }
.estilo-muestra i { flex: 1; }
.estilo-nombre { font: 500 14px/1.3 var(--mincho); display: flex; align-items: center; gap: 6px; }
.estilo-desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.badge-premium { padding: 2px 7px; font-size: 9.5px; background: var(--petal-soft); color: var(--shu); letter-spacing: .06em; text-transform: uppercase; }

/* Foto o inicial del usuario (Ajustes) */
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font: 500 16px/1 var(--mincho);
}

/* ---------- Modo lectura (visitantes) ----------
   app.js pone .modo-lectura en <html> cuando el dispositivo no entró con
   la cuenta compartida: se ve todo, pero no hay botones para cambiar nada. */
.modo-lectura :is(
  [data-act="add"], [data-act="new"], [data-act="edit"], [data-act="del"],
  [data-act="editcol"], [data-act="mejorar"], [data-act="import"], [data-act="wipe"],
  .cover-edit-hint, .title-row-num, .solo-edicion
) { display: none !important; }
.modo-lectura .detail-cover, .modo-lectura .title-row:not(.is-owned) { cursor: default; }
.modo-lectura .title-row:not(.is-owned):hover { background: var(--surface); }
.modo-lectura .title-row:not(.is-owned):hover .tick { transform: none; border-color: var(--line); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .petalos { display: none; }
}
