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

:root {
  /* Brand colors - warm orange gradient */
  --primary: #ff8a00;
  --primary-dark: #e67600;
  --primary-light: #ffa733;
  --gradient: linear-gradient(135deg, #ff8a00 0%, #ff5e3a 100%);
  --gradient-soft: linear-gradient(135deg, #ff8a00 10%, #ff5e3a 90%);

  /* Neutral palette */
  --bg: #faf8f5;
  --bg-card: #ffffff;
  --bg-hover: #fff5ee;
  --bg-tag: #fff0e6;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --border: #f0ebe5;
  --border-hover: #ffd9b3;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 4px 24px rgba(255, 138, 0, 0.25);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font-family: inherit; }
input { font-family: inherit; outline: none; }

/* ==================== Background Decoration ==================== */
.bg-decoration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: float 20s ease-in-out infinite;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #ff8a00, transparent 70%);
  top: -150px;
  right: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ff5e3a, transparent 70%);
  bottom: -100px;
  left: -80px;
  animation-delay: -7s;
}

.blob-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #ffc847, transparent 70%);
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ==================== Main Content ==================== */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

/* ==================== Home / Hero ==================== */
.home-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 40px 0;
}

.hero {
  text-align: center;
  width: 100%;
  max-width: 640px;
}

.hero-title {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -1px;
  animation: fade-up 0.6s ease 0.1s both;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  animation: fade-up 0.6s ease 0.2s both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-box-wrapper {
  animation: fade-up 0.6s ease 0.3s both;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 6px 6px 24px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.search-icon {
  color: var(--text-light);
  flex-shrink: 0;
  margin-right: 12px;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  padding: 14px 0;
  color: var(--text);
  font-weight: 500;
}

.search-btn {
  background: var(--gradient);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.search-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow);
}

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

/* Hot searches */
.hot-searches {
  margin-top: 32px;
  animation: fade-up 0.6s ease 0.4s both;
}

.hot-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.hot-label svg {
  color: #ff5e3a;
}

.hot-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.hot-tag {
  padding: 8px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.hot-tag:hover {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

/* ==================== Search Results ==================== */
.results-view {
  padding: 32px 0 60px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

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

.results-header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 16px;
  transition: all 0.2s ease;
  max-width: 320px;
  flex: 1;
}

.results-header-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.1);
}

.results-header-search svg {
  color: var(--text-light);
  flex-shrink: 0;
}

.results-header-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  padding: 10px 0;
  color: var(--text);
}

.results-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

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

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  gap: 14px;
  padding: 14px;
  animation: card-in 0.4s ease both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.card-poster-wrap {
  width: 80px;
  height: 110px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
}

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

.poster-fallback .card-poster-icon {
  display: flex;
}

.card-poster-icon {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: #ccc;
  pointer-events: none;
}

.card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.badge-source {
  background: var(--gradient-soft);
  color: #fff;
}

.badge-category {
  background: var(--bg-tag);
  color: var(--primary-dark);
}

.badge-year {
  background: #f0f0f0;
  color: var(--text-secondary);
}

.card-remarks {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff;
  font-size: 11px;
  padding: 16px 6px 4px;
  text-align: center;
  font-weight: 500;
  pointer-events: none;
}

.card-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: auto;
}

.card-play-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: var(--shadow-glow);
}

.result-card:hover .card-play-btn {
  opacity: 1;
}

.result-card {
  position: relative;
}

.results-empty {
  text-align: center;
  padding: 80px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.results-empty p {
  color: var(--text-light);
  font-size: 16px;
}

/* Inline status text (episode list loading/empty) */
.loading-text-inline {
  color: var(--text-light);
  text-align: center;
  padding: 40px;
  font-size: 14px;
}

.empty-text {
  color: var(--text-light);
  text-align: center;
  padding: 40px;
  font-size: 14px;
}

/* ==================== Player View ==================== */
.player-view {
  padding: 32px 0 60px;
}

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

.player-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 16px;
  transition: all 0.2s ease;
  max-width: 320px;
  flex: 1;
}

.player-search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.1);
}

.player-search-box svg {
  color: var(--text-light);
  flex-shrink: 0;
}

.player-search-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  padding: 10px 0;
  color: var(--text);
}

.player-container {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.player-main {
  flex: 1;
  min-width: 0;
}

.player-wrapper {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #000;
  aspect-ratio: 16 / 9;
  position: relative;
}

.video-player {
  width: 100%;
  height: 100%;
}

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

.video-player .art-video-player {
  width: 100%;
  height: 100%;
}

/* Player loading overlay */
.player-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 10;
}

.player-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.player-loading p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 500;
}

/* Player error overlay */
.player-error {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

.player-error-icon {
  font-size: 48px;
}

.player-error p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  text-align: center;
  padding: 0 20px;
}

.player-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 16px;
  flex-wrap: wrap;
}

.player-info-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.player-meta {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 400;
}

.player-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.player-actions {
  display: flex;
  gap: 10px;
}

.player-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.player-action-btn:hover {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.player-action-btn:active {
  transform: scale(0.95);
}

/* Video detail info */
.video-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.detail-row .detail-label {
  font-weight: 600;
  color: var(--text);
  margin-right: 4px;
}

.detail-row span {
  word-break: break-word;
}

/* Sidebar */
.player-sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.source-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  gap: 4px;
  overflow-x: auto;
}

.source-tab {
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.source-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.source-tab:hover {
  color: var(--primary);
}

.episode-list-wrapper {
  max-height: 500px;
  display: flex;
  flex-direction: column;
}

.episode-list-header {
  padding: 12px 16px 8px;
}

.episode-count {
  font-size: 13px;
  color: var(--text-light);
}

.episode-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
  overflow-y: auto;
  max-height: 440px;
}

.episode-list::-webkit-scrollbar {
  width: 6px;
}

.episode-list::-webkit-scrollbar-track {
  background: transparent;
}

.episode-list::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

.episode-btn {
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 64px;
  text-align: center;
  transition: all 0.2s ease;
}

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

.episode-btn.active {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

/* ==================== Loading ==================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(250, 248, 245, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.show {
  display: flex;
}

.loading-spinner {
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  padding: 30px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.loading-text {
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 10000;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==================== Footer ==================== */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-light);
  font-size: 13px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}

/* ==================== Responsive ==================== */
@media (max-width: 1024px) {
  .player-container {
    flex-direction: column;
  }

  .player-sidebar {
    width: 100%;
  }

  .episode-list-wrapper {
    max-height: 350px;
  }

  .episode-list {
    max-height: 290px;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 0 16px;
  }

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

  .hero-subtitle {
    font-size: 14px;
  }

  .search-box {
    padding: 4px 4px 4px 16px;
  }

  .search-box input {
    font-size: 14px;
    padding: 12px 0;
  }

  .search-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

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

  .results-title {
    font-size: 18px;
  }

  .results-header-search,
  .player-search-box {
    max-width: 100%;
  }

  .player-title {
    font-size: 16px;
  }

  .player-action-btn span {
    display: none;
  }

  .episode-list {
    max-height: 240px;
  }
}

@media (max-width: 480px) {
  .hot-tag {
    padding: 6px 14px;
    font-size: 13px;
  }

  .result-card {
    padding: 10px;
    gap: 10px;
  }

  .card-poster-wrap {
    width: 64px;
    height: 90px;
  }

  .card-title {
    font-size: 14px;
  }
}
