:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1b1f27;
  --text-muted: #6b7280;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --wanted: #1a7f5a;
  --wanted-bg: #e8f7f0;
  --new-bg: #d7f2e4;
  --unwanted-bg: #eceef1;
  --unwanted-text: #8a8f98;
  --danger: #d64545;
  --star: #e6a400;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 20, 30, 0.08), 0 1px 2px rgba(20, 20, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a;
    --surface: #1d1f26;
    --border: #2b2e37;
    --text: #eceef1;
    --text-muted: #9aa0ab;
    --wanted: #4fd39a;
    --wanted-bg: #123528;
    --new-bg: #163f2f;
    --unwanted-bg: #23252c;
    --unwanted-text: #6b7280;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.topbar-nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topbar-nav a { color: var(--text-muted); }
.topbar-nav a.active { color: var(--text); font-weight: 600; }
.inline-form { display: inline; }
.link-button {
  background: none; border: none; color: var(--text-muted); font-size: 14px; padding: 0;
}
.link-button:hover { color: var(--text); text-decoration: underline; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 0 8px;
  font-size: 15px;
}
.month-nav-current { font-weight: 700; font-size: 20px; color: var(--text); }

.show-feed { max-width: 900px; margin: 0 auto; padding: 8px 20px 60px; }

.scrape-status {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: 280px;
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--text-muted);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.scrape-status.is-hiding { opacity: 0; transform: translateY(-8px); }
.scrape-status p { margin: 0 0 8px; color: var(--text); font-weight: 600; }
.scrape-log {
  list-style: none; margin: 0; padding: 0; max-height: 160px; overflow-y: auto;
  display: flex; flex-direction: column-reverse;
}
.scrape-log li { padding: 3px 0; }

@media (max-width: 600px) {
  .scrape-status { top: 10px; right: 10px; left: 10px; width: auto; }
}

.day-heading {
  margin: 28px 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.day-group { display: flex; flex-direction: column; gap: 12px; }

.show-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.show-card__main { flex: 1; min-width: 0; }
.show-card__title { margin: 0 0 4px; font-size: 24px; }
.show-card__title--compact { font-size: 14px; margin-bottom: 0; }

.title-icon-link { display: inline-flex; vertical-align: middle; }
.title-icon-link img { height: 20px; width: auto; border-radius: 3px; }

.show-card__details { margin-top: 6px; }
.show-card__twisty { cursor: pointer; font-size: 12px; color: var(--text-muted); }
.show-card__twisty:hover { color: var(--text); }
.show-card__details[open] .show-card__twisty { margin-bottom: 8px; }
.show-card__icon-links { margin-bottom: 8px; }

.card--new { border-left: 4px solid var(--wanted); background: linear-gradient(to right, var(--new-bg), var(--surface) 12%); }
.card--old { border-left: 4px solid var(--border); }
.card--unwanted { background: var(--unwanted-bg); }
.card--unwanted .show-card__title { color: var(--unwanted-text); }
.card--unwanted .show-card__meta { color: var(--unwanted-text); }

.show-card__meta { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.show-card__genres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.show-card__summary { margin: 0 0 6px; font-size: 14px; color: var(--text); }
.show-card__summary--muted { color: var(--unwanted-text); font-size: 13px; }
.show-card__summary--pending { color: var(--text-muted); font-size: 13px; font-style: italic; }
.show-card__runtime { margin: 0 0 6px; font-size: 12px; color: var(--text-muted); }
.show-card__language { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.show-card__added { margin: 6px 0 0; font-size: 11px; color: var(--text-muted); }

.show-card__actions { display: flex; flex-direction: column; gap: 6px; }

.genre-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px 3px 4px; font-size: 12px; color: var(--text-muted);
}
.genre-icon { display: inline-flex; width: 38px; height: 38px; border-radius: 5px; overflow: hidden; }
.genre-icon img { width: 100%; height: 100%; object-fit: cover; }

.icon-button {
  border: none; background: none; color: var(--text-muted);
  font-size: 14px; line-height: 1; width: 20px; height: 20px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
}
.icon-button:hover { background: var(--border); color: var(--danger); }

.exclusion-value { font-weight: 600; }
.exclusion-value.is-excluded { font-weight: 400; text-decoration: line-through; color: var(--unwanted-text); }
.exclusion-toggle--remove:hover { color: var(--wanted); }

.toggle-button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  width: 30px; height: 30px; border-radius: 8px; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.toggle-button:hover { border-color: var(--accent); }
.toggle-button--starred.is-active { color: var(--star); border-color: var(--star); background: #fff7e0; }
.toggle-button--hidden.is-active { color: var(--danger); border-color: var(--danger); }

.badge { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.badge-indexed { background: var(--wanted-bg); color: var(--wanted); }
.badge-new { background: var(--accent); color: var(--accent-contrast); font-weight: 700; vertical-align: middle; }
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 8px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { opacity: 0.92; text-decoration: none; }
.btn-small { padding: 5px 12px; font-size: 12px; background: var(--accent); color: var(--accent-contrast); }
.show-card__sonarr-inline { font-size: 8px; padding: 2px 6px; vertical-align: middle; margin-left: 4px; }

.empty-state { text-align: center; color: var(--text-muted); padding: 60px 0; }

/* Auth pages */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; max-width: 360px; width: 100%;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-subtitle { color: var(--text-muted); margin: 0 0 20px; }
.auth-switch { margin-top: 18px; font-size: 13px; color: var(--text-muted); text-align: center; }

form label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
form input[type="text"], form input[type="password"] {
  display: block; width: 100%; margin-top: 6px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px;
}
form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fdecec; color: #b42318; }
.alert-success { background: var(--wanted-bg); color: var(--wanted); }

/* Settings page */
.settings-page { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card-subtitle { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.exclusion-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; }
.exclusion-column h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin: 0 0 8px; }
.exclusion-column form.inline-form { display: flex; gap: 6px; margin-bottom: 10px; }
.exclusion-column form.inline-form input[type="text"] { flex: 1; margin: 0; padding: 6px 10px; font-size: 13px; }
.exclusion-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.exclusion-list li { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 4px 8px; border-radius: 6px; background: var(--bg); }
.exclusion-empty { color: var(--text-muted); background: none !important; padding-left: 0 !important; }

@media (max-width: 600px) {
  .show-card { flex-direction: column; }
  .show-card__actions { flex-direction: row; }
  .topbar { flex-direction: column; gap: 8px; align-items: flex-start; }
}
