/* CommanderFox. Colours are tokens: light by default, dark when the device prefers it. A calm base (ink and parchment)
   with one fox-orange accent, so the cards' art is the colour. Mana colours (W U B R G) mark color identity. */
:root {
  --bg: #f5f3ef;
  --panel: #ffffff;
  --panel-2: #faf8f4;
  --text: #17141f;
  --muted: #625d6e;
  --line: #e4e0d8;
  --accent: #d9581f;
  --accent-text: #ffffff;
  --accent-soft: #fbe9df;
  --ink: #1b1530;
  --price: #12805a;
  --error: #c4291c;
  --warn: #9a5b00;
  --ok: #12805a;
  --gold: #b8871b;
  --mana-w: #f3ecd0; --mana-w-text: #6b5d2a;
  --mana-u: #3d82d6; --mana-b: #3b3340; --mana-r: #d84a33; --mana-g: #2f8a52; --mana-c: #c9c3b8; --mana-c-text: #3a3530;
  --shadow: 0 1px 2px rgba(20, 16, 30, .05), 0 8px 24px rgba(20, 16, 30, .07);
  --radius: 14px;
  --title-font: "Outfit", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0c15;
    --panel: #17141f;
    --panel-2: #1c1826;
    --text: #efedf5;
    --muted: #a19bb2;
    --line: #2b2638;
    --accent: #ff7a3d;
    --accent-text: #160c05;
    --accent-soft: #33201a;
    --ink: #0b0910;
    --price: #4fe0a4;
    --error: #ff8a80;
    --warn: #ffc266;
    --ok: #4fe0a4;
    --gold: #f2c552;
    --mana-b: #8a7f94; --mana-c: #6f6a63; --mana-c-text: #f1ede6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
h1, h2, .brand { font-family: var(--title-font); }
h1 { font-size: clamp(24px, 3.6vw, 32px); margin: 0 0 6px; line-height: 1.2; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; }
.error-text { color: var(--error); }
.price { color: var(--price); font-weight: 600; font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }

/* ----- Buttons and fields ----- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  text-decoration: none; color: var(--text); font-weight: 500; line-height: 1.3;
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.primary, .button.primary { border-color: transparent; background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger, .button.danger { border-color: transparent; background: var(--error); color: #fff; font-weight: 600; }
button.small, .button.small { padding: 4px 9px; font-size: 13px; border-radius: 8px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-weight: inherit; }
button.icon { padding: 4px 8px; min-width: 32px; }
.big { padding: 12px 22px; font-size: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.row.end { justify-content: flex-end; }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  padding: 8px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); min-width: 0;
}
textarea { width: 100%; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.45; }
label.stack { display: grid; gap: 4px; margin: 0 0 12px; }
label.stack > span:first-child { font-weight: 600; font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- Header ----- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px 16px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 19px; flex: none; }
.brand b { color: var(--accent); }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 7px 11px; border-radius: 9px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a.on { color: var(--text); background: var(--accent-soft); font-weight: 600; }
.who { flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 5px; border-radius: 999px; background: var(--accent-soft); color: var(--text); text-decoration: none; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { border-radius: 50%; flex: none; vertical-align: middle; }
@media (max-width: 860px) {
  .top { flex-wrap: wrap; }
  .who { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -8px; }
  .new-deck { padding: 6px 10px; }
}

main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 22px 16px 48px; }
main:focus { outline: none; }
section { margin: 0 0 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.section-head h1, .section-head h2 { margin: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin: 0 0 18px; }
.note { color: var(--muted); padding: 14px 16px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); margin: 0 0 14px; }
.note.error { color: var(--error); border-style: solid; }
.center-card { text-align: center; max-width: 560px; margin: 48px auto; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 24px; }
.loading { color: var(--muted); padding: 24px 0; }

/* ----- Home ----- */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: clamp(22px, 5vw, 48px); margin: 0 0 26px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #6b2a14 0%, transparent 55%), linear-gradient(135deg, #1b1530, #2c1d3f 60%, #3a1d1d); }
.hero h1 { font-size: clamp(28px, 5vw, 46px); max-width: 760px; }
.hero h1 em { font-style: normal; color: #ffb37a; }
.hero p { max-width: 640px; font-size: 16px; color: #e3dcef; }
.hero .button:not(.primary) { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .25); }
.hero-art { position: absolute; right: -40px; top: 50%; transform: translateY(-50%) rotate(8deg); width: 260px; opacity: .9; border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
@media (max-width: 900px) { .hero-art { display: none; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 12px; margin: 0 0 24px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--title-font); }
.stat .sub { color: var(--muted); font-size: 12.5px; }

/* ----- Filters ----- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); max-width: 100%; overflow-x: auto; }
.seg a, .seg button { padding: 7px 12px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 14px; border: 0; border-radius: 0; background: none; }
.seg a.on, .seg button.on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.color-picker { display: inline-flex; gap: 4px; }
.color-picker button { padding: 2px; border-radius: 50%; border: 2px solid transparent; background: none; opacity: .45; }
.color-picker button.on { opacity: 1; border-color: var(--accent); }

/* ----- Mana symbols and color identity ----- */
.ms { display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; border-radius: 50%; font-size: .78em; font-weight: 700; vertical-align: -.15em;
  margin: 0 1px; color: #fff; background: var(--mana-c); color: var(--mana-c-text); line-height: 1; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25); }
.ms.w { background: var(--mana-w); color: var(--mana-w-text); }
.ms.u { background: var(--mana-u); color: #fff; }
.ms.b { background: var(--mana-b); color: #fff; }
.ms.r { background: var(--mana-r); color: #fff; }
.ms.g { background: var(--mana-g); color: #fff; }
.ms.hy { background: linear-gradient(135deg, var(--c1) 50%, var(--c2) 50%); color: transparent; }
.ms.hy.c1-w { --c1: var(--mana-w); } .ms.hy.c1-u { --c1: var(--mana-u); } .ms.hy.c1-b { --c1: var(--mana-b); } .ms.hy.c1-r { --c1: var(--mana-r); } .ms.hy.c1-g { --c1: var(--mana-g); } .ms.hy.c1-c { --c1: var(--mana-c); }
.ms.hy.c2-w { --c2: var(--mana-w); } .ms.hy.c2-u { --c2: var(--mana-u); } .ms.hy.c2-b { --c2: var(--mana-b); } .ms.hy.c2-r { --c2: var(--mana-r); } .ms.hy.c2-g { --c2: var(--mana-g); } .ms.hy.c2-c { --c2: var(--mana-c); }
.ms.phy::after { content: "φ"; font-size: .9em; }
.pips { display: inline-flex; gap: 2px; align-items: center; }
.pips .ms { font-size: 13px; width: 16px; height: 16px; }
.cost { white-space: nowrap; }

/* ----- Badges ----- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--error) 16%, transparent); color: var(--error); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.gc { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.badge.bracket { background: var(--ink); color: #fff; }
.badge.b1 { background: #4f8a5b; } .badge.b2 { background: #3d6fb6; } .badge.b3 { background: #8a55c7; } .badge.b4 { background: #c7552d; } .badge.b5 { background: #b01e3f; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }

/* ----- Deck tiles ----- */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.deck-tile { position: relative; display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: transform .12s ease, border-color .12s ease; min-width: 0; }
.deck-tile:hover, .deck-tile:focus-visible { transform: translateY(-2px); border-color: var(--accent); }
.deck-tile .art { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #2c1d3f, #3a1d1d); overflow: hidden; }
.deck-tile .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deck-tile .art .over { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; justify-content: space-between; align-items: flex-end; gap: 6px; }
.deck-tile .art .pips { background: rgba(0, 0, 0, .55); padding: 3px 6px; border-radius: 999px; }
.deck-tile .meta { padding: 10px 12px 12px; display: grid; gap: 3px; min-width: 0; }
.deck-tile .name { font-weight: 700; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--title-font); }
.deck-tile .cmdr { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-tile .foot-line { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.deck-tile .foot-line .by { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.deck-tile .private { position: absolute; top: 8px; left: 8px; }
.more { display: flex; justify-content: center; margin: 18px 0; }

/* ----- Card tiles (search, decks shown as pictures) ----- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.card-tile { position: relative; display: block; color: var(--text); text-decoration: none; border-radius: 10px; }
.card-tile img { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 4.75% / 3.5%; display: block; box-shadow: var(--shadow); background: var(--panel); }
.card-tile .noimg { aspect-ratio: 63 / 88; display: grid; place-items: center; text-align: center; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); padding: 8px; font-size: 13px; }
.card-tile .cap { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; padding: 4px 2px 0; }
.card-tile .cap span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tile .qty { position: absolute; top: 6px; left: 6px; background: rgba(0, 0, 0, .75); color: #fff; font-weight: 700; font-size: 13px; padding: 1px 7px; border-radius: 999px; }
.card-tile .flag { position: absolute; top: 6px; right: 6px; }
.card-tile:hover img { outline: 2px solid var(--accent); }
.hover-card { position: fixed; z-index: 50; width: 250px; border-radius: 12px; pointer-events: none; box-shadow: 0 18px 50px rgba(0, 0, 0, .45); }

/* ----- Deck page ----- */
.deck-head { position: relative; border-radius: 20px; overflow: hidden; margin: 0 0 18px; background: #1b1530; color: #fff; min-height: 220px; display: flex; align-items: flex-end; }
.deck-head > img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.deck-head .shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(14, 10, 22, .95) 10%, rgba(14, 10, 22, .2) 70%); }
.deck-head .inner { position: relative; padding: 22px; width: 100%; display: grid; gap: 8px; }
.deck-head h1 { color: #fff; font-size: clamp(26px, 4.4vw, 40px); margin: 0; }
.deck-head a { color: #ffc29b; }
.deck-head .sub { color: #ded7ea; display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.deck-head .button:not(.primary), .deck-head button:not(.primary) { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .25); }
.deck-head .button.on, .deck-head button.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.deck-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .deck-layout { grid-template-columns: 1fr; } }
.side-col { display: grid; gap: 14px; position: sticky; top: 80px; }
@media (max-width: 960px) { .side-col { position: static; } }
.commander-cards { display: flex; gap: 10px; }
.commander-cards img { width: 100%; max-width: 280px; border-radius: 4.75% / 3.5%; box-shadow: var(--shadow); }
.commander-cards.two img { max-width: 150px; }
.issues { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.issues li { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--error) 10%, transparent); color: var(--text); font-size: 14px; }
.issues li.note-level { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.issues li .cards { color: var(--muted); font-size: 13px; display: block; margin-top: 3px; }
.legal-ok { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); font-weight: 600; }

.list-groups { columns: 2 300px; column-gap: 24px; }
.list-group { break-inside: avoid; margin: 0 0 18px; }
.list-group h3 { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 4px; font-family: var(--title-font); font-size: 16px; }
.card-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 6px; font-size: 14px; }
.card-row:hover { background: var(--panel-2); }
.card-row .q { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.card-row a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-row a:hover { color: var(--accent); text-decoration: underline; }
.card-row .p { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.card-row.problem a { color: var(--error); }
.card-row .flags { display: inline-flex; gap: 3px; }
.flag-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.flag-dot.gc { background: var(--gold); }
.flag-dot.bad { background: var(--error); }

/* Mana curve and bars */
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; align-items: end; height: 120px; margin: 8px 0 4px; }
.curve .bar { display: grid; align-content: end; justify-items: center; height: 100%; font-size: 12px; color: var(--muted); }
.curve .bar span.fill { width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); display: block; min-height: 2px; }
.curve-labels { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; font-size: 12px; color: var(--muted); text-align: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.power-meter { width: 100%; height: 10px; accent-color: var(--accent); }
.roles { display: grid; gap: 6px; }
.roles details summary { cursor: pointer; display: flex; justify-content: space-between; font-size: 14px; }
.roles details p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.reasons { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

/* ----- Comments ----- */
.comments { display: grid; gap: 12px; }
.comment { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; }
.comment .body { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.comment .who-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.comment .who-line a { font-weight: 700; color: var(--text); text-decoration: none; }
.comment .text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .actions { display: flex; gap: 12px; margin-top: 4px; font-size: 13px; }
.comment .actions button { font-size: 13px; color: var(--muted); }
.comment .replies { margin-top: 10px; display: grid; gap: 10px; }
.comment.deleted .text { color: var(--muted); font-style: italic; }
.comment-form { display: grid; gap: 8px; }
.comment-form textarea { font-family: inherit; font-size: 14px; }
.op-tag { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 11px; padding: 0 6px; border-radius: 999px; }

/* ----- Editor ----- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .editor { grid-template-columns: 1fr; } }
.ac { position: relative; }
.ac input { width: 100%; }
.ac-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); list-style: none; margin: 0; padding: 4px; max-height: 360px; overflow-y: auto; }
.ac-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.ac-list li img { width: 34px; border-radius: 3px; }
.ac-list li.on, .ac-list li:hover { background: var(--accent-soft); }
.ac-list li .t { color: var(--muted); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-list li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; font-weight: 600; }
.edit-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 8px; font-size: 14px; }
.edit-row:hover { background: var(--panel-2); }
.edit-row .qty { display: inline-flex; align-items: center; gap: 2px; }
.edit-row .qty span { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.edit-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-row.problem .nm { color: var(--error); }
.commander-pick { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); margin-bottom: 8px; }
.commander-pick img { width: 64px; border-radius: 4px; }
.count-line { font-family: var(--title-font); font-size: 28px; font-weight: 700; }
.count-line.ok { color: var(--ok); }
.count-line.bad { color: var(--error); }
.import-line { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 8px; font-size: 14px; }
.import-line.unknown { background: color-mix(in srgb, var(--error) 8%, transparent); }
.import-line select { max-width: 260px; }

/* ----- Card page ----- */
.card-page { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .card-page { grid-template-columns: 1fr; } .card-page .pics { max-width: 320px; margin: 0 auto; } }
.card-page .pics { display: grid; gap: 10px; }
.card-page .pics img { width: 100%; border-radius: 4.75% / 3.5%; box-shadow: var(--shadow); }
.oracle { white-space: pre-wrap; line-height: 1.55; margin: 10px 0; }
.face + .face { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.buy-box .row { margin: 6px 0; }

/* ----- Commanders ----- */
.cmdr-row { display: grid; grid-template-columns: 34px 92px minmax(0, 1fr) repeat(4, minmax(60px, auto)); gap: 12px; align-items: center; padding: 8px 10px;
  border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.cmdr-row:hover { background: var(--panel-2); }
.cmdr-row .rank { font-family: var(--title-font); font-weight: 800; font-size: 18px; color: var(--muted); text-align: right; }
.cmdr-row img { width: 92px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; }
.cmdr-row .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdr-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.cmdr-row .num small { display: block; color: var(--muted); font-size: 11.5px; }
@media (max-width: 700px) { .cmdr-row { grid-template-columns: 28px 64px minmax(0, 1fr) auto; } .cmdr-row img { width: 64px; } .cmdr-row .num.hide-sm { display: none; } }

/* ----- Have / want ----- */
.listing { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.listing img { width: 46px; border-radius: 4px; }
.listing .nm { font-weight: 700; color: var(--text); text-decoration: none; }
.listing .sub { color: var(--muted); font-size: 13px; }
.kind { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; }
.kind.have { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.kind.want { background: color-mix(in srgb, var(--mana-u) 18%, transparent); color: var(--mana-u); }

/* ----- Profile ----- */
.profile-head { display: flex; gap: 16px; align-items: center; margin: 0 0 18px; }
.profile-head img { width: 72px; height: 72px; }

/* ----- Dialogs ----- */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .4); width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.small { width: min(440px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 8, 16, .6); backdrop-filter: blur(2px); }
.pad { padding: 22px; position: relative; }
.pad h2 { margin-right: 36px; }
.close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 0; background: var(--bg); font-size: 22px; line-height: 1; z-index: 1; }
.providers { display: grid; gap: 10px; margin: 16px 0; }
.provider { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 600; background: var(--bg); }
.provider svg { width: 20px; height: 20px; }
.provider:hover { border-color: var(--accent); }
.provider.facebook { background: #1877f2; color: #fff; border-color: transparent; }
.provider.off { opacity: .55; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0 10px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.email-form { display: grid; gap: 8px; }
.fine-print { margin-top: 14px; }
.dev-box { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.dev-login { display: grid; gap: 10px; margin-top: 10px; }
.dev-login label { display: grid; gap: 4px; font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.error { background: var(--error); }

/* Admin */
.admin-tabs { margin: 0 0 16px; }
.bars { display: grid; gap: 4px; }
.bars .b { display: grid; grid-template-columns: 110px minmax(0, 1fr) 50px; gap: 8px; align-items: center; font-size: 13px; }
.bars progress { width: 100%; height: 10px; accent-color: var(--accent); }

/* Ads */
.ad-spot { position: relative; min-height: 100px; padding: 26px 10px 10px; color: var(--muted); text-align: center; overflow: hidden; }
.ad-spot.wide { width: calc(100% - 32px); max-width: 1248px; margin: 12px auto; border: 1px solid var(--line); border-radius: 12px; }
.ad-spot.placeholder { display: grid; place-content: center; border-style: dashed; font-size: 13px; }
.ad-label { position: absolute; top: 8px; left: 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }

/* Privacy and terms */
main.legal { max-width: 820px; }
.legal h2 { margin-top: 26px; }
.legal li { margin: 4px 0; }

.foot { padding: 18px 16px 26px; text-align: center; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); }
.foot p { margin: 4px auto; max-width: 900px; }
