/* MTG Card Viewer — dark forest palette, flat surfaces, one accent.
   Layout: fixed topbar (brand · search · random), a navigation rail, and a
   single content surface that swaps views.  No panel-inside-panel. */

:root {
  --bg: #0b100d;
  --rail: #0d1310;
  --surface: #111814;
  --elevate: #16201a;
  --sunken: #0a0f0c;

  --line: rgba(142, 190, 152, 0.11);
  --line-2: rgba(142, 190, 152, 0.22);

  --text: #e7e6dc;
  --dim: #93a08d;
  --faint: #6b7a68;

  --gold: #d6b475;
  --gold-soft: rgba(214, 180, 117, 0.13);
  --leaf: #8cc077;
  --danger: #e0736a;

  --brown: #46341f;
  --brown-hi: #5a4429;
  --bronze: #6b4f33;

  --r: 10px;
  --r-sm: 7px;
  --topbar-h: 58px;
  --rail-w: 208px;

  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "Consolas", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* Bulk selection shares the same controls in grid, list, and deck views. */
.selection-bar { margin: 0 0 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.selection-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.selection-actions select { max-width: 240px; }
.selection-help { color: var(--dim); font-size: 12px; }
.selection-result { flex-basis: 100%; margin: 0; color: var(--dim); overflow-wrap: anywhere; }
.selection-result:empty { display: none; }
.coll-card { position: relative; }
.card-select { position: absolute; top: 5px; left: 5px; z-index: 5; width: 26px; height: 26px;
  display: grid; place-items: center; border: 1px solid var(--gold); border-radius: 5px;
  background: var(--surface); color: var(--gold); cursor: pointer; font: 700 16px var(--sans);
  opacity: 0; }
.coll-card:hover > .card-select, .stack-card:hover > .card-select,
.coll-card:focus-within > .card-select, .stack-card:focus-within > .card-select,
.selecting-cards .card-select { opacity: 1; }
.card-select[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.card-select:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.coll-card.card-selected, .stack-card.card-selected { outline: 3px solid var(--gold); outline-offset: 1px; }
.selecting-cards .coll-card, .selecting-cards .stack-card { user-select: none; }
.selecting-cards .drop, .selecting-cards .cmd, .selecting-cards .steppers { visibility: hidden; }
.coll-grid.list-view.selecting-cards .coll-card { padding-left: 38px; }
@media (hover: none) { .card-select { opacity: 1; } }

/* Author `display` beats the UA [hidden] rule; views set display, so say it. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--sans);
  font-size: calc(13px * var(--text-scale, 1));
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sub { margin: 3px 0 0; font-size: calc(12px * var(--text-scale, 1)); color: var(--dim); }
.empty { font-size: calc(12.5px * var(--text-scale, 1)); color: var(--faint); margin: 2px; line-height: 1.6; }
.empty b { color: var(--dim); font-weight: 600; }

/* ------------------------------------------------------------- topbar */

.topbar {
  position: relative;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--rail);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--display);
  font-size: calc(14px * var(--text-scale, 1));
  letter-spacing: 0.01em;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  padding: 6px 8px;
  border-radius: var(--r-sm);
}

.brand:hover { background: var(--elevate); }
.brand .mark { width: 19px; height: 19px; color: var(--gold); }

.searchbar {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: 460px;
}

.searchbar > .ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

#search {
  width: 100%;
  font: 400 calc(13px * var(--text-scale, 1)) var(--sans);
  color: var(--text);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px 9px 34px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

#search::placeholder { color: var(--faint); }
#search:focus { border-color: var(--line-2); background: #0c1410; }
#search:focus + .suggestions { display: block; }

.suggestions {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: var(--elevate);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  max-height: 320px;
  overflow-y: auto;
}

.suggestions li {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: calc(12.5px * var(--text-scale, 1));
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestions li:hover,
.suggestions li.active { background: var(--gold-soft); color: var(--gold); }

/* indeterminate loading line under the topbar */
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}

body.busy .progress { opacity: 1; }

.progress::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: sweep 1.1s ease-in-out infinite;
}

@keyframes sweep {
  from { transform: translateX(-110%); }
  to { transform: translateX(400%); }
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: 500 calc(12.5px * var(--text-scale, 1)) var(--sans);
  color: var(--text);
  background: var(--elevate);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.btn:hover:not(:disabled) { background: #1c2820; border-color: var(--line-2); }
.btn:disabled { opacity: 0.38; cursor: default; }
.btn.block { width: 100%; }

.btn.primary {
  background: linear-gradient(180deg, var(--brown-hi), var(--brown));
  border-color: var(--bronze);
  color: #f2e6d2;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6b5033, var(--brown-hi));
}

.btn.quiet { background: transparent; }
.btn.quiet:hover:not(:disabled) { background: var(--elevate); }

.btn.danger { color: var(--danger); border-color: rgba(224, 115, 106, 0.3); }
.btn.danger:hover:not(:disabled) { background: rgba(224, 115, 106, 0.12); }
.btn.armed {
  background: var(--danger);
  border-color: var(--danger);
  color: #1a0d0c;
  font-weight: 600;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.icon-btn:hover { background: var(--elevate); color: var(--gold); border-color: var(--line); }

.link-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 8px;
  font: 400 calc(11.5px * var(--text-scale, 1)) var(--sans);
  color: var(--faint);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.link-btn:hover { color: var(--dim); background: var(--elevate); }
.link-btn .ico { width: 13px; height: 13px; }

/* --------------------------------------------------------------- rail */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: calc(100% - var(--topbar-h));
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px 10px;
  background: var(--rail);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  font: 500 calc(12.5px * var(--text-scale, 1)) var(--sans);
  color: var(--dim);
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
}

.nav:hover { background: var(--elevate); color: var(--text); }
.nav .ico { color: var(--faint); }
.nav:hover .ico { color: var(--dim); }

.nav.active { background: var(--gold-soft); color: var(--gold); }
.nav.active .ico { color: var(--gold); }

.count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font: 600 calc(10.5px * var(--text-scale, 1)) var(--sans);
  font-style: normal;
  color: inherit;
}

.rail-group { display: flex; flex-direction: column; min-height: 0; margin-top: 14px; }
.rail-group.grow { flex: 1 1 auto; }

.rail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 7px;
  font: 600 calc(10px * var(--text-scale, 1)) var(--sans);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
}

.rail-head .ico { width: 13px; height: 13px; }
.rail-head .icon-btn { margin-left: auto; }

.rail-empty { margin: 0 10px; font-size: calc(11.5px * var(--text-scale, 1)); color: var(--faint); }

.recent { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }

.recent li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: calc(12.5px * var(--text-scale, 1));
  color: var(--dim);
  cursor: pointer;
}

.recent li:hover { background: var(--elevate); color: var(--text); }

.dname, .rname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcount { margin-left: auto; font-size: calc(10.5px * var(--text-scale, 1)); color: var(--faint); }

.recent .dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }

.rail-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.credit { margin: 7px 8px 2px; font-size: calc(10.5px * var(--text-scale, 1)); line-height: 1.45; color: #55634f; }
.credit a { color: inherit; }

/* ------------------------------------------------------------- views */

.content { min-width: 0; background: var(--surface); overflow: hidden; }
.settings-body { display: flex; flex-direction: column; align-items: stretch; gap: 18px; padding: 18px 26px 28px; overflow-y: auto; }
.settings-section { flex-shrink: 0; }
.settings-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.settings-row select { max-width: 100%; padding: 7px 10px; color: var(--text); background: var(--sunken); border: 1px solid var(--line-2); border-radius: var(--r-sm); font: inherit; }
.settings-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 10px; }
.settings-password { display: grid; gap: 12px; margin-top: 18px; max-width: 380px; }
.settings-password label { display: grid; gap: 6px; }
.settings-password input { width: 100%; padding: 8px; color: var(--text); background: var(--sunken); border: 1px solid var(--line-2); border-radius: var(--r-sm); font: inherit; }
.settings-shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; }
.settings-shortcuts dt { color: var(--gold); }
.settings-shortcuts dd { margin: 0; }
.settings-section h3 { margin-top: 18px; }
.settings-section a { color: var(--gold); }
.backup-reminder { position: fixed; right: 20px; bottom: 20px; z-index: 120; max-width: min(440px, calc(100vw - 40px)); padding: 18px; border: 1px solid var(--gold); border-radius: var(--r); background: var(--elevate); box-shadow: 0 8px 30px #0003; }
.backup-reminder p { margin: 0 0 12px; }
:root[data-theme="light"] { --bg: #f3f5ef; --rail: #e8eee3; --surface: #fafbf7; --elevate: #fff; --sunken: #edf1e8; --line: #ced8c8; --line-2: #a1b399; --text: #203322; --dim: #4c624a; --faint: #63725d; --gold: #805712; --gold-soft: #ac812c18; --leaf: #396a27; --danger: #b32a32; --brown: #e9d6b3; --brown-hi: #f2dfbf; --bronze: #c2a477; }
:root[data-theme="light"] .credit { color: var(--dim); }
:root[data-theme="light"] .btn.primary { color: #382806; }
:root[data-theme="katrine"] {
  --bg: #0a0c15;
  --rail: #101323;
  --surface: #151b2d;
  --elevate: #1d263b;
  --sunken: #0c1120;
  --line: rgba(117, 151, 207, .17);
  --line-2: rgba(151, 179, 225, .34);
  --text: #f0edf4;
  --dim: #b2bbd2;
  --faint: #8793b0;
  --gold: #fa8c86;
  --gold-soft: rgba(231, 74, 92, .15);
  --leaf: #8bbff1;
  --danger: #ff657f;
  --brown: #742c49;
  --brown-hi: #a24059;
  --bronze: #b64f68;
}
:root[data-theme="katrine"] .topbar {
  background: linear-gradient(100deg, #17243e, #101323 54%, #321926);
  border-bottom-color: rgba(226, 88, 109, .35);
}
:root[data-theme="katrine"] .rail { background: linear-gradient(180deg, #121b32, #101323 48%, #1b1324); }
:root[data-theme="katrine"] .view-head { background: linear-gradient(90deg, rgba(57, 90, 147, .16), transparent 62%, rgba(148, 49, 69, .10)); }
:root[data-theme="katrine"] #search:focus { background: var(--sunken); border-color: #728fc6; }
:root[data-theme="katrine"] .btn:not(.primary):not(.danger):not(.armed):hover:not(:disabled) { background: #27334e; }
:root[data-theme="katrine"] .btn.primary { color: #fff3f1; }
:root[data-theme="katrine"] .btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #bb4b60, var(--brown-hi)); }
:root[data-theme="katrine"] .chip.legal,
:root[data-theme="katrine"] .loc.free,
:root[data-theme="katrine"] .legality.ok { border-color: rgba(139, 191, 241, .36); }
:root[data-theme="katrine"] .chip.restricted,
:root[data-theme="katrine"] .deck-price { border-color: rgba(250, 140, 134, .38); }
:root[data-theme="katrine"] .credit { color: var(--faint); }
:root[data-theme="katrine"] ::-webkit-scrollbar-thumb { background: #364363; }
:root[data-theme="katrine"] ::-webkit-scrollbar-thumb:hover { background: #526385; }
:root[data-theme="ty"] {
  --bg: #0c1724;
  --rail: #122638;
  --surface: #1a3143;
  --elevate: #254257;
  --sunken: #0b1b2a;
  --line: rgba(143, 190, 215, .22);
  --line-2: rgba(171, 220, 243, .46);
  --text: #eff7fc;
  --dim: #b8cfde;
  --faint: #91adbe;
  --gold: #70ebd7;
  --gold-soft: rgba(86, 226, 202, .18);
  --gold-border: rgba(112, 235, 215, .47);
  --leaf: #c1a1ff;
  --leaf-border: rgba(193, 161, 255, .45);
  --danger: #ff91a7;
  --brown: #4c419a;
  --brown-hi: #286e9b;
  --bronze: #a787ed;
  --scrollbar: #476b80;
  --scrollbar-hover: #6d9aae;
}
:root[data-theme="ty"] .topbar {
  background: linear-gradient(90deg, #b486f5, #59e5d3 54%, #ff91ad) bottom / 100% 3px no-repeat,
    radial-gradient(circle at 18% -90%, rgba(181, 120, 246, .55), transparent 44%),
    radial-gradient(circle at 82% 150%, rgba(57, 219, 197, .38), transparent 47%),
    linear-gradient(110deg, #2b315b, #142c43 55%, #23485a);
  border-bottom-color: transparent;
}
:root[data-theme="ty"] .rail {
  background: radial-gradient(circle at -20% 5%, rgba(165, 104, 239, .31), transparent 50%),
    radial-gradient(circle at 120% 78%, rgba(50, 212, 192, .26), transparent 55%),
    linear-gradient(180deg, #212a4a, #122b3e 58%, #1c3043);
}
:root[data-theme="ty"] .view-head {
  background: radial-gradient(ellipse at 5% -40%, rgba(172, 113, 244, .44), transparent 54%),
    radial-gradient(ellipse at 78% 130%, rgba(60, 226, 199, .29), transparent 45%),
    linear-gradient(110deg, #283a64, #1c4457 65%, #2b5360);
  border-bottom-color: rgba(112, 235, 215, .48);
}
:root[data-theme="ty"] .content { background: radial-gradient(circle at 95% 2%, rgba(174, 105, 233, .11), transparent 36%), radial-gradient(circle at 4% 98%, rgba(47, 218, 194, .10), transparent 38%), var(--surface); }
:root[data-theme="ty"] .brand { color: #e5dcff; text-shadow: 0 0 12px rgba(181, 130, 245, .34); }
:root[data-theme="ty"] .brand .mark { color: #70ebd7; filter: drop-shadow(0 0 6px rgba(112, 235, 215, .65)); }
:root[data-theme="ty"] .rail-head { color: #c7a9ff; }
:root[data-theme="ty"] .nav.active { color: #ddfff7; background: linear-gradient(90deg, rgba(151, 94, 225, .45), rgba(57, 218, 191, .19)); box-shadow: inset 4px 0 0 #c49bff, 0 0 18px rgba(75, 210, 197, .14); }
:root[data-theme="ty"] .nav.active .ico { color: #95f9e5; }
:root[data-theme="ty"] .view-head h1 { color: #f2e9ff; text-shadow: 0 2px 15px rgba(183, 123, 243, .37); }
:root[data-theme="ty"] .settings-section { border-color: rgba(174, 133, 238, .39); box-shadow: inset 0 2px 0 rgba(113, 234, 213, .43), 0 13px 34px rgba(83, 59, 159, .17); }
:root[data-theme="ty"] .settings-section h2,
:root[data-theme="ty"] .deck-folder h2 { color: #d5baff; }
:root[data-theme="ty"] .btn.primary { color: #f8fcff; background: linear-gradient(115deg, #6249a6, #236f99); border-color: #9e92e8; box-shadow: 0 5px 18px rgba(89, 79, 188, .24); }
:root[data-theme="ty"] .btn.primary:hover:not(:disabled) { background: linear-gradient(115deg, #7357b9, #286e98); border-color: var(--gold); box-shadow: 0 6px 22px rgba(63, 214, 195, .24); }
:root[data-theme="ty"] .qty { background: #26315a; border-color: #b68cec; color: #89f2dd; }
:root[data-theme="ty"] .deck-directory-card:hover { border-color: #c49bff; box-shadow: 0 0 0 1px rgba(112, 235, 215, .38), 0 10px 25px rgba(54, 171, 177, .18); }

:root[data-theme="ethan"] {
  --bg: #070b17;
  --rail: #111b37;
  --surface: #142c55;
  --elevate: #173a78;
  --sunken: #0a1b3b;
  --line: rgba(112, 172, 255, .32);
  --line-2: rgba(165, 204, 255, .59);
  --text: #f1f5ff;
  --dim: #bdcee8;
  --faint: #8fa9ca;
  --gold: #ffdf49;
  --gold-soft: rgba(255, 221, 63, .20);
  --gold-border: rgba(255, 223, 73, .61);
  --leaf: #63d4ff;
  --leaf-border: rgba(99, 212, 255, .50);
  --danger: #ff646d;
  --brown: #0a4bb1;
  --brown-hi: #1463d4;
  --bronze: #4a9ef3;
  --scrollbar: #315887;
  --scrollbar-hover: #4e8bc7;
}
:root[data-theme="ethan"] .topbar {
  background: linear-gradient(90deg, #ffe344 0 7px, transparent 7px),
    repeating-linear-gradient(122deg, transparent 0 34px, rgba(255, 233, 94, .18) 34px 40px, transparent 40px 70px),
    linear-gradient(100deg, #071229, #0845a6 59%, #0474f0);
  border-bottom: 4px solid #ffdd38;
}
:root[data-theme="ethan"] .rail {
  background: radial-gradient(circle at 110% 83%, rgba(14, 98, 246, .43), transparent 52%),
    linear-gradient(180deg, #0c1730, #091225);
  border-right: 3px solid #ffdd38;
}
:root[data-theme="ethan"] .view-head {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: radial-gradient(circle at 86% 52%, #ffe245 0 16px, rgba(255, 226, 69, .22) 17px 47px, transparent 48px),
    repeating-conic-gradient(from 0deg at 86% 52%, rgba(255, 224, 67, .27) 0deg 9deg, transparent 9deg 22deg),
    linear-gradient(105deg, #07317c, #0861dc);
  border-bottom: 4px solid #081531;
}
:root[data-theme="ethan"] .view-head::before {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 38%;
  background: radial-gradient(#071a40 1px, transparent 1.4px) 0 0 / 8px 8px;
  opacity: .35;
  pointer-events: none;
}
:root[data-theme="ethan"] .view-head > * { position: relative; z-index: 1; }
:root[data-theme="ethan"] .view-head h1 { display: inline-block; padding: 3px 10px; background: #ffdc3d; color: #081630; font: 900 calc(22px * var(--text-scale, 1)) Impact, "Arial Black", var(--sans); letter-spacing: .055em; text-transform: uppercase; transform: rotate(-1deg); box-shadow: 4px 4px 0 #07132b; }
:root[data-theme="ethan"] .view-head .sub { color: #e8f1ff; text-shadow: 1px 1px 0 #0b2761; }
:root[data-theme="ethan"] .brand { color: #fff3a3; font: 900 calc(17px * var(--text-scale, 1)) Impact, "Arial Black", var(--sans); letter-spacing: .055em; text-transform: uppercase; text-shadow: 2px 2px 0 #06112a; }
:root[data-theme="ethan"] .brand .mark { color: #ffe044; filter: drop-shadow(2px 2px 0 #06112a); }
:root[data-theme="ethan"] .rail-head { color: #ffe56b; }
:root[data-theme="ethan"] .nav { border-radius: 3px; font-weight: 800; }
:root[data-theme="ethan"] .nav.active { background: #ffdf49; color: #07152f; box-shadow: 4px 4px 0 #050a17; transform: translate(-2px, -2px) rotate(-1deg); }
:root[data-theme="ethan"] .nav.active .ico { color: #07152f; }
:root[data-theme="ethan"] .nav.active .count { background: #07152f; color: #ffdf49; }
:root[data-theme="ethan"] .settings-section { border: 2px solid #4d97ed; border-radius: 5px; box-shadow: 6px 6px 0 #060c1c, inset 0 4px 0 #ffdf49; }
:root[data-theme="ethan"] .settings-section h2 { color: #ffdf49; font: 900 calc(22px * var(--text-scale, 1)) Impact, "Arial Black", var(--sans); letter-spacing: .05em; text-transform: uppercase; }
:root[data-theme="ethan"] .deck-folder h2 { display: inline-block; padding: 4px 8px; background: #ffdf49; color: #07152f; box-shadow: 3px 3px 0 #060c1c; }
:root[data-theme="ethan"] .content { background: radial-gradient(#0b1b3d .8px, transparent 1px) 0 0 / 11px 11px, var(--surface); }
:root[data-theme="ethan"] .btn { border-radius: 4px; font-weight: 800; letter-spacing: .025em; box-shadow: 3px 3px 0 #061128; }
:root[data-theme="ethan"] .btn.primary { background: linear-gradient(180deg, #fff06b, #ffca26); color: #09182f; border-color: #ffe145; box-shadow: 4px 4px 0 #050b1a; }
:root[data-theme="ethan"] .btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #fff5a3, #ffdc42); color: #09182f; border-color: #fff3a0; box-shadow: 5px 5px 0 #050b1a; transform: translate(-1px, -1px); }
:root[data-theme="ethan"] .thumb { border: 2px solid rgba(255, 223, 73, .65); box-shadow: 3px 3px 0 #071229; }
:root[data-theme="ethan"] .qty { border: 2px solid #07152f; background: #ffdf49; color: #07152f; font-weight: 900; box-shadow: 2px 2px 0 #07152f; }
:root[data-theme="ethan"] .manager-placement { border: 2px solid #ffdf49; border-radius: 5px; box-shadow: 5px 5px 0 #071229; }
:root[data-theme="ethan"] .deck-directory-card { border: 2px solid #ffdf49; border-radius: 5px; box-shadow: 5px 5px 0 #071229; }
:root[data-theme="ethan"] .deck-directory-card:hover { box-shadow: 6px 6px 0 #071229; }
:root[data-theme="ethan"] .deck-directory-title { color: #fff4c1; font-family: Impact, "Arial Black", var(--sans); font-weight: 900; letter-spacing: .035em; text-transform: uppercase; text-shadow: 2px 2px 0 #06122b, -1px -1px 0 #06122b; }

:root[data-theme="eli"] {
  --bg: #0d0a1c;
  --rail: #17112c;
  --surface: #1c1635;
  --elevate: #292048;
  --sunken: #110d26;
  --line: rgba(157, 134, 224, .19);
  --line-2: rgba(148, 230, 241, .39);
  --text: #f5efff;
  --dim: #c5b9e5;
  --faint: #998ebc;
  --gold: #81f3f4;
  --gold-soft: rgba(91, 228, 237, .14);
  --gold-border: rgba(129, 243, 244, .40);
  --leaf: #a6e9cc;
  --leaf-border: rgba(166, 233, 204, .40);
  --danger: #ff768e;
  --brown: #762b91;
  --brown-hi: #b13b9d;
  --bronze: #d35db4;
  --scrollbar: #514175;
  --scrollbar-hover: #7556a3;
}
:root[data-theme="eli"] .topbar {
  background: linear-gradient(100deg, #231547, #17112c 55%, #40204e);
  border-bottom-color: rgba(129, 243, 244, .45);
}
:root[data-theme="eli"] .view-head { background: linear-gradient(90deg, rgba(143, 67, 216, .21), transparent 58%, rgba(47, 203, 222, .10)); }
:root[data-theme="eli"] .brand { color: var(--gold); text-shadow: 0 0 14px rgba(129, 243, 244, .35); }
:root[data-theme="eli"] .nav.active { box-shadow: inset 3px 0 0 var(--gold), 0 0 16px rgba(129, 243, 244, .08); }
:root[data-theme="eli"] .settings-section { border-color: rgba(157, 134, 224, .29); box-shadow: 0 8px 25px rgba(92, 42, 160, .12); }
:root[data-theme="eli"] .btn.primary { color: #fff5ff; box-shadow: 0 0 16px rgba(177, 59, 157, .18); }
:root[data-theme="eli"] .btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #a43b91, var(--brown)); border-color: var(--gold); }

:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) #search:focus {
  background: var(--sunken);
  border-color: var(--line-2);
}
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) .btn:not(.primary):not(.danger):not(.armed):hover:not(:disabled) {
  background: var(--surface);
}
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) .credit { color: var(--faint); }
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) .chip.legal,
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) .loc.free,
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) .legality.ok { border-color: var(--leaf-border); }
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) .chip.restricted,
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) .deck-price { border-color: var(--gold-border); }
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) ::-webkit-scrollbar-thumb { background: var(--scrollbar); }
:root:is([data-theme="ty"], [data-theme="ethan"], [data-theme="eli"]) ::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }
.compact .view-head { padding-top: 12px; padding-bottom: 12px; }
.compact .coll-grid { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.compact .nav { padding-top: 6px; padding-bottom: 6px; }
.compact .deck-main { padding: 12px; }
.compact .settings-section { padding: 14px; }
.compact .settings-body { gap: 10px; }
.compact .coll-grid.list-view .coll-card { padding-top: 3px; padding-bottom: 3px; }
.settings-section { max-width: 650px; padding: 22px; border: 1px solid var(--line); border-radius: var(--r); background: var(--elevate); }
.settings-section h2 { margin: 0 0 8px; font: 500 calc(21px * var(--text-scale, 1)) var(--display); }
.settings-section .sub { line-height: 1.6; }
.settings-value { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 0 8px; }
.settings-value strong { color: var(--gold); font: 500 calc(32px * var(--text-scale, 1)) var(--display); }
.settings-refresh { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.settings-refresh .sub { margin-top: 10px; }

.view { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 26px 16px;
  border-bottom: 1px solid var(--line);
}

.view-head h1 { font-family: var(--display); font-size: calc(21px * var(--text-scale, 1)); }
.deck-directory { display: grid; gap: 24px; max-width: 1100px; }
.deck-folder h2 { margin: 0 0 9px; color: var(--gold); font: 600 calc(11px * var(--text-scale, 1)) var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.deck-folder-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.deck-directory-card { position: relative; display: flex; min-height: 150px; overflow: hidden; align-items: flex-end; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--sunken); color: var(--text); cursor: pointer; text-align: left; transition: border-color .14s, transform .14s, background .14s; }
.deck-directory-card:hover { transform: translateY(-2px); border-color: var(--gold); background: var(--elevate); }
.deck-directory-card::after { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(6, 10, 7, .12), rgba(6, 10, 7, .42) 46%, rgba(6, 10, 7, .93)); pointer-events: none; }
.deck-cover { position: absolute; inset: 0; display: grid; overflow: hidden; place-items: center; background: var(--elevate); color: var(--faint); }
.deck-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deck-cover.commander-cover::after { content: ""; position: absolute; inset: 0; border: 1px solid rgba(214, 180, 117, .42); pointer-events: none; }
.deck-cover i { position: absolute; left: 10px; top: 10px; z-index: 2; padding: 3px 7px; border-radius: 999px; background: rgba(8, 13, 10, .82); color: var(--gold); font: 700 calc(8px * var(--text-scale, 1)) var(--sans); font-style: normal; letter-spacing: .08em; text-transform: uppercase; }
.deck-cover.empty-cover .ico { width: 30px; height: 30px; color: var(--faint); }
.deck-directory-copy { position: relative; z-index: 2; display: grid; min-width: 0; gap: 5px; width: 100%; }
.deck-directory-title { overflow: hidden; max-width: 100%; color: #fff8e8; font: 600 calc(25px * var(--text-scale, 1))/1.05 var(--display); text-shadow: 0 2px 12px rgba(0, 0, 0, .85); text-overflow: ellipsis; white-space: nowrap; }
.deck-directory-meta { color: rgba(231, 230, 220, .82); font-size: calc(11px * var(--text-scale, 1)); line-height: 1.45; text-shadow: 0 1px 8px rgba(0, 0, 0, .9); }
.head-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.collection-filter { width: min(310px, 34vw); margin: 0; }

.collection-toolbar {
  display: grid;
  width: min(560px, 52vw);
  min-width: 0;
  gap: 7px;
}

.collection-search-row,
.collection-control-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.collection-search-row .collection-filter { width: 100%; min-width: 0; }
.collection-control-row { justify-content: flex-end; flex-wrap: wrap; }
.collection-filter-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 18px; max-width: 850px; margin: 0 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--elevate); }
.collection-filter-panel[hidden] { display: none !important; }
.filter-group { display: grid; gap: 6px; }
.filter-group > span { color: var(--faint); font: 600 calc(9.5px * var(--text-scale, 1)) var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chips button { padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--sunken); color: var(--dim); cursor: pointer; font: 500 calc(10.5px * var(--text-scale, 1)) var(--sans); }
.filter-chips button:hover, .filter-chips button.active { border-color: var(--bronze); background: var(--gold-soft); color: var(--gold); }

.profile-actions { display: flex; align-items: center; gap: 2px; margin: 5px -7px -4px; }
.profile-actions .link-btn { width: auto; padding: 4px 7px; font-size: calc(10.5px * var(--text-scale, 1)); }

.toolbar-hint {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: calc(10px * var(--text-scale, 1));
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 15px;
  padding: 1px 3px;
  border: 1px solid var(--line-2);
  border-bottom-color: rgba(142, 190, 152, 0.3);
  border-radius: 3px;
  background: var(--sunken);
  color: var(--dim);
  font: 600 calc(9px * var(--text-scale, 1)) var(--mono);
  text-align: center;
}

.view-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 26px 26px; }

/* -------------------------------------------------- collection manager */

.manager-body { display: grid; align-content: start; gap: 15px; }
.manager-search { display: grid; gap: 7px; max-width: 680px; }
.manager-search label, .manager-card-details label, .manager-field-label {
  color: var(--faint); font: 600 calc(10px * var(--text-scale, 1)) var(--sans);
  letter-spacing: .1em; text-transform: uppercase;
}
.manager-search-row { display: flex; align-items: start; gap: 8px; }
.manager-search-wrap { position: relative; flex: 1; min-width: 0; }
.manager-search-wrap .mini-input { width: 100%; margin: 0; padding: 9px 11px; }
.manager-search-wrap .suggestions { z-index: 65; }
.manager-search-row > .btn { min-height: 36px; white-space: nowrap; }
.manager-card { display: grid; grid-template-columns: minmax(180px, 245px) minmax(0, 1fr); gap: 24px; align-items: start; max-width: 900px; }
.manager-card > img { display: block; width: 100%; aspect-ratio: 488 / 680; object-fit: cover; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--sunken); }
.manager-card-details { display: grid; justify-items: start; gap: 9px; min-width: 0; }
.manager-card-details h2 { font: 500 calc(24px * var(--text-scale, 1)) var(--display); }
.manager-card-details > p { margin: 0; }
.manager-card-details #managerRules { max-width: 60ch; white-space: pre-line; line-height: 1.55; color: var(--text); }
.manager-card-details #managerOwned { color: var(--gold); }
.manager-card-details select { max-width: 100%; }
.manager-placement { max-width: 900px; padding: 16px 18px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--sunken); }
.manager-placement h2 { font: 500 calc(18px * var(--text-scale, 1)) var(--display); }
.manager-placement > .sub { margin: 5px 0 12px; }
.manager-placement ol { display: grid; gap: 3px; margin: 0 0 14px; padding: 0; list-style: none; }
.manager-placement li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--dim); }
.manager-placement li.current { border-color: var(--bronze); background: var(--gold-soft); color: var(--gold); }
.manager-placement li.current b { flex: 0 0 auto; font: 600 calc(10px * var(--text-scale, 1)) var(--sans); }
.manager-placement li.boundary { border-style: dashed; color: var(--faint); font-style: italic; }
.manager-placement-actions { display: flex; gap: 8px; }

/* ----------------------------------------------------------- the card */

#cardPanel { overflow-y: auto; padding: 24px 26px 28px; }

.card-layout {
  display: grid;
  grid-template-columns: minmax(210px, 300px) minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  max-width: 980px;
}

.art-column { position: sticky; top: 0; }

.art-frame {
  position: relative;
  aspect-ratio: 488 / 680;
  border-radius: 4.75% / 3.4%;
  overflow: hidden;
  background: var(--sunken);
  border: 1px solid var(--line-2);
}

.art-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s;
}

.art-frame img.loaded { opacity: 1; }

.art-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(12px * var(--text-scale, 1));
  color: var(--faint);
}

#flipBtn { margin-top: 10px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.card-head h1 {
  font-family: var(--display);
  font-size: calc(26px * var(--text-scale, 1));
  line-height: 1.15;
  font-weight: 500;
}

.mana { display: flex; gap: 3px; flex: 0 0 auto; }

.typeline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 7px 0 0;
  font-size: calc(13px * var(--text-scale, 1));
  color: var(--dim);
}

.typeline .pt { font: 600 calc(13px * var(--text-scale, 1)) var(--mono); color: var(--gold); flex: 0 0 auto; }

.rules {
  margin: 18px 0 0;
  padding: 15px 17px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: calc(13.5px * var(--text-scale, 1));
  line-height: 1.62;
}

.rules p { margin: 0 0 9px; }
.rules p:last-child { margin-bottom: 0; }
.rules .flavor { color: var(--faint); font-style: italic; }
.rules .face-name { font-weight: 600; color: var(--gold); }
.rules .face-type { color: var(--dim); font-size: calc(12.5px * var(--text-scale, 1)); margin-top: -4px; }
.rules .divider { height: 1px; background: var(--line); margin: 13px 0; }

.facts { margin: 18px 0 0; display: grid; gap: 11px; }
.facts > div { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 12px; align-items: baseline; }

.facts dt {
  font: 600 calc(10px * var(--text-scale, 1)) var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  padding-top: 2px;
}

.facts dd { margin: 0; font-size: calc(12.5px * var(--text-scale, 1)); color: var(--dim); min-width: 0; }
.facts dd .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; }

#printings, .deck-picker, .mini-input {
  font: 400 calc(12px * var(--text-scale, 1)) var(--sans);
  color: var(--text);
  background: var(--elevate);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  outline: none;
  max-width: 100%;
}

#printings { width: 100%; }
.detail-printing label { display: block; margin-bottom: 6px; color: var(--dim); font-size: 12px; }
.detail-printing select { width: 100%; min-width: 0; }
#printings:disabled { opacity: 0.55; }
#printings:focus, .deck-picker:focus, .mini-input:focus { border-color: var(--line-2); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  font-size: calc(10.5px * var(--text-scale, 1));
  color: var(--faint);
}

.chip .v { color: var(--text); font-weight: 600; }
.chip.legal { color: var(--leaf); border-color: rgba(140, 192, 119, 0.3); }
.chip.restricted { color: var(--gold); border-color: rgba(214, 180, 117, 0.3); }
.chip.banned { color: var(--danger); border-color: rgba(224, 115, 106, 0.3); }

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.card-actions .spacer { flex: 1 1 auto; }
.owned { margin: 9px 0 0; font-size: calc(11.5px * var(--text-scale, 1)); color: var(--gold); }

/* ---------------------------------------------------------- mana pips */

.pip {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  font: 700 calc(10.5px * var(--text-scale, 1)) var(--sans);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
}

.pip.sm { width: 15px; height: 15px; font-size: calc(8.5px * var(--text-scale, 1)); vertical-align: -2px; margin: 0 1px; }

.pip.hybrid {
  background: linear-gradient(135deg, var(--a) 0 50%, var(--b) 50% 100%);
  position: relative;
}

.pip.hybrid i { position: absolute; font-style: normal; font-size: calc(7px * var(--text-scale, 1)); }
.pip.hybrid i:first-child { top: 2px; left: 3.5px; }
.pip.hybrid i:last-child { bottom: 2px; right: 3.5px; }
.pip.sm.hybrid i { font-size: calc(6px * var(--text-scale, 1)); }

/* -------------------------------------------------------- collection */

.coll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 18px 16px;
}

.view-select {
  width: auto;
  min-width: 128px;
  margin: 0;
  font: 400 calc(12px * var(--text-scale, 1)) var(--sans);
  color: var(--text);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 28px 8px 9px;
  outline: none;
}

.view-select:focus { border-color: var(--line-2); }
.filter-toggle { white-space: nowrap; }
.filter-toggle.active { color: var(--gold); background: var(--gold-soft); border-color: var(--bronze); }
.view-toggle { display: flex; gap: 3px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.view-toggle .icon-btn { width: 27px; height: 27px; border-radius: 5px; }
.view-toggle .icon-btn.active { color: var(--gold); background: var(--gold-soft); }

.coll-grid.list-view { display: flex; flex-direction: column; gap: 2px; }
.coll-grid.list-view .coll-card {
  display: grid;
  grid-template-columns: 46px minmax(150px, 1fr) minmax(180px, 1.2fr);
  align-items: center;
  column-gap: 12px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
}
.coll-grid.list-view .coll-card:hover { background: var(--elevate); border-color: var(--line); }
.coll-grid.list-view .thumb { grid-row: 1 / span 2; width: 46px; }
.coll-grid.list-view .coll-card:hover .thumb { transform: none; }
.coll-grid.list-view .coll-card figcaption { margin: 0; align-self: end; }
.coll-grid.list-view .locs { margin: 0; align-self: start; }
.coll-grid.list-view .drop { opacity: 0; }
.coll-grid.list-view .coll-card:hover .drop { opacity: 1; }

.card-preview {
  position: fixed;
  z-index: 30;
  width: 300px;
  overflow: hidden;
  pointer-events: none;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: rgba(17, 24, 20, 0.98);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
}

.card-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 488 / 680;
  object-fit: cover;
  background: var(--sunken);
}

.coll-card { margin: 0; cursor: pointer; }
.wishlist-groups { display: grid; gap: 30px; }
.wishlist-group { min-width: 0; }
.wishlist-group-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.wishlist-group-head h2 { margin: 0; color: var(--gold); font: 500 calc(18px * var(--text-scale, 1)) var(--display); }
.wishlist-group-head p { margin: 3px 0 0; color: var(--faint); font-size: calc(10.5px * var(--text-scale, 1)); }
.wishlist-group-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; }
.wishlist-group-actions > span { color: var(--dim); font: 600 calc(10.5px * var(--text-scale, 1)) var(--sans); white-space: nowrap; }
.wishlist-group-actions .btn { padding: 5px 8px; font-size: calc(10px * var(--text-scale, 1)); }
#wishlistPanel .head-actions { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#deckPanel .head-actions { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.toolbar-label { color: var(--faint); font: 600 calc(9.5px * var(--text-scale, 1)) var(--sans); letter-spacing: .1em; text-transform: uppercase; }
.wishlist-sources { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.wishlist-sources .loc { cursor: default; }
.wishlist-remove { position: absolute; z-index: 2; }
.detail-proxy-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; color: var(--dim); font-size: calc(12px * var(--text-scale, 1)); }
.detail-proxy-picker select { flex: 1; min-width: 0; max-width: 100%; }
/* Desktop manual tabletop. Positions are pixels on the scrollable field. */
#goldfishDialog { padding: 12px; }
.deck-export-dialog.goldfish-dialog { width: 100%; height: calc(100dvh - 24px); max-height: none; padding: 16px; display: flex; flex-direction: column; overflow: hidden; }
.practice-header, .practice-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; }
.practice-header h2 { font-size: 20px; }
.practice-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.practice-toolbar .btn { padding: 6px 10px; }
.practice-toolbar input { min-width: 0; max-width: 100%; }
.practice-life { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.practice-help { position: relative; color: var(--dim); }
.practice-help summary { cursor: pointer; }
.practice-help p { position: absolute; right: 0; top: 20px; z-index: 20; width: 320px; padding: 16px; margin: 0; background: var(--elevate); border: 1px solid var(--line-2); line-height: 1.7; box-shadow: 0 8px 24px #0008; }
.practice-table { display: grid; grid-template-columns: 126px minmax(0, 1fr) 210px; grid-template-rows: minmax(240px, 1fr) 174px; gap: 10px; flex: 1; min-height: 0; position: relative; }
.practice-zones { grid-row: 1 / 3; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.practice-zone { border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 6px; flex-shrink: 0; background: var(--surface); }
.practice-zone-heading { display: flex; justify-content: space-between; width: 100%; background: transparent; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 2px 0 8px; }
.practice-zone-heading:hover { color: var(--gold); }
.practice-empty-zone { display: grid; place-items: center; height: 55px; color: var(--faint); font-size: 11px; border: 1px dashed var(--line-2); }
.practice-field-scroll { overflow: auto; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--sunken); }
.practice-battlefield { position: relative; min-width: 100%; min-height: 100%; user-select: none; }
.practice-field-label { position: absolute; left: 18px; top: 12px; color: var(--faint); letter-spacing: 2px; font-size: 11px; pointer-events: none; }
.practice-field-label small { margin-left: 12px; letter-spacing: 0; }
.practice-card { display: block; position: relative; flex: 0 0 104px; width: 104px; height: 145px; padding: 0; border: 2px solid transparent; border-radius: 7px; background: transparent; color: var(--text); cursor: grab; text-align: center; user-select: none; touch-action: none; }
.practice-card-art { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 5px; background: var(--elevate); transition: transform .12s; overflow: hidden; }
.practice-card-art > span { padding: 8px; overflow-wrap: anywhere; }
.practice-card img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.practice-battlefield > .practice-card { position: absolute; width: 112px; height: 156px; }
.practice-card.tapped .practice-card-art { transform: rotate(90deg); }
.practice-card.selected .practice-card-art { outline: 2px solid var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.practice-card:focus-visible { outline: none; }
.practice-card:focus-visible .practice-card-art { outline: 2px solid var(--gold); outline-offset: 3px; }
.practice-counter-badge { position: absolute; bottom: 3px; left: 0; right: 0; background: var(--brown); border: 1px solid var(--gold); color: var(--text); font-size: 11px; padding: 2px; overflow-wrap: anywhere; pointer-events: none; }
.practice-token-badge { position: absolute; top: 2px; right: 2px; background: var(--surface); color: var(--gold); font-size: 10px; padding: 1px 4px; pointer-events: none; }
.face-down { background: repeating-linear-gradient(45deg, var(--brown), var(--brown) 8px, var(--brown-hi) 8px, var(--brown-hi) 9px); border: 4px solid var(--bronze); color: var(--gold); padding: 8px; }
.practice-inspector { grid-column: 3; grid-row: 1 / 3; overflow: auto; padding: 0 2px; }
.practice-preview { min-height: 100px; margin-bottom: 12px; }
.practice-preview img { display: block; width: 100%; max-height: 280px; object-fit: contain; margin-bottom: 8px; }
.practice-preview strong { display: block; }
.practice-inspector .mini-input, .practice-inspector select { width: 100%; }
.practice-inspector .btn { font-size: 11px; }
.practice-hand-zone { grid-column: 2; border-top: 1px solid var(--line-2); padding-top: 6px; min-width: 0; }
.practice-hand-zone > strong { font-size: 10px; letter-spacing: 1px; color: var(--dim); }
.goldfish-hand { display: flex; gap: 8px; overflow: auto; padding: 4px; height: 153px; margin: 0; }
.goldfish-hand .practice-card { flex-basis: 98px; width: 98px; height: 137px; }
.practice-footer { color: var(--dim); font-size: 11px; padding-top: 8px; }
.practice-footer .btn { padding: 4px 8px; }
.practice-zone-browser { position: absolute; left: 136px; right: 220px; bottom: 184px; max-height: 65%; overflow: auto; z-index: 10; padding: 12px; border: 1px solid var(--gold); border-radius: var(--r); background: var(--surface); box-shadow: 0 8px 32px #000a; }
#practiceBrowserCards { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 12px; }
.practice-drop-active { outline: 2px solid var(--gold); outline-offset: -3px; background-color: var(--gold-soft); }
.practice-drag-ghost { position: fixed; z-index: 10000; pointer-events: none; opacity: .85; }
.practice-drag-ghost * { pointer-events: none; }
.practice-drag-ghost b { background: var(--surface); color: var(--gold); }
.practice-marquee { position: fixed; z-index: 10000; border: 1px solid var(--gold); background: var(--gold-soft); pointer-events: none; }


.thumb {
  position: relative;
  aspect-ratio: 488 / 680;
  border-radius: 4.75% / 3.4%;
  overflow: hidden;
  background: var(--sunken);
  border: 1px solid var(--line-2);
  transition: border-color 0.14s, transform 0.14s;
}

.coll-card:hover .thumb { border-color: var(--gold-dim, var(--bronze)); transform: translateY(-2px); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.qty {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(8, 13, 10, 0.88);
  border: 1px solid var(--line-2);
  font: 600 calc(10.5px * var(--text-scale, 1)) var(--sans);
  color: var(--gold);
}

.drop {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: rgba(8, 13, 10, 0.88);
  color: var(--text);
  font-size: calc(14px * var(--text-scale, 1));
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s, background 0.14s;
}

.coll-card:hover .drop { opacity: 1; }
.drop:hover { background: var(--danger); color: #1a0d0c; border-color: var(--danger); }

.coll-card figcaption {
  margin-top: 8px;
  font-size: calc(12px * var(--text-scale, 1));
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coll-card figcaption small { display: block; color: var(--faint); font-size: calc(10px * var(--text-scale, 1)); margin-top: 1px; }

.locs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.loc {
  padding: 1.5px 7px;
  border-radius: 999px;
  font-size: calc(10px * var(--text-scale, 1));
  border: 1px solid var(--line);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.loc.free { color: var(--leaf); border-color: rgba(140, 192, 119, 0.28); }
.loc.deck { color: var(--dim); cursor: pointer; }
.loc.deck:hover { color: var(--gold); border-color: var(--line-2); background: var(--gold-soft); }
.loc.none { color: var(--faint); font-style: italic; }

/* -------------------------------------------------------- deck view */

.deck-title { min-width: 0; }

.deck-name {
  font: 500 calc(21px * var(--text-scale, 1)) var(--display);
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 2px 7px;
  margin-left: -8px;
  width: 100%;
  max-width: 380px;
  outline: none;
}

.deck-name:hover { border-color: var(--line); }
.deck-name:focus { border-color: var(--line-2); background: var(--sunken); }
.deck-price { flex: 0 0 auto; padding: 4px 8px; border: 1px solid rgba(214, 180, 117, .35); border-radius: 999px; background: var(--gold-soft); color: var(--gold); font: 600 calc(10.5px * var(--text-scale, 1)) var(--sans); white-space: nowrap; }
.deck-category { display: block; width: min(255px, 100%); margin: 5px 0 -1px -1px; padding: 3px 7px; border: 1px solid transparent; border-radius: var(--r-sm); outline: none; background: transparent; color: var(--dim); font: 400 calc(11px * var(--text-scale, 1)) var(--sans); }
.deck-category:hover { border-color: var(--line); }
.deck-category:focus { border-color: var(--line-2); background: var(--sunken); color: var(--text); }

#deckSummary.ok { color: var(--leaf); }

.deck-stats {
  display: grid;
  grid-template-columns: minmax(215px, 1.25fr) repeat(2, minmax(130px, 0.75fr));
  gap: 0;
  margin: 24px 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--sunken);
  overflow: hidden;
}

.stat-overview {
  grid-column: 1 / -1;
  display: flex;
  gap: 16px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: calc(11px * var(--text-scale, 1));
}
.stat-overview b { color: var(--text); font-weight: 600; }
.stat-block { min-width: 0; padding: 10px 11px; border-right: 1px solid var(--line); }
.stat-block:last-child { border-right: 0; }
.stat-block h3 { margin: 0 0 7px; font: 600 calc(9.5px * var(--text-scale, 1)) var(--sans); letter-spacing: .11em; text-transform: uppercase; color: var(--faint); }
.stat-block h3 small { font: 400 calc(9px * var(--text-scale, 1)) var(--sans); letter-spacing: 0; text-transform: none; }
.curve-bars { display: flex; align-items: end; gap: 5px; height: 52px; }
.curve-bar { flex: 1; min-width: 16px; height: 100%; display: grid; grid-template-rows: 1fr auto auto; align-items: end; text-align: center; font-size: calc(9px * var(--text-scale, 1)); color: var(--faint); }
.curve-bar i { display: block; width: 100%; min-height: 2px; border-radius: 2px 2px 0 0; background: var(--gold); opacity: .8; }
.curve-bar b { display: block; color: var(--dim); font: 600 calc(9px * var(--text-scale, 1)) var(--sans); margin-top: 2px; }
.curve-bar span { margin-top: 1px; }
.stat-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.stat-tags > span { padding: 2px 5px; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); font-size: calc(9.5px * var(--text-scale, 1)); white-space: nowrap; }
.stat-tags b { color: var(--text); font-weight: 600; }
.stat-tags .stat-muted { font-style: italic; color: var(--faint); }
.stat-colour.w { color: #f3ead0; }.stat-colour.u { color: #9dcbe8; }.stat-colour.b { color: #b6afc2; }.stat-colour.r { color: #e8907c; }.stat-colour.g { color: #86c087; }

.deck-name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.deck-name-row .deck-name { flex: 1 1 240px; width: auto; min-width: 0; }

.legality {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid;
  font: 600 calc(10.5px * var(--text-scale, 1)) var(--sans);
  white-space: nowrap;
}

.legality.ok { color: var(--leaf); border-color: rgba(140, 192, 119, 0.35); }
.legality.bad { color: var(--danger); border-color: rgba(224, 115, 106, 0.45); }

.deck-problems {
  margin: 5px 0 0;
  font-size: calc(11.5px * var(--text-scale, 1));
  line-height: 1.5;
  color: var(--danger);
  max-width: 70ch;
}

/* a card that breaks a Commander rule */
.stack-card.illegal {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(224, 115, 106, 0.55), 0 4px 12px rgba(0, 0, 0, 0.45);
}

.stack-card.illegal:hover {
  box-shadow: 0 0 0 1px var(--danger), 0 14px 28px rgba(0, 0, 0, 0.6);
}

.stack-card .warn {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--danger);
  color: #1a0d0c;
  font: 700 calc(12px * var(--text-scale, 1)) var(--sans);
  transition: opacity 0.13s;
}

/* the commander star shares this corner, and only appears on hover */
.stack-card:hover .warn { opacity: 0; }

.avail-list li.off-colour { border-color: rgba(224, 115, 106, 0.3); }
.avail-list li.off-colour .an > span { color: var(--danger); }

.deck-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.deck-menu-wrap { position: relative; }
.deck-menu { position: absolute; z-index: 40; right: 0; bottom: calc(100% + 7px); width: 220px; max-height: 260px; overflow-y: auto; padding: 5px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--elevate); box-shadow: 0 14px 32px rgba(0, 0, 0, .5); }
.deck-menu button { display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 9px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); cursor: pointer; text-align: left; font: 500 calc(12px * var(--text-scale, 1)) var(--sans); }
.deck-menu button:hover { background: var(--gold-soft); color: var(--gold); }
.deck-menu small { color: var(--faint); font: 400 calc(10px * var(--text-scale, 1)) var(--sans); }
.deck-side-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 190px; }
.deck-side-topline .side-head { margin-bottom: 0; }
.deck-zone-wrap { position: relative; margin: 0; }
.deck-zone-btn { min-width: 112px; padding: 7px 9px; font-size: calc(10.5px * var(--text-scale, 1)); text-align: left; }
.deck-zone-menu { top: calc(100% + 5px); bottom: auto; }
.deck-search-row { display: flex; gap: 6px; align-items: center; }
.deck-search-wrap { position: relative; min-width: 0; flex: 1; }
.deck-search-wrap .mini-input { width: 100%; margin-bottom: 0; }
.deck-search-row .btn { flex: 0 0 auto; padding: 7px 8px; font-size: calc(10px * var(--text-scale, 1)); white-space: nowrap; }
.deck-suggestions { position: absolute; z-index: 45; top: calc(100% + 5px); left: 0; right: 0; max-height: 245px; margin: 0; padding: 5px; overflow-y: auto; list-style: none; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--elevate); box-shadow: 0 14px 32px rgba(0, 0, 0, .5); }
.deck-suggestions li { padding: 7px 8px; border-radius: var(--r-sm); color: var(--text); cursor: pointer; font-size: calc(11.5px * var(--text-scale, 1)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-suggestions li:hover,
.deck-suggestions li.active { background: var(--gold-soft); color: var(--gold); }
.proxy-count { color: #f4e2be !important; border: 1px solid rgba(214, 180, 117, .42); background: rgba(214, 180, 117, .13) !important; }

.deck-main { grid-row: 2; overflow: auto; min-height: 0; padding: 20px 26px 24px; }

.deck-side {
  display: grid;
  grid-row: 1;
  grid-template-columns: auto minmax(260px, 1fr);
  align-items: center;
  gap: 9px 14px;
  min-height: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}
.deck-side > .empty { grid-column: 1 / -1; margin: 0; }

.side-head {
  font: 600 calc(10px * var(--text-scale, 1)) var(--sans);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 9px;
}

.mini-input { width: 100%; margin-bottom: 9px; }

.avail-list { grid-column: 1 / -1; display: flex; gap: 6px; list-style: none; margin: 0; padding: 0 0 2px; overflow-x: auto; min-height: 0; }

.avail-list li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: clamp(142px, 18vw, 218px);
  flex: 0 0 auto;
  padding: 6px 7px;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--sunken);
}

.avail-list li:hover { background: var(--elevate); border-color: var(--line); }

.avail-list img {
  width: 28px;
  height: 39px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--sunken);
  flex: 0 0 auto;
}

.avail-list .an { flex: 1; min-width: 0; font-size: calc(11.5px * var(--text-scale, 1)); }
.avail-list .an > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avail-list .an small { display: block; overflow: hidden; color: var(--faint); font-size: calc(9.5px * var(--text-scale, 1)); text-overflow: ellipsis; white-space: nowrap; }

.avail-list .free {
  flex: 0 0 auto;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(140, 192, 119, 0.12);
  color: var(--leaf);
  font: 600 calc(10.5px * var(--text-scale, 1)) var(--sans);
}

/* deck columns: one per card type, cards stacked to their title bars */
.deck-columns {
  column-width: 158px;
  column-gap: 16px;
  --peek: 38px;
  /* a card is 488x680, so its height is 139.344% of its width, and a
     percentage margin resolves against that same width */
  --overlap: calc(var(--peek) - 139.344%);
}

.type-col { break-inside: avoid; width: 100%; max-width: 186px; margin: 0 0 20px; }

.type-col h4 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font: 600 calc(10px * var(--text-scale, 1)) var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 2px 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.type-col h4 .n { color: var(--gold); letter-spacing: 0; font-size: calc(11.5px * var(--text-scale, 1)); }

.stack { position: relative; padding-bottom: 4px; }

.stack-card {
  position: relative;
  z-index: 0;
  width: 100%;
  aspect-ratio: 488 / 680;
  border-radius: 4.75% / 3.4%;
  overflow: hidden;
  background: var(--sunken);
  border: 1px solid var(--line-2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.13s, box-shadow 0.13s, border-color 0.13s;
}

.stack-card.proxy {
  border: 3px solid var(--gold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .45), 0 0 0 1px rgba(214, 180, 117, .3);
}
.stack-card.proxy img { filter: grayscale(.72) saturate(.2); }
.stack-card.proxy:hover { border-color: #f4e2be; }
.stack-card.proxy:hover img { filter: grayscale(.58) saturate(.3); }
.proxy-mark { position: absolute; z-index: 4; left: 6px; bottom: 7px; padding: 2px 6px; border: 1px solid rgba(214, 180, 117, .7); border-radius: 999px; background: rgba(23, 18, 9, .88); color: #f4e2be; font: 700 calc(9px * var(--text-scale, 1)) var(--sans); letter-spacing: .08em; text-transform: uppercase; }
.role-mark { position: absolute; z-index: 4; left: 32px; top: 6px; padding: 2px 6px; border: 1px solid rgba(214, 180, 117, .7); border-radius: 999px; background: rgba(8, 13, 10, .9); color: var(--gold); font: 700 calc(8px * var(--text-scale, 1)) var(--sans); letter-spacing: .05em; text-transform: uppercase; }

.stack-card + .stack-card { margin-top: var(--overlap); }

.stack-card:hover {
  z-index: 20;
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.6);
  border-color: var(--bronze);
}

.stack-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stack-card .qty { z-index: 2; }

.stack-card .cmd {
  position: absolute;
  top: 5px;
  left: 6px;
  z-index: 3;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: rgba(8, 13, 10, 0.88);
  color: var(--faint);
  font-size: calc(11px * var(--text-scale, 1));
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.13s, color 0.13s;
}

.stack-card:hover .cmd { opacity: 1; }
.stack-card .cmd:hover { color: var(--gold); border-color: var(--gold); }
.stack-card .cmd.on { opacity: 1; color: var(--gold); border-color: var(--gold); }

.stack-card.is-commander { border-color: var(--gold); }
.stack-card.is-companion { border-color: var(--leaf); }
.stack-card.missing { border: 1px dashed rgba(224, 115, 106, 0.6); }

.stack-card .gone {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 0 14px;
  text-align: center;
  font-size: calc(11px * var(--text-scale, 1));
  color: var(--danger);
}

.steppers {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  background: linear-gradient(180deg, transparent, rgba(6, 10, 7, 0.94) 45%);
  opacity: 0;
  transition: opacity 0.13s;
}

.coll-card:hover .steppers,
.stack-card:hover .steppers { opacity: 1; }

.steppers button {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: rgba(8, 13, 10, 0.9);
  color: var(--text);
  font-size: calc(13px * var(--text-scale, 1));
  line-height: 1;
  cursor: pointer;
}

.steppers button:hover:not(:disabled) { background: var(--elevate); border-color: var(--gold-dim, var(--bronze)); }
.steppers button:disabled { opacity: 0.3; cursor: default; }
.steppers .n { font: 600 calc(11px * var(--text-scale, 1)) var(--sans); color: var(--gold); min-width: 17px; text-align: center; }

/* ------------------------------------------------------------- import */

.import-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  overflow: hidden;
  padding-bottom: 22px;
}

.import-input { display: flex; flex-direction: column; min-height: 0; }

#importText {
  flex: 1 1 auto;
  min-height: 230px;
  resize: none;
  font: 400 calc(12.5px * var(--text-scale, 1))/1.6 var(--mono);
  color: var(--text);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
  outline: none;
}

#importText:focus { border-color: var(--line-2); }
#importText::placeholder { color: var(--faint); }

.import-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.import-actions .sub { margin: 0; }

.import-report {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.report-head h2 { font-family: var(--display); font-size: calc(16px * var(--text-scale, 1)); font-weight: 500; }

.report-sub {
  font: 600 calc(10px * var(--text-scale, 1)) var(--sans);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--danger);
  margin: 18px 0 8px;
}

.report-list { list-style: none; margin: 0; padding: 0; }

.report-list li {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
  font-size: calc(12px * var(--text-scale, 1));
}

.report-list .rq { color: var(--gold); font-weight: 600; flex: 0 0 auto; min-width: 22px; }
.report-list .rn { flex: 1; min-width: 0; }
.report-list .rn small { display: block; color: var(--faint); font-size: calc(10.5px * var(--text-scale, 1)); }
.report-list .rs { color: var(--faint); font-size: calc(10.5px * var(--text-scale, 1)); flex: 0 0 auto; }
.report-list .warn { display: block; color: var(--gold); font-size: calc(10.5px * var(--text-scale, 1)); }
.report-list.problems li { color: var(--danger); }
.report-list.problems .rn small { color: rgba(224, 115, 106, 0.72); }

/* -------------------------------------------------------------- toast */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  max-width: 430px;
  padding: 10px 15px;
  border-radius: var(--r);
  background: var(--elevate);
  border: 1px solid var(--line-2);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  font-size: calc(12.5px * var(--text-scale, 1));
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}

.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: rgba(224, 115, 106, 0.5); color: #ffd8d4; }

/* ------------------------------------------------------- command palette */

.command-overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: start center;
  padding: min(16vh, 130px) 18px 24px;
  background: rgba(4, 8, 5, 0.64);
  backdrop-filter: blur(3px);
}

.command-dialog {
  width: min(560px, 100%);
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.62);
}

#commandInput {
  width: 100%;
  padding: 15px 17px;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
  background: var(--sunken);
  color: var(--text);
  font: 400 calc(14px * var(--text-scale, 1)) var(--sans);
}

#commandInput::placeholder { color: var(--faint); }
.command-list { max-height: min(48vh, 390px); margin: 0; padding: 7px; overflow-y: auto; list-style: none; }
.command-item { display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 16px; padding: 9px 10px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--text); cursor: pointer; text-align: left; font: 500 calc(12px * var(--text-scale, 1)) var(--sans); }
.command-item small { flex: 0 1 auto; overflow: hidden; color: var(--faint); font: 400 calc(10.5px * var(--text-scale, 1)) var(--sans); text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.command-item:hover, .command-item.active { border-color: var(--line); background: var(--gold-soft); color: var(--gold); }
.command-empty { padding: 15px 10px; color: var(--faint); font-size: calc(12px * var(--text-scale, 1)); }
.command-help { margin: 0; padding: 8px 12px 10px; border-top: 1px solid var(--line); color: var(--faint); font-size: calc(10px * var(--text-scale, 1)); text-align: center; }

/* --------------------------------------------------------- profile import */

.profile-import-overlay {
  position: fixed;
  z-index: 51;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(4, 8, 5, 0.72);
  backdrop-filter: blur(3px);
}

.profile-import-dialog {
  width: min(480px, 100%);
  padding: 22px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.62);
}

.profile-import-dialog h2 { margin: 0 0 6px; font: 500 calc(20px * var(--text-scale, 1)) var(--display); }
.profile-import-dialog > p:not(.sub) { margin: 0; color: var(--text); font-size: calc(13px * var(--text-scale, 1)); }
.profile-import-dialog > .sub { margin: 5px 0 14px; }
.price-history-overlay { position: fixed; z-index: 53; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(4, 8, 5, .74); backdrop-filter: blur(3px); }
.price-history-overlay[hidden] { display: none !important; }
.price-history-dialog { position: relative; width: min(430px, 100%); max-height: min(620px, 88vh); overflow: auto; padding: 22px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: 0 22px 60px rgba(0, 0, 0, .62); }
.price-history-dialog h2 { margin: 0; font: 500 calc(21px * var(--text-scale, 1)) var(--display); }
.price-current { margin: 12px 0 3px; color: var(--gold); font: 500 calc(30px * var(--text-scale, 1)) var(--display); }
.price-history-list { margin: 18px 0 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.price-history-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); color: var(--dim); font-size: calc(12px * var(--text-scale, 1)); }
.price-history-list strong { color: var(--text); font: 600 calc(12px * var(--text-scale, 1)) var(--mono); }
.deck-export-overlay { position: fixed; z-index: 53; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(4, 8, 5, .74); backdrop-filter: blur(3px); }
.deck-export-overlay[hidden] { display: none !important; }
.deck-export-dialog { position: relative; width: min(650px, 100%); padding: 22px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: 0 22px 60px rgba(0, 0, 0, .62); }
.deck-export-dialog h2 { margin: 0; font: 500 calc(21px * var(--text-scale, 1)) var(--display); }
.deck-export-dialog > .sub { margin: 6px 0 13px; }
.deck-export-dialog textarea { display: block; width: 100%; min-height: 285px; margin-bottom: 12px; resize: vertical; font: calc(12px * var(--text-scale, 1))/1.5 var(--mono); }
.profile-import-choices { display: grid; gap: 8px; margin-bottom: 14px; }
.profile-choice { display: grid; gap: 3px; padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--r); background: var(--sunken); color: var(--text); cursor: pointer; text-align: left; }
.profile-choice:hover { border-color: var(--bronze); background: var(--elevate); }
.profile-choice b { font: 600 calc(12px * var(--text-scale, 1)) var(--sans); }
.profile-choice span { color: var(--dim); font-size: calc(11px * var(--text-scale, 1)); line-height: 1.45; }
.profile-choice.danger b { color: var(--danger); }
.profile-choice.danger:hover { border-color: rgba(224, 115, 106, 0.5); }

/* ------------------------------------------------------------ deck import */

.deck-import-overlay { position: fixed; z-index: 53; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(4, 8, 5, .74); backdrop-filter: blur(3px); }
.deck-import-overlay[hidden] { display: none !important; }
.deck-import-dialog { position: relative; width: min(680px, 100%); max-height: min(820px, 92vh); overflow: auto; padding: 24px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: 0 22px 60px rgba(0, 0, 0, .62); }.deck-import-dialog h2 { margin: 0; font: 500 calc(22px * var(--text-scale, 1)) var(--display); }.deck-import-dialog > .sub { margin: 6px 0 15px; }.deck-import-dialog .mini-input { width: 100%; }.deck-import-dialog textarea { display: block; width: 100%; min-height: 180px; margin-top: 10px; resize: vertical; }.deck-import-report { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }.deck-import-report > p { margin: 0 0 9px; color: var(--dim); font-size: calc(12px * var(--text-scale, 1)); }.deck-import-report .report-list li > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.deck-import-report .report-list li > small { margin-left: auto; color: var(--faint); white-space: nowrap; }.deck-import-choice-title { margin: 18px 0 9px; color: var(--gold); font: 600 calc(11px * var(--text-scale, 1)) var(--sans); }.deck-import-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }.deck-import-choices button { display: grid; gap: 4px; min-height: 92px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--sunken); color: var(--text); cursor: pointer; text-align: left; }.deck-import-choices button:hover { border-color: var(--bronze); background: var(--elevate); }.deck-import-choices b { font: 600 calc(12px * var(--text-scale, 1)) var(--sans); }.deck-import-choices span { color: var(--dim); font-size: calc(10.5px * var(--text-scale, 1)); line-height: 1.45; }

/* ------------------------------------------------------------ card detail */

.card-detail-overlay, .proxy-overlay { position: fixed; z-index: 52; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(4, 8, 5, .74); backdrop-filter: blur(3px); }.card-detail-overlay[hidden], .proxy-overlay[hidden] { display: none !important; }
.card-detail-dialog { position: relative; display: grid; grid-template-columns: minmax(180px, 245px) minmax(0, 430px); width: min(720px, 100%); max-height: min(760px, 92vh); overflow: auto; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: 0 22px 60px rgba(0, 0, 0, .62); }
.detail-card-art { align-self: start; padding: 18px; }.detail-card-art img { display: block; width: 100%; border: 1px solid var(--line-2); border-radius: 4.75% / 3.4%; background: var(--sunken); }
.detail-copy { min-width: 0; padding: 26px 30px 22px 0; }.detail-kicker { margin: 0 0 5px; color: var(--gold); font: 600 calc(10px * var(--text-scale, 1)) var(--sans); letter-spacing: .12em; text-transform: uppercase; }.detail-copy h2 { margin: 0; font: 500 calc(23px * var(--text-scale, 1)) var(--display); }.detail-type, .detail-meta { margin: 6px 0 0; color: var(--dim); font-size: calc(12px * var(--text-scale, 1)); line-height: 1.5; }.detail-rules { margin-top: 18px; color: var(--text); font-size: calc(12.5px * var(--text-scale, 1)); line-height: 1.6; }.detail-rules p { margin: 0 0 9px; }.detail-facts { margin-top: 17px; border-top: 1px solid var(--line); }.detail-fact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 14px 0; }.detail-fact-grid div { min-width: 0; }.detail-fact-grid span, .detail-info-section h3 { display: block; margin: 0 0 3px; color: var(--faint); font: 600 calc(9px * var(--text-scale, 1)) var(--sans); letter-spacing: .1em; text-transform: uppercase; }.detail-fact-grid b { display: block; overflow: hidden; color: var(--text); font: 500 calc(11.5px * var(--text-scale, 1)) var(--sans); text-overflow: ellipsis; white-space: nowrap; }.detail-info-section { padding: 12px 0; border-top: 1px solid var(--line); }.detail-info-section .chips { display: flex; flex-wrap: wrap; gap: 5px; }.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.detail-close { position: absolute; z-index: 2; top: 9px; right: 10px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--elevate); color: var(--dim); cursor: pointer; font: calc(22px * var(--text-scale, 1))/1 var(--sans); }.detail-close:hover { background: var(--gold-soft); color: var(--gold); }
.proxy-dialog { position: relative; width: min(440px, 100%); max-height: min(600px, 88vh); overflow: auto; padding: 18px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: 0 22px 60px rgba(0, 0, 0, .62); }.proxy-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-right: 30px; }.proxy-dialog h2 { margin: 0; font: 500 calc(20px * var(--text-scale, 1)) var(--display); }.proxy-list { margin: 14px 0 0; padding: 0; list-style: none; }.proxy-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 8px; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: calc(12px * var(--text-scale, 1)); }.proxy-list li:hover { background: var(--gold-soft); color: var(--gold); }.proxy-list small { color: var(--faint); font-size: calc(10px * var(--text-scale, 1)); }

/* --------------------------------------------------------- scrollbars */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #22302a; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #2e3f36; background-clip: content-box; }

/* ----------------------------------------------------------- narrower */

@media (max-width: 1020px) {
  .card-layout { grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: 22px; }
  #collectionPanel .view-head { flex-wrap: wrap; }
  #collectionPanel .collection-toolbar { width: 100%; }
  #collectionPanel .collection-control-row { justify-content: flex-start; }
  .desktop-hint { display: none; }
  .import-body { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .import-report { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; overflow: visible; }
  .deck-stats { grid-template-columns: minmax(210px, 1.2fr) minmax(130px, .8fr); }
  .deck-stats .stat-block:last-child { border-top: 1px solid var(--line); grid-column: 1 / -1; border-right: 0; }
}

@media (max-width: 820px) {
  :root { --rail-w: 60px; }
  .rail { padding: 10px 8px; align-items: stretch; }
  .nav span, .rail-group.grow, .rail-foot span, .link-btn, .credit { display: none; }
  .rail-foot { border-top: 0; }
  .nav { justify-content: center; padding: 9px 0; }
  .count { position: absolute; margin: 0; transform: translate(14px, -10px); }
  .brand span { display: none; }
  .card-layout { grid-template-columns: minmax(0, 1fr); }
  .collection-filter { width: 190px; }
  .view-select { min-width: 0; }
  .coll-grid.list-view .coll-card { grid-template-columns: 42px minmax(110px, 1fr); }
  .coll-grid.list-view .thumb { width: 42px; }
  .coll-grid.list-view .locs { grid-column: 2; }
  .art-column { position: static; max-width: 260px; }
  .deck-side { grid-template-columns: 1fr; align-items: stretch; padding: 12px 18px; }
  .deck-side-topline { min-width: 0; }
  .avail-list li { width: clamp(138px, 38vw, 220px); }
  .deck-main { padding: 18px 20px; }
}

@media (max-width: 700px) {
  .view-head { flex-wrap: wrap; }
  .manager-card { grid-template-columns: 1fr; }
  .manager-card > img { max-width: 245px; }
  .wishlist-group-head { align-items: flex-start; flex-direction: column; }
  .collection-toolbar { width: 100%; }
  .collection-search-row .collection-filter { width: auto; flex: 1; }
  .collection-control-row { justify-content: flex-start; flex-wrap: wrap; }
  .collection-filter-panel { grid-template-columns: 1fr; }
  .deck-import-choices { grid-template-columns: 1fr; }
  .card-preview { display: none; }
  .card-detail-dialog { grid-template-columns: 1fr; }
  .detail-card-art { width: min(210px, 54vw); padding-bottom: 0; }
  .detail-copy { padding: 18px 22px 22px; }
}

/* --------------------------------------------------------- login page */

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 30px 28px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-brand .mark { width: 22px; height: 22px; color: var(--gold); }
.login-brand h1 { font-family: var(--display); font-size: calc(16px * var(--text-scale, 1)); font-weight: 500; }

.login-card label {
  display: block;
  margin: 0 0 6px;
  font: 600 calc(10px * var(--text-scale, 1)) var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card input:not([type]) {
  width: 100%;
  margin-bottom: 16px;
  font: 400 calc(13px * var(--text-scale, 1)) var(--sans);
  color: var(--text);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
}

.login-card input:focus { border-color: var(--line-2); }
.login-card .btn { margin-top: 4px; }

.login-error {
  margin: -6px 0 14px;
  font-size: calc(12px * var(--text-scale, 1));
  color: var(--danger);
}

.login-note {
  margin: 0 0 16px;
  font-size: calc(12.5px * var(--text-scale, 1));
  line-height: 1.6;
  color: var(--dim);
}

.login-note code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 400 calc(11.5px * var(--text-scale, 1)) var(--mono);
  color: var(--gold);
  word-break: break-all;
}

.login-card .credit { margin: 18px 0 0; text-align: center; }

/* who is signed in, at the foot of the rail */
.whoami {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 8px;
  font-size: calc(11.5px * var(--text-scale, 1));
  color: var(--dim);
}

.whoami .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami .who b { color: var(--text); font-weight: 600; }

.practice-context-menu { position: fixed; z-index: 1000; width: 260px; max-height: calc(100dvh - 16px); overflow-y: auto; padding: 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); box-shadow: 0 8px 24px #0008; }
.practice-context-menu .mini-input, .practice-context-menu select { width: 100%; }
.practice-context-menu .btn { font-size: 12px; }

.practice-token-picker { top: 12px; bottom: 12px; max-height: none; }
#practiceTokenQuery { flex: 1; min-width: 180px; }
#practiceTokenResults { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 12px; margin-top: 12px; }
.practice-token-result { padding: 6px; color: var(--text); background: var(--elevate); border: 1px solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; }
.practice-token-result:hover, .practice-token-result:focus-visible { border-color: var(--gold); }
.practice-token-result img { width: 100%; border-radius: 6px; }
.practice-token-result span, .practice-token-result small { display: block; margin-top: 4px; }
.practice-token-result small { color: var(--dim); }

/* Collection tiles are positioned in measured, windowed rows. */
.windowed-collection { position: relative; overflow-anchor: none; }
.windowed-collection > .coll-card { position: absolute; box-sizing: border-box; }
