/**
 * Binder — MTG Collection
 * Dark, single-theme visual system: near-black stage, condensed display type,
 * thin hairline borders, one accent per state.
 */

:root {
  /* The design is a light one: paper, not a cave. The fire lives in the mark and
     in the cover art, and the interface stays out of their way. */
  --bg: #ffffff;
  --stage-glow: #ffffff;
  --panel: #fbfbfa;
  --panel-2: #f4f4f2;
  --line: #e8e8e5;
  --line-2: #d6d6d2;
  --ink: #1c1c1e;
  --ink-2: #6b6b70;
  --ink-3: #97979d;
  --ink-4: #b8b8bd;

  /* the mark's own fire, used sparingly */
  --ember: #FF3B07;
  --ember-2: #FF5D2D;
  --ember-soft: #FEB6A7;

  --gold: #C98A1E;
  --gold-deep: #8F6314;
  --wine: #7E2231;
  --arcane: #7E56C4;
  --spark: #1F9D74;

  /* binder covers stay the five colours of Magic */
  --c-white: #E7DED0;
  --c-black: #26232B;
  --c-green: #2F8F63;
  --c-blue: #3E63C7;
  --c-red: #B3312B;

  --owned: #1F9D74;
  --foil: #C98A1E;
  --danger: #C2384A;

  /* Titles carry the weight; Nunito's rounded terminals carry the warmth. */
  --font-display: 'Helvetica Neue', 'HelveticaNeue', Helvetica, 'Segoe UI',
    Arial, sans-serif;
  --font-sans: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    system-ui, sans-serif;

  --r: 16px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% -10%, var(--stage-glow) 0%, var(--bg) 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.svg-defs { position: absolute; width: 0; height: 0; }

.hidden { display: none !important; }
.muted { color: var(--ink-3); font-size: 14px; }

.display {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: 0.005em;
  margin: 0;
}

/* ---------- App shell ---------- */
.app {
  width: min(1240px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 28px 40px;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
}
.mark {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  text-decoration: none;
}
.mark span {
  width: 5px;
  height: 15px;
  background: var(--ink);
  transform: skewX(-18deg);
  border-radius: 1px;
  opacity: 0.92;
  transition: opacity 0.2s;
}
.mark span:nth-child(2) { opacity: 0.55; }
.mark span:nth-child(3) { opacity: 0.3; }
.mark:hover span { opacity: 1; }
.topbar__meta {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* ---------- Screens ---------- */
.screens {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.screen {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
}
.screen.is-active {
  display: flex;
  animation: rise 0.45s var(--ease) both;
}
.screen__center {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.text-link {
  color: var(--ink-3);
  font-size: 12px;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}
.text-link:hover { color: var(--ink); }

/* ---------- Welcome ---------- */
.welcome {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1fr;
  align-items: center;
  gap: 26px;
  padding-bottom: 40px;
}
.welcome__title {
  font-size: clamp(34px, 5.1vw, 62px);
  color: var(--ink);
  text-wrap: balance;
}
.cardstack {
  justify-self: center;
  position: relative;
  width: 150px;
  aspect-ratio: 5 / 7;
  display: block;
  text-decoration: none;
}
.cardstack i {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(160deg, #2a2a33, #17171d);
  border: 1px solid var(--line-2);
  font-style: normal;
  transition: border-color 0.2s, color 0.2s;
}
.cardstack i:nth-child(1) { transform: translate(14px, -10px) rotate(6deg); opacity: 0.5; }
.cardstack i:nth-child(2) { transform: translate(7px, -4px) rotate(3deg); opacity: 0.75; }
.cardstack i:nth-child(3) {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--ink-3);
}
.cardstack .plus {
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  color: var(--ink-2);
  transition: color 0.2s;
}
.cardstack .cap {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-style: normal;
}
.cardstack:hover i:nth-child(3) { border-color: var(--c-blue); color: var(--ink-2); }
.cardstack:hover .plus { color: var(--c-blue); }
.welcome__lead {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.6;
  max-width: 30ch;
}
.welcome__lead strong { color: var(--ink); font-weight: 600; }

/* ---------- New binder ---------- */
.new {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 40px;
  padding-bottom: 40px;
}
.new__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1400px;
}
.new__form { max-width: 340px; width: 100%; }
.form-title {
  font-size: clamp(24px, 3vw, 34px);
  color: var(--ink-3);
  margin-bottom: 26px;
}
.field { margin-bottom: 22px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.control {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 7px 2px;
  outline: none;
  transition: border-color 0.2s;
}
.control::placeholder { color: var(--ink-4); }
.control:focus { border-bottom-color: var(--c-blue); }
select.control {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position:
    calc(100% - 12px) calc(50% - 2px),
    calc(100% - 7px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select.control option { background: var(--panel-2); color: var(--ink); }

.swatches {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s var(--ease);
}
.swatch::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  transition: border-color 0.15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch[aria-pressed="true"]::after { border-color: var(--ink); }
.swatch[data-color="white"] { background: var(--c-white); }
.swatch[data-color="black"] { background: var(--c-black); }
.swatch[data-color="green"] { background: var(--c-green); }
.swatch[data-color="blue"] { background: var(--c-blue); }
.swatch[data-color="red"] { background: var(--c-red); }

.confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 30px;
}
.confirm {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-4);
  cursor: not-allowed;
  transition: all 0.25s var(--ease);
}
.confirm svg { width: 17px; height: 17px; }
.confirm.is-ready {
  background: var(--ink);
  color: #0a0a0d;
  border-color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 20px -8px rgba(255, 255, 255, 0.5);
}
.confirm.is-ready:hover { transform: scale(1.06); }
.confirm.is-busy { opacity: 0.5; cursor: progress; }

/* ---------- Binder object ---------- */
.binder {
  --binder: var(--c-blue);
  --spine: color-mix(in srgb, var(--binder), #000 34%);
  --sheen: color-mix(in srgb, var(--binder), #fff 16%);
  position: relative;
  width: 210px;
  aspect-ratio: 3 / 4;
  border-radius: 5px 9px 9px 5px;
  background: linear-gradient(105deg, var(--sheen) 0%, var(--binder) 34%, var(--spine) 100%);
  box-shadow:
    0 2px 1px rgba(255, 255, 255, 0.14) inset,
    -1px 0 0 rgba(0, 0, 0, 0.35) inset,
    22px 30px 50px -22px rgba(0, 0, 0, 0.75);
  transform: rotateY(-16deg) rotateX(3deg);
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease);
}
.binder[data-color="white"] { --binder: var(--c-white); }
.binder[data-color="black"] { --binder: var(--c-black); }
.binder[data-color="green"] { --binder: var(--c-green); }
.binder[data-color="blue"] { --binder: var(--c-blue); }
.binder[data-color="red"] { --binder: var(--c-red); }

/* page block on the right edge */
.binder::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  right: -11px;
  width: 13px;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(180deg, #f2f2f2 0 2px, #c4c4c8 2px 4px);
  transform: rotateY(38deg);
  transform-origin: left center;
  box-shadow: 3px 4px 10px -3px rgba(0, 0, 0, 0.6);
  z-index: -1;
}
/* elastic closure band */
.binder::after {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  right: 26%;
  width: 15%;
  background: linear-gradient(90deg,
    rgba(0, 0, 0, 0.05), var(--spine) 40%, color-mix(in srgb, var(--spine), #000 25%));
  box-shadow: -3px 0 8px rgba(0, 0, 0, 0.25), 3px 0 8px rgba(0, 0, 0, 0.25);
}
.binder__emblem {
  position: absolute;
  top: 22%;
  left: 16%;
  width: 34%;
  aspect-ratio: 1;
  opacity: 0.32;
  color: #fff;
}
.new__stage .binder:hover { transform: rotateY(-10deg) rotateX(2deg); }

/* ---------- Collection shelf ---------- */
.collection { flex: 1 1 auto; display: flex; flex-direction: column; }
.collection__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 0;
}
.collection__title { font-size: clamp(24px, 3.4vw, 40px); color: var(--ink); }
.collection__count { font-size: 12px; color: var(--ink-3); letter-spacing: 0.04em; }
.shelf {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 46px;
  padding: 20px 30px 24px;
  overflow-x: auto;
  perspective: 1500px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.shelf-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.shelf-item .binder {
  width: 168px;
  animation: pop 0.5s var(--ease) both;
}
.shelf-item:hover .binder { transform: rotateY(-6deg) rotateX(2deg) translateY(-6px); }
@keyframes pop {
  from { opacity: 0; transform: rotateY(-40deg) translateX(-20px); }
  to { opacity: 1; transform: rotateY(-16deg) rotateX(3deg); }
}
.shelf-item__meta { text-align: center; }
.shelf-item__name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 15px;
  color: var(--ink);
}
.shelf-item__set { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.shelf-item__progress { font-size: 11px; color: var(--ink-4); margin-top: 4px; }

.add-binder {
  flex: 0 0 auto;
  width: 168px;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  border: 1.5px dashed var(--line-2);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: all 0.2s var(--ease);
}
.add-binder:hover { border-color: var(--c-blue); color: var(--ink-2); }
.add-binder .plus { font-size: 30px; font-weight: 200; line-height: 1; }
.add-binder .cap { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; }

/* ---------- Open binder ---------- */
.binder-view { flex: 1 1 auto; display: flex; flex-direction: column; }
.binder-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.binder-head__title { min-width: 0; }
.back-link { display: inline-block; margin-bottom: 10px; }
.binder-name {
  font-size: clamp(24px, 3.4vw, 40px);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.binder-set { font-size: 12px; color: var(--ink-3); margin: 6px 0 0; }
.binder-head__side {
  flex: 0 0 auto;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rename-input {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 3.4vw, 40px);
  line-height: 0.92;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--c-blue);
  color: var(--ink);
  outline: none;
  width: 100%;
  padding: 0 0 2px;
}

.stats { display: flex; flex-direction: column; gap: 6px; }
.stats-bar {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.stats-bar-fill {
  height: 100%;
  width: 0;
  background: var(--owned);
  border-radius: 2px;
  transition: width 0.35s var(--ease);
}
.stats-text { font-size: 11px; color: var(--ink-3); margin: 0; letter-spacing: 0.02em; }

.search-bar { position: relative; }
.search-bar input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.search-bar input::placeholder { color: var(--ink-4); }
.search-bar input:focus { border-color: var(--line-2); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  z-index: 40;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.9);
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: 0; }
.search-result-item:hover { background: rgba(255, 255, 255, 0.04); }
.search-result-item img { width: 32px; border-radius: 3px; flex: 0 0 auto; }
.search-result-info { min-width: 0; }
.search-result-name {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.search-result-empty { padding: 10px; font-size: 12px; color: var(--ink-3); }

.binder-actions { display: flex; gap: 8px; }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.ghost-btn--danger:hover { color: var(--danger); border-color: var(--danger); }
.ghost-btn--confirm {
  color: var(--danger);
  border-color: var(--danger);
}
.binder-actions__prompt {
  font-size: 11px;
  color: var(--ink-2);
  align-self: center;
  margin-right: 2px;
}

/* ---------- Card grid ---------- */
.binder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding-bottom: 20px;
}
.card-slot {
  position: relative;
  aspect-ratio: 5 / 7;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: transform 0.2s var(--ease), border-color 0.2s, opacity 0.2s, filter 0.2s;
}
.card-slot:hover { transform: translateY(-4px); border-color: var(--line-2); }
.card-slot .card-image { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Missing cards recede; owned cards read at full strength. */
.card-slot.unowned { opacity: 0.4; filter: grayscale(0.8); }
.card-slot.unowned:hover { opacity: 0.75; filter: grayscale(0.3); }
.card-slot.owned { border-color: rgba(47, 158, 95, 0.55); }

.card-slot.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  text-align: center;
}
.card-slot.empty .collector-number { font-size: 12px; color: var(--ink-3); }
.card-slot.empty .card-name { font-size: 11px; color: var(--ink-4); }

.collector-label {
  position: absolute;
  bottom: 5px;
  left: 5px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--ink-2);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}
.ownership-badge {
  position: absolute;
  bottom: 5px;
  right: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border-radius: 4px;
  color: #07070a;
}
.ownership-badge.nonfoil { background: var(--owned); }
.ownership-badge.foil { background: var(--foil); }
.ownership-badge.both {
  background: linear-gradient(90deg, var(--owned), var(--foil));
}

.grid-message {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---------- Card modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 5, 0.82);
  backdrop-filter: blur(3px);
}
.modal-content {
  position: relative;
  display: flex;
  gap: 26px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 26px;
  max-width: 660px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
  animation: rise 0.3s var(--ease) both;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: 0;
  color: var(--ink-3);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--ink); }
.modal-card-images { flex: 0 0 240px; position: relative; }
.modal-card-images img { width: 100%; border-radius: 10px; display: block; }
.flip-button {
  margin-top: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 7px;
  cursor: pointer;
  transition: all 0.2s;
}
.flip-button:hover { color: var(--ink); border-color: var(--ink-3); }
.modal-card-info { flex: 1 1 auto; min-width: 0; }
.modal-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.05;
  margin: 0 0 6px;
  color: var(--ink);
}
.modal-card-details { font-size: 12px; color: var(--ink-3); margin: 0 0 22px; }

.ownership-title {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 12px;
}
.ownership-controls { display: flex; flex-direction: column; gap: 10px; }
.ownership-variant { display: flex; align-items: center; gap: 8px; }
.variant-toggle {
  flex: 1 1 auto;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.variant-toggle:hover { border-color: var(--ink-3); color: var(--ink); }
.variant-toggle.owned {
  border-color: rgba(47, 158, 95, 0.5);
  background: rgba(47, 158, 95, 0.1);
  color: var(--ink);
  cursor: default;
}
.variant-quantity-controls { display: flex; gap: 6px; }
.quantity-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
}
.quantity-btn:hover { color: var(--ink); border-color: var(--ink-3); }

/* ---------- Error banner ---------- */
.error-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(520px, calc(100vw - 28px));
  background: #2a1414;
  border: 1px solid #5a2a2a;
  border-radius: 10px;
  padding: 11px 14px;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.9);
  animation: rise 0.25s var(--ease) both;
}
.error-banner-message { font-size: 13px; color: #f0d4d4; }
.error-banner-close {
  background: none;
  border: 0;
  color: #b98686;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.error-banner-close:hover { color: #f0d4d4; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .binder-head { flex-direction: column; align-items: stretch; gap: 18px; }
  .binder-head__side { width: 100%; }
}

@media (max-width: 760px) {
  .app { padding: 0 18px 32px; }
  .welcome { grid-template-columns: 1fr; text-align: center; gap: 22px; justify-items: center; }
  .welcome__lead { max-width: 36ch; }
  .new { grid-template-columns: 1fr; gap: 28px; }
  .new__form { margin: 0 auto; }
  .binder { width: 150px; }
  .shelf { gap: 34px; padding: 18px 10px 20px; }
  .modal-content { flex-direction: column; gap: 18px; padding: 20px; }
  .modal-card-images { flex: 0 0 auto; max-width: 220px; margin: 0 auto; }
}

@media (max-width: 600px) {
  .binder-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
}

@media (max-width: 400px) {
  .app { padding: 0 12px 28px; }
  .binder-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .shelf-item .binder, .add-binder { width: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Binder sections ---------- */
.sections {
  margin: 0 0 22px;
  padding: 16px 18px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.sections__head { margin-bottom: 12px; }
.sections__title {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.sections__hint { margin: 5px 0 0; font-size: 12px; color: var(--ink-3); }
.sections__list { list-style: none; margin: 0; padding: 0; }
.sections__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.sections__item:first-child { border-top: 0; }
.sections__item.is-hidden .sections__label,
.sections__item.is-hidden .sections__count { opacity: 0.45; }
.sections__toggle {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: var(--line-2);
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.sections__toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.2s var(--ease);
}
.sections__toggle[aria-checked="true"] { background: var(--owned); }
.sections__toggle[aria-checked="true"]::after { transform: translateX(16px); }
.sections__toggle:disabled { opacity: 0.5; cursor: default; }
.sections__label { flex: 1 1 auto; min-width: 0; font-size: 14px; color: var(--ink); }
.sections__count {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .sections { padding: 14px 14px 6px; }
  .sections__label { font-size: 13px; }
}

/* Hover preview: three cards from a section, floating beside the cursor */
.section-preview {
  position: fixed;
  z-index: 60;
  display: flex;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.14s var(--ease);
}
.section-preview.is-visible { opacity: 1; }
.section-preview img {
  width: 74px;
  aspect-ratio: 63 / 88;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: var(--panel);
}
.section-preview p {
  margin: 0;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--ink-3);
}

/* Touch devices have no hover; the counts carry the meaning there */
@media (hover: none) {
  .section-preview { display: none; }
}

.sections__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sections__reset { flex: none; }
.sections__move { display: flex; gap: 2px; flex: none; }
.sections__arrow {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.sections__arrow:hover:not(:disabled) { background: var(--line); color: var(--ink); }
.sections__arrow:disabled { opacity: 0.28; cursor: default; }

/* ---------- Batch selection ---------- */
.card-slot.is-selectable { cursor: pointer; }
.card-slot.is-selected {
  outline: 2px solid var(--owned);
  outline-offset: -2px;
  filter: none;
}
.card-slot.is-selected::after {
  content: "✓";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--owned);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  z-index: 2;
}
/* selection wins over the dimming that marks an unowned card */
.binder-grid.is-selecting .card-slot.unowned.is-selected { opacity: 1; filter: none; }

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--panel-2);
  box-shadow: 0 18px 46px -14px rgba(0, 0, 0, 0.85);
  flex-wrap: wrap;
}
.selection-bar__count {
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.selection-bar__group { display: flex; align-items: center; gap: 8px; }
.selection-bar__group label {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.selection-bar select {
  padding: 6px 8px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.selection-bar__actions { display: flex; gap: 8px; margin-left: auto; }

@media (max-width: 760px) {
  .selection-bar { gap: 12px; padding: 10px 12px; bottom: 12px; }
  .selection-bar__actions { margin-left: 0; width: 100%; }
}

/* ---------- Adding a set to a binder ---------- */
.sections__head-actions { display: flex; gap: 8px; flex: none; }
.sections__set {
  margin: 16px 0 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.sections__set:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.sections__set-name {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.sections__set-drop {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
  text-decoration: underline;
}
.sections__set-drop:hover { color: var(--danger); }

.sets-picker { margin: 0 0 14px; }
.sets-picker input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.sets-picker__list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.sets-picker__list:empty { display: none; }
.sets-picker__list li { border-top: 1px solid var(--line); }
.sets-picker__list li:first-child { border-top: 0; }
.sets-picker__list button {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.sets-picker__list button:hover { background: var(--panel-2); }
.sets-picker__list button:disabled { opacity: 0.4; cursor: default; }
.sets-picker__code {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  min-width: 44px;
}
.sections__set-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Adding loose cards ---------- */
.add-cards {
  margin: 0 0 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.add-cards__head { margin-bottom: 12px; }
.add-cards input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.add-cards__results {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}
.add-cards__results:empty { display: none; }
.add-cards__results li { border-top: 1px solid var(--line); }
.add-cards__results li:first-child { border-top: 0; }
.add-cards__results button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 6px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.add-cards__results button:hover { background: var(--panel); }
.add-cards__results button:disabled { opacity: 0.4; cursor: default; }
.add-cards__thumb {
  width: 34px;
  aspect-ratio: 63 / 88;
  object-fit: cover;
  border-radius: 3px;
  flex: none;
  background: var(--panel);
}
.add-cards__where {
  font-size: 11px;
  color: var(--ink-3);
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

/* ---------- Arranging cards by hand ---------- */
.binder-grid.is-arranging .card-slot { cursor: grab; }
.card-slot.is-dragging { opacity: 0.35; }
.card-slot.is-drop-target { box-shadow: 4px 0 0 var(--owned); }
.card-slot.is-loose::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px dashed var(--foil);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
}

/* Filtering the set list when creating a binder */
#set-search { margin-bottom: 8px; }
#set-select[size] { padding: 4px; }
#set-select[size] option { padding: 6px 8px; border-radius: 6px; }
.field__hint { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }

/* ============================ Binder spread ============================ */
/**
 * The pages view mirrors the object on the shelf: two facing pages, a gutter
 * between them, and the thickness of the pages already turned stacked on either
 * side. Purely presentational - the cards and their order are the same ones the
 * grid shows.
 */
.spread {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 8px 0 28px;
}

.spread__stage {
  position: relative;
  width: 100%;
  max-width: 1180px;
  perspective: 2600px;
  perspective-origin: 50% 40%;
}

.spread__book {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  transform-style: preserve-3d;
}

.page {
  position: relative;
  padding: 18px;
  background: linear-gradient(160deg, #17171d 0%, #101014 60%, #0b0b0e 100%);
  border: 1px solid var(--line-2);
  backface-visibility: hidden;
}
/* the slight inward tilt is what reads as "open book" rather than "two panels" */
.page--left {
  border-radius: 12px 4px 4px 12px;
  transform: rotateY(6deg);
  transform-origin: right center;
  box-shadow: inset -24px 0 34px -26px #000, -14px 18px 40px -22px rgba(0, 0, 0, 0.9);
}
.page--right {
  border-radius: 4px 12px 12px 4px;
  transform: rotateY(-6deg);
  transform-origin: left center;
  box-shadow: inset 24px 0 34px -26px #000, 14px 18px 40px -22px rgba(0, 0, 0, 0.9);
}

.spread__gutter {
  position: absolute;
  top: 2%;
  bottom: 2%;
  left: 50%;
  width: 26px;
  transform: translateX(-50%);
  background: linear-gradient(90deg,
    rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.75) 42%, #000 50%,
    rgba(0, 0, 0, 0.75) 58%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}

/* the pages already turned, and the ones still to come */
.spread__stack {
  position: absolute;
  top: 14px;
  bottom: 14px;
  width: 34px;
  border-radius: 6px;
  background: repeating-linear-gradient(90deg, #1c1c22 0 2px, #0d0d11 2px 4px);
  box-shadow: 0 16px 34px -20px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.spread__stack--left { left: -26px; transform: rotateY(16deg); transform-origin: right center; }
.spread__stack--right { right: -26px; transform: rotateY(-16deg); transform-origin: left center; }
.spread__stack.is-shown { opacity: 1; }

.page__pockets {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  grid-template-rows: repeat(var(--rows, 3), 1fr);
}

/* an empty pocket is part of the object, not a missing card */
.pocket-empty {
  aspect-ratio: 5 / 7;
  border-radius: 9px;
  border: 1px dashed var(--line-2);
  background: rgba(255, 255, 255, 0.012);
}

/* ---------- Turning a page ---------- */
.page--turning {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 50%;
  padding: 0;
  border: 0;
  background: none;
  transform-style: preserve-3d;
  transform-origin: left center;
  z-index: 5;
  pointer-events: none;
}
.page--turning.is-flipping { animation: page-turn 0.55s var(--ease) forwards; }
.page--turning.is-flipping-back {
  transform-origin: right center;
  left: 0;
  animation: page-turn-back 0.55s var(--ease) forwards;
}
.page__face {
  position: absolute;
  inset: 0;
  padding: 18px;
  border-radius: 4px 12px 12px 4px;
  border: 1px solid var(--line-2);
  background: linear-gradient(160deg, #17171d 0%, #101014 60%, #0b0b0e 100%);
  backface-visibility: hidden;
}
.page__face--back { transform: rotateY(180deg); border-radius: 12px 4px 4px 12px; }

@keyframes page-turn {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(-180deg); }
}
@keyframes page-turn-back {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(180deg); }
}

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; gap: 18px; }
.pager__btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.pager__btn:hover:not(:disabled) { background: var(--line); color: var(--ink); }
.pager__btn:disabled { opacity: 0.3; cursor: default; }
.pager__label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  min-width: 160px;
  text-align: center;
}

/* ---------- Page layout controls ---------- */
.layout {
  margin: 0 0 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.layout__row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
}
.layout__row > span { flex: 0 0 140px; font-size: 13px; color: var(--ink); }
.layout__row input[type="range"] { flex: 1 1 auto; accent-color: var(--owned); }
.layout__row output {
  flex: none;
  min-width: 22px;
  text-align: right;
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.layout__summary { margin: 10px 0 0; font-size: 12px; color: var(--ink-3); }

@media (max-width: 900px) {
  .spread__stage { perspective: 1600px; }
  .page { padding: 12px; }
  .page__pockets { gap: 7px; }
  .spread__stack { display: none; }
}
@media (max-width: 600px) {
  .page { padding: 8px; }
  .page__pockets { gap: 5px; }
  .layout__row > span { flex: 0 0 96px; font-size: 12px; }
}

/**
 * A class that sets `display` beats the user-agent rule for [hidden], so an
 * element toggled with `el.hidden` stays on screen. Both of these are toggled
 * that way.
 */
.selection-bar[hidden],
.section-preview[hidden] { display: none !important; }

/* ============================================================
   Grimório — the ember treatment
   A grimoire resting in a hoard: warm dark, gold leaf, one fire.
   ============================================================ */

/* the stage gains a low ember from below as well as the glow above */
body { background: var(--bg); }

.display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.022em;
  text-transform: none;
}

/* ---------- the mark ---------- */
.mark {
  display: grid;
  place-items: center;
  width: auto;
  height: auto;
  gap: 0;
}
.mark img {
  width: 22px;
  height: auto;
  display: block;
  filter: drop-shadow(0 0 12px rgba(255, 59, 7, 0.45));
  transition: filter 0.3s var(--ease), transform 0.3s var(--ease);
}
.mark:hover img {
  filter: drop-shadow(0 0 18px rgba(255, 59, 7, 0.75));
  transform: translateY(-1px);
}

/* ---------- welcome ---------- */
/* On paper the mark needs no glow — it is already the only saturated thing here */
.welcome__sigil {
  width: 60px;
  height: auto;
  margin: 0 auto 30px;
  display: block;
}

.welcome__title {
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 0.9;
  background: linear-gradient(172deg, var(--ember-soft) 4%, var(--gold) 46%, var(--ember) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome__kicker {
  margin: 14px 0 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.welcome__lead strong { color: var(--gold); font-weight: 600; }

/* the stack you tap to begin reads as loose leaves on the table */
.cardstack i {
  border-color: var(--line-2);
  background: var(--panel);
  box-shadow: 0 18px 34px -26px rgba(28, 28, 30, 0.5);
}
.cardstack .plus { color: var(--ember); }
.cardstack:hover i:nth-child(3) {
  border-color: var(--ember);
  box-shadow: 0 20px 40px -24px rgba(255, 59, 7, 0.4);
}

/* ---------- the shelf ---------- */
.collection__title {
  background: linear-gradient(168deg, var(--ink) 20%, var(--gold) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.collection__count { color: var(--gold-deep); letter-spacing: 0.14em; }



/* ============================================================
   Home — paper ground, art-backed binders
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 0 0;
  border-bottom: 0;
}
.mark img {
  width: 34px;
  filter: none;
}
.mark:hover img { filter: none; transform: translateY(-1px); }
.topbar__meta { margin-left: auto; color: var(--ink-3); }
.topbar__menu {
  display: grid;
  gap: 5px;
  width: 34px;
  height: 34px;
  padding: 0;
  place-content: center;
  border: 0;
  border-left: 1px solid var(--line);
  padding-left: 18px;
  margin-left: 18px;
  background: none;
  cursor: pointer;
}
.topbar__menu span {
  display: block;
  width: 17px;
  height: 1.5px;
  background: var(--ink);
  border-radius: 1px;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 30px;
  margin: 34px 0 0;
  border-bottom: 1px solid var(--line);
}
.tabs__tab {
  padding: 0 0 12px;
  font-size: 15px;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.18s var(--ease);
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- title block ---------- */
.collection__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 60px;
  padding: 70px 0 44px;
}
.collection__title {
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  margin: 0;
}
.collection__meta {
  display: flex;
  gap: 26px;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: 0;
}
.collection__count { color: var(--ink-3); letter-spacing: 0; }
.collection__lead {
  flex: 0 1 320px;
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* ---------- the binders ---------- */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 360px));
  gap: 18px;
  align-items: start;
  padding: 0 0 80px;
}
.shelf::after { content: none; }

.binder-card {
  position: relative;
  display: block;
  aspect-ratio: 5 / 6.4;
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel-2);
  text-decoration: none;
  color: #fff;
  isolation: isolate;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.binder-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 44px -22px rgba(28, 28, 30, 0.4);
}
.binder-card:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }

.binder-card__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}
/* the wash keeps the type readable over any illustration */
.binder-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    to bottom,
    rgba(20, 12, 8, 0.18) 0%,
    rgba(20, 12, 8, 0.05) 34%,
    rgba(20, 12, 8, 0.62) 74%,
    rgba(16, 9, 6, 0.86) 100%);
}

.binder-card__menu {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.06em;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease);
}
.binder-card:hover .binder-card__menu,
.binder-card__menu:focus-visible { opacity: 1; }
.binder-card__menu:hover { background: rgba(255, 255, 255, 0.26); }

.binder-card__body {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
}
.binder-card__code {
  margin: 0 0 4px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.68);
  letter-spacing: 0.02em;
}
.binder-card__name {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: #fff;
}
.binder-card__stats { display: flex; gap: 40px; }
.binder-card__stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.binder-card__stat b em { font-style: normal; color: rgba(255, 255, 255, 0.5); }
.binder-card__stat span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}

/* the "add" tile keeps the same footprint as a binder */
.binder-card--new {
  border: 1px dashed var(--line-2);
  background: var(--panel);
  color: var(--ink-2);
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
}
.binder-card--new::after { content: none; }
.binder-card--new:hover { border-color: var(--ember); color: var(--ink); }
.binder-card--new b {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--ember);
}

@media (max-width: 760px) {
  .collection__head { flex-direction: column; gap: 20px; padding: 44px 0 30px; }
  .collection__lead { flex: 1 1 auto; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
}

/* ---------- Collection: everything you own ---------- */
.acervo__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin: 0 0 28px;
}
.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}
.seg__btn {
  padding: 7px 15px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.seg__btn:hover { color: var(--ink); }
.seg__btn.is-active { background: var(--ink); color: #fff; }

.acervo__search {
  flex: 0 1 300px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.acervo__search:focus-visible { outline: 2px solid var(--ember); outline-offset: 1px; }

.acervo { display: flex; flex-direction: column; gap: 30px; padding-bottom: 60px; }

/* each collection is a block, not a line of text above more cards */
.acervo__group {
  padding: 26px 0 0;
  border-top: 1px solid var(--line);
}
.acervo__group:first-child { padding-top: 0; border-top: 0; }

.acervo__group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}
.acervo__group-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.acervo__group-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.acervo__group-code {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.acervo__group-count {
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.acervo__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
}

.acervo__more {
  align-self: center;
  padding: 10px 22px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.acervo__more:hover { border-color: var(--ink-3); }

.acervo__empty { padding: 60px 0; text-align: center; color: var(--ink-3); }

/* quantity badge, for the copies you hold more than one of */
.card-slot__qty {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 7px;
  border-radius: 20px;
  background: rgba(28, 28, 30, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  z-index: 2;
}

/* marker that pulls the next chunk of cards into the grid */
.grid-sentinel { grid-column: 1 / -1; height: 1px; }

/* ============================================================
   Selection without a mode, and the reorganised binder header
   ============================================================ */

/* the tick box appears on hover and is what starts a selection */
.card-slot__check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  background: rgba(28, 28, 30, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 0.14s var(--ease), transform 0.14s var(--ease),
              background 0.14s var(--ease);
}
.card-slot:hover .card-slot__check,
.card-slot__check:focus-visible { opacity: 1; transform: none; }

.card-slot__check::after {
  content: "";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  line-height: 22px;
  text-align: center;
}
.card-slot.is-selected .card-slot__check {
  opacity: 1;
  transform: none;
  background: var(--owned);
  border-color: var(--owned);
}
.card-slot.is-selected .card-slot__check::after { content: "\2713"; }

/* a selected card stays legible even when it is one you do not own */
.card-slot.is-selected { outline: 2px solid var(--owned); outline-offset: -2px; }
.card-slot.unowned.is-selected { opacity: 1; filter: none; }

/* cards are draggable at all times, so the cursor says so */
.card-slot { cursor: pointer; }
.card-slot.is-dragging { opacity: 0.35; }

/* ---------- view toggle ---------- */
.viewtoggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.viewtoggle__btn {
  padding: 6px 13px;
  border: 0;
  border-radius: 7px;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.viewtoggle__btn:hover { color: var(--ink); }
.viewtoggle__btn.is-active { background: var(--ink); color: #fff; }

/* ---------- add menu ---------- */
.menu { position: relative; }
.menu__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 176px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  box-shadow: 0 16px 34px -18px rgba(28, 28, 30, 0.45);
}
.menu__item {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 7px;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.menu__item:hover { background: var(--panel-2); }

/* ---------- icon buttons ---------- */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.16s var(--ease), background 0.16s var(--ease),
              border-color 0.16s var(--ease);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--ink); background: var(--panel-2); border-color: var(--line); }
.icon-btn--danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.binder-name-row { display: flex; align-items: center; gap: 6px; }
.binder-name-row .icon-btn { opacity: 0; }
.binder-head__title:hover .icon-btn,
.binder-name-row .icon-btn:focus-visible { opacity: 1; }

/* the count doubles as the way to drop everything */
.selection-bar__count {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}
.selection-bar__count:hover { border-color: var(--line-2); color: var(--danger); }
.field__optional {
  margin-left: 8px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- binder toolbar: controls under the description ---------- */
.binder-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.binder-toolbar__left,
.binder-toolbar__right { display: flex; align-items: center; gap: 10px; }

/* a plain text control, for things that are not the primary action */
.text-btn {
  padding: 7px 2px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.text-btn:hover { color: var(--ink); border-bottom-color: var(--line-2); }
.text-btn:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }

@media (max-width: 600px) {
  .binder-toolbar { gap: 12px; }
  .binder-toolbar__left { flex: 1 1 100%; }
}

/* a button whose icon sits ahead of its label */
.ghost-btn--icon { display: inline-flex; align-items: center; gap: 7px; }
.ghost-btn--icon svg { width: 15px; height: 15px; flex: none; }

/* ---------- dialog ---------- */
.dialog {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 40px));
  margin: 12vh auto 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 30px 80px -28px rgba(28, 28, 30, 0.5);
}
.dialog__title {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.dialog__label {
  display: block;
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.dialog__input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.dialog__input:focus-visible { outline: 2px solid var(--ember); outline-offset: 1px; }
.dialog__hint { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.ghost-btn--primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.ghost-btn--primary:hover { background: #000; }

/* ---------- the menu a card's ... opens ---------- */
.menu-popover {
  position: absolute;
  z-index: 60;
  min-width: 150px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  box-shadow: 0 16px 34px -18px rgba(28, 28, 30, 0.45);
}
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover { background: var(--gap-bg, #f8e7e3); }

/* the ... stays visible while its menu is open */
.binder-card__menu:focus { opacity: 1; }

/* ---------- collections, as blocks ---------- */
.setgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.setcard {
  position: relative;
  display: block;
  aspect-ratio: 5 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: var(--panel-2);
  color: #fff;
  text-decoration: none;
  isolation: isolate;
  transition: transform 0.28s var(--ease), box-shadow 0.28s var(--ease);
}
.setcard:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px -22px rgba(28, 28, 30, 0.42);
}
.setcard:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }

.setcard__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}
.setcard::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom,
    rgba(20, 12, 8, 0.16) 0%, rgba(20, 12, 8, 0.1) 30%,
    rgba(20, 12, 8, 0.68) 72%, rgba(16, 9, 6, 0.9) 100%);
}

.setcard__body { position: absolute; left: 18px; right: 18px; bottom: 16px; }
.setcard__code {
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.66);
}
.setcard__name {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: #fff;
}
.setcard__bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.24);
  overflow: hidden;
  margin-bottom: 8px;
}
.setcard__bar i { display: block; height: 100%; background: var(--owned); border-radius: 2px; }
.setcard__stat {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.setcard__stat b { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.setcard__stat em { font-style: normal; font-size: 13px; color: rgba(255, 255, 255, 0.55); }
.setcard__stat span { margin-left: auto; font-size: 12px; color: rgba(255, 255, 255, 0.7); }
