:root {
  --bg-main: #0c0e14;
  --bg-header: #121620;
  --bg-card: #181d28;
  --bg-card-hover: #222938;
  --bg-panel: #151922;
  --bg-pill: #1f2533;
  --border-color: #272f40;
  --text-main: #f3f4f6;
  --text-sub: #9ca3af;
  --text-muted: #6b7280;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #ef4444;
  --success: #10b981;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  font-size: 26px;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-title .highlight {
  color: #f43f5e;
}

.badge-demo {
  font-size: 11px;
  padding: 2px 7px;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 12px;
  font-weight: 600;
}

/* Search Box */
.search-box-wrapper {
  flex: 1;
  max-width: 680px;
}

.search-input-group {
  display: flex;
  align-items: center;
  background: #1a202c;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 6px 4px 14px;
  transition: all 0.2s ease;
}

.search-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: #202736;
}

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

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

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  font-size: 14px;
}

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

.search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.header-actions {
  display: flex;
  align-items: center;
}

.action-btn {
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

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

.action-badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: bold;
}

/* Hot Tags */
.hot-tags-row {
  max-width: 1400px;
  margin: 0 auto;
  padding: 6px 20px 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
}

.hot-label {
  font-size: 12px;
  color: var(--text-muted);
}

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

.tag-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-sub);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag-chip:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
  border-color: rgba(99, 102, 241, 0.5);
}

/* Stats Bar */
.stats-bar {
  background: #151922;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 20px;
}

.stats-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.stats-text {
  font-size: 13px;
  color: var(--text-sub);
}

.source-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.source-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #1f2533;
  color: var(--text-sub);
  border: 1px solid #2d3748;
}

.source-pill.ok {
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.source-pill.fail {
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Main Container */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  flex: 1;
  width: 100%;
}

.section-title-row {
  margin-bottom: 18px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.movie-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
}

.movie-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
  background: var(--bg-card-hover);
}

.card-poster-wrap {
  width: 100%;
  aspect-ratio: 2/3;
  background: #11141c;
  position: relative;
  overflow: hidden;
}

.card-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.movie-card:hover .card-poster {
  transform: scale(1.04);
}

.card-badge-remarks {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #f3f4f6;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.card-badge-sources {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(99, 102, 241, 0.9);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.card-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Player Section */
.player-section {
  margin-bottom: 30px;
  animation: fadeIn 0.3s ease;
}

.player-wrapper {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

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

.player-header-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
}

.mode-badge {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.back-btn {
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

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

.now-playing-title {
  font-size: 18px;
  font-weight: 700;
}

.now-playing-ep {
  color: #818cf8;
  font-size: 14px;
  font-weight: 600;
}

.player-main-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

.player-art-box {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
}

#artplayer {
  width: 100%;
  height: 100%;
}

.player-controls-panel {
  background: #11141c;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--border-color);
  max-height: 540px;
  overflow-y: auto;
}

.panel-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-block.flex-1 {
  flex: 1;
}

.block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
}

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

.count-badge {
  font-size: 11px;
  color: #818cf8;
}

.source-selector, .line-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selector-chip {
  background: #1c2230;
  border: 1px solid #283244;
  color: var(--text-sub);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.selector-chip:hover {
  background: #252e40;
  color: #fff;
}

.selector-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.episodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.episode-btn {
  background: #1a202c;
  border: 1px solid #2d3748;
  color: var(--text-sub);
  padding: 7px 4px;
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s ease;
}

.episode-btn:hover {
  background: #2a3447;
  color: #fff;
  border-color: #4a5568;
}

.episode-btn.active {
  background: #f43f5e;
  border-color: #f43f5e;
  color: #fff;
  font-weight: 700;
}

.movie-meta-box {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.movie-meta-box h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.meta-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-sub);
}

.meta-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* History Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
}

.history-drawer {
  width: 380px;
  max-width: 90vw;
  background: var(--bg-header);
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.6);
}

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

.text-btn {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 12px;
  cursor: pointer;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 18px;
  cursor: pointer;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.history-item:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.history-thumb {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  background: #111;
}

.history-info {
  flex: 1;
  overflow: hidden;
}

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

.history-ep {
  font-size: 12px;
  color: #818cf8;
  margin-top: 2px;
}

.history-time {
  font-size: 11px;
  color: var(--text-muted);
}

.empty-tip {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
}

/* Loading & Empty State */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 0;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.app-footer {
  background: var(--bg-header);
  border-top: 1px solid var(--border-color);
  padding: 16px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 900px) {
  .player-main-grid {
    grid-template-columns: 1fr;
  }
  .player-controls-panel {
    max-height: 340px;
  }
}

@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}
