:root {
  color-scheme: dark;
  --bg: #080a12;
  --panel: rgba(17, 23, 38, 0.84);
  --panel-solid: #111726;
  --panel-light: #1a2236;
  --text: #f8f8fc;
  --muted: #aeb7cb;
  --soft: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.13);
  --accent: #e62429;
  --accent-2: #ff9f43;
  --done: #5de39b;
  --movie: #ff5a5f;
  --series: #7aa7ff;
  --short: #ffd166;
  --special: #a783ff;
  --shadow: 0 26px 90px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(230, 36, 41, 0.32), transparent 32rem),
    radial-gradient(circle at 90% 10%, rgba(87, 120, 255, 0.24), transparent 30rem),
    linear-gradient(180deg, #0c1020 0%, var(--bg) 42%, #06070b 100%);
  color: var(--text);
}

.page {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  margin-bottom: 14px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 22px var(--accent);
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(38px, 7vw, 82px);
  line-height: 0.94;
  letter-spacing: -0.065em;
}

.intro {
  max-width: 700px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.stats {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.025)),
    var(--panel);
  box-shadow: var(--shadow);
}

.stats-number {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

.stats-number strong {
  font-size: 44px;
  line-height: 1;
}

.stats-number span {
  color: var(--muted);
}

.progress {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 200ms ease;
}

.next-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.055);
}

.next-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.next-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.toolbar {
  position: sticky;
  top: 12px;
  z-index: 3;
  display: grid;
  gap: 12px;
  margin: 28px 0 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: rgba(12, 16, 32, 0.78);
  backdrop-filter: blur(18px);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.filters,
.account-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

button,
.search {
  border: 0;
  border-radius: 999px;
  font: inherit;
}

button {
  padding: 10px 14px;
  background: var(--panel-light);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: #242d45;
}

button.active {
  background: var(--accent);
  color: white;
}

.reset {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
}

.reset:hover {
  color: #ffcfd0;
  background: rgba(230, 36, 41, 0.16);
}

.search {
  width: min(100%, 380px);
  padding: 12px 15px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
}

.search::placeholder {
  color: rgba(174, 183, 203, 0.72);
}

.essential-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.toggle-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.toggle-switch {
  position: relative;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.toggle-input:checked ~ .toggle-switch {
  background: rgba(230, 36, 41, 0.35);
  border-color: var(--accent);
}

.toggle-input:checked ~ .toggle-switch::after {
  transform: translateX(14px);
  background: var(--accent);
}

.toggle-input:focus-visible ~ .toggle-switch {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.title {
  margin: 0;
  font-size: 18px;
  line-height: 1.32;
}

.watched-date {
  margin: 6px 0 0;
  color: var(--done);
  font-size: 12px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: center;
  margin-top: 0.5em;
    margin-bottom: 1em;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.pill.movie-type {
  color: var(--movie);
}

.pill.series-type {
  color: var(--series);
}

.pill.short-type {
  color: var(--short);
}

.pill.special-type {
  color: var(--special);
}

.essential-pill {
  background: rgba(255, 159, 67, 0.16);
  color: var(--accent-2);
  font-weight: 700;
}

.essential-pill::before {
  display: none;
}

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

.runtime {
  color: var(--muted);
  font-size: 13px;
}

.imdb-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid rgba(245, 197, 24, 0.45);
  border-radius: 999px;
  background: rgba(245, 197, 24, 0.1);
  color: #f5c518;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.imdb-link:hover {
  border-color: rgba(245, 197, 24, 0.85);
  background: rgba(245, 197, 24, 0.18);
  transform: translateY(-1px);
}

.imdb-link:focus-visible {
  outline: 2px solid #f5c518;
  outline-offset: 2px;
}

.episode-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid rgba(122, 167, 255, 0.34);
  border-radius: 999px;
  background: rgba(122, 167, 255, 0.12);
  color: #b8ccff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

/* Single segmented "Watched / Skip" control, replacing the old two-checkbox
   layout. Both buttons share one pill-shaped group so the pair reads as a
   single control with two mutually-exclusive states, matching the watched/
   skipped data model in state.js. */
.watch-toggle {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.watch-toggle-btn {
  padding: 8px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.watch-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.watch-toggle-btn.watch-btn.active {
  background: var(--done);
  color: #07130d;
}

.watch-toggle-btn.watch-btn.active:hover {
  background: var(--done);
}

.watch-toggle-btn.skip-btn.active {
  background: var(--muted);
  color: #1a2236;
}

.watch-toggle-btn.skip-btn.active:hover {
  background: var(--muted);
}

.watch-toggle-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.timeline-view {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 8px 0 8px;
}

.timeline-view::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  border-radius: 999px;
  background:
    linear-gradient(180deg,
      rgba(230, 36, 41, 0.95),
      rgba(255, 159, 67, 0.95),
      rgba(122, 167, 255, 0.95));
  transform: translateX(-50%);
  opacity: 0.85;
}

.timeline-era {
  position: relative;
  z-index: 1;
  justify-self: center;
  margin: 14px 0 4px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 16, 32, 0.96);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.26);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  align-items: center;
  min-height: 96px;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  grid-column: 2;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto;
  border: 3px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  background: var(--panel-solid);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 8px rgba(8, 10, 18, 0.92);
}

.timeline-item.watched .timeline-dot {
  border-color: var(--done);
  background: rgba(93, 227, 155, 0.18);
  color: var(--done);
}

.timeline-item.skipped .timeline-dot {
  border-color: var(--muted);
  background: rgba(174, 183, 203, 0.14);
  color: var(--muted);
}

.timeline-card {
  grid-column: 1;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 23px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.082), rgba(255, 255, 255, 0.026)),
    var(--panel-solid);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  transition: border 160ms ease, transform 160ms ease, opacity 160ms ease;
  cursor: pointer;
}

.timeline-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.25);
}

.timeline-item:nth-of-type(even) .timeline-card {
  grid-column: 3;
}

.timeline-card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.timeline-item.watched .timeline-card {
  opacity: 0.62;
}

.timeline-item.watched .title {
  text-decoration: line-through;
  color: var(--muted);
}

.timeline-item.skipped .timeline-card {
  opacity: 0.42;
}

.timeline-item.skipped .title {
  text-decoration: line-through;
  color: var(--muted);
}

/* Timeline cards are narrower than list rows (the card column is roughly
   half the page width, and shrinks further once the mobile breakpoint drops
   to a single column), so the toggle buttons get tighter padding and a
   smaller label here to avoid overflowing the card header's flex row. */
.timeline-card .watch-toggle-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.empty {
  display: none;
  padding: 30px;
  border: 1px dashed var(--border);
  border-radius: 26px;
  color: var(--muted);
  text-align: center;
}

.empty.visible {
  display: block;
}

.source {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

#detailView.active ~ .source {
  display: none;
}

@media (max-width: 820px) {
  .page {
    width: min(100% - 24px, 1160px);
    padding: 28px 0 40px;
  }

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

  .toolbar {
    position: static;
  }

  .search {
    width: 100%;
  }

  .timeline-view::before {
    left: 23px;
  }

  .timeline-era {
    justify-self: start;
    margin-left: 48px;
  }

  .timeline-item {
    grid-template-columns: 46px 1fr;
    gap: 12px;
    align-items: start;
    min-height: 0;
  }

  .timeline-dot {
    grid-column: 1;
    width: 38px;
    height: 38px;
    margin-top: 12px;
    font-size: 11px;
    box-shadow: 0 0 0 6px rgba(8, 10, 18, 0.92);
  }

  .timeline-card,
  .timeline-item:nth-of-type(even) .timeline-card {
    grid-column: 2;
  }

  .timeline-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .timeline-card-header .watch-toggle {
    margin-top: 12px;
  }

  .timeline-card .watch-toggle-btn {
    flex: 1;
    padding: 11px 10px;
    font-size: 14px;
    text-align: center;
  }
}

@media (max-width: 600px) {
  .toolbar {
    padding: 12px;
    border-radius: 20px;
  }

  .toolbar-row {
    display: contents;
  }

  .essential-toggle {
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .toggle-switch {
    width: 28px;
    height: 16px;
  }

  .toggle-switch::after {
    width: 12px;
    height: 12px;
  }

  .toggle-input:checked ~ .toggle-switch::after {
    transform: translateX(12px);
  }

  .account-group {
    order: 4;
    justify-content: space-between;
  }

  .filters {
    gap: 6px;
  }

  .filters button {
    padding: 7px 10px;
    font-size: 12.5px;
  }
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  gap: 16px;
  background: var(--bg);
  color: var(--muted);
}

.app-loading.hidden {
  display: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.spinner[hidden] {
  display: none;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(230, 36, 41, 0.32), transparent 32rem),
    rgba(6, 7, 11, 0.9);
  backdrop-filter: blur(16px);
}

.login-screen.visible {
  display: grid;
}

.login-card {
  width: min(100%, 420px);
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.035)),
    var(--panel-solid);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.login-card p {
  color: var(--muted);
  line-height: 1.5;
}

.login-eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.password-label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.password-input {
  width: 100%;
  margin-bottom: 16px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  outline: none;
}

#signInSubmitButton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#signInSubmitButton:disabled {
  opacity: 0.7;
  cursor: default;
}

.login-error {
  min-height: 22px;
  margin-bottom: 0;
  color: #ffcfd0;
}

.app-error {
  display: none;
  margin: 0 0 16px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(230, 36, 41, 0.16);
  color: #ffcfd0;
}

.app-error.visible {
  display: block;
}

.detail-card {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.082), rgba(255, 255, 255, 0.026)),
    var(--panel-solid);
  box-shadow: var(--shadow);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.back-button:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.detail-omdb {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  margin-top: 18px;
}

.detail-poster {
  width: 140px;
  border-radius: 16px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
}

.detail-omdb-text {
  display: grid;
  gap: 8px;
  align-content: start;
}

.detail-rating {
  margin: 0;
  font-size: 15px;
}

.detail-rating strong {
  color: #f5c518;
}

.detail-released {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-plot {
  margin: 0;
  line-height: 1.6;
  color: var(--text);
}

.detail-trailer {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
  padding-top: 2em;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease;
}

.detail-trailer:hover {
  transform: translateY(-1px);
}

.detail-trailer:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 4px;
}

.detail-trailer-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.detail-trailer-thumb-empty {
  border: 1px dashed var(--border);
}

.detail-trailer-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.detail-trailer-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.detail-trailer-meta {
  color: var(--muted);
  font-size: 12px;
}

.detail-trailer-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.detail-trailer-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
}

.detail-trailer-modal {
  position: relative;
  width: min(100%, 1180px);
}

.detail-trailer-minimize {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.72);
  color: var(--text);
  font-size: 13px;
}

.detail-trailer-iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 12px;
  background: #000;
}

.detail-omdb-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
}

.detail-episodes {
  margin-top: 22px;
  border-top: 1px solid var(--border);
}

.detail-episodes summary {
  padding: 18px 0 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.detail-episodes-status {
  margin: 0;
  color: var(--muted);
}

.episode-list {
  display: grid;
  gap: 0;
}

.episode-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.episode-thumb {
  width: 92px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.episode-thumb-empty {
  border: 1px dashed var(--border);
}

.episode-main {
  min-width: 0;
}

.episode-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.episode-heading h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.episode-watch-btn {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
}

.episode-watch-btn.active {
  border-color: transparent;
  background: var(--done);
  color: #07130d;
}

.episode-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.episode-plot {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 820px) {
  .detail-omdb {
    grid-template-columns: 1fr;
  }

  .detail-poster {
    width: 100%;
    max-width: 220px;
  }

  .detail-trailer {
    grid-template-columns: 1fr;
  }

  .episode-row {
    grid-template-columns: 1fr;
  }

  .episode-thumb {
    width: min(100%, 220px);
  }

  .episode-heading {
    flex-direction: column;
  }

  .episode-watch-btn {
    width: 100%;
    text-align: center;
  }
}

.login-card {
  position: relative;
}

.signin-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.signin-success h2 {
  margin: 0 0 18px;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.signin-success button {
  width: 100%;
}

.account-email {
  color: var(--muted);
  font-size: 13px;
}
