/* MTG Collection — one stylesheet, no framework.
   Dark by default because that is how card images look best; light is a
   full palette swap rather than an afterthought. */

:root {
  --bg:        #0e1116;
  --bg-2:      #151a22;
  --bg-3:      #1c232d;
  --bg-hover:  #222b37;
  --line:      #262f3c;
  --line-2:    #344052;
  --text:      #e4e9f0;
  --text-2:    #9aa7b8;
  --text-3:    #6b7889;
  --accent:    #d4a24c;
  --accent-2:  #f0c070;
  --accent-dim:#3a2f18;
  --ok:        #4ea672;
  --warn:      #d99b3c;
  --bad:       #d6636b;
  --info:      #5b9bd5;

  --w: #f8f2dc; --u: #9dd0f2; --b: #a99fae; --r: #f0a08c; --g: #92cfa4; --c: #c3ccd8;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --topbar-h: 54px;
}

:root[data-theme="light"] {
  --bg:        #f6f7f9;
  --bg-2:      #ffffff;
  --bg-3:      #eef1f5;
  --bg-hover:  #e4e9f0;
  --line:      #dde3ea;
  --line-2:    #c6cfda;
  --text:      #16202c;
  --text-2:    #5a6878;
  --text-3:    #8695a6;
  --accent:    #9a6c14;
  --accent-2:  #7d570c;
  --accent-dim:#f5e9cf;
  --ok:        #2f7d52;
  --warn:      #9a6a12;
  --bad:       #b2333c;
  --info:      #2a6ba8;

  --w: #b9a94a; --u: #2f7fc0; --b: #6a5f70; --r: #c25a3f; --g: #3d8f56; --c: #7c8a99;
  --shadow: 0 8px 30px rgba(22,32,44,.12);
}

* { box-sizing: border-box; }

/* .drawer and .palette-scrim set display, which would beat the default
   [hidden] rule. Toggling .hidden via the property must actually hide them. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #101010; padding: 10px 16px;
}
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h);
  padding: 0 14px;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 650; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 17px; height: 23px; border-radius: 3px; flex: none;
  background: linear-gradient(150deg, var(--accent-2), var(--accent) 45%, #8a6320);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.brand-text { white-space: nowrap; }

.tabs { display: flex; gap: 2px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 7px 13px; border-radius: 7px; color: var(--text-2);
  font-weight: 500; white-space: nowrap;
}
.tabs a:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--accent-dim); color: var(--accent-2); }
/* Edit views while admin mode is off. Still reachable — the view itself
   explains what is needed — but visibly not currently usable. */

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.conn { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.conn.ok i { background: var(--ok); box-shadow: 0 0 7px color-mix(in srgb, var(--ok) 70%, transparent); }
.conn.bad i { background: var(--bad); }
.conn.busy i { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-3); color: var(--text-2); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ico-sun { display: none; }
:root[data-theme="light"] .ico-sun { display: block; }
:root[data-theme="light"] .ico-moon { display: none; }

.nav-toggle { display: none; }

/* ---------------------------------------------------------------- layout */
main { min-height: calc(100vh - var(--topbar-h)); }

.wrap { max-width: 1680px; margin: 0 auto; padding: 18px; }

.split { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 18px; align-items: start; }

.panel {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-3);
}
.panel-head h2 { flex: 1; font-size: 13px; letter-spacing: .02em; text-transform: uppercase; color: var(--text-2); }

/* The results bar carries seven controls. On a phone they have to wrap
   rather than run off the edge, and the count must not hog the slack. */
.results-head { flex-wrap: wrap; row-gap: 8px; }
.results-head h2 { flex: none; }
.panel-body { padding: 14px; }

.sticky-side { position: sticky; top: calc(var(--topbar-h) + 18px); max-height: calc(100vh - var(--topbar-h) - 36px); overflow-y: auto; }

.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--text-2); font-size: 13px; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
        letter-spacing: .04em; color: var(--text-3); margin-bottom: 5px; }

input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; font-size: 13.5px;
}
textarea { font-family: var(--mono); font-size: 13px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
  linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #17130a; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { border-color: color-mix(in srgb, var(--bad) 55%, var(--line-2)); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-3); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text-2); font-size: 12px; cursor: pointer;
  user-select: none; white-space: nowrap;
}
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-2); font-weight: 600; }
.chip.mini { padding: 2px 7px; font-size: 11px; }

/* pip toggles, one per colour */
.pips { display: flex; gap: 5px; }
.pip {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-2); background: var(--bg);
  font-weight: 800; font-size: 12.5px; cursor: pointer; color: var(--text-3);
  font-family: var(--mono);
}
.pip:hover { border-color: var(--text-2); }
.pip[data-c=W].on { background: var(--w); border-color: var(--w); color: #3a3312; }
.pip[data-c=U].on { background: var(--u); border-color: var(--u); color: #08283c; }
.pip[data-c=B].on { background: var(--b); border-color: var(--b); color: #241f28; }
.pip[data-c=R].on { background: var(--r); border-color: var(--r); color: #451a10; }
.pip[data-c=G].on { background: var(--g); border-color: var(--g); color: #103320; }
.pip[data-c=C].on { background: var(--c); border-color: var(--c); color: #1d2630; }

/* inline mana cost */
.mana { display: inline-flex; gap: 2px; vertical-align: -2px; flex-wrap: wrap; }
.ms {
  width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center;
  font: 700 9.5px/1 var(--mono); background: var(--c); color: #1d2630; flex: none;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.2);
}
.ms[data-s=W] { background: var(--w); color: #3a3312; }
.ms[data-s=U] { background: var(--u); color: #08283c; }
.ms[data-s=B] { background: var(--b); color: #241f28; }
.ms[data-s=R] { background: var(--r); color: #451a10; }
.ms[data-s=G] { background: var(--g); color: #103320; }
.ms.hybrid { background: linear-gradient(135deg, var(--a1) 50%, var(--a2) 50%); font-size: 8px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 8px 11px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-3);
  border-bottom: 1px solid var(--line); background: var(--bg-3);
  position: sticky; top: 0; white-space: nowrap;
}
td { padding: 7px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--bg-3); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: var(--mono); font-size: 12.5px; }
.t-name { font-weight: 550; }

/* ---------------------------------------------------------------- cards */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.card {
  position: relative; cursor: pointer; border-radius: 9px;
  transition: transform .12s ease;
}
.card:hover { transform: translateY(-3px); }
.card:hover .card-img { box-shadow: 0 10px 24px rgba(0,0,0,.4); }
.card-img {
  width: 100%; aspect-ratio: 488/680; border-radius: 4.75% / 3.4%;
  background: var(--bg-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7889' stroke-width='1.2'%3E%3Crect x='4' y='2' width='16' height='20' rx='2'/%3E%3C/svg%3E") center/32px no-repeat;
  display: block; object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}
/* Overlays hang off the art, so bottom: 6px is the bottom of the card
   picture and not somewhere under the caption. */
.card-art { position: relative; display: block; }

.card-meta { margin-top: 6px; font-size: 12px; line-height: 1.35; }
.card-meta .nm { font-weight: 550; display: block; }
.card-meta .sb { color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.card-meta .qty {
  margin-left: auto; color: var(--text-2);
  font: 700 11.5px/1 var(--mono); white-space: nowrap;
}
.card-meta .set { font-size: 11px; }

.free-badge {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 6px; border-radius: 5px;
  background: rgba(8,10,14,.86); color: var(--ok); font: 700 10px/1.4 var(--mono);
  box-shadow: 0 0 0 1px rgba(255,255,255,.14);
}
.free-badge.none { color: var(--text-3); }
.price-badge {
  position: absolute; right: 6px; bottom: 6px; padding: 2px 7px; border-radius: 5px;
  background: rgba(8,10,14,.86); color: var(--accent-2);
  font: 700 11px/1.5 var(--mono); box-shadow: 0 0 0 1px rgba(255,255,255,.14);
  pointer-events: none;
}
.price-badge:empty { display: none; }

/* ---------------------------------------------------------------- drawer */
.drawer-scrim { position: fixed; inset: 0; background: rgba(4,6,10,.62); z-index: 60; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--bg-2); border-left: 1px solid var(--line);
  z-index: 61; overflow-y: auto; box-shadow: var(--shadow);
  animation: slide .16s ease;
}
@keyframes slide { from { transform: translateX(24px); opacity: .4; } }
.drawer-head {
  position: sticky; top: 0; z-index: 2; display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.drawer-head h2 { flex: 1; font-size: 16px; }
.drawer-body { padding: 16px; }
.drawer-art { width: 100%; max-width: 300px; border-radius: 4.75% / 3.4%; display: block; margin: 0 auto 8px; box-shadow: var(--shadow); }

.oracle { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; }
.flavor { white-space: pre-wrap; font-style: italic; color: var(--text-3); font-size: 12.5px; margin-top: 8px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding-top: 2px; }
.kv dd { margin: 0; }

.sec { margin-top: 20px; }
.sec > h3 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
  margin-bottom: 9px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}

/* ---------------------------------------------------------------- misc */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile .n { font: 700 25px/1.1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile .l { color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }

.bar-row { display: grid; grid-template-columns: 96px 1fr 52px; gap: 10px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.bar-row .lbl { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg-3); border-radius: 4px; height: 17px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }

.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 11.5px;
  background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line);
}
.tag.ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.tag.bad  { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.tag.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, var(--line)); }

.empty { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty h3 { color: var(--text-2); margin-bottom: 6px; }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--line-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err {
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 42%, transparent);
  color: var(--bad); padding: 10px 13px; border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap;
}

pre.out {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; margin: 0;
}

/* toasts */
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow);
  font-size: 13px; max-width: 380px; animation: pop .15s ease;
}
.toast.ok  { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

/* command palette */
.palette-scrim { position: fixed; inset: 0; background: rgba(4,6,10,.6); z-index: 80; display: grid; place-items: start center; padding-top: 12vh; }
.palette { width: min(560px, 92vw); background: var(--bg-2); border: 1px solid var(--line-2);
           border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.palette input { border: none; border-radius: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; font-size: 15px; }
.palette input:focus { border-color: var(--line); }
.palette ul { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.palette li { padding: 9px 16px; cursor: pointer; display: flex; gap: 10px; align-items: center; font-size: 13.5px; }
.palette li.on { background: var(--accent-dim); }
.palette-hint { padding: 8px 16px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 11.5px; }

/* ------------------------------------------------------------ uploader */
.dropzone {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px; cursor: pointer;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text-2);
  transition: border-color .12s ease, background .12s ease;
}
.dropzone:hover { border-color: var(--accent); background: var(--bg-3); }
.dropzone.over {
  border-color: var(--accent); background: var(--accent-dim);
  border-style: solid;
}
.dz-icon { font-size: 20px; color: var(--accent); line-height: 1; flex: none; }
.dz-main { font-size: 13.5px; font-weight: 550; color: var(--text); }
.dz-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* ---------------------------------------------------------------- logs */
.log-stats {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.log-stat { display: flex; align-items: baseline; gap: 6px; }
.log-stat > span:first-child { font: 700 18px/1 var(--sans); font-variant-numeric: tabular-nums; }
.log-stat .bad-n { color: var(--bad); }
.log-stat .warn-n { color: var(--warn); }
.log-stat .l { color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }

tr.row-error td { background: color-mix(in srgb, var(--bad) 9%, transparent); }
.log-detail { padding: 12px 4px; background: var(--bg); border-radius: var(--radius-sm); }

/* Errors get cards rather than rows: when you are reading errors the
   message is the only thing that matters, so it leads. */
.err-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm); padding: 11px 13px;
}
.err-card.is-error { border-left-color: var(--bad); }
.err-head { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.err-msg {
  font-size: 13px; color: var(--text); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.err-sub { margin-top: 5px; }

/* pagination */
.pager { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 18px 0; }
.pager .info { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }

/* little drop-up/down attached to a button */
.menu-wrap { position: relative; display: inline-block; }
.menu-wrap .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 178px; padding: 5px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-wrap .menu button {
  text-align: left; padding: 8px 10px; border: none; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.menu-wrap .menu button:hover { background: var(--bg-3); color: var(--accent-2); }

/* add/remove wizard */
.steps { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.steps .step {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-2); color: var(--text-2); font: inherit; font-size: 13px;
}
.steps .step:not(:disabled) { cursor: pointer; }
.steps .step:not(:disabled):hover { border-color: var(--line-2); background: var(--bg-3); }
.steps .step-n {
  display: inline-grid; place-items: center; width: 19px; height: 19px;
  border-radius: 50%; background: var(--bg); border: 1px solid var(--line-2);
  font-size: 11px; line-height: 1;
}
.steps .step.on { border-color: var(--accent); background: var(--accent-dim); color: var(--accent-2); }
.steps .step.on .step-n { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.steps .step.done { color: var(--text); }
.steps .step.done .step-n { color: var(--ok, var(--accent-2)); }

/* step two is one decision, so make it one decision's worth of target */
.owner-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.owner-pick .owner-opt {
  flex: 1; min-width: 130px; padding: 18px 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--bg-2); color: var(--text); font: inherit; font-size: 15px;
  cursor: pointer; text-transform: capitalize;
}
.owner-pick .owner-opt:hover { border-color: var(--accent); background: var(--bg-3); }
.owner-pick .owner-opt.on {
  border-color: var(--accent); background: var(--accent-dim); color: var(--accent-2);
}

/* deck list */
.deck-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }
.deck-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; display: flex; flex-direction: column; overflow: hidden;
}
.deck-card:hover { border-color: var(--line-2); background: var(--bg-3); }

/* commander art, cropped to a band across the top */
.deck-banner { flex: none; height: 96px; background: var(--bg-3); overflow: hidden; }
.deck-banner.none { display: none; }
.deck-banner img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: center 38%;
}

.deck-body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 7px; }
.deck-top { display: flex; align-items: flex-start; gap: 8px; }
.deck-top .tag { flex: none; margin-top: 1px; }
.deck-name { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.deck-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.deck-card .cmdr {
  min-width: 0; color: var(--text-2); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pillbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--bg-3); }
.pillbar i { display: block; height: 100%; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  padding: 6px 12px; border: none; background: var(--bg); color: var(--text-2);
  font: inherit; font-size: 12.5px; cursor: pointer; border-right: 1px solid var(--line-2);
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: var(--bg-3); color: var(--text); }
.seg button.on { background: var(--accent-dim); color: var(--accent-2); font-weight: 600; }

details.adv { border-top: 1px solid var(--line); padding-top: 11px; margin-top: 11px; }
details.adv > summary { cursor: pointer; color: var(--text-2); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; list-style: none; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: "▸ "; color: var(--text-3); }
details.adv[open] > summary::before { content: "▾ "; }
details.adv > div { padding-top: 12px; }

/* ============================================================ search UI
   The filter surface is full width and always legible: a responsive grid
   of groups, every control visible, no accordions to hunt through. */

.searchbar {
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.bigsearch { flex: 1 1 260px; min-width: 200px; padding: 9px 12px; font-size: 14.5px; }
.count-pill {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  padding: 0 5px; margin-left: 2px; border-radius: 99px;
  background: var(--bg); color: var(--accent-2);
  font: 700 11px/1 var(--mono);
}
.btn.primary .count-pill { background: rgba(0,0,0,.24); color: inherit; }

/* The Filters toggle marks "open", which everything else in here says with
   accent-dim — tabs, chips, segmented controls. Solid gold made the single
   largest control on a phone the loudest thing on the page. */
.btn.open { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-2); }
.btn.open:hover { background: color-mix(in srgb, var(--accent) 22%, var(--bg-2)); }
.btn.open .count-pill { background: var(--bg); color: var(--accent-2); }

.active-bar {
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
  padding: 9px 11px; margin-bottom: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.active-bar > .chips { flex: 1; }

/* One scrollbar on the page, never a box that scrolls inside another box.
   The panel is as tall as it needs to be; collapsing is what keeps it out
   of the way. */
.filters-wrap { margin-bottom: 14px; }
.fpanel-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 0 2px 7px;
}

.fgrid {
  display: grid; gap: 1px; background: var(--line);
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
}
.fgroup { background: var(--bg-2); min-width: 0; align-self: start; }
.fgroup > summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 11px 14px; list-style: none;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2); user-select: none;
}
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::before {
  content: "▸"; color: var(--text-3); font-size: 9px; transition: transform .12s ease;
}
.fgroup[open] > summary::before { transform: rotate(90deg); }
.fgroup > summary:hover { background: var(--bg-3); color: var(--text); }
.fgroup[open] > summary { color: var(--accent-2); border-bottom: 1px solid var(--line); }
.fg-title { flex: 1; }
.fgroup-body { padding: 13px 14px 15px; }
.fgroup-body > * + * { margin-top: 11px; }
.fgroup-color[open] { background: color-mix(in srgb, var(--accent) 5%, var(--bg-2)); }

.frow > label {
  display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3); margin-bottom: 5px;
}
.hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; line-height: 1.4; }

/* real checkboxes, because a checkbox should look like a checkbox */
.checks { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 3px 10px; }
.check {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 12.5px; color: var(--text-2); text-transform: none;
  letter-spacing: 0; font-weight: 400; margin: 0; padding: 2px 0;
  min-width: 0;
}
.check:hover { color: var(--text); }
.check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check input[type=checkbox] {
  appearance: none; width: 15px; height: 15px; flex: none; margin: 0;
  border: 1.5px solid var(--line-2); border-radius: 4px; background: var(--bg);
  cursor: pointer; position: relative;
}
.check input[type=checkbox]:hover { border-color: var(--text-3); }
.check input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.check input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px; border: solid #17130a;
  border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.check input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the four colour modes, all visible at once */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.mode-grid .chip { text-align: center; padding: 7px 8px; justify-content: center; }

.seg-sm button { padding: 3px 9px; font-size: 11.5px; }
.tri-list > * + * { margin-top: 6px; }
.tri { display: flex; align-items: center; gap: 9px; }
.tri-label { flex: 1; font-size: 12.5px; color: var(--text-2); min-width: 0;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.qbox { font-family: var(--mono); font-size: 13.5px; padding: 10px 12px; }
.qbox:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.scroll-list { max-height: 210px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; background: var(--bg); }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .sticky-side { position: static; max-height: none; }
}

@media (max-width: 560px) {
  .fgrid { grid-template-columns: 1fr; }
  .bigsearch { flex-basis: 100%; }
}

@media (max-width: 720px) {
  .wrap { padding: 12px; }
  .conn span { display: none; }
  .tabs { position: fixed; top: var(--topbar-h); left: 0; right: 0; z-index: 39;
          flex-direction: column; background: var(--bg-2); border-bottom: 1px solid var(--line);
          padding: 8px; gap: 2px; display: none; box-shadow: var(--shadow); }
  .tabs.open { display: flex; }
  .nav-toggle { display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
                border: 1px solid var(--line); border-radius: 8px; background: var(--bg-3);
                color: var(--text-2); cursor: pointer; }
  .nav-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .drawer { width: 100%; }
  .bar-row { grid-template-columns: 78px 1fr 44px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

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