/* Mi Biblioteca — estilo "biblioteca clásica" (verde, dorado y madera)
   con controles limpios de estilo minimalista. */
:root {
  --bg: #18211b;
  --surface: #1f2a22;
  --surface-2: #273429;
  --surface-3: #2f3e32;
  --line: #34443a;
  --text: #efe6d2;
  --muted: #a9b5a2;
  --accent: #d8b46a;          /* dorado */
  --accent-2: #e6c787;
  --accent-text: #1b1a12;
  --wood: #6b4a2b;
  --wood-dark: #4e3520;
  --star: #e3b649;
  --danger: #e0675d;
  --ok: #8fc79b;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  padding-bottom: 100px;
}
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 500; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Cabecera ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(24, 33, 27, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px 0;
}
.brand { display: flex; align-items: center; gap: 10px; max-width: 1200px; margin: 0 auto; }
.brand h1 { font-size: 26px; color: var(--accent); letter-spacing: .2px; }
.logo { font-size: 20px; }
.brand .logout { margin-left: auto; }
.brand .amigos-btn { margin-left: auto; position: relative; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border-radius: 99px; color: var(--accent); }
.brand .amigos-btn:hover { background: var(--surface-2); }
.brand .amigos-btn svg { width: 24px; height: 24px; }
.brand .amigos-btn:not([hidden]) + .logout { margin-left: 0; }
.amigos-btn .count {
  position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--danger); color: #fff; font: 700 11px/18px var(--sans); text-align: center;
}

/* ---------- Amigos ---------- */
.modo-amigo .solo-dueno { display: none !important; }
.amigo-banner, .recos-aviso {
  display: block; width: 100%; text-align: left; margin: 0 0 14px; padding: 12px 16px; border-radius: var(--radius);
  background: rgba(216,180,106,.12); border: 1px solid rgba(216,180,106,.35); color: var(--text); font-size: 14.5px; line-height: 1.45;
}
.amigo-banner[hidden], .recos-aviso[hidden] { display: none; }
.recos-aviso { cursor: pointer; }
.recos-aviso i { font-family: var(--serif); font-style: normal; color: var(--accent); }
.recos-aviso .go { float: right; color: var(--accent); font-weight: 700; margin-left: 10px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.badge.deseo { background: #f7dede; color: #7a2730; }
.sub-h { font-size: 18px; color: var(--accent); margin-bottom: 8px; }
#amigos-dialog .dlg-body { gap: 22px; }
#amigos-dialog section { display: flex; flex-direction: column; gap: 10px; }
#amigos-dialog section p { margin: 0; }
.recos-list, .amigos-list { display: flex; flex-direction: column; gap: 10px; }
.reco-item { display: flex; gap: 12px; background: var(--surface-2); border-radius: 12px; padding: 12px; border: 1px solid transparent; }
.reco-item.nueva { border-color: rgba(216,180,106,.5); }
.reco-item .thumb, .reco-pick .thumb { position: relative; width: 54px; height: 81px; flex: none; border-radius: 4px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.reco-item .thumb .cover-fallback, .reco-pick .thumb .cover-fallback { font-size: 8px; padding: 3px; }
.reco-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reco-who { font-size: 12.5px; color: var(--muted); }
.reco-who b { color: var(--text); }
.reco-item .t, .reco-pick .t { font-family: var(--serif); font-size: 16.5px; line-height: 1.2; overflow-wrap: anywhere; }
.reco-item .a, .reco-pick .a, .amigo-row .a { color: var(--muted); font-size: 13px; }
.reco-item blockquote { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--surface-3); border-radius: 0 8px 8px 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.badge-new { background: var(--accent); color: var(--accent-text); border-radius: 99px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.amigo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.amigo-info { flex: 1 1 140px; min-width: 0; }
.amigo-row .t { font-weight: 600; }
.reco-note { font-size: 12.5px; color: var(--accent); margin-top: 2px; }
.result.blocked { opacity: .55; cursor: default; }
.result.blocked:hover { border-color: transparent; }
.result.blocked .reco-note { color: var(--muted, #9aa59c); }
/* Recomendar a tus amigos */
.reco-a-amigos { display: flex; flex-direction: column; gap: 8px; }
.reco-a-row { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.reco-a-row:has(input:checked) { outline: 1px solid var(--accent); }
.reco-a-share { display: flex; flex-direction: column; gap: 8px; }
#reco-a-done { gap: 14px; }
#reco-a-form[hidden], #reco-a-done[hidden] { display: none; }
.para-mi { display: flex; flex-direction: column; gap: 6px; cursor: default; }
.para-mi-row { background: none; border: 0; padding: 2px 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.para-mi-row i { font-family: var(--serif); font-style: normal; color: var(--accent); }
.para-mi-row .go { float: right; color: var(--accent); font-weight: 700; margin-left: 10px; }
/* Opiniones y préstamos de amigos */
.amigo-blocks { display: flex; flex-direction: column; gap: 10px; }
.amigo-box {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 14.5px; line-height: 1.45;
}
.amigo-box.ok { border-color: rgba(216,180,106,.5); }
.amigo-box.muted { color: var(--muted); }
.amigo-box.link { display: block; width: 100%; text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.amigo-box.link .go { color: var(--accent); font-weight: 700; }
.amigo-box textarea { width: 100%; }
.amigo-box .stars-input button { font-size: 32px; }
.amigo-box .v-stars { font-size: 20px; }
.box-title { font-weight: 600; color: var(--accent); }
.amigo-cta { width: 100%; justify-content: center; }
.op-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.op-list { display: flex; flex-direction: column; gap: 8px; }
.op-item { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 3px; font-size: 14.5px; }
.op-item .stars { font-size: 15px; }
.op-row { width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.op-row .stars { font-size: 15px; }
.reco-pick { display: flex; gap: 12px; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 10px; }
.reco-form { display: flex; flex-direction: column; gap: 12px; }
.reco-form[hidden] { display: none; }
.brand-logo { width: 64px; height: 76px; object-fit: contain; flex: none; }
@media (max-width: 420px) { .brand-logo { width: 54px; height: 64px; } }
.tabs { display: flex; gap: 22px; max-width: 1200px; margin: 10px auto 0; }
.tabs button {
  background: none; border: 0; padding: 6px 0 10px; cursor: pointer;
  color: var(--muted); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 1200px; margin: 0 auto; padding: 18px 16px; }

/* ---------- Barra inferior (móvil) ---------- */
.bottombar { display: none; }
@media (max-width: 700px) {
  .tabs { display: none; }
  .topbar { padding-bottom: 12px; }
  .bottombar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(24, 33, 27, .97); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottombar button {
    flex: 1; background: none; border: 0; color: var(--muted); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 4px 0;
  }
  .bottombar svg { width: 22px; height: 22px; }
  .bottombar button.active { color: var(--accent); }
}

/* ---------- Inicio: leyendo ahora + reto ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 760px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero > .panel { min-width: 0; }
.hero.solo { grid-template-columns: minmax(0, 1fr); max-width: 520px; }
@media (max-width: 700px) {
  .panel { padding: 13px 14px; }
  .hero { gap: 10px; margin-bottom: 10px; }
  .goal-num { font-size: 28px; }
  .toolbar { gap: 8px; }
}
.toolbar #genre-filter[hidden] { display: none; }
.toolbar #genre-filter.on { background: rgba(216,180,106,.16); border-color: var(--accent); color: var(--accent); font-weight: 600; }
@media (max-width: 480px) { .r-meta { flex-wrap: wrap; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.eyebrow { font-size: 11.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: 10px; }
.reading-list { display: flex; flex-direction: column; gap: 14px; }
.reading { display: flex; gap: 14px; align-items: center; }
.reading .thumb { position: relative; width: 60px; height: 90px; flex: none; border-radius: 4px; overflow: hidden; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.reading .thumb .cover-fallback { font-size: 9px; padding: 4px; }
.reading .r-body { flex: 1; min-width: 0; }
.reading .r-title { font-family: var(--serif); font-size: 18px; line-height: 1.2; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reading .r-author { color: var(--muted); font-size: 13px; }
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.r-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.page-form { display: flex; gap: 6px; align-items: center; }
.page-form input { width: 76px; padding: 5px 8px; font-size: 13px; border-radius: 99px; text-align: center; }
.empty-reading { color: var(--muted); font-size: 14px; }
.ql-big { width: 100%; margin-top: 12px; font-size: 16px; padding: 12px 18px; }
.ql-next { margin-top: 14px; }

/* ---------- ¿Qué leo? ---------- */
.ql-intro { margin: 0; font-size: 15px; }
.ql-intro b { font-family: var(--serif); font-weight: 500; color: var(--accent); }
.ql-moods { display: flex; flex-wrap: wrap; gap: 6px; }
.ql-moods .pill { font-size: 13.5px; padding: 7px 13px; }
#ql-results { display: flex; flex-direction: column; gap: 18px; transition: opacity .15s; }
#ql-results.loading { opacity: .45; pointer-events: none; }
.ql-section { display: flex; flex-direction: column; gap: 10px; }
.ql-section h3 { font-size: 18px; color: var(--accent); }
.ql-card { display: flex; gap: 12px; background: var(--surface-2); border-radius: 12px; padding: 12px; }
.ql-cover { position: relative; width: 66px; height: 99px; flex: none; border-radius: 4px; overflow: hidden; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.ql-cover .cover-fallback { font-size: 9px; padding: 4px; }
.ql-card.compra .ql-cover { width: 52px; height: 78px; }
.ql-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ql-name { font-family: var(--serif); font-size: 17px; line-height: 1.2; cursor: pointer; overflow-wrap: anywhere; }
.ql-author { color: var(--muted); font-size: 13px; }
.ql-meta { color: var(--muted); font-size: 12.5px; }
.ql-price { color: var(--accent); font-weight: 600; }
.ql-why { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.ql-why span { background: var(--surface-3); color: var(--text); border-radius: 99px; padding: 3px 9px; font-size: 12px; line-height: 1.35; }
.ql-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ql-actions .mini { padding: 6px 11px; font-size: 12.5px; white-space: nowrap; }
.ql-more { align-self: center; }
@media (max-width: 420px) {
  .ql-card { gap: 10px; padding: 10px; }
  .ql-cover { width: 54px; height: 81px; }
  .ql-card.compra .ql-cover { width: 46px; height: 69px; }
  .ql-name { font-size: 16px; }
  .ql-actions .mini { padding: 6px 9px; }
  .ql-moods { display: grid; grid-template-columns: 1fr 1fr; }
  .ql-moods .pill { white-space: normal; padding: 8px 6px; font-size: 13px; line-height: 1.2; }
}

.goal-num { font-family: var(--serif); font-size: 34px; line-height: 1; }
.goal-num small { font-family: var(--sans); font-size: 14px; color: var(--muted); }
.goal-num button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; padding: 0 0 0 4px; }
.goal-edit { display: flex; gap: 6px; margin-top: 8px; }
.goal-edit input { width: 90px; border-radius: 99px; padding: 6px 12px; }
.goal-foot { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* ---------- Resumen ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 2px 16px; color: var(--muted); font-size: 13.5px; }
.stats b { color: var(--text); font-weight: 600; }

/* ---------- Barra de herramientas ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1 1 260px; }
input, select, textarea {
  background: var(--surface-2); border: 1px solid transparent; border-radius: 12px;
  padding: 10px 13px; min-width: 0; width: 100%; color: var(--text);
}
input::placeholder, textarea::placeholder { color: #7f8c7c; }
.toolbar select { width: auto; flex: 0 1 auto; border-radius: 99px; padding: 8px 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.chips-filter { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; min-width: 0; order: 3; }
.chips-filter::-webkit-scrollbar { display: none; }
.chips-loc { order: 4; align-items: center; }
.chip-sep { flex: 0 0 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.pill.small { padding: 5px 11px; font-size: 12.5px; }
.pill {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 99px; padding: 6px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.pill:hover { border-color: var(--muted); color: var(--text); }
.pill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.viewtoggle { display: inline-flex; background: var(--surface-2); border-radius: 99px; padding: 3px; }
.viewtoggle button { background: none; border: 0; border-radius: 99px; padding: 5px 11px; cursor: pointer; color: var(--muted); display: flex; }
.viewtoggle svg { width: 18px; height: 18px; }
.viewtoggle button.on { background: var(--accent); color: var(--accent-text); }

/* ---------- Tarjetas (miniaturas) ---------- */
/* Miniaturas: tarjeta con la portada arriba y el título dentro (estilo original) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column; min-width: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.25); transition: transform .12s, border-color .12s;
  text-align: left; padding: 0; color: inherit;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .cover-wrap { position: relative; aspect-ratio: 2/3; background: var(--surface-2); }
.cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-wrap .cover, .thumb .cover, .v-cover .cover { position: absolute; inset: 0; z-index: 1; }
.cover-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 12px; text-align: center; font-family: var(--serif); font-size: 15px; line-height: 1.2; color: #f3e6cc;
  background: #7a2e2a;
}
.card .info { padding: 9px 10px 11px; display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.card .t { font-weight: 600; font-size: 14px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card .a { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badges { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; gap: 4px; flex-wrap: wrap; z-index: 2; }
.badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  background: rgba(255,255,255,.92); color: #3a2a1c; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.badge.leido { background: #dcefdc; color: #24532f; }
.badge.leyendo { background: #fdeac4; color: #7a4f00; }
.badge.por_leer { background: #e5e2f7; color: #3a3172; }
.badge.fisico { background: #f6dfcf; color: #7a3e1d; }
.stars { color: var(--star); letter-spacing: 1px; font-size: 12.5px; }
.stars .off { color: var(--surface-3); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---------- Vista en lista ---------- */
.rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 44px minmax(0, 2.2fr) minmax(0, 1fr) auto; gap: 14px; align-items: center;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 4px;
  cursor: pointer; text-align: left; width: 100%; color: inherit;
}
.row:hover { background: var(--surface); }
.row .thumb { position: relative; width: 44px; height: 64px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.row .thumb .cover-fallback { font-size: 8px; padding: 3px; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .a, .row .m { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row .badge { box-shadow: none; }
@media (max-width: 560px) {
  .row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; }
  .row .thumb { width: 40px; height: 58px; }
  .row .mid { display: none; }
}

/* ---------- Vista estantería (lomos en baldas) ---------- */
.shelf { display: flex; flex-wrap: wrap; align-items: flex-end; row-gap: 26px; padding: 0 4px; }
.spine-slot {
  height: 168px; display: flex; align-items: flex-end; padding: 0 2px;
  border-bottom: 12px solid var(--wood);
  box-shadow: 0 6px 0 -2px var(--wood-dark);
}
.spine {
  position: relative; border: 0; cursor: pointer; border-radius: 3px 3px 1px 1px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--serif); font-size: 12px; line-height: 1.1; padding: 8px 2px;
  color: #f3e6cc; text-align: center;
  box-shadow: inset 3px 0 0 rgba(255,255,255,.08), inset -3px 0 0 rgba(0,0,0,.18);
  transition: transform .15s;
}
.spine:hover { transform: rotate(180deg) translateY(6px); }
.spine span { max-height: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.spine::before, .spine::after {
  content: ""; position: absolute; left: 3px; right: 3px; height: 2px; background: rgba(216, 180, 106, .55);
}
.spine::before { top: 10px; }
.spine::after { bottom: 10px; }
.spine.reading { outline: 2px solid var(--accent); outline-offset: 1px; }
.shelf-legend { color: var(--muted); font-size: 12.5px; margin-top: 14px; }

/* ---------- Novedades ---------- */
.nov-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.nov-section { margin: 18px 0 28px; }
.nov-section h3 { font-size: 21px; margin-bottom: 12px; }
.roller {
  display: grid; grid-auto-flow: column; grid-auto-columns: 140px; gap: 14px;
  overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity;
}
.roller .card { scroll-snap-align: start; cursor: default; }
.roller .card:hover { transform: none; border-color: var(--line); }
.nov-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.mini {
  border: 1px solid var(--line); background: transparent; border-radius: 99px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; text-decoration: none; color: var(--text);
}
.mini.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.mini[disabled] { opacity: .6; cursor: default; }
.mini.wish { color: #f0a9a9; border-color: rgba(232,141,141,.5); font-weight: 600; }
.mini.wish:hover { background: rgba(232,141,141,.12); }
.mini.wish.on { background: rgba(232,141,141,.16); color: #e88d8d; }
.mini.wish[disabled] { opacity: .85; }

/* ---------- Botones ---------- */
.btn {
  border: 1px solid transparent; border-radius: 99px; padding: 9px 18px; cursor: pointer;
  font-weight: 600; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { background: none; color: var(--danger); border-color: rgba(224, 103, 93, .5); }
.btn.small { padding: 5px 12px; font-size: 12.5px; }
.icon-btn { background: none; border: 0; font-size: 18px; cursor: pointer; padding: 6px; color: var(--muted); }
.fab {
  position: fixed; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 99px;
  padding: 14px 22px; font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.45);
  z-index: 20;
}
@media (max-width: 700px) {
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); padding: 12px 17px; font-size: 22px; line-height: 1; }
  .fab span { display: none; }
}

/* ---------- Diálogos ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text);
  width: min(640px, calc(100vw - 20px)); max-height: calc(100dvh - 30px);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(5, 10, 6, .65); }
/* Con una ficha o diálogo abierto, la página de detrás no se desplaza */
html:has(dialog[open]), html:has(dialog[open]) body { overflow: hidden; }
dialog { overscroll-behavior: contain; }

/* Escáner en directo */
dialog.scanner {
  width: min(560px, 100vw); height: min(760px, 100dvh); max-width: 100vw; max-height: 100dvh;
  background: #000; border: 0; overflow: hidden;
}
@media (max-width: 700px) { dialog.scanner { width: 100vw; height: 100dvh; border-radius: 0; } }
dialog.scanner::backdrop { background: rgba(0,0,0,.9); }
.scan-view { position: relative; width: 100%; height: 100%; }
.scan-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; left: 7%; right: 7%; top: 50%; height: 26%; transform: translateY(-50%);
  border: 3px solid rgba(255,255,255,.85); border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); transition: border-color .15s;
}
.scan-laser {
  position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff4d4d;
  box-shadow: 0 0 10px 2px rgba(255,60,60,.7); animation: laser 1.6s ease-in-out infinite;
}
@keyframes laser { 0%, 100% { top: 18%; } 50% { top: 82%; } }
dialog.scanner.hit .scan-frame { border-color: #5be37d; box-shadow: 0 0 0 100vmax rgba(20,60,30,.55); }
dialog.scanner.hit .scan-laser { display: none; }
.scan-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: flex-end; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 14px 14px;
}
.scan-top .icon-btn { background: rgba(0,0,0,.55); color: #fff; width: 44px; height: 44px; font-size: 20px; border-radius: 50%; }
.scan-torch.on { background: #f3d27a; color: #000; }
.scan-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center; color: #fff;
  padding: 16px 16px max(22px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.75) 40%);
}
.scan-bottom p { margin: 0 0 12px; font-size: 16px; }
.scan-bottom .btn { color: #fff; border-color: rgba(255,255,255,.5); }

/* Ráfaga */
.burst-btn { width: 100%; margin-top: 8px; }
.burst-panel {
  position: absolute; left: 12px; right: 12px; top: calc(max(14px, env(safe-area-inset-top)) + 54px);
}
.burst-opts { display: flex; gap: 6px; }
.burst-opts select {
  flex: 1 1 0; min-width: 0; padding: 8px 10px; font-size: 14px; border-radius: 10px;
  background: rgba(0,0,0,.6); color: #fff; border: 1px solid rgba(255,255,255,.35);
}
#burst-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
#burst-list li {
  background: rgba(0,0,0,.62); color: #fff; padding: 6px 10px; border-radius: 10px; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#burst-list li.ok { border-left: 4px solid #5be37d; }
#burst-list li.dup { border-left: 4px solid #f3d27a; }
#burst-list li.bad { border-left: 4px solid #ff6b6b; white-space: normal; }
#burst-list li.wait { opacity: .8; }
.burst-count { font-weight: 700; color: #5be37d; margin: 0 0 4px !important; }
.burst-count:empty { display: none; }
dialog.scanner.burst .scan-frame { top: 58%; }
dialog.scanner.burst .scan-bottom label { display: none; }
.dlg-head {
  display: flex; justify-content: space-between; align-items: center; margin: 0;
  padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.dlg-head h2 { font-size: 21px; color: var(--accent); }
.dlg-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label input, label select, label textarea { color: var(--text); font-weight: 400; font-size: 15px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .cols { grid-template-columns: 1fr; } }
.edit-top { display: flex; gap: 14px; }
.edit-main { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cover.big { width: 110px; height: 165px; border-radius: 6px; background: var(--surface-2); flex: none; object-fit: cover; box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.stars-input { display: flex; align-items: center; gap: 2px; }
.stars-input button { background: none; border: 0; font-size: 30px; color: var(--surface-3); cursor: pointer; padding: 0 2px; line-height: 1; }
.stars-input button.on { color: var(--star); }
/* Media estrella: mitad dorada, mitad apagada */
.stars .half, .v-stars .half, .stars-input button.half {
  background: linear-gradient(90deg, var(--star) 50%, var(--surface-3) 50%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stars-value { min-width: 2.2em; margin-left: 6px; color: var(--star); font-weight: 600; }
.v-stars small { font-size: 14px; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.stars-input .clear { font-size: 12px; color: var(--muted); margin-left: 8px; text-decoration: underline; }
.dlg-actions { display: flex; gap: 8px; align-items: center; padding-top: 4px; }
@media (max-width: 420px) { .dlg-actions .btn { padding: 9px 14px; } }
.spacer { flex: 1; }

/* ---------- Ficha en modo lectura ---------- */
.head-actions { display: flex; gap: 2px; align-items: center; }
.head-actions .icon-btn { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 99px; }
.head-actions .icon-btn:hover { background: var(--surface-2); color: var(--text); }
#view-edit { color: var(--accent); }
#view-edit svg { width: 20px; height: 20px; }
.v-top { display: flex; gap: 16px; }
.v-cover { position: relative; width: 120px; height: 180px; flex: none; border-radius: 6px; overflow: hidden; background: var(--surface-2); box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.v-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.v-title { font-family: var(--serif); font-size: 23px; line-height: 1.2; overflow-wrap: anywhere; }
.v-author { color: var(--muted); font-size: 15px; }
.v-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.v-badges .badge { box-shadow: none; font-size: 12px; padding: 3px 10px; }
.v-stars { color: var(--star); font-size: 22px; letter-spacing: 2px; }
.v-stars .off { color: var(--surface-3); }
.v-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 4px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); }
.v-facts div { min-width: 0; }
.v-facts dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.v-facts dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.v-notes { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.v-notes-label { font-size: 12px; color: var(--muted); margin-bottom: -6px; }
.v-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.v-actions .btn { text-decoration: none; }
@media (max-width: 420px) {
  .v-cover { width: 100px; height: 150px; }
  .v-title { font-size: 20px; }
}

.search-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-row input { flex: 1 1 200px; }
.search-row > .btn { flex: 1 1 auto; }
.scan-btn { flex-direction: row; color: var(--text); font-size: 15px; }
.results { display: flex; flex-direction: column; gap: 8px; }
.result {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; color: inherit;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 8px; cursor: pointer;
}
.result:hover { border-color: var(--accent); }
.result img { width: 46px; height: 69px; object-fit: cover; border-radius: 4px; background: var(--surface-3); flex: none; }
.result .t { font-weight: 600; }
.result .a { color: var(--muted); font-size: 13px; }
/* Resultados de Deseos con su corazón a la derecha */
.result-row { position: relative; }
.result-row .result { padding-right: 58px; }
.heart-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--muted);
  font-size: 25px; line-height: 1; cursor: pointer; transition: transform .15s, color .15s;
}
.heart-btn:hover { color: #e88d8d; border-color: rgba(232,141,141,.45); }
.heart-btn.on { color: #e88d8d; border-color: rgba(232,141,141,.45); background: rgba(232,141,141,.12); }
.heart-btn.on:active, .heart-btn:active { transform: translateY(-50%) scale(.88); }
.heart-btn.have { color: var(--ok); font-size: 18px; cursor: default; border-color: rgba(143,199,155,.4); }
.heart-btn[disabled] { opacity: .8; }
.buy-card { position: relative; }
#buy-result, .result-row { scroll-margin-top: 110px; }
.buy-close { position: absolute; top: -8px; right: -4px; z-index: 1; }
.buy-card .b-title { padding-right: 30px; }


.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; opacity: 0; font-weight: 500;
  transition: all .2s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.has-action.show { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 18px; width: max-content; }
.toast-btn { background: var(--bg); color: var(--accent); border: 0; border-radius: 99px; padding: 7px 14px; font-weight: 700; cursor: pointer; white-space: nowrap; }

/* ---------- Compras ---------- */
.tabs button, .bottombar button { position: relative; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: 5px; vertical-align: 2px; }
.bottombar .dot { position: absolute; top: 2px; left: calc(50% + 8px); margin: 0; }
.buy-help { margin: 0 0 10px; }
#buy-isbn { flex: 1 1 160px; }
.buy-card { display: flex; gap: 16px; margin: 14px 0 22px; }
.buy-card .thumb { position: relative; width: 104px; height: 156px; flex: none; border-radius: 6px; overflow: hidden; box-shadow: 0 6px 16px rgba(0,0,0,.4); background: var(--surface-2); }
.buy-card .b-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.buy-card .b-title { font-family: var(--serif); font-size: 21px; line-height: 1.2; }
.buy-card .b-author { color: var(--muted); font-size: 14px; margin-top: -4px; }
.owned { border-radius: 12px; padding: 9px 12px; font-size: 14px; font-weight: 600; }
.owned.yes { background: #dcefdc; color: #24532f; }
.owned.read { background: #e5e2f7; color: #3a3172; }
.owned.list { background: #fdeac4; color: #7a4f00; }
.owned.no { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.price-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price-big { font-family: var(--serif); font-size: 28px; color: var(--accent); }
.price-src { color: var(--muted); font-size: 13px; }
.buy-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.buy-actions .btn { padding: 8px 14px; font-size: 13.5px; text-decoration: none; }
.link-form { display: flex; gap: 6px; flex-wrap: wrap; }
.link-form input { flex: 1 1 200px; padding: 8px 12px; font-size: 13px; border-radius: 99px; }
.hint { font-size: 12.5px; color: var(--muted); }
@media (max-width: 480px) {
  .buy-card { flex-direction: column; align-items: center; text-align: center; }
  .buy-card .b-body { align-items: stretch; width: 100%; }
  .price-line, .buy-actions { justify-content: center; }
}
.watch-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; }
.watch-head h3 { font-size: 21px; color: var(--accent); }
#watch-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 10px; }
.watch { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.watch.drop { background: rgba(216, 180, 106, .08); }
.watch .thumb { position: relative; width: 44px; height: 64px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.watch .thumb .cover-fallback { font-size: 8px; padding: 3px; }
.watch .w-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watch .w-meta { color: var(--muted); font-size: 12.5px; }
.watch .w-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.watch .w-price { font-family: var(--serif); font-size: 19px; }
.drop-badge { display: inline-block; margin: 3px 0; background: var(--accent); color: var(--accent-text); border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.watch .w-info { min-width: 0; }
.watch .w-actions { grid-column: 2 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.watch .thumb { grid-row: span 2; align-self: start; }
.watch .w-link { grid-column: 2 / -1; }
.empty-small { color: var(--muted); font-size: 14px; padding: 16px 4px; }

/* ---------- Gustos (Novedades) ---------- */
.tastes { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 6px 0 12px; }
.tastes-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.tastes-head h3 { font-size: 19px; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 99px;
  background: var(--surface-2); font-size: 13.5px;
}
.chip button { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 12px; padding: 0 4px; }
.taste-add { display: flex; gap: 8px; }
.dislikes { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.dislikes p { margin: 0; }
.dislikes-head { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.chip.no { background: rgba(224,103,93,.12); color: #f0b4ae; }
.chip.no small { color: var(--muted); }
/* ✕ «No me interesa» sobre la portada de cada novedad */
.nov-x {
  position: absolute; top: 6px; right: 6px; z-index: 3; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(10,14,11,.72); color: #fff; font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.nov-x:hover { background: rgba(160,50,45,.9); }
.card.gone { opacity: 0; transform: scale(.9); pointer-events: none; transition: opacity .2s, transform .2s; }
.taste-add select { flex: 1; border-radius: 99px; }
.reason { font-size: 11.5px; color: var(--accent); line-height: 1.25; }
.nov-section h3 small { font-family: var(--sans); font-size: 13px; color: var(--muted); font-weight: 400; }
details.general > summary { cursor: pointer; font-family: var(--serif); font-size: 21px; margin: 22px 0 6px; }
.loc-field { margin: 10px 0; }
.date-hint { margin: 4px 0 0; }
.buy-scan { width: 100%; margin-top: 8px; }
#buy-search { margin-top: 8px; }
.wish-btn.on { color: #e88d8d; border-color: rgba(232,141,141,.45); }
.watch [data-open] { cursor: pointer; }
.add-where { margin: 0 0 10px; color: var(--accent); font-size: 14px; font-weight: 500; }
.loc-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.loc-row { display: flex; gap: 8px; flex-wrap: wrap; }
.loc-row > * { flex: 1 1 140px; min-width: 0; }
.with-btn { display: flex; gap: 6px; }
.with-btn .btn { padding: 6px 12px; }

/* Móvil: buscador + vistas arriba; orden y categoría debajo, a medias */
@media (max-width: 700px) {
  .toolbar input[type=search] { flex: 1 1 140px; min-width: 0; }
  .toolbar .viewtoggle { order: 1; }
  .toolbar #sort, .toolbar #genre-filter { order: 2; flex: 1 1 40%; min-width: 0; }
}

/* ---------- Versión de pruebas (beta, en el NAS) ---------- */
.beta-franja {
  background: repeating-linear-gradient(135deg, #5a3a12 0 12px, #4a300f 12px 24px);
  color: #f6dca0; font-size: 12.5px; font-weight: 600; text-align: center; line-height: 1.35;
  padding: 5px 12px; border-bottom: 1px solid #7a5520;
}
