/* ==============================================================================
   DASHGO — единый дизайн-язык с macOS/SwiftUI-версией
   Токены взяты из Dashgo/Views/*: фон 0.04/0.05/0.07, сайдбар 0.055/0.065/0.095,
   радиус карточек 14, белая primary-кнопка, стеклянные secondary, капсулы-бейджи.
   ============================================================================== */

:root {
  --bg: #0a0d12;
  --bg-sidebar: #0e1118;
  --bg-elevated: #121722;
  --bg-stage: #000;

  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --surface-strong: rgba(255, 255, 255, 0.14);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --text-2: rgba(245, 245, 247, 0.62);
  --text-3: rgba(245, 245, 247, 0.56);

  --accent: #0a84ff;
  --accent-soft: #94c7ff;
  --gold: #ffc738;
  --green: #34c759;
  --mint: #6ee8b8;

  --radius-card: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fast: 0.16s var(--ease);
  --normal: 0.24s var(--ease);

  --sidebar-w: 236px;
  --page-x: 40px;
  --titlebar-h: 36px;
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01" on, "cv11" on;
}

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

button {
  background: none;
  border: 0;
  cursor: pointer;
}

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

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

img {
  display: block;
}

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

::selection {
  background: rgba(10, 132, 255, 0.4);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* -----------------------------------------------------------------------------
   Ambient glow
   -------------------------------------------------------------------------- */

#ambient-glow {
  position: fixed;
  inset: 0 0 auto 0;
  height: 560px;
  background-size: cover;
  background-position: center top;
  filter: blur(110px) opacity(0.28);
  pointer-events: none;
  z-index: 0;
  transition: background-image 0.9s var(--ease);
}

/* -----------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* -----------------------------------------------------------------------------
   Sidebar (macOS NavigationSplitView)
   -------------------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  padding: 16px 10px 14px;
  gap: 18px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, #2f9bff 0%, #1a4ff0 100%);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(26, 79, 240, 0.35);
}

.brand-mark svg {
  width: 14px;
  height: 14px;
  fill: #fff;
  stroke: none;
  margin-left: 1px;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.brand-tag {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 2px 5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-3);
  padding: 14px 12px 6px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background var(--fast), color var(--fast);
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

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

.nav-btn.active {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer-btn {
  margin-top: auto;
}

/* -----------------------------------------------------------------------------
   Topbar (mobile/tablet)
   -------------------------------------------------------------------------- */

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: rgba(10, 13, 18, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.06);
  transition: background var(--fast), color var(--fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* -----------------------------------------------------------------------------
   Tab bar (mobile, iOS style)
   -------------------------------------------------------------------------- */

.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(16, 19, 26, 0.86);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tabbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  border-radius: 10px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
}

.tabbar-btn svg {
  width: 23px;
  height: 23px;
}

.tabbar-btn.active {
  color: var(--accent);
}

/* -----------------------------------------------------------------------------
   Content container
   -------------------------------------------------------------------------- */

.container {
  flex: 1;
  min-height: 0;
  padding-bottom: 48px;
}

.view-content {
  animation: viewIn 0.28s var(--ease);
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page {
  padding: 32px var(--page-x) 24px;
  max-width: 1500px;
}

.page--narrow {
  max-width: 860px;
}

.page-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.7px;
  line-height: 1.15;
  margin-bottom: 18px;
}

.section-header--tight {
  margin-top: 26px;
}

/* -----------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

#hero-banner {
  position: relative;
}

.hero-wrapper {
  position: relative;
  height: clamp(420px, 56vh, 580px);
  overflow: hidden;
  isolation: isolate;
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  transform: scale(1.02);
}

.hero-wrapper::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 13, 18, 0.15) 0%, rgba(10, 13, 18, 0) 26%, rgba(10, 13, 18, 0.55) 68%, var(--bg) 100%),
    linear-gradient(90deg, rgba(10, 13, 18, 0.86) 0%, rgba(10, 13, 18, 0.45) 42%, rgba(10, 13, 18, 0.1) 72%, rgba(10, 13, 18, 0.35) 100%);
  z-index: 1;
}

.hero-gradient {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 14px;
  padding: 0 var(--page-x) 44px;
  max-width: 900px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
}

.badge-pill.type {
  color: var(--accent-soft);
  background: rgba(10, 132, 255, 0.18);
  border-color: rgba(10, 132, 255, 0.42);
}

.badge-pill.rating {
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.14);
}

.badge-pill.rating svg {
  width: 11px;
  height: 11px;
  fill: var(--gold);
  stroke: none;
}

.hero-title {
  font-size: clamp(30px, 3.6vw, 46px);
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.04;
  max-width: 780px;
  text-wrap: balance;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.65);
}

.hero-overview {
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.8);
  max-width: 620px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

/* -----------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 46px;
  padding: 0 24px;
  border-radius: 12px;
  background: #fff;
  color: #000;
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform var(--fast), box-shadow var(--fast), background var(--fast);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: none;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary--compact {
  height: 42px;
  padding: 0 18px;
  font-size: 13.5px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  transition: background var(--fast), transform var(--fast);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.chip-action {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: background var(--fast), color var(--fast);
}

.chip-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* -----------------------------------------------------------------------------
   Shelves and cards
   -------------------------------------------------------------------------- */

.shelf-block {
  padding: 0 var(--page-x);
  margin-top: 34px;
}

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

.section-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.section-counter {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

.media-shelf {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0 12px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.media-shelf::-webkit-scrollbar {
  display: none;
}

.media-shelf--wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 22px 14px;
  overflow: visible;
  padding: 4px 0 8px;
  scroll-snap-type: none;
}

.media-card {
  flex: 0 0 auto;
  width: 172px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  cursor: pointer;
  scroll-snap-align: start;
}

.media-shelf--wrap .media-card {
  width: auto;
}

.poster-box {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform var(--normal), box-shadow var(--normal), border-color var(--normal);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

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

.poster-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  text-align: center;
  color: var(--text-3);
  font-size: 11px;
  background: linear-gradient(160deg, #151a24, #0d1017);
}

.poster-fallback svg {
  width: 26px;
  height: 26px;
}

.card-play-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 8, 12, 0.35);
  opacity: 0;
  transition: opacity var(--normal);
}

.play-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transform: scale(0.9);
  transition: transform var(--normal);
}

.play-circle svg {
  width: 17px;
  height: 17px;
  fill: #000;
  stroke: none;
  margin-left: 2px;
}

.media-card:hover .poster-box,
.media-card:focus-visible .poster-box {
  transform: translateY(-4px) scale(1.03);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55);
}

.media-card:hover .card-play-overlay,
.media-card:focus-visible .card-play-overlay {
  opacity: 1;
}

.media-card:hover .play-circle {
  transform: scale(1);
}

.rating-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.rating-badge svg {
  width: 10px;
  height: 10px;
  fill: var(--gold);
  stroke: none;
}

.media-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.media-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 34px;
}

.media-meta {
  display: flex;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Continue watching */

.continue-shelf {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}

.continue-shelf::-webkit-scrollbar {
  display: none;
}

.continue-card {
  flex: 0 0 auto;
  width: 300px;
  cursor: pointer;
}

.continue-thumb-box {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: #141821;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform var(--normal), border-color var(--normal);
}

.continue-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.continue-card:hover .continue-thumb-box {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.28);
}

.continue-play-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 8, 12, 0.18);
  opacity: 0;
  transition: opacity var(--normal);
}

.continue-card:hover .continue-play-overlay {
  opacity: 1;
}

.continue-play-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  display: grid;
  place-items: center;
}

.continue-play-circle svg {
  width: 16px;
  height: 16px;
  fill: #000;
  stroke: none;
  margin-left: 2px;
}

.continue-progress-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.continue-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.continue-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
}

.continue-info {
  padding: 9px 2px 0;
}

.continue-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-3);
}

/* -----------------------------------------------------------------------------
   Search / filters
   -------------------------------------------------------------------------- */

.search-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color var(--fast), background var(--fast);
  max-width: 720px;
}

.search-bar-wrap:focus-within {
  border-color: rgba(10, 132, 255, 0.6);
  background: rgba(255, 255, 255, 0.07);
}

.search-bar-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--text-3);
}

.search-input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  font-size: 15px;
  color: var(--text);
}

.search-input::placeholder {
  color: var(--text-3);
}

.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.filter-chip {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.filter-chip.active {
  background: rgba(255, 255, 255, 0.92);
  border-color: transparent;
  color: #0a0d12;
}

/* -----------------------------------------------------------------------------
   Settings
   -------------------------------------------------------------------------- */

.settings-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 16px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.settings-head h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.settings-version {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
}

.settings-hint {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 16px;
}

.settings-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 7px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-input {
  flex: 1;
  min-width: 240px;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color var(--fast);
}

.settings-input:focus {
  border-color: rgba(10, 132, 255, 0.6);
}

.settings-status-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.settings-list > div {
  display: flex;
  gap: 12px;
  font-size: 13.5px;
}

.settings-list dt {
  width: 130px;
  flex: none;
  color: var(--text-3);
}

.settings-list dd {
  color: var(--text);
}

.settings-list dd.ok {
  color: var(--mint);
  font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Player modal
   -------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.modal-overlay.active,
.modal-overlay.open {
  display: flex;
}

.modal-box {
  width: min(1140px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.72);
  animation: modalIn 0.26s var(--ease);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.modal-titles {
  min-width: 0;
}

.modal-titles h3 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.modal-titles p {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-2);
}

.modal-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.player-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: background var(--fast), color var(--fast);
}

.player-action-btn svg {
  width: 14px;
  height: 14px;
}

.player-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
  transition: background var(--fast), color var(--fast);
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

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

.player-select {
  height: 34px;
  padding: 0 26px 0 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.5) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.5) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.player-select option {
  background: #121722;
  color: var(--text);
}

.player-stage {
  position: relative;
  background: var(--bg-stage);
  aspect-ratio: 16 / 9;
  max-height: 58vh;
  width: 100%;
}

.player-stage video,
.player-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: radial-gradient(circle at 50% 40%, #151a24 0%, #05070b 70%);
  text-align: center;
  padding: 24px;
}

.placeholder-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.placeholder-icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
  stroke: none;
  margin-left: 2px;
}

.placeholder-title {
  font-size: 16px;
  font-weight: 700;
}

.placeholder-sub {
  font-size: 12.5px;
  color: var(--text-3);
}

.resume-pill {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  background: rgba(10, 13, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: var(--text-2);
  backdrop-filter: blur(10px);
}

.resume-close-btn {
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
}

.resume-close-btn:hover {
  color: #fff;
}

/* Series picker */

.series-picker {
  padding: 14px 22px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.015);
}

.series-picker-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.series-picker-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  flex: none;
}

.seasons-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.seasons-tabs::-webkit-scrollbar {
  display: none;
}

.episode-nav {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex: none;
}

.episodes-grid {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.episodes-grid::-webkit-scrollbar {
  display: none;
}

/* Sources */

.sources-panel {
  padding: 16px 22px 22px;
}

.sources-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

.sources-count {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.sources-empty {
  grid-column: 1 / -1;
  padding: 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.source-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}

.source-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.source-card.active {
  background: rgba(10, 132, 255, 0.14);
  border-color: rgba(10, 132, 255, 0.55);
}

.source-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.source-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.source-sub {
  font-size: 11px;
  color: var(--text-3);
}

.source-tag {
  flex: none;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  color: var(--accent-soft);
  background: rgba(10, 132, 255, 0.16);
  border: 1px solid rgba(10, 132, 255, 0.32);
}

.source-tag.torrent {
  color: var(--mint);
  background: rgba(52, 199, 89, 0.14);
  border-color: rgba(52, 199, 89, 0.34);
}

/* -----------------------------------------------------------------------------
   Downloads
   -------------------------------------------------------------------------- */

.chip-download {
  color: var(--accent-soft);
  border-color: rgba(10, 132, 255, 0.35);
  background: rgba(10, 132, 255, 0.12);
}

.chip-download:hover {
  background: rgba(10, 132, 255, 0.22);
  color: #fff;
}

.chip-download.busy {
  color: #fff;
  border-color: rgba(10, 132, 255, 0.6);
  background: rgba(10, 132, 255, 0.26);
}

.chip-download.done {
  color: var(--mint);
  border-color: rgba(52, 199, 89, 0.42);
  background: rgba(52, 199, 89, 0.14);
}

#episodes-grid .filter-chip {
  position: relative;
}

#episodes-grid .filter-chip.ep-done {
  border-color: rgba(52, 199, 89, 0.5);
  color: var(--mint);
}

#episodes-grid .filter-chip.ep-dl {
  border-color: rgba(10, 132, 255, 0.6);
  color: var(--accent-soft);
}

#episodes-grid .filter-chip.ep-queued {
  opacity: 0.7;
}

#episodes-grid .filter-chip.ep-error {
  border-color: rgba(255, 69, 58, 0.55);
  color: #ff8a80;
}

#episodes-grid .filter-chip.ep-done::after,
#episodes-grid .filter-chip.ep-dl::after,
#episodes-grid .filter-chip.ep-queued::after,
#episodes-grid .filter-chip.ep-error::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

#episodes-grid .filter-chip.ep-done::after { background: var(--green); }
#episodes-grid .filter-chip.ep-dl::after { background: var(--accent); }
#episodes-grid .filter-chip.ep-queued::after { background: rgba(255, 255, 255, 0.5); }
#episodes-grid .filter-chip.ep-error::after { background: #ff453a; }

.download-state {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--mint);
  backdrop-filter: blur(8px);
}

/* -----------------------------------------------------------------------------
   Electron window chrome
   -------------------------------------------------------------------------- */

html.is-electron .app-shell {
  padding-top: var(--titlebar-h);
}

html.is-electron body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 138px;
  height: var(--titlebar-h);
  -webkit-app-region: drag;
  background: rgba(10, 13, 18, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 300;
}

html.is-electron .sidebar {
  height: calc(100vh - var(--titlebar-h));
  top: var(--titlebar-h);
}

html.is-electron .topbar {
  top: var(--titlebar-h);
}

/* -----------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  :root {
    --page-x: 28px;
  }

  .media-card {
    width: 158px;
  }

  .continue-card {
    width: 272px;
  }
}

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

  .topbar {
    display: flex;
  }

  .tabbar {
    display: grid;
  }

  .hero-wrapper {
    height: clamp(400px, 50vh, 460px);
  }

  .container {
    padding-bottom: 92px;
  }

  html.is-electron .sidebar {
    display: none;
  }

  html.is-electron .topbar {
    padding-top: 0;
  }
}

@media (max-width: 720px) {
  :root {
    --page-x: 16px;
  }

  .hero-wrapper {
    height: 440px;
  }

  .hero-gradient {
    padding-bottom: 24px;
    gap: 11px;
  }

  .hero-title {
    font-size: 30px;
    letter-spacing: -0.9px;
  }

  .hero-overview {
    font-size: 13.5px;
    -webkit-line-clamp: 2;
  }

  .hero-actions {
    gap: 8px;
  }

  .btn-primary,
  .btn-secondary {
    height: 42px;
    padding: 0 16px;
    font-size: 13px;
  }

  .btn-secondary span {
    display: none;
  }

  .btn-secondary {
    width: 42px;
    padding: 0;
  }

  .section-title {
    font-size: 17px;
  }

  .shelf-block {
    margin-top: 26px;
  }

  .media-card {
    width: 128px;
  }

  .media-shelf--wrap {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 18px 10px;
  }

  .media-title {
    font-size: 12px;
    min-height: 31px;
  }

  .continue-card {
    width: 236px;
  }

  .page {
    padding-top: 22px;
  }

  .page-title {
    font-size: 24px;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-box {
    width: 100%;
    max-height: 94vh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
  }

  .modal-header {
    padding: 14px 16px;
    flex-direction: column;
    gap: 10px;
  }

  .modal-tools {
    justify-content: flex-start;
  }

  .player-stage {
    max-height: 42vh;
  }

  .sources-panel {
    padding: 14px 16px 20px;
  }

  .sources-grid {
    grid-template-columns: 1fr;
  }

  .series-picker {
    padding: 12px 16px;
  }

  .settings-input {
    min-width: 0;
    width: 100%;
  }

  .settings-list > div {
    flex-direction: column;
    gap: 2px;
  }
}

@media (max-width: 420px) {
  .hero-wrapper {
    height: 400px;
  }

  .hero-title {
    font-size: 26px;
  }

  .media-card {
    width: 116px;
  }

  .continue-card {
    width: 208px;
  }
}

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