/* ================= Tokens ================= */
:root {
  --bg: #f5f1e8;
  --bg-2: #ede7d9;
  --surface: #fffdf8;
  --surface-2: #f8f4ea;
  --ink: #1d1b18;
  --ink-2: #57524a;
  --ink-3: #8b8478;
  --line: #e3dccd;
  --accent: #1f5c4a;
  --accent-2: #2d7a63;
  --accent-soft: #dcebe3;
  --amber: #c98a2b;
  --amber-soft: #f6e7cc;
  --red: #c4473e;
  --red-soft: #f7dcd8;
  --blue: #4559b8;
  --blue-soft: #dfe3f6;
  --green: #2f8a5f;
  --green-soft: #d7efe1;
  --shadow-sm: 0 1px 2px rgba(40, 30, 10, .06), 0 2px 6px rgba(40, 30, 10, .04);
  --shadow: 0 2px 4px rgba(40, 30, 10, .05), 0 12px 32px rgba(40, 30, 10, .08);
  --shadow-lg: 0 24px 64px rgba(40, 30, 10, .18);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --sidebar: 260px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f; --bg-2: #1b1a15; --surface: #1f1e19; --surface-2: #26241e;
    --ink: #f1ece1; --ink-2: #bdb5a5; --ink-3: #8a8374; --line: #34312a;
    --accent: #5fb898; --accent-2: #7ccbae; --accent-soft: #1f3a31;
    --amber: #e3a84c; --amber-soft: #3b2f1a; --red: #ec7a70; --red-soft: #3e2220;
    --blue: #8c9bf0; --blue-soft: #262c4a; --green: #6cc89a; --green-soft: #1d3a2b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 12px 32px rgba(0,0,0,.35); --shadow-lg: 0 24px 64px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14130f; --bg-2: #1b1a15; --surface: #1f1e19; --surface-2: #26241e;
  --ink: #f1ece1; --ink-2: #bdb5a5; --ink-3: #8a8374; --line: #34312a;
  --accent: #5fb898; --accent-2: #7ccbae; --accent-soft: #1f3a31;
  --amber: #e3a84c; --amber-soft: #3b2f1a; --red: #ec7a70; --red-soft: #3e2220;
  --blue: #8c9bf0; --blue-soft: #262c4a; --green: #6cc89a; --green-soft: #1d3a2b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 12px 32px rgba(0,0,0,.35); --shadow-lg: 0 24px 64px rgba(0,0,0,.55);
  color-scheme: dark;
}

/* ================= Base ================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; letter-spacing: -.01em; margin: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--accent-soft); }

/* ================= Splash ================= */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; transition: transform .7s cubic-bezier(.7, 0, .2, 1), visibility .7s; }
.splash.out { transform: translateY(-100%); visibility: hidden; }
.splash.out .splash-book span { animation: none; }
.splash-book { display: flex; gap: 6px; align-items: flex-end; height: 48px; }
.splash-book span { width: 12px; border-radius: 3px; background: var(--accent); animation: bounce 1s var(--ease) infinite; }
.splash-book span:nth-child(1) { height: 40px; }
.splash-book span:nth-child(2) { height: 48px; animation-delay: .12s; background: var(--amber); }
.splash-book span:nth-child(3) { height: 34px; animation-delay: .24s; background: var(--red); }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12px); } }

/* ================= Login ================= */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.login-bg { position: absolute; inset: 0; pointer-events: none; }
.shelf { position: absolute; left: -10%; right: -10%; height: 140px; opacity: .5;
  background: repeating-linear-gradient(90deg, var(--accent) 0 18px, transparent 18px 22px, var(--amber) 22px 34px, transparent 34px 38px, var(--red) 38px 52px, transparent 52px 56px, var(--blue) 56px 66px, transparent 66px 72px, var(--ink-3) 72px 86px, transparent 86px 92px);
  mask: linear-gradient(transparent, #000 30%, #000 70%, transparent);
  animation: slide 60s linear infinite; }
.shelf.s1 { top: 6%; opacity: .14; }
.shelf.s2 { top: 42%; opacity: .08; animation-duration: 90s; animation-direction: reverse; }
.shelf.s3 { bottom: 4%; opacity: .12; animation-duration: 75s; }
@keyframes slide { to { transform: translateX(-184px); } }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .45; animation: float 14s ease-in-out infinite; }
.o1 { width: 420px; height: 420px; background: var(--accent-soft); top: -120px; right: -80px; }
.o2 { width: 360px; height: 360px; background: var(--amber-soft); bottom: -120px; left: -80px; animation-delay: -7s; }
@keyframes float { 50% { transform: translate(30px, 40px) scale(1.08); } }
.login-card { position: relative; width: 100%; max-width: 420px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 24px; padding: 40px 32px; text-align: center; box-shadow: var(--shadow-lg);
  animation: rise .8s var(--spring) both; }
.login-title { font-size: clamp(30px, 6vw, 40px); margin: 18px 0 8px; }
.login-sub { color: var(--ink-2); margin: 0 0 28px; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.login-help { margin: 18px 0 0; color: var(--ink-3); font-size: 13px; text-align: center; }
.login-error { color: var(--red); background: var(--red-soft); padding: 10px 14px; border-radius: var(--radius-sm); margin: 16px 0 0; font-size: 14px; }

/* ================= Brand ================= */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 650; font-size: 19px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; box-shadow: var(--shadow-sm); flex: none; }
.brand-mark svg { width: 22px; height: 22px; fill: var(--bg); stroke: none; }
.brand-mark.big { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto; animation: pop .9s var(--spring) .15s both; }
.brand-mark.big svg { width: 44px; height: 44px; }

/* ================= Layout ================= */
.app { min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
  background: var(--surface); border-right: 1px solid var(--line); z-index: 20; }
.sidebar .brand { padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; position: relative; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); padding: 16px 12px 6px; }
.nav a { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--ink-2);
  text-decoration: none; font-weight: 500; transition: color .3s, transform .3s var(--spring); }
.nav a:hover { color: var(--ink); transform: translateX(3px); }
.nav a.active { color: var(--accent); }

/* Indicador que se desliza entre elementos (menú, barra inferior y filtros) */
.ind { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; border-radius: var(--radius-sm); background: var(--accent-soft);
  transition: transform .55s var(--spring), width .55s var(--spring), height .55s var(--spring); }
.ind.hide { visibility: hidden; }
#bottomnav > .ind { border-radius: 14px; }
.chips > .ind { border-radius: 999px; background: var(--ink); }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; animation: pop .4s var(--spring); }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius); background: var(--surface-2); }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who small { display: block; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--accent); color: var(--bg); display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

.topbar, .bottomnav { display: none; }
.main { margin-left: var(--sidebar); padding: 36px clamp(16px, 4vw, 48px) 48px; max-width: calc(1240px + var(--sidebar)); }

@media (max-width: 959px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
  .topbar .brand { flex: 1; font-size: 17px; }
  .topbar .brand-mark { width: 32px; height: 32px; }
  .bottomnav { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20;
    background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(16px); border: 1px solid var(--line);
    border-radius: 20px; padding: 6px; box-shadow: var(--shadow); animation: rise .6s var(--spring) .2s both; }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px; color: var(--ink-3);
    text-decoration: none; font-size: 11px; font-weight: 500; position: relative; z-index: 1; transition: color .3s; }
  .bottomnav a.active { color: var(--accent); }
  .bottomnav a.active svg { animation: pop .45s var(--spring); }
  .bottomnav .badge { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; min-width: 16px; height: 16px; font-size: 10px; }
}
.icon-btn, .avatar-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--ink-2); transition: background .2s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--bg); }
.avatar-btn { padding: 0; }

/* ================= View ================= */
.view { min-height: 60vh; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.1; }
.page-head p { color: var(--ink-2); margin: 6px 0 0; }
.page-head .grow { flex: 1; min-width: 220px; }

/* ================= Controls ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; background: var(--ink); color: var(--bg); transition: transform .15s var(--ease), box-shadow .2s, background .2s, opacity .2s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0) scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: var(--bg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: var(--bg); } }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-success { background: var(--green-soft); color: var(--green); }
.btn-warn { background: var(--amber-soft); color: var(--amber); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn.loading { color: transparent !important; position: relative; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--bg) transparent var(--bg) transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-ghost.loading::after, .btn-danger.loading::after, .btn-success.loading::after { border-color: var(--ink) transparent var(--ink) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

input, textarea, select { width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); outline: none;
  transition: border-color .2s, box-shadow .2s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { resize: vertical; min-height: 84px; }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; }
.search input { padding-left: 42px; border-radius: 999px; box-shadow: var(--shadow-sm); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 18px; scrollbar-width: none; position: relative; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; position: relative; z-index: 1; border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; transition: color .3s, border-color .3s, background-color .3s, transform .3s var(--spring); }
.chip:hover { border-color: var(--ink-3); }
.chip:active { transform: scale(.95); }
.chip.active { background: transparent; color: var(--bg); border-color: transparent; }
.chip .n { font-size: 11px; background: var(--surface-2); color: var(--ink-2); padding: 0 6px; border-radius: 8px; }
.chip.active .n { background: color-mix(in srgb, var(--bg) 20%, transparent); color: var(--bg); }

/* ================= Stats ================= */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s; cursor: pointer; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 14px; }
.stat b { display: block; font-family: var(--serif); font-size: 30px; line-height: 1; }
.stat span { color: var(--ink-2); font-size: 13px; }
.tone-amber .ic { background: var(--amber-soft); color: var(--amber); }
.tone-blue .ic { background: var(--blue-soft); color: var(--blue); }
.tone-green .ic { background: var(--green-soft); color: var(--green); }
.tone-red .ic { background: var(--red-soft); color: var(--red); }
.tone-red.hot { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.tone-red.hot::after { content: ''; position: absolute; top: 16px; right: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 60%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }

/* ================= Books ================= */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }
.book { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm); transition: transform .35s var(--ease), box-shadow .35s; cursor: pointer; }
.book:hover { transform: translateY(-6px); box-shadow: var(--shadow); }
.book:hover .cover { transform: scale(1.04) rotate(-1deg); }
.cover-wrap { aspect-ratio: 3/4; overflow: hidden; background: var(--surface-2); position: relative; }
.cover { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); display: block; }
.cover.gen { display: flex; flex-direction: column; justify-content: space-between; padding: 18px 16px 16px 24px; color: #fff; position: relative; }
.cover.gen::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 3px; background: rgba(255,255,255,.25); }
.cover.gen .t { font-family: var(--serif); font-size: 19px; line-height: 1.15; font-weight: 650; text-wrap: balance; }
.cover.gen .a { font-size: 12px; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
.avail { position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,.92); color: #1d1b18; backdrop-filter: blur(6px); }
.avail.none { background: var(--red); color: #fff; }
.book-body { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.book-body h3 { font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-body .by { color: var(--ink-2); font-size: 13px; }
.book-body .cat { color: var(--ink-3); font-size: 12px; margin-top: auto; padding-top: 8px; }
.book-body .btn { margin-top: 10px; }

/* ================= Status pills ================= */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pending { background: var(--amber-soft); color: var(--amber); }
.st-accepted { background: var(--blue-soft); color: var(--blue); }
.st-picked_up { background: var(--accent-soft); color: var(--accent); }
.st-returned { background: var(--green-soft); color: var(--green); }
.st-denied, .st-overdue { background: var(--red-soft); color: var(--red); }
.st-cancelled { background: var(--surface-2); color: var(--ink-3); }
.st-overdue::before { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ================= Request cards ================= */
.list { display: grid; gap: 12px; }
.req { display: grid; grid-template-columns: 56px 1fr auto; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); transition: transform .25s var(--ease), box-shadow .25s, border-color .25s; }
.req:hover { box-shadow: var(--shadow); }
.req.is-overdue { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); background: linear-gradient(90deg, var(--red-soft), var(--surface) 40%); }
.req .mini { width: 56px; height: 74px; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow-sm); }
.req .mini .cover.gen { padding: 8px 6px 6px 10px; }
.req .mini .cover.gen::before { left: 4px; width: 2px; }
.req .mini .cover.gen .t { font-size: 9px; }
.req .mini .cover.gen .a { display: none; }
.req h3 { font-size: 16px; line-height: 1.3; }
.req .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font-size: 13px; margin-top: 4px; align-items: center; }
.req .meta span { display: inline-flex; align-items: center; gap: 5px; }
.req .meta svg { width: 14px; height: 14px; color: var(--ink-3); }
.req .note { margin-top: 8px; font-size: 13px; color: var(--ink-2); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; border-left: 3px solid var(--line); }
.req .note.admin { border-left-color: var(--accent); }
.req .who { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.req .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.req .side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
@media (max-width: 680px) {
  .req { grid-template-columns: 48px 1fr; gap: 12px; padding: 12px; }
  .req .mini { width: 48px; height: 64px; }
  .req .side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; }
  .req .actions { justify-content: flex-start; }
}

.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 10px; max-width: 320px; }
.progress i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transform-origin: left; animation: bar 1s var(--ease) both; }
.progress.warn i { background: var(--amber); }
.progress.bad i { background: var(--red); }
@keyframes bar { from { transform: scaleX(0); } }

/* Timeline */
.timeline { display: flex; gap: 0; margin-top: 12px; }
.timeline .step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; font-size: 11px; color: var(--ink-3); text-align: center; gap: 4px; }
.timeline .step::before { content: ''; position: absolute; top: 6px; left: -50%; right: 50%; height: 2px; background: var(--line); z-index: 0; }
.timeline .step:first-child::before { display: none; }
.timeline .step i { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); z-index: 1; transition: all .3s; }
.timeline .step.done { color: var(--ink-2); }
.timeline .step.done i { background: var(--accent); border-color: var(--accent); }
.timeline .step.done::before { background: var(--accent); }
.timeline .step.now i { box-shadow: 0 0 0 4px var(--accent-soft); animation: pop .5s var(--spring); }
.timeline .step.fail i { background: var(--red); border-color: var(--red); }

/* ================= Notifications ================= */
.notif { display: flex; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); position: relative; transition: background .3s; }
.notif.unread { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.notif.unread::after { content: ''; position: absolute; top: 18px; right: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.notif .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.notif b { display: block; font-size: 14px; padding-right: 18px; }
.notif p { margin: 2px 0 4px; font-size: 14px; color: var(--ink-2); white-space: pre-line; }
.notif small { color: var(--ink-3); font-size: 12px; }
.ic-accepted, .ic-returned { background: var(--green-soft); color: var(--green); }
.ic-denied, .ic-overdue { background: var(--red-soft); color: var(--red); }
.ic-reminder { background: var(--amber-soft); color: var(--amber); }
.ic-info, .ic-picked_up { background: var(--blue-soft); color: var(--blue); }

/* ================= Table ================= */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
.u-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.u-cell small { display: block; color: var(--ink-3); }
.role-admin { background: var(--accent-soft); color: var(--accent); }
.role-user { background: var(--surface-2); color: var(--ink-2); }
.hint { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: var(--blue-soft); color: var(--ink); margin-bottom: 18px; font-size: 14px; }
.hint svg { color: var(--blue); margin-top: 1px; }
.hint code { background: var(--surface); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* ================= Empty / skeleton ================= */
.empty { text-align: center; padding: 64px 16px; color: var(--ink-2); }
.empty .art { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 24px; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-3); animation: float 6s ease-in-out infinite; }
.empty .art svg { width: 38px; height: 38px; stroke-width: 1.5; }
.empty h3 { font-size: 20px; color: var(--ink); margin-bottom: 6px; }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-2) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Entrada escalonada */
/* Entrada escalonada: se despliegan desde abajo (sin fundidos) */
.stagger > * { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
tbody.stagger > * { animation-name: slideRow; }
@keyframes rise { from { transform: translateY(28px) scale(.94); clip-path: inset(0 0 100% 0 round 16px); } to { clip-path: inset(0 0 0 0 round 0); } }
@keyframes slideRow { from { transform: translateX(-24px); } }
@keyframes pop { from { transform: scale(.4); } }
@keyframes grow { from { transform: scaleY(0); } }

/* ================= Modal ================= */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(20, 16, 8, .45); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px;
  animation: fade .25s ease both; }
.modal-back.closing { animation: fade .2s ease reverse both; }
.modal { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg);
  animation: modalIn .45s var(--spring) both; }
.modal-back.closing .modal { animation: modalOut .2s ease-in both; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.modal-head h2 { flex: 1; font-size: 22px; }
.modal-body { padding: 18px 22px; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 22px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes modalIn { from { transform: translateY(40px) scale(.9); clip-path: inset(30% 20% 30% 20% round 22px); } to { clip-path: inset(0 round 22px); } }
@keyframes modalOut { to { transform: translateY(30px) scale(.9); clip-path: inset(30% 20% 30% 20% round 22px); } }
/* Mientras la ventana se transforma desde su origen, las animaciones CSS se desactivan */
.modal-back.morphing, .modal-back.morphing .modal { animation: none; }
.modal-back.morphing { view-transition-name: backdrop; }
@media (max-width: 600px) {
  .modal-back { place-items: end center; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); animation-name: sheetIn; }
  .modal-back.closing .modal { animation-name: sheetOut; }
  .modal-foot .btn { flex: 1; }
}
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }

.detail { display: grid; grid-template-columns: 200px 1fr; gap: 22px; }
.detail .cover-wrap { border-radius: 12px; box-shadow: var(--shadow); }
.detail h2 { font-size: 26px; line-height: 1.15; }
.detail .by { color: var(--ink-2); margin: 6px 0 14px; }
.detail .desc { color: var(--ink-2); font-size: 14px; }
.kv { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.kv span { font-size: 12px; background: var(--surface-2); padding: 4px 10px; border-radius: 8px; color: var(--ink-2); }
@media (max-width: 600px) { .detail { grid-template-columns: 1fr; } .detail .cover-wrap { width: 150px; margin: 0 auto; } }

.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; transition: all .2s; }
.quick button:hover, .quick button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ================= Toasts ================= */
.toasts { position: fixed; z-index: 60; top: 16px; right: 16px; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
@media (max-width: 600px) { .toasts { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); right: 16px; } }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg);
  animation: toastIn .45s var(--spring) both; font-size: 14px; }
.toast.out { animation: toastOut .3s ease-in both; }
.toast.error { background: var(--red); color: #fff; }
.toast.success svg { color: var(--accent-2); }
@keyframes toastIn { from { transform: translateX(calc(100% + 24px)); } }
@keyframes toastOut { to { transform: translateX(calc(100% + 24px)); } }

/* ================= Formulario de libro / editor de portada ================= */
.book-form { display: grid; grid-template-columns: 190px 1fr; gap: 22px; align-items: start; }
@media (max-width: 600px) { .book-form { grid-template-columns: 1fr; } }
.book-fields { display: grid; gap: 14px; }
.cover-editor { display: grid; gap: 10px; justify-items: center; }
.cover-drop { position: relative; width: 170px; border-radius: 12px; cursor: pointer; transition: transform .35s var(--spring); }
.cover-drop:hover { transform: rotate(-2deg) translateY(-3px); }
.cover-drop .cover-wrap { border-radius: 12px; box-shadow: var(--shadow); }
.cover-drop .cover.gen .t { font-size: 16px; }
.cover-wrap.flip { animation: flip .6s var(--spring); }
@keyframes flip { from { transform: perspective(700px) rotateY(-100deg); } }
.drop-hint { position: absolute; inset: 0; border-radius: 12px; display: grid; place-content: center; justify-items: center; gap: 6px; color: #fff; font-size: 13px; font-weight: 600;
  background: rgba(20, 30, 25, .55); clip-path: circle(0 at 50% 50%); transition: clip-path .45s var(--ease); }
.drop-hint svg { width: 28px; height: 28px; }
.cover-drop:hover .drop-hint, .cover-drop.over .drop-hint { clip-path: circle(75% at 50% 50%); }
.cover-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cover-editor input[type=url] { font-size: 13px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
label.check input { width: auto; }
.thumb { position: relative; width: 36px; height: 48px; flex: none; padding: 0; border: 0; border-radius: 5px; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-sm); transition: transform .3s var(--spring); }
.thumb .cover.gen { padding: 0; }
.thumb > span { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .5); clip-path: circle(0 at 50% 50%); transition: clip-path .35s var(--ease); }
.thumb > span svg { width: 16px; height: 16px; }
.thumb:hover { transform: scale(1.12) rotate(-3deg); }
.thumb:hover > span { clip-path: circle(80% at 50% 50%); }

/* ================= Botones extra ================= */
.btn-lg { padding: 14px 22px; font-size: 16px; border-radius: 14px; }
.btn-glass { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .22); backdrop-filter: blur(8px); }
.btn-glass:hover { background: rgba(255, 255, 255, .22); }
.btn-dice svg { transition: transform .6s var(--spring); }
.btn-dice:hover svg { transform: rotate(180deg); }
.muted { color: var(--ink-3); font-size: 14px; margin: 0; }
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }

/* ================= Estrellas ================= */
.stars { position: relative; display: inline-block; line-height: 1; letter-spacing: 1px; font-size: 13px; color: var(--line); white-space: nowrap; vertical-align: middle; }
.stars .s-fg { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--amber); }
.stars.sm { font-size: 12px; }
.stars.lg { font-size: 22px; letter-spacing: 2px; }
.rate { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; margin-top: 4px; }
.rate b { font-weight: 700; color: var(--ink); }
.rate small { color: var(--ink-3); }
.rate-none { color: var(--ink-3); }

/* ================= Libro del mes ================= */
/* Diseño editorial sobrio: papel, tipografía y una sola línea de acento */
.featured { display: grid; grid-template-columns: auto 1fr; gap: clamp(20px, 4vw, 48px); align-items: center; margin-bottom: 40px;
  padding: clamp(20px, 3.5vw, 36px); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid var(--accent); box-shadow: var(--shadow-sm); }
.featured-skel { grid-column: 1 / -1; height: 230px; }
.featured.enter { animation: rise .6s var(--ease) both; }
.featured-cover { width: clamp(118px, 16vw, 172px); aspect-ratio: 3 / 4; padding: 0; border: 0; border-radius: 6px; overflow: hidden; cursor: pointer; background: var(--surface-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 12px 28px rgba(40, 30, 10, .18); transition: transform .35s var(--ease), box-shadow .35s var(--ease); }
.featured-cover:hover { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 18px 36px rgba(40, 30, 10, .22); }
.featured-cover .cover.gen .t { font-size: 17px; }
.featured-info { min-width: 0; }
.featured .eyebrow { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.featured .eyebrow span { font-weight: 700; color: var(--accent); }
.featured .eyebrow::after { content: ''; flex: 1; max-width: 120px; height: 1px; background: var(--line); }
.featured h2 { font-size: clamp(26px, 3.8vw, 40px); line-height: 1.08; margin: 12px 0 4px; text-wrap: balance; }
.featured .by { margin: 0; color: var(--ink-2); font-size: 17px; font-style: italic; font-family: var(--serif); font-weight: 500; }
.featured-meta { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 18px 0 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.featured-meta dt { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; }
.featured-meta dd { margin: 0; font-size: 14px; font-weight: 500; }
.featured-meta .rate { margin: 0; }
.featured blockquote { margin: 16px 0 0; padding: 2px 0 2px 16px; border-left: 2px solid var(--accent); font-family: var(--serif); font-size: 16px; line-height: 1.5; color: var(--ink); }
.featured blockquote cite { display: block; margin-top: 6px; font-family: var(--font); font-style: normal; font-size: 12px; color: var(--ink-3); }
.featured-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 20px; }
.featured-avail { font-size: 13px; color: var(--ink-3); }
.featured-avail.ok { color: var(--green); }
.featured-avail.ok::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
@media (max-width: 600px) {
  .featured { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .featured .eyebrow { justify-content: center; }
  .featured .eyebrow::after { display: none; }
  .featured-meta, .featured-actions { justify-content: center; }
  .featured blockquote { text-align: left; }
}

/* ================= Progreso del lector ================= */
.me-xp { display: block; height: 4px; margin-top: 6px; border-radius: 2px; background: var(--line); overflow: hidden; }
.me-xp i { display: block; height: 100%; border-radius: 2px; background: var(--accent); transition: width .8s var(--ease); }

.lvl-card { display: grid; grid-template-columns: auto 1fr auto; gap: clamp(18px, 3vw, 36px); align-items: center; margin-bottom: 20px;
  padding: clamp(20px, 3vw, 32px); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); box-shadow: var(--shadow-sm); }
.lvl-card.enter { animation: rise .6s var(--ease) both; }
.lvl-ring { position: relative; width: 120px; height: 120px; }
.lvl-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.lvl-ring circle { fill: none; stroke-width: 9; }
.lvl-ring .track { stroke: var(--surface-2); }
.lvl-ring .bar { stroke: var(--accent); stroke-linecap: round; stroke-dashoffset: var(--full); transition: stroke-dashoffset 1.4s var(--ease) .2s; }
.lvl-card.ready .lvl-ring .bar { stroke-dashoffset: var(--off); }
.lvl-ring > div { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.lvl-ring small { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.lvl-ring b { font-family: var(--serif); font-size: 40px; line-height: 1; }
.lvl-info .eyebrow { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.lvl-info h2 { font-size: clamp(24px, 3.4vw, 34px); margin: 6px 0 8px; }
.lvl-xp { font-size: 15px; color: var(--ink-2); }
.lvl-xp b { color: var(--ink); font-size: 18px; }
.lvl-xp span { color: var(--ink-3); font-size: 14px; }
.xp-bar { height: 8px; margin-top: 10px; border-radius: 4px; background: var(--surface-2); overflow: hidden; max-width: 460px; }
.xp-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; transform: scaleX(0); transition: transform 1.2s var(--ease) .3s; }
.lvl-card.ready .xp-bar i { transform: scaleX(var(--w)); }
.lvl-streak { display: grid; justify-items: center; gap: 2px; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-3); min-width: 108px; }
.lvl-streak svg { width: 26px; height: 26px; }
.lvl-streak b { font-family: var(--serif); font-size: 30px; line-height: 1; color: var(--ink-2); }
.lvl-streak small { font-size: 12px; }
.lvl-streak.on { background: var(--amber-soft); color: var(--amber); }
.lvl-streak.on b { color: var(--ink); }
.lvl-streak.on svg { fill: color-mix(in srgb, var(--amber) 30%, transparent); animation: flicker 2.2s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flicker { 50% { transform: scale(1.08) rotate(-3deg); } }
@media (max-width: 700px) {
  .lvl-card { grid-template-columns: auto 1fr; }
  .lvl-streak { grid-column: 1 / -1; grid-auto-flow: column; justify-content: center; align-items: center; gap: 8px; }
}
@media (max-width: 460px) { .lvl-card { grid-template-columns: 1fr; justify-items: center; text-align: center; } .xp-bar { margin-inline: auto; } }

.prog-stats .stat { cursor: default; }
.prog-stats .stat:hover { transform: none; box-shadow: var(--shadow-sm); }
.prog-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-bottom: 32px; }
@media (max-width: 760px) { .prog-row { grid-template-columns: 1fr; } }
.panel { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--accent); }
.panel-head h3 { flex: 1; font-size: 18px; color: var(--ink); }
.xp-tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.panel p { margin: 0 0 12px; color: var(--ink-2); }
.challenge-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-3); margin-bottom: 14px; }
.challenge-state svg { width: 16px; height: 16px; }
.challenge.done { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
.challenge.done .challenge-state { color: var(--green); }
.how ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.how li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-2); padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.how li:last-child { border-bottom: 0; padding-bottom: 0; }
.how li b { color: var(--accent); font-variant-numeric: tabular-nums; }

.prog-section { margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h3 { font-size: 22px; }
.section-head span { font-size: 13px; color: var(--ink-3); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.badge-card { display: grid; justify-items: center; gap: 6px; padding: 18px 12px 14px; text-align: center; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: transform .3s var(--spring); }
.badge-card:hover { transform: translateY(-3px); }
.badge-card b { font-size: 14px; }
.badge-card small { font-size: 12px; color: var(--ink-3); line-height: 1.35; min-height: 32px; }
.medal { position: relative; width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 4px;
  background: radial-gradient(circle at 35% 30%, #f7dc93, #d9a441 60%, #b07a1f); color: #5b3d0a; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15), 0 4px 12px rgba(176, 122, 31, .35); }
.medal::after { content: ''; position: absolute; inset: 5px; border-radius: 50%; border: 1.5px dashed rgba(91, 61, 10, .35); }
.medal svg { width: 26px; height: 26px; }
.badge-card.new .medal { animation: medalNew 2.6s ease-in-out infinite; }
@keyframes medalNew { 0%, 100% { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15), 0 4px 12px rgba(176, 122, 31, .35); } 50% { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15), 0 0 0 6px rgba(217, 164, 65, .25), 0 4px 18px rgba(176, 122, 31, .5); } }
.badge-card.locked .medal { background: var(--surface-2); color: var(--ink-3); box-shadow: inset 0 0 0 1.5px var(--line); }
.badge-card.locked .medal::after { border-color: var(--line); }
.badge-card.locked b { color: var(--ink-2); }
.lock { position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--ink-3); }
.lock svg { width: 13px; height: 13px; }
.badge-prog { width: 80%; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.badge-prog i { display: block; height: 100%; background: var(--ink-3); transform-origin: left; transform: scaleX(var(--w)); }
.badge-date { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.badge-card.unlocked .badge-date { color: var(--amber); font-weight: 600; }

.passport { display: flex; flex-wrap: wrap; gap: 12px; }
.stamp { position: relative; display: grid; place-items: center; min-width: 120px; min-height: 64px; padding: 10px 16px; border-radius: 10px;
  border: 1.5px dashed var(--line); background: var(--surface); color: var(--ink-3); font-size: 13px; font-weight: 600; transition: transform .3s var(--spring), border-color .3s; }
.stamp:hover { transform: translateY(-2px); border-color: var(--ink-3); }
.stamp.done { border: 2px solid var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface)); }
.stamp em { position: absolute; top: -9px; right: -8px; padding: 2px 8px; border: 2px solid var(--red); border-radius: 5px; background: var(--surface);
  font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--red); transform: rotate(var(--r)); }

/* Ruleta de XP: panel */
.bet-panel { margin-bottom: 32px; }
.bet-grid { display: grid; grid-template-columns: 1fr minmax(240px, 320px); gap: 24px; align-items: start; }
@media (max-width: 700px) { .bet-grid { grid-template-columns: 1fr; } }
.odds { display: flex; flex-wrap: wrap; gap: 8px; }
.odds span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 8px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.odds span::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.odds b { color: var(--ink); }
.bet-history { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.bet-history small { width: 100%; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.bet-history span { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.bet-history .win { background: var(--green-soft); color: var(--green); }
.bet-history .loss { background: var(--red-soft); color: var(--red); }
.bet-form { display: grid; gap: 12px; }
.bet-max { float: right; font-weight: 500; color: var(--ink-3); }
.bet-amount { display: grid; grid-template-columns: 1fr 90px; gap: 10px; align-items: center; }
.bet-amount input[type=range] { padding: 0; accent-color: var(--accent); box-shadow: none; border: 0; background: none; }
.bet-amount input[type=number] { text-align: center; font-weight: 700; }

/* Ruleta de XP: rueda */
.roulette.wheel-ov { overflow-y: auto; place-content: safe center; gap: clamp(10px, 2vh, 20px);
  background: radial-gradient(circle at 50% 38%, #1c5a48 0%, #0f3329 38%, #07120f 78%); }
.wheel-ov .r-title { font-size: clamp(26px, 5vw, 44px); }
.wheel-wrap { position: relative; width: min(84vw, 400px, 50vh); aspect-ratio: 1; margin-top: 12px; }
.wheel-wrap::before { content: ''; position: absolute; inset: -8%; border-radius: 50%; background: radial-gradient(circle, rgba(246, 199, 90, .22), transparent 68%); transition: opacity .6s; }
.wheel-ov .r-result { min-height: 232px; align-content: start; }
.wheel-svg { position: relative; display: block; width: 100%; height: 100%; fill: none; stroke: none; filter: drop-shadow(0 22px 34px rgba(0, 0, 0, .6)); }
.wheel-rot { transform-origin: 180px 180px; transform-box: view-box; }
.wheel-svg text { font-family: var(--serif); font-size: 30px; font-weight: 650; text-anchor: middle; dominant-baseline: central; fill: #fff; paint-order: stroke; stroke: rgba(0, 0, 0, .3); stroke-width: 2px; }
.wheel-svg .m0 text { fill: #c9ced6; }
.wheel-svg .m3 text { fill: #4a2f07; stroke: rgba(255, 255, 255, .35); }
.wheel-svg .dividers line { stroke: #e9c46f; stroke-width: 1.6; }
.wheel-svg .stud { fill: #fff3c4; }
.wheel-svg .slice { transition: filter .6s; }
.wheel-ov.won .slice:not(.hit) { filter: brightness(.42) saturate(.6); }
.wheel-ov.won .slice.hit { filter: brightness(1.2); animation: slicePulse 1.1s ease-in-out infinite alternate; }
@keyframes slicePulse { to { filter: brightness(1.55); } }
/* Luces del aro: parpadean despacio, corren al girar y destellan al ganar */
.wheel-svg .bulb { fill: #fff6d2; animation: bulb 1.6s steps(1) infinite; }
.wheel-svg .bulb.odd { animation-delay: .8s; }
.wheel-ov.spinning .bulb { animation-duration: .28s; }
.wheel-ov.spinning .bulb.odd { animation-delay: .14s; }
.wheel-ov.w-win .bulb { animation-duration: .4s; }
.wheel-ov.w-win .bulb.odd { animation-delay: .2s; }
.wheel-ov.w-lose .bulb { animation: none; fill: #6d5d38; }
@keyframes bulb { 0% { fill: #fff6d2; filter: drop-shadow(0 0 4px #ffd76a); } 50% { fill: #7a5a1e; filter: none; } }
.wheel-pointer { position: absolute; top: -5.5%; left: 50%; z-index: 2; width: 10%; translate: -50% 0; transform-origin: 50% 30%; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .55)); }
.wheel-pointer svg { display: block; width: 100%; height: auto; stroke: none; }
.wheel-pointer.bump { animation: bump .14s ease-out; }
.w-wait { color: rgba(255, 255, 255, .6); }
.w-mult { font-family: var(--serif); font-size: clamp(56px, 12vw, 88px); font-weight: 650; line-height: 1; animation: titlePop .7s var(--spring); }
.w-win .w-mult { color: #f6c75a; text-shadow: 0 0 40px rgba(246, 199, 90, .5); }
.w-lose .w-mult { color: rgba(255, 255, 255, .45); }
.w-even .w-mult { color: #fff; }
.w-net { font-size: 18px; color: #fff !important; }
.w-total, .w-left { font-size: 14px; }
.w-lose .wheel-wrap::before { opacity: 0; }

/* Aviso de logro */
.achievement { position: fixed; z-index: 65; top: calc(16px + env(safe-area-inset-top)); left: 50%; translate: -50% 0; display: flex; align-items: center; gap: 14px;
  padding: 12px 22px 12px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); cursor: pointer;
  animation: achIn .6s var(--spring) both; width: max-content; min-width: min(320px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
.achievement.out { animation: achOut .35s ease-in both; }
.achievement .medal { width: 48px; height: 48px; margin: 0; flex: none; animation: medalSpin .9s var(--spring) .1s both; }
.achievement .medal svg { width: 22px; height: 22px; }
.achievement small { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--amber); font-weight: 700; }
.achievement b { font-family: var(--serif); font-size: 18px; }
@keyframes achIn { from { transform: translateY(-140%); } }
@keyframes achOut { to { transform: translateY(-140%); } }
@keyframes medalSpin { from { transform: rotateY(540deg) scale(.4); } }

/* ================= Reseñas ================= */
.d-rate { margin: -6px 0 10px; }
.reviews { border-top: 1px solid var(--line); padding-top: 18px; display: grid; gap: 18px; }
.rv-head { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
.rv-score { display: grid; justify-items: center; gap: 4px; }
.rv-score b { font-family: var(--serif); font-size: 44px; line-height: 1; }
.rv-score small { color: var(--ink-3); }
.rv-dist { display: grid; gap: 5px; }
.rv-dist div { display: grid; grid-template-columns: 26px 1fr 22px; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-2); }
.rv-dist i { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.rv-dist em { display: block; height: 100%; border-radius: 4px; background: var(--amber); transform-origin: left; transform: scaleX(0); transition: transform .9s var(--spring); }
.reviews.ready .rv-dist em { transform: scaleX(var(--w)); }
.rv-dist div:nth-child(2) em { transition-delay: .05s; } .rv-dist div:nth-child(3) em { transition-delay: .1s; }
.rv-dist div:nth-child(4) em { transition-delay: .15s; } .rv-dist div:nth-child(5) em { transition-delay: .2s; }
.rv-form { display: grid; gap: 10px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.rv-actions { display: flex; gap: 8px; justify-content: flex-end; }
.star-input { display: flex; align-items: center; gap: 2px; }
.star-input.nudge { animation: nudge .45s; }
@keyframes nudge { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.star-btn { position: relative; border: 0; background: none; padding: 2px 3px; font-size: 32px; line-height: 1; color: var(--line); transition: color .2s, transform .25s var(--spring); }
.star-btn:hover { transform: scale(1.25) rotate(-8deg); }
.star-btn.on { color: var(--amber); text-shadow: 0 0 14px color-mix(in srgb, var(--amber) 50%, transparent); }
.star-btn.pop { animation: starPop .55s var(--spring) var(--d, 0ms) both; }
.star-btn.pop::after { content: ''; position: absolute; inset: 50%; border-radius: 50%; box-shadow: 0 -18px 0 -2px var(--amber), 15px -9px 0 -2px var(--red), 15px 9px 0 -2px var(--amber), 0 18px 0 -2px var(--red), -15px 9px 0 -2px var(--amber), -15px -9px 0 -2px var(--red);
  animation: sparks .6s ease-out var(--d, 0ms) both; }
@keyframes starPop { 0% { transform: scale(.4); } 50% { transform: scale(1.45) rotate(14deg); } 100% { transform: scale(1); } }
@keyframes sparks { from { transform: scale(.2); } to { transform: scale(1.4); box-shadow: 0 -18px 0 -5px transparent, 15px -9px 0 -5px transparent, 15px 9px 0 -5px transparent, 0 18px 0 -5px transparent, -15px 9px 0 -5px transparent, -15px -9px 0 -5px transparent; } }
.rv-label { margin-left: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.rv-list { display: grid; gap: 14px; }
.rv-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 40ms); }
.rv-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 14px; }
.rv-top small { color: var(--ink-3); }
.rv-top .rv-mod { width: 30px; height: 30px; margin-left: auto; }
.rv-item p { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); white-space: pre-line; }
@media (max-width: 520px) { .rv-head { grid-template-columns: 1fr; } }

/* ================= Ruleta ================= */
.roulette { position: fixed; inset: 0; z-index: 48; display: grid; place-content: center; justify-items: center; gap: clamp(16px, 3vh, 28px);
  padding: 20px 0 calc(20px + env(safe-area-inset-bottom)); overflow: hidden; color: #fff;
  background: radial-gradient(circle at 50% 45%, #2a2418, #0c0b09 70%); }
.r-rays { position: absolute; inset: -50%; z-index: -1; opacity: .5;
  background: repeating-conic-gradient(from 0deg, rgba(246, 199, 90, .14) 0deg 9deg, transparent 9deg 18deg);
  animation: rays 40s linear infinite; mask: radial-gradient(circle, #000 10%, transparent 60%); }
.roulette.spinning .r-rays { animation-duration: 6s; }
.roulette.won .r-rays { animation-duration: 12s; opacity: .9; }
@keyframes rays { to { transform: rotate(360deg); } }
.r-top { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; display: flex; gap: 6px; }
.r-btn { color: #fff; background: rgba(255, 255, 255, .1); }
.r-btn:hover { background: rgba(255, 255, 255, .2); }
.r-title { font-size: clamp(30px, 6vw, 56px); text-align: center; padding: 0 16px;
  background: linear-gradient(90deg, #fff, #f6c75a, #fff, #f6c75a); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 3s linear infinite; }
.roulette.won .r-title { animation: shimmer 1.2s linear infinite, titlePop .7s var(--spring); }
@keyframes titlePop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } }
.reel { position: relative; width: min(94vw, 900px); padding: 22px 0; border-radius: 26px; overflow: hidden;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); box-shadow: inset 0 0 60px rgba(0, 0, 0, .6), 0 30px 80px rgba(0, 0, 0, .5);
  -webkit-mask: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); mask: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); }
.reel-strip { display: flex; gap: 14px; width: max-content; will-change: transform; }
.reel-item { flex: none; width: 128px; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; box-shadow: 0 8px 20px rgba(0, 0, 0, .5);
  transition: filter .5s, transform .6s var(--spring), box-shadow .6s; }
.reel-item .cover.gen { padding: 12px 10px 10px 16px; }
.reel-item .cover.gen .t { font-size: 14px; }
.reel-item .cover.gen .a { font-size: 9px; }
.roulette.won .reel-item:not(.winner) { filter: brightness(.3) saturate(.4); transform: scale(.9); }
.reel-item.winner { transform: scale(1.14); position: relative; z-index: 2;
  box-shadow: 0 0 0 3px #f6c75a, 0 0 40px 8px rgba(246, 199, 90, .55), 0 20px 40px rgba(0, 0, 0, .6); animation: winGlow 1.4s ease-in-out .6s infinite alternate; }
@keyframes winGlow { to { box-shadow: 0 0 0 3px #fff, 0 0 70px 16px rgba(246, 199, 90, .75), 0 20px 40px rgba(0, 0, 0, .6); } }
.pointer { position: absolute; left: 50%; z-index: 3; width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent; translate: -50% 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6)); }
.pointer.top { top: 2px; border-top: 18px solid #f6c75a; transform-origin: 50% 0; }
.pointer.bottom { bottom: 2px; border-bottom: 18px solid #f6c75a; }
.pointer.bump { animation: bump .16s ease-out; }
@keyframes bump { 50% { transform: rotate(-22deg) scale(1.15); } }
.reel-glow { position: absolute; top: 0; bottom: 0; left: 50%; width: 150px; translate: -50% 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(246, 199, 90, .14), transparent); }
.r-result { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 0 16px; min-height: 150px; }
.r-result > * { animation: rise .6s var(--spring) backwards; }
.r-result > :nth-child(2) { animation-delay: .08s; } .r-result > :nth-child(3) { animation-delay: .16s; } .r-result > :nth-child(4) { animation-delay: .26s; }
.r-result h3 { font-size: clamp(22px, 3.6vw, 32px); }
.r-result p { margin: 0; color: rgba(255, 255, 255, .75); }
.r-result .stars { color: rgba(255, 255, 255, .3); } .r-result .stars .s-fg { color: #f6c75a; }
.r-result .rate b { color: #fff; } .r-result .rate-none, .r-result .rate small { color: rgba(255, 255, 255, .6); }
.r-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.r-actions .btn-primary { background: linear-gradient(135deg, #f6c75a, #e0892f); color: #1d1b18; box-shadow: 0 10px 30px rgba(246, 199, 90, .35); animation: wantPulse 1.6s ease-in-out 1s infinite; }
@keyframes wantPulse { 50% { transform: scale(1.06); box-shadow: 0 14px 40px rgba(246, 199, 90, .55); } }
@media (max-width: 600px) { .reel-item { width: 100px; } .reel { padding: 16px 0; } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 70; }

/* ================= Transiciones conectadas (View Transitions API) ================= */
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: cubic-bezier(.3, 1.1, .4, 1); }
/* Por defecto la página no se funde: cambia al instante y solo se mueven los elementos con nombre */
::view-transition-old(root) { display: none; }
::view-transition-new(root) { animation: none; }
/* Elementos que aparecen o desaparecen: crecen o se encogen */
::view-transition-new(*):only-child { animation: vtIn .4s var(--ease) both; }
::view-transition-old(*):only-child { animation: vtOut .25s ease-in both; }
@keyframes vtIn { from { transform: scale(0); } }
@keyframes vtOut { to { transform: scale(0); } }

/* Cambio de sección: la página sale por un lado y entra por el otro */
.vt-route #view { view-transition-name: page; }
::view-transition-group(page) { animation: none; }
::view-transition-old(page) { animation: pageOutF .3s cubic-bezier(.5, 0, .9, .5) both; }
::view-transition-new(page) { animation: pageInF .55s var(--ease) .06s both; }
html[data-dir="back"]::view-transition-old(page) { animation-name: pageOutB; }
html[data-dir="back"]::view-transition-new(page) { animation-name: pageInB; }
@keyframes pageOutF { to { transform: translateX(-70px); clip-path: inset(0 100% 0 0); } }
@keyframes pageInF { from { transform: translateX(70px); clip-path: inset(0 0 0 100%); } }
@keyframes pageOutB { to { transform: translateX(70px); clip-path: inset(0 0 0 100%); } }
@keyframes pageInB { from { transform: translateX(-70px); clip-path: inset(0 100% 0 0); } }

/* Filtros y búsqueda: cada tarjeta viaja a su nueva posición */
.vt-cards .book, .vt-cards .req { view-transition-name: var(--vt); view-transition-class: card; }
::view-transition-group(*.card) { animation-duration: .55s; }
::view-transition-new(*.card):only-child { animation: cardIn .45s var(--ease) both; }
::view-transition-old(*.card):only-child { animation: cardOut .3s ease-in both; }
@keyframes cardIn { from { transform: scale(.5); clip-path: inset(40% round 16px); } }
@keyframes cardOut { to { transform: scale(.5); clip-path: inset(40% round 16px); } }

/* Ventanas que nacen del botón o tarjeta pulsados y vuelven a él al cerrarse */
::view-transition-group(morph) { animation-duration: .55s; animation-timing-function: cubic-bezier(.3, 1.15, .4, 1); }
::view-transition-image-pair(morph) { overflow: clip; border-radius: 18px; }
.vt-open::view-transition-old(morph) { animation: none; visibility: hidden; }
.vt-open::view-transition-new(morph) { animation: none; width: 100%; height: 100%; object-fit: none; object-position: 50% 0; }
.vt-close::view-transition-new(morph) { animation: none; visibility: hidden; }
.vt-close::view-transition-old(morph) { animation: none; width: 100%; height: 100%; object-fit: none; object-position: 50% 0; }
::view-transition-group(cover) { animation-duration: .55s; z-index: 2; }
.vt-open::view-transition-new(backdrop):only-child { animation: dimIn .4s ease both; }
.vt-close::view-transition-old(backdrop):only-child { animation: dimIn .3s ease reverse both; }
@keyframes dimIn { from { opacity: 0; } }

/* Entrar / salir de la sesión: la pantalla se desliza como una persiana */
.vt-login::view-transition-old(root) { display: block; animation: loginOut .5s cubic-bezier(.7, 0, .3, 1) both; }
.vt-login::view-transition-new(root) { animation: loginIn .6s cubic-bezier(.7, 0, .3, 1) both; }
@keyframes loginOut { to { transform: translateY(-40px) scale(.97); } }
@keyframes loginIn { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Cambio de tema: el nuevo color se expande en círculo */
.vt-theme::view-transition-old(root) { display: block; animation: none; }
.vt-theme::view-transition-new(root) { animation: themeIn .7s var(--ease) both; }
@keyframes themeIn { from { clip-path: circle(0 at 100% 0); } to { clip-path: circle(150% at 100% 0); } }

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