:root {
  color-scheme: dark;
  --bg: #111827;
  --sidebar: #1f2937;
  --card: #1f2937;
  --raised: #374151;
  --line: #374151;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent-2: #4f46e5;
  --ok: #059669;
  --warn: #d97706;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}
a { color: #a5b4fc; text-decoration: none; }
a:hover { color: #c7d2fe; }
button, .button, input, select, textarea { font: inherit; color: var(--text); }
button, .button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 0.5rem;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--accent-2); }
button.text, button.ghost {
  background: transparent;
  color: var(--muted);
}
button.ghost { border: 1px solid var(--line); }
button.ghost:hover { background: var(--raised); color: var(--text); }

.shell { display: flex; min-height: 100vh; }
.rail {
  width: 16rem;
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid #111827;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: white;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.35rem 0.6rem 1rem;
}
img.mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  display: block;
  object-fit: cover;
}
.login-mark {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 1.05rem;
  display: block;
  margin: 0 0 0.85rem;
}
.rail nav { display: flex; flex-direction: column; gap: 0.2rem; }
.rail nav a {
  color: #d1d5db;
  border-radius: 0.5rem;
  padding: 0.55rem 0.7rem;
}
.rail nav a:hover, .rail nav a.active { background: #374151; color: white; }
.rail nav a.active { color: #c7d2fe; }
.count {
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.75rem;
}
.rail-foot {
  margin-top: auto;
  padding: 0.8rem 0.5rem 0.2rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
}
.rail-foot button { white-space: nowrap; padding: 0.15rem 0.2rem; font-size: 0.85rem; }
.who { color: var(--muted); font-size: 0.9rem; }
.stage { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 2rem; }
.stage h1 { margin: 0 0 0.75rem; font-size: 1.6rem; font-weight: 700; }
.search { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0 0 0.85rem; }
.search form { display: flex; flex: 1; gap: 0.4rem; align-items: center; margin: 0; min-width: min(100%, 18rem); }
.search input {
  width: min(28rem, 100%);
  margin: 0;
  padding: 0.45rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: var(--card);
}
.search a { color: var(--muted); }
.modes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.modes form { margin: 0; }
.modes button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.modes button:hover { background: var(--raised); color: var(--text); }
.modes button.on { background: var(--accent); color: white; border-color: transparent; }
.modes button.on:hover { background: var(--accent-2); color: white; }
.notice {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: min(28rem, calc(100% - 1.5rem));
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: #312e81;
  border-radius: 0.5rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.layout { display: block; }
.filter-drawer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}
.filter-drawer summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 600;
}
.filters { padding: 0 1rem 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.6rem 1rem; }
.filters fieldset { grid-column: 1 / -1; }
.filters fieldset.chips { display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; align-items: center; }
.filters fieldset.chips legend { width: 100%; }
.filters fieldset.chips .meta { width: 100%; margin: 0; }
.genre-chip button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.genre-chip button:hover { background: var(--raised); color: var(--text); }
.genre-chip.in button { background: var(--accent); color: white; border-color: transparent; }
.genre-chip.in button:hover { background: var(--accent-2); color: white; }
.genre-chip.out button {
  color: var(--muted);
  text-decoration: line-through;
  background: transparent;
}
.genre-chip.out button::before { content: "× "; text-decoration: none; display: inline-block; }
.filters label, .stack label, .review-actions label { display: block; margin: 0.35rem 0; color: var(--muted); font-size: 0.85rem; }
.filters input, .filters select, .filters textarea,
.stack input, .stack select, .review-actions input, .review-actions select,
.auth input, .auth select, dialog input, dialog select, dialog textarea {
  width: 100%;
  margin-top: 0.25rem;
  background: #111827;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.45rem 0.55rem;
}
.check { display: flex !important; gap: 0.45rem; align-items: center; color: var(--text); }
.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 0.5rem; margin: 0; }
legend { padding: 0 0.35rem; color: var(--muted); }
.filter-actions, .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.card .actions {
  flex-wrap: nowrap;
  gap: 0.28rem;
  margin-top: 0.4rem;
}
.card .actions form { display: flex; margin: 0; }
.hidden-note {
  margin: 0.28rem 0 0;
  font-size: 0.72rem;
  color: #fbbf24;
}
button.hide[aria-pressed="true"] {
  color: var(--text);
  border-color: #fbbf24;
  background: #3f3a1a;
}
.card .actions button,
.card .actions .badge {
  padding: 0.12rem 0.38rem;
  font-size: 0.7rem;
  line-height: 1.2;
  border-radius: 0.3rem;
  white-space: nowrap;
}
.filter-actions { grid-column: 1 / -1; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.1rem;
}
.card {
  background: transparent;
  border: 0;
}
.poster { position: relative; }
button.poster-open {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
button.poster-open:hover { background: transparent; }
.ribbon { pointer-events: none; }
#detail-dialog {
  width: min(42rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
}
.detail-layout { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; align-items: start; }
#detail-poster { width: 100%; border-radius: 0.6rem; }
#detail-poster[hidden] { display: none; }
#detail-title { margin: 0 0 0.35rem; font-size: 1.25rem; }
#detail-overview { margin: 0.6rem 0; white-space: pre-wrap; }
.guide-rows { list-style: none; padding: 0; margin: 0.55rem 0; display: grid; gap: 0.3rem; }
.guide-rows li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: #111827;
  border-radius: 0.45rem;
  padding: 0.35rem 0.6rem;
}
.guide-rows .level {
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}
.guide-rows .sev-none { background: #064e3b; }
.guide-rows .sev-mild { background: #365314; }
.guide-rows .sev-moderate { background: #78350f; }
.guide-rows .sev-severe { background: #7f1d1d; }
.card img, .poster-blank {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: #030712;
  border-radius: 0.75rem;
  display: block;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.card:hover img { outline: 2px solid #818cf8; }
.ribbon {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
}
.ribbon.ok { background: var(--ok); }
.card-body { padding: 0.55rem 0.15rem 0; }
.card h2, .review h2 { font-size: 0.95rem; margin: 0 0 0.2rem; font-weight: 600; }
.card h2 span, .review h2 span, .meta, .genres, .overview { color: var(--muted); }
.card h2 span { font-weight: 400; }
.genres { font-size: 0.72rem; line-height: 1.3; margin: 0.15rem 0; }
.overview, .why { margin: 0.4rem 0; font-size: 1rem; line-height: 1.45; }
.overview {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #e5e7eb;
}
.why { color: #e0e7ff; }
.facts {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.facts .watched-tag {
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 0 0.28rem;
  font-size: 0.68rem;
  line-height: 1.3;
  color: #e5e7eb;
}
.cert {
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 0 0.28rem;
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--text);
}
.guides { list-style: none; padding: 0; display: flex; gap: 6px; margin: 0.35rem 0; }
.guides li {
  display: block;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  background: none;
}
.guides .sev {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: #fff;
  -webkit-transform: translateZ(0);
}
.guides svg {
  width: 16px;
  height: 16px;
  display: block;
  flex: none;
}
.badge, .unknown-guide {
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.72rem;
  background: var(--raised);
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
#more { height: 2rem; }
.auth.picker { width: min(56rem, 100%); }
.faces { display: flex; flex-wrap: wrap; gap: 1.25rem 1.5rem; justify-content: center; margin: 1.25rem 0; }
button.face {
  background: none;
  border: 0;
  border-radius: 0;
  color: inherit;
  cursor: pointer;
  width: 6.5rem;
  padding: 0;
}
button.face:hover { background: none; }
.face .avatar {
  display: grid;
  place-items: center;
  width: 5.5rem;
  height: 5.5rem;
  margin: 0 auto 0.45rem;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 650;
  color: #fff;
  border: 3px solid transparent;
}
.face.on .avatar { border-color: #fff; }
.avatar.role-adult { background: #7c3aed; }
.avatar.role-teen { background: #d4a017; }
.avatar.role-kid { background: #16a34a; }
.face .name { display: block; text-align: center; font-size: 0.95rem; }
.pin-row { display: grid; justify-items: center; gap: 0.4rem; margin: 0.5rem 0 1rem; }
.pin-row input { width: 8rem; text-align: center; letter-spacing: 0.4em; font-size: 1.3rem; }
.pin-row[hidden] { display: none !important; }
.inactive { display: grid; gap: 0.4rem; margin: 0.8rem 0; }
.inactive[hidden] { display: none !important; }
table.family input[type="email"] { width: 100%; min-width: 9rem; }
.guides .sev-none { background-color: #16a34a; box-shadow: inset 0 0 0 48px #16a34a; }
.guides .sev-mild { background-color: #ca8a04; box-shadow: inset 0 0 0 48px #ca8a04; }
.guides .sev-moderate { background-color: #ea580c; box-shadow: inset 0 0 0 48px #ea580c; }
.guides .sev-severe { background-color: #dc2626; box-shadow: inset 0 0 0 48px #dc2626; }
.unknown-guide { color: var(--muted); display: inline-block; }
.matched { margin-top: 0; }
.empty { color: var(--muted); }
.queue, .wait, .auth {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth { width: min(28rem, 100%); }
.auth h1 { font-size: 1.4rem; }
.wait { max-width: 28rem; margin: 4rem auto; }
.code { font-size: 1.6rem; letter-spacing: 0.04em; }
.table-wrap { overflow-x: auto; }
table.family { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.family th, table.family td { padding: 0.45rem 0.4rem; text-align: left; vertical-align: middle; }
table.family thead th { color: var(--muted); font-size: 0.72rem; font-weight: 600; }
table.family tbody th { font-weight: 600; }
table.family select { width: auto; padding: 0.2rem 0.3rem; font-size: 0.8rem; }
table.family .row-actions { display: flex; gap: 0.35rem; align-items: center; }
tr.role-adult td, tr.role-adult th { background: rgba(99, 102, 241, 0.16); }
tr.role-teen td, tr.role-teen th { background: rgba(217, 119, 6, 0.16); }
tr.role-kid td, tr.role-kid th { background: rgba(22, 163, 74, 0.16); }
tr.role-adult th { box-shadow: inset 3px 0 0 #818cf8; }
tr.role-teen th { box-shadow: inset 3px 0 0 #fbbf24; }
tr.role-kid th { box-shadow: inset 3px 0 0 #4ade80; }
.people { list-style: none; padding: 0; }
.people li, .review {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}
.people form { display: flex; gap: 0.4rem; align-items: center; }
.people form.limits { flex-wrap: wrap; align-items: end; }
.people form.limits label { font-size: 0.75rem; }
.people form.limits select { display: block; width: auto; margin-top: 0.15rem; }
.people select { width: auto; }
.review { align-items: flex-start; flex-wrap: wrap; }
.review-actions { min-width: 16rem; }
dialog {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  width: min(28rem, calc(100% - 2rem));
  padding: 1rem 1.1rem;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
@media (max-width: 800px) {
  .card {
    display: grid;
    grid-template-columns: 7rem 1fr;
    column-gap: 0.75rem;
    align-items: start;
  }
  .card img, .poster-blank { width: 7rem; }
  .detail-layout { grid-template-columns: 1fr; }
  #detail-poster { width: 8rem; }
  .card .actions { flex-wrap: wrap; }
  .guides .sev { width: 40px; height: 40px; border-radius: 8px; }
  .guides svg { width: 22px; height: 22px; }
  .shell { display: block; }
  .rail {
    width: auto;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .stage { padding: 1rem; }
}
