:root {
  --bg-main: #07090e;
  --bg-card: #0f172a;
  --bg-card-hover: #1e293b;
  --bg-input: #020617;
  --border-color: #1e293b;
  --border-focus: #00a4dc;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --brand-cyan: #00a4dc;
  --brand-cyan-hover: #0085b2;
  --brand-purple: #a855f7;
  --brand-emerald: #10b981;
  --brand-rose: #f43f5e;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-cyan), var(--brand-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 164, 220, 0.3);
  color: #fff;
}

.logo-text {
  font-size: 1.125rem;
  font-weight: 800;
  background: linear-gradient(90deg, #38bdf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: rgba(0, 164, 220, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(0, 164, 220, 0.3);
  font-weight: 600;
  margin-left: 0.4rem;
}

/* Nav tabs */
nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

@media (max-width: 768px) {
  nav {
    display: none;
  }
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

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

.nav-btn.active {
  color: #fff;
  background: #1e293b;
  font-weight: 600;
}

.badge-count {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

/* Search input */
.search-wrapper {
  position: relative;
  width: 220px;
}

@media (min-width: 640px) {
  .search-wrapper {
    width: 260px;
  }
}

.search-input {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0.45rem 1rem 0.45rem 2.25rem;
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--brand-cyan);
}

.filter-select {
  background: #020617;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus,
.filter-select:hover {
  border-color: var(--brand-cyan);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

/* Main Container */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
  flex: 1;
}

/* Quick Bar / Banner */
.quick-bar {
  background: linear-gradient(135deg, #0f172a, #1e1b4b);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.quick-bar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.quick-bar-icon {
  padding: 0.65rem;
  border-radius: 12px;
  background: rgba(0, 164, 220, 0.15);
  border: 1px solid rgba(0, 164, 220, 0.25);
  color: var(--brand-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-bar-title {
  font-size: 0.925rem;
  font-weight: 700;
  color: #fff;
}

.quick-bar-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.quick-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--brand-cyan);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 164, 220, 0.3);
}

.btn-primary:hover {
  background: var(--brand-cyan-hover);
}

.btn-secondary {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid #334155;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-success {
  background: #059669;
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  background: #10b981;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: #f43f5e;
  color: #fff;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-icon {
  background: #0f172a;
  border: 1px solid #1e293b;
  color: var(--text-main);
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover:not(:disabled) {
  background: #1e293b;
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-indicator {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 0.5rem;
}

/* Movie Grid */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 640px) {
  .movie-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .movie-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .movie-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Movie Card */
.movie-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.movie-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 164, 220, 0.5);
  box-shadow: 0 12px 24px -6px rgba(0, 164, 220, 0.2);
}

.poster-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  background: #020617;
  overflow: hidden;
}

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

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

.poster-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(2, 6, 23, 0.85) 0%, transparent 60%);
}

.badge-group {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.badge-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.badge-quality {
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-ep {
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-check {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: #10b981;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.5);
}

.card-body {
  padding: 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-subtitle {
  font-size: 0.725rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  margin-top: 0.15rem;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.725rem;
  color: var(--text-muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

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

.modal-content {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  max-width: 760px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  position: relative;
  margin: auto;
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid #334155;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: #020617;
  color: #fff;
}

.video-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: none;
  position: relative;
}

.video-container.active {
  display: block;
}

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

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-top {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .modal-top {
    flex-direction: row;
  }
}

.modal-poster {
  width: 120px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.modal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.modal-orig-title {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.4rem 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.episodes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.ep-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.ep-btn:hover {
  background: #334155;
  color: #fff;
}

.ep-btn.active {
  background: var(--brand-cyan);
  border-color: var(--brand-cyan);
  color: #fff;
}

/* Settings View */
.settings-panel {
  max-width: 760px;
  margin: 0 auto;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-group-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
}

.form-input:focus {
  border-color: var(--brand-cyan);
}

.form-hint {
  font-size: 0.725rem;
  color: var(--text-dim);
}

.switch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #020617;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid #1e293b;
}

.switch-input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand-cyan);
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 60;
  background: #0f172a;
  border: 1px solid #334155;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.875rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 164, 220, 0.2);
  border-top-color: var(--brand-cyan);
  border-radius: 9999px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

.hidden {
  display: none !important;
}
