/* Plex-inspired dark theme */
:root {
  --bg: #1a1a1a;
  --surface: #262626;
  --surface-hover: #303030;
  --border: #3a3a3a;
  --text: #eeeeee;
  --text-muted: #999999;
  --accent: #e5a00d;         /* Plex gold */
  --accent-text: #1a1a1a;
  --ok: #27a557;             /* "in library" green */
  --radius: 8px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- header ---- */
.topbar {
  background: #121212;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 7px; }
.brand h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: .3px; }
.brand h1 span { color: var(--accent); }
.meta { color: var(--text-muted); font-size: .8rem; text-align: right; }

/* ---- filter bar ---- */
.filters { background: var(--bg); }
.filters-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.search {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: .85rem;
  width: 220px;
}
.search:focus { outline: none; border-color: var(--accent); }

/* ---- content ---- */
main { max-width: 960px; margin: 0 auto; padding: 10px 20px 40px; }

.status { color: var(--text-muted); text-align: center; padding: 60px 0; }
.status.error { color: #e0654f; }

.day-header {
  margin: 28px 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.day-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.day-date {
  margin-top: 2px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  min-height: .72rem;   /* keep header height stable when Later has no range yet */
}

.quiet {
  color: var(--text-muted);
  font-size: .85rem;
  padding: 6px 0 2px;
}

.episode {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
.episode:hover { background: var(--surface-hover); }

/* Episode still (fallback: show poster), Plex-style 16:9 thumbnail. The
   chevron placeholder shows until/unless TVmaze has an image. */
.ep-thumb {
  flex: 0 0 132px;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  overflow: hidden;
  background: #141414 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M35 20h18l22 30-22 30H35l22-30z' fill='%23333'/%3E%3C/svg%3E") center / 34px no-repeat;
}
.ep-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ep-code {
  color: var(--accent);
  font-weight: 700;
  font-size: .82rem;
  white-space: nowrap;
}

.ep-main { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }
.ep-show { font-weight: 700; }
.ep-show .year { color: var(--text-muted); font-weight: 400; font-size: .85em; }
.ep-title { color: var(--text-muted); font-size: .9rem; margin-top: 1px; }
.ep-summary {
  color: var(--text-muted);
  font-size: .8rem;
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ep-side {
  flex: 0 0 auto;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.ep-date { color: var(--accent); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; white-space: nowrap; }
.ep-time { font-size: .85rem; white-space: nowrap; }
.ep-time.tba { color: var(--text-muted); font-size: .75rem; font-style: italic; }
.ep-runtime { color: var(--text-muted); font-size: .75rem; }

.badges { display: flex; gap: 6px; }
.badge {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge.library { background: var(--ok); color: #fff; }
.badge.new { border: 1px solid var(--accent); color: var(--accent); }
.badge.aired { border: 1px solid var(--border); color: var(--text-muted); }

.footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 30px;
  color: var(--text-muted);
  font-size: .75rem;
}

@media (max-width: 600px) {
  .ep-summary { display: none; }
  .meta { display: none; }
  .search { width: 100%; }
  .ep-thumb { flex-basis: 96px; }
  /* Side column squeezes the text into a sliver on phones — wrap it onto its
     own row under the thumbnail + title instead. */
  .episode { flex-wrap: wrap; }
  .ep-side {
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
}
