:root {
  color-scheme: light;
  --ink: #172339;
  --muted: #52627a;
  --line: #dce3ed;
  --accent: #185adb;
  --accent-dark: #1245a8;
  --surface: #f4f7fb;
  --success: #126244;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--accent-dark); text-underline-offset: 0.2em; }
button, input, select, textarea { font: inherit; }
button, select, input[type="search"], input[type="file"], textarea {
  min-height: 44px;
  border: 1px solid #acb9cc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
button { padding: 0.5rem 0.85rem; cursor: pointer; font-size: 0.875rem; font-weight: 600; }
button:hover:enabled { border-color: var(--accent); background: #edf3ff; }
button:disabled { cursor: default; opacity: 0.65; }
input[type="search"], select, textarea { width: 100%; padding: 0.55rem 0.7rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 20px; height: 20px; }
input[type="file"] { max-width: 100%; padding: 0.5rem; }
textarea { resize: vertical; overflow-wrap: anywhere; }
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.4rem; }
:focus-visible { outline: 3px solid #e88c13; outline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4.5vw, 3.25rem); line-height: 1.12; letter-spacing: -0.035em; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; line-height: 1.3; }
p { margin-bottom: 1rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.primary:hover:enabled { color: #fff; background: var(--accent-dark); }
.muted { color: var(--muted); }
.error { color: #9c2020; }
.eyebrow { font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0.055em; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 10; padding: 0.7rem; background: white; }
.skip-link:focus { top: 0.5rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 84px;
  padding: 1rem max(1.25rem, calc((100vw - 1160px) / 2));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--ink); }
.brand > span:last-child { line-height: 1.25; }
.brand strong { display: block; }
.monogram { display: grid; place-items: center; width: 38px; height: 38px; background: var(--ink); color: white; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
nav a { font-size: 0.875rem; padding: 0.55rem 0.35rem; text-decoration: none; }
nav button { background: transparent; border-color: transparent; }
main { max-width: 1160px; margin: 0 auto; padding: 2.2rem 1.25rem 4rem; }
.index-heading { max-width: 760px; padding: 1.5rem 0 1.2rem; }
.index-heading > p:not(.eyebrow) { max-width: 650px; }
.set-picker { max-width: 560px; margin-bottom: 1.75rem; }
.set-picker p { font-size: 0.875rem; color: var(--muted); margin-top: 0.6rem; }
.set-grid { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; gap: 1rem; list-style: none; }
.set-grid > li { min-width: 0; content-visibility: auto; contain-intrinsic-size: auto 160px; }
.set-tile {
  display: flex;
  flex-direction: column;
  min-height: 166px;
  height: 100%;
  border: 1px solid var(--line);
  border-top: 3px solid #a8bad7;
  padding: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
}
.set-tile:hover { border-color: var(--accent); background: #f8faff; }
.set-tile h2 { margin: 0.6rem 0 1rem; font-size: 1.125rem; }
.set-tile > div { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; justify-content: space-between; margin-top: auto; }
.set-tile > div span, .set-tile time { font-size: 0.75rem; color: var(--muted); }
.breadcrumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 1.5rem; }
.set-heading { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start; }
.set-heading > div:first-child { max-width: 750px; }
.set-heading h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
.set-heading .muted { font-size: 0.875rem; }
.set-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.2rem; }
.progress-panel { display: grid; grid-template-columns: 1fr 1fr 1.7fr; gap: 1.5rem; padding: 1.4rem; }
.progress-panel { background: var(--surface); border: 1px solid var(--line); margin: 1rem 0; }
.stat-label { font-size: 0.875rem; color: var(--muted); }
.progress-panel p { margin: 0.3rem 0 0; font-size: 1.25rem; }
.progress-panel p strong { font-size: 2rem; font-weight: 650; }
.progress-meter { align-self: center; }
.progress-meter label { display: flex; justify-content: space-between; gap: 0.5rem; }
progress { display: block; width: 100%; height: 10px; border: 0; border-radius: 0; background: #dae2ee; }
progress::-webkit-progress-bar { background: #dae2ee; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
#save-state { display: block; font-size: 0.75rem; margin-top: 0.55rem; color: var(--muted); }
.variant-note { color: var(--muted); font-size: 0.875rem; margin: 1rem 0 1.8rem; }
.checklist-controls { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.checklist-controls > div:first-child { flex: 1; }
.checklist-controls > div:nth-child(2) { min-width: 190px; }
#visible-count { font-size: 0.875rem; color: var(--muted); margin: 0 0 0.7rem; white-space: nowrap; }
.card-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.card {
  display: grid;
  grid-template-columns: 56px minmax(150px, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 0.6rem;
  border-bottom: 1px solid var(--line);
  content-visibility: auto;
  contain-intrinsic-size: auto 104px;
  scroll-margin-top: 1rem;
}
.card:target { background: #fff5d8; outline: 2px solid #dc991e; }
.card.complete { background: #f2faf6; }
.art { display: block; width: 56px; height: 78px; background: #edf1f6; border-radius: 3px; }
.art img { display: block; object-fit: contain; width: 56px; height: 78px; }
.art-missing { display: grid; place-items: center; text-align: center; font-size: 0.75rem; color: var(--muted); }
.card-info { min-width: 0; }
.card-info h2 { font-size: 1rem; margin: 0.15rem 0; overflow-wrap: anywhere; }
.card-number, .rarity { font-size: 0.75rem; color: var(--muted); }
.rarity { margin: 0; }
.variants { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.variants label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  margin: 0;
  border-radius: 5px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
}
.variants input { margin: 0; flex: 0 0 20px; }
.variants label:has(input:checked) { background: #eaf2ff; border-color: #88a9e9; color: #163f87; }
.quantity { font-size: 0.75rem; }
.shared-view .variants label { cursor: default; }
.share-banner { border: 1px solid #90aee3; background: #edf4ff; padding: 1.2rem; margin-bottom: 1rem; }
.share-banner h2 { font-size: 1.125rem; }
.share-banner button { margin: 0 0.5rem 0.5rem 0; }
.empty-state { padding: 2rem 1rem; text-align: center; background: var(--surface); }
.notice { max-width: 1120px; margin: 1rem auto 0; padding: 1rem; background: #f4f7fc; border: 1px solid var(--line); }
.notice.error { background: #fff4f2; border-color: #d4a69c; }
.site-footer { border-top: 1px solid var(--line); padding: 2rem max(1.25rem, calc((100vw - 1120px) / 2)); }
.site-footer p { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.6rem; }
.footer-links { display: flex; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.footer-links a { font-size: 0.875rem; }
.prose { max-width: 780px; }
.prose h2 { margin: 2rem 0 0.75rem; }
.prose li { margin: 0.6rem 0; }
dialog { width: min(660px, calc(100vw - 2rem)); max-height: 86vh; padding: 1.5rem; border: 1px solid var(--line); }
dialog { border-radius: 8px; color: var(--ink); box-shadow: 0 16px 60px #14234026; }
dialog::backdrop { background: #15243b80; }
.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.dialog-heading h2 { margin: 0; }
dialog textarea { margin-bottom: 1rem; }
.search-results { list-style: none; padding: 0; margin: 0; }
.search-results a { display: block; padding: 0.75rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.search-results span { display: block; font-size: 0.875rem; color: var(--muted); }
#search-status { margin-top: 0.8rem; font-size: 0.875rem; }
.radio { display: flex; gap: 0.6rem; align-items: center; font-weight: 400; margin: 1rem 0; }
#backup-status, #share-status { margin: 1rem 0 0; }
.check-results { padding-left: 1.5rem; }
.check-results li { overflow-wrap: anywhere; }
.check-pass { color: var(--success); }
.check-fail { color: #9c2020; }
#startup-frame { width: 100%; height: 650px; border: 1px solid var(--line); }
.print-note { display: none; }

@media (max-width: 860px) {
  .set-grid { grid-template-columns: repeat(2, 1fr); }
  .set-heading { display: block; }
  .set-actions { margin-bottom: 1.2rem; }
  .card { grid-template-columns: 56px 1fr; gap: 0.7rem; contain-intrinsic-size: auto 158px; }
  .variants { grid-column: 1 / -1; }
  .progress-panel { gap: 1rem; }
}

@media (max-width: 600px) {
  .site-header { align-items: flex-start; flex-direction: column; padding: 0.8rem 1rem 0.4rem; gap: 0.4rem; }
  .brand strong { display: inline; }
  .monogram { width: 30px; height: 30px; font-size: 0.8rem; }
  nav { width: 100%; justify-content: space-between; gap: 0.25rem; }
  nav a, nav button { padding-left: 0.25rem; padding-right: 0.25rem; }
  main { padding: 1.5rem 1rem 2.5rem; }
  .index-heading { padding-top: 0.5rem; }
  .set-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .set-tile { min-height: 130px; }
  .set-grid > li { contain-intrinsic-size: auto 140px; }
  .set-tile h2 { margin: 0.35rem 0 0.7rem; }
  .progress-panel { grid-template-columns: 1fr 1fr; padding: 1rem; }
  .progress-meter { grid-column: 1 / -1; }
  .stat-label { font-size: 0.8rem; }
  .checklist-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .checklist-controls > div:first-child { grid-column: 1 / -1; }
  .checklist-controls > div:nth-child(2) { min-width: 0; }
  #visible-count { text-align: right; }
  .variants { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .variants label { padding: 0.35rem; gap: 0.3rem; font-size: 0.875rem; }
  .variants input { width: 18px; height: 18px; flex-basis: 18px; }
  .variants label { flex-wrap: wrap; }
  .variants .quantity { flex-basis: 100%; padding-left: 1.4rem; }
  .card { padding: 0.8rem 0; }
  dialog { padding: 1rem; }
  .footer-links { flex-direction: column; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  :root { color: #000; font-size: 10pt; }
  body, main { padding: 0; margin: 0; max-width: none; }
  .site-header, .breadcrumbs, .set-actions, .checklist-controls, .site-footer, .notice,
  .skip-link, dialog, .art, #save-state, .variant-note, .share-banner button, noscript { display: none !important; }
  h1, .set-heading h1 { font-size: 19pt; margin-bottom: 4mm; }
  .set-heading .muted { font-size: 9pt; }
  .set-heading .eyebrow { display: none; }
  .progress-panel { display: flex; border: 0; background: none; gap: 12mm; padding: 0; margin: 0 0 4mm; }
  .progress-panel p, .progress-panel p strong { font-size: 11pt; }
  .progress-meter { display: none; }
  .print-note { display: block; font-size: 9pt; }
  .card-list { border: 0; }
  .card {
    display: grid;
    grid-template-columns: 1fr 90mm;
    gap: 3mm;
    padding: 2mm 0;
    break-inside: avoid;
    content-visibility: visible;
    contain: none;
    border-color: #aaa;
    background: none !important;
  }
  .card-info h2 { display: inline; font-size: 9pt; margin-left: 2mm; }
  .card-number { font-size: 8pt; }
  .rarity { font-size: 7.5pt; }
  .variants { grid-column: 2; display: flex; justify-content: flex-end; gap: 3mm; }
  .variants label { min-height: 0; border: 0; padding: 0; font-size: 8pt; color: #000; background: none !important; }
  .variants input { appearance: none; width: 3mm; height: 3mm; flex-basis: 3mm; border: 1px solid #222; }
  .variants input:checked::after { content: "✓"; display: block; font-size: 9pt; line-height: 2.6mm; color: #000; }
  .quantity { font-size: 7.5pt; }
  .share-banner { border: 0; background: none; padding: 0; }
  .share-banner h2, .share-banner p { font-size: 9pt; }
  a { color: #000; text-decoration: none; }
}

@media (forced-colors: active) {
  .card, .set-tile, .variants label { border-color: CanvasText; }
  .monogram { border: 1px solid CanvasText; }
  .variants label:has(input:checked) { border-width: 2px; }
}
