:root {
  color-scheme: dark;
  --bg: #08111f;
  --bg-elevated: rgba(10, 18, 32, 0.82);
  --panel: rgba(13, 22, 40, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f6f4ee;
  --muted: #9aa9bc;
  --accent: #ff7a18;
  --accent-soft: #ffb85c;
  --accent-pale: rgba(255, 184, 92, 0.18);
  --shadow: 0 24px 60px rgba(1, 8, 20, 0.45);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-display: "Sora", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Plus Jakarta Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 122, 24, 0.22), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 209, 102, 0.15), transparent 30%),
    linear-gradient(180deg, #09111f 0%, #0e1627 48%, #0b1320 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 20px;
  padding: 20px;
}

.sidebar,
.context-rail,
.section-card,
.brand-card {
  backdrop-filter: blur(20px);
}

.sidebar,
.context-rail {
  position: sticky;
  top: 20px;
  align-self: start;
}

.sidebar {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow);
}

.brand-card h1,
.hero h2,
.section-head h2,
.section-head h3,
.detail-copy h2,
.player-topbar h2 {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.brand-card {
  padding: 0;
}

.brand-card h1 {
  margin: 0 0 10px;
  font-size: 2rem;
}

.brand-copy,
.muted-copy,
.section-note,
.sidebar-foot,
.summary-text,
.detail-subtitle,
.player-meta p,
.empty-state p {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-soft);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
}

.sidebar-nav,
.rail-stack {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.sidebar-foot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

.nav-chip,
.source-chip,
.episode-chip,
.ghost-button,
.ghost-icon-button,
.pill-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.nav-chip:hover,
.source-chip:hover,
.episode-chip:hover,
.ghost-button:hover,
.ghost-icon-button:hover,
.pill-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.nav-chip {
  width: 100%;
  padding: 14px 16px;
  border-radius: 999px;
  text-align: left;
}

.nav-chip.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #ffb85c 100%);
  border-color: transparent;
  color: #1b120a;
  font-weight: 700;
}

.main-stage {
  min-width: 0;
  display: grid;
  gap: 20px;
  align-content: start;
  padding-bottom: 92px;
}

.hero,
.detail-hero,
.player-page,
.section-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 30px;
  display: grid;
  gap: 20px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 122, 24, 0.32), transparent 68%);
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.hero-copy h2 {
  margin: 0 0 14px;
  max-width: 12ch;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
}

.hero-copy p {
  max-width: 58ch;
  margin: 0;
  color: var(--muted);
}

.search-form,
.sync-form {
  display: grid;
  gap: 12px;
}

.search-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.search-field,
.stack-field {
  display: grid;
  gap: 8px;
}

.search-field input,
.stack-field input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 18px;
  padding: 16px 18px;
  outline: none;
}

.search-field input:focus,
.stack-field input:focus {
  border-color: rgba(255, 184, 92, 0.7);
  box-shadow: 0 0 0 4px rgba(255, 184, 92, 0.12);
}

.primary-button,
.ghost-button,
.pill-button,
.ghost-icon-button,
.link-button {
  border-radius: 16px;
  padding: 13px 18px;
  text-decoration: none;
}

.primary-button {
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #ffb85c 100%);
  color: #1a1208;
  font-weight: 800;
}

.ghost-button,
.ghost-icon-button {
  background: rgba(255, 255, 255, 0.05);
}

.ghost-icon-button {
  padding: 11px 14px;
  font-size: 0.92rem;
}

.button-full {
  width: 100%;
}

.quick-searches,
.source-chip-row,
.inline-actions,
.meta-row,
.player-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill-button,
.source-chip,
.episode-chip {
  border-radius: 999px;
  padding: 10px 14px;
}

.overview-grid,
.detail-columns,
.player-layout {
  display: grid;
  gap: 20px;
}

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

.overview-card,
.state-card,
.empty-state {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
}

.overview-card {
  padding: 18px 20px;
  display: grid;
  gap: 8px;
}

.overview-card span,
.overview-card small {
  color: var(--muted);
}

.overview-card strong {
  font-size: 2rem;
}

.section-card {
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-head h2,
.section-head h3,
.detail-copy h2,
.player-topbar h2 {
  margin: 0;
}

.section-note {
  max-width: 32ch;
  margin: 0;
  text-align: right;
}

.compact-card {
  padding: 18px;
}

.status-badge,
.rating-pill,
.pill-subtle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

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

.rating-pill {
  background: linear-gradient(135deg, rgba(255, 122, 24, 0.92), rgba(255, 184, 92, 0.92));
  color: #23170a;
  font-weight: 800;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-row input {
  width: 20px;
  height: 20px;
}

.source-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  color: var(--text);
}

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

.media-card {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 22px;
}

.media-poster {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  aspect-ratio: 2 / 3;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

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

.media-poster .rating-pill {
  position: absolute;
  left: 10px;
  bottom: 10px;
}

.media-body {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.card-head h4 {
  margin: 0;
  font-size: 1.14rem;
}

.summary-clamp {
  margin: 0;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-hero,
.player-page {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.poster-frame {
  overflow: hidden;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  aspect-ratio: 2 / 3;
}

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

.detail-copy {
  display: grid;
  gap: 14px;
}

.detail-subtitle,
.summary-text {
  margin: 0;
}

.detail-columns {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
}

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

.playlist-group {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.playlist-head h4 {
  margin: 0;
}

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

.episode-grid.wide {
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
}

.episode-chip.is-active,
.source-chip.is-active {
  background: var(--accent-pale);
  border-color: rgba(255, 184, 92, 0.4);
}

.detail-specs {
  margin: 0;
  display: grid;
  gap: 14px;
}

.detail-specs dt {
  color: var(--accent-soft);
  margin-bottom: 6px;
}

.detail-specs dd {
  margin: 0;
  color: var(--text);
}

.player-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.player-layout {
  grid-template-columns: minmax(0, 1.4fr) 340px;
}

.player-card,
.episode-panel {
  height: 100%;
}

.player-host {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 18px;
  background: #000;
}

.player-meta {
  margin-top: 18px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.player-meta p {
  margin: 8px 0 0;
}

.state-card,
.empty-state {
  padding: 28px;
  text-align: center;
}

.loader {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 50;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(12, 18, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.bottom-nav {
  display: none;
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

a {
  color: inherit;
}

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

@media (max-width: 1280px) {
  .shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .context-rail {
    display: none;
  }

  .detail-columns,
  .player-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 16px 16px 90px;
  }

  .sidebar {
    display: none;
  }

  .main-stage {
    padding-bottom: 0;
  }

  .search-form,
  .overview-grid,
  .media-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .player-topbar,
  .player-meta,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-nav {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 14px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    background: rgba(8, 17, 31, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  .nav-chip.is-mobile {
    text-align: center;
    padding: 12px 8px;
    font-size: 0.92rem;
  }
}
