:root {
  color-scheme: dark;
  --bg: #0b0d13;
  --bg-elevated: #141824;
  --bg-card: #161b28;
  --bg-card-hover: #1d2436;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f5f9;
  --text-muted: #98a2b3;
  --accent: #ff8b00;
  --accent-hover: #ffa029;
  --accent-soft: rgba(255, 139, 0, 0.14);
  --danger: #f43f5e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 139, 0, 0.7);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:active {
  background: var(--accent);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

.modal__dialog::-webkit-scrollbar-track {
  background: var(--bg-elevated);
  border-radius: 0 var(--radius) var(--radius) 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.container {
  width: min(1560px, 100% - 48px);
  margin: 0 auto;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 13, 19, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  flex-wrap: wrap;
  padding: 10px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #ff5e00);
  color: #0b0d13;
  font-size: 15px;
  font-weight: 800;
}

.brand__text span {
  color: var(--accent);
}

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: 0.18s ease;
}

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

.tab.is-active {
  background: var(--accent);
  color: #0b0d13;
}

.tab__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
}

.tab.is-active .tab__badge {
  background: rgba(11, 13, 19, 0.2);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  justify-content: flex-end;
  max-width: 540px;
}

.search-box {
  position: relative;
  flex: 1 1 220px;
}

.search-box__kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  pointer-events: none;
}

.search-box:focus-within .search-box__kbd {
  opacity: 0;
}

.search-box__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease;
}

.search-box input:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: 0.18s ease;
  white-space: nowrap;
}

.btn__icon {
  width: 16px;
  height: 16px;
}

.btn--primary {
  background: var(--accent);
  color: #0b0d13;
}

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

.btn--secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.btn--secondary:hover {
  background: var(--bg-card-hover);
}

.btn--ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.is-loading .btn__icon {
  animation: spin 0.9s linear infinite;
}

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

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
  padding: 28px 0 0;
  height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero__backdrop {
  position: absolute;
  inset: -20px;
  background-size: cover;
  background-position: center;
  filter: blur(36px) saturate(1.25) brightness(0.32);
  transform: scale(1.08);
  z-index: 0;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 13, 19, 0) 65%, var(--bg) 100%),
    linear-gradient(90deg, rgba(11, 13, 19, 0.95) 0%, rgba(11, 13, 19, 0.65) 55%, rgba(11, 13, 19, 0.9) 100%);
  z-index: 1;
}

.hero__content {
  position: relative;
  z-index: 2;
  flex: 1;
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 36px;
  align-items: center;
  padding-left: 64px;
  padding-right: 64px;
}

.hero__tag {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.hero__title {
  margin: 0 0 10px;
  font-family: "Manrope", sans-serif;
  font-size: clamp(24px, 3.2vw, 38px);
  line-height: 1.15;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero__episode {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero__studios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  max-height: 28px;
  overflow: hidden;
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero__poster-wrap {
  justify-self: end;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

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

.hero__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(11, 13, 19, 0.72);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: all 0.15s ease;
}

.hero__nav:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(11, 13, 19, 0.92);
}

.hero__nav--prev {
  left: 14px;
}

.hero__nav--next {
  right: 14px;
}

.hero__dots {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-bottom: 14px;
}

.hero__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  transition: all 0.2s ease;
}

.hero__dot:hover {
  background: rgba(255, 255, 255, 0.5);
}

.hero__dot.is-active {
  width: 24px;
  background: var(--accent);
}

/* Catalog */
.catalog {
  padding: 28px 0 56px;
}

.catalog__toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.sources-bar,
.studios-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.sources-bar {
  padding-bottom: 2px;
}

.studio-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: 0.16s ease;
}

.studio-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.studio-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.studio-chip__count {
  font-size: 11px;
  opacity: 0.75;
}

.catalog__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.crawl-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 5px 10px 5px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  color: var(--text);
}

.crawl-pill[hidden] {
  display: none;
}

.crawl-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.crawl-pill__dot.is-active {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.crawl-pill__btn {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.crawl-pill__btn:hover {
  background: rgba(255, 139, 0, 0.2);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.load-more-wrap[hidden] {
  display: none;
}

/* Grid & Card */
.history-dash {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-dash__kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.history-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.history-kpi__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.history-kpi__value--sm {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.history-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.history-bars {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 6px;
  height: 92px;
  align-items: end;
}

.history-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.history-bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  overflow: hidden;
}

.history-bar-fill {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  transition: height 0.2s ease;
}

.history-bar-fill.has-val {
  background: linear-gradient(180deg, #ff9f2e 0%, var(--accent) 100%);
}

.history-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.history-cats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-cat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.history-cat-head span:last-child {
  color: var(--text);
  font-weight: 600;
}

.history-cat-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.history-cat-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

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

@media (max-width: 900px) {
  .history-dash__kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .history-dash__charts {
    grid-template-columns: 1fr;
  }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 260px), 1fr));
  gap: 20px;
  transition: opacity 0.15s ease;
}

.grid.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #0f131d;
  overflow: hidden;
}

.card__media.is-no-image {
  background: radial-gradient(circle at 50% 35%, rgba(99, 102, 241, 0.16), transparent 65%),
    linear-gradient(145deg, #121726 0%, #0b0e17 100%);
}

.card__media.is-no-image::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 36px;
  height: 36px;
  opacity: 0.25;
  background-color: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m10 9 5 3-5 3z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m10 9 5 3-5 3z'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.card__img.is-broken {
  display: none;
}

.card:hover .card__img {
  transform: scale(1.05);
}

.card__ep {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(11, 13, 19, 0.84);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.card__source {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(11, 13, 19, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.card__rating {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(22, 163, 74, 0.9);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.card__fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(11, 13, 19, 0.72);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  color: #fff;
  transition: 0.16s ease;
}

.card__fav:hover {
  background: rgba(11, 13, 19, 0.95);
  transform: scale(1.08);
}

.card__fav.is-active {
  color: var(--danger);
}

.card__body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__studios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.card__progress {
  margin-top: 2px;
  padding: 5px 9px;
  border-radius: 7px;
  background: rgba(255, 139, 0, 0.12);
  border: 1px solid rgba(255, 139, 0, 0.28);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card__progress-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__history-del {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  transition: 0.15s ease;
}

.card__history-del:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
}

.modal__resume-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.modal__resume-row[hidden] {
  display: none;
}

.modal__resume-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 139, 0, 0.14);
  border: 1px solid rgba(255, 139, 0, 0.35);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.modal__remove-history-btn {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #fca5a5;
  font-size: 11px;
  font-weight: 600;
  transition: 0.15s ease;
}

.modal__remove-history-btn:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.modal__meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 0 18px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  border: 1px solid var(--border);
}

.modal__meta[hidden] {
  display: none;
}

.modal__genres {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.modal__genre-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 139, 0, 0.12);
  border: 1px solid rgba(255, 139, 0, 0.28);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.modal__genre-chip--btn {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.modal__genre-chip--btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d13;
}

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

.modal__meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-left: 10px;
  border-left: 2px solid rgba(255, 139, 0, 0.48);
}

.modal__meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.modal__meta-val {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty-state__title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.empty-state__desc {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 11, 0.8);
  backdrop-filter: blur(8px);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(1240px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px;
  transition: width 0.2s ease;
}

.modal__dialog::-webkit-scrollbar {
  display: none;
}

.modal__body {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: 30px;
  align-items: start;
}

.modal__media {
  position: sticky;
  top: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  aspect-ratio: 2 / 3;
  background: #0f131d;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

.modal__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: radial-gradient(ellipse at center, #1b2230, #0b0d13 75%);
}

.modal__media::after {
  position: absolute;
  inset: 42% 0 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(5, 7, 11, 0.78));
}

.modal__ep-badge {
  position: absolute;
  z-index: 1;
  left: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(11, 13, 19, 0.86);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.modal__source-badge {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 12px;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(8, 10, 15, 0.76);
  color: #fff;
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 700;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.modal__source-badge:hover {
  border-color: var(--accent);
  background: rgba(8, 10, 15, 0.92);
}

.modal__content {
  min-width: 0;
  padding: 4px 2px 2px 0;
}

.modal__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.modal__copy-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.modal__copy-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.modal__orig-title {
  margin: -6px 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.modal__title {
  margin: 0 36px 8px 0;
  font-family: "Manrope", sans-serif;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.modal__desc {
  margin: 0 0 20px;
  max-width: 72ch;
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-line;
}

.modal__section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.modal__translations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.tr-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  transition: 0.16s ease;
}

.tr-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.modal__sources-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.modal__sources-bar[hidden] {
  display: none;
}

.modal__sources-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal__source-btn {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: 0.16s ease;
}

.modal__source-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.modal__source-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d13;
}

.modal__player-section {
  margin-bottom: 22px;
}

.player-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-strong);
  margin-bottom: 12px;
}

/* CVH adds a narrow native scrollbar to its cross-origin document. The iframe
   cannot be styled from the parent page, so clip only that extra edge. */
.player-frame-wrap.is-cvh .player-frame {
  width: calc(100% + 16px);
}

.player-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  overflow: hidden;
  overscroll-behavior: none;
}

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

.auto-next-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.auto-next-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.player-controls__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.player-watched-btn,
.player-mark-mode-btn {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  transition: 0.16s ease;
}

.player-watched-btn:hover,
.player-mark-mode-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.player-watched-btn.is-watched {
  background: rgba(255, 139, 0, 0.16);
  border-color: rgba(255, 139, 0, 0.45);
  color: var(--accent);
}

.player-mark-mode-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d13;
}

.player-watched-btn[hidden],
.player-mark-mode-btn[hidden] {
  display: none;
}

.player-episodes.is-mark-mode .player-ep-btn:not(.is-unreleased) {
  border-style: dashed;
}

.player-episodes.is-mark-mode .player-ep-btn:not(.is-unreleased):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.player-next-btn {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(255, 139, 0, 0.35);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  transition: 0.16s ease;
}

.player-next-btn:hover {
  background: var(--accent);
  color: #0b0d13;
}

.player-next-btn[hidden] {
  display: none;
}

.player-ep-search {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.player-ep-search[hidden] {
  display: none;
}

.player-ep-search__input {
  flex: 1 1 200px;
  max-width: 260px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.player-ep-search__input:focus {
  border-color: var(--accent);
}

.player-ep-search__stats {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.player-ep-btn[hidden] {
  display: none;
}

.player-episodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
  max-height: 184px;
  overflow-y: auto;
  padding-right: 4px;
}

.player-episodes[hidden] {
  display: none;
}

.player-providers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.player-select-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.player-select-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 4px;
}

.player-ep-btn,
.player-prov-btn {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: 0.16s ease;
}

.player-ep-btn {
  padding: 6px 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.player-ep-btn:hover,
.player-prov-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.player-ep-btn.is-watched {
  background: rgba(255, 139, 0, 0.14);
  border-color: rgba(255, 139, 0, 0.35);
  color: var(--text);
}

.player-ep-btn.is-unreleased,
.player-ep-btn.is-unreleased:hover {
  grid-column: span 3;
  padding: 6px 10px;
  border-style: dashed;
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  opacity: 0.65;
  cursor: not-allowed;
}

.player-ep-btn.is-active,
.player-prov-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d13;
}

.player-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 139, 0, 0.1);
  border: 1px solid rgba(255, 139, 0, 0.35);
  color: var(--text);
  font-size: 13px;
}

.player-notice[hidden] {
  display: none;
}

.modal__dialog--sm {
  width: min(460px, 100%);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#userAuthModal .auth-form [hidden] {
  display: none !important;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-field input {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

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

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

.auth-advanced summary {
  cursor: pointer;
  margin-bottom: 8px;
}

.auth-help-intro,
.auth-help-steps {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-help-steps {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
}

.auth-help-steps p {
  margin: 0;
}

.auth-help-steps a {
  color: var(--accent);
}

.auth-help-steps kbd,
.auth-help-steps code {
  padding: 1px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
}

.auth-help-warning {
  padding: 9px 10px;
  border-left: 2px solid var(--accent);
  background: var(--bg);
}

.auth-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af;
  font-size: 13px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer a {
  color: var(--accent);
}

.footer__hints {
  color: var(--text-muted);
  opacity: 0.85;
}

.footer__hints kbd {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
}

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 820px) {
  .header__actions {
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .search-box {
    flex: 1 1 100%;
  }
  .tabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .hero {
    height: auto;
    padding-bottom: 12px;
  }
  .hero__content {
    grid-template-columns: 1fr;
    padding-left: 20px;
    padding-right: 20px;
  }
  .hero__nav {
    display: none;
  }
  .hero__poster-wrap {
    justify-self: start;
    max-width: 100%;
  }
  .modal__body {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .modal__media {
    position: relative;
    top: auto;
    width: min(100%, 340px);
    justify-self: center;
    aspect-ratio: 2 / 3;
  }
  .modal__meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .modal__content {
    padding-right: 0;
  }
  .search-box__kbd {
    display: none;
  }
  .scroll-top-btn {
    right: 16px;
    bottom: 16px;
    width: 40px;
    height: 40px;
  }
}

/* Watchlists (В планах / Смотрю / Просмотрено / Брошено) */
.lists-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lists-bar[hidden] {
  display: none;
}

.card__season-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.season-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.25;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
}

.season-pill.is-planned {
  border-color: rgba(99, 102, 241, 0.45);
  color: #a5b4fc;
}

.season-pill.is-watching {
  border-color: rgba(249, 115, 22, 0.5);
  color: #fdba74;
}

.season-pill.is-completed {
  border-color: rgba(34, 197, 94, 0.45);
  color: #86efac;
}

.season-pill.is-dropped {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.card__list-row {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card__season-select,
.card__list-select {
  flex: 1;
  min-width: 0;
  padding: 6px 26px 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 12px;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text-muted);
  color-scheme: dark;
  font-size: 12px;
  line-height: 1.3;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
  text-overflow: ellipsis;
}

.card__season-select {
  flex: 0 1 46%;
}

.card__season-select option,
.card__list-select option {
  background: #141923;
  color: #f3f4f6;
}

.card__season-select:hover,
.card__season-select:focus,
.card__list-select:hover,
.card__list-select:focus {
  outline: none;
  border-color: var(--accent);
  color: var(--text);
}

.season-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.season-dot.is-planned {
  background: #6366f1;
}

.season-dot.is-watching {
  background: var(--accent);
}

.season-dot.is-completed {
  background: #22c55e;
}

.season-dot.is-dropped {
  background: #ef4444;
}

.card__list-select.is-planned {
  border-color: rgba(99, 102, 241, 0.55);
  color: #a5b4fc;
}

.card__list-select.is-watching {
  border-color: rgba(249, 115, 22, 0.65);
  color: #fdba74;
}

.card__list-select.is-completed {
  border-color: rgba(34, 197, 94, 0.55);
  color: #86efac;
}

.card__list-select.is-dropped {
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}

.modal__list-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal__list-btn {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal__list-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.modal__list-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 700;
}

.modal__list-btn.is-active[data-list-status="planned"] {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

.modal__list-btn.is-active[data-list-status="watching"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
}

.modal__list-btn.is-active[data-list-status="completed"] {
  background: #22c55e;
  border-color: #22c55e;
  color: #081c0f;
}

.modal__list-btn.is-active[data-list-status="dropped"] {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

/* Sort selector */
.sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.sort-select {
  padding: 5px 28px 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background-color: var(--bg-elevated);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text);
  color-scheme: dark;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.sort-select:hover,
.sort-select:focus {
  outline: none;
  border-color: var(--accent);
}

.sort-select option {
  background: #141923;
  color: #f3f4f6;
}

/* Docked right timeline sidebar */
@media (min-width: 1101px) {
  .header,
  .main,
  .footer {
    padding-right: 320px;
  }
}

@media (min-width: 1600px) {
  .header,
  .main,
  .footer {
    padding-right: 320px;
  }
}

.catalog__layout {
  display: block;
}

.catalog__main {
  min-width: 0;
}

.timeline-sidebar {
  position: fixed;
  top: 71px;
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 25;
}

.timeline__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline__title {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.timeline__tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.timeline__tab {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.timeline__tab:hover {
  color: var(--text);
}

.timeline__tab.is-active {
  background: var(--accent);
  color: #111;
}

.timeline__list {
  position: relative;
  overflow-y: auto;
  padding-left: 16px;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline__list::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border-strong);
  border-radius: 2px;
}

.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg-elevated);
}

.timeline__item:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateX(2px);
}

.timeline__thumb {
  width: 44px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
}

.timeline__thumb.is-broken {
  opacity: 0.2;
}

.timeline__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.timeline__time {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.timeline__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.timeline__countdown {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.timeline__countdown.is-released {
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
}

.timeline__day-header {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 4px 2px;
  margin-top: 4px;
}

.timeline__day-header:first-child {
  margin-top: 0;
}

.timeline__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.timeline__ep {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline__empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px 0;
}

@media (max-width: 1100px) {
  .timeline-sidebar {
    position: static;
    width: 100%;
    max-height: 420px;
    margin-top: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
}

/* ============================================================
   Left filters + display-settings panel
   ============================================================ */
.catalog__filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters-toggle {
  flex: 0 0 auto;
}

.active-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.active-filters:empty {
  display: none;
}

.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: 0.15s ease;
}

.active-filter:hover {
  background: rgba(255, 139, 0, 0.24);
}

.active-filter span {
  font-size: 10px;
  opacity: 0.8;
}

.active-filter--clear {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.active-filter--clear:hover {
  background: var(--bg-soft);
  border-color: var(--accent);
  color: var(--text);
}

.filters-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(320px, 88vw);
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-strong);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  transform: translateX(-102%);
  transition: transform 0.22s ease;
}

body.filters-open .filters-panel {
  transform: none;
}

.filters-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.filters-backdrop[hidden] {
  display: none;
}

.filters-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.filters-panel__head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filters-panel__close {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}

.filters-panel__close:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filters-panel__title {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 15px;
  font-weight: 700;
}

.filters-panel__reset {
  padding: 4px 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.filters-panel__reset:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.filters-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}

.filter-group {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group:last-child {
  border-bottom: none;
}

.filter-group__title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chips--scroll {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 190px;
  padding-right: 4px;
  scrollbar-width: thin;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: 0.15s ease;
}

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

.filter-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.filter-chip.is-empty {
  opacity: 0.45;
}

.filter-chip__count {
  font-size: 10px;
  opacity: 0.7;
}

.filter-empty {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

.filter-search {
  width: 100%;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}

.filter-search:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-rating {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-range {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.filter-rating__value {
  min-width: 52px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.filter-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.filter-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.filter-field__label {
  font-size: 13px;
  color: var(--text);
}

.filter-select {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-select option {
  background: #141923;
  color: #f3f4f6;
}

/* Layout: on wide screens the panel is docked left of the grid */
.catalog__layout {
  display: block;
}

.catalog__main {
  min-width: 0;
}

@media (min-width: 1101px) {
  .catalog__layout {
    display: flex;
    align-items: flex-start;
    gap: 24px;
  }

  .catalog__main {
    flex: 1 1 auto;
  }
}

/* Genre badges on cards */
.card__genres {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.card__genre {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

/* Display-setting driven visibility */
body.hide-hero .hero {
  display: none;
}

body.hide-rating .card__rating {
  display: none;
}

body.hide-translations .card__studios {
  display: none;
}

body.hide-timeline .timeline-sidebar {
  display: none;
}

@media (min-width: 1101px) {
  body:not(.hide-timeline) .header,
  body:not(.hide-timeline) .main,
  body:not(.hide-timeline) .footer {
    padding-right: 320px;
  }
}

/* Wide screens: dock the panel as a sticky column */
@media (min-width: 1500px) {
  .filters-panel {
    position: sticky;
    top: 86px;
    bottom: auto;
    left: auto;
    width: 280px;
    flex: 0 0 280px;
    max-height: calc(100vh - 104px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: none;
    transform: none;
    transition: none;
    overflow: hidden;
  }

  body:not(.filters-open) .filters-panel {
    display: none;
  }

  .filters-backdrop {
    display: none;
  }

  .filters-panel__close {
    display: none;
  }
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(15, 19, 29, 0.85);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.modal__close:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-soft);
}

.modal__sources-bar,
.modal__dialog--sm .modal__title {
  padding-right: 44px;
}

.scroll-top-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.scroll-top-btn[hidden] {
  display: none;
}

.scroll-top-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--bg-soft);
}

.random-pick-btn {
  white-space: nowrap;
}
