/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:            #06080e;
  --surface:       #0b0f18;
  --surface2:      #111826;
  --surface3:      #18202e;
  --border:        #1c2438;
  --accent:        #c8883a;
  --accent-bright: #e09c48;
  --accent-dim:    #a06e28;
  --accent-glow:   rgba(200, 136, 58, 0.18);
  --text:          #ede8de;
  --text-muted:    #71798c;
  --text-dim:      #363d50;
  --success:       #4ecf8c;
  --warning:       #f0a830;
  --error:         #e05555;
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     16px;
  --font:          'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display:  'Playfair Display', Georgia, serif;
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:      cubic-bezier(0.4, 0, 0.2, 1);
  --transition:    0.2s var(--ease-out);
  --shadow-xl:     0 24px 80px rgba(0, 0, 0, 0.8);
}

[data-theme="light"] {
  --bg:            #f0ede7;
  --surface:       #ffffff;
  --surface2:      #e8e4dc;
  --surface3:      #ddd8ce;
  --border:        #ccc6ba;
  --accent:        #a06820;
  --accent-bright: #b87828;
  --accent-dim:    #7a5018;
  --accent-glow:   rgba(160, 104, 32, 0.12);
  --text:          #1a1610;
  --text-muted:    #5a5248;
  --text-dim:      #9a9080;
  --success:       #1a8a50;
  --warning:       #a07020;
  --error:         #c03030;
}

/* Header text is always on a dark background — keep it light in light mode too */
[data-theme="light"] .logo,
[data-theme="light"] .logo:hover { color: #ede8de; }
[data-theme="light"] .nav-link { color: rgba(237, 232, 222, 0.5); }
[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active { color: #ede8de; }
[data-theme="light"] .btn-logout { color: rgba(237, 232, 222, 0.35); border-color: rgba(255, 255, 255, 0.12); }
[data-theme="light"] .btn-logout:hover { color: rgba(237, 232, 222, 0.55); border-color: rgba(255, 255, 255, 0.2); }
[data-theme="light"] .btn-theme-toggle { color: rgba(237, 232, 222, 0.35); border-color: rgba(255, 255, 255, 0.12); }
[data-theme="light"] .btn-theme-toggle:hover { color: rgba(237, 232, 222, 0.55); border-color: rgba(255, 255, 255, 0.2); }

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); }
code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 0.82em;
  color: var(--accent-bright);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  padding: 0 28px;
  height: 60px;
  background: rgba(6, 8, 14, 0.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  opacity: 0.4;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  white-space: nowrap;
  margin-right: 32px;
}
.logo:hover { color: var(--text); text-decoration: none; }
.logo-icon { color: var(--accent); flex-shrink: 0; }

.site-nav {
  display: flex;
  align-self: stretch;
  align-items: center;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  letter-spacing: 0.01em;
  transition: color var(--transition);
}
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0; left: 16px; right: 16px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform var(--transition);
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link:hover::after { transform: scaleX(0.5); }
.nav-link.active { color: var(--text); }
.nav-link.active::after { transform: scaleX(1); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.btn-logout {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition);
}
.btn-logout:hover { color: var(--text-muted); border-color: var(--text-dim); }
.btn-theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  transition: color var(--transition), border-color var(--transition);
}
.btn-theme-toggle:hover { color: var(--text-muted); border-color: var(--text-dim); }

/* ── Main content ───────────────────────────────────────────────────────────── */
.main-content { padding-bottom: 80px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 14px rgba(200, 136, 58, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-bright);
  box-shadow: 0 4px 22px rgba(200, 136, 58, 0.45);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--surface2);
}
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* ── Flash messages ─────────────────────────────────────────────────────────── */
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  margin: 14px 20px;
  font-size: 0.875rem;
  border-left: 3px solid;
}
.flash-success { background: rgba(78, 207, 140, 0.08); border-color: var(--success); color: var(--success); }
.flash-error   { background: rgba(224, 85, 85, 0.08);  border-color: var(--error);   color: var(--error);   }
.flash-warning { background: rgba(240, 168, 48, 0.08); border-color: var(--warning); color: var(--warning); }
.flash-info    { background: var(--accent-glow);        border-color: var(--accent);  color: var(--accent-bright); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--surface3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-ok   { background: rgba(78, 207, 140, 0.1); color: var(--success); border-color: rgba(78, 207, 140, 0.25); }
.badge-fail { background: rgba(224, 85, 85, 0.1);  color: var(--error);   border-color: rgba(224, 85, 85, 0.25); }
.badge-warn { background: rgba(240, 168, 48, 0.1); color: var(--warning); border-color: rgba(240, 168, 48, 0.25); }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin: 16px 20px;
}
.card h3 {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 16px;
}
.card-sm { padding: 13px 18px; }
.card-sm p { margin: 0; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left;
  padding: 8px 14px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(28, 36, 56, 0.6);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface2); }

/* ── Library toolbar ────────────────────────────────────────────────────────── */
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 6px; }

.search-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 7px 14px;
  width: 240px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-input::placeholder { color: var(--text-dim); }

.filter-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 7px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--accent); }
.book-count { font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.02em; padding-right: 4px; }

/* ── Book grid ──────────────────────────────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 14px;
  padding: 20px;
}

/* ── Book card ──────────────────────────────────────────────────────────────── */
.book-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring),
              box-shadow 0.25s var(--ease-out),
              border-color 0.2s var(--ease-out);
  user-select: none;
  position: relative;
}
.book-card:hover {
  transform: translateY(-7px);
  border-color: rgba(200, 136, 58, 0.4);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.72),
              0 0 0 1px rgba(200, 136, 58, 0.12);
}
.book-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(200, 136, 58, 0.4),
              0 10px 32px rgba(0, 0, 0, 0.55);
}

.book-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface3);
  overflow: hidden;
}
.book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--ease-out);
}
.book-card:hover .book-cover { transform: scale(1.06); }

/* Hover overlay */
.book-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(6, 8, 14, 0.94) 0%,
    rgba(6, 8, 14, 0.5) 45%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.25s var(--ease-out);
  display: flex;
  align-items: flex-end;
  padding: 10px 11px;
  pointer-events: none;
}
.book-card:hover .book-cover-overlay { opacity: 1; }

/* Status badge */
.status-badge {
  position: absolute;
  top: 8px; right: 8px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.status-downloaded {
  background: rgba(78, 207, 140, 0.88);
  color: #fff;
}
.status-not-downloaded {
  background: rgba(18, 24, 38, 0.85);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

/* Absent badge */
.absent-badge {
  position: absolute;
  bottom: 8px; left: 8px; right: 8px;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 0.57rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(200, 48, 48, 0.86);
  backdrop-filter: blur(4px);
  color: #fff;
  text-align: center;
}
.absent-from-audible { opacity: 0.65; }

.btn-delete-book { margin-top: 8px; width: 100%; font-size: 0.73rem; padding: 5px 10px; }
.btn-danger {
  background: rgba(200, 48, 48, 0.12);
  color: #e06060;
  border: 1px solid rgba(200, 48, 48, 0.28);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(200, 48, 48, 0.28);
  border-color: rgba(200, 48, 48, 0.5);
  color: #ff8080;
}

/* Selection checkmark */
.book-check {
  position: absolute;
  top: 8px; left: 8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(200, 136, 58, 0.55);
}
.book-card.selected .book-check { display: flex; }

/* Book info */
.book-info { padding: 10px 12px 12px; }
.book-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-series {
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}
.book-duration {
  font-size: 0.69rem;
  color: var(--text-dim);
  margin-top: 3px;
  letter-spacing: 0.02em;
}

/* Assign children button */
.btn-assign-children {
  position: absolute; top: 6px; right: 6px;
  background: rgba(6, 8, 14, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  cursor: pointer;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  z-index: 2;
}
.book-card:hover .btn-assign-children { opacity: 1; }
.btn-assign-children:hover { background: rgba(6, 8, 14, 0.9); }

/* ── View toggle ────────────────────────────────────────────────────────────── */
.view-toggle { display: flex; gap: 2px; }
.btn-icon { padding: 5px 8px; }
.btn-icon.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }

/* ── Book list view ──────────────────────────────────────────────────────────── */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 20px;
  max-width: 900px;
  margin: 0 auto;
}
.book-list .book-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding-right: 16px;
}
.book-list .book-cover-wrap {
  flex: 0 0 72px !important;
  width: 72px !important; min-width: 72px !important; max-width: 72px !important;
  height: 72px !important; max-height: 72px !important;
  aspect-ratio: auto !important;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.book-list .book-info {
  flex: 1;
  min-width: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.book-list .book-title { flex: 1; min-width: 0; -webkit-line-clamp: 1; font-size: 0.88rem; }
.book-list .book-author { flex-shrink: 0; width: 170px; text-align: right; font-size: 0.78rem; }
.book-list .book-series { display: none; }
.book-list .book-duration { flex-shrink: 0; width: 64px; text-align: right; font-size: 0.75rem; }
.book-list .status-badge { position: static; flex-shrink: 0; font-size: 0.6rem; }
.book-list .book-cover-overlay { display: none; }

/* ── Selection bar ──────────────────────────────────────────────────────────── */
@keyframes slideUpBar {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.selection-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 200;
  box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.65);
  animation: slideUpBar 0.32s var(--ease-spring) both;
}
.selection-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.35;
}
#selection-count { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 100px 24px;
  color: var(--text-dim);
}
.empty-state svg { margin-bottom: 20px; opacity: 0.2; }
.empty-state p { margin: 6px 0; font-size: 1.05rem; }
.empty-state .text-muted { font-size: 0.9rem; color: var(--text-dim); }

/* ── Modals ─────────────────────────────────────────────────────────────────── */
@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.94) translateY(18px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
@keyframes overlayEnter {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 8, 0.9);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayEnter 0.2s ease both;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: modalEnter 0.32s var(--ease-spring) both;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; letter-spacing: 0.01em; }
#download-overall { font-size: 0.82rem; color: var(--text-muted); }
.modal-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  min-height: 180px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.7;
}
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface2);
}
.modal-sm { max-width: 340px; }
.modal-body { padding: 1.2rem 1.5rem; }
.child-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  transition: color var(--transition);
}
.child-checkbox:hover { color: var(--accent-bright); }
.child-checkbox input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }

/* Log line colors */
.log-line-success { color: var(--success); }
.log-line-error   { color: var(--error); }
.log-line-start   { color: var(--accent-bright); font-weight: 600; }

/* ── Settings form ──────────────────────────────────────────────────────────── */
.settings-form { max-width: 680px; }
.field-group { display: flex; flex-direction: column; gap: 18px; }
.settings-form label,
.setup-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}
.settings-form label small,
.setup-form label small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}
.settings-form input[type=text],
.settings-form input[type=password],
.setup-form input[type=text],
.setup-form input[type=password],
.setup-form input[type=email] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 9px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.settings-form input:focus,
.setup-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-status { display: flex; align-items: center; gap: 10px; }
.input-status input { flex: 1; }
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.ok   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.fail { background: var(--error);   box-shadow: 0 0 6px var(--error);   }
.form-actions { margin: 16px 20px; }

/* ── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}

/* ── Accounts page ──────────────────────────────────────────────────────────── */
.upload-form { display: flex; flex-direction: column; gap: 12px; }
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  text-align: center;
  position: relative;
}
.file-drop:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent-bright);
}
.file-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.log-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 0 20px 16px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.65;
}

/* ── Setup / Login pages ────────────────────────────────────────────────────── */
.setup-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(38, 24, 8, 0.65) 0%, transparent 70%),
    var(--bg);
}
.setup-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}
.setup-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}
.setup-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 30px;
  letter-spacing: 0.01em;
}
.setup-logo svg { color: var(--accent); }
.setup-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 0.78rem;
}
.step { color: var(--text-dim); }
.step.active { color: var(--text); font-weight: 600; }
.step.done { color: var(--success); }
.step-sep { color: var(--text-dim); }
.setup-form { display: flex; flex-direction: column; gap: 18px; margin-top: 20px; }
.setup-desc { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 6px; line-height: 1.5; }
.setup-container h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }

/* ── Misc helpers ───────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px;
  }
  .logo { flex: 1; margin-right: 0; }
  .site-nav {
    order: 3;
    width: 100%;
    flex: none;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
    height: auto;
    align-self: auto;
  }
  .nav-link {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 0.82rem;
    height: auto;
    justify-content: center;
  }
  .nav-link::after { display: none; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; padding: 12px; }
  .library-toolbar { padding: 10px 14px; flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: space-between; }
  .search-input { width: 100%; }
  .card { margin: 10px 12px; padding: 16px 18px; }
  .setup-container { padding: 28px 24px; }
  .book-list { padding: 6px 12px; }
  .book-list .book-author { width: auto; text-align: left; }
  .book-list .book-duration { display: none; }
  .page-header { padding: 18px 16px 12px; }
  .selection-bar { padding: 12px 16px; }
}
