﻿:root {
  --bg: #0b0f12;
  --surface: #141c20;
  --surface-hover: #1a2429;
  --line: #2a373d;
  --line-light: #3a4a52;
  --text: #f0f4f5;
  --muted: #9fb0b7;
  --accent: #2bb07f;
  --accent-hover: #34ce96;
  --accent-soft: rgba(43, 176, 127, 0.15);
  --ai-brand: #b89bff;
  --ai-bg: rgba(139, 92, 246, 0.18);
  --danger: #e06c75;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-lg: rgba(0, 0, 0, 0.6);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, #17262a 0%, var(--bg) 50%, #080b0d 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  pointer-events: none;
}

.bg-shape-a {
  width: 350px;
  height: 350px;
  background: var(--accent);
  top: -100px;
  right: 5%;
}

.bg-shape-b {
  width: 400px;
  height: 400px;
  background: #67542b;
  bottom: -150px;
  left: -100px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0 32px;
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 18, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* Brand logo + name */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 24px;
}

.topbar-brand span {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff, var(--muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Navigation links */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.topbar-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.topbar-nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.topbar-nav-link.active {
  color: var(--accent);
  background: rgba(43, 176, 127, 0.12);
  font-weight: 600;
}

/* Right-side actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Icon-only button */
.btn.icon-only {
  padding: 0;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
}

/* Sub-toolbar */
.sub-toolbar {
  position: sticky;
  top: 56px;
  z-index: 40;
  padding: 10px 32px;
  background: rgba(11, 15, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(58, 74, 82, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sub-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sort-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Date range filter */
.date-range-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  height: 42px;
}

.date-range-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.date-input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  padding: 0;
  width: 110px;
  cursor: pointer;
}

.date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.date-input:focus {
  box-shadow: none;
  border-color: transparent;
}

.btn-date-apply {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 10px;
  height: 26px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-date-apply:hover {
  background: var(--accent-hover);
}

/* Success score badges */
.score-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 0 16px 4px;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: help;
  letter-spacing: 0.01em;
}

.score-fire {
  background: rgba(255, 80, 50, 0.18);
  color: #ff7754;
  border: 1px solid rgba(255, 80, 50, 0.35);
}

.score-hot {
  background: rgba(43, 176, 127, 0.15);
  color: var(--accent-hover);
  border: 1px solid rgba(43, 176, 127, 0.3);
}

.score-avg {
  background: rgba(159, 176, 183, 0.12);
  color: var(--muted);
  border: 1px solid rgba(159, 176, 183, 0.25);
}

.score-low {
  background: rgba(224, 108, 117, 0.1);
  color: var(--danger);
  border: 1px solid rgba(224, 108, 117, 0.25);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

input,
textarea,
select,
button {
  font: inherit;
  outline: none;
  transition: var(--transition);
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #11181b;
}

#searchInput {
  flex: 1;
  min-width: 200px;
}

#sortBy {
  min-width: 170px;
}

.btn-icon-square {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-square:hover {
  background: var(--line);
  border-color: var(--line-light);
}

.btn-sort-dir svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-sort-dir[data-dir="asc"] svg {
  transform: rotate(180deg);
}

.btn-advanced-filters {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 42px;
  background: transparent;
  border: 1px dashed var(--muted);
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: var(--transition);
}

.btn-advanced-filters:hover,
.btn-advanced-filters.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(43, 176, 127, 0.1);
}

.btn {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.btn-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.08);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.8);
  color: #fecaca;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: transparent;
}

.btn-link {
  text-decoration: none;
}

.btn-filter-fav {
  background: transparent;
  border: 1px solid var(--line);
  height: 42px;
  padding: 0 16px;
}

.btn-filter-fav svg {
  width: 16px;
  height: 16px;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 2;
}

.btn-filter-fav[aria-pressed="true"] {
  background: rgba(251, 191, 36, 0.1);
  border-color: #fbbf24;
  color: #fbbf24;
}

.btn-filter-fav[aria-pressed="true"] svg {
  fill: #fbbf24;
  stroke: #fbbf24;
}

main {
  padding: 24px 40px 40px;
  width: 100%;
  max-width: none;
  margin: 0;
}

.onboarding-banner {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(139, 92, 246, 0.5);
  background: rgba(139, 92, 246, 0.12);
  color: #dcc9ff;
  font-size: 0.9rem;
}

.filter-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.advanced-filters-panel {
  display: none;
  background: rgba(20, 28, 32, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 4px;
  animation: slideDown 0.2s ease-out;
}

.advanced-filters-panel.is-open {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.metrics-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.metrics-filters input {
  width: 140px;
  height: 40px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line-light);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.chip:hover {
  color: var(--text);
  border-color: var(--text);
}

.chip.active {
  color: #111827;
  background: #ffffff;
  border-color: #ffffff;
}

.chip.exclude {
  color: #ffffff;
  background: #dc2626;
  border-color: #dc2626;
}

.hint-icon,
.hint-block {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.hint-block {
  justify-content: flex-start;
  gap: 4px;
}

.hint-icon::after,
.hint-block::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(9, 12, 14, 0.95);
  color: #f8fafc;
  border: 1px solid var(--line);
  font-size: 0.74rem;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.hint-icon:hover::after,
.hint-block:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.dynamic-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  max-width: 280px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(9, 12, 14, 0.97);
  color: #f8fafc;
  border: 1px solid var(--line);
  font-size: 0.76rem;
  line-height: 1.25;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.dynamic-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.chip-uncat {
  border-color: rgba(16, 185, 129, 0.55);
}

.chip-pulse {
  animation: chipPulse 1.5s ease-in-out infinite;
}

@keyframes chipPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.25);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
}

.summary {
  margin-top: 12px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 24px;
}

.channel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 8px 24px var(--shadow);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
  display: flex;
  flex-direction: column;
}

.channel-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  border-color: var(--line-light);
}

.channel-grid.is-masonry {
  display: block;
  width: 100%;
  margin: 0 auto;
}

.channel-grid.is-masonry .channel-card {
  width: calc(16.666% - 20px);
  margin-bottom: 24px;
  transition: top 0.4s ease, left 0.4s ease, transform 0.2s, box-shadow 0.2s;
}

.channel-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent-hover);
  box-shadow: 0 16px 40px var(--shadow-lg);
}

.banner {
  position: relative;
  height: 120px;
  background-size: cover;
  background-position: center;
  background-color: var(--line);
}

.btn-fav {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.btn-fav:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.05);
}

.star-icon {
  width: 18px;
  height: 18px;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 2;
  transition: fill 0.2s, stroke 0.2s, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-fav[aria-pressed="true"] .star-icon {
  fill: #fbbf24;
  stroke: #fbbf24;
  transform: scale(1.15);
  animation: starPop 0.3s ease;
}

@keyframes starPop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.4);
  }

  100% {
    transform: scale(1.15);
  }
}

.card-body {
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.title-row {
  margin-top: 0;
  display: flex;
  gap: 16px;
  align-items: center;
}

.logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid var(--surface);
  background: var(--surface);
  object-fit: cover;
}

.title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 2px;
}

.meta {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: monospace;
}

.metrics {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.metric {
  text-align: center;
}

.metric .label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.metric .value {
  display: block;
  font-size: 0.85rem;
  font-weight: 800;
}

.description {
  margin: 14px 0;
  color: #c9d6db;
  line-height: 1.55;
  font-size: 0.86rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

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

.video-item {
  min-width: 0;
}

.video {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.video img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.video:hover img {
  border-color: var(--accent);
  transform: scale(1.03);
}

.video-title {
  display: -webkit-box;
  margin-top: 8px;
  font-size: 0.75rem;
  line-height: 1.3;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-stats {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.video-meta-row {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.video-cats {
  min-width: 0;
  flex: 1;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-cat-edit {
  width: 26px;
  min-width: 26px;
  height: 26px;
  font-size: 0.72rem;
  line-height: 1;
}

.card-actions,
.category-row,
.suggestion-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.card-actions .btn,
.category-row .btn,
.category-row input {
  flex: 1;
}

.category-row {
  margin-top: 6px;
}

.channel-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  min-height: 16px;
}

.card-categories {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.channel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.channel-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text);
  white-space: nowrap;
}

.btn-chip {
  background: transparent;
  border: 1px dashed var(--muted);
  color: var(--muted);
}

.btn-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(43, 176, 127, 0.1);
}

.card-actions {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions .btn {
  flex: auto;
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.8rem;
}

/* Нові стилі для мінімалістичного інпуту нотаток */
.custom-notes-input {
  width: 100%;
  border: 1px dashed var(--line-light);
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  resize: vertical;
  display: block;
  font-family: inherit;
  font-size: 0.85em;
  box-sizing: border-box;
  line-height: 1.4;
  transition: all 0.2s ease;
  min-height: 38px;
  cursor: text;
}

.custom-notes-input::placeholder {
  color: rgba(159, 176, 183, 0.5);
}

.custom-notes-input:focus,
.custom-notes-input:not(:placeholder-shown) {
  border-style: solid;
  border-color: var(--accent);
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 0 2px var(--accent-soft);
  min-height: 60px;
}

.suggestion-row {
  align-items: center;
}

.suggestion-pill {
  flex: 1;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--ai-bg);
  color: var(--ai-brand);
  border: 1px solid rgba(139, 92, 246, 0.4);
  font-size: 0.78rem;
}

.btn-icon {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-light);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

dialog {
  margin: auto;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-lg);
  width: min(500px, calc(100% - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  padding: 0;
}

dialog::backdrop {
  background: rgba(4, 8, 10, 0.8);
  backdrop-filter: blur(4px);
}

.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--line);
  color: var(--text);
  cursor: pointer;
}

.dialog-form {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.import-result {
  background: #0a0e10;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.empty-state {
  margin: 40px auto 20px;
  max-width: 430px;
  text-align: center;
  border: 1px dashed var(--line-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: rgba(20, 26, 31, 0.5);
}

.empty-icon {
  font-size: 2.4rem;
  color: #64748b;
  margin-bottom: 10px;
}

.empty-state h2 {
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--muted);
  margin-bottom: 14px;
}

.sentinel {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-light);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  animation: toastIn 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.55);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.55);
}

.toast.info {
  border-color: rgba(59, 130, 246, 0.55);
}

.hidden-by-filter {
  display: none !important;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.v-chip {
  font-size: 0.68rem;
  padding: 2px 8px;
  background: var(--surface-hover);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
}

.v-chip-empty {
  opacity: 0.8;
}

.cat-popover {
  position: absolute;
  z-index: 9999;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--line-light);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.cat-popover[data-pos="top"] {
  transform: translateY(10px) scale(0.98);
}

.cat-popover.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 1px solid var(--line);
  padding-left: 12px;
  margin-left: 4px;
}

.user-email {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: monospace;
}

.auth-dialog {
  width: min(400px, calc(100% - 32px));
}

dialog[open] {
  animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--line-light) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.auth-dialog::backdrop {
  background: rgba(4, 8, 10, 0.95);
  backdrop-filter: blur(8px);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}

.auth-tab {
  flex: 1;
  padding: 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: rgba(255, 255, 255, 0.03);
}

.auth-form {
  padding-top: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.auth-error {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.85rem;
  text-align: center;
}

.popover-header {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.1);
}

.popover-header input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-light);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 8px 12px;
}

.popover-header input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 176, 127, 0.2);
  outline: none;
}

.popover-list-wrap {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-light) transparent;
}

.popover-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  list-style: none;
  margin: 0;
  padding: 4px;
}

.popover-list li {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}

.popover-list-wrap::-webkit-scrollbar {
  width: 6px;
}

.popover-list-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.popover-list-wrap::-webkit-scrollbar-thumb {
  background-color: var(--line-light);
  border-radius: 10px;
}

.popover-list-wrap::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent);
}

.popover-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  font-size: 0.8rem;
  padding: 6px 12px;
}

.popover-empty {
  width: 100%;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 8px 10px;
}

.create-hint {
  margin-top: 6px;
  padding: 8px 10px;
  color: var(--accent);
  font-size: 0.85rem;
  background: rgba(43, 176, 127, 0.1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.create-hint kbd {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
}

.popover-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.1);
}

.popover-footer .btn {
  padding: 6px 14px;
  font-size: 0.85rem;
}

@media (max-width: 1600px) {
  .channel-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .channel-grid.is-masonry .channel-card {
    width: calc(20% - 20px);
  }
}

@media (max-width: 1200px) {
  .channel-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .channel-grid.is-masonry .channel-card {
    width: calc(25% - 20px);
  }
}

@media (max-width: 900px) {
  .channel-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .channel-grid.is-masonry .channel-card {
    width: calc(33.333% - 20px);
  }
}

@media (max-width: 768px) {
  .topbar {
    position: sticky;
    top: 0;
    padding: 0 12px;
    height: 56px;
    gap: 8px;
  }

  .topbar-brand {
    margin-right: 8px;
  }

  .topbar-brand span,
  .user-email,
  #logoutBtn {
    display: none;
  }

  .topbar-nav {
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topbar-nav::-webkit-scrollbar {
    display: none;
  }

  .topbar-nav-link {
    font-size: 0.82rem;
    padding: 6px 10px;
  }

  .sub-toolbar {
    top: 56px;
    padding: 10px 12px;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
  }

  .sub-toolbar-right {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .sort-group {
    flex: 1 1 220px;
  }

  #sortBy {
    min-width: 0;
    width: 100%;
  }

  .date-range-group {
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
  }

  .date-input {
    width: 100px;
  }

  #filters {
    padding: 0 16px !important;
  }

  main {
    padding: 20px 16px 32px;
  }

  .metrics-filters input {
    width: calc(50% - 4px) !important;
  }

  .toolbar {
    width: 100%;
  }

  #searchInput {
    min-width: 100%;
  }

  .filter-bar {
    flex-direction: column;
  }

  .channel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .topbar {
    height: 52px;
    padding: 0 10px;
  }

  .sub-toolbar {
    top: 52px;
    padding: 8px 10px;
  }

  .btn-filter-fav {
    padding: 0 12px;
  }

  .btn-filter-fav,
  .btn-advanced-filters,
  .sort-group {
    flex: 1 1 100%;
  }

  .btn-icon-square {
    flex-shrink: 0;
  }

  .channel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .channel-grid.is-masonry .channel-card {
    width: calc(50% - 16px);
  }
}

/* Bulk Actions */
.card-selection {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  opacity: 0;
  transition: opacity var(--transition);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  padding: 4px;
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.channel-card:hover .card-selection,
.channel-card.selected .card-selection,
.channel-card:focus-within .card-selection {
  opacity: 1;
}

.channel-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.channel-select-cb {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
  display: block;
}

.bulk-action-bar {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line-light);
  padding: 12px 24px;
  border-radius: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 100;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bulk-count {
  font-weight: 700;
  color: #fff;
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 40px);
    opacity: 0;
  }

  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}
