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

/* ── Colour tokens ─────────────────────────────────────────── */
:root {
  --bg:           #ffffff;
  --bg-alt:       #f6f5f3;
  --bg-card:      #ffffff;
  --text:         #1a1917;
  --text-muted:   #6b6560;
  --accent:       #6366f1;
  --accent-dim:   #eef2ff;
  --border:       #e2e0dc;
  --nav-bg:       #ffffff;
  --shadow:       0 1px 3px rgba(0,0,0,.07);
  --nav-h:        64px;
  --header-h:     58px;
  --radius:       10px;
  --radius-sm:    6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #131211;
    --bg-alt:     #1c1b1a;
    --bg-card:    #1c1b1a;
    --text:       #ede9e3;
    --text-muted: #8a8580;
    --accent:     #818cf8;
    --accent-dim: #1e1d3a;
    --border:     #2a2927;
    --nav-bg:     #1c1b1a;
    --shadow:     0 1px 3px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

[data-theme="dark"] {
  --bg:         #131211;
  --bg-alt:     #1c1b1a;
  --bg-card:    #1c1b1a;
  --text:       #ede9e3;
  --text-muted: #8a8580;
  --accent:     #818cf8;
  --accent-dim: #1e1d3a;
  --border:     #2a2927;
  --nav-bg:     #1c1b1a;
  --shadow:     0 1px 3px rgba(0,0,0,.3);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:         #ffffff;
  --bg-alt:     #f6f5f3;
  --bg-card:    #ffffff;
  --text:       #1a1917;
  --text-muted: #6b6560;
  --accent:     #6366f1;
  --accent-dim: #eef2ff;
  --border:     #e2e0dc;
  --nav-bg:     #ffffff;
  --shadow:     0 1px 3px rgba(0,0,0,.07);
  color-scheme: light;
}

/* ── Base ──────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: inherit; }

/* ── Header (desktop only) ─────────────────────────────────── */
.site-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  height: var(--header-h);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex: 1;
}

.desktop-nav a {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s, background .15s;
}

.desktop-nav a:hover { color: var(--text); background: var(--bg-alt); }
.desktop-nav a.active { color: var(--accent); background: var(--accent-dim); }

.theme-toggle {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.theme-toggle:hover { background: var(--border); color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ── Page content ──────────────────────────────────────────── */
.page-content {
  padding: 1.5rem 1rem calc(var(--nav-h) + 1.25rem);
  max-width: 640px;
  margin: 0 auto;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.625rem;
}
.section-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .625rem; }
.section-header .section-title { margin: 0; }
.sort-options { display: flex; gap: .25rem; flex-wrap: wrap; }
.sort-btn { font-size: .68rem; padding: .2rem .45rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.sort-btn-active { background: var(--bg-card); color: var(--text); border-color: var(--accent); }

/* ── Mobile bottom nav ─────────────────────────────────────── */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  display: flex;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: .01em;
  transition: color .15s;
}

.mobile-nav-item svg { width: 22px; height: 22px; stroke-width: 1.75; }
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item:hover { color: var(--text); }

/* ── Responsive ────────────────────────────────────────────── */
@media (min-width: 768px) {
  .site-header { display: flex; }
  .mobile-nav { display: none; }
  .page-content {
    padding: 2rem 1.5rem;
    max-width: 900px;
  }
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 0.625rem; }

/* ── Feed (home) ───────────────────────────────────────────── */
.feed-item { display: flex; gap: 0.75rem; }

.feed-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.feed-body { flex: 1; min-width: 0; }
.feed-user { font-weight: 600; font-size: 0.875rem; }
.feed-action { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.1rem; }
.feed-book { font-style: italic; color: var(--text); }
.feed-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.4rem; }

/* ── Book Clubs ────────────────────────────────────────────── */
.club-card { display: flex; gap: 1rem; align-items: flex-start; }

.club-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.club-name { font-weight: 600; font-size: 0.925rem; }
.club-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.club-current { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; }
.club-current strong { color: var(--text); font-style: italic; }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
  margin-top: 0.3rem;
}

.badge-member { background: var(--accent-dim); color: var(--accent); }
.badge-open   { background: var(--bg-alt); color: var(--text-muted); }

/* ── Log (books) ───────────────────────────────────────────── */
.book-entry { display: flex; gap: 0.875rem; align-items: flex-start; }

.book-cover {
  width: 44px;
  height: 64px;
  border-radius: 4px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.book-info { flex: 1; min-width: 0; }
.book-title { font-weight: 600; font-size: 0.9rem; }
.book-author { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }

.progress-bar-track {
  height: 4px;
  background: var(--bg-alt);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.progress-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }

.status-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  margin-top: 0.4rem;
}

.status-reading { background: var(--accent-dim); color: var(--accent); }
.status-done    { background: #dcfce7; color: #16a34a; }
.status-want    { background: var(--bg-alt); color: var(--text-muted); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .status-done { background: #14532d; color: #4ade80; }
}
[data-theme="dark"] .status-done { background: #14532d; color: #4ade80; }

/* ── Profile / Stats ───────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.profile-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-name  { font-size: 1.15rem; font-weight: 700; }
.profile-since { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 0.625rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.stat-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ── Settings ──────────────────────────────────────────────── */
.settings-group { margin-bottom: 1.75rem; }

.settings-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.125rem;
}

.settings-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.settings-row {
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.settings-row:last-child { border-bottom: none; }
.settings-row-label { flex: 1; }
.settings-row-value { font-size: 0.825rem; color: var(--text-muted); }

.settings-select {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.825rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}

.toggle input:checked + .toggle-track { background: var(--accent); }

.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}

.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Back link (sub-pages) ─────────────────────────────────── */
.back-link {
  display: inline-block;
  font-size: 0.825rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 0.75rem;
}
.back-link:hover { color: var(--text); }

/* ── Profile link rows ─────────────────────────────────────── */
.profile-links { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.625rem; }

.profile-link-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  padding: 0.9rem 1rem;
  transition: background .15s;
}

.profile-link-row:hover { background: var(--bg-alt); }
.profile-link-label { flex: 1; font-size: 0.9rem; font-weight: 500; }
.profile-link-meta  { font-size: 0.825rem; color: var(--text-muted); }
.profile-link-chevron { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

/* ── Star ratings ──────────────────────────────────────────── */
.star-rating { display: flex; gap: 2px; margin-top: 0.4rem; }

.star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  color: var(--border);
  padding: 0;
  line-height: 1;
  transition: color .1s;
}

.star.filled, .star:hover { color: #f59e0b; }

/* Interactive star picker */
.star-picker { display: inline-flex; line-height: 1; gap: .05rem; }
.star-pick-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.5rem; padding: 0 .05rem;
  color: var(--border); transition: color .1s; line-height: 1;
}
.star-pick-btn.full  { color: #f59e0b; }
.star-pick-btn.half  {
  background: linear-gradient(90deg, #f59e0b 50%, var(--border) 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Read-only star display */
.stars-display { display: inline-flex; line-height: 1; gap: .05rem; margin-top: .2rem; }
.star-char { font-size: .95rem; color: var(--border); }
.star-char.full  { color: #f59e0b; }
.star-char.half  {
  background: linear-gradient(90deg, #f59e0b 50%, var(--border) 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Editable date fields */
.book-date-editable { cursor: pointer; }
.book-date-editable:hover { text-decoration: underline dotted; }

/* Custom partial date picker (month + year) */
.date-picker-partial { display: flex; align-items: center; gap: .3rem; }

.date-month-select, .date-day-input, .date-year-input {
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .15rem .3rem;
  color: inherit; font-size: .78rem; font-family: inherit;
}

.date-day-input  { width: 2.4rem; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.date-year-input { width: 3.8rem; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

.date-num-wrap { display: flex; align-items: stretch; }
.date-num-btns { display: flex; flex-direction: column; }
.date-num-btn {
  background: var(--bg-alt); border: 1px solid var(--border); border-left: none;
  color: var(--text-muted); cursor: pointer; padding: 0 .3rem;
  font-size: .55rem; line-height: 1; flex: 1;
  display: flex; align-items: center; justify-content: center;
}
.date-num-btn:first-child { border-radius: 0 var(--radius-sm) 0 0; border-bottom-width: 0; }
.date-num-btn:last-child  { border-radius: 0 0 var(--radius-sm) 0; }
.date-num-btn:hover { color: var(--text); }

.date-editor-wrap {
  display: flex; align-items: center; gap: .35rem;
  flex-wrap: wrap; margin: .15rem 0;
}

.date-action-btn { font-size: .72rem !important; padding: .18rem .45rem !important; }

/* Review textarea */
.review-input {
  width: 100%; margin-top: .5rem;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .45rem .6rem;
  color: inherit; font-size: .85rem; font-family: inherit;
  resize: vertical; box-sizing: border-box;
}

/* Review preview on finished card */
.review-preview {
  font-size: .8rem; color: var(--text-muted);
  font-style: italic; margin-top: .25rem; line-height: 1.45;
}

/* book cover image */
.book-cover-img {
  display: block;
  object-fit: cover;
  background: none;
  border: none;
}

/* remove button on book cards */
.btn-remove-x {
  flex-shrink: 0;
  align-self: flex-start;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 1.5rem; height: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: color .15s, border-color .15s;
  padding: 0;
}
.btn-remove-x:hover { color: #ef4444; border-color: #ef4444; }

/* ── Add book card ─────────────────────────────────────────── */
.add-book-card { margin-top: 1rem; }

.add-book-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  width: 100%;
}

.add-book-toggle:hover { opacity: 0.8; }

.add-book-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.add-book-input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.875rem;
}

.add-book-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.add-book-input-pages { max-width: 160px; }

.add-book-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── Page sep & total input ────────────────────────────────── */
.page-sep { font-size: 0.8rem; color: var(--text-muted); }
.page-total { color: var(--text-muted); }

/* ── Log progress controls ─────────────────────────────────── */
.progress-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.page-input {
  width: 64px;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.825rem;
  text-align: center;
}

.page-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.page-of { font-size: 0.8rem; color: var(--text-muted); }

.btn-update {
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

.btn-update:hover { background: var(--border); }

.btn-finished {
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

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

.book-finished-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }

/* ── Join club / add friend inputs ─────────────────────────── */
.join-club { margin-top: 1.5rem; }
.join-club-label, .add-friend-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.join-club-row {
  display: flex;
  gap: 0.5rem;
}

.join-club-input {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.875rem;
}

.join-club-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.join-club-btn {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

.join-club-btn:hover { opacity: 0.88; }

.add-friend { margin-top: 1rem; }

/* ── Profile page ──────────────────────────────────────────── */
.profile-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 0.25rem;
}

.profile-avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }

.profile-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-upload-wrap { cursor: pointer; }
.avatar-upload-wrap .profile-avatar-lg { transition: filter .18s; }
.avatar-upload-wrap:hover .profile-avatar-lg { filter: brightness(0.72); }
.border-color-picker { display: flex; gap: .5rem; margin-top: .875rem; flex-wrap: wrap; }
.border-color-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; outline: none; transition: transform .12s; }
.border-color-swatch:hover { transform: scale(1.15); }
.border-color-swatch.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }

.profile-avatar-change {
  font-size: 0.7rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.edit-photo-row { display: flex; align-items: center; gap: .875rem; }
.edit-field-label { font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }

/* Profile shelf */
.shelf-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: .5rem; }
.shelf-covers { display: flex; justify-content: center; gap: .625rem; padding: 0 .25rem; }
.shelf-covers a { display: block; width: calc((100% - 3 * .625rem) / 4); flex-shrink: 0; }
.shelf-cover { width: 100%; aspect-ratio: 2/3; border-radius: var(--radius-sm); object-fit: cover; display: block; box-shadow: 0 2px 8px rgba(0,0,0,.18); }

/* Cover picker */
.book-cover-wrap { position: relative; flex-shrink: 0; cursor: pointer; }
.book-cover-wrap:hover::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.22); border-radius: var(--radius-sm); pointer-events: none; }
.cover-picker-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.cover-picker-modal { background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; max-width: 380px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.3); }
.cover-picker-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.cover-picker-item { width: calc(25% - .375rem); cursor: pointer; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent; transition: border-color .12s, transform .12s; }
.cover-picker-item:hover { border-color: var(--accent); transform: scale(1.04); }
.cover-picker-item.selected { border-color: var(--accent); }
.cover-picker-item img { width: 100%; display: block; aspect-ratio: 2/3; object-fit: cover; }
.cover-picker-upload { aspect-ratio: 2/3; border: 2px dashed var(--border) !important; display: flex; align-items: center; justify-content: center; }
.cover-picker-upload:hover { border-color: var(--accent) !important; }
.cover-picker-upload-inner { font-size: 2rem; line-height: 1; color: var(--text-muted); pointer-events: none; }
.cover-picker-upload:hover .cover-picker-upload-inner { color: var(--accent); }

/* Library cover grid */
.books-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .625rem; }
.books-list  { display: block; margin-bottom: .625rem; }
.books-list-row { display: flex !important; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--border); cursor: pointer; min-width: 0; overflow: hidden; }
.books-list-row.hidden { display: none !important; }
.library-cover-cell { width: calc(25% - .375rem); position: relative; cursor: pointer; flex-shrink: 0; border-radius: var(--radius-sm); overflow: hidden; }
.library-cover-cell img { width: 100%; aspect-ratio: 2/3; display: block; object-fit: cover; }
.library-cover-placeholder { width: 100%; aspect-ratio: 2/3; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; background: var(--bg-card); }
.library-cover-cell::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background .15s; border-radius: var(--radius-sm); pointer-events: none; }
.library-cover-cell:hover::after { background: rgba(0,0,0,.18); }
.library-progress-strip { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(0,0,0,.25); z-index: 2; }
.library-progress-fill { height: 100%; background: var(--accent); }
.library-cover-info { position: absolute; bottom: 0; left: 0; right: 0; padding: .75rem .35rem .3rem; background: linear-gradient(transparent, rgba(0,0,0,.72)); pointer-events: none; z-index: 1; }
.library-cover-rating { display: block; margin-bottom: .15rem; }
.library-cover-title { font-size: .68rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.library-cover-rating .star-char { color: transparent; }
.library-cover-rating .star-char.full { color: #fff; }
.library-cover-rating .star-char.half { background: linear-gradient(90deg, #fff 50%, transparent 50%); -webkit-background-clip: text; background-clip: text; }
.rating-stars-compact { display: none; color: #fff; font-weight: 700; }
@media (max-width: 540px) {
  .rating-stars-full { display: none; }
  .rating-stars-compact { display: inline; }
  .library-cover-title { display: none; }
}

/* Book detail modal */
.book-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 500; display: flex; align-items: flex-start; justify-content: center; padding: 1.5rem 1rem; overflow-y: auto; }
.book-modal-inner { max-width: 480px; width: 100%; }
.book-modal-inner .card { margin: 0; }

/* Edit shelf */
.shelf-edit-list { display: flex; flex-wrap: wrap; gap: .625rem; margin-bottom: .75rem; min-height: 0; }
.shelf-edit-item { position: relative; }
.shelf-edit-cover { width: 64px; height: 96px; border-radius: var(--radius-sm); object-fit: cover; display: block; background: var(--bg-alt); }
.shelf-edit-remove {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-muted); color: var(--bg);
  border: none; cursor: pointer; font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.shelf-edit-remove:hover { background: #ef4444; }
.shelf-edit-title { font-size: .65rem; color: var(--text-muted); margin-top: .25rem; width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-name-wrap { flex: 1; min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: .75rem; }
.profile-name-wrap .profile-name { font-size: 1.25rem; font-weight: 700; }

.profile-actions { display: none; gap: .4rem; margin-top: .45rem; }
.profile-actions:not([hidden]) { display: flex; }
.profile-action-btn {
  padding: .2rem .65rem;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.6;
  transition: opacity .15s;
  border: 1px solid transparent;
}
.profile-action-follow { background: var(--accent); color: #fff; border-color: var(--accent); }
.profile-action-follow.following { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
.profile-action-follow:hover { opacity: .82; }
.profile-action-mute { background: none; color: var(--text-muted); border-color: var(--border); }
.profile-action-mute.muted { color: var(--text); }
.profile-action-mute:hover { color: var(--text); border-color: var(--text-muted); }

.friend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.friend-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-alt);
  border: 2px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
  overflow: hidden;
}
.friend-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.friend-name { font-size: 0.9rem; font-weight: 500; }

/* ── Auth (login / register) ───────────────────────────────── */
body.auth-loading { visibility: hidden; animation: auth-reveal 0s 8s forwards; }
@keyframes auth-reveal { to { visibility: visible; } }

.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem 1rem;
}

.auth-main { width: 100%; max-width: 380px; }

.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.auth-tabs {
  display: flex;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 0.75rem;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.auth-card { padding: 1.25rem; }

.auth-field { margin-bottom: 0.875rem; }

.auth-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.auth-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.9rem;
}

.auth-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.auth-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.auth-error {
  font-size: 0.825rem;
  color: #ef4444;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.875rem;
}

[data-theme="dark"] .auth-error { background: #450a0a; border-color: #7f1d1d; color: #fca5a5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .auth-error { background: #450a0a; border-color: #7f1d1d; color: #fca5a5; }
}

.auth-submit {
  width: 100%;
  padding: 0.6rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
  margin-top: 0.25rem;
}

.auth-submit:hover:not(:disabled) { opacity: 0.88; }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Danger zone */
.btn-danger {
  display: inline-block;
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid #fca5a5;
  background: transparent;
  color: #ef4444;
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

.btn-danger:hover { background: #fee2e2; }
[data-theme="dark"] .btn-danger:hover { background: #450a0a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-danger:hover { background: #450a0a; }
}

/* ── Book search dropdown ──────────────────────────────────── */
.book-search-wrap { position: relative; }

.book-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
}

.book-suggestion-item {
  padding: .6rem .875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.book-suggestion-item:last-child { border-bottom: none; }
.book-suggestion-item:hover { background: var(--bg-alt); }

.suggestion-inner { display: flex; gap: .625rem; align-items: center; }

.suggestion-cover {
  width: 28px;
  height: 42px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}
.suggestion-cover-placeholder {
  width: 28px;
  height: 42px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 2px;
  flex-shrink: 0;
}

.suggestion-title { font-size: .85rem; font-weight: 500; line-height: 1.3; }
.suggestion-meta  { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }

/* ── Search results ─────────────────────────────────────────── */
.search-result-row {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .625rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background .1s;
  border-radius: var(--radius-sm);
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:hover { background: var(--bg-alt); padding-left: .5rem; padding-right: .5rem; margin: 0 -.5rem; }
.search-result-cover {
  width: 42px;
  height: 63px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}
.search-result-cover-placeholder {
  width: 42px;
  height: 63px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
}
.search-result-title { font-size: .9rem; font-weight: 500; line-height: 1.3; }
.search-result-meta  { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Clickable stars (finished book cards) ──────────────────── */
.stars-clickable { cursor: pointer; display: inline-block; margin-top: .2rem; }

/* ── Date range (Started – Finished) ───────────────────────── */
.book-date-range { display: flex; align-items: baseline; flex-wrap: wrap; gap: .3rem; }

/* ── Feed day dividers ──────────────────────────────────────── */
.feed-day-divider {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .75rem 0 .35rem;
  white-space: nowrap;
}
.feed-day-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.feed-day-divider:first-child { padding-top: 0; }
