/* ═══════════════════════════════════════════════════════════════════════
   binary_voting — Design System
   ═══════════════════════════════════════════════════════════════════════ */

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

/* ── Design Tokens: Dark Theme (default) ────────────────────────────── */
:root {
  /* Colors */
  --bg: #0f0f14;
  --card: #1a1a28;
  --card-hover: #222236;
  --accent: #4f8;
  --accent-dim: #3a6;
  --text: #ccc;
  --text-dim: #999;
  --muted: #777;
  --danger: #e44;
  --danger-hover: #c22;
  --success: #4c4;
  --warning: #ea4;
  --border: #333;
  --border-light: #444;
  --overlay: rgba(15,15,20,0.6);
  --accent-glow: rgba(68,255,136,0.15);
  --accent-glow-strong: rgba(68,255,136,0.4);
  --accent-glow-soft: rgba(68,255,136,0.05);

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Typography scale */
  --text-xs: 0.7rem;
  --text-sm: 0.8rem;
  --text-base: 0.9rem;
  --text-lg: 1.1rem;
  --text-xl: 1.5rem;

  /* Border radii */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  /* Transitions */
  --transition-fast: 0.1s ease;
  --transition: 0.2s ease;
  --transition-slow: 0.4s ease;

  /* Layout */
  --sidebar-w: 280px;
  --focus-ring: 0 0 0 2px var(--accent);

  /* Glass morphism */
  --glass-bg: rgba(26,26,40,0.85);
  --glass-border: rgba(255,255,255,0.06);
  --glass-blur: 12px;
}

/* ── Light Theme ────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg: #f5f5f8;
  --card: #ffffff;
  --card-hover: #f0f0f5;
  --accent: #2a7;
  --accent-dim: #1e8a5e;
  --text: #222;
  --text-dim: #666;
  --muted: #999;
  --danger: #d33;
  --danger-hover: #b22;
  --success: #2a7;
  --warning: #d80;
  --border: #ddd;
  --border-light: #ccc;
  --overlay: rgba(245,245,248,0.6);
  --accent-glow: rgba(34,170,119,0.15);
  --accent-glow-strong: rgba(34,170,119,0.4);
  --accent-glow-soft: rgba(34,170,119,0.05);
  --glass-bg: rgba(255,255,255,0.85);
  --glass-border: rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
}

/* ── Body ───────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  overflow: hidden; font-size: var(--text-base); line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

/* ── Focus-visible ring ─────────────────────────────────────────────── */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── Reduced motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── App shell ──────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; }
.sidebar-panel {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width var(--transition), min-width var(--transition);
}
.sidebar-panel.collapsed {
  width: 0; min-width: 0; overflow: hidden; border: none;
}
.main-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: auto; padding: var(--space-lg);
}

/* ── Sidebar tabs ───────────────────────────────────────────────────── */
.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-tabs button {
  flex: 1; padding: var(--space-sm); background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: var(--text-sm); font-weight: 500;
  border-bottom: 2px solid transparent; transition: color var(--transition);
}
.sidebar-tabs button.active {
  color: var(--accent); border-bottom-color: var(--accent);
}
.sidebar-content { flex: 1; overflow-y: auto; padding: var(--space-sm); }
.sidebar-toggle {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; padding: 0.4rem 0.3rem; border-radius: var(--radius) 0 0 var(--radius);
  font-size: var(--text-sm); z-index: 10; transition: right var(--transition);
}
.sidebar-toggle.collapsed { right: -1px; }

/* ── Sidebar list ───────────────────────────────────────────────────── */
.sidebar-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem var(--space-sm); border-radius: var(--radius-sm); font-size: var(--text-sm);
  transition: background var(--transition-fast);
}
.sidebar-item:hover { background: var(--card-hover); }
.sidebar-item .rank { width: 2.2rem; color: var(--muted); font-size: var(--text-xs); flex-shrink: 0; }
.sidebar-item .name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-item .score { color: var(--accent); font-size: var(--text-xs); margin-left: 0.4rem; }
.sidebar-item .comp-badge {
  background: var(--card-hover); color: var(--muted);
  font-size: var(--text-xs); padding: 0.05rem 0.3rem; border-radius: 3px;
  margin-left: 0.3rem;
}
.sidebar-item .rank-change {
  font-size: var(--text-xs); margin-left: 0.2rem; width: 1.2rem; text-align: center;
}
.rank-up { color: var(--accent); }
.rank-down { color: var(--danger); }
.rank-same { color: var(--muted); }

.history-entry {
  padding: 0.35rem var(--space-sm); border-radius: var(--radius-sm); font-size: var(--text-sm);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.3rem;
  flex-wrap: wrap;
}
.history-entry .winner { color: var(--accent); font-weight: 500; }
.history-entry .loser { color: var(--danger); }
.history-entry .delta { color: var(--muted); font-size: var(--text-xs); }
.history-entry .time-ago { color: var(--text-dim); font-size: var(--text-xs); margin-left: auto; }

/* ── Top bar ────────────────────────────────────────────────────────── */
.top-bar {
  display: flex; align-items: center; gap: var(--space-sm);
  margin-bottom: var(--space-md); flex-shrink: 0;
}
.top-bar h1 { font-size: var(--text-lg); color: var(--text); font-weight: 600; }

/* ── Collection list (card layout) ──────────────────────────────────── */
#section-list { }
#collections {
  list-style: none; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}
.collection-card {
  background: var(--card); border-radius: var(--radius); padding: var(--space-md);
  border: 1px solid var(--border); transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer; display: flex; flex-direction: column; gap: var(--space-xs);
  position: relative;
}
.collection-card:hover {
  background: var(--card-hover); transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.collection-card .card-header {
  display: flex; align-items: center; gap: var(--space-sm);
}
.collection-card .card-name {
  font-weight: 600; color: var(--text); font-size: var(--text-base);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.collection-card .card-meta {
  display: flex; align-items: center; gap: var(--space-sm);
  font-size: var(--text-xs); color: var(--muted);
}
.collection-card .card-desc {
  color: var(--muted); font-size: var(--text-sm);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.collection-card .card-tags {
  display: flex; flex-wrap: wrap; gap: 0.2rem;
}
.collection-card .card-delete {
  position: absolute; top: var(--space-xs); right: var(--space-xs);
}
.collection-card .card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: var(--space-xs);
  border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--muted);
}
.tag {
  display: inline-block; background: var(--card-hover); color: var(--muted);
  font-size: var(--text-xs); padding: 0.1rem 0.4rem; border-radius: 3px;
}
.detail-desc { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--space-xs); }
#detail-meta { padding: 0 0 var(--space-sm) 0; }

/* ── Voting area ────────────────────────────────────────────────────── */
.vs-container {
  display: flex; gap: var(--space-md); align-items: stretch; flex: 1;
  max-height: 70vh;
}
.vs-card {
  flex: 1; background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-lg); padding: var(--space-xl) var(--space-lg);
  text-align: center; cursor: pointer; border: 2px solid var(--glass-border);
  transition: border-color var(--transition-fast), transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  position: relative; overflow: hidden;
}
.vs-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow-soft) 0%, transparent 60%);
  pointer-events: none; transition: opacity var(--transition);
  opacity: 0;
}
.vs-card:hover::before { opacity: 1; }
.vs-card:hover {
  border-color: var(--accent); transform: scale(1.02);
  box-shadow: 0 0 32px var(--accent-glow);
}
.vs-card.key-hint::after {
  content: "←"; position: absolute; left: var(--space-sm); top: 50%; transform: translateY(-50%);
  font-size: var(--text-xl); color: var(--accent); opacity: 0.4; pointer-events: none;
}
.vs-card:last-child.key-hint::after { content: "→"; left: auto; right: var(--space-sm); }
.vs-card .card-name { font-size: var(--text-xl); color: var(--text); margin-bottom: var(--space-sm); word-break: break-word; font-weight: 600; }
.vs-card .card-elo { font-size: var(--text-sm); color: var(--accent); font-weight: 500; }
.vs-card .card-glicko { font-size: var(--text-xs); color: var(--text-dim); margin-top: 0.1rem; }
.vs-card .card-rd { font-size: var(--text-xs); color: var(--muted); margin-top: 0.1rem; }
.vs-card .card-votes { font-size: var(--text-xs); color: var(--muted); margin-top: 0.25rem; }
.vs-separator {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: var(--border-light); width: 3rem;
  flex-shrink: 0; position: relative;
}
.vs-separator::after {
  content: ""; position: absolute; inset: 20% 30%;
  border-radius: 50%; background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}
.vs-card.voted {
  animation: voteFlash 0.5s ease-out;
}
@keyframes voteFlash {
  0% { border-color: var(--accent); box-shadow: 0 0 30px var(--accent-glow-strong); transform: scale(1.03); }
  50% { transform: scale(1.05); }
  100% { border-color: transparent; box-shadow: none; transform: scale(1); }
}

/* ── Progress bar ───────────────────────────────────────────────────── */
.progress-bar {
  width: 100%; max-width: 600px; margin: 0 auto var(--space-md);
}
.progress-label {
  display: flex; justify-content: space-between; font-size: var(--text-xs);
  color: var(--muted); margin-bottom: 0.25rem;
}
.progress-track {
  height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width var(--transition-slow);
}

/* ── Stats bar ──────────────────────────────────────────────────────── */
.stats-bar {
  display: flex; gap: var(--space-md); flex-wrap: wrap;
  padding: var(--space-sm) var(--space-md); background: var(--card);
  border-radius: var(--radius); margin-bottom: var(--space-md);
  border: 1px solid var(--border);
}
.stat-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
}
.stat-value { font-size: var(--text-lg); font-weight: 600; color: var(--accent); }
.stat-label { font-size: var(--text-xs); color: var(--muted); }

/* ── Card content ───────────────────────────────────────────────────── */
.card-image {
  max-width: 240px; max-height: 180px; border-radius: var(--radius-sm);
  margin: var(--space-sm) 0; object-fit: cover;
  transition: opacity var(--transition);
}
.card-image.loading { opacity: 0; }
.card-image.loaded { opacity: 1; animation: fadeIn 0.3s ease-out; }
.card-image-placeholder {
  width: 240px; height: 120px; background: var(--border);
  border-radius: var(--radius-sm); margin: var(--space-sm) 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: var(--text-sm);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.card-rating { color: var(--accent); font-size: var(--text-sm); margin: 0.2rem 0; }
.card-details { margin-top: 0.3rem; font-size: var(--text-xs); color: var(--muted); }

/* ── Buttons / inputs ───────────────────────────────────────────────── */
button, .btn {
  cursor: pointer; border: none; border-radius: var(--radius-sm); padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm); font-weight: 500; transition: background var(--transition-fast), transform var(--transition-fast);
  font-family: inherit; min-height: 2.2rem;
}
.btn-primary { background: var(--accent); color: #111; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 0.2rem 0.5rem; font-size: var(--text-xs); min-height: 1.8rem; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--card-hover); }
.btn-icon {
  padding: 0.3rem; min-height: 2rem; min-width: 2rem; display: inline-flex;
  align-items: center; justify-content: center;
}

.form-row { display: flex; gap: var(--space-sm); margin-bottom: var(--space-md); }
.form-row input {
  flex: 1; padding: var(--space-sm); border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card); color: var(--text);
  font-size: var(--text-sm); font-family: inherit;
}
.form-row input:focus, form input:focus, form textarea:focus, form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent);
}
form textarea {
  padding: var(--space-sm); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); font-size: var(--text-sm);
  font-family: inherit; resize: vertical;
}
.detail-form {
  display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: var(--space-md);
  padding: var(--space-md); background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.detail-form input, .detail-form textarea {
  padding: var(--space-sm); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-size: var(--text-sm);
  font-family: inherit; transition: border-color var(--transition-fast);
}
.detail-form input::placeholder, .detail-form textarea::placeholder {
  color: var(--muted); opacity: 0.7;
}
.detail-form input:focus, .detail-form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent);
}
.detail-form textarea { resize: vertical; }
.card-link {
  display: block; margin-top: 0.3rem; font-size: var(--text-xs); color: var(--accent);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-link:hover { text-decoration: underline; }

.section { display: none; }
.section.active { display: flex; flex-direction: column; height: 100%; }

.back-link { color: var(--muted); cursor: pointer; font-size: var(--text-sm); display: inline-block; }
.back-link:hover { color: var(--accent); }

.empty-state {
  color: var(--muted); font-size: var(--text-sm); padding: var(--space-md) 0;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-sm);
}
.empty-icon { font-size: 2.5rem; opacity: 0.3; }
.kb-hint { color: var(--muted); font-size: var(--text-xs); text-align: center; margin-top: var(--space-sm); }

/* ── Toast (severity-aware, global container) ────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 100;
  pointer-events: none;
}
.toast {
  position: relative;
  background: var(--card);
  color: var(--text);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  opacity: 0;
  pointer-events: auto;
  transition: opacity var(--transition);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  max-width: min(420px, calc(100vw - var(--space-xl) * 2));
}
.toast.show { opacity: 1; }
.toast.info     { border-left: 4px solid var(--accent); }
.toast.success  { border-left: 4px solid var(--success); background: rgba(68,204,68,0.08); }
[data-theme="light"] .toast.success { background: rgba(34,170,119,0.10); }
.toast.warning  { border-left: 4px solid var(--warning); background: rgba(238,170,68,0.08); }
[data-theme="light"] .toast.warning { background: rgba(221,136,0,0.10); }
.toast.error    { border-left: 4px solid var(--danger);  background: rgba(238,68,68,0.10); }
[data-theme="light"] .toast.error   { background: rgba(221,51,51,0.10); }
.toast-icon {
  margin-right: var(--space-xs);
  font-weight: bold;
  flex-shrink: 0;
}
.toast-message {
  flex: 1;
  min-width: 0;
}
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  margin-left: var(--space-md);
  padding: 0 var(--space-xs);
  font-size: var(--text-base);
  line-height: 1;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text); }
.toast-close:focus-visible { color: var(--text); box-shadow: var(--focus-ring); }

/* ── Diagnostics button ──────────────────────────────────────────────── */
.toast-diagnostics {
  flex-basis: 100%;
  margin-top: var(--space-xs);
  padding: 0.3rem var(--space-sm);
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: var(--text-xs);
  color: var(--text-dim);
  background: rgba(128, 128, 128, 0.08);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.toast-diagnostics:hover {
  border-color: var(--text-dim);
  color: var(--text);
}
.toast-diagnostics:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.toast-diagnostics.pending {
  opacity: 0.5;
  cursor: wait;
  border-style: solid;
}
.toast-diagnostics:disabled {
  pointer-events: none;
}

@media (max-width: 640px) {
  .toast-container {
    bottom: var(--space-md);
    left: var(--space-md);
    right: var(--space-md);
  }
  .toast { max-width: none; }
}

/* ── Spinner ────────────────────────────────────────────────────────── */
.spinner-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--overlay); display: none; align-items: center;
  justify-content: center; z-index: 200;
}
.spinner-overlay.show { display: flex; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Inline spinner (button) ────────────────────────────────────────── */
.btn-loading {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  pointer-events: none; opacity: 0.7;
}
.btn-spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: currentColor; border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}

/* ── Skeleton screen ────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; margin-bottom: var(--space-xs); }
.skeleton-title { height: 20px; width: 60%; margin-bottom: var(--space-sm); }
.skeleton-card { height: 120px; border-radius: var(--radius); }

/* ── Confirmation modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; animation: fadeIn 0.15s ease-out;
}
.modal-box {
  background: var(--card); border-radius: var(--radius-lg); padding: var(--space-lg);
  max-width: 400px; width: 90%; border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin-bottom: var(--space-sm); font-size: var(--text-lg); color: var(--text); }
.modal-box p { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--space-md); }
.modal-actions { display: flex; gap: var(--space-sm); justify-content: flex-end; }

/* ── Bulk action bar (sidebar item selection) ──────────────────────── */
.bulk-action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-sm); padding: var(--space-xs) var(--space-sm);
  margin-bottom: var(--space-xs);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--text);
}
.sidebar-item input[type="checkbox"] { flex-shrink: 0; }

/* ── Link-style button / verification panel ────────────────────────── */
.btn-link {
  background: none; border: none; padding: 0;
  color: var(--accent); cursor: pointer; font-size: var(--text-sm);
}
.btn-link:hover { text-decoration: underline; }
.verification-pending {
  text-align: center; padding: var(--space-md); color: var(--text);
}
.verification-pending p { margin-bottom: var(--space-sm); }

/* ── Owner filter group / role badge / sort select ─────────────────── */
.owner-filter-group {
  display: flex; gap: 0; border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border-light);
}
.owner-filter-group .btn-sm { border-radius: 0; }
.role-badge {
  position: absolute; top: var(--space-xs); left: var(--space-xs);
  font-size: 0.65rem; padding: 0 0.3rem; border-radius: 3px;
  background: var(--accent); color: var(--bg); opacity: 0.85;
}
.sort-select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.15rem 0.3rem;
  font-size: var(--text-xs); margin-left: 0.5rem;
}

/* ── Tooltip ────────────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%); background: var(--card); color: var(--text);
  padding: 0.2rem 0.6rem; border-radius: var(--radius-sm); font-size: var(--text-xs);
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity var(--transition-fast); z-index: 50;
  border: 1px solid var(--border);
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Live region (screen reader only) ───────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Page transitions ───────────────────────────────────────────────── */
.section {
  transition: opacity var(--transition);
}
.section.active { animation: sectionIn 0.2s ease-out; }
@keyframes sectionIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Mobile (≤640px) ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #app { flex-direction: column; }
  .sidebar-panel {
    width: 100%; min-width: 100%; max-height: 40vh;
    border-right: none; border-top: 1px solid var(--border);
  }
  .main-area { padding: var(--space-md); }
  .vs-container { flex-direction: column; max-height: none; gap: var(--space-sm); }
  .vs-card { padding: var(--space-md); }
  .vs-card .card-name { font-size: var(--text-lg); }
  .vs-separator { width: 100%; height: 2rem; }
  .top-bar { flex-wrap: wrap; }
  .top-bar select { margin-left: 0; }
  .stats-bar { gap: var(--space-sm); padding: var(--space-sm); }
  .stat-item { flex: 1; }
  .collection-card { min-width: 0; }
}

/* ── Tablet (≤768px) ────────────────────────────────────────────────── */
@media (max-width: 768px) and (min-width: 641px) {
  :root { --sidebar-w: 240px; }
  .main-area { padding: var(--space-md); }
  .vs-card { padding: var(--space-lg); }
  .vs-card .card-name { font-size: var(--text-lg); }
  .stats-bar { gap: var(--space-sm); }
}

/* ── Auth ───────────────────────────────────────────────────────────── */
.auth-header {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 0.4rem 0.8rem; background: var(--card); border-radius: var(--radius);
  margin-bottom: var(--space-md); border: 1px solid var(--border);
}
.auth-user { color: var(--text); font-weight: 600; }
.auth-btn {
  padding: 0.3rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); cursor: pointer; font-size: var(--text-sm);
}
.auth-btn:hover { background: var(--card-hover); }
.auth-page {
  max-width: 440px; margin: 4rem auto; padding: var(--space-xl);
  background: var(--card); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
}
.auth-page h2 { margin: 0 0 1.2rem; color: var(--text); font-size: var(--text-lg); }
.auth-page label {
  display: block; margin: 0.6rem 0 0.2rem; color: var(--muted);
  font-size: var(--text-sm);
}
.auth-page input {
  width: 100%; padding: var(--space-sm); border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  font-size: var(--text-base); box-sizing: border-box;
}
.auth-page input:focus { border-color: var(--accent); outline: none; }
.auth-page button[type="submit"] {
  width: 100%; margin-top: var(--space-md); padding: 0.6rem; border: none;
  border-radius: var(--radius-sm); background: var(--accent); color: #111;
  font-size: var(--text-base); cursor: pointer; font-weight: 600;
}
.auth-page button[type="submit"]:hover { background: var(--accent-dim); }
.auth-error {
  color: var(--danger); font-size: var(--text-sm); margin-bottom: var(--space-sm);
  padding: var(--space-sm); background: rgba(238,68,68,0.1);
  border-radius: var(--radius-sm); border: 1px solid rgba(238,68,68,0.2);
  display: flex; align-items: center; gap: var(--space-xs);
}
.auth-error::before { content: "⚠"; }
.auth-switch {
  margin-top: var(--space-md); text-align: center; color: var(--muted);
  font-size: var(--text-sm);
}
.auth-switch a { color: var(--accent); cursor: pointer; }
.auth-resend {
  margin-top: var(--space-sm);
  text-align: center;
}
.auth-resend a {
  color: var(--accent);
  cursor: pointer;
  font-size: var(--text-sm);
}

/* ── Auth tabs ──────────────────────────────────────────────────────── */
.auth-tabs {
  display: flex; gap: 0; margin-bottom: var(--space-md);
  border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border);
}
.auth-tab {
  flex: 1; padding: var(--space-sm) var(--space-md); border: none;
  background: var(--bg); color: var(--muted); font-size: var(--text-sm); cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.auth-tab:hover { background: var(--card-hover); color: var(--text-dim); }
.auth-tab.active { background: var(--card); color: var(--text); font-weight: 600; }

/* ── Password strength ──────────────────────────────────────────────── */
.pw-strength {
  margin-top: 0.25rem; height: 4px; border-radius: 2px; overflow: hidden;
  background: var(--border);
}
.pw-strength-bar {
  height: 100%; border-radius: 2px; transition: width var(--transition), background var(--transition);
}
.pw-strength-label {
  font-size: var(--text-xs); margin-top: 0.15rem;
}
.strength-weak { background: var(--danger); }
.strength-fair { background: #e90; }
.strength-good { background: #ea4; }
.strength-strong { background: var(--accent); }

/* ── Remember-me checkbox ───────────────────────────────────────────── */
.remember-row {
  display: flex; align-items: center; gap: var(--space-xs); margin-top: var(--space-sm);
  font-size: var(--text-sm); color: var(--muted);
}
.remember-row input[type="checkbox"] {
  width: auto; accent-color: var(--accent);
}

/* ── Bot registration ───────────────────────────────────────────────── */
.bot-explainer {
  color: var(--muted); font-size: var(--text-sm); margin: 0 0 0.8rem; line-height: 1.4;
}
.bot-code-display { text-align: center; }
.bot-code-display p { color: var(--text); margin: 0 0 var(--space-sm); }
.bot-code-box {
  display: flex; align-items: center; gap: var(--space-sm);
  justify-content: center; margin: 0.8rem 0 var(--space-md);
}
.bot-code {
  font-size: 1.8rem; font-weight: bold; letter-spacing: 0.15em;
  color: var(--accent); background: var(--bg); padding: 0.3rem 0.8rem;
  border-radius: var(--radius-sm); border: 2px dashed var(--border); user-select: all;
}
.btn-copy {
  padding: 0.3rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); font-size: var(--text-sm); cursor: pointer;
}
.btn-copy:hover { background: var(--card-hover); }
.bot-instructions {
  text-align: left; color: var(--muted); font-size: var(--text-sm); line-height: 1.5;
}
.bot-instructions ul { padding-left: 1.2rem; margin: 0.3rem 0; }
.bot-instructions li { margin-bottom: 0.2rem; }
.bot-instructions code {
  background: var(--card-hover); padding: 0.1rem 0.3rem; border-radius: 3px;
  font-size: var(--text-sm); color: var(--accent);
}
.bot-note {
  margin-top: 0.8rem; font-style: italic; color: var(--muted); font-size: var(--text-sm);
}

/* ── Bulk delete checkboxes ─────────────────────────────────────────── */
.checkbox-col { width: 1.2rem; flex-shrink: 0; }
.checkbox-col input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.bulk-actions {
  display: flex; gap: var(--space-xs); padding: var(--space-xs) var(--space-sm);
  border-top: 1px solid var(--border); align-items: center; flex-shrink: 0;
}
.bulk-actions .selected-count { font-size: var(--text-xs); color: var(--muted); flex: 1; }
.bulk-actions button { min-height: 1.6rem; }

/* ── Filter bar ─────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: var(--space-sm); padding: var(--space-sm) var(--space-md);
  flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}
.filter-bar input, .filter-bar select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.25rem var(--space-sm);
  font-size: var(--text-sm); font-family: inherit;
}

/* ── Theme toggle button ────────────────────────────────────────────── */
.theme-toggle {
  background: none; border: none; cursor: pointer; font-size: 1.1rem;
  padding: 0.2rem; color: var(--muted); min-height: auto;
}
.theme-toggle:hover { color: var(--text); }
