/* Shared visual contract for the mobile-first editorial interface. */
:root {
  --ds-ivory: #f7f5ef;
  --ds-paper: #fffaf5;
  --ds-white: #ffffff;
  --ds-ink: #24312b;
  --ds-muted: #5f6862;
  --ds-terracotta: #a36b42;
  /* Compatibility alias: one canonical terracotta for all shared surfaces. */
  --accent: var(--ds-terracotta);
  --ds-gold: #d29c2e;
  --ds-beige: #ead9c8;
  --ds-line: #e9e5dc;
  --ds-success: #356b4a;
  --ds-danger: #963f35;
  --ds-radius-sm: 12px;
  --ds-radius-md: 16px;
  --ds-radius-lg: 24px;
  --ds-shadow-card: 0 10px 26px rgb(75 56 33 / 6%);
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-touch: 44px;
}
html, body { overflow-x: hidden; }

@media (max-width: 480px) {
  main:has(.saga-detail-hero):not(:has([data-saga-theme="riverton"])) .saga-detail-hero { background-image: none; }
  main:has(.saga-detail-hero):not(:has([data-saga-theme="riverton"])) .saga-detail-hero::after,
  main:has(.saga-detail-hero):not(:has([data-saga-theme="riverton"])) .saga-detail-hero__stack::after { display: none; }
  main:has(.saga-detail-hero) .saga-volume { min-height: 112px; }
}

@media (min-width: 700px) {
  main:has(.saga-detail-hero):not(:has([data-saga-theme="riverton"])) .saga-detail-hero { background-image: none !important; }
  main:has(.saga-detail-hero):not(:has([data-saga-theme="riverton"])) .saga-detail-hero::after,
  main:has(.saga-detail-hero):not(:has([data-saga-theme="riverton"])) .saga-detail-hero__stack::after { display: none; }
  body:has(.profile-hero) .profile-hero h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(3.4rem, 6vw, 5.2rem);
    font-weight: 400;
    letter-spacing: -.045em;
  }
  body:has(.home-summary) main > h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(3.8rem, 7vw, 5.8rem);
    font-weight: 400;
    letter-spacing: -.045em;
  }
  body:has(.home-summary) main > h1 br { display: none; }
  body:has(.home-summary) .home-active-reading {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 38px;
    align-items: center;
    padding: 24px;
  }
  body:has(.home-summary) .home-active-reading .book-icon {
    width: 300px;
    height: 450px;
    flex-basis: 300px;
  }
  body:has(.home-summary) .home-active-reading h2 {
    font: 400 2.45rem/1.08 Georgia, 'Times New Roman', serif;
  }
  body:has(.home-summary) .home-active-reading .button {
    min-height: 72px;
    margin-top: 26px;
    font: 1.2rem Georgia, 'Times New Roman', serif;
  }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card > span {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--ds-beige);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 34px 34px;
    font-size: 0;
  }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/mi-biblioteca/"] > span { background-image: url('/static/images/raster-reference/icons/book-open.png'); }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/comunidad-hub/"] > span { background-image: url('/static/images/raster-reference/icons/members.png'); }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/participar/"] > span { background-image: url('/static/images/raster-reference/icons/pencil.png'); }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/dinamicas/"] > span { background-image: url('/static/images/raster-reference/icons/trophy.png'); }
  body:has(.library-summary) main > h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(3.8rem, 7vw, 5.8rem);
    font-weight: 400;
    letter-spacing: -.045em;
  }
  body:has(.library-summary) main > h1 + p { display: none; }
  body:has(.library-summary) .library-summary { display: none; }
  body:has(.library-summary) .library-tabs { margin-top: 26px; }
  body:has(.library-summary) .ds-reading-card {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 30px;
    align-items: start;
    padding: 24px;
  }
  body:has(.library-summary) .ds-reading-card .book-icon {
    width: 190px;
    height: 285px;
    flex-basis: 190px;
  }
  body:has(.library-summary) .ds-reading-card h3,
  body:has(.library-summary) .ds-reading-card h3 a {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2rem;
    font-weight: 400;
    line-height: 1.1;
  }
  main:has(.library-summary) { max-width: 850px; }
  body:has(.library-summary) .bottom-nav { width: 850px; }
  main:has(.saga-detail-hero) { max-width: 850px; }
  body:has(.saga-detail-hero) .bottom-nav { width: 850px; }
}

/* Administrative activity keeps the icon language raster-based. */
.audit-icon {
  font-size: 0 !important;
  background-image: url('/static/images/raster-reference/icons/activity.png') !important;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 1.25rem;
}

.notification-heading .graphic-icon img {
  content: url('/static/images/raster-reference/icons/bell.png');
}

.graphic-icon--ranking img { content: url('/static/images/raster-reference/icons/ranking.png'); }
.graphic-icon--survey img { content: url('/static/images/raster-reference/icons/survey.png'); }
.graphic-icon--camera img { content: url('/static/images/raster-reference/icons/camera.png'); }

main:has(.club-summary) .book-content .activity-icon {
  font-size: 0 !important;
  background: var(--ds-beige) !important;
}
main:has(.club-summary) .book-content .activity-icon::before {
  width: 2.5rem;
  height: 2.5rem;
  background: url('/static/images/raster-reference/icons/book-open.png') center / contain no-repeat;
}

@media (max-width: 699px) {
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card > span {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--ds-beige);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 26px 26px;
    font-size: 0;
  }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/mi-biblioteca/"] > span { background-image: url('/static/images/raster-reference/icons/book-open.png'); }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/comunidad-hub/"] > span { background-image: url('/static/images/raster-reference/icons/members.png'); }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/participar/"] > span { background-image: url('/static/images/raster-reference/icons/pencil.png'); }
  body:has(.home-summary) > main > .hub-grid:first-of-type .hub-card[href="/dinamicas/"] > span { background-image: url('/static/images/raster-reference/icons/trophy.png'); }
}

.ds-card { background: var(--ds-white); border: 1px solid var(--ds-line); border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-card); padding: var(--ds-space-6); }
.book-icon { aspect-ratio: 2 / 3; contain: layout paint; }
.book-icon:not(.has-cover-image), .saga-stack__cover:not(.has-cover-image) { color: transparent; text-shadow: none; }
.saga-stack__cover:not(.has-cover-image), .saga-volume .book-icon:not(.has-cover-image) { background: var(--ds-paper) url('/static/images/icons/book.svg') center / 42% auto no-repeat; }
.has-cover-image { background-position: center; background-repeat: no-repeat; background-size: cover; }
.community-featured, .community-recent { display: grid; gap: var(--ds-space-3); margin: var(--ds-space-5) 0; border-color: var(--ds-beige); background: var(--ds-paper); }
.community-featured::before { display: block; height: 150px; margin: calc(var(--ds-space-5) * -1) calc(var(--ds-space-5) * -1) 0; border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0; background: linear-gradient(180deg, rgb(247 245 239 / 10%), rgb(247 245 239 / 22%)), url('/static/images/library-cover-art.png') center 42% / cover; content: ""; }
.community-featured h2, .community-featured p, .community-recent p { margin: 0; }
.community-reading { display: grid; gap: 3px; padding-top: var(--ds-space-3); border-top: 1px solid var(--ds-beige); }
.community-reading strong, .community-recent .eyebrow { color: var(--ds-terracotta); }
.community-reading span { font-weight: 800; }
.community-reading small, .community-recent small { color: var(--ds-muted); }
.community-featured .button { width: 100%; text-align: center; }
.community-tabs { display: flex; gap: var(--ds-space-5); margin: var(--ds-space-5) 0 var(--ds-space-3); border-bottom: 1px solid var(--ds-beige); }
.community-tabs a { padding: 10px 4px; color: var(--ds-muted); font-weight: 750; text-decoration: none; }
.community-tabs a.is-active { border-bottom: 3px solid var(--ds-terracotta); color: var(--ds-terracotta); }
@media (max-width: 600px) { .community-tabs { overflow-x: auto; scrollbar-width: none; white-space: nowrap; scroll-snap-type: x proximity; scroll-padding-inline: var(--ds-space-3); } .community-tabs::-webkit-scrollbar { display: none; } .community-tabs a { flex: 0 0 auto; min-height: var(--ds-touch); scroll-snap-align: start; } }
.community-search { display: flex; gap: var(--ds-space-2); align-items: center; margin-bottom: var(--ds-space-4); padding: 8px 12px; border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-md); background: var(--ds-white); }
.community-search input { min-width: 0; flex: 1; border: 0; background: transparent; }
.community-search button { min-width: var(--ds-touch); min-height: var(--ds-touch); margin: 0; padding: 0; }
.participate-catalog { grid-template-columns: 1fr; gap: 10px; }
.participate-catalog .hub-card { display: grid; grid-template-columns: 48px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: var(--ds-space-3); align-items: center; min-height: 76px; padding: 14px 16px; border-color: var(--ds-beige); }
.participate-catalog .hub-card .graphic-icon { grid-row: 1 / span 2; }
.participate-catalog .hub-card strong, .participate-catalog .hub-card small { margin: 0; }
.participate-featured { display: grid; gap: var(--ds-space-3); margin: var(--ds-space-5) 0; border-color: var(--ds-beige); background: var(--ds-paper); }
.participate-featured h2, .participate-featured p { margin: 0; }
.participate-featured .button { width: 100%; text-align: center; }
.activity-family-title { margin: var(--ds-space-6) 0 var(--ds-space-2); color: var(--ds-ink); font-size: 1.25rem; }
.participate-catalog .activity-family-title { grid-column: 1; }
.notification-tabs { display: grid; grid-template-columns: 1fr 1fr; margin: var(--ds-space-5) 0; padding: 4px; border-radius: 999px; background: var(--ds-paper); }
.notification-tabs a { min-height: var(--ds-touch); display: grid; place-items: center; border-radius: 999px; color: var(--ds-muted); font-weight: 750; text-decoration: none; }
.notification-tabs a.is-active { background: var(--ds-terracotta); color: var(--ds-white); }
.notification-tabs span { margin-left: 4px; font-size: .75rem; }
.notification-card { margin: var(--ds-space-3) 0; padding: var(--ds-space-4); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-md); background: var(--ds-paper); }
.notification-card--unread { border-left: 4px solid var(--ds-terracotta); }
.notification-card--read { opacity: .82; }
.notification-card:focus-within { border-color: var(--ds-terracotta); box-shadow: 0 0 0 3px rgb(163 107 66 / 18%), var(--ds-shadow-card); }
@media (max-width: 480px) { .notification-card form.inline-form { display: block; margin-top: var(--ds-space-2); } .notification-card form.inline-form .button, .notification-card form.inline-form button { width: 100%; min-height: var(--ds-touch); margin: 0; } .notification-card > p:last-child { display: grid; gap: var(--ds-space-2); } }
.profile-hero { position: relative; margin: 0 calc(var(--ds-space-4) * -1) var(--ds-space-5); padding: var(--ds-space-5) var(--ds-space-4); border-bottom: 1px solid var(--ds-beige); background: linear-gradient(180deg, rgb(255 250 245 / 20%), rgb(234 217 200 / 36%)), url('/static/images/library-cover-art.png') center 70% / cover; }
@media (max-width: 480px) { main:has(.profile-hero) { display: flex; flex-direction: column; } main:has(.profile-hero) > * { order: 10; } main:has(.profile-hero) > .eyebrow { order: 1; } main:has(.profile-hero) > .profile-hero { order: 2; } main:has(.profile-hero) > .profile-summary { order: 3; } main:has(.profile-hero) > .metrics { order: 4; } main:has(.profile-hero) > .profile-achievements-cta { order: 5; } main:has(.profile-hero) > .avatar-editor { order: 6; } main:has(.profile-hero) > .admin-profile-link { order: 99; } }
.profile-hero h1 { margin: 0; }
main:has(.club-summary) > section .book-content { margin: var(--ds-space-3) 0; padding: var(--ds-space-4); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-md); background: var(--ds-white); box-shadow: var(--ds-shadow-card); }
main:has(.club-summary) > section .book-content .activity-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 8px; border-radius: 14px; background: var(--ds-beige); font-size: 1.5rem; }
@media (max-width: 480px) { main:has(.club-summary) > section .book-content { margin-block: 12px; padding: 14px; } main:has(.club-summary) > section .book-content .button, main:has(.club-summary) > section .book-content form button { width: 100%; } }
.profile-hero .avatar-large { box-shadow: 0 0 0 4px var(--ds-white), 0 0 0 6px var(--ds-beige); }
.profile-summary { border-width: 2px; }
.metrics section { min-height: 86px; }
.profile-achievements-cta { display: block; width: 100%; margin: var(--ds-space-4) 0; text-align: center; }
.management-pending { display: grid; gap: var(--ds-space-2); margin: var(--ds-space-5) 0; border-color: var(--ds-gold); background: linear-gradient(145deg, #fff9df, var(--ds-white)); }
.management-pending h2, .management-pending p { margin: 0; }
.management-pending > strong { color: var(--ds-gold); font-size: 2.5rem; }
.management-pending .button { width: 100%; text-align: center; }
.management-pending-list { display: grid; gap: .55rem; margin: .35rem 0 .5rem; }
.management-pending-row { display: grid; grid-template-columns: 2rem minmax(0,1fr) auto; gap: .65rem; align-items: center; padding: .75rem; color: var(--ds-ink); background: rgba(255,255,255,.72); border: 1px solid rgba(163,107,66,.18); border-radius: .8rem; text-decoration: none; }
.management-pending-row:hover, .management-pending-row:focus-visible { border-color: var(--ds-terracotta); }
.management-pending-row b, .management-pending-row small { display: block; }
.management-pending-row b { font-size: .9rem; }
.management-pending-row small { margin-top: .15rem; color: var(--ds-muted); font-size: .72rem; }
.management-pending-row em { min-width: 1.7rem; padding: .25rem .4rem; color: var(--ds-ink); background: #f5e3ad; border-radius: 999px; font-style: normal; font-weight: 800; text-align: center; }
.management-pending-icon { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--ds-terracotta); background: #f8eadf; border-radius: 50%; }
.management-pending-icon img { width: 1.25rem; height: 1.25rem; object-fit: contain; }
.management-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 480px) { .management-actions { grid-template-columns: 1fr; } }
.home-active-reading { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: var(--ds-space-4); align-items: center; margin: var(--ds-space-5) 0; border-color: var(--ds-beige); background: var(--ds-paper); }
.home-active-reading .book-icon { width: 92px; height: 132px; }
.home-active-reading h2, .home-active-reading p { margin: 4px 0; }
.home-active-reading .button { width: 100%; margin-top: var(--ds-space-3); text-align: center; }
main:has(.home-active-reading) > section[aria-label="Lectura activa"]:not(.home-active-reading) { display: none; }
.ds-reading-card { border-color: var(--ds-beige); box-shadow: var(--ds-shadow-card); }
.ds-reading-card .ds-progress { margin: var(--ds-space-3) 0; }
.ds-reading-card .ds-progress .split { align-items: baseline; }
.ds-catalog-card { border-color: var(--ds-line); }
.ds-catalog-card .book-content { min-width: 0; }
.ds-catalog-card .action-row { margin-top: var(--ds-space-3); }
.saga-card { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--ds-space-4); align-items: start; }
.saga-featured { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--ds-space-5); align-items: center; margin: var(--ds-space-5) 0; padding: var(--ds-space-5); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-lg); background: var(--ds-paper); box-shadow: var(--ds-shadow-card); }
.saga-featured__stack { position: relative; min-height: 170px; }
.saga-featured__stack .saga-stack__cover { width: 92px; height: 132px; }
.saga-featured__stack .saga-stack__cover--1 { inset: 18px auto auto 0; }
.saga-featured__stack .saga-stack__cover--2 { inset: 8px auto auto 24px; }
.saga-featured__stack .saga-stack__cover--3 { inset: 20px auto auto 48px; }
.saga-featured__content h2 { margin: 4px 0 8px; }
.saga-featured__content h2 a { color: var(--ds-ink); text-decoration: none; }
.saga-featured__content > p { margin: 0 0 8px; color: var(--ds-muted); }
.saga-featured__content > .button { background: var(--ds-terracotta); border-color: var(--ds-terracotta); color: var(--ds-white); width: 100%; text-align: center; }
.saga-progress-bar { height: 8px; overflow: hidden; margin-bottom: var(--ds-space-4); border-radius: 999px; background: var(--ds-beige); }
.saga-progress-bar i { display: block; height: 100%; background: var(--ds-gold); }
.book-detail-hero { position: relative; z-index: 1; border-color: var(--ds-beige); box-shadow: var(--ds-shadow-card); }
.book-detail-hero .book-detail-cover { box-shadow: 4px 12px 20px rgb(36 49 43 / 24%); }
.saga-stack { position: relative; width: 72px; min-height: 104px; }
.saga-stack__cover { position: absolute; display: grid; place-items: end center; width: 54px; height: 78px; padding: 6px; overflow: hidden; border: 1px solid rgb(75 56 33 / 18%); border-radius: 5px; background: linear-gradient(145deg, #b6754e, #6f3d2a); color: #fff3d0; font: 1.2rem Georgia, serif; box-shadow: 2px 5px 9px rgb(36 49 43 / 18%); }
.saga-stack__cover.has-cover-image { background-position: center; background-repeat: no-repeat; background-size: cover; }
.saga-stack__cover > img { width: 34px; height: 34px; opacity: .78; }
.saga-detail-hero { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 20px; align-items: center; margin: 18px 0 20px; padding: 22px 18px; min-height: 248px; border-radius: var(--ds-radius-lg); background: linear-gradient(90deg, rgb(36 49 43 / 66%), rgb(36 49 43 / 12%) 52%, rgb(255 250 240 / 92%)), url('/static/images/saga-detail-editorial.png') center / cover; overflow: hidden; }
.saga-detail-hero__stack { position: relative; min-height: 170px; }
.saga-detail-hero__stack .saga-stack__cover { width: 92px; height: 132px; }
.saga-detail-hero__stack .saga-stack__cover--1 { inset: 20px auto auto 0; }
.saga-detail-hero__stack .saga-stack__cover--2 { inset: 8px auto auto 28px; }
.saga-detail-hero__stack .saga-stack__cover--3 { inset: 20px auto auto 56px; }
.saga-detail-hero__copy { padding: 16px 12px; border-radius: var(--ds-radius-md); background: rgb(255 250 240 / 88%); box-shadow: 0 8px 24px rgb(36 49 43 / 12%); }
.saga-detail-hero__copy h2 { margin: 6px 0 8px; color: var(--ds-ink); font-family: Georgia, serif; font-size: clamp(1.6rem, 6vw, 2.5rem); line-height: 1.02; }
.saga-detail-hero__copy p { margin: 0 0 12px; color: var(--ds-muted); }
.saga-detail-hero__copy strong { color: var(--ds-gold); font: 700 1.2rem Georgia, serif; }
main:has(.saga-detail-hero) > .eyebrow, main:has(.saga-detail-hero) > h1 { display: none; }
main:has(.saga-detail-hero) > h1 + p { display: none; }
main:has(.saga-detail-hero) > .saga-detail-hero ~ .action-row .button { background: var(--ds-terracotta); border-color: var(--ds-terracotta); color: var(--ds-white); }
@media (max-width: 480px) { .saga-detail-hero { grid-template-columns: 108px minmax(0, 1fr); gap: 8px; margin-inline: -4px; padding: 14px 10px; min-height: 232px; background: linear-gradient(90deg, rgb(36 49 43 / 74%), rgb(36 49 43 / 18%) 48%, rgb(255 250 240 / 94%)), url('/static/images/saga-detail-editorial.png') center / cover; } .saga-detail-hero__stack { min-height: 170px; transform: scale(.92); transform-origin: left center; width: 112px; } .saga-detail-hero__copy { padding: 12px 10px; } .saga-detail-hero__copy h2 { font-size: 1.48rem; } .saga-detail-hero__copy p { font-size: .85rem; } }
@media (max-width: 340px) { .saga-detail-hero { grid-template-columns: 86px minmax(0, 1fr); gap: 6px; padding-inline: 8px; } .saga-detail-hero__stack { transform: scale(.74); width: 92px; } .saga-detail-hero__copy h2 { font-size: 1.28rem; overflow-wrap: anywhere; } .saga-detail-hero__copy p { font-size: .78rem; } .saga-detail-hero__copy strong { font-size: 1rem; } }
.saga-stack__cover--1 { z-index: 3; inset: 8px auto auto 0; transform: rotate(-7deg); }
.saga-stack__cover--2 { z-index: 2; inset: 2px auto auto 13px; background: linear-gradient(145deg, #d29c2e, #9b642b); transform: rotate(3deg); }
.saga-stack__cover--3 { z-index: 1; inset: 10px auto auto 25px; background: linear-gradient(145deg, #49675a, #24312b); transform: rotate(10deg); }
.saga-volume { display: grid; grid-template-columns: 32px 58px minmax(0, 1fr); gap: var(--ds-space-3); align-items: start; }
.saga-volume__number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ds-beige); color: var(--ds-ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.saga-volume .book-icon { width: 58px; height: 84px; flex: 0 0 58px; font-size: 1.25rem; }
.saga-volume .book-content h3 { margin-top: 0; }
.saga-volume .action-row { margin-top: var(--ds-space-3); }
@media (max-width: 480px) { .saga-volume { grid-template-columns: 34px 64px minmax(0, 1fr); gap: var(--ds-space-2); padding: 14px 10px; border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-md); background: var(--ds-white); } .saga-volume .book-icon { width: 64px; height: 92px; flex-basis: 64px; } .saga-volume__number { width: 34px; height: 34px; } .saga-volume .book-content h3 { font-size: 1rem; line-height: 1.15; } .saga-volume .action-row { grid-column: 3; display: grid; gap: var(--ds-space-2); } .saga-volume .action-row .button { width: 100%; margin: 0; text-align: center; } .saga-volume:has(.status-locked) { border-style: dashed; background: var(--ds-paper); opacity: .82; } }
.saga-progress-dots { display: flex; gap: var(--ds-space-2); overflow-x: auto; margin: var(--ds-space-3) 0; padding: 0 0 var(--ds-space-1); list-style: none; }
.saga-progress-dots li { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; border: 1px solid var(--ds-beige); border-radius: 50%; background: var(--ds-paper); color: var(--ds-muted); font-size: .75rem; font-weight: 800; }
.saga-progress-dots li.is-added { border-color: var(--ds-gold); color: #755016; }
.saga-progress-dots li.is-reading { border-color: var(--ds-terracotta); background: var(--ds-terracotta); color: var(--ds-white); }
.saga-progress-dots li.is-done { border-color: var(--ds-success); background: var(--ds-success); color: var(--ds-white); }
.status-abandoned { border-color: var(--ds-gold); background: #fff8df; color: #755016; }
.cover-fallback img { width: 42px; height: 42px; opacity: .72; }
.library-search { padding: var(--ds-space-5); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-lg); background: var(--ds-paper); box-shadow: var(--ds-shadow-card); }
.library-search button { width: 100%; }
.library-summary { position: relative; }
@media (max-width: 480px) { main:has(.library-summary) { display: flex; flex-direction: column; } main:has(.library-summary) .library-tabs { order: 1; } main:has(.library-summary) .library-section { order: 2; } main:has(.library-summary) .library-pagination { order: 3; } main:has(.library-summary) .library-summary { order: 4; } }
main:has(.library-summary)::before, main:has(.saga-card)::before { display: block; height: 118px; margin: -20px -22px 8px; border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg); background: linear-gradient(180deg, rgb(247 245 239 / 12%), rgb(247 245 239 / 30%)), url('/static/images/library-cover-art.png') center 42% / cover; content: ""; }
main:has(.library-summary)::before { background-image: linear-gradient(180deg, rgb(247 245 239 / 12%), rgb(247 245 239 / 30%)), url('/static/images/library-header-editorial.webp'); background-position: center 48%; }
main:has(.ds-catalog-card)::before { background-image: linear-gradient(180deg, rgb(247 245 239 / 12%), rgb(247 245 239 / 30%)), url('/static/images/library-discover-editorial.webp'); background-position: center 48%; }
@media (max-width: 480px) {
  body:has(.ds-catalog-card) .ds-catalog-card { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; align-items: start; padding: 16px 0; border-bottom: 1px solid var(--ds-beige); }
  body:has(.ds-catalog-card) .ds-catalog-card .book-icon { width: 120px; height: 180px; border-radius: 10px; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content { min-width: 0; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content h3 { font: 700 1.22rem/1.12 Georgia, serif; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content .split { display: block; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content .split h3 { min-width: 0; overflow-wrap: normal; word-break: normal; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content .split .tag { display: inline-block; margin-top: 8px; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content p { margin: 6px 0; overflow-wrap: anywhere; }
  body:has(.ds-catalog-card) .ds-catalog-card .action-row { display: grid; gap: 8px; margin-top: 12px; }
  body:has(.ds-catalog-card) .ds-catalog-card .action-row form,
  body:has(.ds-catalog-card) .ds-catalog-card .action-row button { width: 100%; }
  body:has(.ds-catalog-card) .ds-catalog-card .action-row button { min-height: 52px; padding-inline: 10px; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content { display: flex; flex-direction: column; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > .split { order: 1; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > .action-row { order: 2; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > p,
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > .notice,
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > a { order: 3; }
  /* Keep the primary catalog action in the first mobile fold. Secondary
     community counters and long synopses remain available on the detail page. */
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > p.social-signal:last-of-type,
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > p:not(.social-signal):has(+ .action-row) { display: none; }
  body:has(.ds-catalog-card) .ds-catalog-card .book-content > .action-row { margin-top: 10px; }
  body:has(.library-summary) .bottom-nav, body:has(.saga-card) .bottom-nav, body:has(.book-detail-hero) .bottom-nav, body:has(.saga-detail-hero) .bottom-nav, body:has(.library-empty-hero) .bottom-nav { min-height: 84px; padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  body:has(.library-summary) .bottom-nav a, body:has(.saga-card) .bottom-nav a, body:has(.book-detail-hero) .bottom-nav a, body:has(.saga-detail-hero) .bottom-nav a, body:has(.library-empty-hero) .bottom-nav a { min-height: 52px; }
  body:has(.library-summary) .context-strip,
  body:has(.saga-card) .context-strip,
  body:has(.book-detail-hero) .context-strip,
  body:has(.saga-detail-hero) .context-strip { display: none; }
  body:has(.library-empty-hero) .context-strip { display: none; }
}
main:has(.home-active-reading) > section[aria-label="Lectura activa"] { display: none; }
.home-annual-summary { margin-top: var(--ds-space-5); }
.home-annual-summary .section-heading > span { color: var(--ds-gold); font-size: 1.5rem; }
.home-annual-summary__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.home-annual-summary__stats div { display: grid; gap: 4px; padding: 8px 4px; border-right: 1px solid var(--ds-beige); }
.home-annual-summary__stats div:last-child { border-right: 0; }
.home-annual-summary__stats strong { color: var(--ds-terracotta); font: 700 1.65rem Georgia, serif; }
.home-annual-summary__stats span { color: var(--ds-muted); font-size: .72rem; line-height: 1.2; }
.home-annual-summary > p { margin: 14px 0 0; }
main:has(.book-detail-hero)::before { display: block; height: 118px; margin: -20px -22px -84px; border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg); background: linear-gradient(180deg, rgb(247 245 239 / 15%), rgb(247 245 239 / 42%)), url('/static/images/book-detail-editorial.webp') center 38% / cover; content: ""; }
.library-summary::before { content: none; }
main:has(.hub-grid)::before { display: block; height: 104px; margin: -20px -22px 8px; border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg); background: linear-gradient(180deg, rgb(247 245 239 / 22%), rgb(247 245 239 / 40%)), url('/static/images/library-cover-art.png') 68% 32% / cover; content: ""; }
main:has(.home-summary)::before { background-image: linear-gradient(180deg, rgb(247 245 239 / 18%), rgb(247 245 239 / 42%)), url('/static/images/library-home-editorial.png'); background-position: center 70%; }
main:has(.activity-icon)::before, main:has(.challenge-card)::before { display: block; height: 96px; margin: -20px -22px 8px; border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg); background: linear-gradient(180deg, rgb(247 245 239 / 24%), rgb(247 245 239 / 44%)), url('/static/images/library-cover-art.png') 36% 68% / cover; content: ""; }
main:has(.participate-catalog)::before { display: block; height: 104px; margin: -20px -22px 8px; border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg); background: linear-gradient(180deg, rgb(247 245 239 / 18%), rgb(247 245 239 / 40%)), url('/static/images/library-cover-art.png') 82% 44% / cover; content: ""; }
.library-filter-trigger, .library-filter-backdrop { display: none; }
.library-filter-chips { display: flex; gap: var(--ds-space-2); overflow-x: auto; margin-top: var(--ds-space-3); scrollbar-width: none; }
.library-filter-chips::-webkit-scrollbar { display: none; }
.library-filter-chip { flex: 0 0 auto; padding: 6px 10px; border: 1px solid var(--ds-beige); border-radius: 999px; background: var(--ds-paper); color: var(--ds-ink); font-size: .78rem; }
.library-format-filters { display: flex; flex-wrap: wrap; gap: var(--ds-space-2); }
.library-format-filters legend { width: 100%; }
.library-format-filters label { display: inline-flex; align-items: center; min-height: var(--ds-touch); padding: 8px 14px; border: 1px solid var(--ds-beige); border-radius: 999px; background: var(--ds-white); color: var(--ds-ink); }
.library-format-filters label:has(input:checked) { border-color: var(--ds-terracotta); background: #fff7ef; color: var(--ds-terracotta); font-weight: 750; }
.library-format-filters input { accent-color: var(--ds-terracotta); }
.profile-summary, .ranking-mode, .points-guide { border: 1px solid var(--ds-beige); background: var(--ds-paper); box-shadow: var(--ds-shadow-card); }
.metrics section { border: 1px solid var(--ds-line); background: var(--ds-white); box-shadow: none; }
.profile-links { background: transparent; box-shadow: none; padding: 0; }
.profile-link { min-height: var(--ds-touch); border-color: var(--ds-line); background: var(--ds-white); }
.ranking section { border: 1px solid var(--ds-line); background: var(--ds-white); box-shadow: none; }
.ranking section.current { border-color: var(--ds-terracotta); box-shadow: 0 0 0 2px rgb(163 107 66 / 12%); }
.badge-card { border: 1px solid var(--ds-line); background: var(--ds-white); box-shadow: none; }
.badge-card.locked { background: var(--ds-paper); }
.wallet { border: 1px solid var(--ds-beige); background: var(--ds-paper); box-shadow: var(--ds-shadow-card); }
.wallet-history { display: grid; gap: var(--ds-space-3); }
.wallet-entry { border-color: var(--ds-line); background: var(--ds-white); box-shadow: none; }
.home-summary { border: 2px solid var(--ds-beige); }
.home-summary + h2 { margin-top: var(--ds-space-6); }
.home-summary .wallet-balance { color: var(--ds-terracotta); }
main:has(.home-summary) .hub-grid { margin-top: var(--ds-space-4); }
main:has(.home-summary) .hub-card { min-height: 132px; border: 1px solid var(--ds-line); box-shadow: none; }
main:has(.home-summary) .hub-card.primary-hub { border: 2px solid var(--ds-beige); }
@media (max-width: 480px) { main:has(.home-summary) .hub-grid { gap: 10px; } main:has(.home-summary) .hub-card { min-height: 128px; padding: 16px 14px; } main:has(.home-summary) .hub-card span { font-size: 1.8rem; } main:has(.home-summary) .hub-card strong { font-size: 1rem; } main:has(.home-summary) .hub-card small { font-size: .78rem; line-height: 1.25; } }
main:has(.home-summary) > .button:last-child { width: 100%; text-align: center; }
main:has(.home-summary) section[aria-label="Lectura activa"] { border: 2px solid var(--ds-beige); background: var(--ds-paper); }

/* Community: the same quiet editorial hierarchy as Library and Profile. */
.club-card, .club-summary, .member-card, main:has(.club-summary) > section,
main:has(.person-line) > section {
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-md);
  background: var(--ds-white);
  box-shadow: none;
}
.club-card, .club-summary { box-shadow: var(--ds-shadow-card); }
.club-card .button, .club-summary .button, .member-card { min-height: var(--ds-touch); }
.club-card .meta, .club-summary .meta { color: var(--ds-muted); }
.member-card { display: flex; gap: var(--ds-space-3); padding: var(--ds-space-4); }
.member-card:hover, .member-card:focus-within { border-color: var(--ds-terracotta); }
main:has(.club-summary) > section + section { margin-top: var(--ds-space-5); }
main:has(.club-summary) .book-content { border-color: var(--ds-line); }
.person-line { gap: var(--ds-space-3); }

/* Participate: one catalogue language for activities, rewards and empty states. */
main:has(.challenge-card) > section,
main:has(.activity-icon) > section,
main:has(.crossword-result-hero) > section,
.challenge-card {
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-md);
  background: var(--ds-white);
  box-shadow: none;
}
main:has(.activity-card) .activity-card { position: relative; display: grid; gap: var(--ds-space-3); padding: var(--ds-space-5); border: 1px solid var(--ds-line); border-radius: var(--ds-radius-lg); background: var(--ds-white); box-shadow: var(--ds-shadow-card); }
main:has(.activity-card) .activity-card + .activity-card { margin-top: var(--ds-space-4); }
main:has(.activity-card) .activity-card .activity-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: var(--ds-beige); }
main:has(.activity-card) .activity-card .activity-icon img { width: 42px; height: 42px; }
main:has(.activity-card) .activity-card h2 { margin: 0; font-size: 1.35rem; }
main:has(.activity-card) .activity-card .meta { display: flex; gap: var(--ds-space-2); }
main:has(.activity-card) .activity-card .meta span { border: 1px solid var(--ds-line); background: var(--ds-paper); }
main:has(.activity-card) .activity-card > .button { width: 100%; margin-top: 0; text-align: center; }
main:has(.challenge-card) > section,
main:has(.activity-icon) > section { padding: var(--ds-space-4); }
.challenge-card { display: block; padding: var(--ds-space-4); margin-block: var(--ds-space-3); color: inherit; }
.challenge-card:hover, .challenge-card:focus-within { border-color: var(--ds-terracotta); }
main:has(.activity-icon) > section .button,
main:has(.challenge-card) > section .button { min-height: var(--ds-touch); }
.crossword-result-hero { border: 2px solid var(--ds-beige); background: var(--ds-paper); }
.result-hero { display: grid; justify-items: center; gap: var(--ds-space-2); margin-block: var(--ds-space-5); padding: var(--ds-space-6); border: 2px solid var(--ds-gold); background: linear-gradient(145deg, #fff9df, var(--ds-white)); text-align: center; }
.result-hero__icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--ds-beige); }
.result-hero__icon .graphic-icon, .result-hero__icon img { display: block; width: 54px; height: 54px; }
.result-hero > strong { color: var(--ds-terracotta); font-size: 2.8rem; line-height: 1; }
.result-hero > span:last-child { color: var(--ds-muted); }
@media (max-width: 480px) { .result-hero { gap: var(--ds-space-3); margin: var(--ds-space-5) 0; padding: var(--ds-space-5) var(--ds-space-4); border-color: var(--ds-beige); border-radius: var(--ds-radius-lg); } .result-hero__icon { width: 112px; height: 112px; background: var(--ds-paper); box-shadow: 0 0 0 8px var(--ds-beige); } .result-hero__icon .graphic-icon, .result-hero__icon img { width: 82px; height: 82px; } .result-hero > strong { font-size: 3.25rem; } .result-actions { display: grid; gap: var(--ds-space-3); } .result-actions .button { width: 100%; text-align: center; } }
.result-actions { display: flex; gap: var(--ds-space-3); flex-wrap: wrap; }
.result-actions .button { flex: 1 1 220px; text-align: center; }
.mini-game:has(.ds-notice) > .ds-notice { margin-top: var(--ds-space-5); border-width: 2px; border-color: var(--ds-gold); background: linear-gradient(145deg, #fff9df, var(--ds-white)); box-shadow: var(--ds-shadow-card); }
.mini-game:has(.ds-notice) > .button { display: block; width: 100%; margin-top: var(--ds-space-4); text-align: center; }
.mini-game:has(.ds-notice) { position: relative; }
.mini-game:has(.ds-notice)::before { display: grid; place-items: center; width: 64px; height: 64px; margin: var(--ds-space-5) auto var(--ds-space-2); border-radius: 50%; background: var(--ds-beige); color: var(--ds-terracotta); content: "✦"; font-size: 2rem; font-weight: 800; }
.mini-game:has(.ds-notice) > .ds-notice::before { display: block; margin-bottom: var(--ds-space-2); color: var(--ds-terracotta); content: "Resultado de la partida"; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.mini-game[aria-label="Partida de Wordle"]:has(.ds-notice) > .ds-notice:has(.ds-notice--error), .mini-game[aria-label="Partida de Wordle"]:has(.ds-notice) > .ds-notice.ds-notice--error { border-color: var(--ds-danger); background: #fff1ef; }
main:has(.catalog-card) .book.catalog-card { border-color: var(--ds-line); box-shadow: none; }
main:has(.catalog-card) .book.catalog-card:hover { border-color: var(--ds-terracotta); }
main:has(.catalog-card) .filter-row { padding: var(--ds-space-3); border: 1px solid var(--ds-line); border-radius: var(--ds-radius-md); background: var(--ds-paper); }
.mini-game { margin-top: var(--ds-space-5); }
.wordle-board { display: grid; gap: 8px; max-width: 320px; margin: 0 auto var(--ds-space-5); }
.wordle-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wordle-row span { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid var(--ds-beige); border-radius: 6px; background: var(--ds-paper); font-weight: 800; }
.wordle-row span.correct { background: var(--ds-terracotta); border-color: var(--ds-terracotta); color: var(--ds-white); }
.wordle-row span.present { background: var(--ds-gold); border-color: var(--ds-gold); }
.wordle-row span.absent { background: var(--ds-muted); border-color: var(--ds-muted); color: var(--ds-white); }
.mini-game .game-hint { margin-bottom: var(--ds-space-4); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-md); background: var(--ds-paper); }
.mini-game .game-hint summary { padding: 12px 14px; color: var(--ds-terracotta); font-weight: 800; cursor: pointer; }
.mini-game .game-hint p { margin: 0; padding: 0 14px 14px; color: var(--ds-muted); }
.mini-game [data-wordle-form] > input { min-height: 48px; border: 1px solid var(--ds-beige); border-radius: 12px; text-transform: uppercase; letter-spacing: .16em; text-align: center; font-weight: 800; }
.mini-game .action-row > button:first-child, .mini-game > .button:first-of-type { background: var(--ds-terracotta); border-color: var(--ds-terracotta); color: var(--ds-white); }
.word-search-grid { display: grid; gap: 3px; max-width: 360px; margin: 0 auto var(--ds-space-5); padding: var(--ds-space-3); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-md); background: var(--ds-paper); }
.word-search-row { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 3px; }
.word-search-row button { display: grid; place-items: center; min-width: 32px; min-height: 44px; border: 0; border-radius: 5px; background: var(--ds-white); color: var(--ds-ink); font-weight: 800; touch-action: manipulation; }
.word-search-row button:focus-visible { outline: 3px solid var(--ds-gold); outline-offset: 2px; }
.word-search-row button.selected { background: var(--ds-gold); color: var(--ds-ink); }
.word-search-row button.found { background: var(--ds-terracotta); color: var(--ds-white); }
.word-search-words { display: flex; flex-wrap: wrap; gap: var(--ds-space-2); padding: 0; list-style: none; }
.word-search-words li { padding: 6px 10px; border: 1px solid var(--ds-line); border-radius: 999px; color: var(--ds-muted); }
.word-search-words li.found { border-color: var(--ds-terracotta); background: var(--ds-beige); color: var(--ds-ink); text-decoration: line-through; }
.word-search-words small { display: block; margin-top: 3px; color: var(--ds-muted); text-decoration: none; }
.word-search-words details { margin-top: 4px; font-size: .72rem; }
.word-search-words summary { color: var(--ds-terracotta); cursor: pointer; }
.crossword-flow-controls button:last-child { background: var(--ds-terracotta); border-color: var(--ds-terracotta); color: var(--ds-white); box-shadow: 0 5px 0 #7f4b2d; }
.mini-game-preview { margin-top: var(--ds-space-5); padding: var(--ds-space-4); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-md); background: var(--ds-paper); }
.mini-game-preview .word-search-grid { margin-bottom: 0; }
.reader-shell { border: 1px solid var(--ds-line); border-radius: var(--ds-radius-md); background: var(--ds-white); box-shadow: var(--ds-shadow-card); }
.reader-meta { color: var(--ds-muted); }
.reader-toolbar { background: var(--ds-ink); }
.reader-controls button, .reader-epub-options button { min-height: var(--ds-touch); }
.public-auth-form, main:has(.notification-heading) > section, main:has(.pending-dialog) .pending-notice { border: 1px solid var(--ds-line); border-radius: var(--ds-radius-md); background: var(--ds-white); box-shadow: none; }
.public-auth-form { padding: var(--ds-space-5); }
main:has(.notification-heading) > section { padding: var(--ds-space-4); margin-block: var(--ds-space-3); }
main:has(.notification-heading) > section.notice { border-left: 4px solid var(--ds-terracotta); background: var(--ds-paper); }
.notification-heading { display: flex; align-items: center; gap: var(--ds-space-3); }
.notification-heading .tag { margin-left: auto; }
.notification-section-title { margin-top: var(--ds-space-6); font-size: 1.05rem; }
.pending-dialog { border: 1px solid var(--ds-line); border-radius: var(--ds-radius-md); padding: var(--ds-space-5); }
main:has(.admin-user-card) .admin-user-card, main:has(.module-card) .module-card, main:has(.moderation-card) .moderation-card { border: 1px solid var(--ds-line); border-radius: var(--ds-radius-md); background: var(--ds-white); box-shadow: none; }
main:has(.admin-user-card) .admin-user-card { padding: var(--ds-space-4); }
main:has(.admin-user-card) .admin-user-card + .admin-user-card { margin-top: var(--ds-space-3); }
main:has(.module-card) .module-card { padding: var(--ds-space-4); }
main:has(.moderation-card) .moderation-card { padding: var(--ds-space-3); }
main:has(.admin-user-card) .filter-row, main:has(.module-card) .form { border-radius: var(--ds-radius-md); }
.ds-card--quiet { box-shadow: none; background: var(--ds-paper); }
.ds-card--danger { border-color: #e4b1aa; background: #fff1ef; }
.ds-card--quiet em { color: var(--ds-terracotta); font-style: normal; }
.ds-badge { display: inline-flex; align-items: center; gap: var(--ds-space-2); min-height: var(--ds-touch); padding: 8px 14px; border-radius: 999px; font-weight: 750; line-height: 1.2; }
.ds-badge--reading, .ds-badge--success { color: var(--ds-white); background: var(--ds-ink); }
.ds-badge--pending { color: #755016; background: #fff0c9; }
.ds-badge--done { color: var(--ds-white); background: var(--ds-success); }
.ds-badge--blocked { color: var(--ds-danger); border: 1px solid #e4b1aa; background: #fff1ef; }
.ds-progress { display: grid; gap: var(--ds-space-2); color: var(--ds-muted); font-size: .86rem; }
.ds-progress__track { height: 8px; overflow: hidden; border-radius: 999px; background: #eee8df; }
.ds-progress__value { display: block; height: 100%; border-radius: inherit; background: var(--ds-terracotta); }
.ds-progress--gold .ds-progress__value { background: var(--ds-gold); }
.ds-empty { display: grid; place-items: center; gap: var(--ds-space-3); text-align: center; }
.ds-empty__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--ds-beige); color: var(--ds-ink); font-size: 2rem; }
.ds-empty__icon img { width: 30px; height: 30px; object-fit: contain; }
.cover-fallback { background: var(--ds-paper) url('/static/images/library-cover-placeholder.webp') center / cover no-repeat; }

/* Legacy featured/saga cards still receive cover_emoji from old fixtures. Keep
   the visual surface consistent with every other cover fallback. */
main:has(.library-section) .book-featured > .book-icon:not(.has-cover-image),
main:has(.library-section) .next-saga .book-icon:not(.has-cover-image) {
  background: var(--ds-paper) url('/static/images/library-cover-placeholder.webp') center / cover no-repeat;
  color: transparent;
  font-size: 0;
}

/* Todas las fichas de Biblioteca comparten el mismo fallback editorial; el
   campo legacy cover_emoji sigue disponible para datos antiguos, pero nunca
   se expone como tratamiento visual de la interfaz. */
main:has(.library-summary) .book-icon:not(.has-cover-image),
main:has(.library-summary) .book-icon.cover-fallback {
  background: var(--ds-paper) url('/static/images/library-cover-placeholder.webp') center / cover no-repeat;
  color: transparent;
  font-size: 0;
  text-shadow: none;
}
main:has(.library-summary) .book-icon:not(.has-cover-image) img,
main:has(.library-summary) .book-icon.cover-fallback img { opacity: 0; }

/* Stacks and volume rows must use the same visual language when a catalog
   record has no image. The legacy cover_emoji remains data-only. */
main:has(.saga-detail-hero) .saga-stack__cover:not(.has-cover-image),
main:has(.saga-card) .saga-stack__cover:not(.has-cover-image) {
  color: transparent;
  font-size: 0;
  background: var(--ds-paper) url('/static/images/library-cover-placeholder.webp') center / cover no-repeat;
}
main:has(.saga-detail-hero) .saga-volume .book-icon:not(.has-cover-image),
main:has(.saga-card) .saga-card .book-icon:not(.has-cover-image) {
  color: transparent;
  font-size: 0;
  background: var(--ds-paper) url('/static/images/library-cover-placeholder.webp') center / cover no-repeat;
}
.social-reader-strip { display: flex; align-items: center; gap: 12px; margin: -8px 0 20px; color: var(--ds-muted); font-family: Georgia, serif; }
.social-reader-strip__avatars { display: flex; padding-left: 8px; }
.social-reader-avatar { display: grid; place-items: center; width: 42px; height: 42px; margin-left: -8px; overflow: hidden; border: 3px solid var(--ds-ivory); border-radius: 50%; background: var(--avatar-color, var(--ds-beige)); color: var(--ds-ink); font-weight: 800; }
.social-reader-avatar img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 480px) { .social-reader-strip { justify-content: center; margin: -8px 0 20px; font-size: .95rem; } }
.saga-volume .status-done::before, .saga-volume .status-reading::before, .saga-volume .status-want::before, .saga-volume .status-locked::before { display: inline-block; width: 18px; height: 18px; margin-right: 5px; background: center / contain no-repeat; content: ''; vertical-align: -4px; }
.saga-volume .status-done::before { background-image: url('/static/images/icons/check.svg'); }
.saga-volume .status-reading::before { background-image: url('/static/images/icons/book.svg'); }
.saga-volume .status-want::before { background-image: url('/static/images/icons/library-eye.png'); }
.saga-volume .status-locked::before { background-image: url('/static/images/icons/lock.svg'); }
.saga-detail-hero ~ .saga-volume-list .saga-volume .book-content .tag,
main:has(.saga-detail-hero) .saga-volume .book-content .tag {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 3px 0;
  font-family: Georgia, serif;
  font-size: .95rem;
  font-weight: 700;
}
main:has(.saga-detail-hero) .saga-volume .status-done,
main:has(.saga-detail-hero) .saga-volume .status-reading { color: var(--ds-gold); }
main:has(.saga-detail-hero) .saga-volume .status-want,
main:has(.saga-detail-hero) .saga-volume .status-locked { color: var(--ds-muted); }
main:has(.saga-detail-hero) .saga-volume .status-done::before,
main:has(.saga-detail-hero) .saga-volume .status-reading::before,
main:has(.saga-detail-hero) .saga-volume .status-want::before,
main:has(.saga-detail-hero) .saga-volume .status-locked::before {
  width: 21px;
  height: 21px;
  margin-right: 7px;
  vertical-align: -6px;
}
.ds-empty h2, .ds-empty p { margin: 0; }
.ds-empty p { max-width: 34ch; color: var(--ds-muted); }
.ds-empty .button { width: 100%; max-width: 22rem; text-align: center; }
main:has(.library-section) .ds-empty { border: 2px dashed var(--ds-beige); background: linear-gradient(180deg, var(--ds-paper), #fffdf9); box-shadow: none; }
main:has(.library-empty-hero) { text-align: left; }
.library-empty-hero { margin: 18px 0 28px; padding: 18px 10px 28px; }
.library-empty-hero__eyebrow { color: var(--ds-terracotta); font-size: .78rem; font-weight: 800; letter-spacing: .14em; }
.library-empty-hero h1 { margin: 14px 0 10px; font-family: Georgia, serif; font-size: clamp(2.2rem, 9vw, 3.6rem); line-height: .98; color: var(--ds-ink); }
.library-empty-hero h1 em { color: var(--ds-terracotta); font-style: normal; }
.library-empty-hero__rule { display: block; width: min(300px, 100%); height: 26px; margin: 16px 0; color: transparent; border: 0; background: url('/static/images/library-divider.webp') center / 100% 100% no-repeat; line-height: 0; font-size: 0; }
.library-empty-hero p { font-size: 1.05rem; line-height: 1.5; }
.library-empty-hero__art { margin: 8px -10px 18px; height: 210px; overflow: hidden; border-radius: var(--ds-radius-lg); background: var(--ds-paper); }
.library-empty-hero__art img { width: 100%; height: 100%; object-fit: cover; object-position: center 68%; }
.library-empty-hero__primary, .library-empty-hero__sagas { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 64px; margin-top: 12px; padding: 14px 20px; border-radius: 22px; font-size: 1.05rem; font-weight: 800; text-decoration: none; }
.library-empty-hero__primary img, .library-empty-hero__sagas img { width: 24px; height: 24px; object-fit: contain; }
.library-empty-hero__primary img { filter: brightness(0) invert(1); }
.library-empty-hero__primary { background: var(--ds-terracotta); color: #fff; }
.library-empty-hero__primary span, .library-empty-hero__sagas span:last-child { font-size: 2rem; line-height: .7; }
.library-empty-hero__sagas { border: 2px solid #ead0ae; color: var(--ds-ink); background: transparent; }
.library-empty-hero__sagas span:first-child { color: var(--ds-gold); font-size: 1.7rem; }
main:has(.library-section) .ds-empty__icon { width: 86px; height: 86px; border-radius: 24px; background: transparent; color: var(--ds-terracotta); font-size: 3rem; }
@media (max-width: 480px) { main:has(.library-section) .ds-empty { margin-inline: 0; padding: 28px 18px; } main:has(.library-section) .ds-empty .button { max-width: none; } }
section.empty { display: grid; gap: var(--ds-space-3); padding: var(--ds-space-5); border: 1px solid var(--ds-line); border-radius: var(--ds-radius-md); background: var(--ds-white); }
.ds-notice { display: flex; gap: var(--ds-space-3); align-items: flex-start; padding: var(--ds-space-4); }
.ds-notice p { margin: var(--ds-space-1) 0 0; }
.ds-notice__meta { display: block; margin-top: var(--ds-space-2); color: var(--ds-muted); font-variant-numeric: tabular-nums; }
.ds-notice__icon { flex: 0 0 auto; font-size: 1.25rem; }
.ds-notice--success { border-color: var(--ds-gold); }
.ds-notice--warning { border-color: var(--ds-gold); background: #fff9df; }
.ds-notice--error { border-color: var(--ds-terracotta); }
.ds-tabs { display: flex; gap: var(--ds-space-2); overflow-x: auto; padding: var(--ds-space-1) 0; scrollbar-width: thin; }
.ds-tabs__item { flex: 0 0 auto; min-height: var(--ds-touch); padding: 10px 16px; border: 1px solid var(--ds-beige); border-radius: 999px; background: var(--ds-white); color: var(--ds-ink); text-decoration: none; }
.ds-tabs__item[aria-current="page"], .ds-tabs__item.is-active { border-color: var(--ds-terracotta); background: var(--ds-terracotta); color: var(--ds-white); }
.ds-icon-button { display: inline-grid; place-items: center; min-width: var(--ds-touch); min-height: var(--ds-touch); padding: 8px; border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-sm); background: transparent; color: var(--ds-ink); }
.ds-bottom-sheet { position: fixed; z-index: 10; inset: auto 0 0; max-height: min(82dvh, 720px); overflow: auto; padding: var(--ds-space-6) var(--ds-space-4) calc(var(--ds-space-6) + env(safe-area-inset-bottom)); border: 1px solid var(--ds-beige); border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0; background: var(--ds-paper); box-shadow: 0 -18px 50px rgb(36 49 43 / 20%); }
.ds-bottom-sheet::before { display: block; width: 42px; height: 4px; margin: 0 auto var(--ds-space-4); border-radius: 999px; background: var(--ds-beige); content: ""; }
.sticky-save { bottom: calc(72px + env(safe-area-inset-bottom)); padding-bottom: calc(var(--ds-space-3) + env(safe-area-inset-bottom)); }
html { scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .ds-bottom-sheet { left: 50%; right: auto; width: min(100% - 32px, 560px); transform: translateX(-50%); } }
@media (max-width: 699px) {
  main:has(.library-summary)::before, main:has(.saga-card)::before { height: 92px; margin: -16px -16px 8px; background-position: center 38%; }
  main:has(.hub-grid)::before { height: 86px; margin: -16px -16px 8px; background-position: 70% 28%; }
  main:has(.activity-icon)::before, main:has(.challenge-card)::before { height: 78px; margin: -16px -16px 8px; background-position: 36% 68%; }
  .library-filter-trigger { display: block; width: 100%; min-height: var(--ds-touch); margin: var(--ds-space-4) 0 0; border: 1px solid var(--ds-terracotta); border-radius: 999px; background: transparent; color: var(--ds-terracotta); font: inherit; font-weight: 750; }
  .library-filter-backdrop { position: fixed; z-index: 19; inset: 0; display: block; background: rgb(36 49 43 / 48%); }
  .library-filter-backdrop[hidden] { display: none; }
  body.filter-sheet-open { overflow: hidden; }
  form.library-search { position: fixed; z-index: 20; inset: auto 0 0; display: none; max-height: min(82dvh, 720px); overflow: auto; margin: 0; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); border-radius: 30px 30px 0 0; background: var(--ds-paper); box-shadow: 0 -18px 50px rgb(36 49 43 / 20%); }
  .library-filter-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-3); margin-bottom: var(--ds-space-4); padding-top: var(--ds-space-2); }
  .library-filter-heading strong { color: var(--ds-ink); font-family: Georgia, serif; font-size: 2rem; letter-spacing: -.03em; }
  .library-filter-handle { position: absolute; top: var(--ds-space-4); left: 50%; width: 42px; height: 4px; border-radius: 999px; background: var(--ds-beige); transform: translateX(-50%); }
  .library-filter-close { display: grid; place-items: center; width: var(--ds-touch); min-width: var(--ds-touch); height: var(--ds-touch); min-height: var(--ds-touch); flex: 0 0 var(--ds-touch); margin: 0; padding: 0; border: 1px solid var(--ds-beige); border-radius: 50%; background: transparent; color: var(--ds-ink); font-size: 1.4rem; line-height: 1; }
  form.library-search button:not(.library-filter-close) { background: var(--ds-terracotta); }
  form.library-search.is-sheet-open { display: grid; }
  form.library-search .library-filter-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(92px, auto); align-items: center; gap: 12px; min-height: 64px; padding: 8px 0; border-bottom: 1px solid var(--ds-beige); }
  form.library-search .library-filter-row::before { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--ds-beige); color: var(--ds-terracotta); content: attr(data-icon); font: 700 1.35rem Georgia, serif; }
  form.library-search .library-filter-row__label { margin: 0; color: var(--ds-ink); font-weight: 750; line-height: 1.15; }
  form.library-search .library-filter-row--search .library-filter-row__label { font-size: 0; }
  form.library-search .library-filter-row--search .library-filter-row__label::after { content: 'Buscar'; font-size: 1rem; }
  form.library-search .library-filter-row input[type="text"], form.library-search .library-filter-row input:not([type]), form.library-search .library-filter-row select { grid-column: 3; width: 100%; min-height: 44px; margin: 0; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ds-muted); text-align: right; font: inherit; }
  form.library-search .library-filter-row input[type="text"]::placeholder, form.library-search .library-filter-row input:not([type])::placeholder { color: var(--ds-muted); opacity: 1; }
  form.library-search .library-filter-row select { appearance: none; background: transparent; }
  form.library-search .library-filter-row input:focus, form.library-search .library-filter-row select:focus { outline: 2px solid var(--ds-gold); outline-offset: 2px; }
  form.library-search .library-format-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 16px 0 4px; padding: 0; border: 0; }
  form.library-search .library-format-filters legend { grid-column: 1 / -1; margin-bottom: 2px; color: var(--ds-ink); font-weight: 750; }
  form.library-search .library-format-filters label { justify-content: space-between; min-height: 48px; padding: 8px 12px; border-radius: 14px; }
  form.library-search .library-format-filters input { order: 2; width: 20px; height: 20px; }
  form.library-search > button:not(.library-filter-close), form.library-search > .button { min-height: 64px; margin-top: 14px; border-radius: 16px; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media (prefers-reduced-motion: reduce) { .ds-tabs { scroll-behavior: auto; } }
@media (max-width: 380px) {
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row .button,
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row form button { padding-inline: 10px; font-size: .92rem; }
}

/* Optimized raster variants for the mobile Biblioteca/Sagas surfaces. */
.saga-detail-hero { background-image: linear-gradient(90deg, rgb(36 49 43 / 66%), rgb(36 49 43 / 12%) 52%, rgb(255 250 240 / 92%)), url('/static/images/saga-detail-editorial.webp'); }
.saga-detail-hero { position: relative; }
.saga-detail-hero::after { content: ''; position: absolute; right: 12px; bottom: 8px; width: 120px; height: 60px; background: url('/static/images/library-leaf-ornament.png') center / contain no-repeat; opacity: .38; pointer-events: none; }
main:has(.library-summary)::before { background-image: linear-gradient(180deg, rgb(247 245 239 / 12%), rgb(247 245 239 / 30%)), url('/static/images/library-header-editorial.webp'); }
main:has(.ds-catalog-card)::before { background-image: linear-gradient(180deg, rgb(247 245 239 / 12%), rgb(247 245 239 / 30%)), url('/static/images/library-discover-editorial.webp'); }
main:has(.home-summary)::before { background-image: linear-gradient(180deg, rgb(247 245 239 / 18%), rgb(247 245 239 / 42%)), url('/static/images/library-home-editorial.webp'); }
.library-empty-hero__rule { background-image: url('/static/images/library-divider.webp'); }

@media (max-width: 480px) {
  .saga-detail-hero { background-image: linear-gradient(90deg, rgb(36 49 43 / 74%), rgb(36 49 43 / 18%) 48%, rgb(255 250 240 / 94%)), url('/static/images/saga-detail-editorial.webp'); }
  .saga-detail-hero::after { right: 4px; bottom: 6px; width: 96px; height: 48px; opacity: .3; }
body:has(.saga-detail-hero) .saga-volume:has(.status-locked) .book-icon { background-image: url('/static/images/saga-volume-locked.webp'); }
main:has(.saga-detail-hero) > .tag { margin: 8px 0; padding: 5px 10px; font-size: .78rem; }
main:has(.saga-detail-hero) > .notice { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--ds-terracotta); border-radius: 0 12px 12px 0; font-size: .88rem; line-height: 1.3; }
.saga-detail-topbar { display: flex; align-items: center; gap: 22px; min-height: 58px; margin: -20px -22px 0; padding: 8px 22px; border-bottom: 1px solid var(--ds-beige); background: var(--ds-paper); }
.saga-detail-topbar .context-back { display: grid; place-items: center; width: 44px; height: 44px; color: var(--ds-ink); font-size: 2rem; line-height: 1; text-decoration: none; }
.saga-detail-topbar > span { color: var(--ds-ink); font: 700 1.45rem Georgia, serif; }
.saga-index-topbar { display: flex; align-items: center; gap: 22px; min-height: 58px; margin: -20px -22px 0; padding: 8px 22px; border-bottom: 1px solid var(--ds-beige); background: var(--ds-paper); }
.saga-index-topbar { flex-direction: row; justify-content: flex-start; }
.saga-index-topbar .context-back { display: grid; place-items: center; width: 44px; height: 44px; color: var(--ds-ink); font-size: 2rem; line-height: 1; text-decoration: none; }
.saga-index-topbar > span { color: var(--ds-ink); font: 700 1.45rem Georgia, serif; }
main:has(.saga-card)::before { display: none; }
@media (max-width: 480px) {
  main:has(.saga-card) .saga-index-topbar { flex-direction: row; justify-content: flex-start; height: 58px; min-height: 58px; }
  main:has(.saga-card) > h1 + p { display: none; }
  main:has(.saga-card) > h1 { margin-bottom: 18px; }
  main:has(.saga-detail-hero) .saga-detail-hero { grid-template-columns: 58% 42%; min-height: 0; height: 292px; padding: 10px 8px; background-image: linear-gradient(90deg, rgb(255 250 240 / 94%), rgb(255 250 240 / 22%) 58%, rgb(36 49 43 / 24%)), url('/static/images/saga-detail-editorial.webp'); background-position: center; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack { order: 2; min-height: 0; height: 250px; transform: none; transform-origin: right top; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover { width: 92px; height: 138px; padding: 3px; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--1 { inset: 28px auto auto 8px; transform: rotate(7deg); }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--2 { inset: 16px auto auto 42px; transform: rotate(2deg); }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--3 { inset: 28px auto auto 76px; transform: rotate(-5deg); }
  main:has(.saga-detail-hero) .saga-detail-hero__copy { order: 1; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy { align-self: start; min-width: 0; padding: 16px 4px 6px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > p { display: none; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy .eyebrow { display: block; margin-bottom: 2px; font-size: .68rem; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy h2 { margin: 0 0 5px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy h2 { font-size: 1.32rem; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy p { margin-bottom: 6px; font-size: .78rem; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy strong { font-size: .98rem; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy .ds-progress { margin: 6px 0 0; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row { margin-top: 8px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row form,
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row .button { min-height: 48px; }
  main:has(.saga-detail-hero) .saga-volume { grid-template-columns: 32px 58px minmax(0, 1fr); min-height: 112px; padding: 10px 8px; gap: 8px; }
  main:has(.saga-detail-hero) .saga-volume .book-icon { width: 58px; height: 87px; flex-basis: 58px; }
  main:has(.saga-detail-hero) .saga-volume .book-content h3 { font-size: .94rem; line-height: 1.12; }
  main:has(.saga-detail-hero) .saga-volume .book-content > p:not(.tag) { display: none; }
  main:has(.saga-detail-hero) .saga-volume .book-content .tag { margin: 6px 0 0; padding: 4px 7px; font-size: .72rem; }
  main:has(.saga-detail-hero) .saga-volume .book-content > .action-row { display: none; }
}
}

/* Editorial authentication composition, derived mobile-first. */
@media (max-width: 480px) {
  /* Empty Biblioteca follows the reference as a page composition, not as a
     nested white card. Keep the editorial hierarchy visible above the fold. */
  main:has(.library-empty-hero) { padding: 28px 16px 104px; background: transparent; border: 0; box-shadow: none; }
  .library-empty-hero { margin: 0; padding: 0; background: transparent; border-radius: 0; box-shadow: none; }
  .library-empty-hero h1 { font-size: clamp(2.55rem, 11vw, 3rem); line-height: .98; margin-top: 12px; }
  .library-empty-hero > p { max-width: 330px; margin-bottom: 0; font-size: 1.08rem; }
  .library-empty-hero__rule { position: relative; width: 150px; height: 12px; margin: 22px 0 18px; background: none; }
  .library-empty-hero__rule::before { content: ''; position: absolute; left: 0; top: -1px; width: 14px; height: 14px; background: url('/static/images/library-spark.png') center / contain no-repeat; }
  .library-empty-hero__rule::after { content: ''; position: absolute; left: 15px; right: 0; top: 5px; height: 2px; background: var(--ds-gold); transform-origin: left center; }
  .library-empty-hero p { max-width: 350px; margin-bottom: 16px; font-size: 1.05rem; }
  .library-empty-hero__art { height: 270px; margin-inline: 0; border-radius: 0; }

  main:has(.library-summary), main:has(.saga-card), main:has(.book-detail-hero), main:has(.saga-detail-hero) { padding-bottom: 104px; }
  main:has(.library-summary) .library-section,
  main:has(.library-summary) .rating-stars,
  main:has(.library-summary) .rating-stars textarea,
  main:has(.library-summary) .rating-stars label { box-sizing: border-box; max-width: 100%; }
  main:has(.library-summary) .library-section form,
  main:has(.library-summary) .library-section form > *,
  main:has(.library-summary) .library-section .tag { max-width: 100%; box-sizing: border-box; overflow-wrap: anywhere; }
  main:has(.library-summary) form,
  main:has(.library-summary) form > *,
  main:has(.library-summary) fieldset,
  main:has(.library-summary) textarea { max-width: 100%; box-sizing: border-box; }
  main:has(.library-summary) form > label,
  main:has(.library-summary) form > textarea,
  main:has(.library-summary) form > fieldset,
  main:has(.library-summary) form > button { width: 100%; }
  main:has(.library-summary) form label,
  main:has(.library-summary) form fieldset,
  main:has(.library-summary) form textarea,
  main:has(.library-summary) form button { width: 100%; }
  /* La biblioteca conserva todos sus estados y permite desplazarlos en móvil. */
  body:has(.library-summary) .library-tabs { display: flex; gap: 6px; padding: 6px 4px; border: 1px solid var(--ds-beige); border-radius: 14px; background: var(--ds-paper); overflow-x: auto; }
  body:has(.library-summary) .library-tabs a { justify-content: center; min-height: 48px; padding: 8px 12px; border-radius: 10px; font: 700 .82rem Georgia, serif; white-space: nowrap; }
  body:has(.library-summary) .library-tabs a.is-active { background: var(--ds-terracotta); color: #fff; }
  body:has(.library-summary) > main > h1 + p { display: none; }
  body:has(.library-summary) > main > h1 {
    margin: 26px 0 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--ds-beige);
    font: 700 clamp(2.6rem, 12vw, 3.3rem)/.98 Georgia, serif;
  }
  body:has(.library-summary) .library-section { padding: 16px; border: 1px solid var(--ds-beige); border-radius: 18px; background: var(--ds-paper); box-shadow: 0 8px 24px rgb(36 49 43 / 8%); }
  body:has(.library-summary) .book-featured { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 0; border: 0; background: transparent; box-shadow: none; }
  body:has(.library-summary) .book-featured .book-icon { width: 150px; height: 225px; border-radius: 10px; }
  body:has(.library-summary) .book-featured .book-icon:not(.has-cover-image) { display: grid; place-items: center; color: transparent; text-shadow: none; background: var(--ds-paper) url('/static/images/icons/book.svg') center / 42% auto no-repeat; }
  body:has(.library-summary) .book-featured .book-content { min-width: 0; }
  body:has(.library-summary) .book-featured h3 { margin: 0 0 6px; font: 700 clamp(1.25rem, 5vw, 1.65rem)/1.08 Georgia, serif; }
  body:has(.library-summary) .book-featured p { margin: 5px 0; font-size: .9rem; }
  body:has(.library-summary) .book-featured .reading-status { color: var(--ds-ink); font: 1rem/1.25 Georgia, serif; }
  body:has(.library-summary) .book-featured .reading-status strong { font-weight: 700; }
  body:has(.library-summary) .book-featured .button { width: 100%; min-height: 56px; padding: 10px 8px; font-size: .85rem; }
  body:has(.library-summary) .book-featured form { margin-top: 6px; }
  body:has(.library-summary) .book-featured form .secondary { min-height: 44px; padding: 8px; font-size: .76rem; }
  body:has(.library-summary) .book-secondary-actions { margin-top: 8px; }
  body:has(.library-summary) .book-secondary-actions summary { min-height: 44px; padding: 10px 4px; color: var(--ds-muted); font-size: .82rem; text-align: center; cursor: pointer; }
  body:has(.library-summary) .book-secondary-actions form { margin-top: 0; }
  .library-empty-hero__art { height: 290px; margin-top: 12px; }
  .library-empty-hero__art img { object-position: center 74%; }
  body:has(.library-summary) .ds-reading-card,
  body:has(.library-summary) .ds-catalog-card {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  body:has(.library-summary) .ds-reading-card .book-icon,
  body:has(.library-summary) .ds-catalog-card .book-icon { width: 120px; height: 180px; border-radius: 10px; }
  body:has(.library-summary) .ds-reading-card .book-content,
  body:has(.library-summary) .ds-catalog-card .book-content { min-width: 0; }
  body:has(.library-summary) .ds-reading-card h3,
  body:has(.library-summary) .ds-catalog-card h3 { margin: 0 0 6px; font: 700 clamp(1.12rem, 4.8vw, 1.45rem)/1.1 Georgia, serif; }
  body:has(.library-summary) .ds-reading-card .action-row,
  body:has(.library-summary) .ds-catalog-card .action-row { display: grid; gap: 8px; margin-top: 12px; }
  body:has(.library-summary) .ds-reading-card .action-row .button,
  body:has(.library-summary) .ds-catalog-card .action-row .button { width: 100%; min-height: 48px; }
  body:has(.library-summary) .ds-reading-card .ds-progress { margin: 10px 0; }
  body:has(.saga-detail-hero) .saga-volume:has(.status-locked) .book-icon { background: url('/static/images/saga-volume-locked.webp') center / cover; color: transparent; }
  @media (max-width: 360px) {
    body:has(.library-summary) .book-featured { grid-template-columns: 112px minmax(0, 1fr); gap: 12px; }
    body:has(.library-summary) .book-featured .book-icon { width: 112px; height: 168px; }
  }
  /* Las tarjetas destacadas no deben caer en un emoji: la referencia siempre conserva una cubierta editorial. */
  body:has(.library-summary) .book-featured .book-icon:not(.has-cover-image) { background: var(--ds-paper) url('/static/images/library-cover-placeholder.webp') center / cover no-repeat; color: transparent; text-shadow: none; }
  body:has(.public-home) .context-strip,
  body:has(.public-home) .pending-dialog,
  body:has(.public-home) .bottom-nav { display: none; }
  body:has(.public-home) main { max-width: 480px; padding: 0 16px 40px; }
  .public-home { min-height: 100dvh; padding-top: 18px; color: var(--ds-ink); }
  .public-home-hero { position: relative; min-height: 510px; padding-top: 284px; overflow: hidden; }
  .public-home-editorial { position: absolute; z-index: -1; top: -10px; right: -80px; width: 560px; height: 390px; object-fit: cover; object-position: 65% 25%; opacity: .92; mask-image: linear-gradient(to bottom, black 65%, transparent 100%); }
  .public-home .eyebrow { position: relative; z-index: 1; }
  .public-home h1 { position: relative; z-index: 1; max-width: 380px; margin: 10px 0 18px; font: 700 clamp(2.65rem, 12vw, 4rem)/.96 Georgia, serif; letter-spacing: -.04em; }
  .public-home h1 em { color: var(--ds-terracotta); font-style: normal; }
  .public-home-hero > p { position: relative; z-index: 1; max-width: 340px; margin: 0; color: var(--ds-muted); font: 1.1rem/1.45 Georgia, serif; }
  .public-home-actions { display: grid; gap: 14px; margin-top: 2px; }
  .public-home-primary { width: 100%; min-height: 62px; margin: 0; border-radius: 14px; background: var(--ds-terracotta); color: #fff; text-align: center; font: 700 1.12rem Georgia, serif; box-shadow: 0 10px 20px rgb(163 107 66 / 18%); }
  .public-home-login { min-height: 44px; padding: 10px; color: var(--ds-ink); text-align: center; font: 1.12rem Georgia, serif; text-decoration: underline; text-decoration-color: var(--ds-terracotta); text-underline-offset: 5px; }
  .public-home-footer { display: grid; justify-items: center; margin-top: 54px; text-align: center; }
  .public-home-footer img { width: 150px; height: 82px; object-fit: contain; opacity: .85; }
  .public-home-footer p { margin: 8px 0 0; color: var(--ds-ink); font: italic 1.05rem/1.35 Georgia, serif; }
  @media (max-width: 340px) { .public-home { padding-top: 12px; } .public-home-hero { min-height: 455px; padding-top: 252px; } .public-home-editorial { right: -112px; width: 500px; } .public-home h1 { font-size: 2.45rem; } .public-home-hero > p { font-size: 1rem; } .public-home-footer { margin-top: 32px; } }
  body:has(.public-auth-form) .context-strip,
  body:has(.public-auth-form) .pending-dialog,
  body:has(.public-auth-form) .bottom-nav { display: none; }
  body:has(.public-auth-form) main {
    position: relative;
    padding-top: 26px;
  }
  body:has(.public-auth-form) main::before {
    position: absolute;
    z-index: -1;
    inset: 0 -16px auto;
    height: 330px;
    background: linear-gradient(180deg, rgb(247 245 239 / 12%), rgb(247 245 239 / 88%)), url('/static/images/auth-login-editorial.png') center / cover;
    border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg);
    content: "";
    opacity: .72;
  }
  body:has(.public-auth-form) main > h1 {
    max-width: 320px;
    margin-top: 10px;
    font-family: Georgia, serif;
    font-size: clamp(2.6rem, 12vw, 3.5rem);
    line-height: .98;
  }
  body:has(.public-auth-form) .auth-heading { position: relative; z-index: 1; }
  body:has(.public-auth-form) .auth-heading > p { margin: 20px 0 0; color: var(--ds-muted); font: 1.05rem/1.45 Georgia, serif; }
  body:has(.public-auth-form) .public-auth-form {
    margin-top: 36px;
    padding: 28px 22px 24px;
    border: 1px solid var(--ds-beige);
    border-radius: var(--ds-radius-lg);
    background: rgb(255 250 245 / 94%);
    box-shadow: var(--ds-shadow-card);
  }
  body:has(.public-auth-form) .public-auth-form button {
    width: 100%;
    min-height: 52px;
    background: var(--ds-terracotta);
    border-color: var(--ds-terracotta);
  }
  body:has(.public-auth-form) .auth-field { gap: 8px; }
  body:has(.public-auth-form) .auth-field label { color: var(--ds-ink); font: 700 1rem Georgia, serif; }
  body:has(.public-auth-form) .auth-input-wrap { position: relative; display: flex; align-items: center; }
  body:has(.public-auth-form) .auth-input-wrap::before { width: 24px; height: 24px; margin-left: 16px; flex: 0 0 24px; background: center / contain no-repeat; content: ""; opacity: .9; }
  body:has(.public-auth-form) .auth-input-mail::before { width: 24px; height: 24px; background: none; content: "✉"; color: var(--ds-ink); font-size: 1.25rem; line-height: 24px; }
  body:has(.public-auth-form) .auth-input-lock::before { background-image: url('/static/images/raster-reference/icons/lock.png'); }
  body:has(.public-auth-form) .auth-input-wrap input { min-height: 68px; padding: 14px 16px 14px 52px; border-radius: 14px; border-color: #dfd5ca; background: #fffdfb; margin-left: -40px; }
  body:has(.public-auth-form) .auth-password-toggle { position: absolute; right: 8px; z-index: 2; display: grid; place-items: center; width: 44px !important; min-width: 44px !important; max-width: 44px; height: 44px; min-height: 44px; margin: 0 !important; padding: 0; border: 0; border-radius: 50%; background: transparent !important; color: var(--ds-ink); font-size: 1.2rem; line-height: 1; }
  body:has(.public-auth-form) .auth-password-toggle img { width: 22px; height: 22px; object-fit: contain; }
  body:has(.public-auth-form) .auth-recovery { margin-top: -2px; text-align: right; }
  body:has(.public-auth-form) .auth-recovery a { padding: 10px 0; color: var(--ds-terracotta); font-size: .92rem; text-decoration: none; }
  body:has(.public-auth-form) .auth-submit { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; border-radius: 14px; font: 700 1.08rem Georgia, serif; }
  body:has(.public-auth-form) .auth-submit span { font-size: 1.5rem; }
  body:has(.public-auth-form) .auth-submit img { width: 26px; height: 26px; object-fit: contain; }
  body:has(.public-auth-form) .auth-divider { display: flex; align-items: center; gap: 12px; margin: 4px 0 0; color: var(--ds-muted); font: 1rem Georgia, serif; }
  body:has(.public-auth-form) .auth-divider span { height: 1px; flex: 1; background: var(--ds-beige); }
  body:has(.public-auth-form) .auth-register { display: grid; justify-items: center; gap: 5px; color: var(--ds-muted); font: 1rem Georgia, serif; }
  body:has(.public-auth-form) .auth-register a { color: var(--ds-terracotta); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
  body:has(.public-auth-form) .auth-errors, body:has(.public-auth-form) .auth-error { color: #963f35; font-size: .82rem; }
  body:has(.public-auth-form) main > p {
    text-align: center;
  }
}
@media (min-width: 361px) and (max-width: 480px) {
  body:has(.library-summary) .book-featured .reading-status { white-space: nowrap; font-size: .88rem; }
}

/* Biblioteca detail proportions: mobile reference baseline. */
@media (max-width: 480px) {
  main:has(.book-detail-hero) > .eyebrow { display: none; }
  main:has(.book-detail-hero) .context-back { min-height: 44px; border: 0; background: transparent; box-shadow: none; padding: 8px 0; color: var(--ds-ink); font: 1.15rem/1.2 Georgia, serif; }
  main:has(.book-detail-hero) .context-nav { padding-top: 4px; }
  main:has(.saga-card) .saga-featured { grid-template-columns: 164px minmax(0, 1fr); gap: 12px; margin: 20px 0 24px; padding: 16px 12px; border-radius: 20px; }
  main:has(.saga-card) .saga-featured__stack { min-height: 190px; transform: scale(.94); transform-origin: left center; }
  main:has(.saga-card) .saga-featured__content h2 { font: 700 clamp(1.45rem, 7vw, 2rem)/1.05 Georgia, serif; overflow-wrap: anywhere; }
  main:has(.saga-card) .saga-featured__content > .button { min-height: 64px; border-radius: 18px; }
  main:has(.saga-card) > .form { margin: 16px 0 20px; padding: 16px; border: 1px solid var(--ds-beige); border-radius: 18px; background: var(--ds-paper); }
  main:has(.saga-card) > .form button { width: 100%; min-height: 56px; }
  main:has(.saga-card) .saga-card { grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 14px 12px; border-radius: 18px; }
  main:has(.saga-card) .saga-card + .saga-card { margin-top: 12px; }
  main:has(.saga-card) .saga-card .saga-stack { min-height: 112px; }
  main:has(.saga-card) .saga-card .saga-stack__cover { width: 64px; height: 96px; }
  main:has(.saga-card) .saga-card .book-content h3 { margin: 0 0 6px; font: 700 1.2rem/1.08 Georgia, serif; overflow-wrap: anywhere; }
  main:has(.saga-card) .library-tabs a.is-active,
  main:has(.saga-card) .library-tabs a[aria-current="page"] { border-color: var(--ds-terracotta); background: var(--ds-terracotta); color: #fff; }
  body:has(.library-summary) .library-section + .library-section { margin-top: 24px; }
  body:has(.library-summary) .book-icon,
  body:has(.library-summary) .book-detail-cover { aspect-ratio: 2 / 3; object-fit: cover; }
  body:has(.library-summary) .book-featured .book-icon { box-shadow: 0 6px 16px rgb(36 49 43 / 18%); }
  body:has(.library-summary) .library-summary { margin-bottom: 24px; }
  body:has(.library-summary) .library-section > .section-heading { margin-bottom: 16px; }
  main:has(.book-detail-hero)::before { height: 240px; margin: -16px -16px -210px; border-radius: 0 0 24px 24px; background-position: center 38%; }
  main:has(.book-detail-hero) .context-nav { margin-bottom: 10px; }
  main:has(.book-detail-hero) .book-detail-hero { display: grid; grid-template-columns: 1fr; justify-items: center; gap: 0; margin: -16px -16px 8px; padding: 0 16px 12px; border: 0; border-radius: 0 0 24px 24px; background: transparent; box-shadow: none; text-align: center; }
  main:has(.book-detail-hero) .book-detail-hero .book-detail-cover { width: min(190px, 58vw) !important; height: min(285px, 87vw) !important; flex-basis: auto !important; margin: 0 auto; border: 1px solid rgb(36 49 43 / 12%); border-radius: 12px; box-shadow: 0 10px 22px rgb(36 49 43 / 20%); background-color: var(--ds-beige); background-size: cover !important; }
  main:has(.book-detail-hero) .book-detail-hero > div { width: 100%; padding: 18px 0 0; }
  main:has(.book-detail-hero) .book-detail-hero h1 { margin: 0 0 6px; font: 700 clamp(2rem, 9vw, 2.75rem)/1.02 Georgia, serif; }
  main:has(.book-detail-hero) .book-author { margin: 0 0 8px; font: 1.25rem Georgia, serif; color: var(--ds-muted); }
  main:has(.book-detail-hero) .book-saga-meta { margin: 0 0 8px; color: var(--ds-muted); text-align: center; line-height: 1.45; }
  main:has(.book-detail-hero) .book-saga-meta + .social-reader-strip + .book-reading-action,
  main:has(.book-detail-hero) .book-saga-meta + .book-reading-action { margin-top: 0; }
  main:has(.book-detail-hero) .book-reading-action { scroll-margin-top: 16px; }
  main:has(.book-detail-hero) .book-saga-meta a { color: var(--ds-terracotta); font-weight: 750; }
  main:has(.book-detail-hero) .book-saga-meta::before { display: inline-block; width: 22px; height: 22px; margin-right: 6px; background: url('/static/images/icons/book.svg') center / contain no-repeat; content: ''; vertical-align: -5px; }
  main:has(.book-detail-hero) .book-detail-hero > div > p:not(.book-author) { margin: 6px 0; }
  main:has(.book-detail-hero) .book-detail-hero + section,
  main:has(.book-detail-hero) .social-summary,
  main:has(.book-detail-hero) .book-downloads { border-color: var(--ds-beige); border-radius: 18px; box-shadow: 0 8px 22px rgb(36 49 43 / 7%); }
  main:has(.book-detail-hero) .book-downloads .action-row { gap: 0; }
  main:has(.book-detail-hero) .book-downloads .button { min-height: 68px; margin: 0; border-radius: 0; border-bottom: 1px solid var(--ds-beige); background: transparent; color: var(--ds-ink); text-align: left; }
  main:has(.book-detail-hero) .book-downloads .button:last-child { border-bottom: 0; }
  main:has(.book-detail-hero) .book-reading-action { border: 1px solid var(--ds-beige); background: var(--ds-paper); }
  main:has(.book-detail-hero) .book-reading-action { margin-top: 0; padding: 12px 16px; }
  main:has(.book-detail-hero) .book-reading-action h2 { margin: 0 0 8px; font-size: 1.25rem; }
  main:has(.book-detail-hero) .book-reading-action > p { margin: 6px 0; }
  main:has(.book-detail-hero) .book-reading-action .ds-progress { gap: 6px; margin: 8px 0; }
  main:has(.book-detail-hero) .book-reading-action > .button,
  main:has(.book-detail-hero) .book-reading-action > form button { min-height: 72px; }
  main:has(.book-detail-hero) .book-reading-action h2::before { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-right: 8px; border-radius: 50%; background: var(--ds-beige); color: var(--ds-terracotta); content: '▱'; font-size: 1.1rem; vertical-align: middle; }
  main:has(.book-detail-hero) .book-community-card, main:has(.book-detail-hero) .book-formats-card { border: 1px solid var(--ds-beige); background: var(--ds-paper); }
  main:has(.book-detail-hero) > section:not(.social-summary):not(.book-downloads) .button,
  main:has(.book-detail-hero) > section:not(.social-summary):not(.book-downloads) form button { min-height: 64px; width: 100%; border-radius: 16px; }
  main:has(.book-detail-hero) .book-downloads .button::before { display: inline-grid; place-items: center; width: 36px; height: 36px; margin-right: 12px; border-radius: 10px; background: var(--ds-beige); color: var(--ds-terracotta); content: '↓'; font-weight: 800; vertical-align: middle; }
  main:has(.book-detail-hero) .book-downloads .button[href*="/pdf/"]::before { content: 'PDF'; font-size: .62rem; }
  main:has(.book-detail-hero) .book-downloads .button[href*="/epub/"]::before { content: 'EPUB'; font-size: .54rem; }
  main:has(.book-detail-hero) .social-summary h2 { display: flex; align-items: center; gap: 12px; }
  main:has(.book-detail-hero) .social-summary h2::after { display: block; width: 38px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 50% 42%, #f7e6d5 0 28%, transparent 29%), radial-gradient(circle at 50% 48%, #a36b42 0 47%, transparent 48%), #d29c2e; box-shadow: -18px 0 0 -3px #ead9c8, 18px 0 0 -3px #f0c9aa; content: ''; flex: 0 0 38px; }
  main:has(.book-detail-hero) .social-summary .notice { position: relative; margin: 14px 0 0; padding: 14px 14px 14px 58px; border: 0; border-top: 1px solid var(--ds-beige); border-radius: 0; background: transparent; color: var(--ds-ink); line-height: 1.45; }
  main:has(.book-detail-hero) .social-summary .notice::before { position: absolute; top: 14px; left: 0; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--ds-beige); color: var(--ds-terracotta); content: '★'; font-size: 1.15rem; }
  main:has(.book-detail-hero) .social-summary .review-author-avatar { position: absolute; top: 14px; left: 0; z-index: 1; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--ds-terracotta); color: #fff; font: 700 1.1rem Georgia, serif; }
  main:has(.book-detail-hero) .social-summary .notice:first-of-type { border-top: 0; }
  main:has(.saga-detail-hero) > .context-nav { margin-bottom: 8px; }
  main:has(.saga-detail-hero) .saga-detail-hero { min-height: 260px; margin: 0 -16px 22px; padding: 18px 16px; border-radius: 0 0 24px 24px; background-position: 34% center; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack { min-height: 220px; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover { width: 108px; height: 162px; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--1 { inset: 24px auto auto 0; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--2 { inset: 12px auto auto 6px; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--3 { inset: 24px auto auto 12px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy { padding: 14px 12px; border-radius: 0; background: transparent; text-shadow: 0 1px 0 rgb(255 250 240 / 72%); box-shadow: none; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy h2 { font-size: clamp(1.45rem, 7vw, 2rem); }
  main:has(.saga-detail-hero) .saga-detail-hero__copy strong { display: block; font-size: 1.05rem; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy .ds-progress { margin: 12px 0 0; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row { display: grid; gap: 8px; margin-top: 14px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row .button,
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row form { width: 100%; min-height: 56px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row .button { background: var(--ds-terracotta); border-color: var(--ds-terracotta); color: var(--ds-white); }
  main:has(.saga-detail-hero) > .action-row { display: grid; gap: 8px; margin: -8px 0 24px; }
  main:has(.saga-detail-hero) > .action-row .button,
  main:has(.saga-detail-hero) > .action-row form { width: 100%; min-height: 64px; }
  main:has(.saga-detail-hero) > .action-row .button { background: var(--ds-terracotta); border-color: var(--ds-terracotta); color: var(--ds-white); text-align: center; }
  main:has(.saga-detail-hero) .saga-volume { min-height: 150px; }
  body:has(.saga-detail-hero) .saga-volume:has(.status-locked) .book-icon { background-image: url('/static/images/saga-volume-locked.webp'); }
}

/* Canonical Saga mobile geometry: keep the hero and first reading row visible. */
@media (max-width: 480px) {
  /* Biblioteca canonical mobile geometry: the reference starts with the
     editorial title and tabs; the decorative header art is not part of this
     screen's composition. */
  main:has(.library-summary)::before { display: none; }
  body:has(.library-summary) main > .eyebrow { display: none; }
  body:has(.library-summary) main > h1 { margin: 18px 0 12px; font: 700 clamp(2.35rem, 11vw, 3.35rem)/.98 Georgia, serif; letter-spacing: -.045em; }
  body:has(.library-summary) main > h1 + p { display: none; }
  body:has(.library-summary) .library-tabs { margin-top: 28px; }
  body:has(.library-summary) .library-section { margin-top: 24px; }
  body:has(.library-summary) main > .library-section:first-of-type .section-heading { display: none; }
  body:has(.library-summary) main > .library-section:first-of-type { padding-top: 14px; }
  body:has(.library-summary) .book-featured { grid-template-columns: 136px minmax(0, 1fr); gap: 14px; }
  body:has(.library-summary) .book-featured .book-icon { width: 136px; height: 204px; }
  body:has(.library-summary) .book-featured h3 { font-size: clamp(1.15rem, 5vw, 1.45rem); }
  body:has(.library-summary) .book-featured .button { min-height: 52px; }

  main:has(.saga-detail-hero) .saga-detail-hero { grid-template-columns: 58% 42%; height: 292px; min-height: 292px; padding: 10px 8px; background-image: linear-gradient(90deg, rgb(255 250 240 / 94%), rgb(255 250 240 / 28%) 58%, rgb(36 49 43 / 18%)), url('/static/images/saga-detail-riverton-editorial.png'); background-position: center; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack { order: 2; min-height: 0; height: 250px; transform: none; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover { width: 80px; height: 120px; padding: 3px; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--1 { inset: 28px auto auto 8px; transform: rotate(7deg); }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--2 { inset: 16px auto auto 42px; transform: rotate(2deg); }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover--3 { inset: 28px auto auto 76px; transform: rotate(-5deg); }
  main:has(.saga-detail-hero) .saga-detail-hero__copy { order: 1; align-self: start; min-width: 0; padding: 16px 4px 6px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > p { display: none; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy h2 { margin: 0 0 5px; font-size: 1.58rem; }
  main:has(.saga-detail-hero) .saga-volume { grid-template-columns: 32px 52px minmax(0, 1fr); min-height: 82px; padding: 6px 8px; gap: 8px; }
  main:has(.saga-detail-hero) .saga-volume .book-icon { width: 52px; height: 78px; flex-basis: 52px; }
  main:has(.saga-detail-hero) .saga-volume .book-content > p:not(.tag), main:has(.saga-detail-hero) .saga-volume .book-content > .action-row { display: none; }
  main:has(.saga-detail-hero) .saga-volume .book-content h3 { font-size: .98rem; }
  main:has(.saga-detail-hero) .library-section > .section-heading h2 { font: 400 1.9rem/1.05 Georgia, serif; letter-spacing: -.025em; }
  main:has(.saga-detail-hero) .saga-volume .book-content h3,
  main:has(.saga-detail-hero) .saga-volume .book-content h3 a { font: 400 1.05rem/1.08 Georgia, serif; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row .button { font-family: Georgia, serif; font-size: 1.05rem; }
  /* The editorial book group belongs to the background asset. Impost the
     first real cover over the hero's lead book so the saga remains dynamic
     without duplicating a full stack of covers over the artwork. */
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover:not(:first-child) { display: none; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover:first-child { width: 92px; height: 138px; inset: 42px 2px auto auto; z-index: 4; transform: rotate(-5deg); box-shadow: 3px 8px 14px rgb(36 49 43 / 28%); }
  main:has(.saga-detail-hero) .saga-detail-hero__copy h2 { font-size: 1.9rem; line-height: .98; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy .ds-progress { display: none; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy .saga-progress-dots { margin-top: 10px; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy > .action-row .button { width: 178px; min-height: 58px; border-radius: 18px; }
  /* Hero editorial en tres capas: placa horizontal, grupo separado y portada real. */
  main:has(.saga-detail-hero) .saga-detail-hero {
    background-image: linear-gradient(90deg, rgb(247 245 239 / 94%) 0%, rgb(247 245 239 / 64%) 34%, rgb(247 245 239 / 10%) 72%), url('/static/images/saga-detail-riverton-background.png');
    background-size: cover;
    background-position: center;
  }
  main:has(.saga-detail-hero) .saga-detail-hero__stack::before {
    content: "";
    position: absolute;
    inset: -2px -112px -8px -20px;
    z-index: 1;
    pointer-events: none;
    background: url('/static/images/saga-detail-riverton-book-group.png') center bottom / contain no-repeat;
    filter: drop-shadow(3px 8px 9px rgb(36 49 43 / 20%));
  }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover:first-child { z-index: 4; }
  main:has(.saga-detail-hero) .saga-detail-hero::after { content: ""; position: absolute; inset: 0; z-index: 6; pointer-events: none; background: url('/static/images/ux-riverton/volume-1-hero-rasterized.png') left top / 390px 292px no-repeat; }
  main:has(.saga-detail-hero) .saga-detail-hero__copy { position: relative; z-index: 7; }
  main:has(.saga-detail-hero) .saga-detail-hero__stack .saga-stack__cover:first-child { opacity: 0; }
  main:has(.saga-detail-hero) .saga-volume .book-content h3 > label { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; margin-right: 2px; color: var(--ds-terracotta); font: 700 .78rem/1 Georgia, serif; vertical-align: middle; }
  main:has(.saga-detail-hero) .saga-volume .book-content h3 > label input { width: 20px; height: 20px; margin: 0; accent-color: var(--ds-terracotta); }
}

@media (max-width: 480px) {
  main:has(.saga-detail-hero) .saga-detail-topbar { box-sizing: border-box; display: flex; flex-direction: row; justify-content: flex-start; align-items: center; height: 78px; min-height: 78px; margin: -16px -16px 0; padding: 7px 16px; overflow: hidden; }
  main:has(.saga-detail-hero) .saga-detail-topbar .context-back { flex: 0 0 44px; }
  main:has(.saga-detail-hero) .saga-detail-topbar > span { display: block; flex: 0 0 auto; margin-left: 14px; color: var(--ds-ink); font: 700 1.1rem/1 Georgia, serif; }
  main:has(.saga-detail-hero) .saga-detail-hero::after { display: none; }
  main:has(.saga-detail-hero) .saga-detail-hero { background-image: linear-gradient(90deg, rgb(247 245 239 / 94%) 0%, rgb(247 245 239 / 64%) 34%, rgb(247 245 239 / 10%) 72%), url('/static/images/saga-detail-riverton-background.png'); }
  main:has(.saga-detail-hero) .saga-detail-hero__stack::after { content: ""; position: absolute; left: -234px; top: -15px; width: 390px; height: 292px; z-index: 6; pointer-events: none; background: url('/static/images/ux-riverton/volume-1-hero-rasterized.png') left top / 390px 292px no-repeat; }
}

@media (max-width: 480px) {
  /* The active reading card is the first content block in the canonical
     mobile reference; its internal heading is redundant at this breakpoint. */
  body:has(.library-summary) .library-section > .section-heading { display: none !important; }
}

/* Desktop library hero: keep the active reading cover as the visual anchor. */
@media (min-width: 700px) {
  body:has(.home-summary) main > .hub-grid:first-of-type {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body:has(.library-summary) .library-section:not(.next-saga) .book-featured {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 38px;
    padding: 24px;
  }
  body:has(.library-summary) .library-section:not(.next-saga) .book-featured .book-icon {
    width: 300px;
    height: 450px;
    flex-basis: 300px;
  }
  body:has(.library-summary) .library-section:not(.next-saga) .book-featured h3 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2.45rem;
    font-weight: 400;
    line-height: 1.08;
  }
  body:has(.library-summary) .library-section:not(.next-saga) .book-featured .reading-status {
    margin-top: 34px;
    font-size: 1.25rem;
  }
  body:has(.library-summary) .library-section:not(.next-saga) .book-featured .button {
    min-height: 72px;
    margin-top: 26px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.2rem;
  }
}
