@import './tokens.css';

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: #0f0e0d;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

#app { width: 100%; display: flex; justify-content: center; }

.device {
  width: var(--device-w);
  height: var(--device-h);
  max-height: 95dvh;
  background: var(--paper);
  border-radius: 44px;
  overflow: hidden;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 40px 80px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
}

.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  padding: 16px 28px 0;
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

.status-bar__icons { font-size: 12px; letter-spacing: 1px; opacity: 0.7; }

.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  background: var(--paper);
}

.screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px);
  background: var(--paper);
}

.screen--scroll { padding-left: 20px; padding-right: 20px; }
.screen__sticky {
  flex-shrink: 0;
  z-index: 5;
  background: var(--paper);
  padding-bottom: 8px;
  transition: padding-bottom 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
.screen__sticky--chrome-hidden { padding-bottom: 0; }
.screen__sticky--scrolled .library-search-row .search-bar {
  box-shadow: 0 2px 12px rgba(28, 25, 23, 0.07);
}
.screen__sticky--scrolled {
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.06);
}
.screen__sticky--chrome-hidden .library-search-row {
  margin-bottom: 6px;
}

/* Collapsing header — scroll único; contenido pasa bajo cabecera transparente */
.screen--collapsing {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.screen__scroll--collapsing {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
}
.screen--collapsing:not(.screen--detail) .screen__scroll--collapsing {
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 20px);
}
.screen--collapsing.screen--detail .screen__scroll--collapsing {
  padding-bottom: calc(var(--safe-bottom) + 20px);
}
.screen--collapsing .screen__sticky {
  position: sticky;
  top: 0;
  background: transparent;
  padding: 0 20px 8px;
  box-shadow: none;
  --header-frost: 0;
  isolation: isolate;
}
.screen--collapsing .screen__sticky > * {
  position: relative;
  z-index: 1;
}
/* Degradado opaco arriba → transparente abajo; sin blur */
.screen--collapsing .screen__sticky::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: calc(100% + 52px);
  z-index: 0;
  pointer-events: none;
  opacity: var(--header-frost);
  background: linear-gradient(
    180deg,
    var(--paper) 0%,
    var(--paper) 52%,
    color-mix(in srgb, var(--paper) 96%, transparent) 68%,
    color-mix(in srgb, var(--paper) 78%, transparent) 78%,
    color-mix(in srgb, var(--paper) 52%, transparent) 86%,
    color-mix(in srgb, var(--paper) 28%, transparent) 92%,
    color-mix(in srgb, var(--paper) 10%, transparent) 96%,
    transparent 100%
  );
  transition: opacity 0.22s ease;
}
.screen--collapsing .collapsing-content {
  padding: 0 20px;
}
.screen--collapsing .screen__sticky--scrolled {
  padding-bottom: 4px;
}
.screen--collapsing .screen__sticky--scrolled .collapsing-header,
.screen--collapsing .screen__sticky--scrolled .large-header {
  margin-bottom: 0;
}
.screen--collapsing .screen__sticky--chrome-hidden {
  padding-bottom: 0;
}
.screen--collapsing .screen__sticky--chrome-hidden .collapsing-chrome,
.screen--collapsing .screen__sticky--chrome-hidden .library-chrome {
  display: none;
}
.home-sub {
  color: var(--ink-secondary);
  font-size: 15px;
  margin: 0 0 16px;
}
.collapsing-chrome__subtitle {
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 4px;
}
.providers-footer {
  padding: 16px 0 8px;
}
.screen--camera { background: #000; color: #fff; padding-bottom: var(--safe-bottom); }
.screen--detail { padding-bottom: var(--safe-bottom); }
.screen--onboarding {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 32px var(--safe-bottom);
  padding-bottom: calc(var(--safe-bottom) + 24px);
}

/* Typography */
.large-header { margin-bottom: 20px; }
.large-header h1 {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.large-header--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.large-header__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
}
.large-header__brand .icon { width: 22px; height: 22px; color: var(--accent); fill: var(--accent); stroke: var(--accent); }
.large-header__sub { color: var(--ink-secondary); font-size: 15px; margin-top: 4px; }

.section { margin-bottom: 28px; }
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section__head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.section__footer {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}
.author-detail-list .search-row:last-child { border-bottom: none; }

/* Covers */
.cover {
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(28,25,23,0.18);
  flex-shrink: 0;
}
.cover--sm { width: 48px; height: 72px; }
.cover--md { width: 100%; aspect-ratio: 2/3; }
.cover--lg { width: 72px; height: 108px; }
.cover--xl { width: 140px; height: 210px; margin: 0 auto 16px; }
.cover__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  padding: 4px;
  text-align: center;
}
.cover--xl .cover__label { font-size: 16px; }
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover--fallback {
  background: linear-gradient(145deg, var(--accent) 0%, #1a4d37 100%);
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--badge-color) 14%, transparent);
  color: var(--badge-color);
}
.badge--muted { background: var(--paper-muted); color: var(--ink-tertiary); --badge-color: var(--ink-tertiary); }

/* Hero card — ref Speechify continue reading */
.hero-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 12px rgba(28,25,23,0.06);
  margin-bottom: 12px;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.hero-card:active { transform: scale(0.98); }
.hero-card__body { flex: 1; min-width: 0; }
.hero-card__body h3 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.hero-card__body p { font-size: 14px; color: var(--ink-secondary); margin-bottom: 8px; }

.progress { height: 4px; background: var(--paper-muted); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.progress__bar { height: 100%; background: var(--accent); border-radius: 2px; }
.progress__label { font-size: 12px; color: var(--ink-tertiary); }

/* Scan banner — ref Goodreads/Zara */
.scan-banner, .scan-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  margin-bottom: 24px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.scan-banner div strong, .scan-hero strong { display: block; font-size: 16px; }
.scan-banner div span, .scan-hero span { font-size: 13px; opacity: 0.7; }
.scan-banner__icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.scan-banner .icon:last-child { margin-left: auto; opacity: 0.5; width: 18px; }

.scan-hero {
  flex-direction: column;
  text-align: center;
  padding: 24px;
  background: linear-gradient(160deg, #1c1917 0%, #2d6a4f 100%);
}
.scan-hero__frame {
  width: 120px; height: 80px;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  position: relative;
  margin-bottom: 8px;
}
.scan-hero__line {
  position: absolute;
  left: 8px; right: 8px;
  top: 50%;
  height: 2px;
  background: var(--warm);
  box-shadow: 0 0 12px var(--warm);
  animation: scan 2s ease-in-out infinite;
}
@keyframes scan { 0%,100% { top: 20%; } 50% { top: 80%; } }

/* Horizontal scroll — ref Speechify carousels */
.h-scroll {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }
.book-chip,
.saga-chip {
  flex: 0 0 72px;
  width: 72px;
  min-width: 0;
  overflow: hidden;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
}
.author-chip {
  flex: 0 0 80px;
  width: 80px;
  min-width: 0;
  overflow: hidden;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
}
.book-chip span,
.saga-chip span,
.author-chip span {
  display: block;
  font-size: 11px;
  margin-top: 6px;
  line-height: 1.3;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.author-chip .avatar,
.author-chip .avatar--photo {
  margin: 0 auto;
}
.saga-chip .saga-cover {
  margin: 0 auto;
}

/* Book grid — ref StoryGraph/Headway 3-col */
.book-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.book-grid__item {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.book-grid__item:active { transform: scale(0.96); }
.book-grid__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  gap: 4px;
}
.fav-dot .icon { width: 12px; height: 12px; fill: var(--gold); stroke: var(--gold); }

/* Author grid / list — mismo toggle que libros */
.author-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 12px;
}
.author-grid__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
}
.author-grid__item:active { transform: scale(0.96); }
.author-grid__item .avatar--lg {
  width: 72px;
  height: 72px;
  font-size: 26px;
}
.author-grid__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  width: 100%;
}
.author-grid__meta {
  font-size: 12px;
  color: var(--ink-secondary);
}
.author-grid__fav {
  position: absolute;
  top: 0;
  right: 4px;
}
.author-list {
  display: flex;
  flex-direction: column;
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(28,25,23,0.04);
}
.author-list__row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--paper-muted);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.author-list__row:last-child { border-bottom: none; }
.author-list__row:active { background: var(--paper-muted); }
.author-list__body { flex: 1; min-width: 0; }
.author-list__body strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.author-list__body > span {
  display: block;
  font-size: 13px;
  color: var(--ink-secondary);
}
.author-list__row > .icon {
  width: 16px;
  color: var(--ink-tertiary);
  flex-shrink: 0;
}

/* Book list — vista alternativa a grid */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(28,25,23,0.04);
}
.book-list__row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--paper-muted);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.book-list__row:last-child { border-bottom: none; }
.book-list__row:active { background: var(--paper-muted); }
.book-list__body { flex: 1; min-width: 0; }
.book-list__body strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-list__body > span {
  display: block;
  font-size: 13px;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}
.book-list__badges { display: flex; align-items: center; gap: 6px; }
.book-list__row > .icon {
  width: 16px;
  color: var(--ink-tertiary);
  flex-shrink: 0;
}

/* Library toolbar — filtros + toggle vista */
.library-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.library-toolbar--end { justify-content: flex-end; }
.library-toolbar .chip-row { flex: 1; min-width: 0; margin-bottom: 0; }
.view-toggle {
  display: flex;
  background: var(--paper-muted);
  border-radius: var(--radius-sm);
  padding: 2px;
  flex-shrink: 0;
}
.view-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-tertiary);
}
.view-toggle__btn .icon { width: 18px; height: 18px; }
.view-toggle__btn--active {
  background: var(--paper-elevated);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(28,25,23,0.08);
}

/* Segmented control — iOS */
.segmented {
  display: flex;
  background: var(--paper-muted);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented__item {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.segmented__item--active {
  background: var(--paper-elevated);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-weight: 600;
}

.chip-row, .provider-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--paper-muted);
  background: var(--paper-elevated);
  font-size: 13px;
  color: var(--ink-secondary);
  cursor: pointer;
}
.chip--active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.chip--warn { background: var(--warm-soft); border-color: var(--warm); color: var(--warm); }

/* Search — ref Speechify results */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper-muted);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  outline: none;
}
.search-bar .icon { width: 18px; color: var(--ink-tertiary); flex-shrink: 0; }

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  border: none;
  background: none;
  border-bottom: 1px solid var(--paper-muted);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.search-row__body { flex: 1; min-width: 0; }
.search-row__body strong { display: block; font-size: 16px; margin-bottom: 2px; }
.search-row__body span { display: block; font-size: 14px; color: var(--ink-secondary); }

.fallback-banner {
  background: var(--warm-soft);
  color: var(--warm);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.provider-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Stats — ref StoryGraph */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(28,25,23,0.04);
}
.stat-card__n {
  display: block;
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-card__l { font-size: 13px; color: var(--ink-secondary); margin-top: 4px; }
.stats-grid--compact {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.stats-grid--compact .stat-card { padding: 12px 6px; }
.stats-grid--compact .stat-card__n { font-size: 24px; }
.stats-grid--compact .stat-card__l { font-size: 11px; }

/* Charts — Perfil (inspiración GitHub) */
.github-summary {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(28,25,23,0.04);
}
.github-summary__item { text-align: center; flex: 1; }
.github-summary__n {
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.github-summary__l {
  display: block;
  font-size: 11px;
  color: var(--ink-secondary);
  margin-top: 2px;
}
.github-summary__sep {
  width: 1px;
  height: 32px;
  background: var(--paper-muted);
  flex-shrink: 0;
}

.chart-card {
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(28,25,23,0.04);
}
.chart-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.chart-card__head h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.chart-card__meta {
  font-size: 11px;
  color: var(--ink-tertiary);
  white-space: nowrap;
}

/* Heatmap — GitHub contributions */
.heatmap {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.heatmap::-webkit-scrollbar { display: none; }
.heatmap__days {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 1px;
  font-size: 9px;
  color: var(--ink-tertiary);
  line-height: 11px;
  flex-shrink: 0;
}
.heatmap__days span { height: 11px; }
.heatmap__grid {
  display: flex;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.heatmap__week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.heatmap__cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  flex-shrink: 0;
}
.heatmap__cell--legend { width: 10px; height: 10px; }
.heatmap__months {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--ink-tertiary);
  margin-top: 6px;
  padding-left: 14px;
}
.heatmap__legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 10px;
  font-size: 10px;
  color: var(--ink-tertiary);
}

/* Status bar — GitHub languages */
.status-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}
.status-bar__seg { min-width: 2px; }
.status-bar__legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
}
.status-bar__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.status-bar__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-bar__name { flex: 1; color: var(--ink-secondary); }
.status-bar__pct { font-weight: 600; font-size: 11px; color: var(--ink-tertiary); }

/* Sparkline — libros terminados por mes */
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 72px;
  padding-top: 4px;
}
.sparkline__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.sparkline__bar {
  width: 100%;
  max-width: 28px;
  min-height: 4px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  opacity: 0.85;
  transition: height 0.3s ease;
}
.sparkline__label {
  font-size: 10px;
  color: var(--ink-tertiary);
  margin-top: 6px;
}

/* Lists — iOS grouped */
.list { margin-bottom: 20px; }
.list--grouped .list-row:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.list--grouped .list-row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--paper-elevated);
  border: none;
  border-bottom: 1px solid var(--paper-muted);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.list-row--static { cursor: default; justify-content: space-between; }
.list-row--toggle { justify-content: space-between; }
.list-row div strong { display: block; font-size: 16px; }
.list-row div span { font-size: 13px; color: var(--ink-secondary); }
.list-row .icon { margin-left: auto; width: 16px; color: var(--ink-tertiary); flex-shrink: 0; }

.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 18px;
  flex-shrink: 0;
}
.avatar--saga { background: var(--accent); }
.avatar--lg { width: 64px; height: 64px; font-size: 24px; }
.avatar--photo {
  overflow: hidden;
  background: var(--avatar-fallback, var(--paper-muted));
  position: relative;
}
.avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar--photo .avatar__initial {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}
.avatar--photo.avatar--fallback .avatar__initial { display: flex; }

/* Author detail */
.author-hero {
  text-align: center;
  margin-bottom: 16px;
}
.author-hero__photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 12px;
  box-shadow: 0 4px 16px rgba(28,25,23,0.12);
}
.author-hero__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.author-hero__fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 36px;
  font-weight: 700;
}
.author-hero h1 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}
.author-hero__meta {
  font-size: 14px;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}
.author-bio {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-secondary);
  margin-bottom: 20px;
}
.author-stats {
  display: flex;
  justify-content: space-around;
  padding: 16px;
  margin-bottom: 24px;
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(28,25,23,0.04);
  text-align: center;
  font-size: 12px;
  color: var(--ink-secondary);
}
.author-stats__n {
  display: block;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

/* Saga — portada rectangular en mosaico */
.saga-cover {
  display: grid;
  gap: 1px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(28, 25, 23, 0.18);
  flex-shrink: 0;
  background: var(--paper-muted);
}
.saga-cover--hero {
  width: 132px;
  aspect-ratio: 2 / 3;
  margin: 0 auto 12px;
}
.saga-cover--sm {
  width: 48px;
  height: 72px;
}
.saga-cover--tiles-1 { grid-template: 1fr / 1fr; }
.saga-cover--tiles-2 { grid-template: 1fr / 1fr 1fr; }
.saga-cover--tiles-3 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.saga-cover--tiles-3 .saga-cover__cell:nth-child(3) { grid-column: 1 / -1; }
.saga-cover--tiles-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.saga-cover__cell {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background: var(--paper-muted);
}
.saga-cover__cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.saga-cover__fallback { display: none; }
.saga-cover__cell--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.saga-cover__cell--fallback .saga-cover__fallback,
.saga-cover__cell--fallback > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.saga-cover--hero .saga-cover__cell--fallback { font-size: 18px; }
.saga-cover--sm .saga-cover__cell--fallback { font-size: 10px; }

/* Saga detail */
.saga-hero {
  text-align: center;
  margin-bottom: 24px;
}
.saga-hero h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.2;
}
.saga-progress { max-width: 280px; margin: 12px auto 0; }
.saga-volumes {
  background: var(--paper-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(28,25,23,0.04);
}
.saga-volume {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--paper-muted);
}
.saga-volume:last-child { border-bottom: none; }
.saga-volume__n {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--paper-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
  flex-shrink: 0;
}
.saga-volume__body { flex: 1; min-width: 0; }
.saga-volume__body strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}
.saga-volume__author {
  display: block;
  font-size: 13px;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}
.saga-volume--link { cursor: pointer; }
.saga-volume--link:active { background: var(--paper-muted); }
.list-row .author-links,
.search-row__body .author-links {
  color: var(--ink-secondary);
}

/* Forms — editar / manual */
.form { padding-bottom: 24px; }
.form-field {
  display: block;
  margin-bottom: 16px;
}
.form-field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}
.form-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--paper-muted);
  border-radius: var(--radius-md);
  background: var(--paper-elevated);
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.form-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-note { font-size: 13px; margin: 8px 0 20px; }
.form .btn { margin-bottom: 10px; }

.text-btn--link {
  font-size: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  vertical-align: baseline;
}
.author-links {
  display: inline;
  font-size: inherit;
  color: inherit;
}
.author-links .text-btn--link {
  font-size: inherit;
  font-weight: inherit;
}
.hero-card__body .author-links {
  color: var(--ink-secondary);
}
.book-list__body .author-links {
  color: var(--ink-secondary);
}
.search-row__body .author-links {
  color: var(--ink-secondary);
}
.author-links__sep {
  color: var(--ink-secondary);
  text-decoration: none;
  pointer-events: none;
}

/* Status sheet */
.status-options { display: flex; flex-direction: column; gap: 4px; }
.status-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  color: inherit;
  text-align: left;
}
.status-option:active { background: var(--paper-muted); }
.status-option--active { background: var(--accent-soft); font-weight: 600; }
.status-option__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Detail — ref Speechify book page */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  font-weight: 600;
}
.nav-bar--dark { color: #fff; }
.detail-hero { text-align: center; margin-bottom: 20px; }
.detail-hero h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.2;
}
.detail-author { color: var(--ink-secondary); margin-bottom: 12px; }
.detail-actions { display: flex; gap: 10px; margin-bottom: 28px; }
.detail-actions .btn { flex: 1; }

.timeline { padding-left: 8px; }
.timeline__item {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  position: relative;
}
.timeline__item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 0;
  width: 2px;
  background: var(--paper-muted);
}
.timeline__dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.timeline__item strong { display: block; font-size: 15px; }
.timeline__item span { font-size: 13px; color: var(--ink-secondary); }

.quote {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.5;
  font-style: italic;
  color: var(--ink-secondary);
}
.book-synopsis {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-secondary);
  margin: 0;
}
.section--synopsis { margin-bottom: 8px; }
.section--bio .author-bio { margin-bottom: 0; }

/* Camera — ref Zara/Woolworths */
.camera-modes {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 16px;
}
.camera-mode {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding-bottom: 8px;
  border-bottom: 2px solid transparent;
}
.camera-mode--active { color: #fff; border-bottom-color: #fff; }
.camera-viewfinder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}
.camera-frame {
  width: 260px; height: 160px;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 12px;
  margin-bottom: 24px;
  position: relative;
}
.camera-frame::before, .camera-frame::after,
.camera-frame > ::before {
  content: '';
}
.camera-viewfinder p { color: rgba(255,255,255,0.6); font-size: 14px; }
.camera-capture { margin: 16px 20px; }

/* Tab bar — Liquid Glass ref Goodreads floating bar */
.tab-bar {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 8px);
  left: 16px;
  right: 16px;
  height: var(--tab-h);
  display: flex;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  z-index: 50;
}
.tab-bar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--ink-tertiary);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-lg);
  margin: 4px;
}
.tab-bar__item .icon { width: 22px; height: 22px; }
.tab-bar__item--active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--secondary { background: var(--paper-muted); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--full { width: 100%; }
.btn--small { padding: 8px 14px; font-size: 14px; background: var(--accent); color: #fff; border-radius: 999px; }
.btn:active { opacity: 0.85; transform: scale(0.98); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--paper-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn--accent { background: var(--accent); color: #fff; }
.icon-btn--light { background: rgba(255,255,255,0.15); color: #fff; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* Sheet — iOS modal */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.2s ease;
}
.sheet {
  width: 100%;
  background: var(--paper-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 12px 20px calc(var(--safe-bottom) + 16px);
  animation: slideUp 0.3s ease;
}
.sheet__handle {
  width: 36px; height: 5px;
  background: var(--paper-muted);
  border-radius: 3px;
  margin: 0 auto 16px;
}
.sheet h2 { font-size: 20px; margin-bottom: 16px; }
.add-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  margin-bottom: 8px;
  background: var(--paper);
  border: 1px solid var(--paper-muted);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.add-option span:first-child { font-size: 28px; }
.add-option strong { display: block; font-size: 16px; }
.add-option span span { font-size: 13px; color: var(--ink-secondary); }
.sheet--form {
  max-height: 88vh;
  overflow-y: auto;
}
.form--sheet { padding-bottom: 8px; }
.form--sheet .form-field:last-of-type { margin-bottom: 12px; }

.search-bar--compact {
  margin-bottom: 0;
  padding: 10px 14px;
}
.search-bar--discover {
  margin-bottom: 10px;
}
.search-bar--grow { flex: 1; min-width: 0; }

/* Búsquedas recientes — scroll horizontal bajo el buscador */
.recent-searches {
  margin: 0 -20px 2px;
  padding: 0 20px;
  overflow: hidden;
}
.recent-searches__scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.recent-searches__scroll::-webkit-scrollbar { display: none; }
.chip--recent {
  flex-shrink: 0;
  white-space: nowrap;
}
/* Large title → compact (patrón collapsing header, ref. Dribbble/iOS) */
.collapsing-header,
.library-header {
  margin-bottom: 16px;
  align-items: center;
  transition: margin-bottom 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
.collapsing-header__title,
.library-header__title {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  transform-origin: left center;
  transition:
    font-size 0.38s cubic-bezier(0.32, 0.72, 0, 1),
    letter-spacing 0.38s cubic-bezier(0.32, 0.72, 0, 1),
    transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
.collapsing-header--compact.large-header,
.collapsing-header--compact.library-header {
  margin-bottom: 8px;
}
.collapsing-header--compact .collapsing-header__title,
.collapsing-header--compact .large-header__brand {
  font-size: 22px;
  letter-spacing: -0.015em;
  transform: scale(0.98);
}
.collapsing-header--compact .large-header__sub {
  opacity: 0.85;
}
.library-header__action {
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
.library-header--compact {
  margin-bottom: 8px;
}
.library-header--compact .library-header__title {
  font-size: 22px;
  letter-spacing: -0.015em;
  transform: scale(0.98);
}
.library-header--compact .library-header__action {
  transform: scale(0.92);
}

.library-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  transition: margin-bottom 0.36s cubic-bezier(0.32, 0.72, 0, 1);
}

/*
 * Tabs + filtros — colapso ligado al scroll (diffClamp).
 * Refs: Dribbble 25102458, 6272514; YouTube Music / Vestiaire (Mobbin).
 * Buscador fijo; segmentos + chips se pliegan al bajar y reaparecen al subir.
 */
.screen__sticky {
  --chrome-p: 0;
}
.collapsing-chrome,
.library-chrome {
  overflow: hidden;
  max-height: calc(var(--chrome-max, 108px) * (1 - var(--chrome-p)));
  opacity: calc(1 - var(--chrome-p));
  margin-bottom: calc(2px * (1 - var(--chrome-p)));
  pointer-events: auto;
  transition: none;
  will-change: max-height, opacity;
}
.collapsing-chrome--hero {
  --chrome-max: 520px;
}
.collapsing-chrome--collapsed,
.library-chrome--collapsed { pointer-events: none; }
.collapsing-chrome--snapping,
.library-chrome--snapping {
  transition:
    max-height 0.34s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.28s cubic-bezier(0.32, 0.72, 0, 1),
    margin-bottom 0.34s cubic-bezier(0.32, 0.72, 0, 1);
}
.collapsing-chrome--snapping .library-chrome__inner .segmented,
.collapsing-chrome--snapping .library-chrome__inner .chip-row,
.library-chrome--snapping .library-chrome__inner .segmented,
.library-chrome--snapping .library-chrome__inner .chip-row {
  transition:
    opacity 0.28s cubic-bezier(0.32, 0.72, 0, 1),
    transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
}
.collapsing-chrome__inner,
.library-chrome__inner {
  transform: translateY(calc(var(--chrome-p) * -6px));
}
.library-chrome__inner .segmented {
  margin-bottom: 10px;
  background: transparent;
  padding: 0;
  opacity: calc(1 - min(1, var(--chrome-p) * 1.1));
  transform: translateY(calc(var(--chrome-p) * -8px)) scale(calc(1 - var(--chrome-p) * 0.025));
  transform-origin: top center;
}
.library-chrome__inner .segmented__item--active {
  background: var(--paper-muted);
  box-shadow: none;
}
.library-chrome__inner .chip-row {
  margin-bottom: 0;
  opacity: calc(1 - min(1, var(--chrome-p) * 1.35));
  transform: translateY(calc(var(--chrome-p) * -14px)) scale(calc(1 - var(--chrome-p) * 0.035));
  transform-origin: top center;
}
.library-chrome__inner .chip {
  background: transparent;
  border-color: var(--paper-muted);
}
.library-chrome__inner .chip--active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
/* Paginación — scroll infinito (30 iniciales, +30 al acercarse al final) */
.list-paginated { margin-bottom: 8px; }
.list-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  flex-shrink: 0;
}
.list-sentinel__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-tertiary);
  opacity: 0.35;
}
.list-sentinel--loading .list-sentinel__dot {
  opacity: 1;
  animation: sentinelPulse 0.9s ease-in-out infinite;
}
@keyframes sentinelPulse {
  0%, 100% { transform: scale(0.85); opacity: 0.45; }
  50% { transform: scale(1.15); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .collapsing-chrome--snapping,
  .library-chrome--snapping,
  .collapsing-chrome--snapping .library-chrome__inner .segmented,
  .collapsing-chrome--snapping .library-chrome__inner .chip-row,
  .library-chrome--snapping .library-chrome__inner .segmented,
  .library-chrome--snapping .library-chrome__inner .chip-row,
  .library-search-row,
  .collapsing-header,
  .library-header,
  .collapsing-header__title,
  .library-header__title {
    transition-duration: 0.01ms !important;
  }
  .list-sentinel--loading .list-sentinel__dot { animation: none; }
}
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 4px;
  gap: 12px;
}
.list-footer__count { font-size: 13px; color: var(--ink-secondary); }
.list-footer--hint,
.list-footer--done {
  font-size: 12px;
  color: var(--ink-tertiary);
  text-align: center;
  padding: 10px 0 4px;
  margin: 0;
}

/* Toggle */
.toggle { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span {
  position: absolute; inset: 0;
  background: var(--paper-muted);
  border-radius: 31px;
  cursor: pointer;
  transition: 0.2s;
}
.toggle span::before {
  content: '';
  position: absolute;
  width: 27px; height: 27px;
  left: 2px; bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::before { transform: translateX(20px); }

/* Onboarding */
.onboarding__skip { align-self: flex-end; width: 100%; text-align: right; margin-bottom: 40px; }
.onboarding__visual { font-size: 72px; margin-bottom: 32px; }
.onboarding__title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 16px;
}
.onboarding__body { color: var(--ink-secondary); font-size: 17px; line-height: 1.5; margin-bottom: 32px; max-width: 280px; }
.onboarding__dots { display: flex; gap: 8px; margin-bottom: 32px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--paper-muted); }
.dot--active { background: var(--accent); width: 24px; border-radius: 4px; }

.muted { color: var(--ink-secondary); font-size: 14px; }
.pad { padding: 0 0 16px; }
.footnote { text-align: center; font-size: 12px; color: var(--ink-tertiary); padding: 24px 0; }
.empty-inline { color: var(--ink-secondary); font-size: 15px; padding: 16px; background: var(--paper-muted); border-radius: var(--radius-md); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Desktop: show device frame context */
@media (min-width: 500px) {
  body::before {
    content: 'Shiori v2 — Prototipo interactivo · iOS-first';
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.02em;
  }
}
