/* ==========================================================================
   StreamHub — Classic High-Density Dark-Charcoal + Crimson Video Portal
   ========================================================================== */

:root,
[data-theme="light"] {
  color-scheme: light;
  /* Default Light / White Theme Palette */
  --bg-page: #ffffff;
  --bg-surface: #f4f4f5;
  --bg-elevated: #e4e4e7;
  --bg-hover: #dcdce0;
  --bg-input: #ffffff;
  --bg-overlay: rgba(17, 17, 17, 0.56);

  /* Crisp Crimson Accents */
  --accent: #e50914;
  --accent-hover: #de2600;
  --accent-soft: rgba(229, 9, 20, 0.1);
  --accent-text: #ffffff;

  /* Typography & Borders */
  --text-primary: #111111;
  --text-secondary: #4b5563;
  --text-muted: #71717a;
  --border-color: #e4e4e7;
  --border-strong: #d4d4d8;

  /* Status Colors */
  --success: #2ba640;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #2563eb;

  /* Layout & Radii */
  --header-height: 56px;
  --subnav-height: 40px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.14);
  --transition-fast: 140ms ease;
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark Charcoal Theme Variables */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #0f0f0f;
  --bg-surface: #181818;
  --bg-elevated: #222222;
  --bg-hover: #2c2c2c;
  --bg-input: #121212;
  --bg-overlay: rgba(0, 0, 0, 0.78);

  --accent: #e50914;
  --accent-hover: #de2600;
  --accent-soft: rgba(229, 9, 20, 0.16);
  --accent-text: #ffffff;

  --text-primary: #f1f1f1;
  --text-secondary: #aaaaaa;
  --text-muted: #777777;
  --border-color: #2c2c2c;
  --border-strong: #3d3d3d;

  --info: #3ea6ff;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 14px;
  overflow-x: clip;
  max-width: 100%;
}

body.app-body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-select option,
.form-select option {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

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

.is-hidden {
  display: none !important;
}

.container-wide {
  width: 100%;
  max-width: 1600px;
  min-width: 0;
  margin-inline: auto;
  padding-inline: 16px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9999;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-page);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   Sticky Top Header & Sub-Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand-mark {
  display: none;
}

.brand-title {
  display: inline-flex;
  align-items: baseline;
  font-size: 1.42rem;
  font-weight: 900;
  letter-spacing: 0.025em;
  line-height: 1;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-accent {
  color: #e50914;
  font-weight: 900;
  font-size: 1.14em;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 10px rgba(229, 9, 20, 0.22);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--success);
}

/* Header Search */
.header-search-wrap {
  position: relative;
  flex: 1;
  max-width: 580px;
}

.search-form {
  display: flex;
  align-items: center;
  height: 36px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.search-form:focus-within {
  border-color: var(--accent);
}

.search-back-btn,
.mobile-search-toggle,
.mobile-only-btn {
  display: none;
}

.search-input-box {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  height: 100%;
}

.search-input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 0 30px 0 12px;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-clear-btn {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  line-height: 1;
  padding: 2px 6px;
}

.search-clear-btn:hover {
  color: var(--text-primary);
}

.search-submit-btn {
  height: 100%;
  padding: 0 14px;
  border: none;
  border-left: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

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

.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  max-height: 360px;
  overflow-y: auto;
}

.search-suggestion-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border-color);
}

.search-suggestion-item:last-child {
  border-bottom: none;
}

.search-suggestion-item:hover,
.search-suggestion-item.is-active {
  background-color: var(--bg-hover);
}

.search-suggestion-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn,
.header-btn {
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 0.86rem;
  font-weight: 600;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn {
  width: 34px;
  padding: 0;
}

.icon-btn:hover,
.header-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.header-btn--accent {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

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

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-dot.is-remote {
  background-color: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.lang-pill {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.profile-avatar-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Desktop Sub-nav */
.desktop-subnav {
  background-color: var(--bg-page);
  border-top: 1px solid var(--border-color);
}

.subnav-inner {
  height: var(--subnav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subnav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.subnav-list::-webkit-scrollbar {
  display: none;
}

.subnav-link {
  display: inline-flex;
  align-items: center;
  height: var(--subnav-height);
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.subnav-link:hover {
  color: var(--text-primary);
}

.subnav-link.is-active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.api-mode-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  white-space: nowrap;
}

.api-mode-badge.is-remote {
  color: var(--success);
  border-color: rgba(43, 166, 64, 0.45);
}

/* ==========================================================================
   Mobile Slide-out Drawer & Sticky Bottom Nav
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
}

.drawer-backdrop.is-hidden {
  pointer-events: none;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 82vw;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 200ms ease, visibility 200ms ease;
}

.mobile-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.drawer-section {
  margin-bottom: 18px;
}

.drawer-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 10px;
}

.drawer-link,
.drawer-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
}

.drawer-link:hover,
.drawer-action-btn:hover {
  background-color: var(--bg-hover);
}

.drawer-link.is-active {
  background-color: var(--accent-soft);
  color: var(--accent);
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 120;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 600;
}

.bottom-nav-item.is-active {
  color: var(--accent);
}

/* ==========================================================================
   Category Ribbon & Feed Controls
   ========================================================================== */
.category-ribbon-section {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.ribbon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-block: 8px;
  width: 100%;
  min-width: 0;
}

.category-ribbon {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
}

.category-ribbon:active {
  cursor: grabbing;
}

.category-ribbon::-webkit-scrollbar {
  display: none;
}

.ribbon-chip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-x;
  user-select: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.ribbon-chip:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.ribbon-chip.is-active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.ribbon-chip--more {
  background-color: var(--accent-soft);
  border-color: rgba(229, 9, 20, 0.35);
  color: var(--accent);
  font-weight: 700;
}

.ribbon-chip--more:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.ribbon-arrow {
  width: 28px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ribbon-arrow:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent);
}

/* Quick Feed Tabs & Filter Bar */
.feed-controls-section {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background-color: var(--bg-page);
  border-bottom: 1px solid var(--border-color);
  padding-top: 8px;
  padding-bottom: 8px;
}

.quick-feed-tabs {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
  padding-bottom: 8px;
  cursor: grab;
  user-select: none;
}

.quick-feed-tabs:active {
  cursor: grabbing;
}

.quick-feed-tabs::-webkit-scrollbar {
  display: none;
}

.feed-tab {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  touch-action: pan-x;
  user-select: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.feed-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.feed-tab.is-active {
  background-color: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.filter-selects {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.filter-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.filter-select {
  height: 28px;
  padding: 0 2px;
  border-radius: 0;
  border: none;
  background-color: transparent;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
}

.filter-select:focus {
  outline: none;
}

.filter-group:focus-within {
  border-color: var(--accent);
}

.filter-right-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.active-filters-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.active-filter-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.active-filter-chip button {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font-weight: 700;
}

.view-toggle-group {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-toggle-btn {
  width: 32px;
  height: 30px;
  border: none;
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.view-toggle-btn.is-active {
  background-color: var(--accent);
  color: var(--accent-text);
}

/* ==========================================================================
   Main Content & High-Density Video Grid
   ========================================================================== */
.main-content {
  flex: 1;
  padding-top: 16px;
  padding-bottom: 36px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.section-heading {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

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

/* Dense 4-column Desktop Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.video-grid--list {
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Video Card */
.video-card {
  position: relative;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: visible;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

@media (hover: hover) {
  .video-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
  }
}

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

.video-card__thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: var(--bg-elevated);
  background-image: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border-color) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: thumbShimmer 1.3s ease-in-out infinite;
  overflow: hidden;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: block;
}

.video-card__thumb-wrap.is-loaded,
.video-card__thumb-wrap.is-thumb-error {
  background-image: none;
  animation: none;
}

.video-card__thumb-link {
  display: block;
  width: 100%;
  height: 100%;
}

.video-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 240ms ease;
}

.video-card:hover .video-card__thumb {
  transform: scale(1.03);
}

.video-card__thumb-wrap.is-thumb-error .video-card__thumb {
  transform: none;
  object-fit: cover;
}

.video-card__duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(12, 12, 14, 0.86);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  pointer-events: none;
  z-index: 2;
}

.video-card__quality {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.03em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 2;
}

.video-card__wl-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(15, 15, 18, 0.78);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 3;
  transition: opacity var(--transition-fast), background-color var(--transition-fast);
}

.video-card:hover .video-card__wl-btn,
.video-card__wl-btn.is-active {
  opacity: 1;
}

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

.video-card__body {
  padding: 10px 11px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.video-card__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background-color: #111216;
  border: 1px solid rgba(229, 9, 20, 0.35);
  color: #e50914;
  font-weight: 900;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-card__avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-fallback {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--accent);
}

.video-card__info {
  flex: 1;
  min-width: 0;
}

.video-card__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.video-card__title {
  margin: 0 0 4px;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

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

.video-card__menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.video-card__menu-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.video-card__menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.video-card__menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  width: 170px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  padding: 4px;
}

.video-card__menu-dropdown button {
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  font-size: 0.82rem;
}

.video-card__menu-dropdown button:hover {
  background: var(--accent);
  color: var(--accent-text);
}

.video-card__channel {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-card__meta {
  font-size: 0.77rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.video-card__desc {
  display: none;
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Compact List Mode Card Variant */
.video-grid--list .video-card {
  flex-direction: row;
  align-items: stretch;
}

.video-grid--list .video-card__thumb-wrap {
  width: 240px;
  flex-shrink: 0;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.video-grid--list .video-card__desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Pagination */
.pagination-bar {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.86rem;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background-color: var(--bg-hover);
}

.page-btn.is-active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

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

/* ==========================================================================
   Watch / Video Player View
   ========================================================================== */
.watch-view {
  overflow-x: clip;
}

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 20px;
  align-items: start;
}

.watch-primary,
.watch-sidebar {
  min-width: 0;
}

.player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.player-wrapper.is-fullscreen {
  border-radius: 0;
  border: none;
  max-height: none;
}

.video-element {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.embed-element {
  border: 0;
}

.player-wrapper.is-embed .player-controls,
.player-wrapper.is-embed .player-big-play,
.player-wrapper.is-embed .player-click-overlay {
  display: none !important;
}

.player-click-overlay {
  position: absolute;
  inset: 0 0 54px 0;
  z-index: 4;
  cursor: pointer;
}

.player-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.spinner-ring {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.player-big-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(229, 9, 20, 0.9);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.player-wrapper.is-paused .player-big-play {
  opacity: 1;
  pointer-events: auto;
}

.player-big-play:hover {
  transform: translate(-50%, -50%) scale(1.07);
  background: var(--accent-hover);
}

.player-center-feedback {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  z-index: 7;
  pointer-events: none;
}

/* Player Custom Controls Overlay */
.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 26px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.55) 60%, transparent);
  color: #ffffff;
  opacity: 0;
  transition: opacity 180ms ease;
}

.player-wrapper:hover .player-controls,
.player-wrapper.is-paused .player-controls,
.player-wrapper.is-controls-visible .player-controls,
.player-wrapper:focus-within .player-controls {
  opacity: 1;
}

.player-progress-wrap {
  position: relative;
  padding: 6px 0;
  cursor: pointer;
}

.player-seek-tooltip {
  position: absolute;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}

.player-progress-track {
  position: relative;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
  transition: height 120ms ease;
}

.player-progress-wrap:hover .player-progress-track {
  height: 7px;
}

.player-progress-buffer {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-pill);
}

.player-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

.player-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  transform: translate(-50%, -50%) scale(0.8);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px #ffffff;
  transition: transform 120ms ease;
}

.player-progress-wrap:hover .player-progress-thumb {
  transform: translate(-50%, -50%) scale(1.05);
}

.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.player-controls-left,
.player-controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-ctrl-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.player-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.player-ctrl-pill {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.player-ctrl-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
}

.player-volume-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.player-volume-slider {
  width: 68px;
  accent-color: var(--accent);
  cursor: pointer;
}

.player-time-display {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: #f1f1f1;
  margin-left: 4px;
  white-space: nowrap;
}

.player-inline-select {
  height: 26px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 20, 20, 0.85);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 600;
}

/* Watch Info & Actions */
.watch-info-card {
  margin-top: 14px;
  padding: 14px 16px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.watch-title {
  margin: 0 0 10px;
  font-size: 1.32rem;
  font-weight: 700;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.watch-stats-actions-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.watch-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 34px;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.quality-badge {
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.category-pill {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 600;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.category-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.watch-actions-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.reaction-cluster {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.reaction-buttons {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.watch-ratio-bar {
  width: 100%;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  overflow: hidden;
}

.watch-ratio-fill {
  height: 100%;
  background: var(--accent);
  transition: width 200ms ease;
}

.action-pill-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.action-pill-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.action-pill-btn.is-active {
  background-color: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Channel Card */
.watch-channel-card {
  margin-top: 14px;
  padding: 12px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.channel-info-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.channel-meta {
  min-width: 0;
  flex: 1;
}

.channel-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #99000b);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.channel-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.channel-name {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.verified-badge {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text-secondary);
  color: var(--bg-page);
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.channel-subs {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-subscribe {
  height: 36px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: none;
  background-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

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

.btn-subscribe.is-subscribed,
.btn-subscribe.is-active {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

/* Description Box */
.watch-description-box {
  margin-top: 12px;
  padding: 12px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.watch-description-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.watch-description-box.is-expanded .watch-description-text {
  display: block;
  -webkit-line-clamp: unset;
}

.watch-tags-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.desc-toggle-btn {
  margin-top: 8px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.84rem;
}

.desc-toggle-btn:hover {
  color: var(--accent);
}

#channelsView .section-header .filter-select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
}

/* Up Next Sidebar (Desktop Scrollable List) */
.watch-sidebar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.up-next-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.related-videos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: clamp(520px, 76vh, 840px);
  overflow-y: auto;
  padding-right: 4px;
}

.related-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 5px;
  border-radius: var(--radius-md);
  min-width: 0;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.related-card:hover {
  background-color: var(--bg-hover);
}

.related-card:hover .related-card__title {
  color: var(--accent);
}

.related-card__thumb-wrap {
  position: relative;
  width: 148px;
  aspect-ratio: 16 / 9;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-elevated);
  background-image: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border-color) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: thumbShimmer 1.3s ease-in-out infinite;
}

.related-card__thumb-wrap.is-loaded,
.related-card__thumb-wrap.is-thumb-error {
  background-image: none;
  animation: none;
}

.related-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.related-card__quality {
  position: absolute;
  left: 5px;
  top: 5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.03em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 2;
}

.related-card__duration {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(12, 12, 14, 0.86);
  color: #ffffff;
  font-size: 0.69rem;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 2;
}

.related-card__info {
  flex: 1;
  min-width: 0;
}

.related-card__title {
  margin: 0 0 4px;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  transition: color var(--transition-fast);
}

.related-card__channel,
.related-card__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.related-card__channel {
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 2px;
}

.related-card__meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.related-card__meta > span {
  white-space: nowrap;
}

.related-card__meta > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Full-width Recommended / More Videos Section below Watch Layout */
.watch-more-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border-color);
}

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

/* ==========================================================================
   Directories & Library Views
   ========================================================================== */
.categories-header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.categories-search-input {
  width: 240px;
  max-width: 100%;
  height: 34px;
}

.categories-more-wrap {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.categories-grid,
.channels-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.category-card,
.channel-card {
  padding: 15px 16px;
  min-width: 0;
  height: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

@media (hover: hover) {
  .category-card:hover,
  .channel-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
  }
}

.category-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.category-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--cat-accent, var(--accent));
  color: var(--cat-accent, var(--accent));
  letter-spacing: 0.03em;
}

.category-card__count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.category-card__title,
.channel-card__name {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.28;
}

.category-card__desc {
  margin: 0;
  font-size: 0.81rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.category-card__meta,
.channel-card__meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.tags-search-input {
  max-width: 260px;
}

.tags-alphabet-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
}

.alpha-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.8rem;
}

.alpha-btn.is-active,
.alpha-btn:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.tag-chip:hover {
  border-color: var(--accent);
  background-color: var(--accent-soft);
}

.tag-chip__count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Library */
.library-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.library-tab {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.library-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.library-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.library-subtitle {
  margin: 0;
  font-size: 1.05rem;
}

.library-subbar-actions {
  display: flex;
  gap: 8px;
}

.library-playlists-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.playlist-pill {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
}

.playlist-pill.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.empty-state-icon {
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.empty-state p {
  margin: 0 0 16px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Buttons, Forms & Modals
   ========================================================================== */
.btn-primary,
.btn-subtle {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.btn-primary {
  border: 1px solid var(--accent);
  background-color: var(--accent);
  color: var(--accent-text);
}

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

.btn-subtle {
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-subtle:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

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

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-input);
  color: var(--text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-hint {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.code-textarea {
  font-family: Consolas, Monaco, monospace;
  font-size: 0.8rem;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--bg-overlay);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-dialog--wide {
  max-width: 680px;
}

.modal-dialog--sm {
  max-width: 440px;
}

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

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-subtitle {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.modal-close-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1;
}

.modal-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.modal-footer--tight {
  margin-top: 4px;
}

.modal-divider {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 6px 0;
}

.api-quick-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-quick-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.api-quick-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-primary);
}

.api-quick-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.api-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  text-align: left;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.api-preset-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent);
}

.api-preset-btn.is-active {
  background-color: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.api-preset-btn__title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.api-preset-btn.is-active .api-preset-btn__title {
  color: var(--accent);
}

.api-preset-btn__sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.25;
}

.api-advanced-details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-page);
  overflow: hidden;
}

.api-advanced-summary {
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-elevated);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.api-advanced-summary::-webkit-details-marker {
  display: none;
}

.api-advanced-summary::after {
  content: "+";
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.api-advanced-details[open] .api-advanced-summary {
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.api-advanced-details[open] .api-advanced-summary::after {
  content: "−";
  color: var(--accent);
}

.api-advanced-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.api-toggle-banner {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.switch-label input {
  accent-color: var(--accent);
}

.api-test-row,
.api-data-tools,
.copy-row,
.inline-create-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.copy-row .form-input,
.inline-create-form .form-input {
  flex: 1;
  min-width: 0;
}

.api-test-status {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.timestamp-mini-input {
  width: 82px;
  padding: 4px 8px;
}

.playlist-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.playlist-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  cursor: pointer;
}

.download-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.download-option-row:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
}

.download-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.download-option-info strong,
.download-option-quality,
.download-option-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.download-option-info span,
.download-option-meta,
.download-option-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.download-option-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.download-option-note {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-page);
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
}

.profile-summary-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
}

.profile-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.profile-stats {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Multi-column Footer & Toast Container
   ========================================================================== */
.site-footer {
  margin-top: auto;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding-top: 28px;
  padding-bottom: 18px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.footer-brand {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.footer-desc {
  margin: 0 0 10px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  max-width: 340px;
}

.sfw-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--success);
  font-size: 0.74rem;
  font-weight: 700;
}

.footer-heading {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 700;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-links a,
.footer-link-btn {
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-links a:hover,
.footer-link-btn:hover {
  color: var(--accent);
}

.footer-bottom {
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.back-to-top-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.back-to-top-btn:hover {
  border-color: var(--accent);
}

/* Toasts */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}

.toast--success {
  border-left-color: var(--success);
}

.toast--error {
  border-left-color: var(--danger);
}

.toast--info {
  border-left-color: var(--info);
}

/* ==================== SEO BREADCRUMB, EDITORIAL & INFO PAGES ==================== */
.seo-breadcrumb {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  overflow: hidden;
  max-width: 100%;
}

.seo-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.seo-breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.seo-breadcrumb__sep {
  opacity: 0.55;
  flex-shrink: 0;
}

.seo-breadcrumb__current {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seo-editorial-box {
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
}

.seo-editorial-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.seo-editorial-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.seo-editorial-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.seo-lang-links {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.seo-lang-links a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.seo-lang-links a:hover {
  text-decoration: underline;
}

.info-page-card {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.info-page-body {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.info-page-body h2 {
  margin: 8px 0 2px;
  font-size: 1.12rem;
  color: var(--text-primary);
}

.info-page-body h3 {
  margin: 6px 0 2px;
  font-size: 0.98rem;
  color: var(--text-primary);
}

.info-page-body p,
.info-page-body ul {
  margin: 0;
}

.info-page-body ul {
  padding-left: 20px;
}
