/* ============================================================
   Lectorium — Design system "Modern Bibliophile"
   Tokens tomados del proyecto Stitch "Club de Lectura Digital".
   Playfair Display (títulos) + Source Sans 3 (texto) + Material Symbols.
   ============================================================ */

:root {
  /* Superficies (papel envejecido) */
  --background: #fbf9f8;
  --surface: #fbf9f8;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f5f3f3;
  --surface-container: #efeded;
  --surface-container-high: #eae8e7;
  --surface-container-highest: #e4e2e2;
  --surface-variant: #e4e2e2;

  /* Tinta / texto */
  --on-surface: #1b1c1c;
  --on-surface-variant: #44474c;
  --outline: #74777d;
  --outline-variant: #c4c6cc;

  /* Primario — tinta de medianoche */
  --primary: #041525;
  --on-primary: #ffffff;
  --primary-container: #1a2a3a;
  --on-primary-container: #8191a5;

  /* Secundario — madera cálida */
  --secondary: #7d562d;
  --on-secondary: #ffffff;
  --secondary-container: #ffca98;
  --on-secondary-container: #7a532a;
  --secondary-fixed: #ffdcbd;

  /* Estados */
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #93000a;
  --success: #4b6b3a;

  /* Radios */
  --radius-sm: 0.25rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Espaciado (base 4px) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;
  --gutter: 24px;
  --container-max: 1120px;

  /* Tipografía */
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, sans-serif;

  /* Sombras suaves (elevación tonal, no dura) */
  --shadow-ambient: 0 4px 12px rgba(4, 21, 37, 0.05);
  --shadow-float: 0 8px 28px rgba(4, 21, 37, 0.10);

  --bottomnav-h: 68px;
}

/* ---------- Reset ligero ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--on-surface);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: inherit; }

/* ---------- Tipografía ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 8vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--primary);
  margin: 0;
}
.headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 6vw, 32px);
  line-height: 1.2;
  color: var(--primary);
  margin: 0;
}
.title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.4;
  color: var(--primary);
  margin: 0;
}
.subtitle {
  font-size: 18px;
  line-height: 1.55;
  color: var(--on-surface-variant);
  margin: 0;
}
.label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}
.caption {
  font-size: 12px;
  line-height: 1.4;
  color: var(--on-surface-variant);
}
.muted { color: var(--on-surface-variant); }

/* ---------- Iconos ---------- */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}
.material-symbols-outlined.fill { font-variation-settings: 'FILL' 1; }
.icon-sm { font-size: 18px; }

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) calc(var(--bottomnav-h) + var(--space-xl));
}
@media (min-width: 768px) {
  .container { padding-left: var(--space-xl); padding-right: var(--space-xl); }
}

/* Barra superior */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--outline-variant) 30%, transparent);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
}
.topbar__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.01em;
  color: var(--primary);
}
.topbar__action {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  border-radius: var(--radius-full);
  color: var(--on-surface-variant);
  transition: background .15s, transform .15s;
}
.topbar__action:hover { background: var(--surface-container-high); }
.topbar__action:active { transform: scale(.94); }

/* Nav inferior */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  z-index: 50;
  height: var(--bottomnav-h);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 var(--space-sm) env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid color-mix(in srgb, var(--outline-variant) 30%, transparent);
}
.bottomnav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 48px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--on-surface-variant);
  transition: transform .15s, background .15s, color .15s;
}
.bottomnav__item span:last-child { font-size: 10px; font-weight: 600; letter-spacing: .02em; }
.bottomnav__item:active { transform: scale(.9); }
.bottomnav__item--active {
  color: var(--on-secondary-container);
}
.bottomnav__item--active .material-symbols-outlined { font-variation-settings: 'FILL' 1; }
.bottomnav__item--active::before {
  content: "";
  position: absolute;
}
.bottomnav__pill {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border-radius: var(--radius-full);
  padding-inline: var(--space-md);
  flex: 0 0 auto;
}

/* ---------- Encabezado de página ---------- */
.page-head { margin-bottom: var(--space-xl); }
.page-head .display + .subtitle { margin-top: var(--space-sm); max-width: 60ch; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s, color .18s, border-color .18s, transform .12s, box-shadow .18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-container); }
.btn--secondary {
  background: transparent;
  color: var(--secondary);
  border-color: color-mix(in srgb, var(--secondary) 45%, transparent);
}
.btn--secondary:hover { background: color-mix(in srgb, var(--secondary-container) 40%, transparent); }
.btn--ghost { background: transparent; color: var(--on-surface); }
.btn--ghost:hover { background: var(--surface-container-high); }
.btn--danger { background: transparent; color: var(--error); }
.btn--danger:hover { background: color-mix(in srgb, var(--error) 10%, transparent); }
.btn--full { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--icon { padding: 10px; width: 40px; height: 40px; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-md); }
.field > label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--on-surface-variant);
}
.input, .textarea, select.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-container-low);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  color: var(--on-surface);
  transition: border-color .18s, background .18s;
}
.input::placeholder, .textarea::placeholder { color: var(--outline); }
.input:focus, .textarea:focus, select.input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
  background: var(--surface-container-lowest);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }

/* Alerta / error de formulario */
.form-error {
  background: var(--error-container);
  color: var(--on-error-container);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface-container-lowest);
  border: 1px solid color-mix(in srgb, var(--outline-variant) 30%, transparent);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.card + .card { margin-top: var(--space-md); }

/* Rejilla auto-responsiva */
.grid { display: grid; gap: var(--space-lg); grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid--books { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }

/* Tarjeta de libro */
.book-card {
  background: var(--surface-container-lowest);
  border: 1px solid color-mix(in srgb, var(--outline-variant) 25%, transparent);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: border-color .3s, transform .3s, box-shadow .3s;
}
.book-card:hover {
  border-color: color-mix(in srgb, var(--primary) 22%, transparent);
  box-shadow: var(--shadow-ambient);
}
.book-cover {
  aspect-ratio: 3 / 4;
  width: 100%;
  position: relative;
  background: var(--surface-container-low);
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.book-card:hover .book-cover img { transform: scale(1.05); }
.book-cover__placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--outline);
}
.book-cover__placeholder .material-symbols-outlined { font-size: 48px; }
.book-card__body { padding: var(--space-md); display: flex; flex-direction: column; flex-grow: 1; }
.book-card__title { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--primary); margin: 0 0 2px; }
.book-card__author { font-size: 15px; color: var(--on-surface-variant); margin: 0; }
.book-card__foot {
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid color-mix(in srgb, var(--outline-variant) 25%, transparent);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--on-surface-variant);
}

/* ---------- Chips / etiquetas ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.chip--wood { background: var(--secondary-container); color: var(--on-secondary-container); }
.chip--neutral { background: var(--surface-container-high); color: var(--on-surface-variant); }
.chip--ink { background: var(--primary); color: var(--on-primary); }
.chip--cover {
  position: absolute; top: 12px; right: 12px;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--secondary-container) 90%, transparent);
  color: var(--on-secondary-container);
  backdrop-filter: blur(4px);
}

/* ---------- Avatar ---------- */
.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.avatar--sm { width: 32px; height: 32px; font-size: 14px; }
.avatar--md { width: 44px; height: 44px; font-size: 18px; }
.avatar--lg { width: 72px; height: 72px; font-size: 30px; }

/* ---------- Barra de progreso ---------- */
.progress {
  height: 8px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress__bar { height: 100%; background: var(--secondary); border-radius: var(--radius-full); transition: width .4s ease; }

.member-progress { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-sm) 0; }
.member-progress__meta { flex: 1; min-width: 0; }
.member-progress__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-sm); margin-bottom: 4px; }

/* ---------- Estrellas ---------- */
.estrellas, .estrellas-picker { display: inline-flex; gap: 2px; font-size: 18px; line-height: 1; }
.estrellas-picker { cursor: pointer; }
.star, .sp-star { color: var(--outline-variant); }
.star--filled, .sp-filled { color: var(--secondary); }

/* ---------- Comentarios ---------- */
.comment {
  background: var(--surface-container-low);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-top: var(--space-md);
}
.comment--reply { margin-left: var(--space-lg); background: var(--surface-container); }
.comment__head { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: 6px; }
.comment__author { font-family: var(--font-display); font-weight: 600; color: var(--primary); }
.comment__time { font-size: 12px; color: var(--outline); }
.comment__body { margin: 4px 0; line-height: 1.55; }
.comment__actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; margin-top: 6px; }
.comment__actions button { background: none; border: none; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); padding: 4px 6px; border-radius: var(--radius-sm); }
.comment__actions button:hover { background: var(--surface-container-high); }

.reaction {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container-lowest);
  border-radius: var(--radius-full);
  padding: 2px 10px; font-size: 13px; cursor: pointer;
}
.reaction--mine { border-color: var(--primary); background: color-mix(in srgb, var(--secondary-container) 40%, transparent); }
.reaction-picker button { border: none; background: none; font-size: 16px; cursor: pointer; opacity: .55; padding: 2px 4px; }
.reaction-picker button:hover { opacity: 1; }

/* ---------- Cita destacada ---------- */
.quote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  line-height: 1.5;
  color: var(--primary);
  padding: var(--space-sm) 0 var(--space-sm) var(--space-lg);
  position: relative;
  margin: var(--space-md) 0;
}
.quote::before {
  content: "\201C";
  position: absolute;
  left: -2px; top: -6px;
  font-size: 44px;
  color: var(--secondary);
  line-height: 1;
}
.quote__author { display: block; font-family: var(--font-body); font-style: normal; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); margin-top: 4px; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list__item {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid color-mix(in srgb, var(--outline-variant) 25%, transparent);
  text-decoration: none; color: inherit;
}
.list__item:last-child { border-bottom: none; }
.list__item--unread { background: color-mix(in srgb, var(--secondary-container) 22%, transparent); border-radius: var(--radius); padding-inline: var(--space-md); }

/* Fila de capítulo */
.chapter-row {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  background: var(--surface-container-lowest);
  border: 1px solid color-mix(in srgb, var(--outline-variant) 22%, transparent);
  text-decoration: none; color: inherit;
  margin-bottom: var(--space-sm);
  transition: border-color .2s, transform .2s;
}
.chapter-row:hover { border-color: color-mix(in srgb, var(--primary) 20%, transparent); }
.chapter-row__num {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--surface-container-high);
  font-family: var(--font-display); font-weight: 600; color: var(--primary);
}
.chapter-row__num--read { background: var(--primary); color: var(--on-primary); }
.chapter-row__meta { flex: 1; min-width: 0; }
.chapter-row__readers { display: flex; margin-left: auto; }
.chapter-row__readers .avatar { margin-left: -8px; border: 2px solid var(--surface-container-lowest); }

/* ---------- Selección múltiple de capítulos ---------- */
/* Modo que se activa con body.selecting, igual que body.managing. */
.cap-item { position: relative; }

body.selecting .chapter-row { cursor: pointer; user-select: none; }
body.selecting .chapter-row__readers { display: none; }

/* El recuadro del número hace de casilla: número → check al seleccionar. */
.cap-check { display: none; font-size: 22px; }
body.selecting .cap-item--sel .cap-check { display: block; }
body.selecting .cap-item--sel .cap-num { display: none; }

body.selecting .cap-item--sel .chapter-row {
  border-color: var(--secondary);
  background: color-mix(in srgb, var(--secondary-fixed) 45%, var(--surface-container-lowest));
}
body.selecting .cap-item--sel .chapter-row__num { background: var(--secondary); color: var(--on-secondary); }

/* Los ya leídos quedan fuera del modo selección. */
body.selecting .cap-item--leido { opacity: .45; }
body.selecting .cap-item--leido .chapter-row { cursor: default; }

/* Atajo «hasta aquí»: ocupa el hueco que dejan los avatares. */
.cap-upto {
  position: absolute; right: var(--space-md); top: 50%;
  transform: translateY(-50%);
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  background: var(--surface-container-lowest);
  color: var(--on-surface-variant);
  cursor: pointer; z-index: 2;
  transition: color .2s, border-color .2s;
}
.cap-upto:hover { color: var(--secondary); border-color: var(--secondary); }
.cap-upto:active { transform: translateY(-50%) scale(.94); }
body.selecting .cap-item:not(.cap-item--leido) .cap-upto { display: flex; }

/* Barra de acción, justo encima de la nav inferior. */
.selectbar {
  position: fixed; left: 0; right: 0;
  bottom: var(--bottomnav-h);
  z-index: 90;
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-sm) var(--space-md) calc(var(--space-sm) + env(safe-area-inset-bottom));
  background: var(--surface-container-lowest);
  border-top: 1px solid var(--outline-variant);
  box-shadow: var(--shadow-float);
  /* Fuera de pantalla del todo: su alto + el de la nav inferior. */
  transform: translateY(calc(100% + var(--bottomnav-h)));
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.22, 1, .36, 1), opacity .2s ease-out;
}
body.selecting .selectbar { transform: none; opacity: 1; pointer-events: auto; }
.selectbar__count { flex: 1; min-width: 0; font-size: 14px; color: var(--on-surface-variant); }
.selectbar__count strong { font-family: var(--font-display); font-size: 17px; color: var(--primary); }
body.selecting .container { padding-bottom: calc(var(--bottomnav-h) + 96px); }

/* ---------- Edición en línea (comentarios y citas) ---------- */
.edit-form { margin-top: var(--space-sm); }
.edit-form .textarea { margin-bottom: var(--space-sm); }
.edit-form .row { gap: var(--space-sm); }

/* Marca discreta de contenido editado. */
.edited { font-size: 12px; color: var(--on-surface-variant); font-style: normal; }

/* Acciones de una cita: mismo lenguaje que .comment__actions. */
.quote__actions { display: flex; gap: var(--space-sm); margin-top: var(--space-xs); }
.quote__actions button {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  color: var(--on-surface-variant);
  padding: 4px 6px; border-radius: var(--radius-sm);
}
.quote__actions button:hover { background: var(--surface-container-high); }

/* ---------- Estado vacío ---------- */
.empty {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--on-surface-variant);
}
.empty .material-symbols-outlined { font-size: 48px; color: var(--outline-variant); margin-bottom: var(--space-sm); }
.empty__title { font-family: var(--font-display); font-size: 20px; color: var(--primary); margin: 0 0 4px; }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + var(--space-md));
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--space-sm);
  z-index: 100; width: max-content; max-width: 90vw;
}
.toast {
  background: var(--primary);
  color: var(--on-primary);
  padding: 12px 18px;
  border-radius: var(--radius-full);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-float);
  animation: toast-in .25s cubic-bezier(.22,1,.36,1);
}
.toast--error { background: var(--error); color: var(--on-error); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Utilidades ---------- */
.stack { display: flex; flex-direction: column; gap: var(--space-md); }
.stack--sm { gap: var(--space-sm); }
.stack--lg { gap: var(--space-lg); }
.row { display: flex; align-items: center; gap: var(--space-md); }
.row--between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--primary);
  margin: var(--space-xl) 0 var(--space-md);
}
.divider { height: 1px; background: color-mix(in srgb, var(--outline-variant) 30%, transparent); border: none; margin: var(--space-lg) 0; }
.text-danger { color: var(--error); }

/* Interruptor (toggle) */
.switch { position: relative; display: inline-flex; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track { width: 46px; height: 28px; border-radius: var(--radius-full); background: var(--surface-container-highest); transition: background .2s; position: relative; pointer-events: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: var(--radius-full); background: var(--surface-container-lowest); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + .switch__track { background: var(--secondary); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch--sm .switch__track { width: 38px; height: 22px; }
.switch--sm .switch__track::after { width: 16px; height: 16px; }
.switch--sm input:checked + .switch__track::after { transform: translateX(16px); }

/* Selector de color de usuario */
.color-swatch { width: 40px; height: 40px; border-radius: var(--radius-full); border: 3px solid transparent; cursor: pointer; padding: 0; transition: transform .15s; }
.color-swatch:hover { transform: scale(1.08); }
.color-swatch--active { border-color: var(--on-surface); }

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

/* ---------- El recuerdo (estadísticas de un libro) ---------- */
.rec-head {
  display: flex;
  gap: var(--space-lg);
  align-items: flex-start;
  margin-bottom: var(--space-lg);
}
.rec-head__text { flex: 1; min-width: 0; }
.rec-head .label { font-size: 12px; letter-spacing: .14em; color: var(--secondary); }
.rec-head .display { margin-top: 6px; }
.rec-head__cover {
  width: 84px;
  flex-shrink: 0;
  aspect-ratio: 3/4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-container-low);
  box-shadow: var(--shadow-ambient);
  transform: rotate(2deg);
}
.rec-head__cover img { width: 100%; height: 100%; object-fit: cover; }

.rec-nota {
  font-size: 14px;
  line-height: 1.5;
  color: var(--on-surface-variant);
  border-top: 1px solid var(--outline-variant);
  border-bottom: 1px solid var(--outline-variant);
  padding: var(--space-sm) 0;
  margin: 0 0 var(--space-xl);
  max-width: 62ch;
}

.rec-section { margin-bottom: var(--space-xl); }

/* Cifras: rejilla de papel pautado, sin tarjetas */
.rec-tally {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  column-gap: var(--space-lg);
  border-bottom: 1px solid var(--outline-variant);
}
.rec-tally__item {
  padding: var(--space-md) 0;
  border-top: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rec-tally__num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 7vw, 38px);
  line-height: 1;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.rec-tally__label { font-size: 15px; font-weight: 600; color: var(--on-surface); }
.rec-tally__note { font-size: 12px; line-height: 1.35; color: var(--on-surface-variant); }

/* Retratos */
.rec-portraits { list-style: none; margin: 0; padding: 0; }
.rec-portrait {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  padding: var(--space-md) 0;
  border-bottom: 1px solid color-mix(in srgb, var(--outline-variant) 55%, transparent);
}
.rec-portrait:last-child { border-bottom: none; }
.rec-portrait__faces { display: flex; flex-shrink: 0; }
.rec-portrait__body { flex: 1; min-width: 0; }
.rec-portrait__faces .avatar + .avatar { margin-left: -12px; border: 2px solid var(--background); }
.rec-portrait__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--primary);
  margin: 0;
}
.rec-portrait__who { margin: 0; font-size: 15px; font-weight: 700; }
.rec-portrait__detail { margin: 2px 0 0; font-size: 15px; line-height: 1.45; color: var(--on-surface-variant); max-width: 52ch; }

.rec-emojis { margin: var(--space-md) 0 0; font-size: 13px; color: var(--on-surface-variant); }
.rec-emoji { display: inline-flex; align-items: center; gap: 4px; margin-left: var(--space-sm); font-size: 16px; }
.rec-emoji span { font-size: 12px; font-weight: 700; color: var(--on-surface-variant); }

/* Momentos */
.rec-moment {
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
}
.rec-moment__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--primary);
  margin: 0 0 2px;
}
.rec-moment__text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--on-surface-variant); }
.rec-moment__quote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  line-height: 1.45;
  color: var(--primary);
  margin: var(--space-sm) 0 0;
  padding: 0;
}
.rec-moment__quote cite { display: block; font-family: var(--font-body); font-style: normal; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); margin-top: 4px; }
.rec-moment__spoiler { display: flex; align-items: center; gap: 6px; margin: var(--space-sm) 0 0; font-size: 13px; color: var(--outline); }
.rec-moment__emojis { margin: var(--space-sm) 0 0; }
.rec-moment__emojis .rec-emoji { margin: 0 var(--space-sm) 0 0; }
.rec-moment__link { display: inline-block; margin-top: var(--space-sm); font-size: 13px; font-weight: 700; color: var(--secondary); text-decoration: none; }
.rec-moment__link:hover { text-decoration: underline; }

/* Cada uno en cifras */
.rec-people { list-style: none; margin: 0; padding: 0; }
.rec-people .member-progress { align-items: flex-start; padding: var(--space-md) 0; border-bottom: 1px solid color-mix(in srgb, var(--outline-variant) 55%, transparent); }
.rec-people .member-progress:last-child { border-bottom: none; }
.rec-people .avatar { margin-top: 2px; }
.rec-person__meta { margin: 6px 0 0; font-size: 13px; line-height: 1.4; color: var(--on-surface-variant); }

/* Nota final */
.rec-score { display: flex; align-items: center; gap: var(--space-md); }
.rec-score__num { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; color: var(--primary); }

@media (min-width: 700px) {
  .rec-head__cover { width: 120px; }
  .rec-tally { grid-template-columns: repeat(4, 1fr); }
  .rec-moment { max-width: 68ch; }
}

/* Aparición escalonada al abrir el recuerdo (sutil, como pasar páginas) */
@media (prefers-reduced-motion: no-preference) {
  .rec-head, .rec-nota, .rec-section {
    animation: rec-in .55s cubic-bezier(.16, 1, .3, 1) backwards;
  }
  .rec-nota { animation-delay: .06s; }
  .rec-section:nth-of-type(1) { animation-delay: .12s; }
  .rec-section:nth-of-type(2) { animation-delay: .18s; }
  .rec-section:nth-of-type(3) { animation-delay: .24s; }
  .rec-section:nth-of-type(4) { animation-delay: .30s; }
  .rec-section:nth-of-type(5) { animation-delay: .36s; }
  .rec-section:nth-of-type(6) { animation-delay: .42s; }
  @keyframes rec-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
  }
}
