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

:root {
  --background: #fff8f6;
  --surface: #ffffff;
  --surface-light: #f9ece9;
  --text: #24191a;
  --muted: #866f6f;
  --accent: #7b1f2b;
  --accent-dark: #59141d;
  --accent-light: #f3dadd;
  --border: #ead7d3;
  --shadow: rgba(91, 45, 45, 0.12);
}

body {
  min-height: 100vh;
  background: #f7efec;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 20px 110px;
  background:
    radial-gradient(
      circle at top right,
      rgba(123, 31, 43, 0.09),
      transparent 35%
    ),
    var(--background);
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.welcome-text,
.eyebrow,
.progress-text,
.episode-text,
.stat-label {
  color: var(--muted);
}

.welcome-text {
  margin-bottom: 4px;
  font-size: 14px;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.profile-circle {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(123, 31, 43, 0.16);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b95d69);
  color: #ffffff;
  font-weight: 700;
}

.page {
  display: none;
}

.active-page {
  display: block;
}

.page-title,
.section-heading {
  margin-bottom: 20px;
}

.eyebrow {
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.4px;
}

#continue-watching-list,
.search-results {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.show-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 17px;
  margin-bottom: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 12px 30px var(--shadow);
}

.poster-image,
.poster-placeholder {
  width: 115px;
  min-width: 115px;
  max-width: 115px;
  height: 170px;
  min-height: 170px;
  max-height: 170px;
  flex: 0 0 115px;
  border-radius: 15px;
}

.poster-image {
  display: block;
  object-fit: cover;
  object-position: center;
}

.poster-placeholder {
  display: grid;
  place-items: center;
  background:
    linear-gradient(
      rgba(123, 31, 43, 0.05),
      rgba(123, 31, 43, 0.2)
    ),
    var(--accent-light);
  color: var(--accent);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
}

.show-information {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.show-status {
  margin: 4px 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
}

.episode-text {
  margin-top: 8px;
  font-size: 14px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface-light);
}

.progress-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--accent), #b95d69);
}

.progress-text {
  margin-top: 7px;
  font-size: 12px;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  padding: 11px 12px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

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

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-light);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.secondary-button:hover {
  border-color: var(--accent);
}

.tracking-buttons {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 16px;
}

.tracking-buttons .primary-button {
  margin-top: 0;
}

.empty-card {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
}

.empty-card p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.search-box {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

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

.search-box button {
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.form-message {
  min-height: 20px;
  color: var(--accent);
  font-size: 13px;
  text-align: center;
}

.search-result-card {
  display: flex;
  gap: 15px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}

.search-result-poster,
.search-result-poster-placeholder {
  width: 92px;
  min-width: 92px;
  max-width: 92px;
  height: 138px;
  min-height: 138px;
  max-height: 138px;
  flex: 0 0 92px;
  border-radius: 13px;
}

.search-result-poster {
  object-fit: cover;
  object-position: center;
}

.search-result-poster-placeholder {
  display: grid;
  place-items: center;
  background: var(--surface-light);
  color: var(--muted);
  font-weight: 700;
}

.search-result-information {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.search-result-information h3 {
  margin-bottom: 6px;
}

.search-result-year {
  margin-bottom: 9px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.search-result-description {
  display: -webkit-box;
  margin-bottom: 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.search-result-information .primary-button {
  margin-top: auto;
}

.filter-buttons {
  display: flex;
  gap: 9px;
  margin-bottom: 22px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.filter-button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

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

.status-select {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  background: var(--surface-light);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.status-select:focus {
  border-color: var(--accent);
}

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

.stat-card {
  min-height: 130px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}

.stat-number {
  margin-bottom: 26px;
  font-size: 30px;
  font-weight: 800;
}

.stat-label {
  font-size: 13px;
  line-height: 1.4;
}

.home-show-card {
  padding-right: 68px;
}

.home-check-button {
  position: absolute;
  top: 50%;
  right: 14px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  transform: translateY(-50%);
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.home-check-button:hover {
  background: var(--accent);
  color: #ffffff;
  transform: translateY(-50%) scale(1.06);
}

.home-check-button:active {
  transform: translateY(-50%) scale(0.94);
}

.home-check-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.bottom-navigation {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 10px 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(255, 248, 246, 0.96);
  box-shadow: 0 -6px 24px rgba(91, 45, 45, 0.08);
  backdrop-filter: blur(16px);
}

.nav-button {
  display: flex;
  width: 25%;
  max-width: 120px;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: #a28c8c;
  font-size: 11px;
}

.nav-icon {
  font-size: 23px;
}

.active-nav {
  color: var(--accent);
}
.library-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.library-check-button,
.library-undo-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.library-check-button {
  border: 2px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 22px;
}

.library-check-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.library-undo-button {
  border: 1px solid var(--border);
  background: var(--surface-light);
  color: var(--accent);
  font-size: 21px;
}

.library-undo-button:hover {
  border-color: var(--accent);
}

.library-check-button:active,
.library-undo-button:active {
  transform: scale(0.94);
}

.library-check-button:disabled,
.library-undo-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.back-button {
  margin-bottom: 20px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.back-button:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.details-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 12px 30px var(--shadow);
}

.details-poster {
  display: block;
  width: 125px;
  min-width: 125px;
  height: 188px;
  object-fit: cover;
  object-position: center;
  border-radius: 16px;
}

.details-poster-placeholder {
  display: grid;
  width: 125px;
  min-width: 125px;
  height: 188px;
  place-items: center;
  border-radius: 16px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 26px;
  font-weight: 800;
}

.details-information {
  flex: 1;
  min-width: 0;
}

.details-information h2 {
  margin-bottom: 10px;
}

.details-status {
  margin-bottom: 14px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
}

.details-progress-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.seasons-section {
  margin-top: 24px;
}

.seasons-section h3 {
  margin-bottom: 14px;
}

.season-buttons {
  display: flex;
  gap: 9px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.season-button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.active-season-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.episode-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.episode-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.episode-number {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-light);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.episode-information {
  flex: 1;
  min-width: 0;
}

.episode-information h4 {
  margin-bottom: 4px;
  font-size: 14px;
}

.episode-information p {
  color: var(--muted);
  font-size: 12px;
}

.episode-check-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 19px;
  font-weight: 800;
}

@media (max-width: 380px) {
  .app-container {
    padding-right: 14px;
    padding-left: 14px;
  }

  .poster-image,
  .poster-placeholder {
    width: 96px;
    min-width: 96px;
    max-width: 96px;
    height: 145px;
    min-height: 145px;
    max-height: 145px;
    flex-basis: 96px;
  }

  .search-result-poster,
  .search-result-poster-placeholder {
    width: 78px;
    min-width: 78px;
    max-width: 78px;
    height: 117px;
    min-height: 117px;
    max-height: 117px;
    flex-basis: 78px;
  }

  .primary-button {
    font-size: 12px;
  }

  .home-show-card {
    padding-right: 58px;
  }

  .home-check-button {
    right: 10px;
    width: 40px;
    height: 40px;
  }
  .library-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.library-check-button,
.library-undo-button,
.library-delete-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  line-height: 1;
}

.library-check-button {
  border: 2px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 22px;
}

.library-undo-button {
  border: 1px solid var(--border);
  background: var(--surface-light);
  color: var(--accent);
  font-size: 21px;
}

.library-delete-button {
    border:1px solid var(--border);
    background: var(--surface-light);
    color: var(--accent);
}

.library-check-button:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.library-undo-button:hover {
  border-color: var(--accent);
}

.library-delete-button:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.library-check-button:active,
.library-undo-button:active,
.library-delete-button:active {
  transform: scale(0.94);
}

.library-check-button:disabled,
.library-undo-button:disabled,
.library-delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.details-header {
    gap: 13px;
    padding: 14px;
}
.details-poster,
.details-poster-placeholder {
    width: 100px;
    min-width: 100px;
    height: 150px;
}
.watched-episode-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.episode-check-button:hover {
  background: var(--accent-light);
}

.watched-episode-button:hover {
  background: var(--accent-dark);
  color: #ffffff;
}

.episode-check-button:active {
  transform: scale(0.94);
}

.episode-card {
  transition:
    border-color 0.2s ease,
    transform 0.2s ease;
}

.episode-card:hover {
  border-color: var(--accent);
}

.delete-icon {
  display: block;
  transform: translateY(-1px);
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
}

.import-section {
  margin-top: 26px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 12px 30px var(--shadow);
}

.import-heading {
  margin-bottom: 12px;
}

.import-description {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

#tvtime-import-input {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--surface-light);
  color: var(--text);
  font-size: 13px;
}

.import-message {
  min-height: 20px;
  margin-top: 14px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.45;
}

}
/* =========================================================
   TV TRACKER AUTHENTICATION
   ========================================================= */

.tv-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #101014;
}

.tv-auth-gate[hidden] {
  display: none;
}

.tv-login-card {
  width: min(100%, 380px);
  padding: 28px;
  border-radius: 18px;
  background: #1c1c22;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.tv-login-card h1 {
  margin: 0 0 8px;
  color: #ffffff;
  font-size: 28px;
}

.tv-login-card p {
  color: #b8b8c2;
}

.tv-login-card label {
  display: block;
  margin: 18px 0 7px;
  color: #ffffff;
  font-weight: 600;
}

.tv-login-card input {
  box-sizing: border-box;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #3d3d46;
  border-radius: 10px;
  outline: none;
  background: #282830;
  color: #ffffff;
  font: inherit;
}

.tv-login-card input:focus {
  border-color: #8b7cff;
}

.tv-login-card button {
  width: 100%;
  margin-top: 22px;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: #8b7cff;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tv-login-card button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.tv-login-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: #ff8e8e !important;
  font-size: 14px;
}

.tv-logout-button {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9998;
  padding: 8px 12px;
  border: 1px solid #44444e;
  border-radius: 8px;
  background: #222229;
  color: #ffffff;
  cursor: pointer;
}
/* =========================================================
   CLOUD SYNC STATUS
   ========================================================= */

.tv-sync-status {
  max-width: 250px;
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tv-sync-status[data-state="synced"] {
  color: #39754a;
}

.tv-sync-status[data-state="loading"],
.tv-sync-status[data-state="syncing"],
.tv-sync-status[data-state="pending"] {
  color: var(--accent);
}

.tv-sync-status[data-state="warning"] {
  color: #9a6500;
}

.tv-sync-status[data-state="error"] {
  color: #b42318;
}

/* -------------------------------------
   My Shows poster grid
------------------------------------- */

#shows-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 13px;
}

#shows-list .empty-card {
  grid-column: 1 / -1;
}

.library-poster-card {
  min-width: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    filter 0.18s ease;
}

.library-poster-card:hover {
  transform: translateY(-3px);
  filter: brightness(1.03);
}

.library-poster-card:active {
  transform: scale(0.97);
}

.library-poster-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-light);
  box-shadow: 0 8px 20px var(--shadow);
}

.library-poster-image,
.library-poster-placeholder {
  display: block;
  width: 100%;
  height: 100%;
}

.library-poster-image {
  object-fit: cover;
  object-position: center;
}

.library-poster-placeholder {
  display: grid;
  place-items: center;
  padding: 8px;
  background:
    linear-gradient(
      145deg,
      rgba(123, 31, 43, 0.05),
      rgba(123, 31, 43, 0.2)
    ),
    var(--accent-light);
  color: var(--accent);
  font-size: clamp(18px, 6vw, 26px);
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
}

.library-poster-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.14);
}

.library-poster-progress-fill {
  height: 100%;
  min-width: 0;
  background:
    linear-gradient(
      90deg,
      var(--accent),
      #b95d69
    );
  transition: width 0.25s ease;
}

@media (max-width: 360px) {
  #shows-list {
    gap: 9px;
  }

  .library-poster-frame {
    border-radius: 13px;
  }
}

.details-status-control {
  display: block;
  margin-top: 14px;
}

.details-status-control > span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.details-status-select {
  margin-top: 6px;
}

/* -------------------------------------
   Entire-season watched control
------------------------------------- */

.season-watch-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-light);
}

.season-watch-copy {
  min-width: 0;
}

.season-watch-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.season-watch-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.season-watch-button {
  display: inline-flex;
  min-height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.season-watch-button:hover {
  background: var(--accent-light);
}

.season-watch-button:active {
  transform: scale(0.96);
}

.season-watch-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.season-watch-check {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
}

.season-watch-button-complete {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.season-watch-button-complete:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.season-watch-button-complete
.season-watch-check {
  border-color: #ffffff;
  background: #ffffff;
  color: var(--accent);
}

@media (max-width: 420px) {
  .season-watch-control {
    align-items: stretch;
    flex-direction: column;
  }

  .season-watch-button {
    width: 100%;
  }
}

/* -------------------------------------
   Compact Home episode cards
------------------------------------- */

#continue-watching-list {
  gap: 12px;
}

.home-episodes-loading {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.home-episode-card {
  display: grid;
  grid-template-columns:
    60px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 12px;
  min-height: 102px;
  padding: 10px 12px 10px 10px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 8px 20px var(--shadow);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    transform 0.18s ease;
}

.home-episode-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.home-episode-card:active {
  transform: scale(0.985);
}

.home-episode-poster,
.home-episode-poster-placeholder {
  display: block;
  width: 60px;
  height: 90px;
  border-radius: 11px;
}

.home-episode-poster {
  object-fit: cover;
  object-position: center;
}

.home-episode-poster-placeholder {
  display: grid;
  place-items: center;
  padding: 5px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

.home-episode-information {
  min-width: 0;
}

.home-series-title {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-episode-code {
  margin-top: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
}

.home-episode-name {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.home-episode-progress {
  width: 100%;
  height: 5px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-light);
}

.home-episode-progress-fill {
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(
      90deg,
      var(--accent),
      #b95d69
    );
}

.home-episode-check-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.home-episode-check-button:hover {
  background: var(--accent);
  color: #ffffff;
}

.home-episode-check-button:active {
  transform: scale(0.92);
}

@media (max-width: 360px) {
  .home-episode-card {
    grid-template-columns:
      52px minmax(0, 1fr) 36px;
    gap: 9px;
    padding: 8px 9px 8px 8px;
  }

  .home-episode-poster,
  .home-episode-poster-placeholder {
    width: 52px;
    height: 78px;
    border-radius: 9px;
  }

  .home-episode-check-button {
    width: 36px;
    height: 36px;
    font-size: 19px;
  }
}

/* -------------------------------------
   Readable watch-time statistic
------------------------------------- */

#time-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 20px;
  line-height: 1.15;
}

#time-stat span {
  display: block;
}

#time-stat span:first-child {
  font-size: 25px;
}
/* -------------------------------------
   Library toolbar and custom lists
------------------------------------- */

.library-tools {
  margin-bottom: 18px;
}

.library-search-box {
  margin-bottom: 12px;
}

.library-search-box button[hidden] {
  display: none;
}

.library-select-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.library-control {
  display: block;
  min-width: 0;
}

.library-control > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.library-control select {
  width: 100%;
  min-width: 0;
  padding: 11px 34px 11px 11px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.library-control select:focus {
  border-color: var(--accent);
}

.library-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  margin-bottom: 13px;
}

.library-results-header p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* Stronger poster progress gradient */

.library-poster-progress {
  height: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.library-poster-progress-fill {
  background:
    linear-gradient(
      90deg,
      #7b1f2b 0%,
      #c84f78 52%,
      #ee9a4d 100%
    );
  box-shadow:
    0 0 8px rgba(200, 79, 120, 0.55);
}

/* Show-details custom lists */

.details-lists-section {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-light);
}

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

.details-lists-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.details-lists-description {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.details-list-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.details-list-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 7px 9px 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.details-list-chip:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.details-list-chip span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.details-list-chip-remove {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-light);
  font-size: 14px;
  line-height: 1;
}

.details-no-lists {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.details-list-form {
  display: flex;
  gap: 8px;
  margin-top: 11px;
}

.details-list-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.details-list-form input:focus {
  border-color: var(--accent);
}

.details-list-form button {
  flex: 0 0 auto;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.details-list-form button:hover {
  background: var(--accent-dark);
}

@media (max-width: 380px) {
  .library-select-grid {
    grid-template-columns: 1fr;
  }

  .details-list-form {
    flex-direction: column;
  }

  .details-list-form button {
    min-height: 40px;
  }
}

/* Swipe-to-watch Home cards */

.home-swipe-row {
  position: relative;
  overflow: hidden;
  border-radius: 17px;
  background: linear-gradient(90deg, #18864b, #28a964);
}

.home-swipe-complete {
  position: absolute;
  inset: 0 auto 0 0;
  display: flex;
  width: 130px;
  align-items: center;
  gap: 8px;
  padding-left: 20px;
  color: #ffffff;
}

.home-swipe-complete span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  font-size: 18px;
}

.home-episode-card {
  position: relative;
  grid-template-columns: 60px minmax(0, 1fr);
  touch-action: pan-y;
  user-select: none;
  will-change: transform;
}

.home-episode-card.is-swiping {
  cursor: grabbing;
  transition: none;
}

.home-episode-card.is-swipe-complete {
  pointer-events: none;
  transition: transform 0.22s ease-in;
}

.home-swipe-undo {
  position: fixed;
  z-index: 1200;
  right: 16px;
  bottom: 92px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border: 1px solid #4ac77d;
  border-radius: 12px;
  background: #173c29;
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  font-weight: 700;
}

/* Search result preview */

.search-result-card {
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.search-result-card:hover,
.search-result-card:focus-visible {
  border-color: var(--accent);
  outline: none;
  transform: translateY(-2px);
}

.search-preview-meta,
.search-preview-overview {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.search-preview-overview {
  margin-bottom: 14px;
}

.search-preview-saved {
  display: inline-block;
  margin-top: 13px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(38, 166, 91, 0.14);
  color: #36b86e;
  font-size: 12px;
  font-weight: 800;
}

.search-preview-cast {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.search-preview-cast ul {
  display: grid;
  gap: 9px;
  margin-top: 13px;
  padding: 0;
  list-style: none;
}

.search-preview-cast li {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.search-preview-cast li span {
  color: var(--muted);
}

/* Completed episode controls */

.watched-episode-button,
.watched-episode-button:hover {
  border-color: #24965a;
  background: #24965a;
  color: #ffffff;
}

.season-watch-button-complete,
.season-watch-button-complete:hover {
  border-color: #24965a;
  background: #24965a;
  color: #ffffff;
}

/* Statistics hierarchy */

.stat-card-wide {
  grid-column: 1 / -1;
}

.stat-card-watch-time {
  overflow-x: auto;
}

#time-stat {
  display: flex;
  gap: 18px;
  width: max-content;
  min-width: 100%;
  align-items: baseline;
  white-space: nowrap;
}

#time-stat span,
#time-stat span:first-child {
  display: inline;
  font-size: inherit;
}

@media (max-width: 520px) {
  .search-preview-header {
    align-items: flex-start;
  }

  .search-preview-header .details-poster,
  .search-preview-header .details-poster-placeholder {
    width: 92px;
    min-width: 92px;
    height: 138px;
  }

  #time-stat {
    gap: 13px;
    font-size: 24px;
  }
}

/* TV Time-inspired statistics hierarchy */

.statistics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  overflow: visible;
  padding-bottom: 0;
}

.statistics-grid .stat-card {
  min-width: 0;
  min-height: 132px;
  padding: 20px;
  border-radius: 20px;
  border-color: rgba(123, 31, 43, 0.2);
  box-shadow: 0 8px 24px var(--shadow);
}

.statistics-grid .stat-card-full {
  grid-column: 1 / -1;
}

.statistics-grid .stat-card-full .stat-label {
  order: -1;
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.statistics-grid .stat-card-watch-time {
  min-height: 172px;
  overflow-x: auto;
  overflow-y: hidden;
}

.statistics-grid #time-stat {
  display: flex;
  width: max-content;
  min-width: 100%;
  flex: 1;
  align-items: center;
  gap: 28px;
  margin: 0;
  white-space: nowrap;
}

.statistics-grid .watch-time-unit {
  display: flex;
  min-width: 76px;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  text-align: center;
}

.statistics-grid .watch-time-unit strong {
  color: var(--accent);
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 900;
  line-height: 0.95;
}

.statistics-grid .watch-time-unit small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 1px;
  line-height: 1;
  text-transform: uppercase;
}

.statistics-grid .stat-card-episodes {
  min-height: 150px;
}

.statistics-grid .stat-card-episodes .stat-number {
  color: var(--accent);
  font-size: clamp(38px, 7vw, 54px);
  font-weight: 900;
}

.statistics-grid .stat-card:not(.stat-card-full) .stat-number {
  color: var(--accent);
  font-size: 34px;
  font-weight: 900;
}

@media (max-width: 420px) {
  .statistics-grid {
    gap: 10px;
  }

  .statistics-grid .stat-card {
    min-height: 118px;
    padding: 16px;
  }

  .statistics-grid .stat-card-watch-time {
    min-height: 158px;
  }

  .statistics-grid #time-stat {
    gap: 18px;
  }
}

/* Discovery */

.bottom-navigation .nav-button {
  width: 25%;
}

.discovery-filters {
  display: flex;
  gap: 9px;
  margin-bottom: 14px;
  padding-bottom: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.discovery-filter {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.discovery-filter:hover,
.active-discovery-filter {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.browse-genre-control {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 18px;
}

.browse-genre-control > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.browse-genre-control select {
  width: min(240px, 100%);
  min-width: 0;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.browse-genre-control select:focus {
  border-color: var(--accent);
}

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

.discovery-grid > .empty-card {
  grid-column: 1 / -1;
}

.discovery-card {
  min-width: 0;
  cursor: pointer;
}

.discovery-poster-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 22px var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.discovery-card:hover .discovery-poster-frame,
.discovery-card:focus-visible .discovery-poster-frame {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.discovery-card:focus-visible {
  outline: none;
}

.discovery-poster-frame img,
.discovery-poster-placeholder {
  width: 100%;
  height: 100%;
}

.discovery-poster-frame img {
  display: block;
  object-fit: cover;
}

.discovery-poster-placeholder {
  display: grid;
  place-items: center;
  padding: 12px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.discovery-saved-badge,
.discovery-rating {
  position: absolute;
  bottom: 8px;
  padding: 5px 7px;
  border-radius: 999px;
  background: rgba(20, 18, 20, 0.82);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  backdrop-filter: blur(5px);
}

.discovery-saved-badge {
  top: 8px;
  right: 8px;
  bottom: auto;
  background: rgba(29, 139, 78, 0.92);
}

.discovery-rating {
  left: 8px;
}

.discovery-card h3 {
  margin-top: 9px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discovery-card > p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.search-section-heading {
  margin: 30px 0 14px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.search-results[hidden],
#search-highlights[hidden] {
  display: none;
}

.search-with-genres {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.55fr) auto;
}

.search-with-genres select {
  min-width: 0;
  padding: 0 36px 0 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.search-with-genres select:focus {
  border-color: var(--accent);
}

.search-result-genres {
  margin: -4px 0 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

/* Custom-list statistics */

.stats-lists-section {
  margin-top: 24px;
}

.stats-lists-heading {
  margin-bottom: 13px;
}

.stats-lists-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stats-lists-grid > .empty-card {
  grid-column: 1 / -1;
}

.stats-list-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.stats-list-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.stats-list-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-list-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 760px) {
  .discovery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .discovery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 11px;
  }

  .search-with-genres {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-with-genres input {
    grid-column: 1 / -1;
  }

  .search-with-genres select,
  .search-with-genres button {
    min-height: 46px;
  }
}

@media (max-width: 520px) {
  .browse-genre-control {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .browse-genre-control select {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .bottom-navigation {
    padding-right: 5px;
    padding-left: 5px;
  }

  .bottom-navigation .nav-button {
    font-size: 9px;
  }

  .bottom-navigation .nav-icon {
    font-size: 20px;
  }
}

/* Fixed single-row statistics scroller */

.statistics-scroll-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.statistics-scroll-container::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.statistics-row {
  display: flex;
  width: max-content;
  flex-wrap: nowrap;
  gap: 12px;
}

.statistics-row .stat-card {
  display: flex;
  box-sizing: border-box;
  width: 175px;
  height: 92px;
  min-width: 175px;
  min-height: 92px;
  max-width: 175px;
  max-height: 92px;
  flex: 0 0 175px;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 7px 20px var(--shadow);
  scroll-snap-align: start;
}

.statistics-row .stat-card:first-child {
  width: max-content;
  min-width: 175px;
  max-width: none;
  flex: 0 0 auto;
}

.statistics-row .stat-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.55px;
  line-height: 1.2;
  text-transform: uppercase;
}

.statistics-row .stat-number {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 25px;
  font-weight: 900;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statistics-row #time-stat {
  display: block;
  width: auto;
  min-width: 0;
  width: max-content;
  max-width: none;
  overflow: visible;
  font-size: 20px;
  letter-spacing: -0.4px;
  text-overflow: clip;
  white-space: nowrap;
}

/* Shared cast rail and season preview */
.details-cast-section,
.preview-seasons-section { margin-top: 20px; }

.details-cast-section > h3,
.preview-seasons-section > h3 { margin-bottom: 12px; }

.cast-rail {
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 1px 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.cast-rail::-webkit-scrollbar { display: none; }

.cast-card {
  width: 105px;
  min-width: 105px;
  flex: 0 0 105px;
  scroll-snap-align: start;
}

.cast-card img,
.cast-photo-placeholder {
  display: block;
  width: 105px;
  height: 132px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-light);
  object-fit: cover;
}

.cast-photo-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 22px;
  font-weight: 850;
}

.cast-actor {
  margin-top: 8px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cast-character {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.preview-seasons-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.preview-season-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.preview-season-card strong { color: var(--text); font-size: 13px; }
.preview-season-card span,
.preview-season-card small { color: var(--muted); font-size: 11px; }

/* Unified show header actions */
.details-header { position: relative; }
.saved-details-header { padding-top: 58px; }
.details-action-menus {
  position: absolute; top: 12px; right: 12px; z-index: 8;
  display: flex; gap: 8px;
}
.details-action-menu { position: relative; }
.details-action-menu > summary {
  display: grid; width: 38px; height: 38px; place-items: center;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface-light); color: var(--accent);
  font-size: 22px; font-weight: 850; cursor: pointer; list-style: none;
}
.details-action-menu > summary::-webkit-details-marker { display: none; }
.details-action-menu[open] > summary,
.details-action-menu > summary:hover {
  border-color: var(--accent); background: var(--accent); color: #fff;
}
.details-action-popover {
  position: absolute; top: 46px; right: 0;
  width: min(310px, calc(100vw - 42px)); padding: 14px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); box-shadow: 0 16px 40px rgba(60,25,30,.2);
}
.details-action-popover > strong {
  display: block; margin-bottom: 9px; color: var(--text);
  font-size: 12px; text-transform: uppercase;
}
.status-action-popover { width: min(220px, calc(100vw - 42px)); }
.details-action-popover .status-select { margin-top: 0; }
.details-action-popover .details-lists-section {
  margin: 0; padding: 0; border: 0; background: transparent;
}
.preview-episode-card { grid-template-columns: 42px minmax(0, 1fr); }

/* Shared Canadian watch-provider availability */
.watch-providers-section {
  margin-top: 20px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}
.watch-providers-section > h3 { margin-top: 2px; }
.watch-providers-content { margin-top: 14px; }
.watch-provider-group + .watch-provider-group { margin-top: 15px; }
.watch-provider-group h4 {
  margin-bottom: 8px; color: var(--text); font-size: 11px;
  font-weight: 850; letter-spacing: .6px; text-transform: uppercase;
}
.watch-provider-rail {
  display: flex; max-width: 100%; gap: 10px;
  overflow-x: auto; overflow-y: hidden; padding-bottom: 4px;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.watch-provider-rail::-webkit-scrollbar { display: none; }
.watch-provider {
  display: flex; width: 68px; min-width: 68px; flex: 0 0 68px;
  flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.watch-provider img,
.provider-logo-placeholder {
  display: block; width: 48px; height: 48px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-light); object-fit: cover;
}
.provider-logo-placeholder {
  display: grid; place-items: center; color: var(--accent);
  font-size: 12px; font-weight: 850;
}
.watch-provider span {
  display: -webkit-box; overflow: hidden; color: var(--muted);
  font-size: 9px; line-height: 1.2;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.watch-providers-empty { color: var(--muted); font-size: 12px; line-height: 1.45; }
.watch-provider-link {
  display: inline-block; margin-top: 14px; color: var(--accent);
  font-size: 12px; font-weight: 800;
}
.watch-provider-attribution {
  margin-top: 9px; color: var(--muted); font-size: 9px;
}

/* Compact single-row provider rail */
.watch-providers-section {
  padding: 13px 14px;
}
.watch-providers-content { margin-top: 10px; }
.watch-provider-list {
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 9px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1px 0 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.watch-provider-list::-webkit-scrollbar { display: none; }
.watch-provider-compact {
  display: flex;
  width: 150px;
  min-width: 150px;
  height: 54px;
  flex: 0 0 150px;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-light);
  scroll-snap-align: start;
}
.watch-provider-compact img,
.watch-provider-compact .provider-logo-placeholder {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
}
.watch-provider-compact > div:last-child { min-width: 0; }
.watch-provider-compact strong,
.watch-provider-compact span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch-provider-compact strong {
  color: var(--text);
  font-size: 11px;
}
.watch-provider-compact span {
  margin-top: 3px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 750;
}
.watch-provider-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.watch-provider-footer .watch-provider-link,
.watch-provider-footer .watch-provider-attribution { margin-top: 0; }

@media (max-width: 520px) {
  .preview-seasons-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Swipeable Home sections */
.home-views-scroll {
  display: flex;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.home-views-scroll::-webkit-scrollbar { display: none; }
.home-view-tabs { display: none; }
.home-view-panel {
  display: block !important;
  width: 100%;
  min-width: 100%;
  flex: 0 0 100%;
  padding: 2px 1px 16px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.home-panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.home-panel-heading h2 { margin: 3px 0 0; font-size: clamp(1.7rem, 7vw, 2.35rem); line-height: 1.05; }
.home-swipe-hint { max-width: 140px; margin: 0 2px 2px 0; color: var(--muted); font-size: .72rem; line-height: 1.35; text-align: right; }
.upcoming-group + .upcoming-group { margin-top: 24px; }
.upcoming-group > h3 { margin-bottom: 10px; color: var(--accent); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.upcoming-card { margin-bottom: 10px; }
.upcoming-date { margin-top: 7px; color: var(--text); font-size: .72rem; font-weight: 750; }
.upcoming-network { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.home-skeleton-list { display: grid; gap: 12px; }
.home-skeleton-card { height: 102px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-light); }

/* Direct repeat-watch controls */
.watch-again-button,
.season-rewatch-button {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
}
.watch-again-button { margin-top: 8px; }
.rewatch-count { margin-top: 5px !important; color: var(--success-dark, #216b49) !important; font-weight: 800; }

/* Detailed activity opens from the Watch Time card. */
.stat-card[data-open-activity] { cursor: pointer; text-align: left; font: inherit; }
.stat-card[data-open-activity]:hover { border-color: var(--accent); background: var(--surface-light); }
.page-intro { max-width: 560px; margin-top: 8px; color: var(--muted); line-height: 1.5; }
.insights-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.insight-card { min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.insight-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.insight-values p { margin: 0; }
.insight-values strong { display: block; color: var(--accent-dark); font-size: clamp(1.2rem, 3vw, 1.8rem); }
.insight-values span { display: block; margin-top: 4px; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.insight-note { margin: 18px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }

/* Four-poster custom-list covers */
.stats-list-card { overflow: hidden; padding: 0; text-align: left; }
.stats-list-cover { display: grid; grid-template: repeat(2, 1fr) / repeat(2, 1fr); width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-light); }
.stats-list-cover img,
.list-cover-placeholder { width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.list-cover-placeholder { display: grid; place-items: center; border: 1px solid var(--border); color: var(--muted); font-size: .7rem; font-weight: 800; }
.stats-list-copy { display: block; padding: 13px 14px 15px; }
.stats-list-name,
.stats-list-count { display: block; }

button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(119,31,45,.28); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 640px) {
  .insights-grid { grid-template-columns: 1fr; }
  .insight-card { padding: 16px; }
  .home-panel-heading { align-items: start; }
  .home-swipe-hint { max-width: 110px; }
}

/* Full-width horizontal custom-list cards */
.stats-lists-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
}
.stats-list-card {
  display: flex;
  width: 100%;
  min-height: 92px;
  height: 92px;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  border-radius: 16px;
}
.stats-list-cover {
  width: 142px;
  min-width: 142px;
  aspect-ratio: auto;
}
.stats-list-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 12px 16px;
}
.stats-list-name {
  overflow: visible;
  font-size: .95rem;
  line-height: 1.25;
  text-overflow: clip;
  white-space: normal;
}
.stats-list-count { margin-top: 4px; font-size: .7rem; }

/* Clear label/value relationships on Watching Activity. */
#activity-page .page-title { margin-bottom: 22px; }
#activity-page .insights-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 0;
}
#activity-page .insight-card { padding: 22px; }
#activity-page .insight-values {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}
#activity-page .insight-values p {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
#activity-page .insight-values span {
  order: -1;
  margin: 0;
  color: var(--text);
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
}
#activity-page .insight-values strong {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}
#activity-page .insight-note {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-light);
  color: var(--muted);
}

@media (max-width: 520px) {
  .stats-list-card { min-height: 82px; height: 82px; }
  .stats-list-cover { width: 112px; min-width: 112px; }
  .stats-list-copy { padding: 10px 12px; }
  #activity-page .insight-card { padding: 17px; }
  #activity-page .insight-values p { gap: 12px; }
}

/* Four posters in one strip with an overlapping list-name band. */
.stats-list-card {
  position: relative;
  display: block;
  isolation: isolate;
  height: 104px;
  min-height: 104px;
  background: var(--surface-light);
}
.stats-list-cover {
  display: grid;
  width: 100%;
  min-width: 100%;
  height: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: 1fr;
}
.stats-list-cover img,
.stats-list-cover .list-cover-placeholder {
  min-width: 0;
  border: 0;
  object-position: center 24%;
}
.stats-list-copy {
  position: absolute;
  z-index: 2;
  top: auto;
  bottom: 9px;
  left: 0;
  display: block;
  width: auto;
  max-width: 72%;
  min-width: 135px;
  padding: 8px 16px 9px;
  border-radius: 0 10px 10px 0;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 4px 12px rgba(36, 25, 26, .16);
  transform: none;
}
.stats-list-name {
  overflow: hidden;
  color: var(--accent-dark, #491018);
  font-size: .88rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-list-copy .stats-list-count { display: none; }

@media (max-width: 520px) {
  .stats-list-card { height: 92px; min-height: 92px; }
  .stats-list-copy { min-width: 118px; padding: 7px 12px 8px; }
  .stats-list-name { font-size: .8rem; }
}

/* Complete phone compatibility layer */
html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
img,
svg,
video,
canvas { max-width: 100%; }
.page,
main,
.app-container,
.details-information,
.episode-information,
.search-result-information { min-width: 0; max-width: 100%; }
.filter-buttons,
.season-buttons,
.discovery-filters,
.cast-rail,
.watch-provider-list,
.statistics-scroll-container {
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.filter-buttons::-webkit-scrollbar,
.season-buttons::-webkit-scrollbar,
.discovery-filters::-webkit-scrollbar,
.cast-rail::-webkit-scrollbar,
.statistics-scroll-container::-webkit-scrollbar { display: none; }

.bottom-navigation {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.app-container {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.tv-auth-gate {
  min-height: 100dvh;
  overflow-y: auto;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
}
.tv-logout-button {
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
}

@media (max-width: 600px) {
  body { background: var(--background); }
  .app-container {
    padding-top: max(18px, env(safe-area-inset-top));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }
  .top-header { gap: 12px; margin-bottom: 24px; }
  .top-header > div:first-child { min-width: 0; }
  .top-header h1 { overflow-wrap: anywhere; font-size: clamp(1.35rem, 7vw, 1.75rem); }
  .profile-circle { width: 42px; height: 42px; flex: 0 0 42px; }
  .tv-sync-status { max-width: min(62vw, 230px); }
  h2 { overflow-wrap: anywhere; }

  button,
  summary,
  .filter-button,
  .season-button,
  .discovery-filter { min-height: 44px; }
  input,
  select,
  textarea { max-width: 100%; font-size: 16px !important; }
  .primary-button { min-height: 46px; }

  .search-box,
  .search-with-genres { width: 100%; max-width: 100%; }
  .search-with-genres { grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
  .search-with-genres input { grid-column: 1 / -1; }
  .search-with-genres select,
  .search-with-genres button { min-width: 0; }
  .browse-genre-control { width: 100%; }

  .details-header { gap: 13px; padding: 14px; }
  .saved-details-header { padding-top: 58px; }
  .details-poster,
  .details-poster-placeholder { width: 100px; min-width: 100px; height: 150px; }
  .details-information h2 { font-size: clamp(1.18rem, 6vw, 1.5rem); line-height: 1.15; }
  .details-progress-text { overflow-wrap: anywhere; }
  .details-action-menus { top: 10px; right: 10px; }
  .details-action-menu > summary { width: 42px; height: 42px; }
  .details-action-popover {
    position: fixed;
    top: max(72px, calc(env(safe-area-inset-top) + 58px));
    right: 14px;
    left: 14px;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 100px - env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .status-action-popover { width: auto; }

  .episode-card { min-width: 0; }
  .episode-information h4,
  .episode-information p { overflow-wrap: anywhere; }
  .watch-again-button { width: 100%; white-space: normal; }
  .season-watch-control { align-items: stretch; flex-direction: column; }
  .season-watch-button,
  .season-rewatch-button { width: 100%; white-space: normal; }

  .watch-providers-section,
  .search-preview-cast { padding: 14px; }
  .watch-provider-footer { align-items: flex-start; flex-direction: column; }
  .watch-provider-footer a { overflow-wrap: anywhere; }

  .insight-values strong { max-width: 42%; overflow-wrap: anywhere; white-space: normal; }
  .stats-list-copy { max-width: 78%; }
  .stats-list-name { white-space: nowrap; }
  .import-section { min-width: 0; }
  #tvtime-import-input { overflow: hidden; }
}

@media (max-width: 380px) {
  .app-container { padding-right: 12px; padding-left: 12px; }
  .top-header { align-items: flex-start; }
  .profile-circle { width: 38px; height: 38px; flex-basis: 38px; }
  .tv-sync-status { max-width: 68vw; white-space: normal; }

  .details-header { gap: 10px; padding: 11px; }
  .saved-details-header { padding-top: 56px; }
  .details-poster,
  .details-poster-placeholder { width: 84px; min-width: 84px; height: 126px; border-radius: 12px; }
  .details-status { margin-bottom: 8px; font-size: .65rem; }
  .details-information h2 { margin-bottom: 7px; }

  .episode-card {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 38px;
    gap: 9px;
    padding: 11px 9px;
  }
  .episode-number { width: 34px; height: 34px; flex-basis: 34px; }
  .episode-check-button { width: 38px; height: 38px; }
  .home-panel-heading { gap: 8px; }
  .home-swipe-hint { max-width: 92px; font-size: .64rem; }

  .statistics-row .stat-card { width: 158px; min-width: 158px; max-width: 158px; flex-basis: 158px; }
  .statistics-row .stat-card:first-child { min-width: 158px; }
  #activity-page .insight-values p { align-items: flex-start; flex-direction: column; gap: 7px; }
  #activity-page .insight-values strong { max-width: 100%; text-align: left; }
  .stats-list-copy { max-width: 82%; min-width: 108px; }
}

@media (max-width: 330px) {
  .search-with-genres { grid-template-columns: 1fr; }
  .search-with-genres input,
  .search-with-genres select,
  .search-with-genres button { grid-column: 1; width: 100%; }
  #shows-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-navigation .nav-button { font-size: .55rem; }
  .bottom-navigation .nav-icon { font-size: 1.1rem; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .tv-login-card { padding: 18px; }
  .tv-login-card label { margin-top: 10px; }
  .tv-login-card button { margin-top: 14px; }
  .bottom-navigation { padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .nav-button { flex-direction: row; justify-content: center; }
}
