/* ============================================================
   HORUS HERESY TRACKER - Grimdark Theme
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --bg-primary: #0A0A0A;
  --bg-secondary: #141414;
  --bg-tertiary: #1E1E1E;
  --bg-card: #161616;
  --bg-card-hover: #1C1C1C;
  --gold-primary: #C9A84C;
  --gold-secondary: #A68A3E;
  --gold-dim: #7A6830;
  --gold-glow: rgba(201, 168, 76, 0.3);
  --red-primary: #8B0000;
  --red-secondary: #B22222;
  --red-glow: rgba(139, 0, 0, 0.3);
  --text-primary: #E0D5C0;
  --text-secondary: #A09880;
  --text-muted: #605848;
  --status-read: #2E7D32;
  --status-read-bg: rgba(46, 125, 50, 0.15);
  --status-reading: #F9A825;
  --status-reading-bg: rgba(249, 168, 37, 0.15);
  --status-unread: #424242;
  --status-unread-bg: rgba(66, 66, 66, 0.15);
  --border-color: #2A2520;
  --border-light: #3A3530;
  --tag-really-good: #C9A84C;
  --tag-good: #4CAF50;
  --tag-ok-meh: #FF9800;
  --tag-bad: #f44336;
  --modal-backdrop: rgba(0, 0, 0, 0.85);
  --card-radius: 6px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Source Sans Pro', 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-weight: 700;
  letter-spacing: 0.05em;
}

a {
  color: var(--gold-primary);
  text-decoration: none;
}

a:hover {
  color: var(--gold-secondary);
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold-dim);
}

/* ── Starfield Background ──────────────────────────────────── */
/* Fixed canvas injected by js/starfield.js; sits behind all
   content (negative z-index paints above the body background) */
#starfield-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dim);
}

/* ── App Layout (prevents page-level scroll, flex fills space) */
body.app-layout {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(180deg, #1A1510 0%, var(--bg-primary) 100%);
  border-bottom: 2px solid var(--gold-dim);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.aquila {
  font-size: 28px;
  color: var(--gold-primary);
  line-height: 1;
}

.header-left h1 {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: 1.4rem;
  color: var(--gold-primary);
  text-shadow: 0 0 20px rgba(201, 168, 76, 0.3);
}

/* ── Category Selector ───────────────────────────────────── */
.category-selector {
  background: var(--bg-secondary);
  color: var(--gold-primary);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 4px 24px 4px 8px;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23C9A84C'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.category-selector:hover {
  border-color: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-glow);
}

.category-selector:focus {
  outline: none;
  border-color: var(--gold-primary);
  box-shadow: 0 0 12px var(--gold-glow);
}

.category-selector option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'Source Sans Pro', sans-serif;
}

/* ── Facebook Link ─────────────────────────────────────────── */
.fb-link {
  display: inline-flex;
  align-items: center;
  color: var(--gold-dim);
  transition: color var(--transition-fast), filter var(--transition-fast);
}

.fb-link:hover {
  color: #1877F2;
  filter: drop-shadow(0 0 6px rgba(24, 119, 242, 0.5));
}

.fb-link-auth {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--gold-dim);
  text-decoration: none;
}

.fb-link-auth span {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.8rem;
}

.fb-link-auth:hover {
  color: #1877F2;
}

.header-stats {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.header-stats .stat {
  display: flex;
  align-items: center;
  gap: 5px;
}

.header-stats .stat-value {
  color: var(--gold-primary);
  font-weight: 600;
}

/* ── View Controls / Nav ───────────────────────────────────── */
#view-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 10px;
}

.view-tabs {
  display: flex;
  gap: 4px;
}

.view-tab {
  padding: 8px 20px;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-normal);
  letter-spacing: 0.05em;
}

.view-tab:hover {
  color: var(--text-secondary);
}

.view-tab.active {
  color: var(--gold-primary);
  border-bottom-color: var(--gold-primary);
}

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-bar input[type="text"] {
  width: 220px;
  padding: 7px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.filter-bar select {
  padding: 7px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  min-width: 140px;
}

/* ── Main Content ──────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.view-container {
  display: none;
  height: 100%;
}

.view-container.active {
  display: block;
}

/* ── Card View ─────────────────────────────────────────────── */
#card-view {
  overflow-y: auto;
  padding: 20px 24px;
  height: 100%;
}

/* Arc Group */
.arc-group {
  margin-bottom: 28px;
}

.arc-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: 12px;
  user-select: none;
}

.arc-group-header:hover {
  background: var(--bg-tertiary);
}

.arc-group-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.arc-color-bar {
  width: 4px;
  height: 28px;
  border-radius: 2px;
}

.arc-group-header h3 {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.arc-group-header .arc-desc {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 8px;
}

.arc-book-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
}

.arc-collapse-icon {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform var(--transition-fast);
}

.arc-group.collapsed .arc-collapse-icon {
  transform: rotate(-90deg);
}

.arc-group.collapsed .arc-books-grid {
  display: none;
}

/* Card Grid */
.arc-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* Book Card */
.book-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition-normal);
  overflow: hidden;
}

.book-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}

.book-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-dim);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 8px var(--gold-glow);
  transform: translateY(-2px);
}

.book-card.status-read {
  border-left: 3px solid var(--status-read);
}

.book-card.status-reading {
  border-left: 3px solid var(--status-reading);
  box-shadow: 0 0 8px rgba(249, 168, 37, 0.15);
}

.book-card.status-unread {
  border-left: 3px solid var(--status-unread);
  opacity: 0.7;
}

.book-card.status-unread:hover {
  opacity: 1;
}

.book-card.is-skippable {
  opacity: 0.6;
}

.book-card.is-skippable:hover {
  opacity: 0.9;
}

.card-number {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-title {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.card-author {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.card-type-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-badge.read {
  background: var(--status-read-bg);
  color: var(--status-read);
}

.status-badge.reading {
  background: var(--status-reading-bg);
  color: var(--status-reading);
}

.status-badge.unread {
  background: var(--status-unread-bg);
  color: var(--status-unread);
}

/* Star Rating (Card) */
.card-stars {
  display: flex;
  gap: 1px;
}

.card-stars .star {
  color: var(--border-light);
  font-size: 0.8rem;
}

.card-stars .star.filled {
  color: var(--gold-primary);
}

/* Half star: gold left half, dim right half, clipped to the glyph */
.card-stars .star.half-filled,
.card-avg-stars .star.half-filled {
  background: linear-gradient(90deg, var(--gold-primary) 50%, var(--border-light) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Tag Rating (Card) */
.card-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.card-tag.really-good { background: rgba(201, 168, 76, 0.2); color: var(--tag-really-good); }
.card-tag.good { background: rgba(76, 175, 80, 0.2); color: var(--tag-good); }
.card-tag.ok-meh { background: rgba(255, 152, 0, 0.2); color: var(--tag-ok-meh); }
.card-tag.bad { background: rgba(244, 67, 54, 0.2); color: var(--tag-bad); }

/* Format Icon */
.card-format {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Skippable Banner */
.skip-badge {
  position: absolute;
  top: 8px;
  right: -20px;
  background: var(--red-primary);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 2px 24px;
  transform: rotate(45deg);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

/* ── Order Source Toggle (Default / Community) ─────────────── */
.order-source-toggle {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.source-btn {
  padding: 6px 16px;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all var(--transition-normal);
}

.source-btn:hover {
  color: var(--text-secondary);
}

.source-btn.active {
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold-primary);
}

/* ── Reading Order Position & Importance Chip ──────────────── */
.order-seq {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  margin-right: 4px;
  border-radius: 10px;
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid rgba(201, 168, 76, 0.4);
  color: var(--gold-primary);
  font-weight: 700;
  text-align: center;
}

.importance-chip {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 8px;
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.importance-chip.essential {
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold-primary);
  border: 1px solid rgba(201, 168, 76, 0.4);
}

.importance-chip.skippable {
  background: rgba(255, 152, 0, 0.12);
  color: #FF9800;
  border: 1px dashed rgba(255, 152, 0, 0.5);
}

/* ── Importance Vote (Modal) ───────────────────────────────── */
.importance-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.imp-text.essential { color: var(--gold-primary); font-weight: 600; }
.imp-text.skippable { color: #FF9800; font-weight: 600; }

.radio-btn.imp-mandatory.active {
  border-color: var(--gold-primary);
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold-primary);
}

.radio-btn.imp-skippable.active {
  border-color: #FF9800;
  background: rgba(255, 152, 0, 0.15);
  color: #FF9800;
}

.importance-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* ── Legend Node Samples (Flowchart) ───────────────────────── */
.legend-node {
  width: 22px;
  height: 14px;
  border-radius: 3px;
  background: #1A1A1A;
  flex-shrink: 0;
}

.legend-node.solid {
  border: 2px solid var(--gold-primary);
}

.legend-node.dashed {
  border: 2px dashed #FF9800;
}

/* ── Detail Modal ──────────────────────────────────────────── */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

#modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 30px var(--gold-glow);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

#modal-backdrop.visible .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.1rem;
  color: var(--gold-primary);
  line-height: 1.3;
}

.modal-subtitle {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 2px;
}

.modal-close {
  font-size: 1.6rem;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--red-secondary);
}

.modal-body {
  padding: 16px 20px 20px;
}

/* Modal Sections */
.modal-section {
  margin-bottom: 16px;
}

.modal-section-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

/* Radio Group (Status, Format) */
.radio-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.radio-btn {
  padding: 6px 14px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.radio-btn:hover {
  border-color: var(--gold-dim);
  color: var(--text-primary);
}

.radio-btn.active {
  border-color: var(--gold-primary);
  background: rgba(201, 168, 76, 0.1);
  color: var(--gold-primary);
}

.radio-btn.status-read.active {
  border-color: var(--status-read);
  background: var(--status-read-bg);
  color: var(--status-read);
}

.radio-btn.status-reading.active {
  border-color: var(--status-reading);
  background: var(--status-reading-bg);
  color: var(--status-reading);
}

.radio-btn.status-unread.active {
  border-color: var(--status-unread);
  background: var(--status-unread-bg);
  color: #999;
}

/* Star Rating (Modal) */
.star-rating {
  display: flex;
  gap: 4px;
}

.star-rating .star {
  font-size: 1.6rem;
  color: var(--border-light);
  cursor: pointer;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.star-rating .star:hover {
  transform: scale(1.15);
}

.star-rating .star.filled {
  color: var(--gold-primary);
  text-shadow: 0 0 6px var(--gold-glow);
}

.star-rating .star.hover-fill {
  color: var(--gold-secondary);
}

.star-rating .star.half-filled {
  background: linear-gradient(90deg, var(--gold-primary) 50%, var(--border-light) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.star-rating .star.hover-half {
  background: linear-gradient(90deg, var(--gold-secondary) 50%, var(--border-light) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.star-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Tag Rating (Modal) */
.tag-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-btn {
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag-btn:hover {
  opacity: 0.8;
}

.tag-btn.active.really-good { border-color: var(--tag-really-good); background: rgba(201, 168, 76, 0.15); color: var(--tag-really-good); }
.tag-btn.active.good { border-color: var(--tag-good); background: rgba(76, 175, 80, 0.15); color: var(--tag-good); }
.tag-btn.active.ok-meh { border-color: var(--tag-ok-meh); background: rgba(255, 152, 0, 0.15); color: var(--tag-ok-meh); }
.tag-btn.active.bad { border-color: var(--tag-bad); background: rgba(244, 67, 54, 0.15); color: var(--tag-bad); }

/* Skippable Checkbox */
.skip-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.skip-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold-primary);
  cursor: pointer;
}

/* Notes Textarea */
.modal-notes {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.modal-notes::placeholder {
  color: var(--text-muted);
}

/* Connections Section */
.connections-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.connection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 0;
}

.connection-arrow {
  color: var(--gold-dim);
  font-size: 0.7rem;
}

.connection-type {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.connection-type.required { background: rgba(201, 168, 76, 0.15); color: var(--gold-primary); }
.connection-type.recommended { background: rgba(76, 175, 80, 0.15); color: var(--tag-good); }
.connection-type.optional { background: rgba(66, 66, 66, 0.2); color: var(--text-muted); }

/* Summary */
.modal-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
  padding: 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  border-left: 3px solid var(--gold-dim);
}

/* ── Flowchart View ────────────────────────────────────────── */
#flowchart-view {
  position: relative;
  height: 100%;
}

#flowchart-canvas {
  width: 100%;
  height: 100%;
  background: transparent; /* let the starfield show through */
  touch-action: none;
}

#flowchart-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

#flowchart-controls button {
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

#flowchart-controls button:hover {
  background: var(--bg-tertiary);
  border-color: var(--gold-dim);
  color: var(--gold-primary);
}

/* Flowchart Legend */
#flowchart-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px 16px;
  z-index: 10;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 200px;
}

#flowchart-legend h4 {
  font-size: 0.75rem;
  color: var(--gold-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.legend-section {
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 2px 0;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.legend-line {
  width: 24px;
  height: 2px;
  flex-shrink: 0;
}

.legend-line.required { background: var(--gold-primary); }
.legend-line.recommended { border-top: 2px dashed var(--text-muted); height: 0; }
.legend-line.optional { border-top: 2px dotted var(--text-muted); height: 0; }

/* ── Footer ────────────────────────────────────────────────── */
#app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 10px;
}

.progress-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 200px;
}

.progress-bar {
  flex: 1;
  max-width: 300px;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-primary));
  border-radius: 4px;
  transition: width var(--transition-normal);
}

#progress-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.footer-actions {
  display: flex;
  gap: 8px;
}

.footer-actions button {
  padding: 6px 14px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.footer-actions button:hover {
  border-color: var(--gold-dim);
  color: var(--gold-primary);
}

/* ── Filter Toggle (Mobile) ───────────────────────────────── */
.filter-toggle {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-tertiary);
  transition: all var(--transition-fast);
}

.filter-toggle:hover {
  border-color: var(--gold-dim);
  color: var(--gold-primary);
}

.filter-toggle .filter-arrow {
  font-size: 0.6rem;
  transition: transform var(--transition-fast);
}

.filter-toggle.open .filter-arrow {
  transform: rotate(180deg);
}

/* ── Hidden Utility ────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .arc-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .header-left h1 {
    font-size: 1.1rem;
  }

  .filter-bar input[type="text"] {
    width: 160px;
  }
}

@media (max-width: 600px) {
  #app-header {
    padding: 6px 12px;
    gap: 6px;
  }

  .header-left h1 {
    font-size: 0.85rem;
  }

  .aquila {
    font-size: 20px;
  }

  .header-left .fb-link {
    display: none;
  }

  .header-stats {
    display: none;
  }

  #view-controls {
    padding: 5px 12px;
  }

  .view-tab {
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  .source-btn {
    padding: 4px 10px;
    font-size: 0.62rem;
  }

  .filter-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .filter-bar {
    display: none;
    width: 100%;
    order: 1;
  }

  .filter-bar.open {
    display: flex;
  }

  .filter-bar input[type="text"] {
    width: auto;
    flex: 1 1 100%;
  }

  .filter-bar select {
    flex: 1 1 calc(33% - 7px);
    min-width: 0;
  }

  #card-view {
    padding: 8px 10px;
  }

  .arc-group {
    margin-bottom: 16px;
  }

  .arc-group-header {
    padding: 7px 10px;
    margin-bottom: 8px;
  }

  .arc-group-header h3 {
    font-size: 0.85rem;
  }

  .arc-group-header .arc-desc {
    display: none;
  }

  .arc-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }

  .book-card {
    padding: 10px;
  }

  .modal {
    max-width: 100%;
    margin: 10px;
    max-height: 90vh;
  }

  #app-footer {
    padding: 4px 12px;
  }

  .footer-actions {
    display: none;
  }

  .progress-section {
    min-width: auto;
    width: 100%;
    gap: 8px;
  }

  #progress-label {
    font-size: 0.7rem;
  }

  #flowchart-legend {
    max-height: 40vh;
    padding: 10px 12px;
    min-width: 150px;
  }

  #flowchart-controls {
    top: 8px;
    right: 8px;
  }

  #flowchart-controls button {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 4px var(--gold-glow); }
  50% { box-shadow: 0 0 12px var(--gold-glow); }
}

.book-card.status-reading {
  animation: pulse-gold 3s ease-in-out infinite;
}

/* Subtle fade-in for cards */
.book-card {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* No results message */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

.no-results .no-results-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ============================================================
   AUTH PAGE STYLES - Login / Register
   ============================================================ */

.auth-container {
  max-width: 420px;
  margin: 80px auto;
  padding: 30px;
  background: var(--bg-secondary);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 30px var(--gold-glow);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header .aquila {
  font-size: 2.5rem;
}

.auth-title {
  font-family: 'Cinzel Decorative', serif;
  color: var(--gold-primary);
  font-size: 1.5rem;
  margin: 12px 0 4px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-tab:hover {
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.auth-tab.active {
  color: var(--gold-primary);
  border-color: var(--gold-primary);
  background: rgba(201, 168, 76, 0.1);
}

.auth-error {
  background: rgba(139, 0, 0, 0.2);
  border: 1px solid var(--red-primary);
  color: var(--red-secondary);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.auth-error a {
  color: var(--gold-primary);
  text-decoration: underline;
}

/* Email verification pages (verify_email.php, resend_verification.php,
   post-registration "check your email" panel) */
.auth-panel-title {
  font-family: 'Cinzel', serif;
  color: var(--gold-primary);
  font-size: 1.2rem;
  margin: 0 0 4px;
}

.auth-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 16px;
}

.auth-text strong {
  color: var(--gold-primary);
}

.auth-text a {
  color: var(--gold-primary);
  text-decoration: underline;
}

.auth-links {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.auth-links p {
  margin: 6px 0;
}

.auth-links a {
  color: var(--gold-primary);
  text-decoration: underline;
}

a.auth-submit-link {
  display: block;
  text-align: center;
  text-decoration: none;
  color: #0A0A0A;
  box-sizing: border-box;
}

.auth-form.hidden {
  display: none;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-glow);
}

.form-group input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.form-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.remember-me {
  margin-bottom: 8px;
}

.remember-me .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold-primary);
  cursor: pointer;
}

.auth-submit {
  width: 100%;
  padding: 12px;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold-primary));
  color: #0A0A0A;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.05em;
  margin-top: 8px;
}

.auth-submit:hover {
  background: var(--gold-primary);
  box-shadow: 0 0 20px var(--gold-glow);
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--gold-dim);
}

/* reCAPTCHA v3 badge - subtle on dark theme */
.grecaptcha-badge {
  visibility: hidden;
}

.recaptcha-notice {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 12px;
  line-height: 1.4;
}

.recaptcha-notice a {
  color: var(--text-secondary);
  text-decoration: underline;
}

.fan-disclaimer {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 16px;
  line-height: 1.5;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(201, 168, 76, 0.15);
}

/* ============================================================
   HEADER USER CONTROLS
   ============================================================ */

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-label {
  font-family: 'Cinzel', serif;
  color: var(--text-secondary);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.header-btn {
  padding: 5px 12px;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  background: transparent;
  color: var(--gold-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
}

.header-btn-dim {
  border-color: var(--border-color);
  color: var(--text-muted);
}

.header-btn-dim:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

/* ============================================================
   SHARED VIEW LABEL
   ============================================================ */

.shared-label {
  font-family: 'Cinzel', serif;
  color: var(--gold-primary);
  font-size: 0.85rem;
}

.shared-label strong {
  color: var(--gold-primary);
}

.pw-success {
  background: rgba(46, 125, 50, 0.2);
  border: 1px solid var(--status-read);
  color: var(--status-read);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ============================================================
   RESPONSIVE ADDITIONS
   ============================================================ */

@media (max-width: 900px) {
  .header-user {
    gap: 6px;
  }
  .user-label {
    display: none;
  }
}

@media (max-width: 600px) {
  .auth-container {
    margin: 40px 16px;
    padding: 20px;
  }
  .header-user {
    gap: 4px;
  }
  .header-btn {
    padding: 4px 8px;
    font-size: 0.65rem;
  }
}

/* ============================================================
   GLOBAL STATS PAGE
   ============================================================ */

/* Popularity-based left border (replaces per-user status border) */
.book-card.popularity-high {
  border-left: 3px solid var(--status-read);
}
.book-card.popularity-mid {
  border-left: 3px solid var(--gold-dim);
}
.book-card.popularity-low {
  border-left: 3px solid var(--status-unread);
}

/* Stats rows inside cards */
.card-stats-section {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.card-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Mini progress bar for read count */
.card-read-bar {
  flex: 1;
  max-width: 80px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.card-read-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--status-read), #4CAF50);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Average star display (non-interactive) */
.card-avg-stars {
  display: flex;
  align-items: center;
  gap: 2px;
}
.card-avg-stars .star {
  color: var(--border-light);
  font-size: 0.75rem;
}
.card-avg-stars .star.filled {
  color: var(--gold-primary);
}
.card-avg-stars .avg-num {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Community average line (modal, read-only) */
.community-avg {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.community-avg .card-avg-stars .star {
  font-size: 0.95rem;
}
.community-avg .community-avg-count {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Horizontal bar chart (used in detail modal) */
.stats-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.stats-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}
.stats-bar-label {
  width: 100px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.stats-bar-track {
  flex: 1;
  height: 16px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.stats-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.stats-bar-value {
  width: 35px;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* Login page stats link */
.stats-link-container {
  text-align: center;
  margin-top: 20px;
}
.global-stats-link {
  display: inline-block;
  padding: 10px 20px;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: all 0.2s ease;
  text-decoration: none;
}
.global-stats-link:hover {
  color: var(--gold-primary);
  border-color: var(--gold-dim);
}

/* Skippable badge on stats cards */
.card-skip-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-family: 'Cinzel', serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
  margin-top: 2px;
}
.card-skip-badge.skippable {
  color: var(--tag-ok-meh);
  border: 1px solid var(--tag-ok-meh);
}
.card-skip-badge.not-skippable {
  color: var(--status-read);
  border: 1px solid var(--status-read);
}

/* ── Stats Flowchart View ─────────────────────────────────── */
#stats-flowchart-view {
  position: relative;
  height: 100%;
}

#stats-flowchart-canvas {
  width: 100%;
  height: 100%;
  background: transparent; /* let the starfield show through */
  touch-action: none;
}

#stats-flowchart-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

#stats-flowchart-controls button {
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

#stats-flowchart-controls button:hover {
  background: var(--bg-tertiary);
  border-color: var(--gold-dim);
  color: var(--gold-primary);
}

#stats-flowchart-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px 16px;
  z-index: 10;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 200px;
}

#stats-flowchart-legend h4 {
  font-size: 0.75rem;
  color: var(--gold-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Stats page responsive */
@media (max-width: 600px) {
  .stats-bar-label {
    width: 70px;
    font-size: 0.65rem;
  }
  .card-stat-row {
    flex-wrap: wrap;
  }
  #stats-flowchart-legend {
    max-height: 40vh;
    padding: 10px 12px;
    min-width: 150px;
  }
  #stats-flowchart-controls {
    top: 8px;
    right: 8px;
  }
  #stats-flowchart-controls button {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}

/* ============================================================
   PROFILE PAGE
   ============================================================ */

.profile-container {
  max-width: 600px;
  margin: 30px auto;
  padding: 0 20px 40px;
}

.profile-header {
  text-align: center;
  margin-bottom: 30px;
}

.profile-header h1 {
  font-family: 'Cinzel Decorative', serif;
  color: var(--gold-primary);
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.profile-header p {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.profile-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.profile-section h2 {
  font-size: 1rem;
  color: var(--gold-primary);
  margin-bottom: 4px;
}

.profile-section h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 20px;
  margin-bottom: 10px;
}

.profile-section-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.profile-stat-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px;
  text-align: center;
}

.profile-stat-value {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  color: var(--gold-primary);
  font-weight: 700;
}

.profile-stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.profile-liked-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-liked-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  border-left: 3px solid var(--gold-dim);
}

.profile-liked-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  flex: 1;
}

.profile-liked-author {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.profile-liked-tag {
  font-size: 0.65rem;
  font-family: 'Cinzel', serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
}

.profile-liked-tag.tag-really-good {
  color: var(--tag-really-good);
  border: 1px solid var(--tag-really-good);
}

.profile-liked-tag.tag-good {
  color: var(--tag-good);
  border: 1px solid var(--tag-good);
}

.profile-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  padding: 10px 0;
}

.profile-share-controls {
  margin-top: 12px;
}

.profile-share-controls .auth-submit {
  width: auto;
}

#share-link-row {
  margin-top: 14px;
}

#share-link-row label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

#share-link-row .share-url-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

#share-link-row .share-url-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-primary);
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.75rem;
}

#share-link-row .share-url-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

/* ── Profile Category Progress ────────────────────────────── */
.profile-category-progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.profile-category-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-category-label {
  width: 140px;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: 'Cinzel', serif;
}

.profile-category-bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-category-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.profile-category-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-primary));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.profile-category-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 50px;
  text-align: right;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .profile-container {
    padding: 0 12px 30px;
  }
  .profile-liked-item {
    flex-wrap: wrap;
  }
  .profile-liked-author {
    order: 3;
    width: 100%;
  }
  .profile-category-label {
    width: 100px;
    font-size: 0.75rem;
  }
  .category-selector {
    font-size: 0.7rem;
    padding: 3px 20px 3px 6px;
  }
}

/* ── Profile Two-Column Layout (wishlist beside the stats) ──── */
/* Mobile/stacked: DOM order puts the wishlist first, right under
   the profile header. Desktop: grid places it in the right column
   so it soaks up the previously empty space. */

@media (min-width: 1000px) {
  .profile-container.has-wishlist {
    max-width: 1260px;
  }
  .has-wishlist .profile-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
  .has-wishlist .profile-col-main {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  .has-wishlist .profile-col-side {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
}

/* ── Profile Wishlist ───────────────────────────────────────── */

.wl-add-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.wl-select {
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.8rem;
  min-width: 0;
}

.wl-select:focus {
  outline: none;
  border-color: var(--gold-dim);
}

#wl-category { flex: 2; }
#wl-book { flex: 3; }

.wl-add-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 18px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.wl-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 10px;
}

.wl-hint-chip {
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.68rem;
  white-space: nowrap;
}

.wl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.wl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--gold-dim);
  border-radius: 4px;
}

.wl-item.wl-dragging {
  opacity: 0.92;
  border-color: var(--gold-primary);
  border-left-color: var(--gold-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  position: relative;
  z-index: 5;
}

.wl-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  padding: 8px 6px;
  flex-shrink: 0;
}

.wl-item.wl-dragging .wl-handle { cursor: grabbing; }

.wl-info {
  flex: 1;
  min-width: 0;
}

.wl-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wl-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wl-chips {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.wl-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px dashed var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.68rem;
  padding: 3px 7px;
  cursor: pointer;
  opacity: 0.7;
  transition: all var(--transition-fast);
}

.wl-chip .wl-chip-icon {
  filter: grayscale(1);
  opacity: 0.7;
}

.wl-chip:hover {
  border-color: var(--text-muted);
  opacity: 1;
}

.wl-chip.owned {
  border: 1px solid var(--gold-primary);
  background: rgba(201, 168, 76, 0.14);
  color: var(--gold-primary);
  opacity: 1;
}

.wl-chip.owned .wl-chip-icon {
  filter: none;
  opacity: 1;
}

.wl-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}

.wl-remove:hover {
  color: #C0392B;
}

@media (max-width: 600px) {
  .wl-add-row {
    flex-wrap: wrap;
  }
  #wl-category,
  #wl-book,
  .wl-add-btn {
    flex: 1 1 100%;
  }
}

@media (max-width: 420px) {
  .wl-chip-label {
    display: none;
  }
  .wl-chip {
    padding: 4px 6px;
  }
}
