:root {
  --bg: #14171c;
  --panel: #1c2128;
  --fg: #e6e8eb;
  --muted: #8b949e;
  --accent: #4c9aff;
  --error: #f47174;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid #2a3038;
}
.brand { font-weight: 700; color: var(--fg); text-decoration: none; letter-spacing: 0.02em; }
.user { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); }

main { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.empty { color: var(--muted); padding: 2rem 0; }

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.9rem;
}
button:disabled { background: #39414b; cursor: not-allowed; }

/* login */
.login-card {
  max-width: 360px;
  margin: 4rem auto;
  background: var(--panel);
  padding: 2rem;
  border-radius: 10px;
}
.login-card h1 { margin-top: 0; }
.login-card label { display: block; margin: 0.75rem 0; }
.login-card input {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  background: #0f1216;
  border: 1px solid #2a3038;
  border-radius: 6px;
  color: var(--fg);
}
.login-card button { width: 100%; margin-top: 0.5rem; padding: 0.6rem; }

/* type tabs (Movies / TV Shows) */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 1.5rem 0 0;
  border-bottom: 1px solid #2a3038;
}
.tab {
  background: none;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
  padding: 0.5rem 0.9rem;
  font-size: 1rem;
  font-weight: 600;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab-count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }

/* list controls (search / filter / sort) */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1.25rem 0;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid #2a3038;
  border-radius: 8px;
}
.controls input[type="search"],
.controls select {
  background: #0f1216;
  border: 1px solid #2a3038;
  border-radius: 6px;
  color: var(--fg);
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}
.controls input[type="search"] { flex: 1 1 12rem; min-width: 10rem; }
.controls .group-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.controls .result-count { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.controls #reset { margin-left: 0.25rem; }

/* list */
.intro h1 { margin-bottom: 0.25rem; }
.genre { margin-top: 2rem; }
.genre > summary {
  border-bottom: 1px solid #2a3038;
  padding-bottom: 0.35rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: 700;
  list-style: none;
}
.genre > summary::-webkit-details-marker { display: none; }
.genre > summary::before {
  content: "\25B8"; /* ▸ */
  display: inline-block;
  width: 1em;
  color: var(--muted);
  font-size: 0.8em;
  transition: transform 0.12s ease;
}
.genre[open] > summary::before { transform: rotate(90deg); }
.genre .count { color: var(--muted); font-weight: 400; font-size: 0.9rem; }
.items { list-style: none; padding: 0; }
.items li {
  display: flex;
  gap: 0.85rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #21262d;
}
/* The list-filtering JS hides rows via the `hidden` attribute, but `.items li`
   above sets `display`, which overrides the UA `[hidden] { display: none }`.
   Re-assert it (higher specificity, so no !important needed) or filtered-out
   rows — type tab, search, genre, size, recency — stay visible. */
.items li[hidden] { display: none; }
.poster {
  flex: 0 0 60px;
  width: 60px;
  height: 90px;
  border-radius: 4px;
  background: #0f1216 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%238b949e' stroke-width='1.5'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E") center / 24px no-repeat;
  overflow: hidden;
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-body { flex: 1 1 auto; min-width: 0; }
.item-main { display: flex; align-items: baseline; gap: 0.5rem; }
.name { font-weight: 600; }
.year { color: var(--muted); }
.lastwatched { margin-left: auto; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.size { margin-left: 1rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.type-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.02rem 0.4rem;
}
.versions { margin-left: 1rem; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.overview {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.35rem 0;
  /* Clamp to a few lines by default; the more/less toggle lifts the clamp. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.overview.expanded { -webkit-line-clamp: unset; overflow: visible; }
.more-toggle {
  background: none;
  color: var(--accent);
  border: 0;
  padding: 0;
  font-size: 0.85rem;
  cursor: pointer;
}
.more-toggle:hover { text-decoration: underline; }
.keep-row { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.35rem; }
.kept-badge {
  color: #56d364;
  font-size: 0.85rem;
  background: rgba(86, 211, 100, 0.12);
  border: 1px solid rgba(86, 211, 100, 0.3);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
}

/* nav */
.nav { color: var(--accent); text-decoration: none; }
.nav:hover { text-decoration: underline; }

/* admin table */
table.keeps { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table.keeps th, table.keeps td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #21262d;
  vertical-align: top;
}
table.keeps th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
table.keeps .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
