:root {
  --bg: #FFFFFF;
  --ink: #111111;
  --muted: #5E5E5E;
  --line: #E4E4E4;
  --soft: #F4F4F4;
  --accent: #FF4F00;
  --accent-ink: #C23B00;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.4;
}
a { color: var(--ink); }
a:hover { color: var(--accent-ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Text fields already show focus with their underline, and text links get a
   heavier underline instead of a box. */
input:focus-visible { outline: none; }
.link:focus-visible { outline: none; color: var(--ink); text-decoration-thickness: 2px; }

.wrap { max-width: 1360px; margin: 0 auto; padding: 0 48px; }
.home.owner .wrap { max-width: 1530px; }
.home.public .wrap { max-width: 1040px; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; padding-top: 32px; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; text-decoration: none; }
.logo span { color: var(--accent); }
.top-right { display: flex; align-items: flex-end; gap: 24px; flex: 0 1 520px; justify-content: flex-end; }
.link { background: none; border: 0; padding: 0; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }

.search { position: relative; flex: 1 1 auto; max-width: 420px; }
.search label { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid var(--ink); height: 44px; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.results {
  position: absolute; z-index: 10; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg); border: 2px solid var(--ink); max-height: 70vh; overflow-y: auto;
}
.result { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: center; padding: 10px 14px; text-decoration: none; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }
.result:hover, .result:focus-visible { background: var(--soft); color: var(--ink); outline: none; }
.result strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result span { font-size: 13px; color: var(--muted); }
.results .empty { padding: 14px; color: var(--muted); font-size: 14px; }

.poster { width: 40px; height: 60px; object-fit: cover; background: var(--soft); }

/* Counts */
.counts { display: grid; grid-template-columns: repeat(4, minmax(0, 200px)); gap: 24px 48px; padding-top: 48px; padding-bottom: 56px; }
.count { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px 0; text-decoration: none; }
.count b { font-size: 96px; font-weight: 800; letter-spacing: -4px; line-height: 0.9; }
.count span { font-size: 14px; font-weight: 500; color: var(--muted); }
.count:first-child b { color: var(--accent); }

/* Main layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 56px; align-items: start; padding-top: 24px; padding-bottom: 96px; }
.lists { min-width: 0; display: flex; flex-direction: column; gap: 56px; }
.side { min-width: 0; display: flex; flex-direction: column; }
.block { display: flex; flex-direction: column; gap: 32px; }
/* A heavy rule and open space set Upcoming apart from Catch up. */
.block + .block { margin-top: 72px; padding-top: 32px; border-top: 8px solid var(--ink); }
@media (min-width: 1200px) {
  .owner .layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 31%); gap: 72px; }
}

/* Catch up */
.catch-list { display: flex; flex-direction: column; max-height: 624px; overflow-y: auto; overscroll-behavior: contain; }
.catch { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 14px; align-items: center; width: 100%; min-height: 52px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.catch:hover { background: var(--soft); }
.catch[aria-pressed='true'] .box { background: var(--accent); border-color: var(--accent); }
.catch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.catch .what { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-line { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catch-list .none { border-bottom: 0; }

.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.head h2 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.8px; }
.head span { font-size: 14px; font-weight: 600; color: var(--muted); }

.table { overflow-x: auto; }
.table-inner { min-width: 560px; }
/* Title gets a bounded share and the rest goes between years and rating;
   episodes is exactly as wide as its bar, so the row ends at the list's edge. */
.row { display: grid; grid-template-columns: 40px minmax(0, 1.6fr) minmax(112px, 1fr) minmax(112px, 1fr) 128px; gap: 18px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row.labels { padding: 12px 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
.row[data-href] { cursor: pointer; }
.row[data-href]:hover { background: var(--soft); }
.row .title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.row .rate-input .stars { font-size: 17px; }
.row .rate-input .hit button { min-height: 32px; }
.row .years { font-size: 15px; color: var(--muted); }
.eps { display: flex; flex-direction: column; gap: 6px; max-width: 128px; font-size: 14px; font-weight: 500; }
.bar { height: 3px; background: var(--line); }
.bar i { display: block; height: 3px; background: var(--ink); }
.bar.on i { background: var(--accent); }
.none { padding: 18px 0; color: var(--muted); font-size: 15px; border-bottom: 1px solid var(--line); }

/* Stars: grey row with a black row clipped on top */
.stars { position: relative; display: inline-block; font-size: 15px; letter-spacing: 0; line-height: 1; color: #CFCFCF; white-space: nowrap; }
.stars::before { content: '\2605\2605\2605\2605\2605'; }
.stars i { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--ink); font-style: normal; }
.stars i::before { content: '\2605\2605\2605\2605\2605'; }

/* Upcoming */
.week { display: flex; flex-direction: column; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8px; }
.week-head b { font-size: 15px; font-weight: 800; }
.week-head span { font-size: 13px; color: var(--muted); }
.up { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; }
.up .when { font-size: 13px; font-weight: 600; color: var(--muted); }
.up .when small { display: block; font-weight: 500; font-size: 12px; }
.up .what { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up .code { font-size: 13px; font-weight: 600; }
.week .none { border-top: 1px solid var(--line); border-bottom: 0; padding: 12px 0; font-size: 14px; }

/* Show page */
.back { display: inline-block; margin-top: 40px; font-size: 14px; font-weight: 600; color: var(--muted); }
.show { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; padding-top: 28px; padding-bottom: 48px; border-bottom: 1px solid var(--line); }
.show .art { width: 240px; aspect-ratio: 2 / 3; object-fit: cover; background: var(--soft); }
.show h1 { margin: 0; font-size: 56px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.meta { margin-top: 12px; font-size: 16px; color: var(--muted); }
.controls { display: flex; flex-direction: column; gap: 28px; margin-top: 36px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px; }
.seg { display: flex; flex-wrap: wrap; border: 2px solid var(--ink); width: fit-content; max-width: 100%; }
.seg button { border: 0; border-right: 2px solid var(--ink); background: var(--bg); padding: 0 20px; min-height: 48px; font-size: 15px; font-weight: 600; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--soft); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--bg); }
.seg button[aria-pressed='true']:first-child { background: var(--accent); color: var(--ink); }

.rate { display: flex; align-items: center; gap: 16px; }
.rate-input { position: relative; display: inline-flex; }
.rate-input .stars { font-size: 34px; }
.rate-input .hit { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(10, 1fr); }
.rate-input .hit button { border: 0; background: transparent; padding: 0; min-height: 44px; }
.rate-value { font-size: 15px; font-weight: 600; }

.progress { display: flex; align-items: baseline; gap: 12px; }
.progress b { font-size: 40px; font-weight: 800; letter-spacing: -1.5px; line-height: 1; }
.progress span { color: var(--muted); font-size: 15px; }

.seasons { display: flex; flex-direction: column; gap: 48px; padding-top: 48px; padding-bottom: 96px; }
.season-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 20px; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.season-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.6px; }
.season-head span { font-size: 14px; font-weight: 600; color: var(--muted); }
.season-head .link { margin-left: auto; }
.ep {
  display: grid; grid-template-columns: 24px 56px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  width: 100%; min-height: 52px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
}
.ep:hover:not(:disabled) { background: var(--soft); }
.ep:disabled { cursor: default; color: var(--muted); }
.box { width: 20px; height: 20px; border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.ep[aria-pressed='true'] .box { background: var(--accent); border-color: var(--accent); }
.ep:disabled .box { border-color: var(--line); }
.ep .code { font-size: 14px; font-weight: 700; }
.ep .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep .date { font-size: 14px; color: var(--muted); }
.ep[aria-pressed='true'] .name { color: var(--muted); }
.readonly .ep { cursor: default; }

/* Sign in */
dialog { border: 2px solid var(--ink); padding: 32px; width: min(400px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(17, 17, 17, 0.4); }
dialog h2 { margin: 0 0 20px; font-size: 24px; font-weight: 800; }
dialog input { width: 100%; height: 48px; border: 0; border-bottom: 2px solid var(--ink); outline: none; font-size: 16px; }
dialog .actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }
.btn { background: var(--ink); color: var(--bg); border: 0; min-height: 48px; padding: 0 24px; font-weight: 600; }
.btn:hover { background: #333333; }
.error { color: var(--accent-ink); font-size: 14px; min-height: 20px; margin-top: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 12px 18px; font-size: 14px; font-weight: 500; max-width: calc(100vw - 32px);
}

@media (max-width: 1040px) {
  .counts { gap: 24px 32px; }
  .count b { font-size: 72px; letter-spacing: -3px; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .top { padding-top: 20px; }
  .top-right { flex: 1 1 100%; }
  .search { max-width: none; }
  .counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 32px; padding-bottom: 32px; gap: 16px 0; }
  .count b { font-size: 64px; letter-spacing: -3px; }
  .block + .block { margin-top: 56px; }
  .layout { gap: 48px; padding-top: 32px; }
  .show { grid-template-columns: 1fr; gap: 24px; }
  .show .art { width: 160px; }
  .show h1 { font-size: 40px; letter-spacing: -1.4px; }
  .ep { grid-template-columns: 24px 44px minmax(0, 1fr); }
  .table-inner { min-width: 0; }
  .row.labels { display: none; }
  .row { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: 'poster title rating' 'poster years eps'; gap: 4px 14px; }
  .row .poster { grid-area: poster; }
  .row .title { grid-area: title; font-size: 16px; }
  .row .years { grid-area: years; font-size: 13px; }
  .row .rating { grid-area: rating; justify-self: end; }
  .row .eps { grid-area: eps; justify-self: end; width: 84px; font-size: 13px; gap: 4px; }
  .ep .date { grid-column: 3; margin-top: -8px; font-size: 13px; }
}

/* Import notice */
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-top: 32px; padding: 16px 20px; border: 2px solid var(--ink); font-size: 15px; }
.notice-list { flex-direction: column; align-items: flex-start; }
.notice ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.notice summary { cursor: pointer; }
.notice details ul { margin-top: 12px; }
