/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f8f8f6;
  --surface:  #ffffff;
  --border:   #e2e2dc;
  --text:     #1a1a1a;
  --muted:    #6b6b6b;
  --accent:   #5865f2;  /* Discord blurple */
  --green:    #2d8a4e;
  --red:      #c0392b;
  --orange:   #c77b2a;
  --radius:   6px;
  --shadow:   0 1px 3px rgba(0,0,0,.08);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ───────────────────────────────────────────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-brand { font-weight: 700; font-size: 1rem; }
.nav-links  { display: flex; gap: 1rem; align-items: center; flex: 1; }
.nav-links a { color: var(--text); font-size: 0.875rem; }
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.nav-user   { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; color: var(--muted); }

/* ── Container ─────────────────────────────────────────────────────────────── */
.container         { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.container-narrow  { max-width: 680px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover, button[type="submit"]:hover { opacity: 0.88; text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-danger         { background: #c0392b; color: #fff; border: 1px solid #a93226; }
.btn-danger:hover   { background: #a93226; opacity: 1; color: #fff; }
.btn-link     { background: none; color: var(--accent); padding: 0; font-size: inherit; border: none; cursor: pointer; }
.btn-sm       { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-logout   { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.875rem; padding: 0; }
.btn-logout:hover { color: var(--red); }

/* ── Discord login ─────────────────────────────────────────────────────────── */
.btn-discord {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  margin: 1rem 0 0.5rem;
  transition: opacity .15s;
}
.btn-discord:hover { opacity: 0.88; text-decoration: none; color: #fff; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-card h1 { font-size: 1.4rem; }
.login-sub  { color: var(--muted); font-size: 0.875rem; margin-top: 0.25rem; }
.login-note { font-size: 0.78rem; color: var(--muted); margin-top: 1rem; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.alert-error   { background: #fdf2f2; border: 1px solid #f5c6c6; color: var(--red); }
.alert-danger  { background: #fdf2f2; border: 1px solid #f5c6c6; color: var(--red); }
.alert-success { background: #f0faf3; border: 1px solid #a8d5b5; color: var(--green); }
.alert-info    { background: var(--surface); border: 1px solid var(--border); color: var(--text); }

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; }

/* ── Dashboard stats ───────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  text-align: center;
}
.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-top: 0.4rem;
}
/* Per-type stat card accents */
.stat-card-finished  { border-top-color: var(--green);  }
.stat-card-reading   { border-top-color: var(--accent); }
.stat-card-abandoned { border-top-color: var(--orange); }
.stat-card-pages     { border-top-color: var(--muted);  }
.stat-card-rating    { border-top-color: var(--orange); }
.stat-card-finished  .stat-number { color: var(--green);  }
.stat-card-abandoned .stat-number { color: var(--orange); }
.stat-card-pages     .stat-number { color: var(--text); font-size: 1.8rem; }
.quick-actions h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.quick-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-bar select { padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 0.875rem; }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th { background: var(--bg); text-align: left; padding: 0.6rem 0.9rem; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); }
td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafaf8; }

.book-title  { font-weight: 700; }
.book-author { font-size: 0.8rem; color: var(--muted); }
.book-meta   { font-size: 0.8rem; color: var(--muted); }

.actions { display: flex; gap: 0.4rem; white-space: nowrap; align-items: center; }
.actions form { display: contents; }

.table-count { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
.rank-cell { font-weight: 700; text-align: center; color: var(--muted); font-size: 0.9rem; }
.form-control { padding: 0.45rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; background: var(--surface); width: 100%; color: var(--text); }
.add-quip-form { margin: 1.25rem 0; }
.add-quip-form .form-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0; }
.add-quip-form .form-row input { flex: 1; }
.empty-state { color: var(--muted); font-style: italic; padding: 2rem 0; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge-finished  { background: #e6f4ec; color: var(--green); }
.badge-reading   { background: #eef2ff; color: var(--accent); }
.badge-abandoned { background: #fef3e8; color: var(--orange); }
.badge-botm      { background: #fef9e6; color: #9a6f00; border: 1px solid #edd97a; }

/* ── Form ──────────────────────────────────────────────────────────────────── */
.field       { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1.1rem; }
.field-group { margin-bottom: 1.1rem; }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.1rem; }
.field-note  { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }
.required    { color: var(--red); }

label { font-size: 0.875rem; font-weight: 400; }
input[type="text"], input[type="url"], input[type="number"], input[type="date"],
select, textarea {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--surface);
  width: 100%;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
input[type="checkbox"] { width: auto; margin-right: 0.4rem; }

.input-with-button { display: flex; gap: 0.5rem; }
.input-with-button input { flex: 1; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ── Book preview (lookup + edit) ──────────────────────────────────────────── */
.book-lookup-preview {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.book-lookup-preview.loading { background: var(--bg); color: var(--muted); }
.book-lookup-preview.success { background: #f0faf3; color: var(--green); }
.book-lookup-preview.error   { background: #fdf2f2; color: var(--red); }

.book-preview {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
}
.book-cover { width: 50px; border-radius: 3px; flex-shrink: 0; }
.book-meta-row { font-size: 0.875rem; color: var(--muted); margin-bottom: 1.25rem; }

/* ── Dark mode ─────────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:      #111113;
  --surface: #1c1c1f;
  --border:  #2e2e32;
  --text:    #e4e4e7;
  --muted:   #8c8c9a;
  --accent:  #7c85f5;
}
[data-theme="dark"] tr:hover td { background: #25252a; }

[data-theme="dark"] .alert-error   { background: #2d1515; border-color: #6b2c2c; }
[data-theme="dark"] .alert-danger  { background: #2d1515; border-color: #6b2c2c; }
[data-theme="dark"] .alert-success { background: #122a1c; border-color: #2a6b45; }
[data-theme="dark"] .alert-info    { background: var(--surface); }
[data-theme="dark"] .badge-finished  { background: #122a1c; }
[data-theme="dark"] .badge-reading   { background: #1a1e3d; }
[data-theme="dark"] .badge-abandoned { background: #2d1e0a; }
[data-theme="dark"] .badge-botm      { background: #2a2210; border-color: #6b5a20; }
[data-theme="dark"] .book-lookup-preview.loading { background: #1c1c1f; }
[data-theme="dark"] .book-lookup-preview.success { background: #122a1c; }
[data-theme="dark"] .book-lookup-preview.error   { background: #2d1515; }

/* ── User stats page ───────────────────────────────────────────────────────── */

/* Hero header */
.user-hero {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  margin-bottom: 2.5rem;
  padding: 2rem 2.25rem;
  background: linear-gradient(135deg, var(--surface) 55%, rgba(88,101,242,.04) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
.user-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -48deg,
    transparent,
    transparent 28px,
    rgba(88,101,242,.018) 28px,
    rgba(88,101,242,.018) 29px
  );
  pointer-events: none;
}
.user-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--accent), 0 4px 18px rgba(88,101,242,.18);
  position: relative;
  z-index: 1;
}
.user-hero-info { flex: 1; position: relative; z-index: 1; }
.user-hero-info h1 {
  font-size: 2rem;
  margin: 0 0 0.15rem;
  line-height: 1.15;
}
.user-since { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.user-hero-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}
.user-hero-stat { display: flex; flex-direction: column; }
.user-hero-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.user-hero-stat-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-top: 0.2rem;
}
.nav-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

/* Empty state */
.empty-hero { text-align: center; padding: 4rem 1rem; }
.empty-hero-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-hero h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.empty-hero p  { color: var(--muted); }
.empty-hero code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.1rem 0.4rem; font-size: 0.875rem; }

/* Section wrapper */
.stats-section {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.stats-section:last-child { border-bottom: none; }
.stats-section h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 1.25rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.section-header h2 { margin-bottom: 0; }
.section-sub { font-size: 0.85rem; color: var(--muted); font-weight: 400; }
.text-muted { color: var(--muted); font-size: 0.875rem; }

/* Activity heatmap */
.heatmap-scroll { overflow-x: auto; }
.heatmap-wrap { display: inline-flex; flex-direction: column; gap: 4px; }
.heatmap-months-row { display: flex; gap: 2px; padding-left: 26px; }
.heatmap-month-label { width: 13px; font-size: 0.68rem; color: var(--muted); white-space: nowrap; overflow: visible; flex-shrink: 0; }
.heatmap-body-row { display: flex; gap: 4px; align-items: flex-start; }
.heatmap-day-col { display: flex; flex-direction: column; gap: 2px; width: 22px; flex-shrink: 0; }
.heatmap-day-label { height: 11px; font-size: 0.65rem; color: var(--muted); line-height: 11px; text-align: right; }
.heatmap-grid { display: flex; gap: 2px; }
.heatmap-col { display: flex; flex-direction: column; gap: 2px; }
.heatmap-cell { width: 11px; height: 11px; border-radius: 2px; flex-shrink: 0; cursor: default; }
.heat-0 { background: #eaeaea; }
.heat-1 { background: #b8e0c8; }
.heat-2 { background: #6dbf91; }
.heat-3 { background: #3da36e; }
.heat-4 { background: #1d6e44; }
.heat-future { background: #f0f0f0; opacity: 0.4; }
.heatmap-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.heatmap-legend .heatmap-cell { cursor: default; }
.heatmap-legend-text { font-size: 0.72rem; color: var(--muted); }
[data-theme="dark"] .heat-0 { background: #1e2028; }
[data-theme="dark"] .heat-1 { background: #0e4429; }
[data-theme="dark"] .heat-2 { background: #006d32; }
[data-theme="dark"] .heat-3 { background: #26a641; }
[data-theme="dark"] .heat-4 { background: #39d353; }
[data-theme="dark"] .heat-future { background: #1a1a1f; }

/* Year toggle */
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.toggle-btn {
  background: var(--surface);
  border: none;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  transition: background .15s, color .15s;
}
.toggle-btn.active { background: var(--accent); color: #fff; }
.toggle-btn:not(.active):hover { background: var(--bg); color: var(--text); }

/* Currently reading */
.reading-list { display: flex; flex-direction: column; gap: 1rem; }
.reading-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.book-cover-sm {
  width: 56px;
  height: 84px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.book-cover-placeholder { background: var(--border); border-radius: 4px; }
.reading-info { flex: 1; min-width: 0; }
.reading-title  { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reading-author { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.6rem; }
.reading-progress-row { display: flex; align-items: center; gap: 0.75rem; }
.progress-bar-wrap { flex: 1; height: 8px; background: var(--border); border-radius: 5px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.progress-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; min-width: 2.5rem; text-align: right; }
.reading-pages  { font-size: 0.78rem; color: var(--muted); margin-top: 0.35rem; }

/* Highlights */
.highlights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.highlight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  transition: box-shadow .18s, transform .18s;
}
.highlight-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.09);
  transform: translateY(-2px);
}
.highlight-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 0.65rem;
  background: rgba(88,101,242,.08);
}
.highlight-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.1rem;
  line-height: 1.25;
}
.highlight-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 0.1rem;
}
.highlight-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* BOTM stats row */
.botm-stats-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.botm-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-width: 140px;
}
.botm-streak { border-top-color: var(--orange); }
.botm-stat-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 0.25rem; }
.botm-stat-value { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.botm-rate       { font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.botm-stat-sub   { font-size: 0.78rem; color: var(--muted); }
.botm-streak .botm-stat-value { color: var(--orange); }

/* BOTM participation grid */
.botm-grid-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.botm-grid { border-collapse: collapse; font-size: 0.8rem; width: 100%; }
.botm-grid th, .botm-grid td {
  padding: 0.45rem 0.6rem;
  text-align: center;
  border: 1px solid var(--border);
}
.botm-grid th { background: var(--bg); font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: 0.7rem; letter-spacing: .03em; }
.botm-year-col { font-weight: 700; color: var(--text); text-align: left; padding-right: 0.75rem; white-space: nowrap; }
.botm-cell { width: 38px; font-size: 0.8rem; }
.botm-grid .botm-empty     { background: transparent; color: transparent; }
.botm-grid .botm-finished  { background: #e6f4ec; color: var(--green); font-weight: 700; }
.botm-grid .botm-reading   { background: #eef2ff; color: var(--accent); }
.botm-grid .botm-abandoned { background: #fef3e8; color: var(--orange); }
.botm-grid .botm-dnr       { background: #fdf2f2; color: var(--red); }
.botm-grid .botm-not-enrolled { background: var(--bg); color: var(--muted); }

/* BOTM legend */
.botm-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 0.75rem; }
.legend-item { display: flex; align-items: center; gap: 0.3rem; }
.legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
}

/* Genre breakdown */
.genre-list { display: flex; flex-direction: column; gap: 0.65rem; max-width: 600px; }
.genre-row  { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
.genre-label { width: 160px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.genre-bar-wrap { flex: 1; height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.genre-bar  { height: 100%; background: var(--accent); border-radius: 5px; transition: width .3s; }
.genre-count { width: 28px; text-align: right; color: var(--muted); flex-shrink: 0; }

/* History table */
.book-thumb { width: 32px; height: 48px; object-fit: cover; border-radius: 2px; display: block; }

/* ── Hamburger nav ─────────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  margin-left: auto;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-hamburger.nav-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.nav-open span:nth-child(2) { opacity: 0; }
.nav-hamburger.nav-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-user-mobile { display: none; }
.nav-user-desktop { display: flex; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  /* Container */
  .container { padding: 1.25rem 1rem; }

  /* Nav — hamburger mode */
  nav {
    padding: 0 1rem;
    height: 52px;
    flex-wrap: nowrap;
    position: relative;
  }
  .nav-brand { flex: 1; }
  .nav-hamburger { display: flex; }
  .nav-user-desktop { display: none; }

  /* Dropdown — absolutely positioned below nav bar */
  .nav-links {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    padding: 0.25rem 1rem 0.75rem;
    gap: 0;
    z-index: 100;
    /* reset base flex properties that don't apply here */
    flex: none;
    align-items: stretch;
  }
  .nav-links.nav-open { display: flex; }
  .nav-links a {
    padding: 0.75rem 0;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
  }
  .nav-links a:last-of-type { border-bottom: none; }
  .nav-links .btn-sm { display: none; } /* hide "+ Add Log" in mobile menu */
  .nav-user-mobile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
  }

  /* Page header */
  .page-header { flex-wrap: wrap; gap: 0.5rem; }
  .page-header h1 { font-size: 1.2rem; }

  /* Section header — let toggle wrap below heading */
  .section-header { flex-wrap: wrap; gap: 0.5rem; }

  /* Filter bar — stack selects */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select { width: 100%; }

  /* Hero */
  .user-hero { padding: 1.25rem; gap: 1rem; }
  .user-avatar { width: 64px; height: 64px; }
  .user-hero-info h1 { font-size: 1.35rem; }

  /* Stat + highlight grids — 2 columns */
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .highlights-grid { grid-template-columns: repeat(2, 1fr); }

  /* BOTM stat cards — full width stack */
  .botm-stats-row { flex-direction: column; }
  .botm-stat-card { min-width: 0; }

  /* Genre bar label narrower */
  .genre-label { width: 110px; }

  /* History table — hide less important columns */
  /* col 1: thumb, 3: type, 5: progress, 7: started, 8: finished */
  #history-table th:nth-child(1),
  #history-table td:nth-child(1),
  #history-table th:nth-child(3),
  #history-table td:nth-child(3),
  #history-table th:nth-child(5),
  #history-table td:nth-child(5),
  #history-table th:nth-child(7),
  #history-table td:nth-child(7),
  #history-table th:nth-child(8),
  #history-table td:nth-child(8) { display: none; }

  /* Leaderboard table — hide Enrolled and Rate */
  #lb-table th:nth-child(4),
  #lb-table td:nth-child(4),
  #lb-table th:nth-child(5),
  #lb-table td:nth-child(5) { display: none; }

  /* Book detail member table — hide Progress, Started, Finished */
  #members-table th:nth-child(3),
  #members-table td:nth-child(3),
  #members-table th:nth-child(5),
  #members-table td:nth-child(5),
  #members-table th:nth-child(6),
  #members-table td:nth-child(6) { display: none; }
}
.book-thumb-placeholder { width: 32px; height: 48px; background: var(--border); border-radius: 2px; }

/* ── Book detail page ─────────────────────────────────────────────────────── */
.book-detail-hero { display: flex; gap: 1.5rem; align-items: flex-start; margin-bottom: 2rem; }
.book-detail-cover { width: 120px; height: 180px; object-fit: cover; border-radius: 6px; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.book-detail-info { flex: 1; min-width: 0; }
.book-detail-info h1 { margin: 0 0 0.25rem; font-size: 1.6rem; line-height: 1.2; }
.book-detail-author { color: var(--muted); font-size: 1rem; margin-bottom: 0.5rem; }
.book-detail-badge { display: inline-block; background: var(--accent); color: #fff; font-size: 0.8rem; padding: 0.2rem 0.6rem; border-radius: 999px; margin-bottom: 0.75rem; }
.book-detail-meta { color: var(--muted); font-size: 0.875rem; margin-top: 0.4rem; }
.book-detail-meta a { color: var(--accent); }
@media (max-width: 520px) {
  .book-detail-hero { flex-direction: column; }
  .book-detail-cover { width: 80px; height: 120px; }
}

/* ── Books catalog page ────────────────────────────────────────────────────── */
.books-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1.75rem;
}
.books-search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}
.books-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  pointer-events: none;
}
.books-search {
  width: 100%;
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color .15s;
}
.books-search:focus { border-color: var(--accent); }
.books-filter-chips { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.books-chip {
  padding: 0.28rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.books-chip:hover  { border-color: var(--accent); color: var(--accent); }
.books-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.books-sort {
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}

/* Grid */
@keyframes bookCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1.2rem;
}
.book-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .18s, transform .18s;
  animation: bookCardIn .4s ease both;
}
.book-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
  transform: translateY(-4px);
  text-decoration: none;
  color: var(--text);
}

/* Cover */
.book-card-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.book-card-cover {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.book-card-cover-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  background: linear-gradient(135deg, #eeeee8 0%, #ddddd6 100%);
}
.book-badge-botm {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  line-height: 1.5;
  text-align: center;
}
.book-badge-reading {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(45,138,78,.22);
}

/* Card body */
.book-card-body {
  padding: 0.6rem 0.7rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  flex: 1;
}
.book-card-title {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-card-author {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-card-stats {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
  flex-wrap: wrap;
}
.book-stat-rating  { color: var(--orange); font-weight: 700; }
.book-stat-reading { color: var(--green); }
.book-stat-sep     { color: var(--border); }
.book-card-genres  { display: flex; gap: 0.22rem; flex-wrap: wrap; margin-top: 0.18rem; }
.book-genre-tag {
  font-size: 0.62rem;
  padding: 0.08rem 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  white-space: nowrap;
}
.books-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}
@media (max-width: 680px) {
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.85rem; }
  .books-controls { gap: 0.5rem; }
}

/* ── Activity feed ─────────────────────────────────────────────────────────── */
.activity-day { margin-bottom: 2rem; }
.activity-day-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.activity-list { display: flex; flex-direction: column; gap: 0.55rem; }
.activity-event {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  transition: box-shadow .15s, transform .15s;
}
.activity-event:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,.07);
  transform: translateY(-1px);
}
.activity-event.ev-finished  { border-left-color: var(--green); }
.activity-event.ev-abandoned { border-left-color: var(--orange); }

.activity-cover {
  width: 44px;
  height: 66px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.14);
  display: block;
}
.activity-cover-placeholder { background: var(--border); box-shadow: none; }

.activity-body { flex: 1; min-width: 0; }

.activity-chip {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  background: rgba(88,101,242,.1);
  color: var(--accent);
  margin-bottom: 0.3rem;
}
.ev-finished  .activity-chip { background: rgba(45,138,78,.1);  color: var(--green); }
.ev-abandoned .activity-chip { background: rgba(199,123,42,.1); color: var(--orange); }

.activity-member {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}
.activity-book-title {
  display: block;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}
.activity-book-title:hover { color: var(--accent); text-decoration: none; }
.activity-author {
  font-size: 0.77rem;
  color: var(--muted);
  margin-top: 0.08rem;
  margin-bottom: 0.55rem;
}

/* Progress bar */
.activity-progress-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}
.activity-progress-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.activity-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}
.ev-finished  .activity-progress-fill { background: var(--green); }
.ev-abandoned .activity-progress-fill { background: var(--orange); }
.activity-progress-pct {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 2.2rem;
  text-align: right;
}

.activity-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.activity-stars { font-size: 0.78rem; color: var(--orange); letter-spacing: .02em; }
.activity-time  { font-size: 0.72rem; color: var(--muted); }

/* Club book combined card */
.activity-club-card { border-left-color: var(--accent); }
.activity-chip-botm { background: rgba(88,101,242,.1); color: var(--accent); }
.activity-club-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
}
.activity-club-month { font-size: 0.78rem; color: var(--muted); font-weight: 400; }
.activity-club-members {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.55rem 0 0.5rem;
}
.activity-club-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.activity-club-name {
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 80px;
  flex-shrink: 0;
}
.activity-club-name:hover { color: var(--accent); text-decoration: none; }
.activity-club-status {
  font-size: 0.72rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}
.activity-club-row .activity-progress-pct { min-width: 2.2rem; }

/* Per-status fill colours in club rows */
.acf-finished  { background: var(--green); }
.acf-reading   { background: var(--accent); }
.acf-abandoned { background: var(--orange); }
.acf-dnr       { background: var(--border); }

/* ── Dark mode additions ────────────────────────────────────────────────────── */
[data-theme="dark"] .user-hero {
  background: linear-gradient(135deg, var(--surface) 55%, rgba(88,101,242,.06) 100%);
}
[data-theme="dark"] .user-avatar {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--accent), 0 4px 18px rgba(88,101,242,.3);
}
[data-theme="dark"] .highlight-icon-wrap { background: rgba(88,101,242,.12); }
[data-theme="dark"] .reading-item { background: var(--surface); }
[data-theme="dark"] .book-cover-sm { box-shadow: 0 2px 6px rgba(0,0,0,.4); }
[data-theme="dark"] .highlight-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.35); }
[data-theme="dark"] .botm-grid .botm-finished  { background: #122a1c; color: #5fbf82; }
[data-theme="dark"] .botm-grid .botm-reading   { background: #1a1e3d; color: #7c85f5; }
[data-theme="dark"] .botm-grid .botm-abandoned { background: #2d1e0a; color: #d4913a; }
[data-theme="dark"] .botm-grid .botm-dnr       { background: #2d1515; color: #d96060; }
[data-theme="dark"] .botm-grid .botm-not-enrolled { background: #1c1c1f; }
[data-theme="dark"] .toggle-btn.active { background: var(--accent); }
[data-theme="dark"] .book-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.4); }
[data-theme="dark"] .book-card-cover-placeholder { background: linear-gradient(135deg, #2a2a2e 0%, #1e1e22 100%); }
[data-theme="dark"] .book-genre-tag { background: var(--surface); }
[data-theme="dark"] .activity-event { background: var(--surface); }
[data-theme="dark"] .activity-event:hover { box-shadow: 0 3px 12px rgba(0,0,0,.35); }
[data-theme="dark"] .activity-cover  { box-shadow: 0 2px 6px rgba(0,0,0,.4); }

/* ── Theme toggle ──────────────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.55rem;
  line-height: 1;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--border); }

/* ── Nominations page ──────────────────────────────────────────────────────── */
.nom-period {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.nom-period-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.nom-period-header h2 {
  margin: 0;
  font-size: 1.15rem;
}
.nom-period-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.empty-state-inline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0.5rem;
}
.nom-pending {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}
.nom-pending strong {
  color: var(--text);
}

/* ── Vote results page ─────────────────────────────────────────────────────── */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.result-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  background: var(--bg);
}
.result-winner {
  border-color: #d4af37;
  background: color-mix(in srgb, #d4af37 6%, var(--bg));
}
[data-theme="dark"] .result-winner {
  background: color-mix(in srgb, #d4af37 10%, var(--bg));
}
.result-rank {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
  padding-top: 0.15rem;
}
.result-body {
  flex: 1;
  min-width: 0;
}
.result-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.result-title-row .book-title { font-size: 1rem; }
.result-pts {
  margin-left: auto;
  font-size: 1rem;
  white-space: nowrap;
}
.result-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 0.6rem;
  overflow: hidden;
}
.result-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.result-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.breakdown-item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.breakdown-medal { flex-shrink: 0; }
.breakdown-voters { color: var(--text); }
.breakdown-pts { color: var(--text-muted); }

/* ── Reading streak ────────────────────────────────────────────────────────── */
.streak-cards {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.streak-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--orange);
  border-radius: var(--radius);
  padding: 1.25rem 2rem;
  text-align: center;
  min-width: 140px;
}
.streak-number {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
}
.streak-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-top: 0.4rem;
}
.streak-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
