:root {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --sleeve: #eceef2;
  --binder: #2b2f3a;
  --text: #1c1e24;
  --muted: #5d6270;
  --line: #d9dce3;
  --accent: #d8343f;
  --filed: #2f6fdd;
  --owned: #23955a;
  --need: #d98a12;
  --choose: #9097a5;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1d2027;
    --sleeve: #262a33;
    --binder: #0b0c10;
    --text: #e8eaef;
    --muted: #9aa0ad;
    --line: #333845;
    --accent: #f0545e;
    --filed: #5b93f2;
    --owned: #3fbf7a;
    --need: #f0a63a;
    --choose: #757c8b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.15rem; margin-top: 1.6em; }
.muted { color: var(--muted); margin: 0; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: thin; }
.tabs a {
  padding: 6px 10px; border-radius: 999px; text-decoration: none; white-space: nowrap;
  color: var(--muted); font-weight: 500;
}
.tabs a:hover { background: var(--sleeve); color: var(--text); }
.tabs a.active { background: var(--accent); color: #fff; }
.sync-form { margin: 0; }
.sync {
  white-space: nowrap; text-decoration: none; font: inherit; font-weight: 600;
  color: var(--text); background: var(--surface); cursor: pointer;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
}
.sync:hover { border-color: var(--accent); color: var(--accent); }
.banner {
  margin: 0; padding: 8px 16px;
  background: color-mix(in srgb, var(--owned) 15%, var(--surface));
  border-bottom: 1px solid var(--line);
}

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
.hero { margin-bottom: 16px; }
.notice { max-width: 560px; margin: 48px auto; padding: 0 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); }
.stat-note { font-weight: 600; color: var(--owned); }

.binder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.binder-card {
  display: block; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.binder-card:hover { border-color: var(--accent); }
.binder-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chip { font-size: .8rem; color: var(--muted); text-align: right; }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--sleeve); overflow: hidden; margin: 10px 0 8px; }
.bar span { position: absolute; inset: 0 auto 0 0; }
.bar-own { background: var(--owned); }
.bar-filed { background: var(--filed); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: var(--radius); }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 12px; font-size: .88rem; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key::before { content: ""; width: 12px; height: 12px; border-radius: 3px; border: 3px solid var(--status); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; margin-bottom: 14px; }
.pager, .toggle { display: flex; gap: 6px; align-items: center; }
button, select, input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
button { cursor: pointer; min-width: 38px; }
button:disabled { opacity: .4; cursor: default; }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
input[type="number"] { width: 80px; }

.spread {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  background: var(--binder); padding: 14px; border-radius: 14px;
  max-width: 900px; margin: 0 auto;
}
.spread-title { margin: 22px 0 8px; font-size: 1rem; }
.page { background: var(--sleeve); border-radius: 8px; padding: 10px; min-width: 0; }
.page header { font-weight: 700; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.page.cover {
  display: grid; place-items: center; min-height: 240px;
  background: repeating-linear-gradient(135deg, var(--binder) 0 12px, color-mix(in srgb, var(--binder) 80%, #fff) 12px 24px);
  color: #c9ccd4; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.pocket {
  --status: var(--choose);
  margin: 0; min-width: 0;
  background: var(--surface);
  border: 3px solid var(--status); border-radius: 8px;
  display: flex; flex-direction: column;
}
.status-filed { --status: var(--filed); }
.status-owned { --status: var(--owned); }
.status-need { --status: var(--need); }
.status-choose { --status: var(--choose); }
.status-empty { --status: var(--line); }
.pocket.status-empty { border-style: dashed; background: transparent; }
.art { aspect-ratio: 63 / 88; display: grid; place-items: center; overflow: hidden; border-radius: 5px 5px 0 0; }
.art img { width: 100%; height: 100%; object-fit: contain; }
.no-art { color: var(--muted); font-size: .8rem; padding: 6px; text-align: center; }
figcaption { padding: 4px 6px 6px; font-size: .78rem; line-height: 1.25; display: flex; flex-wrap: wrap; gap: 0 5px; }
.pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.form { color: var(--muted); width: 100%; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .tabs { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  .spread { grid-template-columns: 1fr; padding: 8px; gap: 8px; }
  .page.cover { min-height: 60px; }
  .grid { gap: 5px; }
  figcaption { font-size: .72rem; }
}
