@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #eef3fb;
  --panel: #ffffff;
  --edge: #d3e0f2;
  --techblue: #2f5fac;
  --cherry: #ac2f5f;
  --blue-dim: #7fa1d6;
  --text: #1c2b40;
  --muted: #64748c;
  --border: #91B1DE;
  --movie: #2274A5;
  --show: #EB9C0A;
  --show-shelved: #F9CB76;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, rgba(47,95,172,0.07), transparent 45%);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.wrap {
  max-width: 768px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

.wrap.bulk {
  max-width: 1080px;
}

.wrap.wide {
  max-width: 1080px;
}

.marquee {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: 0.01em;
  color: var(--techblue);
  margin: 0 0 4px;
}

.subhead {
  color: var(--muted);
  margin: 0 0 36px;
  font-size: 0.95rem;
}

nav.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 36px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}

nav.tabs a {
  flex-shrink: 0;
}
nav.tabs a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 16px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
}

nav.tabs a.active {
  color: var(--techblue);
  font-weight: 500;
  background: #fff;
  border: 2px solid var(--techblue);
}
.card {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 28px;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input[type=text],
.field input[type=password],
.field input[type=date],
.field textarea,
.field select {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--edge);
  border-radius: 8px;
  color: var(--muted);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

.field input[type=text]:focus,
.field input[type=password]:focus,
.field input[type=date]:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--techblue);
  box-shadow: 0 0 0 3px rgba(47,95,172,0.12);
}

.field textarea { resize: vertical; min-height: 60px; }

.radio-row {
  display: flex;
  gap: 20px;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

button.save {
  background: var(--techblue);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
}

button.save:hover { background: #244d8f; }

.cancel-link {
  margin-left: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.cancel-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.notice {
  background: #e5f3ea;
  border: 2px solid #b9dcc4;
  color: #2f6b45;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 24px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.filter-bar input[type=text],
.filter-bar input[type=search] {
  flex: 1;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  -webkit-appearance: none;
  appearance: none;
}

.filter-bar select {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
}

.filter-bar input[type=text]:focus,
.filter-bar input[type=search]:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--techblue);
  box-shadow: 0 0 0 3px rgba(47,95,172,0.12);
}

.filter-bar input[type=search] { min-width: 180px; }
.filter-bar form { margin: 0; }
.filter-bar button.save {
  width: auto;
  white-space: nowrap;
  padding: 10px 18px;
  font-size: 0.9rem;
  height: 100%;
}

.table-wrap {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 4px 16px rgba(47,95,172,0.08);
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--techblue);
  font-weight: 600;
  padding: 16px 22px;
  border-bottom: 2px solid var(--border);
  background: #f6f9fe;
}

tbody td {
  padding: 18px 22px;
  border-bottom: 2px solid var(--edge);
  vertical-align: middle;
  font-size: 0.9rem;
  position: relative;
}

tbody tr:nth-child(even) td {
  background: #f6f9fe;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #e9f1fc;
}

tbody td:first-child {
  border-left: 6px solid var(--edge);
}

tbody tr[data-type="movie"] td:first-child { border-left-color: var(--movie); }
tbody tr[data-type="show"] td:first-child { border-left-color: var(--show); }
tbody tr.is-shelved[data-type="show"] td:first-child { border-left-color: var(--show-shelved); }

.row-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.row-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

.badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 8px;
  white-space: nowrap;
  color: #ffffff;
}

.badge.movie { background: var(--movie); }
.badge.show { background: var(--show); }

.service-form { margin: 0; }

.col-service {
  text-align: left;
}

.service-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.service-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #ffffff;
  border-radius: 8px;
  padding: 3px 6px 3px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

.service-remove {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 2px;
}

.service-remove:hover {
  color: #ffffff;
}

.service-add {
  appearance: none;
  -webkit-appearance: none;
  border: 2px dashed var(--edge);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.7rem;
  padding: 3px 8px;
  cursor: pointer;
}

.service-add:focus {
  outline: none;
  border-color: var(--techblue);
}

.col-title {
  min-width: 260px;
}

.col-date {
  color: var(--muted);
  white-space: nowrap;
}

.date-form {
  margin: 0;
}

.date-input {
  border: 2px solid var(--edge);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 5px 8px;
  cursor: pointer;
}

.date-input:focus {
  outline: none;
  border-color: var(--techblue);
  box-shadow: 0 0 0 3px rgba(47,95,172,0.12);
}

.col-actions {
  text-align: right;
  white-space: nowrap;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
  margin-left: 2px;
}

.action-icon:hover {
  background: #e9f1fc;
  color: var(--techblue);
}

.watch-icon:hover {
  background: #e6f4ec;
  color: #2f8f6f;
}

.remove-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
}

.remove-icon:hover {
  background: #fbe9e7;
  color: #a13f2e;
}

.empty {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  border: 2px dashed var(--edge);
  border-radius: 4px;
}

/* ---- Section title (edit page: "Seasons") ---- */

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
}

/* ---- Season rows (edit page) ---- */

.season-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.season-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
  padding: 8px 8px;
  border: 2px solid var(--edge);
  border-radius: 8px;
  background: var(--bg);
}

.season-row.season-add {
  margin-top: 4px;
  background: var(--panel);
  border-style: dashed;
}

.season-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.season-input {
  width: 116px;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 9px;
  font-family: inherit;
  font-size: 0.9rem;
}

.season-input[type="date"] {
  width: 130px;
}

/* ---- Progress pill (used on the Watching table and season headers) ---- */

.progress-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--techblue);
  background: #dce9fa;
  border-radius: 20px;
  padding: 4px 12px;
  white-space: nowrap;
}

.progress-pill-empty {
  color: var(--muted);
  background: var(--bg);
}

.show-body {
  border-top: 2px solid var(--edge);
  padding: 18px 22px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- Seasons (nested inside a show) ---- */

.season-block {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 8px;
  overflow: hidden;
}

.season-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}

.season-summary::-webkit-details-marker {
  display: none;
}

/* ---- Episodes (nested inside a season) ---- */

.episode-list {
  border-top: 2px solid var(--edge);
  display: flex;
  flex-direction: column;
}

.episode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 2px solid var(--edge);
}

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

.episode-row.episode-watched {
  background: #E4F1E9;
}

.episode-toggle-form {
  margin: 0;
}

.episode-check {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 1.15rem;
  color: var(--edge);
  display: flex;
  align-items: center;
}

.episode-watched .episode-check {
  color: #2f8f6f;
}

.episode-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
}

.episode-date-form {
  margin: 0;
}

.episode-delete {
  width: 22px;
  height: 22px;
  font-size: 0.95rem;
}

/* ---- Watched page: expandable per-episode detail row ---- */

tr.has-detail td {
  border-bottom: none;
}

.episode-detail-row td {
  padding: 0;
  border-bottom: 2px solid var(--edge);
  background: var(--bg);
}

.episode-detail-cell {
  padding: 0 !important;
}

.episode-detail {
  padding: 0;
}

.episode-detail-summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 22px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.episode-detail-summary::-webkit-details-marker {
  display: none;
}

.episode-detail .show-body {
  padding: 16px 22px 20px;
}

.chevron-icon {
  font-size: 0.65rem;
  margin-right: 6px;
  color: var(--muted);
  display: inline-block;
  transition: transform 0.15s ease;
}

details[open] > summary .chevron-icon {
  transform: rotate(90deg);
}

/* ---- Streaming service dropdown (Add page) ---- */

#service_select {
    padding: 4px;
    border-radius: 8px;
    color: #64748c;
}
#service_select option:checked {
    background-color: #007bff;
    color: white;
    border-radius: 8px;
}
#service_select option {
    padding: 1px 8px;
}

#service_select::-webkit-scrollbar {
    width: 10px;
}

#service_select::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 8px 8px 8px 8px;
}

#service_select::-webkit-scrollbar-thumb {
    background: #bcbcbc;
    border-radius: 8px 8px 8px 8px;
}

#service_select::-webkit-scrollbar-thumb:hover {
    background: #999;
}
.service-tag-unavailable {
  font-style: italic;
}
/* ---- Poster picker (Add page + "change poster" icon) ---- */

#posterPicker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 10px;
  max-height: 170px;
  overflow-y: auto;
  border: 2px solid var(--edge);
  padding: 2px 2px 2px 2px;
  border-radius: 8px;
}

.poster-option {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--panel);
  transition: border-color 0.15s ease;
}

#posterPicker::-webkit-scrollbar {
  width: 8px;
}

#posterPicker::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 8px;
}

#posterPicker::-webkit-scrollbar-thumb {
  background: var(--edge);
  border-radius: 8px;
}

#posterPicker::-webkit-scrollbar-thumb:hover {
  background: var(blue-dim);
}
.poster-option:hover {
  border-color: var(--blue-dim);
}

.poster-option.selected {
  border-color: var(--techblue);
  box-shadow: 0 0 0 3px rgba(47,95,172,0.12);
}

.poster-option img {
  display: block;
  width: 44px;
  height: 65px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.poster-option span {
  width: 44px;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.65rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.poster-option div {
  font-size: 0.85rem;
  color: var(--text);
}
/* ---- Poster thumbnail / placeholder (Saved, Watching, Watched rows) ---- */

.row-with-poster {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.row-poster-thumb {
  width: 51px;
  height: 75px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.row-poster-placeholder {
  width: 51px;
  height: 75px;
  border-radius: 4px;
  border: 1.5px dashed;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
}

.row-poster-placeholder.movie {
  border-color: var(--movie);
  background: rgba(34, 116, 165, 0.08);
  color: var(--movie);
}

.row-poster-placeholder.show {
  border-color: var(--show);
  background: rgba(235, 156, 10, 0.08);
  color: var(--show);
}
/* ---- Edit page: poster + details layout ---- */

.edit-details {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 20px;
}

.edit-poster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.current-poster {
  width: 90px;
  height: 130px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--edge);
}

.current-poster-placeholder {
  width: 90px;
  height: 130px;
  border: 2px dashed var(--edge);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.edit-fields {
  min-width: 0;
}

.edit-fields .field:last-child {
  margin-bottom: 0;
}

.edit-poster .service-add {
  white-space: nowrap;
}
/* iOS Safari: stop the date box overflowing and being taller than other fields */
.field input[type=date] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
  height: 47px;
}
/* View page */
.view-container {
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 12px;
    padding: 20px;
    max-width: 900px;
    margin: 20px auto;
}
.view-container .backdrop img {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.view-container .header {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 25px;
}
.view-container .poster {
    width: 150px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.view-container .meta h1 {
    margin: 0 0 10px 0;
    font-size: 1.8rem;
    color: var(--text);
}

.view-container .meta p {
    margin: 6px 0;
    color: var(--muted);
}
.view-container h2 {
    margin-top: 30px;
    margin-bottom: 10px;
    font-size: 1.4rem;
    color: var(--text);
}
.view-container .cast ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.view-container .cast li {
    padding: 4px 0;
    color: var(--muted);
}
.view-container .note p {
    white-space: pre-wrap;
    color: var(--text);
    line-height: 1.5;
}
@media (max-width: 600px) {
    .view-container .header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .view-container .poster {
        width: 200px;
    }
}
/* View page: your info + season progress */
.view-container .info {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 10px 16px;
    margin: 0;
}
.view-container .info dt {
    color: var(--muted);
    font-size: 0.85rem;
}
.view-container .info dd {
    margin: 0;
    color: var(--text);
}
.view-container .season-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 2px solid var(--edge);
}
.view-container .season-line:last-child {
    border-bottom: none;
}
/* View page: full-width container */
.wrap .view-container { max-width: none; margin: 0; }

/* Hero: faded backdrop behind the poster */
.view-hero {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 2px solid var(--edge);
  margin-bottom: 20px;
}
.view-hero .hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  opacity: 0.5;
}
.view-hero .hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, var(--panel) 0%, rgba(255,255,255,0.5) 30%, rgba(255,255,255,0) 60%);
}
.view-hero .header { position: relative; margin: 0; padding: 20px; }
.view-hero .meta p { color: var(--text); }

/* Action buttons */
.view-actions { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.view-actions form { margin: 0; }
.view-actions button.save { width: auto; }
.view-actions .cancel-link { margin-left: 0; }

/* Your Info */
.view-container .info { display: grid; grid-template-columns: 130px 1fr; gap: 12px 16px; margin: 0; align-items: center; }
.view-container .info dt { color: var(--muted); font-size: 0.85rem; }
.view-container .info dd { margin: 0; color: var(--text); }
.view-container .service-tag form { margin: 0; display: inline; }
.view-container button.service-remove { background: none; border: none; cursor: pointer; font-family: inherit; }
.view-container .season-progress .season-block { margin-bottom: 10px; }
/* List rows: link to the detail page */
.row-poster-link { display: block; flex-shrink: 0; }
.row-title a { color: inherit; text-decoration: none; }
.row-title a:hover { color: var(--techblue); text-decoration: underline; }
/* TMDB backfill: one match option per row */
.match-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.match-option {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 4px 10px 4px 10px;
  background: var(--bg);
}
.match-option img {
  width: 34px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.match-option span:not(:has(img)) {
  width: 34px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.65rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.match-skip {
  border-style: dashed;
  color: var(--muted);
}
/* Cast: horizontal scrolling photo cards */
.cast-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.cast-card {
  flex: 0 0 130px;
  width: 130px;
}
.cast-card img,
.cast-photo-placeholder {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--edge);
}
.cast-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.6rem;
  background: var(--bg);
}
.cast-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin-top: 8px;
}
.cast-character {
  font-size: 0.82rem;
  color: var(--techblue);
  margin-top: 2px;
}
.cast-episodes {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}
/* Cast: "see more" card */
.cast-more {
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  align-self: flex-start;

}
.cast-more .cast-photo-placeholder {
  background: var(--bg);
  border: 2px dashed var(--edge);
}
.cast-more:hover .cast-photo-placeholder {
  border-color: var(--blue-dim);
}
.cast-more .cast-name {
  margin-top: 16px;
}
button.action-icon {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
/* Season header: mark-watched form, right-aligned */
.season-mark-form {
  margin: 0 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mark-btn {
  background: var(--techblue);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.mark-btn:hover { background: #244d8f; }

.service-tag:not(:has(.service-remove)) {
  padding: 3px 10px;
}

/* Ratings */
.rating-stars {
  color: #e3a008;
  letter-spacing: 2px;
}
.row-rating {
  margin-top: 4px;
  font-size: 0.8rem;
}
/* Your Info + Review side by side */
.info-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.info-columns:not(:has(.review)) {
  grid-template-columns: 1fr;
}
@media (max-width: 700px) {
  .info-columns {
    grid-template-columns: 1fr;
  }
}
/* Season reviews */
.season-review {
  border-top: 2px solid var(--edge);
  padding: 14px 16px;
}
.season-review p {
  margin: 0 0 8px;
}
.season-review .field {
  margin-bottom: 12px;
}
.season-review button.save {
  width: auto;
}
/* Episode air dates: one aligned column on wide screens, tighter on phones */
.episode-row .episode-label { flex: 0 0 40%; }
.episode-row .episode-air {
  flex: 0 0 160px;
  margin-right: auto;
  text-align: left;
  opacity: .65;
  font-size: .85em;
}

@media (max-width: 600px) {
  .episode-row { flex-wrap: wrap; }
  .episode-row .episode-label { flex: 0 0 50%; min-width: 0; overflow-wrap: anywhere; }
  .episode-row .episode-air { flex: 0 0 auto; margin-left: 0; }
}
/* Whole-show "Mark watched" row: right-aligned to match the season rows */
form.season-row:has(> input[value="mark_show_watched"]) {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-right: 17px;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.episode-row:has(+ .episode-overview) {
  border-bottom: none;
}

.episode-row.episode-watched + .episode-overview {
  background: #f2f8f4;
}

.episode-overview {
  font-size: 0.9rem;
  line-height: 1.4;
  opacity: 0.75;
  padding: 10px 12px 10px 36px;
  border-bottom: 2px solid var(--edge);
}

.episode-overview:last-child {
  border-bottom: none;
}

/* Saved list: clickable episodes with a description */
.episode-item {
  border-bottom: 2px solid var(--edge);
}
.episode-item:last-child {
  border-bottom: none;
}
.episode-item .episode-row,
.episode-item .episode-overview {
  border-bottom: none;
}
details.episode-item > summary.episode-row {
  cursor: pointer;
  list-style: none;
}
details.episode-item > summary.episode-row::-webkit-details-marker {
  display: none;
}
tbody tr.group-row td,
tbody tr.group-row:hover td { background: #cfdcf1; font-weight: 600; }
.group-row td:first-child { border-left-color: var(--blue-dim); }.cs-item .cs-label { font-weight: 500; }
.cs-item summary.cs-label { cursor: pointer; }
.cs-item .episode-overview { margin-top: 6px; }
@media (max-width: 640px) {
  .cs-table,
  .cs-table tbody,
  .cs-table tr,
  .cs-table td { display: block; width: 100%; min-width: 0; box-sizing: border-box; white-space: normal; }
  .cs-table { min-width: 0; }
  .cs-table thead { display: none; }
  .cs-table tr:not(.group-row) { padding: 10px 0; border-bottom: 1px solid rgba(128,128,128,.2); }
  .cs-table tr[data-type="movie"] { border-left: 3px solid var(--movie); }
  .cs-table tr[data-type="show"] { border-left: 3px solid var(--show); }
  .cs-table tr:not(.group-row) td { border: 0; padding: 4px 14px; }
  .cs-table .group-row td { padding: 12px 14px; }
  .cs-table .col-date { opacity: .7; font-size: .9em; }
}
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
}
.radio-row label {
  white-space: nowrap; /* stops "TV show" / "Already watched" splitting over two lines */
}
.type-checks {
  display: contents; /* desktop: wrapper has no effect, everything stays on one line */
}
@media (max-width: 600px) {
  .type-checks {
    display: flex;
    flex-basis: 100%; /* phone: checkboxes drop onto their own line */
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
  }
}
.view-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 2px solid #c8d4ea;
    border-radius: 8px;
    color: #34496b;
    font-size: .85rem;
    text-decoration: none;
}
.view-btn:hover {
    background: #eef3fc;
    border-color: #a9bde0;
}
button.view-btn {
    font-family: inherit;
    line-height: 1.5;
    cursor: pointer;
}
.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  font-size: 2rem;
  line-height: 1;
  color: #2a62b5;
  z-index: 100;
}
.back-to-top:hover { opacity: .7; }
html { scroll-behavior: smooth; }
/* Episode run time: its own column, right after the air date */
.episode-row .episode-air:has(+ .episode-runtime) { margin-right: 0; }
.episode-row .episode-runtime {
  flex: 0 0 70px;
  margin-right: auto;
  text-align: left;
  opacity: .65;
  font-size: .85em;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .episode-row .episode-runtime { flex: 0 0 auto; }
  .episode-row .episode-runtime:empty { display: none; }
}
/* ---- Mobile: Saved / Watching / Watched rows stack instead of scrolling ---- */
@media (max-width: 640px) {
  .wrap { padding: 28px 14px 60px; }

  #listTable:not(.cs-table),
  #listTable:not(.cs-table) tbody { display: block; min-width: 0; }
  #listTable:not(.cs-table) thead { display: none; }

  /* each main row becomes a wrapping card; the colour bar moves from the first cell to the row */
  #listTable:not(.cs-table) tbody tr:not(.episode-detail-row) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 14px;
    border-bottom: 2px solid var(--edge);
    border-left: 6px solid var(--edge);
  }
  #listTable:not(.cs-table) tr[data-type="movie"]:not(.episode-detail-row) { border-left-color: var(--movie); }
  #listTable:not(.cs-table) tr[data-type="show"]:not(.episode-detail-row)  { border-left-color: var(--show); }
  #listTable:not(.cs-table) tr.is-shelved[data-type="show"]:not(.episode-detail-row) { border-left-color: var(--show-shelved); }
  #listTable:not(.cs-table) tr.has-detail { border-bottom: none; }

  #listTable:not(.cs-table) tbody tr:not(.episode-detail-row) td {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    min-width: 0;
  }

  /* order: title, then badge + date/progress + actions on one line, then services */
  #listTable:not(.cs-table) td:nth-child(1) { order: 1; flex: 0 0 100%; }
  #listTable:not(.cs-table) td:nth-child(2) { order: 2; }
  #listTable:not(.cs-table) td:nth-child(4) { order: 3; }
  #listTable:not(.cs-table) td:nth-child(5) { order: 4; margin-left: auto; }
  #listTable:not(.cs-table) td:nth-child(3) { order: 5; flex: 0 0 100%; }

  /* the expandable seasons row spans full width */
  #listTable:not(.cs-table) tr.episode-detail-row,
  #listTable:not(.cs-table) tr.episode-detail-row td { display: block; width: 100%; }
  .show-body { padding: 14px; }

  /* bigger tap targets for the action icons */
  .action-icon { width: 36px; height: 36px; font-size: 1.1rem; }

  /* season header: let the mark-watched form drop onto its own line */
  .season-summary { flex-wrap: wrap; }
  .season-mark-form { flex-wrap: wrap; margin-left: 0; width: 100%; }
}
/* iOS: stop zoom on focus, and don't make the whole list one scroll layer */
.filter-bar input[type=text],
.filter-bar input[type=search],
.filter-bar select { font-size: 16px; }

@media (max-width: 640px) {
  .table-wrap { overflow: visible; }
}
html { scroll-behavior: auto; }

/* ---- Mobile list rows: poster on the left, text/pills/services beside it ---- */
@media (max-width: 640px) {
  #listTable:not(.cs-table) tbody tr:not(.episode-detail-row) {
    display: grid;
    grid-template-columns: 51px auto minmax(0, 1fr);
    align-items: start;
    gap: 8px 12px;
  }

  /* unwrap the title cell so the poster and the title text become grid items of the row */
  #listTable:not(.cs-table) tbody tr:not(.episode-detail-row) td.col-title,
  #listTable:not(.cs-table) .row-with-poster { display: contents; }

  #listTable:not(.cs-table) .row-poster-link { grid-column: 1; grid-row: 1 / span 3; }
  #listTable:not(.cs-table) .row-with-poster > div { grid-column: 2 / -1; grid-row: 1; min-width: 0; }

  #listTable:not(.cs-table) td:nth-child(2) { grid-column: 2; grid-row: 2; }        /* Movie / TV Show badge */
  #listTable:not(.cs-table) td:nth-child(4) { grid-column: 3; grid-row: 2; }        /* progress pill / date */
  #listTable:not(.cs-table) td:nth-child(3) { grid-column: 2 / -1; grid-row: 3; }   /* services */
  #listTable:not(.cs-table) td:nth-child(5) { grid-column: 1 / -1; grid-row: 4; margin-left: 0; justify-self: end; } /* actions */

  /* cells with nothing in them (logged out, or no services) shouldn't leave a gap */
  #listTable:not(.cs-table) tbody tr:not(.episode-detail-row) td.col-actions:not(:has(*)),
  #listTable:not(.cs-table) tbody tr:not(.episode-detail-row) td.col-service:not(:has(.service-tag, form)) { display: none; }
}