:root {
  --bg-root: #090b10;
  --bg-surface: #0f1219;
  --bg-elevated: #151922;
  --bg-card: #121620;
  --bg-card-hover: #181e2c;
  --bg-header-day: #161b26;
  --bg-header-today: #2563eb;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-focus: #3b82f6;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-blue: #2563eb;
  --accent-blue-light: #3b82f6;
  --accent-emerald: #10b981;
  --accent-crimson: #e11d48;
  --accent-amber: #f59e0b;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html,
body {
  background-color: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Top Navigation Bar */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15, 18, 25, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent-blue);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.03em;
}

.brand-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  max-width: 460px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-input-wrap svg {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.field-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  padding: 0.42rem 0.7rem 0.42rem 2rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.field-input.no-icon {
  padding-left: 0.7rem;
}

.field-input:focus {
  border-color: var(--border-focus);
}

.field-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
  outline: none;
  cursor: pointer;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.42rem 0.78rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: #1f2637;
  border-color: rgba(255, 255, 255, 0.24);
}

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

.btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.btn-primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue-light);
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-emerald {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}

.btn-emerald:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.26);
}

.btn-danger {
  background: rgba(225, 29, 72, 0.14);
  border-color: rgba(225, 29, 72, 0.4);
  color: #fda4af;
}

.btn-sm {
  padding: 0.3rem 0.58rem;
  font-size: 0.74rem;
}

.btn-lg {
  padding: 0.58rem 1.05rem;
  font-size: 0.84rem;
  font-weight: 600;
}

.badge-counter {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.05rem 0.38rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

/* Timetable Controls Bar (Like AnimeSchedule.net top controls) */
.timetable-toolbar {
  max-width: 1760px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.week-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.week-range-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.filter-pills-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-pills-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.filter-pill {
  padding: 0.26rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.filter-pill:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.filter-pill.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue-light);
  color: #ffffff;
}

.timezone-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* 7-Column AnimeSchedule Timetable */
.timetable-wrap {
  max-width: 1760px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  overflow-x: auto;
}

.timetable-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(195px, 1fr));
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  min-width: 1365px;
}

.day-column {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  min-width: 0;
}

.day-column:last-child {
  border-right: none;
}

.day-column.is-today {
  background: rgba(37, 99, 235, 0.04);
}

.day-header {
  background: var(--bg-header-day);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 0.5rem;
  text-align: center;
  position: sticky;
  top: 49px;
  z-index: 20;
}

.day-column.is-today .day-header {
  background: var(--bg-header-today);
  border-top-color: #60a5fa;
  border-bottom-color: #1d4ed8;
  box-shadow: 0 -4px 0 var(--bg-header-today);
}

.day-date-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.15rem;
}

.day-column.is-today .day-date-sub {
  color: rgba(255, 255, 255, 0.88);
}

.day-name-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.day-column.is-today .day-name-title {
  color: #ffffff;
}

.day-entries {
  display: flex;
  flex-direction: column;
}

/* Individual Anime Timetable Tile (Matches AnimeSchedule.net Tile) */
.timetable-tile {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
  transition: filter 0.15s ease;
  position: relative;
  user-select: none;
}

.timetable-tile:hover {
  filter: brightness(1.1);
}

.tile-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.32rem 0.45rem;
  background: #171c28;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
}

.day-column.is-today .tile-meta-bar {
  background: #1b2232;
}

.tile-ep-badge {
  background: rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.38rem;
  border-radius: 3px;
}

.tile-time {
  font-size: 0.76rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.tile-sub-badge {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0.1rem 0.36rem;
  border-radius: 3px;
  background: #2563eb;
  color: #ffffff;
  text-transform: uppercase;
}

.tile-sub-badge.aired {
  background: #059669;
  color: #ecfdf5;
}

.tile-poster-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4.2;
  overflow: hidden;
  background: #0b0e14;
}

.tile-poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.timetable-tile:hover .tile-poster-wrap img {
  transform: scale(1.04);
}

.tile-title-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.4rem 0.55rem 0.55rem;
  background: linear-gradient(
    to top,
    rgba(6, 8, 12, 0.96) 0%,
    rgba(6, 8, 12, 0.78) 55%,
    transparent 100%
  );
  text-align: center;
}

.tile-title-text {
  font-size: 0.76rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.28;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Search Results Grid (When user searches across all anime) */
.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.85rem;
}

.search-results-grid .timetable-tile {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Active VPS Downloads Strip (Only visible when tasks exist) */
.vps-active-strip {
  max-width: 1760px;
  margin: 0 auto 0.75rem;
  padding: 0 1.25rem;
}

.vps-strip-inner {
  background: var(--bg-surface);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.44rem;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.tag-pl {
  background: rgba(225, 29, 72, 0.18);
  border-color: rgba(225, 29, 72, 0.5);
  color: #fda4af;
}

.tag-blue {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

.tag-ready {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.tag-ai {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.mono-stat {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 6, 10, 0.84);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-window {
  width: 100%;
  max-width: 980px;
  max-height: 92vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
}

.modal-top {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-content {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

/* Anime Details & Episode Selector inside Modal */
.anime-hero {
  display: flex;
  gap: 1.15rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
}

.anime-hero-poster {
  width: 105px;
  height: 150px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: #090b10;
}

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

.anime-hero-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.anime-hero-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.anime-hero-romaji {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.anime-hero-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.2rem;
}

/* Episode Selector Section (Current & Previous Episodes) */
.episode-picker-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  margin-bottom: 1.15rem;
}

.episode-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.episode-picker-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.episode-pills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ep-pill {
  padding: 0.38rem 0.72rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.ep-pill:hover {
  border-color: var(--accent-blue-light);
  background: #1b2234;
}

.ep-pill.active {
  background: var(--accent-blue);
  border-color: #60a5fa;
  color: #ffffff;
}

.ep-pill.upcoming {
  border-style: dashed;
  color: var(--text-secondary);
}

/* Selected Episode Best Release Action Card */
.best-release-panel {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.09) 0%, rgba(15, 18, 25, 0.95) 100%);
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.best-release-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

/* Table for all Nyaa releases */
.data-table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-top: 0.75rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.data-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Task Progress Cards */
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0.75rem;
}

.task-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.task-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.task-name {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  word-break: break-all;
}

.meter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  color: var(--text-secondary);
}

.meter-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill-seq {
  height: 100%;
  background: var(--accent-emerald);
}

.meter-fill-total {
  height: 100%;
  background: var(--accent-blue-light);
}

.meter-fill-sub {
  height: 100%;
  background: var(--accent-amber);
}

.task-stats-row {
  display: flex;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Artplayer Video Workstation & Live Translation Percentage Progress Bar */
.translation-progress-box {
  background: var(--bg-elevated);
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.95rem;
  margin-bottom: 0.75rem;
}

.translation-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.translation-stage-label {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
}

.translation-percent-badge {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
  color: #60a5fa;
  background: rgba(37, 99, 235, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.45);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-sm);
}

.translation-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.translation-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb 0%, #10b981 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.artplayer-stage {
  width: 100%;
  height: 600px;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.art-mini-progress-bar {
  display: none !important;
}

.player-subbar {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.track-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.track-pill {
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.73rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer;
}

.track-pill.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue-light);
  color: #fff;
}

/* Config Cards inside Settings Modal */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}

.config-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.module-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.module-row:last-child {
  border-bottom: none;
}

@media (max-width: 900px) {
  .artplayer-stage {
    height: 360px;
  }
  .anime-hero {
    flex-direction: column;
  }
}
