:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #eeedf5;
  --border: #dddbe8;
  --text: #1d1b2b;
  --muted: #6b6880;
  --accent: #7c5cff;
  --accent-text: #ffffff;
  --pos: #22a06b;
  --neg: #e5484d;
  --mal: #2e51a2;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(20 16 50 / 6%), 0 4px 16px rgb(20 16 50 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12111a;
    --surface: #1b1a26;
    --surface-2: #252433;
    --border: #33314a;
    --text: #ecebf5;
    --muted: #9b98b3;
    --accent: #9d85ff;
    --accent-text: #120d2e;
    --pos: #3ccf8e;
    --neg: #ff6b70;
    --mal: #7f9cff;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
code { background: var(--surface-2); padding: .1em .4em; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
section { margin-bottom: 32px; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 32px; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand img { width: 26px; height: 26px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.search { flex: 1; max-width: 360px; margin-left: auto; }
.search input { width: 100%; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px;
  display: flex; flex-direction: column; gap: 2px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu-body strong { padding: 4px 8px 8px; }
.menu-body a, .menu-body .linklike { padding: 6px 8px; border-radius: 6px; color: var(--text); text-align: left; }
.menu-body a:hover, .menu-body .linklike:hover { background: var(--surface-2); text-decoration: none; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .search { order: 2; max-width: none; }
}

/* --- controls --- */
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="color"] { padding: 2px; width: 40px; height: 32px; }
.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--accent-text); background: var(--accent);
  border: 0; border-radius: 8px; padding: 8px 16px;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.small { padding: 5px 12px; font-size: .9rem; }
.linklike { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.linklike.danger, .danger { color: var(--neg); }
form.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; background: color-mix(in oklab, var(--pos) 18%, var(--surface)); border: 1px solid color-mix(in oklab, var(--pos) 40%, transparent); }
.flash.error { background: color-mix(in oklab, var(--neg) 15%, var(--surface)); border-color: color-mix(in oklab, var(--neg) 40%, transparent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.narrow { max-width: 460px; margin: 24px auto; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }

/* --- people --- */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c); color: #12111a; font-weight: 700; font-size: .85rem;
}
.avatar.xl { width: 64px; height: 64px; font-size: 1.8rem; }
.member { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.name { color: var(--c); font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; background: var(--c); cursor: pointer; position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch:has(input:checked) { outline: 3px solid var(--text); outline-offset: 2px; }

/* --- anime bits --- */
.poster { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; }
.poster.big { width: 220px; flex: none; box-shadow: var(--shadow); }
.poster.thumb { width: 36px; flex: none; border-radius: 5px; }
.tag { display: inline-block; font-size: .78rem; padding: 2px 8px; margin: 0 4px 4px 0; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag.on { background: color-mix(in oklab, var(--accent) 22%, var(--surface)); color: var(--text); }
.mal-badge { font-weight: 600; color: var(--mal); font-size: .9rem; }
.score-pill { display: inline-block; min-width: 2.4em; text-align: center; padding: 2px 6px; border-radius: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }

.hero { display: flex; gap: 28px; align-items: flex-start; }
.hero-body { flex: 1; min-width: 0; }
.hero h1 { font-size: 2.1rem; }
.hero h1 a { color: var(--text); }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.meta { color: var(--muted); }
.note { font-style: italic; }
@media (max-width: 700px) {
  .hero { flex-direction: column; }
  .poster.big { width: 150px; }
}

.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; min-width: 120px; display: flex; flex-direction: column; }
.stat span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }

/* 1–10 score strip */
.strip { position: relative; height: calc(var(--rows) * 22px + 44px); margin: 18px 10px 8px; }
.strip-track { position: absolute; left: 0; right: 0; bottom: 20px; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--neg), color-mix(in oklab, var(--neg) 40%, var(--pos)) 50%, var(--pos)); opacity: .55; }
.tick { position: absolute; bottom: 0; transform: translateX(-50%); font-size: .72rem; color: var(--muted); }
.marker { position: absolute; top: -14px; bottom: 18px; transform: translateX(-50%); border-left: 2px dashed; font-size: .65rem; font-weight: 700; padding-left: 3px; }
.marker.mal { color: var(--mal); }
.marker.avg { color: var(--text); border-left-style: solid; }
.strip .dot, .duel .dot {
  position: absolute; transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); color: #12111a; border: 2px solid var(--surface);
  display: grid; place-items: center; font-size: .65rem; font-weight: 800;
}
.strip .dot { bottom: calc(26px + var(--stack) * 20px); }

.progress-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.progress-list li { display: flex; align-items: center; gap: 12px; }
.progress-list .member { width: 150px; flex: none; }
.progress-list .muted { flex: 1; }
.progress-list .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-list .bar + .muted { flex: none; width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }
.progress-list .bar i { display: block; height: 100%; background: var(--c); }
.progress-list .quote { padding-left: 40px; font-style: italic; color: var(--muted); }

.quick { margin-top: 12px; }
.quick summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.entry-form, .pick-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 12px; }
.entry-form label, .pick-form label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.entry-form label.wide, .pick-form label.wide { flex: 1 1 240px; }
.entry-form input[type="number"] { width: 5.5em; }
.eps { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.entry-form .actions { display: flex; gap: 8px; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 32px; }
.two-col > section { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.synopsis p { white-space: pre-line; }
.plain { padding-left: 18px; }
.empty { text-align: center; padding: 48px 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.anime-card { padding: 0; overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.anime-card .poster { border-radius: 0; }
.anime-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.anime-card:hover { text-decoration: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

.row-cards { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.mini-card { display: flex; gap: 12px; align-items: center; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-width: 260px; margin-bottom: 8px; }
.mini-card .poster { width: 48px; }
.mini-card div { display: flex; flex-direction: column; }
.mini-card:hover { text-decoration: none; border-color: var(--accent); }

/* --- tables --- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child > * { border-bottom: 0; }
thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.num { text-align: center; font-variant-numeric: tabular-nums; }
.title-cell a { display: flex; align-items: center; gap: 10px; color: var(--text); }
.title-cell span { display: flex; flex-direction: column; }
.title-cell small { color: var(--muted); }
.title-cell .quote { font-style: italic; }
.legend { font-size: .85rem; color: var(--muted); }
.status { font-size: .8rem; font-weight: 600; white-space: nowrap; }
.s-watching { color: var(--pos); }
.s-completed { color: var(--accent); }
.s-dropped { color: var(--neg); }
.s-on_hold { color: #d69e2e; }
.s-plan { color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .linklike { margin-left: 10px; }

.matrix td { text-align: center; min-width: 110px; padding: 0; }
.matrix td a { display: flex; flex-direction: column; padding: 10px; color: var(--text); }
.matrix td a:hover { text-decoration: none; outline: 2px solid var(--accent); outline-offset: -2px; }
.matrix td b { font-size: 1.15rem; }
.matrix td small { color: var(--muted); }
.matrix td.self { background: repeating-linear-gradient(45deg, var(--surface-2) 0 6px, var(--surface) 6px 12px); }
.matrix td.none { color: var(--muted); font-size: .8rem; }
.matrix thead th { text-align: center; }
.matrix thead th .small { display: block; text-transform: none; letter-spacing: 0; }
.genre-table td { min-width: 64px; font-weight: 600; }

.member-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.member-card { border-top: 4px solid var(--c); }
.member-card dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 12px 0; }
.member-card dt { color: var(--muted); }
.member-card dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.split-card { margin-bottom: 12px; padding: 12px 16px 4px; }
.split-card > a { display: flex; align-items: center; gap: 10px; color: var(--text); }

.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; text-align: center; }
.versus > div:first-child, .versus > div:last-child { font-size: 1.3rem; }
.versus .avatar { width: 48px; height: 48px; font-size: 1.3rem; }
.vs-stats { display: flex; flex-direction: column; }
.vs-stats b { font-size: 2.4rem; }
.duel-bar { width: 40%; min-width: 160px; }
.duel { position: relative; height: 22px; margin: 0 11px; }
.duel::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 2px; background: var(--surface-2); }
.duel .seg { position: absolute; top: 9px; height: 4px; left: var(--l); width: var(--w); background: var(--muted); border-radius: 2px; }
.duel .dot { top: 0; width: 16px; height: 16px; margin-top: 3px; }

.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-head h1 { margin: 0; }
.profile-head .stat-row { margin-left: auto; }
.dist { display: flex; gap: 6px; height: 140px; align-items: flex-end; }
.dist-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.dist-col i { display: block; width: 100%; max-width: 48px; background: var(--c); border-radius: 4px 4px 0 0; min-height: 2px; }
.dist-n { font-size: .75rem; color: var(--muted); }
.dist-label { font-size: .8rem; font-weight: 600; margin-top: 4px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 16px 0; }
.tabs a { padding: 5px 12px; border-radius: 99px; color: var(--muted); font-weight: 500; }
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.on { background: var(--accent); color: var(--accent-text); }
.tabs small { opacity: .75; }
.tabs .spacer { flex: 1; }
.tabs.compact { margin: 0; }

.activity { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.activity li { display: flex; align-items: center; gap: 10px; }
.activity li > span:nth-child(2) { flex: 1; }

/* --- browse filters --- */
.filters { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin-bottom: 16px; }
.filters > label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.filters input[type="number"] { width: 6.5em; }
.filters .pair { display: flex; gap: 6px; }
.filters .checks { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.filters .check { display: flex; align-items: center; gap: 6px; }
.filters .chips { flex: 1 1 100%; border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.filters .chips legend, .filters details.chips summary { font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.filters details.chips { display: block; }
.filters details.chips summary { cursor: pointer; }
.filters details.chips[open] summary { margin-bottom: 8px; }
.filters details.chips .chip-check { margin: 0 6px 6px 0; }
.chip-check { display: inline-block; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: .85rem; }
.chip-check span small { color: var(--muted); margin-left: 2px; }
.chip-check input:checked + span { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip-check input:checked + span small { color: inherit; opacity: .8; }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-actions { display: flex; gap: 14px; align-items: center; }
.more { text-align: center; margin-top: 20px; }

/* --- streaming links --- */
.streams { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.stream {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 99px;
  color: var(--text); font-weight: 600; font-size: .9rem;
  background: color-mix(in oklab, var(--c) 16%, var(--surface)); border: 1px solid color-mix(in oklab, var(--c) 45%, transparent);
}
.stream:not(:has(img)) { padding-left: 12px; }
.stream:hover { text-decoration: none; background: color-mix(in oklab, var(--c) 28%, var(--surface)); }
.stream img { width: 22px; height: 22px; border-radius: 5px; background: var(--c); padding: 3px; }
.stream small { color: var(--muted); font-weight: 400; }
.chip-scroll { max-height: 7.6rem; overflow-y: auto; padding-right: 4px; }

/* --- browse toolbar & collapsible filters --- */
.browse-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; margin-bottom: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.toolbar .pair { display: flex; gap: 6px; }
.filter-panel { align-self: flex-end; }
.filter-panel[open] { flex: 1 1 100%; }
.filter-panel > summary { list-style: none; cursor: pointer; display: inline-block; }
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary::after { content: " ▾"; }
.filter-panel[open] > summary::after { content: " ▴"; }
.filter-panel .count { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; margin-left: 4px; border-radius: 99px; background: var(--accent); color: var(--accent-text); font-size: .75rem; }
.filter-panel > .filters { margin: 10px 0 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; font-size: .85rem; }
.pill { padding: 3px 10px; border-radius: 99px; background: color-mix(in oklab, var(--accent) 20%, var(--surface)); color: var(--text); }
.pill:hover { text-decoration: none; background: color-mix(in oklab, var(--accent) 32%, var(--surface)); }
.filters legend .muted { font-weight: 400; }
