:root {
  --ivory: #f7f2e7;
  --paper: #fbf8f1;
  --paper-2: #efe7d6;
  --ink: #1f1b16;
  --ink-2: #4a4239;
  --muted: #6b6155;
  --line: #ddd2bd;
  --green: #1f4a3a;
  --green-2: #2d6650;
  --green-soft: #e3ece5;
  --wine: #7a2335;
  --wine-soft: #f3e3e3;
  --gold: #a7843e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(40, 30, 15, .08), 0 6px 18px -8px rgba(40, 30, 15, .25);
  --shadow-lift: 0 2px 4px rgba(40, 30, 15, .08), 0 16px 30px -12px rgba(40, 30, 15, .35);
  --serif-display: "Fraunces", Georgia, "Times New Roman", serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wrap: 1200px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ivory); color: var(--ink);
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.6;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--green); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--wine); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--serif-display); font-weight: 600; line-height: 1.15; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); }
h2 { font-size: clamp(1.35rem, 2.4vw, 1.75rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--green); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.eyebrow { font-family: var(--sans); font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--wine); font-weight: 600; margin-bottom: .6em; }
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 60ch; }

/* Header */
.site-header { background: var(--ivory); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; backdrop-filter: saturate(1.2) blur(6px); background: color-mix(in srgb, var(--ivory) 92%, transparent); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif-display); font-weight: 600; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.brand-mark { color: var(--wine); font-size: 1.3rem; }
.main-nav { display: flex; gap: 4px; font-family: var(--sans); font-size: .95rem; overflow-x: auto; }
.main-nav a { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.main-nav a:hover { background: var(--paper-2); color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--green); box-shadow: inset 0 -2px 0 var(--green); border-radius: 0; }
@media (max-width: 640px) { .header-inner { padding-top: 8px; padding-bottom: 4px; } .main-nav { width: 100%; margin: 0 -12px; } }

/* Hero */
.hero { padding: 40px 0 28px; }
.hero-inner { display: grid; gap: 32px; align-items: center; grid-template-columns: 1fr; }
@media (min-width: 900px) { .hero-inner { grid-template-columns: 1.1fr 1fr; } .hero { padding: 56px 0 36px; } }
.hero h1 { margin-bottom: .3em; }
.search-hero { display: flex; gap: 8px; margin: 20px 0 12px; max-width: 560px; }
.search-hero input, .search-inline input {
  flex: 1; min-width: 0; font: inherit; font-family: var(--sans); font-size: 1rem; padding: 14px 16px; min-height: 48px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.04);
}
.search-hero input:focus, .search-inline input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search-hero button { font-family: var(--sans); font-weight: 600; padding: 0 22px; min-height: 48px; border-radius: 999px; border: 0; background: var(--green); color: #fff; cursor: pointer; }
.search-hero button:hover { background: var(--green-2); }
.hero-stats { font-family: var(--sans); font-size: .9rem; color: var(--muted); }
.hero-covers { position: relative; height: 300px; display: flex; justify-content: center; align-items: flex-end; }
.hero-covers a { width: 150px; margin-left: -46px; transition: transform .3s var(--ease); transform: var(--t); }
.hero-covers a:first-child { margin-left: 0; }
.hero-covers a:nth-child(1) { --t: rotate(-8deg) translateY(20px); }
.hero-covers a:nth-child(2) { --t: rotate(-4deg) translateY(8px); }
.hero-covers a:nth-child(3) { --t: rotate(0deg); z-index: 1; }
.hero-covers a:nth-child(4) { --t: rotate(4deg) translateY(8px); }
.hero-covers a:nth-child(5) { --t: rotate(8deg) translateY(20px); }
.hero-covers a:hover { transform: translateY(-10px); z-index: 3; }
@media (max-width: 899px) { .hero-covers { height: 220px; } .hero-covers a { width: 112px; margin-left: -36px; } }
@media (max-width: 420px) { .hero-covers a { width: 92px; margin-left: -30px; } .hero-covers { height: 180px; } }

/* Covers */
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 4px 6px 6px 4px; overflow: hidden; background: var(--paper-2); box-shadow: var(--shadow); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .25s ease; }
.cover img.ok { opacity: 1; background: var(--paper-2); }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.14) 0, rgba(255,255,255,.08) 3px, transparent 7px); pointer-events: none; }
.cover-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px; padding: 14% 12%; background: var(--green); color: #f4ecd9; border: 1px solid rgba(255,255,255,.1); }
.cover-fallback::before { content: ""; position: absolute; inset: 7%; border: 1px solid rgba(244, 236, 217, .45); border-radius: 2px; }
.cf-title { font-family: var(--serif-display); font-weight: 600; font-size: clamp(.8rem, 1.6vw, 1.15rem); line-height: 1.15; }
.cf-rule { width: 30%; height: 1px; background: var(--gold); }
.cf-author { font-family: var(--sans); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.cover-xs .cf-title { font-size: .5rem; } .cover-xs .cf-author { display: none; }
.cover-lg .cf-title { font-size: 1.6rem; } .cover-lg .cf-author { font-size: .85rem; }

/* Cards & grids */
.grid { display: grid; gap: 28px 20px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; } }
.grid-shelf { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: var(--ink); border-radius: var(--radius); }
.card .cover { transition: transform .22s var(--ease), box-shadow .22s var(--ease); }
.card:hover .cover, .card:focus-visible .cover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.card:hover { color: var(--ink); }
.card-title { font-size: 1.02rem; margin: 2px 0 2px; font-weight: 600; }
.card:hover .card-title { color: var(--green); }
.card-author { font-size: .92rem; color: var(--muted); margin: 0 0 6px; font-style: italic; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.card-badges:empty { display: none; }
.badge { font-family: var(--sans); font-size: .68rem; font-weight: 600; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); }
.badge-obra { background: var(--green); color: #fff; }
.badge-dest { background: var(--wine-soft); color: var(--wine); }
.badge-rec { background: var(--wine); color: #fff; }
.badge-demo { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; font-family: var(--sans); font-size: .74rem; color: var(--green); }
.tags li + li::before { content: "·"; margin-right: 10px; color: var(--line); }

/* Sections */
.shelf { padding: 28px 0; }
.shelf + .shelf { border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2, .section-head h3 { margin: 0; }
.section-head-sub { margin-top: 28px; }
.more { font-family: var(--sans); font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap; padding: 8px 0; }
.demo-note { font-family: var(--sans); font-size: .9rem; background: var(--paper); border: 1px dashed var(--gold); color: var(--ink-2); padding: 10px 14px; border-radius: 8px; margin: 4px 0 8px; }
.demo-note.small { font-size: .82rem; display: inline-block; }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); text-decoration: none; color: var(--ink); transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; }
.tile:hover { border-color: var(--green); transform: translateY(-2px); box-shadow: var(--shadow); color: var(--ink); }
.tile-covers { display: flex; flex: none; }
.tile-covers .cover { width: 34px; margin-left: -14px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.tile-covers .cover:first-child { margin-left: 0; }
.tile-text { display: flex; flex-direction: column; }
.tile-label { font-family: var(--serif-display); font-weight: 600; font-size: 1.05rem; }
.tile-count { font-family: var(--sans); font-size: .8rem; color: var(--muted); }
.theme-row + .theme-row { margin-top: 10px; }
.page-head { padding: 40px 16px 12px; }
.page-head-compact { padding-top: 28px; padding-bottom: 4px; }
.page-head-compact h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); }
@media (min-width: 720px) { .page-head { padding-left: 32px; padding-right: 32px; } }

/* Timeline (obra) */
.timeline { list-style: none; padding: 0; margin: 12px 0 48px; display: grid; gap: 28px 20px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 520px) { .timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tl-year { display: block; font-family: var(--serif-display); color: var(--wine); font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }

/* Buttons */
.btn { font-family: var(--sans); font-size: .92rem; font-weight: 600; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--green); color: var(--green); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-2); color: #fff; }
.btn-ghost { background: transparent; }

/* Book page */
.book { padding-bottom: 40px; }
.crumbs { font-family: var(--sans); font-size: .85rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; padding: 20px 0 8px; }
.crumbs a { color: var(--muted); }
.book-top { display: grid; gap: 28px; grid-template-columns: 1fr; padding: 12px 0 24px; }
@media (min-width: 820px) { .book-top { grid-template-columns: minmax(240px, 340px) 1fr; gap: 56px; } }
.book-cover { max-width: 300px; width: 70%; margin: 0 auto; }
@media (min-width: 820px) { .book-cover { width: 100%; max-width: none; position: sticky; top: 96px; align-self: start; } }
.credit { font-family: var(--sans); font-size: .72rem; color: var(--muted); margin-top: 8px; text-align: center; }
.book-title { margin-bottom: .15em; }
.book-subtitle { font-size: 1.2rem; color: var(--ink-2); font-style: italic; margin: 0 0 .4em; }
.book-author { font-size: 1.2rem; margin-bottom: 12px; }
.book-author a { text-decoration: none; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.book-author a:hover { color: var(--wine); border-color: var(--wine); }
.actions { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
.copy-status { font-family: var(--sans); font-size: .85rem; color: var(--green); }
.synopsis { margin-top: 20px; max-width: 68ch; }
.synopsis h2, .recommendation h2, .book-details h2, .related h2 { font-size: 1.2rem; }
.synopsis p { font-size: 1.1rem; }
.origin { font-family: var(--sans); font-size: .8rem !important; color: var(--muted); }
.recommendation { margin-top: 28px; max-width: 68ch; background: var(--wine-soft); border-left: 4px solid var(--wine); border-radius: 0 var(--radius) var(--radius) 0; padding: 20px 24px; }
.recommendation h2 { color: var(--wine); }
.recommendation blockquote { margin: 0; font-size: 1.15rem; font-style: italic; }
.recommendation footer { font-style: normal; font-family: var(--sans); font-size: .88rem; color: var(--wine); margin-top: 8px; }
.book-details { display: grid; gap: 28px; grid-template-columns: 1fr; border-top: 1px solid var(--line); padding-top: 28px; }
@media (min-width: 820px) { .book-details { grid-template-columns: 1fr 1fr; } }
.facts { margin: 0; display: grid; gap: 0; }
.facts div { display: grid; grid-template-columns: 11rem 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dotted var(--line); }
@media (max-width: 480px) { .facts div { grid-template-columns: 1fr; gap: 0; } }
.facts dt { font-family: var(--sans); font-size: .82rem; color: var(--muted); }
.facts dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-family: var(--sans); font-size: .85rem; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); text-decoration: none; color: var(--ink-2); min-height: 36px; display: inline-flex; align-items: center; }
.chip:hover { border-color: var(--green); color: var(--green); }
.chip-strong { background: var(--green-soft); border-color: transparent; color: var(--green); font-weight: 600; }
.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-family: var(--sans); }
.links a { display: inline-block; padding: 6px 0; }
.sources { grid-column: 1 / -1; font-family: var(--sans); font-size: .85rem; color: var(--muted); }
.sources summary { cursor: pointer; padding: 8px 0; }
.related { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 28px; }

/* Catalog */
.catalog { display: grid; gap: 32px; grid-template-columns: 1fr; padding-bottom: 48px; }
@media (min-width: 960px) { .catalog { grid-template-columns: 270px 1fr; } }
.filters { font-family: var(--sans); font-size: .92rem; }
@media (min-width: 960px) {
  .filters { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; padding-right: 8px; }
  .filters-head .btn-close, #show-results, .btn-filters { display: none !important; }
}
.filters-head { display: flex; justify-content: space-between; align-items: center; }
.filters-head h2 { font-size: 1.15rem; margin: 0; }
.btn-close { font-size: 1.6rem; line-height: 1; width: 44px; height: 44px; border: 0; background: transparent; cursor: pointer; color: var(--ink); border-radius: 50%; }
.fgroup { border-top: 1px solid var(--line); padding: 12px 0; }
.fgroup:first-child { border-top: 0; }
.fgroup > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; padding: 6px 0; min-height: 36px; }
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::after { content: "+"; font-weight: 400; color: var(--muted); font-size: 1.2rem; }
.fgroup[open] > summary::after { content: "–"; }
.fgroup .opts { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.opt { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 6px; cursor: pointer; min-height: 36px; }
.opt:hover { background: var(--paper-2); }
.opt input { width: 18px; height: 18px; accent-color: var(--green); margin: 0; flex: none; }
.opt .n { margin-left: auto; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.opt.disabled { opacity: .45; }
.opt.sub { padding-left: 26px; }
.range { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.range input { width: 100%; min-width: 0; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); min-height: 40px; }
.range-hint { font-size: .78rem; color: var(--muted); margin: 6px 0 0; }
.show-more-opts { background: none; border: 0; color: var(--green); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 4px; text-align: left; }
.filters-foot { display: flex; gap: 8px; padding: 14px 0 4px; border-top: 1px solid var(--line); }
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.search-inline { display: flex; }
.toolbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-family: var(--sans); }
.result-count { margin: 0 auto 0 0; color: var(--ink-2); font-size: .95rem; }
.sort select { font: inherit; font-size: .9rem; padding: 0 34px 0 12px; min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234a4239' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center; appearance: none; color: var(--ink); cursor: pointer; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.view-toggle button { border: 0; background: var(--paper); min-width: 44px; min-height: 42px; font-size: 1.05rem; cursor: pointer; color: var(--muted); }
.view-toggle button[aria-pressed="true"] { background: var(--green); color: #fff; }
.count-pill { background: var(--wine); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 7px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--sans); }
.active-filters:empty { display: none; }
.fchip { display: inline-flex; align-items: center; gap: 6px; background: var(--green-soft); color: var(--green); border: 0; border-radius: 999px; padding: 6px 8px 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; min-height: 36px; }
.fchip span[aria-hidden] { font-size: 1.1rem; line-height: 1; }
.fchip:hover { background: var(--green); color: #fff; }
.linkish { background: none; border: 0; font: inherit; font-size: .85rem; color: var(--wine); text-decoration: underline; cursor: pointer; padding: 6px; }
.grid-catalog { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
@media (max-width: 520px) { .grid-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid-catalog.list { grid-template-columns: 1fr; gap: 0; }
.grid-catalog.list .card { flex-direction: row; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.grid-catalog.list .cover { width: 76px; flex: none; }
.grid-catalog.list .card-body { display: flex; flex-direction: column; justify-content: center; }
.grid-catalog.list .card-syn { display: block; }
.card-syn { display: none; color: var(--ink-2); font-size: .95rem; margin: 4px 0 6px; max-width: 70ch; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.grid-catalog:not(.list) .card-syn { display: none; }
.load-more-wrap { display: flex; justify-content: center; margin-top: 32px; }
.empty { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; font-family: var(--sans); }
.empty h2 { font-family: var(--serif-display); }
.empty ul { margin: 8px 0 16px; padding-left: 1.2em; }
.scrim { position: fixed; inset: 0; background: rgba(31, 27, 22, .45); z-index: 40; }
@media (max-width: 959px) {
  .filters { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; max-height: 86vh; background: var(--ivory); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.2); display: flex; flex-direction: column; transform: translateY(105%); visibility: hidden; transition: transform .28s var(--ease), visibility 0s linear .28s; }
  .filters.open { transform: none; visibility: visible; transition: transform .28s var(--ease); }
  .filters-head { padding: 12px 16px 4px; }
  .filters-body { overflow: auto; padding: 0 16px; flex: 1; overscroll-behavior: contain; }
  .filters-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .filters-foot .btn { flex: 1; justify-content: center; }
  .result-count { order: 3; width: 100%; }
}

/* About */
.about { display: grid; gap: 32px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .about { grid-template-columns: 300px 1fr; } }
.about-photo { border-radius: var(--radius); box-shadow: var(--shadow); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--paper); padding: 28px 0; font-family: var(--sans); font-size: .88rem; margin-top: 24px; }
.footer-inner p { margin: 0 0 6px; }

/* Entrada suave */
@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise .35s var(--ease) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
