:root {
  color-scheme: dark;
  --bg: #060816;
  --bg-secondary: #0b1024;
  --card: rgba(18, 24, 47, 0.86);
  --card-strong: rgba(21, 28, 56, 0.98);
  --surface: rgba(255, 255, 255, 0.05);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #99a4c3;
  --muted-strong: #c7d2fe;
  --primary: #7c8cff;
  --primary-strong: #9b6dff;
  --primary-shadow: rgba(124, 140, 255, 0.28);
  --success: #34d399;
  --danger: #fb7185;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(124, 140, 255, 0.18), transparent 26%),
    radial-gradient(circle at top left, rgba(155, 109, 255, 0.14), transparent 22%),
    linear-gradient(180deg, #070b18 0%, #05070f 100%);
  color: var(--text);
}

.app-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 16px 132px;
}

.topbar {
  margin-bottom: 16px;
}

.topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-pill,
.section-badge,
.status-badge,
.favorite-state,
.meta-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.brand-pill {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(124, 140, 255, 0.12);
  border: 1px solid rgba(124, 140, 255, 0.28);
}

.topbar h1,
.card h2,
.card h3,
.details-card h3 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(32px, 5vw, 42px);
  line-height: 1;
}

.topbar-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.banner {
  margin-bottom: 14px;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.banner.hidden,
.diagnostics.hidden,
.hidden {
  display: none !important;
}

.banner.error {
  background: rgba(251, 113, 133, 0.12);
  color: #fecdd3;
}

.banner.info {
  background: rgba(124, 140, 255, 0.12);
  color: #dbe4ff;
}

.banner.success {
  background: rgba(52, 211, 153, 0.14);
  color: #d1fae5;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 18px;
  padding: 8px;
  border-radius: 20px;
  background: rgba(10, 14, 28, 0.8);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.tab,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tab:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.tab {
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  box-shadow: 0 12px 24px var(--primary-shadow);
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  box-shadow: 0 14px 30px var(--primary-shadow);
}

.secondary-button,
.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.danger-button {
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.08);
  border: 1px solid rgba(251, 113, 133, 0.22);
}

main {
  display: block;
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.card,
.details-card,
.info-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.card,
.details-card {
  padding: 20px;
}

.section-card,
.dashboard-card {
  overflow: hidden;
}

.hero-card {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 18px;
  padding: 20px;
  margin-bottom: 18px;
  overflow: hidden;
  background: linear-gradient(140deg, rgba(19, 26, 53, 0.96) 0%, rgba(14, 19, 41, 0.96) 100%);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  flex: 1 1 100%;
}

.hero-card h2 {
  font-size: clamp(26px, 4vw, 34px);
}

.hero-summary {
  margin: 0;
  color: var(--muted-strong);
  font-size: 16px;
  line-height: 1.5;
}

.hero-action {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  flex: 0 0 auto;
  flex-shrink: 0;
  padding: 10px 14px;
  border-radius: 999px;
}

.hero-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-badge,
.status-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-badge {
  align-self: flex-start;
  color: #eef2ff;
  background: rgba(124, 140, 255, 0.14);
  border: 1px solid rgba(124, 140, 255, 0.24);
}

.section-badge-pro {
  background: rgba(155, 109, 255, 0.16);
  border-color: rgba(155, 109, 255, 0.28);
}

.home-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 18px;
  margin-bottom: 18px;
}

.section-header,
.details-header,
.feature-show-head,
.episode-status-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.section-eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.mini-grid,
.shows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.profile-label {
  color: var(--muted);
}

.profile-value {
  text-align: right;
  color: var(--text);
  font-weight: 600;
}

.value-accent {
  color: var(--muted-strong);
}

.feature-show-card,
.show-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  align-items: start;
}

.show-card-compact {
  grid-template-columns: 56px minmax(0, 1fr);
}

.feature-show-card {
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.03);
}

.poster,
.poster-large {
  width: 72px;
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  overflow: hidden;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.poster-large {
  width: 92px;
}

.poster-compact {
  width: 56px;
}

.poster img,
.poster-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-has-image .poster-fallback {
  display: none;
}

.poster-has-image.poster-broken img {
  display: none;
}

.poster-has-image.poster-broken .poster-fallback {
  display: flex;
}

.poster-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 108px;
  border-radius: inherit;
  background:
    radial-gradient(circle at top left, rgba(124, 140, 255, 0.28), transparent 45%),
    linear-gradient(145deg, rgba(28, 36, 72, 1) 0%, rgba(14, 18, 35, 1) 100%);
  color: #dbe4ff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.show-card-main,
.feature-show-main,
.details-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.show-card-title,
.feature-show-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.28;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.show-card-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-row,
.status-badges,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.show-card .meta-row,
.feature-show-card .meta-row {
  row-gap: 6px;
}

.meta-chip {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted-strong);
  font-size: 12px;
}

.status-badge-primary {
  color: #e8ecff;
  background: rgba(124, 140, 255, 0.18);
}

.status-badge-success {
  color: #d1fae5;
  background: rgba(52, 211, 153, 0.16);
}

.status-badge-violet {
  color: #f3e8ff;
  background: rgba(155, 109, 255, 0.18);
}

.status-badge-muted {
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.06);
}

.show-subline,
.show-overview,
.details-overview,
.muted,
.search-hint {
  margin: 0;
  line-height: 1.55;
}

.show-subline,
.muted,
.search-hint,
.episode-status-label {
  color: var(--muted);
}

.show-overview {
  color: rgba(238, 242, 255, 0.86);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.info-box,
.empty-state,
.loading-state,
.diagnostics-card,
.info-panel {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.empty-state-rich h3 {
  margin: 0 0 8px;
}

.empty-state p,
.info-panel p,
.info-panel ul {
  margin: 0;
}

.empty-action {
  margin-top: 12px;
}

.loading-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.16) 50%,
    rgba(255, 255, 255, 0.08) 100%
  );
  background-size: 200% 100%;
  animation: loading-shimmer 1.2s linear infinite;
}

.loading-line + .loading-line {
  margin-top: 10px;
}

.loading-line-title {
  width: 58%;
  height: 16px;
}

.loading-line-short {
  width: 38%;
}

.episode-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.episode-status-top {
  align-items: center;
}

.episode-status-code {
  font-size: 14px;
  line-height: 1.3;
}

.episode-status-date {
  color: var(--muted-strong);
  font-size: 13px;
}

.episode-status-compact {
  padding: 14px;
}

.inline-link {
  color: var(--muted-strong);
  font-size: 13px;
}

.card-actions {
  margin-top: auto;
  padding-top: 2px;
  align-items: center;
}

.card-action-main {
  flex: 0 0 auto;
  min-width: 0;
}

.card-action-danger {
  flex: 0 0 auto;
}

.details-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.details-media-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.details-summary {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.details-title {
  margin: 0;
  font-size: clamp(20px, 3.2vw, 26px);
  line-height: 1.22;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.details-overview {
  color: rgba(238, 242, 255, 0.9);
  font-size: 14px;
  line-height: 1.62;
}

.details-overview.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.details-overview.expanded {
  display: block;
}

.details-overview-section,
.details-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.details-overview-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.details-overview-empty {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.details-primary-action {
  width: auto;
  min-width: 0;
  align-self: flex-start;
  padding-inline: 14px;
}

.details-secondary-action {
  width: auto;
  min-width: 0;
  align-self: flex-start;
  padding-inline: 14px;
}

.details-toggle {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 600;
}

.details-back-button {
  padding: 8px 12px;
  border-radius: 12px;
  flex: 0 0 auto;
  font-size: 13px;
}

.favorite-state {
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted-strong);
  font-size: 12px;
}

.details-head-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.details-main {
  gap: 6px;
}

.details-actions {
  margin-top: 14px;
}

.details-header {
  align-items: flex-start;
  gap: 8px;
}

.details-hero .meta-row {
  gap: 6px;
}

.details-hero .meta-chip {
  padding: 4px 8px;
  font-size: 11px;
}

.details-upcoming-empty {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.details-episode-status {
  margin-top: 14px;
  border-radius: 18px;
  padding: 14px;
}

.favorite-state.active {
  color: #d1fae5;
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.28);
}

#favoritesList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#favoritesList .show-card {
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border-radius: 20px;
}

#favoritesList .show-card-main {
  gap: 8px;
}

#favoritesList .show-card-head {
  gap: 6px;
}

#favoritesList .show-card-title {
  font-size: 16px;
  line-height: 1.3;
}

#favoritesList .meta-row,
#favoritesList .status-badges {
  gap: 6px;
}

#favoritesList .meta-chip,
#favoritesList .status-badge {
  font-size: 11px;
}

#favoritesList .meta-chip {
  padding: 4px 8px;
}

#favoritesList .show-subline {
  font-size: 13px;
  line-height: 1.4;
}

#favoritesList .show-overview {
  font-size: 13px;
  line-height: 1.5;
  -webkit-line-clamp: 2;
}

#favoritesList .episode-status,
#favoritesList .info-box {
  border-radius: 18px;
}

#favoritesList .card-actions {
  gap: 8px;
  flex-wrap: nowrap;
  padding-top: 0;
}

#favoritesList .card-action-main,
#favoritesList .card-action-danger {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.2;
}

#favoritesList .card-action-main {
  flex: 0 1 auto;
}

#favoritesList .card-action-danger {
  flex: 0 0 auto;
}

input[type="search"] {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
}

input[type="search"]::placeholder {
  color: var(--muted);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.search-row .primary-button {
  min-width: 112px;
}

.bottom-nav .tab {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pro-benefits-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted-strong);
  display: grid;
  gap: 8px;
}

.pro-note {
  color: var(--muted);
}

.diagnostics-card h3 {
  margin-bottom: 12px;
}

@media (min-width: 900px) {
  .app-shell {
    padding: 28px 24px 36px;
  }

  #favoritesList,
  #searchResults {
    min-width: 0;
  }
}

@media (max-width: 899px) {
  .home-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 16px 14px 138px;
  }

  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 20;
    margin: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }

  .hero-card,
  .search-row {
    grid-template-columns: 1fr;
  }

  .hero-card {
    align-items: stretch;
  }

  .feature-show-card,
  .show-card {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
  }

  #favoritesList .show-card {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .details-media-row {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 12px;
  }

  .hero-action,
  .search-row .primary-button,
  .empty-action {
    width: 100%;
  }

  .tab {
    min-height: 52px;
    padding: 9px 6px;
    font-size: 12px;
    line-height: 1.2;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .section-header {
    gap: 10px;
  }

  .card,
  .details-card {
    padding: 16px;
  }

  .show-card-title,
  .feature-show-card h3 {
    font-size: 17px;
  }

  .card-actions {
    gap: 10px;
  }

  #favoritesList .show-card-title {
    font-size: 15px;
  }

  #favoritesList .show-overview {
    font-size: 12.5px;
  }

  .details-title {
    font-size: 19px;
  }

  .details-primary-action {
    width: auto;
    max-width: 100%;
  }

  .details-secondary-action {
    width: auto;
    max-width: 100%;
  }
}

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