/* ============================================================
   MediaWhack Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg: #e8ecf1;
  --bg-page: #f5f5f8;
  --surface: #ffffff;
  --surface-soft: #f4f6f9;
  --surface-hover: #fafafe;
  --border: #dfe3ea;
  --border-hover: #c8cdd6;
  --text: #1a1f2e;
  --text-secondary: #5a6070;
  --text-muted: #98a0b0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.07);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.08);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --radius: 14px;
  --radius-lg: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.03);
  --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  --font: "Outfit", -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --sidebar-w: 244px;
}

html.dark {
  --bg: #131620;
  --bg-page: #181b26;
  --surface: #1e2230;
  --surface-soft: #242838;
  --surface-hover: #282d3e;
  --border: #2e3346;
  --border-hover: #3d4460;
  --text: #e4e7ed;
  --text-secondary: #a0a6b8;
  --text-muted: #646d82;
  --accent: #4b83f0;
  --accent-hover: #6b9df5;
  --accent-soft: rgba(75, 131, 240, 0.12);
  --success: #34d673;
  --success-soft: rgba(52, 214, 115, 0.12);
  --danger: #f04848;
  --danger-soft: rgba(240, 72, 72, 0.12);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.15);
  --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
}

/* ============================================================
   Reset & Base
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: var(--font);
}

input {
  font-family: var(--font);
}

/* ============================================================
   Layout
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-radius: 0 24px 24px 0;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
  padding: 24px 0;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 44px 64px;
}

.main-board {
  flex: 1;
  margin-left: var(--sidebar-w);
  overflow: hidden;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Sidebar Elements
   ============================================================ */

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  margin-bottom: 30px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Sora', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}

.logo-text-thin {
  font-weight: 400;
  opacity: 0.5;
}

.logo-login {
  justify-content: center;
  margin-bottom: 24px;
}

.logo-login .logo-icon {
  width: 36px;
  height: 36px;
}

.logo-login .logo-text {
  font-size: 1.4rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  text-decoration: none;
  width: 100%;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
  flex-shrink: 0;
}

.nav-item.active svg {
  stroke-width: 2;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 22px;
}

.sidebar-section {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 22px;
  margin-bottom: 8px;
}

.sub-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 12px;
}

.sub-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.sub-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.sub-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sub-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.sub-avatar-init {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
}

.sub-avatar-img {
  object-fit: cover;
}

.sub-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sub-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 8px 22px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 20px 22px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

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

.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.topbar-back:hover {
  color: var(--text);
}

.topbar-back svg {
  width: 16px;
  height: 16px;
}

.greeting {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 13px;
  padding: 0 7px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.topbar-btn:hover {
  background: var(--surface-soft);
  border-color: var(--border-hover);
  color: var(--text);
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow var(--transition);
}

.topbar-avatar:hover {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* User menu dropdown */
.user-menu-wrapper {
  position: relative;
}

.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 100;
  padding: 6px;
}

.user-menu.open {
  display: block;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: background 0.15s ease;
  text-align: left;
}

.user-menu-item:hover:not(:disabled) {
  background: var(--surface-soft);
}

.user-menu-item:disabled {
  color: var(--text-muted);
  cursor: default;
}

.user-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Settings modal extras */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0;
}

.settings-row label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.settings-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

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

/* Toggle switch */
.settings-toggle {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.settings-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-toggle-track {
  display: block;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--border);
  transition: background 0.2s ease;
  position: relative;
}

.settings-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
}

.settings-toggle input:checked + .settings-toggle-track {
  background: var(--accent);
}

.settings-toggle input:checked + .settings-toggle-track::after {
  transform: translateX(20px);
}

.settings-input {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
  transition: border-color 0.15s ease;
}

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

.settings-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-settings-save {
  padding: 8px 16px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.btn-settings-save:hover:not(:disabled) {
  opacity: 0.85;
}

.btn-settings-save:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ============================================================
   Header (Board Pages)
   ============================================================ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-shrink: 0;
}

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

.channel-dropdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

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

/* ============================================================
   Search
   ============================================================ */

.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-card);
}

.search-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.search-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-input {
  flex: 1;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 16px;
  font-size: 0.96rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-btn {
  height: 46px;
  padding: 0 26px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

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

.search-feedback {
  min-height: 22px;
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 220px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  outline: none;
  transition: all var(--transition);
}

.search-pill:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================================================
   Result Card (Search Result)
   ============================================================ */

.result-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: slideUp 0.3s var(--transition) both;
}

.result-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

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

.result-handle {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 2px;
}

.result-name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.result-btn {
  height: 34px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

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

.result-btn.saved {
  background: var(--success-soft);
  color: var(--success);
}

/* ============================================================
   Section Headers
   ============================================================ */

.section-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.section-title {
  font-size: 1.14rem;
  font-weight: 700;
}

.section-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: color var(--transition);
}

.section-link:hover {
  color: var(--accent-hover);
}

/* ============================================================
   Suggested Channels Grid
   ============================================================ */

.suggested-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.suggested-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.suggested-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: all var(--transition);
}

.suggested-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card);
}

.suggested-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.suggested-avatar-init {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

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

.suggested-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggested-handle {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.suggested-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
}

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

/* ============================================================
   Story Cards (Dashboard Grid)
   ============================================================ */

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

/* Date timeline headers */
.date-timeline-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 14px;
}

.date-timeline-header:first-child {
  margin-top: 0;
}

.date-timeline-pill {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 16px;
  border-radius: 100px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.date-timeline-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.date-timeline-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.story-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: default;
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.story-card:nth-child(1) { animation: cardReveal 0.4s var(--transition) 0.00s both; }
.story-card:nth-child(2) { animation: cardReveal 0.4s var(--transition) 0.06s both; }
.story-card:nth-child(3) { animation: cardReveal 0.4s var(--transition) 0.12s both; }
.story-card:nth-child(4) { animation: cardReveal 0.4s var(--transition) 0.18s both; }
.story-card:nth-child(5) { animation: cardReveal 0.4s var(--transition) 0.24s both; }
.story-card:nth-child(6) { animation: cardReveal 0.4s var(--transition) 0.30s both; }

a.story-card {
  cursor: pointer;
}

.story-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
}

.story-card:hover .story-thumb img {
  transform: scale(1.04);
}

.story-thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-soft);
  position: relative;
}

.story-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--transition);
}

.story-thumb-badge {
  margin-top: auto;
  align-self: flex-end;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 105px;
}

.story-thumb-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.story-thumb-badge.captured {
  background: var(--success);
  color: #fff;
}

.story-thumb-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.story-info {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.story-channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.story-channel-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.story-channel-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.story-card-title {
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 6px;
}

.story-card-sting {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  margin: 0 0 8px;
}

.story-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================
   Board Layout (Stories Page)
   ============================================================ */

.board {
  flex: 1;
  display: flex;
  gap: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
}

.board::-webkit-scrollbar {
  height: 6px;
}

.board::-webkit-scrollbar-track {
  background: transparent;
}

.board::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.board::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

.column {
  min-width: 290px;
  width: 290px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.column-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.column-name {
  font-size: 0.92rem;
  font-weight: 700;
}

.column-count {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.column-cards {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.column-cards::-webkit-scrollbar {
  width: 4px;
}

.column-cards::-webkit-scrollbar-track {
  background: transparent;
}

.column-cards::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.column-cards::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

.card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--surface-soft);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.card-thumb-wrap .card-thumb {
  margin-bottom: 0;
}

.card:hover .card-thumb img {
  transform: scale(1.03);
}

.card-thumb-wrap {
  position: relative;
  margin-bottom: 12px;
}

.card-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-title {
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 6px;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 12px;
  line-height: 1.5;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-date {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.card-date svg {
  width: 13px;
  height: 13px;
}

.card-channel {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-channel-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.card-channel-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-more {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-muted);
}

.card:hover .card-more {
  opacity: 1;
}

.card-more:hover {
  background: var(--surface-soft);
}

/* ============================================================
   Channel Profile
   ============================================================ */

.channel-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.channel-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  background: var(--text);
}

.channel-avatar-img {
  object-fit: cover;
}

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

.btn-email-subscribe {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transition: all 0.22s ease;
}

.btn-email-subscribe svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.22s ease;
}

.btn-email-subscribe:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
}

.btn-email-subscribe:hover svg {
  transform: translateY(-1px);
}

.btn-email-subscribe.subscribed {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success);
}

.btn-email-subscribe.subscribed:hover {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.25);
}

.channel-avatar-init {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.channel-meta h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.channel-handle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 2px 0 0;
}

.channel-stats {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.channel-stats span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.video-card {
  position: relative;
  cursor: pointer;
}

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

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-soft);
  margin-bottom: 10px;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--transition);
}

.video-card:hover .thumb-wrap img {
  transform: scale(1.03);
}

.duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-captured {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--success);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}

.btn-get {
  margin-top: auto;
  align-self: flex-end;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 105px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition);
}

.btn-get:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-get.sent {
  background: #f59e0b;
  color: #1a1f2e;
  cursor: default;
}

.btn-get.sent .btn-spinner {
  border-color: rgba(26, 31, 46, 0.25);
  border-top-color: #1a1f2e;
}

.btn-get.failed {
  background: var(--danger);
}

.video-info {
  display: flex;
  gap: 10px;
}

.video-info-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
}

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

.video-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 4px;
  transition: color var(--transition);
}

.video-channel {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0;
}

.video-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.video-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================================
   Story Detail — Article Layout
   ============================================================ */

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

.back-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.back-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.article-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 40px;
}

.article-scroll::-webkit-scrollbar { width: 6px; }
.article-scroll::-webkit-scrollbar-track { background: transparent; }
.article-scroll::-webkit-scrollbar-thumb { background: #c8cdd6; border-radius: 3px; }

.article-container {
  max-width: 900px;
  margin: 0 auto;
}

.article-hero {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-soft);
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
}

.article-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.article-title {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
  color: var(--text);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.meta-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.meta-avatar-img {
  object-fit: cover;
}

.meta-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.meta-link:hover .meta-channel {
  color: var(--accent);
}

.meta-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-channel {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.meta-handle {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.meta-separator {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.meta-date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: auto;
}

.meta-date svg {
  width: 15px;
  height: 15px;
  opacity: 0.5;
}

.article-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 40px 44px;
  margin-bottom: 28px;
}

.article-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.article-card h2:first-child {
  margin-top: 0;
}

.article-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 10px;
}

.article-card p {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.article-card p:last-child {
  margin-bottom: 0;
}

.article-card ul {
  margin: 12px 0 20px;
  padding-left: 0;
  list-style: none;
}

.article-card li {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 6px 0 6px 24px;
  position: relative;
}

.article-card li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

.article-card strong {
  color: var(--text);
  font-weight: 600;
}

.article-card blockquote {
  border-left: 3px solid var(--accent);
  margin: 20px 0;
  padding: 12px 20px;
  background: var(--accent-soft);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.article-card blockquote p {
  color: var(--text);
  font-style: italic;
  margin-bottom: 0;
}

.article-card .verdict-box {
  margin-top: 32px;
  padding: 28px 32px;
  background: var(--text);
  border-radius: var(--radius-sm);
  color: var(--surface-soft);
}

.article-card .verdict-box h3,
.article-card .verdict-box p {
  color: var(--surface-soft);
}

.article-card .verdict-box h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 0;
}

.article-card hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.article-card img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

/* n8n story HTML uses email-style table layouts — neutralise them */

/* Strip all fixed widths & email cruft from layout tables */
.article-card table {
  width: 100% !important;
  max-width: 100% !important;
  border-collapse: collapse;
  font-size: inherit;
  display: table;
  background: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  border: none;
  margin: 0;
  padding: 0;
}

.article-card td,
.article-card th {
  width: auto !important;
  color: inherit;
  line-height: 1.6;
}

/* Layout wrapper tables — make them invisible containers */
.article-card table.outer-wrapper,
.article-card table.container-table {
  background: none !important;
  padding: 0 !important;
}

.article-card table.outer-wrapper > tbody > tr > td,
.article-card table.container-table > tbody > tr > td {
  padding: 0 !important;
}

/* Body-padding cells inside email layout — let article-card handle padding */
.article-card td.body-padding {
  padding: 0 !important;
}

/* Images inside layout tables — responsive */
.article-card table img {
  max-width: 100%;
  height: auto !important;
}

/* Hide the duplicate hero thumbnail from the email template */
.article-card table.outer-wrapper img[alt="Video Thumbnail"],
.article-card table.container-table img[alt="Video Thumbnail"] {
  display: none;
}

/* Proper data tables with class or th — get styled borders */
.article-card table.content-table,
.article-card table:has(th) {
  width: auto !important;
  max-width: 100% !important;
  table-layout: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs) !important;
  margin: 20px 0;
  overflow: hidden;
  display: block;
  overflow-x: auto;
}

.article-card table.content-table th,
.article-card table:has(th) th {
  background: var(--surface-soft);
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.article-card table.content-table td,
.article-card table:has(th) td {
  border-bottom: 1px solid var(--surface-soft);
  padding: 12px 14px;
  font-size: 0.92rem;
}

.article-card table.content-table tr:last-child td,
.article-card table:has(th) tr:last-child td {
  border-bottom: none;
}

.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-back:hover {
  border-color: #c8cdd6;
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.btn-back svg {
  width: 16px;
  height: 16px;
}

.btn-youtube {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-youtube:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-youtube svg {
  width: 16px;
  height: 16px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  height: 38px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  gap: 6px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--border);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.14);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--border-hover);
  color: var(--text);
}

/* ============================================================
   Flash Messages
   ============================================================ */

.flash {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

.flash-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.15);
}

.flash-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

/* ============================================================
   Modal
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s var(--transition) both;
}

.modal-content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 10px;
}

.modal-content p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 22px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================
   Login / Auth Page (No Sidebar)
   ============================================================ */

.auth-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-card);
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.auth-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.88rem;
  font-weight: 600;
}

.stack-lg {
  display: grid;
  gap: 18px;
}

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

.auth-link a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

.auth-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.auth-link-btn:hover {
  text-decoration: underline;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 0.94rem;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================================================
   Animations
   ============================================================ */

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

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

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

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
  .video-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main,
  .main-board {
    margin-left: 0;
  }

  .article-card {
    padding: 28px 24px;
  }
}

@media (max-width: 800px) {
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  .main {
    padding: 20px 16px 48px;
  }

  .main-board {
    padding: 16px 12px;
  }

  .article-card {
    padding: 24px 20px;
  }

  .article-title {
    font-size: 1.35rem;
  }

  .article-meta {
    flex-wrap: wrap;
    gap: 10px;
  }

  .meta-date {
    margin-left: 0;
  }

  .article-footer {
    flex-direction: column;
    gap: 12px;
  }

  .article-footer a {
    width: 100%;
    justify-content: center;
  }

  .search-card {
    padding: 20px;
  }

  .channel-header {
    flex-direction: column;
    text-align: center;
  }

  .channel-stats {
    justify-content: center;
  }
}

/* ============================================================
   Utility
   ============================================================ */

.version-footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 0.78rem;
}
