:root {
  --bg: #faf7f1;
  --surface: #ffffff;
  --surface-2: #f3eee4;
  --border: #e6dfd2;
  --ink: #211e1b;
  --muted: #6e665e;
  --accent: #2e5e4e;
  --accent-hover: #244b3e;
  --accent-soft: #e4eee9;
  --gold: #c08a3e;
  --danger: #b4452f;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(33, 30, 27, 0.06);
  --shadow: 0 10px 30px -12px rgba(33, 30, 27, 0.18);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: var(--accent); }

img { display: block; max-width: 100%; }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

/* ---------- Cabecera ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 247, 241, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.logo-img {
  height: 34px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
}

.logo-text {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.35rem;
}

.main-nav { display: flex; align-items: center; gap: 6px; }

.lang-picker {
  position: relative;
  margin-left: 4px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.lang-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lang-btn:active { transform: translateY(1px); }

.lang-globe,
.lang-chevron {
  width: 15px;
  height: 15px;
  fill: var(--muted);
  flex-shrink: 0;
}

.lang-btn[aria-expanded="true"] .lang-chevron {
  transform: rotate(180deg);
}

.lang-chevron { transition: transform 0.18s ease; }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 178px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 40;
  animation: langFade 0.14s ease-out;
}

@keyframes langFade {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.lang-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.lang-option:hover { background: var(--surface-2); }

.lang-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.lang-option-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.lang-code {
  display: inline-block;
  min-width: 26px;
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.lang-option.active .lang-code {
  background: var(--accent);
  color: #fff;
}

.lang-check {
  font-size: 0.85rem;
  color: var(--accent);
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.93rem;
  transition: background 0.15s, color 0.15s;
}

.main-nav a:hover { color: var(--ink); background: var(--surface-2); }
.main-nav a.active { color: var(--accent); background: var(--accent-soft); }

.count-pill {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  line-height: 20px;
  text-align: center;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--ink); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #000; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-lg { padding: 13px 24px; font-size: 1rem; }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }

/* ---------- Hero ---------- */
.hero {
  padding: 72px 0 56px;
  background:
    radial-gradient(900px 320px at 50% -10%, rgba(46, 94, 78, 0.12), transparent 70%),
    linear-gradient(var(--bg), var(--bg));
}

.hero-inner { text-align: center; max-width: 820px; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 700;
}

.hero h1 em { color: var(--accent); font-style: italic; }

.hero-sub {
  max-width: 620px;
  margin: 18px auto 34px;
  color: var(--muted);
  font-size: 1.08rem;
}

.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 10px;
  text-align: left;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 10px;
  background: var(--surface-2);
  border-radius: 12px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 12px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.search-form, .results-bar { display: flex; gap: 10px; }

.input-group {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 94, 78, 0.14);
}

.input-icon {
  width: 18px;
  height: 18px;
  margin-left: 14px;
  fill: var(--muted);
  flex-shrink: 0;
}

.input-group input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 12px 12px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  outline: none;
}

.input-group select {
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  padding: 0 12px;
  height: 28px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  outline: none;
}

.form-error {
  margin: 10px 4px 2px;
  color: var(--danger);
  font-size: 0.9rem;
}

.quick-picks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  font-size: 0.88rem;
  color: var(--muted);
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 13px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Features ---------- */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 8px 0 56px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.feature-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 700;
  margin-bottom: 14px;
}

.feature h3 { font-size: 1.15rem; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); font-size: 0.94rem; }

/* ---------- Secciones y rejilla ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 18px;
}

.section-head h2 { font-size: 1.6rem; }

.link { font-weight: 600; text-decoration: none; font-size: 0.92rem; }

.recent { margin-bottom: 64px; }

.results-bar { margin: 32px 0 28px; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 22px;
  margin-bottom: 24px;
}

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  padding: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #d6cdbd;
}

.book-card:focus-visible { outline: 3px solid rgba(46, 94, 78, 0.4); outline-offset: 2px; }

.card-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--surface-2);
  overflow: hidden;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(46, 94, 78, 0.92);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
}

.cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 14px;
  background: linear-gradient(160deg, #2e5e4e, #1d3d33);
  color: #f4efe6;
}

.cover-placeholder .ph-title {
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-placeholder .ph-author { font-size: 0.75rem; opacity: 0.8; }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; flex: 1; }

.card-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-author {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta { color: var(--muted); font-size: 0.76rem; margin-top: auto; padding-top: 6px; }

.skeleton-card .card-cover,
.skeleton-line {
  background: linear-gradient(90deg, #efe9de 25%, #f7f3ec 50%, #efe9de 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}

.skeleton-line { height: 12px; border-radius: 6px; margin-top: 6px; }
.skeleton-line.short { width: 60%; }

@keyframes shimmer { to { background-position: -200% 0; } }

.state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.state.error { color: var(--danger); }
.state .btn { margin-top: 12px; }

/* ---------- Detalle del libro ---------- */
.back-link {
  margin: 28px 0 20px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
}

.back-link:hover { color: var(--ink); }

.book-header {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
  align-items: start;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--border);
}

.book-cover-wrap {
  position: sticky;
  top: 90px;
}

.book-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px 12px 12px 6px;
  box-shadow: 0 22px 40px -18px rgba(33, 30, 27, 0.45), inset 4px 0 8px rgba(0,0,0,.12);
  background: var(--surface-2);
}

.book-cover-wrap .cover-placeholder {
  aspect-ratio: 2 / 3;
  border-radius: 6px 12px 12px 6px;
  box-shadow: 0 22px 40px -18px rgba(33, 30, 27, 0.45);
}

.book-info h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 700; }

.book-author { margin: 8px 0 18px; font-size: 1.15rem; color: var(--muted); }

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  margin: 0 0 18px;
}

.book-meta div { display: flex; flex-direction: column; }
.book-meta dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.book-meta dd { margin: 0; font-weight: 500; font-size: 0.94rem; }

.book-description {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 680px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.summary-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin: 22px 0 18px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  user-select: none;
}

.toggle input { position: absolute; opacity: 0; pointer-events: none; }

.toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #d8d0c2;
  position: relative;
  transition: background 0.15s;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}

.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid rgba(46, 94, 78, 0.35); }

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 10px;
}

.seg {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.seg.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.book-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Carga del resumen ---------- */
.summary-loading { padding: 56px 20px; text-align: center; }
.summary-loading p { margin: 6px 0; }
#loading-text { font-family: var(--serif); font-size: 1.2rem; }

.book-loader {
  display: inline-flex;
  gap: 6px;
  align-items: flex-end;
  height: 44px;
  margin-bottom: 16px;
}

.book-loader span {
  width: 12px;
  border-radius: 3px;
  background: var(--accent);
  animation: stack 1.1s infinite ease-in-out;
}

.book-loader span:nth-child(1) { height: 30px; }
.book-loader span:nth-child(2) { height: 42px; animation-delay: 0.15s; background: var(--gold); }
.book-loader span:nth-child(3) { height: 34px; animation-delay: 0.3s; background: #8a6f5a; }

@keyframes stack {
  0%, 100% { transform: scaleY(0.6); opacity: 0.6; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ---------- Resumen ---------- */
.summary { max-width: 820px; margin: 0 auto; padding: 40px 0 72px; }

.notice {
  padding: 14px 16px;
  margin-bottom: 22px;
  border-radius: 12px;
  background: #fbf0e3;
  border: 1px solid #efd7b8;
  color: #7a4a1a;
  font-size: 0.92rem;
}

.synopsis {
  margin: 0 0 28px;
  padding: 22px 26px;
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: var(--surface);
  font-family: var(--serif);
  font-size: 1.22rem;
  font-style: italic;
  line-height: 1.55;
}

.summary-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.summary-toc a {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
}

.summary-toc a:hover { border-color: var(--accent); color: var(--accent); }

.summary-section { padding-top: 28px; scroll-margin-top: 80px; }

.summary-section h2 {
  font-size: 1.75rem;
  margin: 18px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.summary-section p { margin: 0 0 14px; font-size: 1.03rem; }

.summary-part { margin-bottom: 26px; }

.summary-part h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.22rem;
  margin-bottom: 8px;
}

.part-num {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.character-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.character-filter .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.character {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  color: #fff;
  font-size: 1.05rem;
}

.character h4 { margin: 0; font-size: 1rem; font-family: var(--serif); font-weight: 600; }

.role {
  display: inline-block;
  margin: 3px 0 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.role.protagonista { color: #2e5e4e; }
.role.antagonista { color: var(--danger); }
.role.principal { color: #8a5a1f; }
.role.secundario { color: var(--muted); }

.character p { margin: 0; font-size: 0.9rem; color: var(--muted); line-height: 1.5; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.theme {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.theme h4 { margin: 0 0 6px; font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.theme p { margin: 0 !important; font-size: 0.92rem !important; color: var(--muted); }

.settings-list { margin: 0 0 8px; padding-left: 20px; }
.settings-list li { margin-bottom: 6px; }

.recommend {
  margin-top: 24px;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.recommend h3 { font-size: 1.1rem; margin-bottom: 6px; color: var(--accent); }
.recommend p { margin: 0 !important; }

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.source-pill:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.disclaimer {
  margin-top: 40px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

/* ---------- Biblioteca ---------- */
#view-library .muted { margin: -8px 0 24px; }

.card-remove {
  align-self: flex-start;
  margin-top: 8px;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}

.card-remove:hover { color: var(--danger); }

/* ---------- Pie y toast ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  font-size: 0.88rem;
}

.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  z-index: 50;
}

/* ---------- Barra inferior móvil (PWA) ---------- */
.mobile-nav {
  display: none;
}

@media (max-width: 720px) {
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .main-nav a {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    background: rgba(250, 247, 241, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 8px;
    border-radius: 12px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.74rem;
    font-weight: 600;
    transition: color 0.15s, background 0.15s;
  }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
  }

  .mobile-nav-item.active {
    color: var(--accent);
    background: var(--accent-soft);
  }

  .mobile-nav-icon-wrap {
    position: relative;
    display: inline-flex;
  }

  .mobile-count-pill {
    position: absolute;
    top: -4px;
    right: -10px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    line-height: 17px;
    text-align: center;
  }

  .toast {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .features { grid-template-columns: 1fr; }
  .book-header { grid-template-columns: 1fr; gap: 24px; }
  .book-cover-wrap { position: static; max-width: 200px; }
}

@media (max-width: 560px) {
  .container { padding: 0 16px; }
  .hero { padding: 48px 0 40px; }
  .search-form, .results-bar { flex-direction: column; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .main-nav a { padding: 8px 10px; }
  .synopsis { font-size: 1.08rem; padding: 18px; }
}
