:root {
  --bg: #0f1115;
  --surface: #181b22;
  --line: #262a33;
  --text: #e9ecf1;
  --muted: #949cad;
  --accent: #4f8cff;
  --ok: #3fbf7f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

h1 {
  font-size: 1.25rem;
  margin: 0;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.status {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#refresh {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  flex: none;
}

.banner {
  background: #3a2c12;
  border-bottom: 1px solid #5a4520;
  color: #f0d9a8;
  padding: 10px 16px;
  font-size: 0.85rem;
}

.filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}

.filters button {
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.filters button.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 32px;
}

.card {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.card.is-watched {
  opacity: 0.55;
}

.poster {
  width: 96px;
  height: 144px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: #23272f;
}

.poster.placeholder {
  display: block;
}

.body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.body h2 {
  font-size: 1rem;
  margin: 0;
  line-height: 1.3;
}

.meta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.providers {
  color: var(--ok);
}

.providers.none {
  color: var(--muted);
  font-style: italic;
}

.toggle {
  margin-top: auto;
  align-self: flex-start;
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* Offline toggles stay tappable so the handler can explain itself. They only
   need to *look* unavailable. */
.toggle.unavailable {
  opacity: 0.45;
  border-style: dashed;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 10px;
  background: #2b2f3a;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.88rem;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.card.is-watched .toggle {
  border-color: var(--ok);
  color: var(--ok);
}

.empty,
.error {
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: #ff8f8f;
}

/* Set by the inline head script when a token is already stored, so the login
   form never flashes before app.js swaps the panes. app.js clears the class
   whenever it sends you back to the gate. */
.has-token #gate {
  display: none;
}

.gate {
  max-width: 380px;
  margin: 15vh auto;
  padding: 0 20px;
  text-align: center;
}

.gate p {
  color: var(--muted);
  font-size: 0.9rem;
}

.gate form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.gate input {
  font: inherit;
  padding: 12px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

@media (min-width: 620px) {
  main {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
  .poster {
    width: 110px;
    height: 165px;
  }
}
