/* Mobile first. Colours are tokens so dark mode is one override. */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #e2e0db;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --accent-soft: #fde8dc;
  --paid: #92400e;
  --paid-bg: #fef3c7;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 12px;
  --tabs-h: 60px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1c1c1f;
    --text: #ececef;
    --muted: #9a9aa2;
    --line: #2e2e33;
    --accent: #fb923c;
    --accent-text: #1a0d05;
    --accent-soft: #3a2316;
    --paid: #fcd34d;
    --paid-bg: #3a2f10;
    --danger: #f87171;
    --ok: #4ade80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h3 { margin: 0; font-size: 1rem; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
code { background: var(--line); padding: 0 .3em; border-radius: 4px; }

/* Top bar */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 720px; margin: 0 auto; padding: 12px 16px 4px;
}
.brand { font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--text); letter-spacing: .02em; }
.top-links { display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.top-links a { color: var(--muted); text-decoration: none; }
.top-links a[aria-current] { color: var(--text); }
.top-links form { margin: 0; }

/* Bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .7rem; color: var(--muted); text-decoration: none;
}
.tabs a[aria-current] { color: var(--accent); font-weight: 600; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fab {
  position: fixed; right: 16px; z-index: 11;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-text);
  font-size: 2rem; line-height: 1; text-decoration: none;
  box-shadow: 0 4px 14px rgb(0 0 0 / .25);
}

/* Buttons and forms */
button, .button {
  font: inherit; font-size: .9rem; cursor: pointer;
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.big { width: 100%; min-height: 48px; font-size: 1rem; }
button.quiet { border-color: transparent; color: var(--muted); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--muted); font-size: .9rem; }
input, select, textarea {
  font: inherit; font-size: 16px; /* stops iOS zooming */
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; }
label { display: block; font-size: .9rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: end; }
.row > * { flex: 1; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
label.check { display: flex; gap: 10px; align-items: center; padding: 10px 0; color: var(--text); font-size: 1rem; border-bottom: 1px solid var(--line); }
label.check input { width: 20px; height: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; }
.chip span {
  display: inline-block; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: .95rem;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
details > summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
details[open] > summary { margin-bottom: 8px; }
details > label { margin-bottom: 12px; }
.filters { display: flex; gap: 8px; margin-bottom: 8px; }
.filters label { flex: 1; }
.filters select { padding: 8px 10px; }

/* Messages */
.error { color: var(--danger); }
#errors:not(:empty) {
  position: sticky; top: 0; z-index: 20;
  max-width: 720px; margin: 0 auto; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--danger);
}
#errors .error { margin: 0; }
.saved { color: var(--ok); }
.empty { text-align: center; padding: 3rem 0; }

/* Cards */
.card {
  display: flex; gap: 12px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 10px;
}
.card .body { flex: 1; min-width: 0; }
.card h3 a { color: var(--text); text-decoration: none; }
.sn { color: var(--muted); font-weight: 500; }
.poster { flex: none; }
.poster img, .noposter {
  display: block; width: 56px; height: 84px; border-radius: 6px; object-fit: cover; background: var(--line);
}
.noposter { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); font-size: 1.4rem; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0; font-size: .85rem; color: var(--muted); }
.svc { font-weight: 600; color: var(--text); }
.svc.paid { color: var(--paid); background: var(--paid-bg); padding: 0 6px; border-radius: 4px; }
.rt { white-space: nowrap; }
.status { font-weight: 600; color: var(--accent); }
.progress { margin: 2px 0; font-size: .9rem; }
.progress:empty { display: none; }
.note {
  margin: 4px 0; font-size: .85rem; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tags { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: .75rem; color: var(--muted); }
.moved { margin: 4px 0; font-size: .85rem; color: var(--ok); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.actions .ask { width: 100%; font-size: .9rem; }
.card.htmx-request { opacity: .6; }

/* Season page: the card's poster and title repeat the header, so hide them. */
.season-card .poster, .season-card h3, .season-card .meta, .season-card .progress { display: none; }
.season-card .card { padding: 0 0 4px; border: 0; background: none; }

/* Schedule */
.schedule { list-style: none; margin: 0 0 8px; padding: 0; }
.schedule li {
  display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 6px;
}
.schedule a { color: var(--text); font-weight: 600; text-decoration: none; }
.schedule .ep { color: var(--muted); font-size: .85rem; }
.schedule .svc { margin-left: auto; font-size: .85rem; font-weight: 500; color: var(--muted); }
.badge { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
h3.day { font-size: .95rem; margin: 12px 0 6px; }

/* Search */
.search { margin-bottom: 12px; }
.search input { font-size: 1.1rem; padding: 12px 14px; }
.results { list-style: none; padding: 0; margin: 0; }
.results a {
  display: flex; gap: 12px; align-items: center; padding: 8px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.results img, .results .noposter { width: 46px; height: 69px; border-radius: 4px; object-fit: cover; flex: none; }
.r-body { display: flex; flex-direction: column; }

/* Show header */
.show-head { display: flex; gap: 14px; align-items: flex-start; margin-top: 8px; }
.show-head h1 { margin: 0 0 4px; }
.big-poster { width: 92px; height: 138px; border-radius: 8px; object-fit: cover; flex: none; }
.overview { font-size: .95rem; }
.seasons { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.seasons li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .9rem; }
.seasons li[aria-current] { border-color: var(--accent); }
.episodes { padding-left: 1.6rem; font-size: .9rem; }
.episodes li { padding: 2px 0; }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2rem; }
.danger-zone form { margin: 0; }

/* Services */
.services { list-style: none; padding: 0; margin: 0 0 16px; }
.service { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.service form { margin: 0; }
.toggle.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.add-service { align-items: center; }
.add-service .check { border: 0; flex: none; }
.add-service button { flex: none; }

/* Login */
.login { max-width: 360px; margin: 10vh auto 0; }

@media (min-width: 720px) {
  .tabs { justify-content: center; gap: 24px; }
  .tabs a { flex: none; width: 88px; }
}

/* What's new */
.changes { list-style: none; padding: 0; margin: 0 0 8px; }
.changes li {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; align-items: baseline;
  padding: 10px 12px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.changes li.unseen { border-left: 4px solid var(--accent); }
.changes a { color: var(--text); text-decoration: none; }
.sync-status { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sync-status p { margin: 0; }
.sync-status form { margin: 0; }

/* People */
.fav { color: var(--accent); white-space: nowrap; }
.person-result { display: flex; gap: 12px; align-items: center; padding: 8px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.person-result .r-body { flex: 1; min-width: 0; }
.person { display: flex; gap: 12px; padding: 12px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.person .body { flex: 1; min-width: 0; }
.person h3 { margin-bottom: 2px; }
.person ul { list-style: none; padding: 0; margin: 4px 0; font-size: .9rem; }
.person li { padding: 2px 0; }
.person .remove { margin-top: 6px; }

/* All / TV / Movies switch */
.kinds { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 10px; background: var(--surface); }
.kinds a { padding: 8px 16px; color: var(--text); text-decoration: none; font-size: .9rem; }
.kinds a + a { border-left: 1px solid var(--line); }
.kinds a[aria-current] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head a { font-size: .9rem; }
