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

:root {
  --bg: #040714;
  --surface-1: rgba(255,255,255,.03);
  --surface-2: rgba(255,255,255,.06);
  --border-subtle: rgba(255,255,255,.07);
  --border: rgba(255,255,255,.1);
  --border-strong: rgba(255,255,255,.22);
  --text-primary: #f9f9f9;
  --text-secondary: #cacaca;
  --text-muted: rgba(255,255,255,.55);
  --accent: #67e8f9;
  --accent-dim: rgba(103,232,249,.15);
  --accent-glow: rgba(103,232,249,.3);
  --font: 'Avenir Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.25rem; --text-2xl: 1.5rem;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 15px;
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 120ms; --dur: 200ms;
}

html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  min-height: 100%;
  color: var(--text-primary);
  display: flex; flex-direction: column;
}

/* ── Layout ────────────────────────────────────────────────── */
#main { flex: 1; }
.container {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 30px;
}

/* ── Header ────────────────────────────────────────────────── */
.header-bar {
  background: linear-gradient(in oklch 135deg, #B015B0 0%, #3D0080 50%, #040714 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-6);
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
}

.header-logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.header-logo-img {
  height: 36px; width: auto; flex-shrink: 0;
  filter: brightness(0) invert(1);
  transition: transform 0.3s var(--ease-snap);
  display: block;
}
.header-logo-img:hover { transform: scale(1.14) rotate(-9deg); }

.header-title-link { text-decoration: none; color: inherit; }
.header-logo h1 { font-size: 1.2em; font-weight: 600; color: var(--text-primary); letter-spacing: .5px; }
.header-subtitle { font-size: .82em; color: rgba(255,255,255,.72); font-weight: 500; margin-top: 3px; }

/* ── Nav & Auth ────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.nav-link {
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.nav-link:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.nav-link.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.auth-toggle {
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
  display: flex;
  align-items: center;
  position: relative;
}
.auth-toggle:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.auth-toggle svg { width: 22px; height: 22px; }

.rec-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.header-home {
  display: flex; align-items: center;
  padding: 5px;
  color: rgba(255,255,255,0.9); text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--dur), background var(--dur); flex-shrink: 0;
}
.header-home:hover { color: #fff; background: rgba(255,255,255,0.12); }
.header-home svg { width: 34px; height: 34px; display: block; }

/* ── Auth panel ────────────────────────────────────────────── */
.auth-panel {
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border-subtle);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.auth-panel.open { max-height: 350px; }
.auth-panel-inner {
  padding: 20px;
  max-width: 400px;
  margin: 0 auto;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
  flex: 1;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur);
}
.auth-tab.active {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.auth-form input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.auth-submit {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #040714;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur);
}
.auth-submit:hover { background: #a5f3fc; }
#authUser {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-username { color: var(--text-primary); font-weight: 600; }
.auth-logout {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur);
}
.auth-logout:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.auth-divider { height: 1px; background: var(--border-subtle); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--dur);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); transition-duration: var(--dur-fast); }

.btn-accent {
  background: var(--accent);
  color: #040714;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-accent:hover { background: #a5f3fc; border-color: #a5f3fc; }

.btn-outline {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-outline:hover {
  background: var(--accent-dim);
}

.btn-ghost {
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-2); }

.btn-danger {
  border-color: transparent;
  color: #f87171;
}
.btn-danger:hover { background: rgba(248,113,113,.1); }

.btn-sm { padding: 4px 10px; font-size: var(--text-xs); }

/* ── Feed sections ────────────────────────────────────────── */
.feed-section { margin-bottom: 36px; }
.section-title {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.subsection-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}
.count-badge {
  font-size: var(--text-xs);
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.feed-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

/* ── Channel card grid ────────────────────────────────────── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.channel-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: box-shadow var(--dur) ease-out, border-color var(--dur);
  animation: fadeIn 0.3s ease-out both;
}
.channel-card:hover {
  box-shadow: 0 0 0 1px var(--accent-glow);
  border-color: var(--accent-glow);
}

.channel-card-top {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  align-items: flex-start;
}
.channel-thumb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 2px solid var(--border-subtle);
}
.channel-thumb-placeholder {
  background: linear-gradient(135deg, var(--accent-dim), var(--surface-2));
}
.stack-card .channel-thumb {
  width: 72px;
  height: 72px;
}
.channel-info { min-width: 0; flex: 1; }
.channel-name {
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-link {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--dur);
}
.channel-link:hover { color: var(--accent); }
.channel-stats {
  display: flex;
  gap: 10px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.channel-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.channel-note {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.channel-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.channel-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.engineer-badge {
  font-size: var(--text-xs);
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* ── Stack toggle buttons (+/-) ────────────────────────────── */
.btn-stack {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur);
}
.btn-stack-add {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-stack-add:hover {
  background: var(--accent);
  color: #040714;
}
.btn-stack-remove {
  border-color: #f87171;
  color: #f87171;
}
.btn-stack-remove:hover {
  background: #f87171;
  color: #040714;
}

/* ── Stack card layout ────────────────────────────────────── */
.stack-card-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.stack-card-thumb {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stack-card-body {
  flex: 1;
  min-width: 0;
}
.stack-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  width: 24px; height: 24px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur);
}
.btn-icon:hover { color: var(--accent); border-color: var(--accent); }

/* ── YouTube category ─────────────────────────────────────── */
.channel-yt-category {
  font-size: var(--text-xs);
  color: var(--accent);
  margin-bottom: 4px;
  opacity: .7;
}

/* ── Tags ─────────────────────────────────────────────────── */
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.tag-collection {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(103,232,249,.2);
  cursor: pointer;
  transition: background var(--dur);
}
.tag-collection:hover { background: rgba(103,232,249,.25); }

/* ── User card grid ───────────────────────────────────────── */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.user-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow var(--dur), border-color var(--dur);
  animation: fadeIn 0.3s ease-out both;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.user-card:hover {
  box-shadow: 0 0 0 1px var(--accent-glow);
  border-color: var(--accent-glow);
}
.user-card-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--text-base); flex-shrink: 0;
}
.user-card-info { flex: 1; min-width: 0; }
.user-handle { font-size: var(--text-xs); color: var(--text-muted); }
.user-name {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
}
.user-name:hover { text-decoration: underline; }
.user-bio {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-stats {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}
.user-link {
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
}
.user-link:hover { text-decoration: underline; }
.user-link.small { font-size: var(--text-xs); }

/* ── Match badge ──────────────────────────────────────────── */
.match-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.match-high { background: rgba(52,211,153,.15); color: #34d399; }
.match-mid { background: rgba(251,191,36,.15); color: #fbbf24; }
.match-low { background: rgba(156,163,175,.1); color: #9ca3af; }
.match-none { display: none; }

/* ── Collection cards ─────────────────────────────────────── */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.collection-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: box-shadow var(--dur), border-color var(--dur);
  animation: fadeIn 0.3s ease-out both;
}
.collection-card:hover {
  box-shadow: 0 0 0 1px var(--accent-glow);
  border-color: var(--accent-glow);
}
.collection-name {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
}
.collection-name:hover { text-decoration: underline; }
.collection-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}
.collection-image {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.collection-cover {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.collection-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 6px;
}
.collection-header {
  margin-bottom: 24px;
}
.collection-header h2 { margin-bottom: 4px; }

/* ── Profile ──────────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.profile-info h2 { margin-bottom: 4px; }
.profile-bio {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.profile-stats {
  display: flex;
  gap: 16px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.profile-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Stack header ─────────────────────────────────────────── */
.stack-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stack-actions { display: flex; gap: 8px; margin-left: auto; }

/* ── Explore header ───────────────────────────────────────── */
.explore-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.search-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--text-sm);
  flex: 1;
  max-width: 300px;
}

/* ── Rec card ─────────────────────────────────────────────── */
.rec-card { border-left: 3px solid var(--accent); }
.rec-from {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 8px;
}
.rec-message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 8px;
}

/* ── Search overlay ───────────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
}
.search-overlay[hidden] { display: none; }
.search-panel {
  background: #0d1117;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 70vh;
  overflow-y: auto;
}
.search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: #0d1117;
  z-index: 1;
}
.search-header input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--text-base);
}
.search-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5em;
  cursor: pointer;
  padding: 4px 8px;
}
.search-close:hover { color: var(--text-primary); }

.search-results { padding: 8px; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: background var(--dur);
}
.search-result-item:hover { background: var(--surface-2); }
.search-result-info {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.search-thumb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 2px solid var(--border-subtle);
}
.search-thumb-placeholder {
  background: linear-gradient(135deg, var(--accent-dim), var(--surface-2));
}

/* ── Recommend panel ──────────────────────────────────────── */
.recommend-panel {
  max-width: 400px;
}
.recommend-body {
  padding: 16px;
}
.recommend-body input {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--text-sm);
}

/* ── Tag editor overlay ───────────────────────────────────── */
.tag-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tag-editor-overlay[hidden] { display: none; }
.tag-editor {
  background: #0d1117;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 400px;
}
.tag-editor h3 { margin-bottom: 12px; }
.tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.tag-option {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background var(--dur);
}
.tag-option:has(input:checked) {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.tag-option input { display: none; }
.tag-note-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--text-sm);
  margin-bottom: 12px;
}
.tag-editor-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon {
  font-size: 3em;
  margin-bottom: 16px;
}
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 16px; }

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

/* ── Entrance animation ───────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: #1a1730; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 10px 16px;
  font-size: 0.84rem; color: var(--text-primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.55);
  pointer-events: none;
  transform: translateY(8px); opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.visible { opacity: 1; transform: translateY(0); }

/* ── Footer ────────────────────────────────────────────────── */
.info-footer {
  text-align: center; padding: 20px var(--space-6) 28px;
  color: var(--text-muted); font-size: .78em; line-height: 1.8;
  border-top: 1px solid var(--border-subtle);
  margin-top: 48px;
}
.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--dur);
}
.footer-link:hover,
.footer-link:focus-visible {
  color: var(--text-secondary);
  text-decoration: underline;
}

/* ── Focus styles ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Skip link ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: #040714;
  font-weight: 600;
  font-size: var(--text-sm);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: top var(--dur);
}
.skip-link:focus { top: 0; }

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

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-bar { padding: 0 var(--space-3); }
  .header-subtitle { display: none; }
  nav { gap: 4px; }
  .nav-link { padding: 5px 8px; font-size: var(--text-xs); }
  .container { padding: var(--space-4); }
  .channel-grid { grid-template-columns: 1fr; }
  .user-grid { grid-template-columns: 1fr; }
  .collection-grid { grid-template-columns: 1fr; }
  .profile-header { flex-direction: column; }
  .profile-actions { margin-left: 0; }
  .stack-header { flex-direction: column; align-items: flex-start; }
  .stack-actions { margin-left: 0; }
  .explore-header { flex-direction: column; align-items: flex-start; }
  .search-input { max-width: 100%; }
}

@media (max-width: 480px) {
  .header-logo h1 { font-size: 1em; }
  .channel-card { padding: 12px; }
}

/* ── Bulk Import Modal ─────────────────────────────────────── */
.bulk-import-overlay .tag-editor {
  max-width: 600px;
}

.bulk-import-disclaimer {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.bulk-import-disclaimer p {
  margin-bottom: 8px;
  line-height: 1.5;
}

.bulk-import-disclaimer ul {
  margin-left: 20px;
  margin-top: 8px;
}

.bulk-import-disclaimer li {
  margin-bottom: 4px;
}

.bulk-import-disclaimer strong {
  color: var(--accent);
}

.bulk-import-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-sm);
  resize: vertical;
  min-height: 120px;
}

.bulk-import-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: var(--space-3);
}

.bulk-import-results {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
}

.bulk-import-results .success-msg {
  color: #34d399;
  margin-bottom: 8px;
}

.bulk-import-results .info-msg {
  color: var(--text-muted);
  margin-bottom: 8px;
}

.bulk-import-results .error-msg {
  color: #f87171;
  margin-bottom: 8px;
}

.bulk-import-results ul {
  margin-left: 20px;
  margin-top: 8px;
  color: #f87171;
}

/* ── Image Upload Area ────────────────────────────────────── */
.image-upload-area {
  position: relative;
  transition: border-color var(--dur);
}

.image-upload-area:hover {
  border-color: var(--accent) !important;
}

.image-upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-preview img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ── Shared Videos Modal ──────────────────────────────────── */
.videos-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.videos-modal-overlay[hidden] { display: none; }

.videos-modal {
  background: #0d1117;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.videos-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.videos-modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.videos-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5em;
  cursor: pointer;
  padding: 4px 8px;
}

.videos-close:hover { color: var(--text-primary); }

.videos-modal-body {
  padding: var(--space-4);
  overflow-y: auto;
  flex: 1;
}

/* ── Individual Video Cards ───────────────────────────────── */
.video-card {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-3);
  background: var(--surface-1);
  transition: transform var(--dur), border-color var(--dur);
}

.video-card:hover {
  border-color: var(--accent-glow);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.video-thumbnail {
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 90px;
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-1);
}

.video-title {
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 4px;
}

.video-title:hover { color: var(--accent); }

.video-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.shared-by { font-weight: 500; }

.video-score {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.video-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-self: center;
}

.video-vote-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 60px;
  justify-content: center;
}

.video-vote-btn.vote-active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.vote-count {
  min-width: 16px;
  text-align: center;
  font-weight: 600;
}

@media (max-width: 768px) {
  .video-card {
    grid-template-columns: 120px 1fr;
  }

  .video-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-subtle);
  }
}

.card-elevated {
  background: linear-gradient(160deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ── Action Bar ────────────────────────────────────────────── */
.channel-actions-bar {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.action-btn {
  flex: 1;
  min-width: 80px;
  padding: 6px 12px !important;
  font-size: 0.85rem !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.action-btn .btn-sm {
  padding: 4px 8px !important;
  font-size: 0.8rem !important;
}

/* ── Sort controls ─────────────────────────────────────────── */
.sort-controls {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Profile Page Redesign ─────────────────────────────────── */
.profile-header-v2 {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-6);
  align-items: center;
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-1));
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3D0080);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.profile-info-v2 h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
  letter-spacing: -0.5px;
}

.profile-bio-v2 {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.5;
  max-width: 600px;
}

.profile-stats-v2 {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  min-width: 80px;
}

.profile-stat-value {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--accent);
}

.profile-username-sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: -2px;
}

.profile-settings {
  max-width: 480px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.settings-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.settings-input {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: var(--text-base);
  font-family: inherit;
  resize: vertical;
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-toggle-row {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; margin-top: var(--space-2);
}
.settings-toggle-row input[type="checkbox"] { display: none; }
.toggle-switch {
  width: 38px; height: 20px; background: var(--surface-2); border-radius: 10px;
  position: relative; transition: background var(--dur); flex-shrink: 0;
}
.toggle-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted);
  transition: transform var(--dur), background var(--dur);
}
.settings-toggle-row input:checked + .toggle-switch { background: var(--accent-dim); }
.settings-toggle-row input:checked + .toggle-switch::after { transform: translateX(18px); background: var(--accent); }
.settings-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: -4px; }

.profile-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Match Score Badge ─────────────────────────────────────── */
.match-badge-v2 {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: white;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  box-shadow: 0 2px 8px rgba(103,232,249,0.3);
}

.match-badge-v2::before {
  content: '✦';
  font-size: var(--text-xs);
}

/* ── Two-column Layout ────────────────────────────────────── */
.profile-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
  align-items: start;
}

.profile-main {
  /* Main content area */
}

.profile-sidebar {
  position: sticky;
  top: calc(68px + var(--space-4));
}

/* ── Responsive Cards ─────────────────────────────────────── */
@media (min-width: 1200px) {
  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  }
}

@media (min-width: 769px) and (max-width: 1199px) {
  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
  }
  .profile-layout {
    grid-template-columns: 1fr;
  }
  .profile-sidebar {
    position: static;
  }
}

/* ── Highlights Modal ─────────────────────────────────────── */
.highlights-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}

.highlights-modal {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.highlights-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.highlights-modal-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
}

.highlights-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.highlights-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

/* Highlight cards */
.highlight-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  background: var(--surface-2);
}

.highlight-thumbnail {
  flex-shrink: 0;
  width: 120px;
  height: 68px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.highlight-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.highlight-title {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight-meta {
  display: flex;
  gap: 12px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.highlight-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.highlight-vote-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: var(--text-xs);
}

.highlight-vote-btn.vote-active {
  background: var(--accent-dim);
  color: var(--accent);
}

.add-highlight-form {
  padding: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  background: var(--surface-2);
}

.add-highlight-form h4 {
  margin: 0 0 12px 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ── Overflow Menu ─────────────────────────────────────────── */
.overflow-menu-wrapper {
  position: relative;
}
.overflow-trigger {
  font-size: 1.2em;
  letter-spacing: 2px;
  min-width: 36px;
  justify-content: center;
}
.overflow-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.overflow-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 100;
  background: #0d1117;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  min-width: 180px;
  padding: 4px 0;
}
.overflow-menu.open { display: block; }
.overflow-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast);
}
.overflow-menu-item:hover { background: var(--surface-2); }
.overflow-menu-item--danger { color: #f87171; }
.overflow-menu-item--danger:hover { background: rgba(248,113,113,.08); }

/* ── Breadcrumbs ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: var(--text-sm);
}
.breadcrumb-link {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur);
}
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-current { color: var(--text-secondary); }

/* ── Section Labels ────────────────────────────────────────── */
.section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 6px;
}
.section-label--trending { color: #fbbf24; }
.section-label--recent { color: var(--accent); }

/* ── Section dividers ──────────────────────────────────────── */
.feed-section + .feed-section { border-top: 1px solid var(--border-subtle); padding-top: 32px; }

/* ── Section header row (title + sort) ─────────────────────── */
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* ── Sort controls ─────────────────────────────────────────── */
.sort-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.sort-select {
  margin-left: 8px;
  padding: 4px 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

/* ── Collection detail actions ─────────────────────────────── */
.collection-detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

/* ── Recommend overlay title ───────────────────────────────── */
.recommend-title {
  flex: 1;
  font-size: 1.1em;
}

/* ── Action icon (inside action bar) ───────────────────────── */
.action-icon { font-size: 1.2em; }

/* ── Utility: full-width button ────────────────────────────── */
.btn--full { width: 100%; }

/* ── Responsive: overflow menus ────────────────────────────── */
@media (max-width: 480px) {
  .overflow-menu { min-width: 160px; }
}
