/* The Forge — web Deck Builder. Mobile-first, dark-fantasy gold-on-black to
   match the Black Cat Card Forge desktop theme. No external fonts/assets: system
   font stack, everything inline-friendly. Designed down to ~360px width. */

:root {
  --bg: #0e0d0b;
  --panel: #17150f;
  --panel-line: #2a2418;
  --gold: #d4af37;
  --gold-soft: #e8cf7a;
  --ink: #ece7db;
  --muted: #9a917d;
  --error: #e5817a;
  --ok: #8fce8f;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, #1a1710 0%, var(--bg) 60%) fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* Masthead */
/* Masthead + footer are hidden on every size: the builder IS the app, like the
   desktop dialog. The only intro line is the import panel's `.slogan`
   ("Let's get your deck ready for the forge"). The h1/subtitle/tagline styles
   below still apply if the masthead is ever shown again. */
.masthead {
  display: none;
  text-align: center;
  padding: 8px 0 20px;
}
.masthead h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 9vw, 3rem);
  letter-spacing: 0.04em;
  color: var(--gold);
  margin: 0;
  text-shadow: 0 2px 12px rgba(212, 175, 55, 0.25);
}
.subtitle {
  color: var(--gold-soft);
  font-style: italic;
  margin: 2px 0 10px;
  font-size: 0.95rem;
}
.tagline {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 16px 0;
}
.step {
  font-family: Georgia, serif;
  color: var(--gold);
  font-size: 1.15rem;
  margin: 0 0 14px;
  font-weight: 600;
}

/* Fields */
.field {
  display: block;
  margin: 0 0 14px;
}
.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
/* email/password added for /admin (web-0.33.1) — the builder has neither, so
   nothing there changes. `number` is deliberately NOT here: the builder has one
   and it is sized on purpose, as are the admin page's own. */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* >=16px stops iOS zoom-on-focus */
  resize: vertical;
}
input[type="text"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}
textarea {
  min-height: 120px;
  line-height: 1.6;
}

/* Buttons — large tap targets */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--panel-line);
  background: #201c13;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #17140a;
  border-color: var(--gold);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Import panel: slogan + green/red counts (mirrors the desktop deck builder's
   left panel). */
.slogan {
  color: var(--gold-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 0.9rem;
  margin: 0 0 12px;
}
/* Invite-link banner: greets a named friend, or explains a link that's died.
   Sits under the slogan on step 1; hidden entirely without ?i= (web-0.13.1). */
.invite-banner {
  border: 1px solid var(--panel-line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--ink);
  background: rgba(212, 175, 55, 0.06);
}
/* A dead link is information, not an error the friend caused — warn in the
   muted error tone rather than shouting, since they can still send a deck. */
.invite-banner.dead {
  border-left-color: var(--error);
  background: rgba(229, 129, 122, 0.07);
  color: var(--muted);
}
/* Invite-code box (web-0.26.0, moved into step 1 in 0.26.3). The second door
   into an invite: a friend with no link types their short code here to unlock
   sending. Sits under the invite banner so it's reachable the moment the page
   loads — down beside Send it was inside the review pane and invisible until a
   deck had been resolved. Visible only while sending is locked, so it vanishes
   the moment it has done its job. Gold-edged like the invite banner rather than
   error-toned — it's an invitation, not a complaint. */
.code-box {
  border: 1px solid var(--panel-line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: rgba(212, 175, 55, 0.06);
  padding: 10px 12px;
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
/* The author `display: flex` above beats the UA's `[hidden] { display: none }`
   (0,1,0 against 0,0,1), so the box painted on regardless — which is why every
   friend with a working link was still asked for a code. Same trap already
   guarded on .draft-banner, .sheet-overlay and .picker-dpi; this one was
   missed. setSubmitEnabled() was doing its job all along. */
.code-box[hidden] { display: none; }
.code-box .field {
  margin: 0;
  flex: 1 1 150px;
}
/* A code is read off one screen and typed into another, so it's set monospaced
   and letter-spaced: the characters have to be checkable one at a time. Upper
   case is forced because that's the shape it was given in — the normalizer
   accepts either, but seeing it echo back differently reads as a mistake. */
.code-box input {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.code-box .btn {
  width: auto;
  flex: 0 0 auto;
}
.code-box .status {
  flex: 1 0 100%;
  margin: 0;
}
.code-box .status:empty {
  display: none;
}

/* Import by link (web-0.38.0). Same flex-wrap shape as .code-box — input and
   button on one row on a desktop, stacked once the row can't hold both — but
   deliberately NOT gold-edged: this is an ordinary tool, not an invitation, and
   two gold boxes stacked would fight each other for the eye. */
.url-import {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin: 0 0 12px;
}
/* 150px, not the 220 this started at: step 1 is a ~263px column on a desktop,
   so a 220 basis plus the button pushed the button onto its own row there while
   fitting fine on a phone — the opposite way round from what you'd guess. Same
   basis .code-box uses, and the two now wrap at the same width. */
.url-import .field {
  margin: 0;
  flex: 1 1 150px;
}
.url-import .btn {
  width: auto;
  flex: 0 0 auto;
}
/* The heading, the sites note and the status each take a full row of their own,
   so none of them ever squeezes the input. :empty keeps the status from
   reserving space before an import has been tried. */
.url-import .field-label,
.url-import .status {
  flex: 1 0 100%;
  margin: 0;
}
.url-import .status:empty { display: none; }
/* Reads before the input, so it's the one line here that answers "is my site on
   the list?" — hence the emphasis on the names rather than flat muted text. */
.url-sites {
  flex: 1 0 100%;
  margin: 0 0 2px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}
.url-sites strong {
  color: var(--text);
  font-weight: 600;
}

/* The line the import blocks fold behind once a deck exists (web-0.40.0).
   Quiet, like .start-empty — it is a way back, not a call to action, and it
   must not compete with Resolve. Left-aligned rather than centred because it
   labels the block beneath it. */
.import-toggle {
  display: block;
  margin: 0 0 10px;
  padding: 11px 0; /* keeps the 44px tap target .start-empty measured for */
  background: none;
  border: 0;
  color: var(--gold-soft);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.import-toggle:hover {
  color: var(--gold);
}
/* An author display rule beats the UA's [hidden]{display:none} — the same trap
   .start-empty and .hover-preview hit. Both of these set display, so both need
   it back. */
.import-toggle[hidden],
#importTools[hidden] {
  display: none;
}

/* Opening a saved deck file (web-0.39.1). Laid out like .url-import — heading,
   explanation, control, status, each on its own row — because it sits directly
   under it and the two are the same kind of offer. Its own class rather than a
   second .url-import so the sites note and the file note can't drift apart. */
.file-import {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.file-import .field-label,
.file-import .url-sites,
.file-import .status {
  flex: 1 0 100%;
  margin: 0;
}
.file-import .btn {
  width: auto;
  flex: 0 0 auto;
  margin-top: 2px;
}
.file-import .status:empty { display: none; }

/* Restored draft (web-0.24.0). Same shape as the invite banner but in the muted
   tone — it's a courtesy, not a greeting, and it shouldn't compete with the
   "Hi <name>" above it. Wraps on narrow screens so the button never squeezes
   the text to one word per line. */
.draft-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  border: 1px solid var(--panel-line);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--ink);
}
.draft-banner span { flex: 1 1 12rem; }
/* An author `display: flex` beats the UA `[hidden] { display: none }` rule (same
   trap the sheet overlays hit below), so without this the banner sat there as an
   empty bordered box whenever there was no draft — reported by Gavin, 0.29.3.
   The `hidden` attribute is how app.ts shows/hides it, so it must actually
   hide. */
.draft-banner[hidden] { display: none; }
/* The banner takes itself away after ten seconds (web-0.40.1). It says one
   thing, once; leaving it there costs a bar of the phone's screen forever.
   The tap-to-dismiss is why the cursor changes. */
.draft-banner {
  cursor: pointer;
  overflow: hidden;
  /* It COLLAPSES upward rather than fading in place (web-0.40.2, Gavin), so the
     deck box slides up behind it instead of jumping the moment it goes. Every
     box property that occupies vertical space has to be in the transition —
     leaving margin or border out strands a few pixels of empty bordered box,
     which is the same jump made small. Opacity runs faster than the height so
     the text is gone before the box finishes closing. */
  /* 0.6s, up from 0.35 (web-0.40.3, Gavin: "a little slower"). Eased at BOTH
     ends, not just the tail: a plain ease-out gave away half the height in the
     first 100ms (measured 88px to 49px), which is the jump he objected to in
     the first place, only shorter. This one starts gently. */
  transition:
    max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s ease,
    margin 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    border-width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.draft-banner.is-fading {
  max-height: 0 !important; /* beats the pinned inline height set in JS */
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
}
/* Someone who has asked not to see motion gets the disappearance without the
   animation — the banner still goes, it just doesn't slide on the way. */
@media (prefers-reduced-motion: reduce) {
  .draft-banner { transition: none; }
}
/* Start fresh sits directly above Resolve deck (web-0.29.1, Gavin) rather than
   inside the restore banner: that's where the eye already is when deciding what
   to do with a restored deck. Centred in its own full-width box so it reads as
   a deliberate second action next to Resolve, not as a corner of the banner. */
.draft-actions {
  display: flex;
  justify-content: center;
  margin: 0 0 10px;
}
.draft-actions[hidden] { display: none; } /* same [hidden] trap as the banner */
.draft-actions .draft-discard { min-width: 11rem; }
.draft-discard {
  flex: none;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  /* Comfortably tappable on a phone, which is where stepping away happens. */
  min-height: 40px;
}
.draft-discard:hover { color: var(--ink); border-color: var(--muted); }

/* Spent invite link: shown INSTEAD of the builder, so nobody builds a deck they
   can't send. Calm rather than alarming — they've done nothing wrong. */
.dead-link {
  border-left: 3px solid var(--error);
}
.dead-link-msg {
  color: var(--ink);
  margin: 0 0 8px;
}
.dead-link-hint {
  color: var(--muted);
  margin: 0;
  font-size: 0.92rem;
}
/* A one-off link fixes the name it was issued to (Gavin, 2026-07-21), so the
   field reads as locked rather than looking like an editable box that ignores you. */
.invite-locked {
  opacity: 0.75;
  cursor: not-allowed;
}
.counts-row {
  display: flex;
  gap: 12px;
  margin: 10px 0 0;
}
.count-green {
  color: var(--ok);
  font-size: 0.85rem;
  font-weight: 700;
}
.count-red {
  color: #d0654f;
  font-size: 0.85rem;
  font-weight: 700;
}
.viewer-empty {
  display: none; /* desktop layout only, and only when the grid is empty */
  color: #6a6256;
  text-align: center;
  margin: 40px 0;
}

/* Status lines */
.status {
  margin: 12px 0 0;
  min-height: 1.2em;
  font-size: 0.92rem;
  color: var(--muted);
}
.status.error {
  color: var(--error);
}
.status.ok {
  color: var(--ok);
}

/* Review */
.summary {
  color: var(--gold-soft);
  font-weight: 600;
  margin: 0 0 12px;
}
/* Against an expected count (web-0.52.0): red until it's right, then green. */
.summary.count-off { color: var(--error); }
.summary.count-ok { color: var(--ok); }
.unresolved {
  background: rgba(229, 129, 122, 0.08);
  border: 1px solid rgba(229, 129, 122, 0.35);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.unresolved-head {
  margin: 0 0 6px;
  color: var(--error);
  font-size: 0.9rem;
}
/* web-0.64.0: names the builder corrected — a heads-up, not an error. */
.unresolved.corrected { background: rgba(242, 178, 76, 0.08); border-color: rgba(242, 178, 76, 0.4); }
.unresolved.corrected .unresolved-head { color: var(--gold, #f2b24c); }
.unresolved ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 0.9rem;
}

/* Deck-section tabs (Commander / Main / Sideboard / Tokens) above the review grid.
   Hidden when the deck is a single section. Scrolls horizontally if it can't fit. */
.deck-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.deck-tabs::-webkit-scrollbar {
  display: none;
}
.deck-tab {
  flex: 1 0 auto;
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
  border: 1px solid var(--panel-line);
  background: #201c13;
  color: var(--muted);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.deck-tab.is-active {
  color: #17140a;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold);
}

/* Filter bar — search the active tab + sort the grid (desktop #deckFilterBar). */
.deck-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}
.deck-search {
  flex: 1;
  min-width: 0;
  background: #100e09;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
}
.deck-search:focus {
  outline: none;
  border-color: var(--gold);
}
.deck-sort-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.deck-sort-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.deck-sort {
  background: #100e09;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  color: var(--gold-soft);
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  cursor: pointer;
}

/* Every <select> in the builder (web-0.27.3). Colours alone weren't enough —
   without `appearance: none` the browser still draws its own arrow and, on
   macOS, its own control chrome, which reads as a stray light widget on a dark
   gold-on-black page. The arrow is an inline SVG data URI so there's no asset
   to ship and no extra request; its colour is the literal gold (#d4af37) since
   a CSS variable can't be interpolated inside a url(). */
.deck-sort,
#addSection,
.confirm-pick,
.picker-dpi select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d4af37' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.deck-sort:hover {
  border-color: #3a3a35;
}
.deck-sort:focus {
  outline: none;
  border-color: var(--gold);
}

/* Show the empty note whenever the grid is empty (e.g. a search with no match). */
.card-grid:empty + .viewer-empty {
  display: block;
}

/* Card grid — auto-fill, phone-friendly.
   The minimum was 96px, which fitted three across a phone and left the rules
   text unreadable; 128px gives two bigger tiles there and fewer, larger ones on
   a desktop (Gavin, web-0.31.2). Still `1fr` at the top, so the tiles grow into
   whatever width is going rather than leaving a gutter.
   The 150% pass (web-0.37.0) deliberately did NOT touch this one: 128 gives a
   phone two tiles across, and 192 would give it one. See the min-width:900 rule
   for where the enlargement actually lives. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
  margin: 0 0 20px;
}
.card-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-thumb {
  position: relative;
  aspect-ratio: 745 / 1040;
  border-radius: 8px;
  overflow: hidden;
  background: #100e09;
  border: 1px solid var(--panel-line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  /* It's a <button>: strip the native chrome, keep it tappable. */
  width: 100%;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.card-thumb:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-tile.missing .card-thumb {
  border-color: rgba(229, 129, 122, 0.5);
  color: var(--error);
}
/* Keyboard/click selection — the desktop's gold tile border. */
.card-tile.is-selected .card-thumb {
  outline: 2px solid #d98a1f;
  outline-offset: 2px;
}
/* Positioning context for the on-tile split switch overlay. */
.card-thumb-wrap {
  position: relative;
}
/* Not-found placeholder — "not found" over a smaller "tap to fix" hint. */
.card-nf {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
}
.card-nf-hint {
  font-size: 0.62rem;
  font-weight: 400;
  opacity: 0.8;
}
/* "Different art per copy" switch — bottom-left of the art (desktop's
   ToggleSwitch), clear of the qty badge in the bottom-right. */
.split-toggle {
  position: absolute;
  bottom: 5px;
  left: 5px;
  z-index: 3;
  width: 34px;
  height: 19px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: rgba(0, 0, 0, 0.72);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.split-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold-soft);
  transition: transform 0.12s ease, background 0.12s ease;
}
.split-toggle.is-on {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold);
}
.split-toggle.is-on .split-toggle-knob {
  transform: translateX(15px);
  background: #17140a;
}
.split-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* DFC flip badge — round control on the left edge, just above centre (desktop's
   FlipButton spot). Translucent dark disc + gold ring/glyph when showing the
   front; solid gold with a dark glyph when flipped to the back. */
.dfc-badge {
  position: absolute;
  left: 6px;
  top: 40%;
  transform: translateY(-50%);
  z-index: 3;
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(18, 16, 12, 0.84);
  border: 1px solid var(--gold);
  color: var(--gold);
  cursor: pointer;
}
.dfc-badge:hover {
  color: #f0a637;
  border-color: #f0a637;
}
.dfc-badge.is-flipped {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold);
  color: #12100c;
}
.dfc-badge svg {
  display: block;
}
.dfc-badge:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.card-qty {
  position: absolute;
  right: 4px;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.78);
  color: var(--gold-soft);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.78rem;
  font-weight: 700;
}
/* One line, ellipsised — keeps every tile the same height so the grid stays
   even (full name in the tooltip / picker title). */
.card-name {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* − / + / ⋯ under each tile: remove a copy, add a copy, open the card menu. */
.card-actions {
  display: flex;
  gap: 4px;
}
.card-act {
  flex: 1;
  min-height: 30px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--panel-line);
  background: #201c13;
  color: var(--gold-soft);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.card-act:disabled {
  opacity: 0.35;
  cursor: default;
}
.card-act:active:not(:disabled) {
  transform: translateY(1px);
}

/* Success */
.success {
  border-color: rgba(143, 206, 143, 0.4);
}
.success .step {
  color: var(--ok);
}

.foot {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 24px;
}

/* A little more room on larger screens */
@media (min-width: 560px) and (max-width: 899px) {
  .wrap {
    padding: 32px 24px 64px;
  }
  .panel {
    padding: 22px 22px;
  }
}

/* ── Desktop layout (≥900px): mirror the desktop app's Deck Builder window ──
   Two flush panes filling the viewport — a fixed 300px import panel on the
   left (slogan, Text/URL tabs, Resolve, counts, status) and the viewer on the
   right (section-tab header bar, scrolling card grid, bottom action bar).
   Colours come straight from styles/forge.qss (#deckImport/#deckViewer/…). */
@media (min-width: 900px) {
  body {
    background: #171817;
    overflow: hidden;
  }
  .wrap {
    max-width: none;
    height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
  }
  .builder {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px 1fr;
  }

  /* Left: the import panel. */
  .pane-import {
    margin: 0;
    border: 0;
    border-right: 1px solid #2a2620;
    border-radius: 0;
    background: #141513;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
    overflow-y: auto;
  }
  .pane-import .step {
    display: none; /* no step numbers — the desktop builder has none */
  }
  /* min-height matches the textarea's floor below, and that pairing is
     load-bearing. With `min-height: 0` these two shrank freely while the
     textarea refused to go under 160px, so the textarea OVERFLOWED its own
     container and the tokens checkbox printed on top of the decklist. It went
     unnoticed until the import row (web-0.38.0) added enough height to the
     column to force the squeeze. The panel already scrolls (`overflow-y: auto`
     above), so refusing to shrink here is free. */
  #pageText {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 160px;
  }
  #pageText .field {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 160px;
  }
  #pageText textarea {
    flex: 1;
    min-height: 160px;
    font-family: Menlo, Consolas, monospace;
    font-size: 0.8rem;
  }

  /* Right: the viewer pane. Shown even before a deck resolves (the desktop
     viewer always exists, with "Resolved cards appear here."); the author
     display below would beat [hidden] anyway, so it's deliberate. */
  .pane-viewer {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #171817;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .viewer-head {
    background: #161715;
    border-bottom: 1px solid #242421;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 52px;
  }
  .viewer-head .step {
    display: none;
  }
  .viewer-head .summary {
    margin: 0 0 0 auto;
    color: #8a8276;
    font-size: 0.8rem;
    font-weight: 400;
  }
  /* Section tabs become the desktop's underline style in the header bar. */
  .viewer-head .deck-tabs {
    margin: 0;
    overflow: visible;
  }
  .viewer-head .deck-tab {
    flex: none;
    min-height: 0;
    padding: 4px 4px 6px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: #8a8276;
    letter-spacing: 0.5px;
  }
  .viewer-head .deck-tab:hover {
    color: #cbbf9f;
  }
  .viewer-head .deck-tab.is-active {
    background: transparent;
    color: #d98a1f;
    border-bottom-color: #d98a1f;
  }
  /* The filter bar becomes its own band under the header, like the desktop. */
  .deck-filter-bar {
    margin: 0;
    background: #131412;
    border-bottom: 1px solid #242421;
    padding: 8px 18px;
  }
  .viewer-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
  }
  /* The desktop layout has its own track, and it is the one that actually
     applies on a laptop — the base rule above is the phone's. Both had to move
     for the 150% pass (web-0.37.0); changing only the base one did nothing
     visible, which is exactly the sort of thing measuring catches and reasoning
     doesn't. 130 → 195. */
  .card-grid {
    margin: 0;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 14px 12px;
  }
  .card-grid:empty + .viewer-empty {
    display: block;
  }

  /* Bottom action bar: name + note + Send, like the desktop's Build bar. */
  .action-bar {
    background: #161715;
    border-top: 1px solid #242421;
    padding: 12px 18px;
    display: grid;
    grid-template-columns: 1fr 1.4fr auto;
    gap: 12px;
    align-items: end;
  }
  .action-bar .field {
    margin: 0;
  }
  .action-bar textarea {
    min-height: 0;
    height: 48px;
    resize: none;
  }
  .action-bar .btn {
    width: auto;
    padding: 12px 26px;
  }
  /* Save deck to file (web-0.46.5) sits under Send, in Send's column. */
  .action-bar #saveFileBtn {
    grid-column: 3;
  }
  .action-bar .status {
    grid-column: 1 / -1;
    margin: 0;
    min-height: 0;
  }
  .action-bar .status:empty {
    display: none;
  }

  /* Sent ✓ becomes a centered overlay above the builder. */
  .success {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    min-width: 340px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  }
}

/* Art-picker bottom sheet */
body.sheet-open {
  overflow: hidden; /* stop the page scrolling behind the sheet */
}
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center; /* centre the popup on screen */
  justify-content: center;
  padding: 16px;
}
/* The author `display: flex` above beats the UA `[hidden] { display: none }`
   rule, so `hidden` alone wouldn't hide the sheet — restore it explicitly. */
.sheet-overlay[hidden] {
  display: none;
}
.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
/* The art picker is the one sheet whose job is showing pictures, so it gets more
   room than the rest (web-0.37.0). 968px inside the 16px padding holds four
   232px cells with 10px gaps — the same four-across the picker has always had,
   kept while the cells grew 150%. Everything else stays at 720px: a confirm or
   a help text reads worse the wider it gets. */
.sheet--picker {
  max-width: 1000px;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.sheet-title {
  font-family: Georgia, serif;
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The confirm/notice sheet is the one whose title is always an authored string
   ("Heads up", "A message from …") rather than a card name, so it can wrap
   instead of being ellipsised. Without this "A message from Black Cat Card
   Forge" truncates to "A message from Black Cat C…". */
#confirmTitle {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.sheet-close {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: #201c13;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}
.sheet-search {
  display: flex;
  gap: 8px;
}
.sheet-search input {
  flex: 1;
  min-width: 0;
}
.sheet-search-btn {
  width: auto;
  flex: none;
  padding: 12px 18px;
}
/* Source tabs (Scryfall / MPC) */
.picker-tabs {
  display: flex;
  gap: 6px;
  margin: 4px 0 10px;
}
.picker-tab {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--panel-line);
  background: #201c13;
  color: var(--muted);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.picker-tab.is-active {
  color: #17140a;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold);
}
/* Options row: Tokens toggle + Min-DPI filter */
.picker-opts {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
/* "Fetch tokens" opt-in under the decklist box (desktop's Fetch-tokens check). */
.opt-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}
.opt-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

.picker-tokens {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}
.picker-tokens input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}
.picker-dpi {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
/* The author display above beats the UA [hidden] rule, so hide it explicitly
   when toggled off on the Scryfall tab (same fix as .sheet-overlay). */
.picker-dpi[hidden] {
  display: none;
}
.picker-dpi select {
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  /* Right padding leaves room for the shared gold arrow — this rule sits after
     that one, so a plain `padding` shorthand here would undo it. */
  padding: 6px 26px 6px 8px;
  font: inherit;
  font-size: 0.9rem;
}
.picker-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 6px 0 2px;
  min-height: 1em;
}
.picker-grid {
  display: grid;
  /* Fixed cell size (like the desktop picker's CELL_SIZE) so the row height is
     deterministic and never depends on when/whether an image loads — that image
     dependence is what let the cards overlap. auto-fill packs as many columns
     as fit; justify-content centres the leftover gutter.

     Sized so the sheet holds exactly FOUR across on a desktop (688px inside the
     720px sheet: 4 × 155 + 3 × 10 = 650, five would need 815) and two on a
     phone — big enough to read the rules text, which is what Gavin asked for
     (web-0.31.1). It was 104px, which fitted six and made every card a stamp.

     The 150% pass (web-0.37.0) leaves THIS size alone and enlarges in the
     min-width:900 rule below — 232px cells fit one across on a phone, not two,
     and a picker showing a single artwork can't be compared with anything. */
  grid-template-columns: repeat(auto-fill, 155px);
  grid-auto-rows: 216px; /* 155 × 1040/745 ≈ 216, the card aspect */
  justify-content: center;
  align-content: start;
  gap: 10px;
  margin-top: 8px;
  flex: 1 1 auto; /* take the remaining sheet height … */
  min-height: 0; /* … and allow shrinking so overflow-y actually scrolls */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.picker-cell {
  position: relative;
  height: 100%; /* fill the fixed 145px row track */
  border-radius: 8px;
  overflow: hidden;
  background: #100e09;
  border: 1px solid var(--panel-line);
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.picker-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Inset, not offset: an outline drawn outside the cell gets clipped by the
   grid's own overflow-y scroller, so the gold box lost its top and bottom edges
   (Gavin, 2026-07-21). Drawing it inside can't be clipped by anything. */
.picker-cell:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
.picker-cell:active {
  transform: translateY(1px);
}
.picker-cell-dpi {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--gold-soft);
  border-radius: 5px;
  font-size: 0.62rem;
  font-weight: 700;
}

/* Help button (viewer header) + the help sheet (desktop `#deckHelpBtn` look).
   Header button is desktop-only; mobile uses the floating `.help-fab` below. */
.help-btn {
  display: none;
  background: transparent;
  border: 1px solid #3a3630;
  border-radius: 6px;
  color: #a89c86;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 12px;
  cursor: pointer;
  margin-left: auto;
}

/* Floating Help — phones only. Fixed to the bottom-right so it's reachable from
   any screen (including before a deck is resolved). Hidden on desktop, which
   keeps the header button. iOS safe-area padding keeps it off the home bar. */
.help-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #17140a;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.help-fab:active {
  transform: translateY(1px);
}
/* Desktop keeps Help in the review header and drops the floating FAB. Placed
   after the base rules above so it wins the cascade at >=900px. */
@media (min-width: 900px) {
  .viewer-head .help-btn {
    display: inline-flex;
  }
  .help-fab {
    display: none;
  }
  /* The 150% pass, desktop half (Gavin, web-0.37.0). 155 → 232, with the row
     track following the card aspect as before (232 × 1040/745 ≈ 324).
     Deliberately gated at 900px rather than applied globally: measured on a
     390px phone, 232px cells fit ONE across instead of two, leaving 92px of
     dead gutter and a picker that can't compare two artworks — the opposite of
     what a bigger picture is for. The phone keeps 155 and the desktop, where
     the room actually exists, gets the enlargement.
     `.sheet--picker` widens in step, or four across would have become two. */
  .picker-grid {
    grid-template-columns: repeat(auto-fill, 232px);
    grid-auto-rows: 324px;
  }
}
.help-btn:hover {
  color: #d98a1f;
  border-color: #d98a1f;
}
.viewer-head .help-btn {
  flex: none;
}
.viewer-head .summary {
  margin-left: 0;
}
.sheet--help {
  max-width: 560px;
}
.help-body {
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.help-section {
  color: #cbbf9f;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 16px 0 8px;
}
.help-section:first-child {
  margin-top: 0;
}
.help-list {
  margin: 0;
}
.help-list dt {
  color: #f2b24c;
  font-size: 0.88rem;
  font-weight: 700;
  margin: 8px 0 2px;
}
.help-list dd {
  color: #a89c86;
  font-size: 0.88rem;
  margin: 0;
}

/* First-visit guide (web-0.32.4). Shares the help sheet's frame; the type is a
   step above the reference list's, because this one is read once by someone who
   has never seen the page and shouldn't have to squint at it. */
.welcome-lead {
  color: var(--ink);
  font-size: 0.95rem;
  margin: 0 0 14px;
}
.welcome-steps {
  margin: 0;
  padding-left: 22px;
  color: #a89c86;
  font-size: 0.9rem;
}
.welcome-steps li {
  margin-bottom: 12px;
}
.welcome-steps li::marker {
  color: var(--gold);
  font-weight: 700;
}
.welcome-steps strong {
  color: #f2b24c;
  font-weight: 700;
}
.welcome-steps em {
  color: var(--ink);
  font-style: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}
.welcome-foot {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 14px 0 0;
}
/* Sits outside .help-body so it can't scroll away from the text it dismisses. */
/* The guide's "Don't show this again" tick (web-0.42.0): sits between the
   text and the buttons, like the send sheet's option. */
.welcome-again {
  margin: 12px 0 0;
  flex-shrink: 0;
}
.welcome-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-shrink: 0;
}

/* Card-actions sheet: a small centered menu (Move to / per-copy art / Delete),
   sharing the picker's overlay styling. */
.sheet--menu {
  max-width: 360px;
}
.menu-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Where the chosen art came from (web-0.21.0). Information, not an action —
   styled deliberately unlike .menu-btn so it isn't tapped at. */
.menu-info {
  margin: 0 0 2px;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--panel-line);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}
.menu-btn {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-line);
  background: #201c13;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.menu-btn:active {
  transform: translateY(1px);
}
/* Armed destructive state ("Really delete …?") + the delete row itself. */
.menu-btn-delete {
  color: var(--error);
}
.menu-btn.danger {
  border-color: rgba(229, 129, 122, 0.6);
  background: rgba(229, 129, 122, 0.12);
  color: var(--error);
}

/* Merge confirm sheet — warning text over a Cancel / Merge row. */
.confirm-message {
  margin: 0 0 4px;
  color: var(--ink);
  line-height: 1.45;
  /* The text is set with textContent, so line breaks in a message would
     otherwise collapse to spaces — the send warning uses one to separate what
     happens from what it costs. */
  white-space: pre-line;
}
/* The confirm sheet's optional tick-box (web-0.39.0). Sits between the warning
   and the buttons — it is a decision about the action, so it must be read
   before the button that takes it, not after. The extra bottom margin keeps it
   from reading as a label on the button row. */
.confirm-opt {
  margin: 2px 0 14px;
  color: var(--ink);
}
/* An author display rule beats the UA's [hidden]{display:none} — the same trap
   as .code-box. .opt-check sets display, so every confirm sheet was painting
   an empty tick-box; .confirm-pick would paint an empty dropdown (web-0.45.6). */
.confirm-opt[hidden],
.confirm-pick[hidden] {
  display: none;
}

/* The commander question's dropdown (web-0.45.6) — full width so a long
   legend's name isn't clipped on a phone. */
.confirm-pick {
  display: block;
  width: 100%;
  margin: 8px 0 14px;
  background-color: #100e09;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  color: var(--gold-soft);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  cursor: pointer;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  /* Three buttons fit a desktop row but not a phone's, and a wrapped label in a
     squeezed button is how a choice gets misread. Wrapping is the safety net
     (web-0.32.3) — with two buttons nothing changes. */
  flex-wrap: wrap;
}
.confirm-actions .menu-btn {
  flex: 1 1 120px; /* a floor wide enough to read; below it they stack */
  text-align: center;
}

/* Step 1's from-scratch route — deliberately quieter than Resolve, which is
   still the main way in for anyone holding a decklist (web-0.32.3). */
/* A quiet text link, NOT a `.btn` (Gavin, web-0.32.6). As a full-width button it
   sat directly under Resolve and competed with it, when it's the rarer way in.
   Kept rather than removed: without it a blank page has no way to build card by
   card at all, which is the whole point of web-0.32.3. Padded to a 44px tap
   target even though it reads as text — it's a phone-first UI. */
.start-empty {
  display: block;
  margin: 10px auto 0;
  padding: 11px 8px; /* measured: 45px tall, clears the 44px minimum */
  background: none;
  border: 0;
  color: var(--gold-soft);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.start-empty:hover {
  color: var(--gold);
}
/* An author display rule beats the UA's [hidden]{display:none} — so without this
   the button stayed on screen after a deck existed, while `.hidden` read true.
   Same trap as `.hover-preview[hidden]`. Seen in a screenshot, not reasoned
   about; still needed now `display:block` is set here rather than by `.btn`. */
.start-empty[hidden] {
  display: none;
}

/* Tap targets: kill the iOS double-tap-zoom delay/absorption so a quick tap
   always registers as a click (fixes "tapping does nothing" on iPhone — e.g.
   opening the ⋯ menu then tapping Move to / a section tab in quick succession).
   Every interactive control here is a <button>, so one rule covers them all. */
button {
  touch-action: manipulation;
}

/* Hover-to-enlarge preview: a floating card-sized image, positioned in JS.
   pointer-events:none so it never eats the mouse; above the sheet (z 50). */
.hover-preview {
  position: fixed;
  z-index: 100;
  /* 510px, up from 340 (Gavin's 150% pass, web-0.37.0; 340 was itself up from
     230 in web-0.31.3) — the point of the preview is to read the card, so it may
     as well be worth stopping for. The 64vh arm is a guard, not the usual case:
     height is width × 1040/745, so 64vh keeps the whole card inside a short
     window (64 × 1.396 ≈ 89vh) instead of running off the top and bottom, which
     the JS clamp can only slide, never shrink. **It stays 64vh**: scaling that
     arm by 150% too would put the card's height past the viewport, which is the
     one thing it exists to prevent. On a short laptop the vh arm now binds
     first, so the preview grows with the window rather than jumping to 510. */
  width: min(510px, 64vh);
  /* The box carries the card shape itself now (web-0.32.1). It used to inherit
     its height from the <img>, which stops working the moment the image is
     absolutely positioned to crop MPC bleed — the box would collapse to nothing
     and the preview would vanish. */
  aspect-ratio: 745 / 1040;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
  background: #100e09;
}
.hover-preview[hidden] {
  display: none; /* author display would otherwise beat the UA [hidden] rule */
}
.hover-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* MPC art carries 3mm of bleed on every edge of a 69×94mm card, which the forge
   trims before printing (core/preprocessing.bleed_box — the one definition, and
   the desktop's own picker crops its previews the same way). Untrimmed, the
   picker, the deck tile and the printed card all disagree about where the card
   ends, which is what Gavin saw as "the MPC art shows the extra bleed".

   Scaling the image up and pulling it back by the margin, inside an
   overflow:hidden box, is the CSS equivalent of Pillow's crop. The numbers are
   that arithmetic, once, rather than a guess:
     width  1 / (1 − 2·3/69) = 109.5238%   left  −(3/69)·109.5238% = −4.7619%
     height 1 / (1 − 2·3/94) = 106.8182%   top   −(3/94)·106.8182% = −3.4091%
   Every box using it must be a positioned, clipping ancestor, and must be named
   in the selector below. That list is not decoration: `.card-thumb img` and
   `.picker-cell img` are specificity 0,1,1 and a bare `.art-bleed` is 0,1,0, so
   they win the width/height and the image gets the offsets WITHOUT the scaling
   — sliding up and left, leaving a gap at the right and bottom instead of
   trimming anything. That shipped-looking-fine in a static test and was only
   caught by measuring a real picker cell (153px where 168 was intended). A new
   container for card art must be added here, or it gets the same silent half-fix. */
.card-thumb img.art-bleed,
.picker-cell img.art-bleed,
.hover-preview img.art-bleed {
  position: absolute;
  left: -4.7619%;
  top: -3.4091%;
  width: 109.5238%;
  height: 106.8182%;
  max-width: none; /* beats the global img { max-width: 100% } reset */
  object-fit: fill; /* the box IS the trimmed card, so fill it exactly */
}

/* Add cards to a resolved deck (web-0.27.2). Mirrors the desktop's
   AddCardsDialog: a Type tab with Scryfall suggestions staged into a list, a
   Paste tab, and one section dropdown that applies to everything above it. */
.deck-add-btn {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--gold);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.deck-add-btn:hover {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
}

.sheet--add {
  max-width: 480px;
}
.add-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
}
.add-tab {
  flex: 1 1 0;
  padding: 8px 10px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.add-tab.is-on {
  border-color: var(--gold);
  color: var(--ink);
  background: rgba(212, 175, 55, 0.08);
}
.add-pane {
  min-height: 0;
  overflow-y: auto;
}
.add-qty-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-top: 8px;
}
.add-qty {
  /* Sized by its contents, NOT a fixed width. It was pinned at 90px back when
     it held a bare number input; the −/+ buttons then took 80px of that and
     squeezed the number itself down to 10px — invisible. */
  flex: 0 0 auto;
  margin: 0;
}
.add-qty-row .btn {
  width: auto;
  flex: 0 0 auto;
}
.add-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 8px 0 4px;
}

/* The destination dropdown carries the same colours as the sort one; the shared
   rule above gives both the gold arrow. */
#addSection {
  width: 100%;
  background-color: #100e09;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;   /* >=16px stops iOS zoom-on-focus, as elsewhere */
  padding: 12px 28px 12px 14px;
  cursor: pointer;
}
#addSection:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

/* Quantity stepper (web-0.27.3). The native number-input spinner is a pair of
   pale grey arrows the page can't recolour — and iOS Safari draws no stepper at
   all, so on a phone there was nothing to tap. Hidden, and replaced with real
   buttons that match the theme and work everywhere. */
.qty-step-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.qty-step {
  flex: 0 0 auto;
  width: 40px;
  border: 1px solid var(--panel-line);
  background: #201c13;
  color: var(--gold);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  /* Comfortably tappable on a phone, matching .btn's min-height. */
  min-height: 48px;
}
.qty-step:first-child {
  border-radius: 10px 0 0 10px;
  border-right: 0;
}
.qty-step:last-child {
  border-radius: 0 10px 10px 0;
  border-left: 0;
}
.qty-step:hover {
  background: rgba(212, 175, 55, 0.14);
}
.qty-step:disabled {
  color: var(--muted);
  opacity: 0.5;
  cursor: default;
  background: #201c13;
}
.qty-step-group input[type="number"] {
  /* Explicit and non-shrinkable: `width: 100%` + `min-width: 0` let the number
     collapse to nothing when the row got tight. */
  flex: 0 0 56px;
  width: 56px;
  text-align: center;
  border-radius: 0;
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  font: inherit;
  font-size: 16px;
  padding: 12px 4px;
}
.qty-step-group input[type="number"]:focus {
  outline: none;
  border-color: var(--gold);
  position: relative;
  z-index: 1;
}
/* Hide the native spinner in every engine — the custom buttons replace it. */
.qty-step-group input[type="number"]::-webkit-inner-spin-button,
.qty-step-group input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-step-group input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Suggestions sit directly under the field they complete. Capped and scrollable
   so a broad prefix can't push the rest of the dialog off-screen. */
.add-suggest {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  /* Suggestions are capped at 8, ~38px each, so 304px shows the lot and there is
     usually nothing to scroll at all (web-0.31.4). It was 168px, which cut the
     list off mid-item — the screenshot Gavin sent. The 45vh arm keeps it off a
     short screen's edges; past that it scrolls, which now works. */
  max-height: min(304px, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain; /* don't hand a finished scroll to the page */
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--bg);
}
.add-suggest-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
}
/* Hover and the arrow-key highlight are deliberately the SAME look (web-0.31.6):
   whichever one you're using, the highlighted row is the one Enter takes. */
.add-suggest-item:hover,
.add-suggest-item.is-active {
  background: rgba(212, 175, 55, 0.12);
  color: var(--gold);
}

.add-staged {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 150px;
  overflow-y: auto;
}
.add-staged-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  margin-bottom: 5px;
  font-size: 0.88rem;
  color: var(--ink);
}
.add-staged-drop {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.add-staged-drop:hover {
  color: var(--error);
}

.add-foot {
  border-top: 1px solid var(--panel-line);
  margin-top: 12px;
  padding-top: 12px;
}
.add-dest {
  display: block;
  margin-bottom: 8px;
}
.add-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.add-actions .btn {
  width: auto;
}
.add-foot .status:empty {
  display: none;
}

/* The picker's suggestion list (web-0.27.5). Shares .add-suggest's look, but
   DROPS OVER the results grid rather than sitting in the sheet's flex column
   (web-0.31.0).

   As a flex sibling it was a height rival to the grid, and flexbox settles that
   fight by basis: the grid's basis is its full content height (20 000px with a
   few hundred artworks), so it absorbed almost nothing and the list was squashed
   to about 3px — a gold sliver you could neither read nor scroll. Taking it out
   of flow means neither can starve the other. */
.sheet-search-wrap {
  position: relative;
  flex: 0 0 auto; /* the search row itself must never be shrunk either */
}
.picker-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 10; /* over the grid, under nothing else in the sheet */
  margin: 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

/* ── Invite admin (/admin, web-0.33.0) ───────────────────────────────────────
   Gavin's phone view of the desktop Invites dialog. Reuses the builder's
   .panel/.btn/.status/.sheet furniture on purpose — a second visual language
   for the same brand would be work to build and work to keep in step. Only
   what has no equivalent there is defined here. */

/* The builder sets `.masthead { display: none }` — it IS the app there. This
   page needs a title, so it gets its own class rather than an override. */
.admin-masthead {
  text-align: center;
  padding: 8px 0 4px;
}
.admin-masthead h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  letter-spacing: 0.04em;
  color: var(--gold);
  margin: 0;
  text-shadow: 0 2px 12px rgba(212, 175, 55, 0.25);
}

/* The admin sheets are TALL — facts, then four actions, then extend, greeting
   and the two destructive buttons — and `.sheet` is capped at 88vh. Without
   this the overflow had nowhere to go and Delete simply couldn't be reached on
   a 390×844 phone: the element reported 316px of overflow and refused to
   scroll, because a flex ITEM won't shrink below its content unless min-height
   is cleared. `min-height: 0` is the load-bearing line, not `overflow-y`.
   Caught by measuring the button's position against the viewport; it looked
   perfectly fine in a screenshot of the top of the sheet.
   `.sheet-body` exists only on this page — the builder's sheets don't use it. */
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

#loginForm input {
  width: 100%;
  padding: 12px;
  background: #0f0e0a;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* >=16px stops iOS zooming the page on focus */
  margin-bottom: 12px;
}
#loginForm input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}
#loginForm .btn {
  width: 100%;
}

.admin-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.admin-signout {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px 0;
  cursor: pointer;
}

.admin-filter {
  display: flex;
  gap: 8px;
  margin: 12px 0 4px;
}
.admin-filter .picker-tab {
  flex: 1;
}

.invite-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* The whole row is the tap target — on a phone, a small chevron somewhere on
   the right is a miss waiting to happen. */
.invite-row-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: #14120d;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.invite-row-btn:hover {
  border-color: var(--gold);
}
.invite-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.invite-name {
  font-weight: 600;
  color: var(--gold-soft);
  /* A long name must not shove the status pill off the row. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invite-sub {
  color: var(--muted);
  font-size: 0.88rem;
}

.invite-pill {
  flex: none;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  font-size: 0.78rem;
  text-transform: lowercase;
  color: var(--muted);
}
.invite-pill.is-active {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}
.invite-pill.is-revoked,
.invite-pill.is-expired {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
}

/* Facts read as label/value pairs. Two columns on a phone would squeeze the
   link into unreadable slivers, so the label sits above its value. */
.admin-facts {
  margin: 0;
}
.admin-facts dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 12px;
}
.admin-facts dd {
  margin: 2px 0 0;
  /* A link or a token has no spaces to break at and would otherwise widen the
     whole sheet — the one thing a phone layout can't absorb. */
  overflow-wrap: anywhere;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
/* `.btn` is width:100%, which stacked these four one per row and pushed the
   rest of the sheet off a phone screen. Two to a row instead — measured at
   390px, where 45% leaves room for the gap. */
.admin-actions .btn {
  width: auto;
  flex: 1 1 45%;
  min-width: 8rem;
}

.admin-new {
  margin-top: 4px;
}
/* The number field is a stub of a thing at full width — a 3-digit day count
   doesn't need 350px, and shrinking it stops it reading as a text box. */
#daysField input {
  width: 8rem;
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* >=16px stops iOS zoom-on-focus */
}
/* A code is read off one screen and typed into another — same treatment as the
   builder's code box, for the same reason. */
#newCode {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
#modeHint {
  margin: 8px 0 0;
}
/* The shared textarea rule is 120px tall, sized for pasting a decklist. Here it
   pushed Create invite off the bottom of a phone screen, and a greeting is a
   sentence. Measured on a 390×844 viewport, not guessed. */
#newGreeting {
  min-height: 70px;
}

/* Action groups in the detail sheet, each separated from the facts above so a
   destructive button is never adjacent to a harmless one by accident. */
.admin-sub {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-line);
}
.admin-sub .field-label {
  margin-bottom: 8px;
}
.admin-sub textarea {
  min-height: 64px;
  margin-bottom: 8px;
}
.admin-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.admin-inline input {
  width: 6.5rem;
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
}
.admin-inline .btn {
  flex: 1;
}
/* The code row reverses those proportions (web-0.35.1). A code runs to 24
   characters and has to be readable and editable; "7" never needs more than the
   numeric width. Sharing the rule gave the input 104px and the button 212px —
   measured, not guessed. `min-width: 0` is what actually lets the input shrink
   and grow inside the flex row rather than sitting at its intrinsic size. */
.admin-inline--grow input {
  width: auto;
  flex: 1;
  min-width: 0;
}
/* `width: auto` is not redundant next to `flex: 0 0 auto`. `.btn` is
   `width: 100%` for the full-width mobile buttons everywhere else, and a basis
   of `auto` reads that width — so the button sat at 324px and squeezed the
   input to 30px, worse than the shared rule it was meant to fix. */
.admin-inline--grow .btn {
  flex: 0 0 auto;
  width: auto;
}
.admin-danger {
  display: flex;
  gap: 8px;
}
/* Error-toned but not solid red: these are ordinary housekeeping most days,
   and a wall of red would make the sheet read as a warning screen. The
   confirmation is the two-tap, not the colour. */
.admin-danger .btn {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 35%, var(--panel-line));
}
.admin-danger .btn[hidden] {
  display: none; /* .btn sets inline-flex — the same [hidden] trap as elsewhere */
}

/* The lite deployment (web-0.43.0): FORGE_LITE=1 puts .lite on <body> and
   these go. Import a deck (link or list), pick the art, send — nothing else. */
body.lite .file-import,
body.lite #addCardsBtn,
body.lite #startEmptyBtn,
body.lite #submitterField,
body.lite #inviteBanner,
body.lite .url-import .field-label,
body.lite .url-import .url-sites,
body.lite #codeBox {
  display: none !important;
}

/* /admin refund (web-0.47.0): a destructive action, so it wears the same red
   as the builder's Remove — and asks twice. */
.btn.danger {
  border-color: rgba(229, 129, 122, 0.6);
  background: rgba(229, 129, 122, 0.12);
  color: var(--error);
}
#refundBox { margin-top: 14px; }
/* The order sheet hides controls with the `hidden` attribute; .btn and .field
   set their own display, which beat it — Clear flag and the tracking box
   showed on every order (web-0.46.0 bug, fixed web-0.47.0). */
#orderSheet [hidden] { display: none !important; }

/* ── Site bar on the builder (web-0.48.5) ─────────────────────────────────
   The builder had no way back to the home page. Same centred brand as the
   other pages' top bar (site.css), kept slim: the builder is the app, so the
   bar mustn't eat the room the cards need. */
.site-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 14px;
}
.site-home {
  justify-self: start;
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 10px;
  border: 1px solid #4a4034;
  border-radius: 8px;
  white-space: nowrap;
}
.site-home:hover { background: #1a1712; }
.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.site-brand img { height: 60px; width: auto; display: block; }
.site-brand span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  color: var(--gold);
  white-space: nowrap;
}
@media (max-width: 420px) {
  .site-brand img { height: 48px; }
  .site-brand span { font-size: 1rem; }
  .site-home { font-size: 0.82rem; padding: 5px 8px; }
}
@media (min-width: 900px) {
  .site-top {
    flex: none;
    padding: 8px 18px;
    border-bottom: 1px solid #242421;
    background: #121210;
  }
}

/* /admin Stock tab (web-0.53.0): a panel per supply, not a button — the row
   holds its own controls. Same card look as .invite-row-btn. */
.stock-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #14120d;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
}
.stock-row .invite-pill {
  font-size: 15px;
  min-width: 3ch;
  text-align: center;
}
.stock-controls input {
  width: 4.5rem;
  flex: 0 0 auto;
}
.stock-controls .btn {
  width: auto;
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
}
.stock-warn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stock-warn input {
  width: 5.5rem;
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
}

/* Add a material + Remove (web-0.53.2). */
.stock-new { margin: 10px 0; }
.stock-new > input {
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
}
.stock-new .stock-controls input { width: auto; flex: 1; min-width: 0; }
.stock-new .stock-controls .btn { flex: 0 0 auto; padding-left: 18px; padding-right: 18px; }
.stock-remove {
  align-self: flex-end;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
/* Edit order (web-0.53.5): name-only rows with a ☰ handle to drag. */
.stock-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stock-edit-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}
.stock-name-input {
  flex: 1;
  min-width: 0;
  margin-right: 8px;
}
.stock-handle {
  font-size: 22px;
  color: var(--gold);
  padding: 4px 8px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stock-edit-row.is-dragging {
  position: relative;
  z-index: 2;
  border-color: var(--gold);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.stock-edit-row.is-dragging .stock-handle { cursor: grabbing; }

/* /admin Shop tab (web-0.55.0): accessories, each opening into its editor. */
.acc-top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.acc-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.acc-words { display: flex; flex-direction: column; min-width: 0; }
.acc-editor { display: flex; flex-direction: column; gap: 10px; }
.acc-field { display: flex; flex-direction: column; gap: 4px; }
.acc-field input, .acc-field textarea {
  background: #100e09;
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
}
.acc-show { display: flex; align-items: center; gap: 8px; }
.acc-show input { width: 20px; height: 20px; accent-color: var(--gold); }
.acc-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.acc-tile {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  overflow: hidden;
  background: #0a0908;
  display: flex;
  align-items: center;
  justify-content: center;
}
.acc-tile.is-main { border-color: var(--gold); }
.acc-tile img { width: 100%; height: 100%; object-fit: cover; }
.acc-video { color: var(--gold); font-size: 28px; }
.acc-star, .acc-del {
  position: absolute;
  bottom: 4px;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--gold);
  font: inherit;
  font-size: 13px;
  padding: 4px 7px;
  cursor: pointer;
}
.acc-star { left: 4px; }
.acc-del { right: 4px; color: #e8bdbd; }

/* The basket button on the builder's site bar (web-0.57.0); the other pages
   style theirs in site.css. */
.site-top-end { justify-self: end; }
.site-home.basket-tab { display: inline-flex; align-items: center; gap: 6px; }
.site-home .basket-icon { flex: none; }
.site-home .basket-count {
  min-width: 1.45em;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f2b24c;
  color: #1a1207;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}
.site-home .basket-count[hidden] { display: none; }
@media (max-width: 420px) {
  .site-home.basket-tab > span:not(.basket-count) { display: none; }
}

/* 0.80.0: Gloss / Matte for an eBay order that sold both finishes. */
.finish-field {
  grid-column: 1 / -1;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
}
.finish-field[hidden] { display: none; }
.finish-field legend { float: left; margin-right: 6px; padding: 0; }
.finish-option { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
