/* ============================================================
   BESTIARY CODEX - ink, stone and brass
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  /* light: quarried stone + ink */
  --bg:          #E7E8E1;
  --bg-deep:     #DCDED4;
  --surface:     #F2F3EE;
  --surface-2:   #E1E3D9;
  --surface-3:   #D2D5C9;
  --ink:         #191C18;
  --ink-2:       #4B5049;
  --ink-3:       #797E74;
  --line:        #C4C7BA;
  --line-soft:   #D6D9CD;
  --gold:        #806017;
  --gold-2:      #A8842E;
  --gold-glow:   rgba(168,132,46,.16);
  --shadow:      0 1px 2px rgba(25,28,24,.07), 0 8px 24px -12px rgba(25,28,24,.28);
  --shadow-lift: 0 2px 4px rgba(25,28,24,.09), 0 18px 40px -18px rgba(25,28,24,.38);
  --scrim:       rgba(30,33,28,.45);

  --ok:      #3D7A55;
  --warn:    #8E6412;
  --info:    #45607C;
  --bad:     #9B3A2C;

  --w: #E8DCB6; --u: #2E6FA6; --b: #45414F; --r: #A93A2C; --g: #3A7442; --c: #8E9187;

  /* a printed card is the same card in any light: never themed */
  --card-face:  #F7F4E8;
  --card-ink:   #16140E;
  --card-ink-2: #55503F;
  --card-hair:  rgba(20,16,8,.30);
  --card-rule:  rgba(20,16,8,.16);

  --rail: 268px;
  --f-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --f-body: "Spectral", "Iowan Old Style", Georgia, serif;
  --f-util: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0E110F;
    --bg-deep:     #090B09;
    --surface:     #161A17;
    --surface-2:   #1E231F;
    --surface-3:   #272D28;
    --ink:         #E9E8DD;
    --ink-2:       #A8AC9E;
    --ink-3:       #757A6D;
    --line:        #2B322C;
    --line-soft:   #212721;
    --gold:        #CBA43A;
    --gold-2:      #E6C868;
    --gold-glow:   rgba(203,164,58,.14);
    --shadow:      0 1px 2px rgba(0,0,0,.5), 0 10px 28px -14px rgba(0,0,0,.8);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.55), 0 22px 48px -20px rgba(0,0,0,.9);
    --scrim:       rgba(4,6,4,.66);
    --ok:      #6DBB88; --warn: #D5A63C; --info: #7FA0C4; --bad: #DB7461;
    --w: #D9CEA8; --u: #4E93CE; --b: #6F6A80; --r: #D0584A; --g: #55A263; --c: #9DA095;
  }
}

:root[data-theme="dark"] {
  --bg:          #0E110F;
  --bg-deep:     #090B09;
  --surface:     #161A17;
  --surface-2:   #1E231F;
  --surface-3:   #272D28;
  --ink:         #E9E8DD;
  --ink-2:       #A8AC9E;
  --ink-3:       #757A6D;
  --line:        #2B322C;
  --line-soft:   #212721;
  --gold:        #CBA43A;
  --gold-2:      #E6C868;
  --gold-glow:   rgba(203,164,58,.14);
  --shadow:      0 1px 2px rgba(0,0,0,.5), 0 10px 28px -14px rgba(0,0,0,.8);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.55), 0 22px 48px -20px rgba(0,0,0,.9);
  --scrim:       rgba(4,6,4,.66);
  --ok:      #6DBB88; --warn: #D5A63C; --info: #7FA0C4; --bad: #DB7461;
  --w: #D9CEA8; --u: #4E93CE; --b: #6F6A80; --r: #D0584A; --g: #55A263; --c: #9DA095;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(120% 80% at 50% -10%, var(--gold-glow), transparent 60%),
    radial-gradient(100% 60% at 50% 110%, var(--bg-deep), transparent 65%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold); color: var(--bg); }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0,1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.rail__brand { padding: 18px 18px 12px; border-bottom: 1px solid var(--line-soft); }
.brandmark {
  font-family: var(--f-display); font-weight: 700; font-size: 17px;
  letter-spacing: .1em; text-transform: uppercase; line-height: 1.25;
  color: var(--ink); margin: 0; display: block; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer; width: 100%;
}
.brandmark span { display: block; color: var(--gold); }
.brandmark:hover { color: var(--gold-2); }
.brand__sub {
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .18em;
  font-size: 11px; color: var(--ink-3); margin-top: 6px;
}

.rail__nav { display: flex; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.rail__search { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.rail__scroll { overflow-y: auto; flex: 1 1 auto; padding: 6px 8px 18px; scrollbar-width: thin; }
.rail__foot { border-top: 1px solid var(--line-soft); padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.railgroup { margin: 10px 0 4px; }
.railgroup__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 6px 10px 5px; font-family: var(--f-util); text-transform: uppercase;
  letter-spacing: .16em; font-size: 11px; color: var(--ink-3);
  border-bottom: 1px solid var(--line-soft);
}
.railgroup__count { font-variant-numeric: tabular-nums; color: var(--ink-3); }

.railitem {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border: 0; border-left: 2px solid transparent;
  background: none; color: var(--ink-2); cursor: pointer; text-align: left;
  font-family: var(--f-body); font-size: 14.5px; line-height: 1.3;
}
.railitem:hover { background: var(--surface-2); color: var(--ink); }
.railitem[aria-current="true"] {
  background: var(--surface-2); color: var(--ink);
  border-left-color: var(--gold); font-weight: 600;
}
.railitem__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.railitem__n { font-family: var(--f-util); font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.railitem__flag { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }

/* ---------- pips ---------- */
.pips { display: inline-flex; gap: 2px; flex: 0 0 auto; }
.pip {
  width: 13px; height: 13px; border-radius: 50%; display: inline-grid; place-items: center;
  font-family: var(--f-util); font-size: 9px; font-weight: 600; line-height: 1;
  border: 1px solid rgba(0,0,0,.25); color: #10120F;
}
.pip--W { background: var(--w); } .pip--U { background: var(--u); color: #F4F7FA; }
.pip--B { background: var(--b); color: #E7E4EE; } .pip--R { background: var(--r); color: #FBEDEA; }
.pip--G { background: var(--g); color: #EDF6EE; } .pip--C { background: var(--c); }
.pip--N { background: var(--surface-3); color: var(--ink-2); border-color: var(--line); }
.pip--hy { font-size: 0; }
.pips--lg .pip { width: 18px; height: 18px; font-size: 11.5px; }
.mtgcard .pip--N { background: #DCD6C2; color: #16140E; border-color: var(--card-hair); }

/* ---------- controls ---------- */
.btn {
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .12em; font-size: 12px;
  padding: 7px 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); border-radius: var(--radius); cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--gold); color: var(--ink); background: var(--surface-2); }
.btn--primary { background: var(--gold); border-color: var(--gold); color: var(--bg); font-weight: 600; }
.btn--primary:hover { background: var(--gold-2); border-color: var(--gold-2); color: var(--bg); }
.btn--ghost { background: none; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn--sm { padding: 4px 9px; font-size: 11px; }
.btn--pill { border-radius: 20px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[aria-pressed="true"] { border-color: var(--gold); color: var(--ink); background: var(--surface-2); }

.field {
  width: 100%; font-family: var(--f-body); font-size: 14.5px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px;
}
.field:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px var(--gold-glow); }
.field::placeholder { color: var(--ink-3); }
textarea.field { line-height: 1.6; resize: vertical; min-height: 90px; font-size: 14px; }
textarea.field--mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.label {
  display: block; font-family: var(--f-util); text-transform: uppercase; letter-spacing: .14em;
  font-size: 11px; color: var(--ink-3); margin-bottom: 4px;
}
.formgrid { display: grid; gap: 14px; }
.formgrid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.formgrid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--f-util);
  text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 2px; border: 1px solid currentColor; white-space: nowrap;
}
.chip--ready { color: var(--ok); } .chip--qc { color: var(--warn); } .chip--wip { color: var(--info); }
.chip--ok { color: var(--ok); } .chip--warn { color: var(--warn); } .chip--bad { color: var(--bad); }
.chip__dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 34px 96px; }
.wrap--narrow { max-width: 780px; }
.wrap--wide { max-width: 1240px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 34px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.topbar__crumb {
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .16em;
  font-size: 11.5px; color: var(--ink-3); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__crumb b { color: var(--ink-2); font-weight: 600; }
.topbar__search { flex: 1 1 auto; max-width: 380px; margin-left: auto; }
.topbar__search .field { padding: 5px 10px; font-size: 13.5px; }
.savepill {
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .12em; font-size: 11px;
  color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.savepill__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.savepill[data-s="saving"] .savepill__dot { background: var(--gold); animation: pulse 1s ease-in-out infinite; }
.savepill[data-s="saved"] .savepill__dot { background: var(--ok); }
.savepill[data-s="error"] .savepill__dot { background: var(--warn); }
.savepill[data-s="ro"] .savepill__dot { background: var(--info); }
@keyframes pulse { 0%,100% { opacity: .3 } 50% { opacity: 1 } }

/* ---------- headings ---------- */
.eyebrow {
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .22em;
  font-size: 11px; color: var(--gold); margin: 0 0 10px;
}
h1.display {
  font-family: var(--f-display); font-weight: 700; font-size: clamp(28px, 4.2vw, 42px);
  line-height: 1.08; letter-spacing: .005em; margin: 0; text-wrap: balance;
}
h2.section {
  font-family: var(--f-display); font-weight: 600; font-size: 20px; letter-spacing: .06em;
  text-transform: uppercase; margin: 0; text-wrap: balance;
}
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }
.rule--gold { height: 2px; border: 0; margin: 0; background: linear-gradient(90deg, var(--gold), transparent 72%); }

/* ---------- hero fan ---------- */
.hero { display: grid; grid-template-columns: minmax(0,1fr) 420px; gap: 34px; align-items: center; padding: 40px 0 28px; }
.hero__fan { position: relative; height: 300px; }
.mtgcard-wrap.hero__card {
  position: absolute; top: 50%; left: 50%; width: 168px; max-width: none;
  transform-origin: 50% 120%;
  filter: drop-shadow(0 14px 26px rgba(0,0,0,.34));
  animation: dealIn .7s cubic-bezier(.2,.75,.3,1) backwards;
}
@keyframes dealIn { from { opacity: 0; transform: translate(-50%,-30%) rotate(0deg) scale(.9); } }
@media screen and (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; }
  .hero__fan { height: 226px; }
  .mtgcard-wrap.hero__card { width: 128px; }
}

/* ---------- deck banner ---------- */
.banner {
  position: relative; margin-top: 20px; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; background: var(--surface);
  box-shadow: var(--shadow);
}
.banner__art { height: 216px; background-size: cover; background-position: center 40%; position: relative; }
.banner__art--gen { filter: saturate(.85); }
.banner__scrim { position: absolute; inset: 0; }
.banner__body { position: relative; padding: 18px 24px 20px; margin-top: -58px; }
.banner__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.banner__sub { color: var(--ink-2); font-size: 15.5px; margin: 8px 0 0; max-width: 62ch; }
.banner__acts { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 2; }

/* ---------- plates / stats ---------- */
.plate { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.plate__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.plate__body { padding: 18px; }

.statrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 1px; background: var(--line-soft); }
.stat { background: var(--surface); padding: 14px 16px; }
.stat__n { font-family: var(--f-display); font-weight: 700; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat__l { font-family: var(--f-util); text-transform: uppercase; letter-spacing: .14em; font-size: 10.5px; color: var(--ink-3); margin-top: 6px; }

.deftable { width: 100%; border-collapse: collapse; }
.deftable th, .deftable td { text-align: left; padding: 7px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.deftable th { font-family: var(--f-util); text-transform: uppercase; letter-spacing: .14em; font-size: 11px; color: var(--ink-3); font-weight: 500; width: 34%; padding-right: 16px; }
.deftable td { font-size: 14.5px; color: var(--ink); }
.deftable tr:last-child th, .deftable tr:last-child td { border-bottom: 0; }

/* ---------- charts ---------- */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 118px; }
.chart__col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; }
.chart__bar { width: 100%; background: var(--gold); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .82; transition: opacity .15s ease; }
.chart__col:hover .chart__bar { opacity: 1; }
.chart__n { font-family: var(--f-util); font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart__x { font-family: var(--f-util); font-size: 10.5px; color: var(--ink-3); letter-spacing: .08em; }

.meter { display: flex; align-items: center; gap: 10px; }
.meter__track { flex: 1 1 auto; height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.meter__fill { display: block; height: 100%; }
.meter__label { font-family: var(--f-util); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); width: 92px; }
.meter__n { font-family: var(--f-util); font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; width: 76px; text-align: right; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs--plain { border-bottom: 0; flex-wrap: wrap; }
.tab {
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .13em; font-size: 12px;
  padding: 10px 14px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-3); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }
.tab__n { font-variant-numeric: tabular-nums; opacity: .65; margin-left: 5px; }

/* ---------- card list ---------- */
.cardlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(292px, 1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.cardrow {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px; background: var(--surface);
  border: 0; border-left: 2px solid transparent; text-align: left; cursor: pointer; width: 100%;
  font-family: var(--f-body); font-size: 14.5px; color: var(--ink-2); line-height: 1.3;
}
.cardrow:hover { background: var(--surface-2); color: var(--ink); border-left-color: var(--gold); }
.cardrow__i { font-family: var(--f-util); font-size: 11px; color: var(--ink-3); width: 20px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.cardrow__main { flex: 1 1 auto; min-width: 0; }
.cardrow__n { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cardrow__t { display: block; font-family: var(--f-util); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cardrow__mark { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex: 0 0 auto; }
.cardrow__mark--empty { background: none; border: 1px solid var(--line); }

/* ============================================================
   the card frame
   ============================================================ */
/* the frame sizes every detail off its own width, so one component serves
   the deck page, the hero fan and a 63mm print sheet without redefinition */
.mtgcard-wrap { container-type: inline-size; width: 100%; max-width: 320px; }
.mtgcard {
  --fa: #8E9187; --fb: #8E9187;
  font-size: 320px;
  position: relative; width: 100%; aspect-ratio: 63 / 88;
  border-radius: 4.7% / 3.4%; padding: 3.4% 3.1% 3.8%;
  background:
    linear-gradient(158deg, var(--fa) 0%, var(--fb) 62%, rgba(0,0,0,.34) 100%);
  box-shadow:
    var(--shadow-lift),
    inset 0 0 0 1px rgba(255,255,255,.26),
    inset 0 1px 0 rgba(255,255,255,.34),
    inset 0 -2px 10px rgba(0,0,0,.42),
    inset 0 0 40px rgba(0,0,0,.22);
  display: flex; flex-direction: column; gap: 1.6%;
  transition: transform .24s cubic-bezier(.2,.7,.3,1);
  isolation: isolate;
}
.mtgcard--live:hover { transform: translateY(-5px) rotate(-.4deg); }

/* the colour band down the edge of a three-plus-colour frame */
.mtgcard__band { position: absolute; left: 0; top: 8%; bottom: 8%; width: 5px; border-radius: 3px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.34); }
.mtgcard__band span { flex: 1 1 0; }

/* foil sheen, earned only by rares and mythics */
.mtgcard--foil::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(114deg,
    transparent 22%, rgba(255,255,255,.30) 38%, rgba(180,235,255,.22) 46%,
    rgba(255,222,170,.26) 54%, transparent 70%);
  opacity: 0; transition: opacity .3s ease; mix-blend-mode: overlay; z-index: 3;
}
.mtgcard--foil:hover::after { opacity: 1; }

.mtgbar {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  background: var(--card-face);
  border: 1px solid var(--card-hair); border-radius: 4px;
  padding: 2.2% 3.4%;
  box-shadow: 0 1px 0 rgba(255,255,255,.20), inset 0 1px 2px rgba(0,0,0,.10);
}
.mtgcard__name { font-family: var(--f-display); font-weight: 600; font-size: 4%; line-height: 1.18; color: var(--card-ink); letter-spacing: .005em; }
.mtgcard__art {
  flex: 1 1 36%; min-height: 0; position: relative; overflow: hidden;
  border-radius: 2px;
  background-size: cover; background-position: center; background-color: rgba(0,0,0,.2);
  box-shadow: 0 0 0 1px var(--card-hair), 0 0 0 2px rgba(255,255,255,.14), inset 0 2px 8px rgba(0,0,0,.34);
}
.mtgcard__type { font-family: var(--f-body); font-size: 3.3%; font-weight: 600; color: var(--card-ink); letter-spacing: .005em; }
.mtgcard__set {
  width: 11px; height: 11px; flex: 0 0 auto; border-radius: 2px;
  transform: rotate(45deg); box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), 0 1px 1px rgba(0,0,0,.2);
}
.mtgcard__text {
  flex: 1 1 44%; min-height: 0; overflow-y: auto;
  background: var(--card-face); color: var(--card-ink);
  border: 1px solid var(--card-hair); border-radius: 4px;
  padding: 3% 3.4% 3.4%;
  font-size: 3.45%; line-height: 1.44; scrollbar-width: thin;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.10);
}
.mtgcard__text p { margin: 0 0 5px; }
.mtgcard__text p:last-child { margin-bottom: 0; }
.mtgcard__text .pip { width: 1em; height: 1em; font-size: .78em; vertical-align: -.12em; }
.mtgcard__kw { font-weight: 600; }
.mtgcard__flavor { font-style: italic; color: var(--card-ink-2); border-top: 1px solid var(--card-rule); padding-top: 5px; margin-top: 6px; }
.reminder { font-style: italic; color: var(--card-ink-2); }
.abilityword { font-style: italic; font-weight: 600; }
.mtgcard__pt {
  position: absolute; right: 4.5%; bottom: 2.4%;
  background: var(--card-face); color: var(--card-ink);
  border: 1px solid var(--card-hair); border-radius: 4px; padding: 0 3%;
  font-family: var(--f-display); font-weight: 700; font-size: 4%;
  font-variant-numeric: tabular-nums; z-index: 2;
  box-shadow: 0 1px 2px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.4);
}
.mtgcard__setline {
  display: flex; justify-content: space-between; gap: 6px;
  font-family: var(--f-util); font-size: 2.6%; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.78); padding: 0 2%; text-shadow: 0 1px 1px rgba(0,0,0,.5);
}
.mtgcard__setline span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@supports (width: 1cqw) { .mtgcard { font-size: 100cqw; } }

/* mini frames (hero fan) reuse the same box */
.mtgcard--mini .mtgcard__text { display: none; }
.mtgcard--mini .mtgcard__art { flex: 1 1 auto; }

.cardspread { display: grid; grid-template-columns: 320px minmax(0,1fr); gap: 28px; align-items: start; }
@media (max-width: 820px) { .cardspread { grid-template-columns: 1fr; } }

/* ---------- print sheet ---------- */
.sheet { display: grid; grid-template-columns: repeat(3, 63mm); gap: 3mm; justify-content: center; }
.sheet .mtgcard-wrap { width: 63mm; max-width: none; }
.sheetpage { break-after: page; padding: 4mm 0; }
.sheetpage:last-child { break-after: auto; }

/* ---------- prose ---------- */
.prose { font-size: 15.5px; color: var(--ink); max-width: 68ch; }
.prose--wide { max-width: none; }
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--f-display); font-weight: 600; letter-spacing: .03em; line-height: 1.2; margin: 1.6em 0 .5em; text-wrap: balance; }
.prose h1 { font-size: 25px; }
.prose h2 { font-size: 19px; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line-soft); padding-bottom: .3em; }
.prose h3 { font-size: 16.5px; }
.prose h4 { font-size: 14.5px; color: var(--ink-2); }
.prose p { margin: 0 0 .95em; }
.prose ul, .prose ol { margin: 0 0 .95em; padding-left: 1.3em; }
.prose li { margin-bottom: .3em; }
.prose li::marker { color: var(--gold); }
.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85em; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 2px; padding: .08em .34em; }
.prose pre { background: var(--surface-2); border: 1px solid var(--line-soft); border-left: 2px solid var(--gold); padding: 12px 14px; overflow-x: auto; font-size: 13px; margin: 0 0 1em; }
.prose pre code { background: none; border: 0; padding: 0; }
.prose blockquote { margin: 0 0 1em; padding: 2px 0 2px 16px; border-left: 2px solid var(--gold); color: var(--ink-2); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.8em 0; }
.prose table { border-collapse: collapse; font-size: 13.5px; width: 100%; }
.prose .tablewrap { overflow-x: auto; margin: 0 0 1.1em; border: 1px solid var(--line-soft); }
.prose th, .prose td { border-bottom: 1px solid var(--line-soft); padding: 6px 11px; text-align: left; vertical-align: top; }
.prose th { font-family: var(--f-util); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; color: var(--ink-3); font-weight: 500; background: var(--surface-2); white-space: nowrap; }
.prose a { color: var(--gold); text-decoration: none; border-bottom: 1px solid var(--gold-glow); }
.prose a:hover { border-bottom-color: var(--gold); }
.wikilink { font-family: var(--f-body); color: var(--gold); background: none; border: 0; padding: 0; cursor: pointer; border-bottom: 1px dashed var(--gold); font-size: inherit; }
.wikilink:hover { background: var(--gold-glow); }
.wikilink--dead { color: var(--ink-3); border-bottom-style: dotted; border-bottom-color: var(--line); cursor: default; }
.pathref { font-family: var(--f-util); font-size: .92em; color: var(--ink-3); letter-spacing: .02em; }
mark { background: var(--gold-glow); color: inherit; border-bottom: 1px solid var(--gold); }

/* ---------- notes ---------- */
.note { border: 1px solid var(--line); border-left: 2px solid var(--gold); background: var(--surface); padding: 14px 18px; border-radius: var(--radius); }
.note__head { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; margin-bottom: 8px; }
.note__title { font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: .03em; }
.note__ts { font-family: var(--f-util); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }

/* ---------- drop zone ---------- */
.drop {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px;
  text-align: center; color: var(--ink-3); background: var(--surface);
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .14em; font-size: 11.5px;
  cursor: pointer; transition: border-color .15s ease, color .15s ease, background .15s ease; width: 100%;
}
.drop:hover, .drop.is-over { border-color: var(--gold); color: var(--gold); background: var(--surface-2); }

/* ---------- deck grid ---------- */
.deckgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 14px; }
.deckplate {
  position: relative; text-align: left; cursor: pointer; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 0; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.deckplate:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--gold); }
.deckplate__art { height: 84px; background-size: cover; background-position: center; border-bottom: 1px solid var(--line); }
.deckplate__body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.deckplate__name { font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: .02em; color: var(--ink); line-height: 1.2; }
.deckplate__cmd { font-size: 13px; color: var(--ink-3); line-height: 1.35; }
.deckplate__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 4px; }

/* ---------- search / review ---------- */
.hit {
  display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left;
  padding: 9px 14px; background: var(--surface); border: 0; border-left: 2px solid transparent;
  cursor: pointer; font-family: var(--f-body); font-size: 14.5px; color: var(--ink-2);
}
.hit:hover { background: var(--surface-2); color: var(--ink); border-left-color: var(--gold); }
.hit__n { flex: 0 0 auto; font-weight: 600; color: var(--ink); }
.hit__where { font-family: var(--f-util); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.hit__snip { flex: 1 1 auto; min-width: 0; font-size: 13.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hitlist { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }

.matchrow { display: grid; grid-template-columns: 26px minmax(0,1fr) 96px 62px 62px; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px 14px; background: var(--surface); border: 0; border-left: 2px solid transparent; cursor: pointer; font-family: var(--f-body); font-size: 14.5px; color: var(--ink-2); }
.matchrow:hover { background: var(--surface-2); color: var(--ink); border-left-color: var(--gold); }
.matchrow__i { font-family: var(--f-util); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.matchrow__pct { font-family: var(--f-util); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
@media (max-width: 700px) { .matchrow { grid-template-columns: 22px minmax(0,1fr) 56px; } .matchrow__hide { display: none; } }

/* ---------- misc ---------- */
.stack { display: flex; flex-direction: column; }
.stack--xs { gap: 8px; } .stack--sm { gap: 14px; } .stack--md { gap: 22px; } .stack--lg { gap: 36px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.util { font-family: var(--f-util); text-transform: uppercase; letter-spacing: .14em; font-size: 11px; color: var(--ink-3); }
.empty { padding: 34px 20px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--radius); }
.pad-t { padding-top: 30px; }
.colorbar { display: flex; height: 6px; border-radius: 2px; overflow: hidden; border: 1px solid var(--line); }
.colorbar span { display: block; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: start center; padding: 5vh 20px 40px; overflow-y: auto; }
.modal__scrim { position: fixed; inset: 0; background: var(--scrim); border: 0; padding: 0; cursor: default; }
.modal__panel {
  position: relative; width: 100%; max-width: 760px; background: var(--surface);
  border: 1px solid var(--line); border-top: 2px solid var(--gold); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); padding: 24px 26px 26px;
  animation: rise .22s cubic-bezier(.2,.7,.3,1);
}
.modal__panel--wide { max-width: 960px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal__close { position: absolute; top: 10px; right: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90;
  background: var(--surface); border: 1px solid var(--line); border-left: 2px solid var(--gold);
  padding: 10px 18px; border-radius: var(--radius); box-shadow: var(--shadow-lift);
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .12em; font-size: 11.5px;
  color: var(--ink); max-width: 80vw;
}

.railtoggle { display: none; }

/* ---------- staged reveal ---------- */
.enter > * { animation: riseIn .34s cubic-bezier(.2,.75,.3,1) backwards; }
.enter > *:nth-child(1) { animation-delay: 0ms; }
.enter > *:nth-child(2) { animation-delay: 55ms; }
.enter > *:nth-child(3) { animation-delay: 105ms; }
.enter > *:nth-child(4) { animation-delay: 150ms; }
.enter > *:nth-child(n+5) { animation-delay: 190ms; }
@keyframes riseIn { from { opacity: 0; transform: translateY(9px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; }
}

@media screen and (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 50; width: min(86vw, 320px); left: 0; top: 0; transform: translateX(-102%); transition: transform .24s cubic-bezier(.2,.7,.3,1); box-shadow: var(--shadow-lift); }
  .rail.is-open { transform: none; }
  .railtoggle { display: inline-flex; }
  .wrap { padding: 0 18px 80px; }
  .topbar { padding: 9px 18px; flex-wrap: wrap; }
  .topbar__search { max-width: none; width: 100%; order: 3; margin-left: 0; }
  .banner__art { height: 152px; }
  .banner__body { margin-top: -44px; padding: 14px 16px 18px; }
  .formgrid--2, .formgrid--3 { grid-template-columns: 1fr; }
  .sheet { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
  .sheet .mtgcard-wrap { width: 100%; }
}

/* ---------- print ---------- */
@media print {
  .rail, .topbar, .tabs, .banner__acts, .noprint { display: none !important; }
  body { background: #fff !important; }
  .shell { display: block; }
  .wrap { max-width: none; padding: 0; }
  .sheetpage { page-break-after: always; }
  .mtgcard { box-shadow: none !important; break-inside: avoid; }
  .mtgcard--foil::after { display: none; }
  @page { size: A4 portrait; margin: 8mm; }
}

/* ============================================================
   the hub - the front door
   ============================================================ */
.shell--solo { grid-template-columns: minmax(0, 1fr); }

.topbar__home {
  flex: 0 0 auto;
  font-family: var(--f-display); font-weight: 600; font-size: 12px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
}
.topbar__home:hover { color: var(--gold); }

.hubhead { padding: 56px 0 40px; max-width: 62ch; }
.hubhead h1.display { margin-bottom: 14px; }

.hubgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  gap: 1px; background: var(--line-soft);
  border: 1px solid var(--line-soft); border-top: 2px solid var(--gold);
}
.hubtile {
  display: flex; align-items: flex-start; gap: 16px; text-align: left; cursor: pointer;
  background: var(--surface); border: 0; padding: 20px 22px 22px; width: 100%;
  font-family: var(--f-body); color: var(--ink-2);
  transition: background .16s ease, color .16s ease;
}
.hubtile:hover { background: var(--surface-2); color: var(--ink); }
.hubtile__glyph {
  flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: 17px;
  color: var(--gold); border: 1px solid var(--line);
  background: var(--bg); border-radius: 2px;
}
.hubtile:hover .hubtile__glyph { border-color: var(--gold); }
.hubtile__body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hubtile__name {
  font-family: var(--f-display); font-weight: 600; font-size: 16px;
  letter-spacing: .03em; color: var(--ink);
}
.hubtile__flag {
  font-family: var(--f-util); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--warn); border: 1px solid currentColor; border-radius: 2px;
  padding: 1px 5px; vertical-align: 2px; margin-left: 4px; font-weight: 600;
}
.hubtile__blurb { font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.hubtile__count {
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .13em;
  font-size: 10.5px; color: var(--ink-3); margin-top: 2px;
}

/* the way back, on every area that is not the hub */
.backbar {
  display: flex; align-items: center; gap: 10px; padding: 26px 0 4px;
  font-family: var(--f-util); text-transform: uppercase; letter-spacing: .14em; font-size: 11px;
}
.backlink {
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--gold);
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  display: inline-flex; align-items: center; gap: 7px;
}
.backlink:hover { color: var(--gold-2); text-decoration: underline; }
.backbar__sep { color: var(--line); }
.backbar__here { color: var(--ink-3); }

@media screen and (max-width: 900px) {
  .hubhead { padding: 34px 0 26px; }
  .hubgrid { grid-template-columns: 1fr; }
  .topbar__home { display: none; }
}
