:root {
  --bg: #0a0b0e;
  --sidebar: #0e1015;
  --surface: #13161d;
  --surface-2: #191d26;
  --surface-3: #222734;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ededf0;
  --text-2: #949ba8;
  --text-3: #5e6675;
  --accent: #d4a853;
  --sage: #5eb989;
  --sky: #72a4dc;
  --amber: #dba046;
  --rose: #d86475;
  --radius-card: 4.75% / 3.4%;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
svg.ico { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* Custom subtle scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ==================== APP SHELL ==================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; z-index: 70;
}
.sb-top {
  padding: 13px 12px 11px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.brand-mark {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; letter-spacing: -0.02em; color: var(--text);
}
.brand-sq {
  width: 18px; height: 18px; border-radius: 5px;
  background: linear-gradient(135deg, #d4a853, #9e742b);
  display: inline-flex; align-items: center; justify-content: center;
  color: #0a0b0e; font-size: 10px; font-weight: 800;
}
.sync-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px;
  border-radius: 5px; border: 1px solid transparent; background: transparent;
  font-size: 11px; color: var(--text-3); cursor: pointer;
}
.sync-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-2); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.sync-dot.ok { background: var(--sage); }
.sync-dot.dirty { background: var(--amber); }
.sync-dot.local { background: var(--sky); }

.sb-scroll { flex: 1; overflow-y: auto; padding: 10px 8px 16px; display: flex; flex-direction: column; gap: 14px; }
.sb-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 4px; font-size: 11px; font-weight: 500; color: var(--text-3);
}
.sb-sec-head .lbl { display: inline-flex; align-items: center; gap: 5px; }
.sb-sec-head .cnt { font-variant-numeric: tabular-nums; opacity: 0.7; }
.sb-icon-btn {
  border: 0; background: transparent; color: var(--text-3);
  height: 20px; padding: 0 5px; border-radius: 4px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px;
}
.sb-icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.sb-filter-wrap { padding: 0 4px 5px; }
.sb-filter {
  width: 100%; height: 26px; padding: 0 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 11.5px; outline: none;
}
.sb-filter:focus { border-color: var(--border-strong); }
.sb-filter::placeholder { color: var(--text-3); }

.sb-list { display: flex; flex-direction: column; gap: 1px; }
.sb-item {
  width: 100%; height: 29px; padding: 0 8px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 450;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  cursor: pointer; text-align: left; transition: background .08s, color .08s;
}
.sb-item:hover { background: rgba(255,255,255,0.045); color: var(--text); }
.sb-item.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.sb-item-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-right { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sb-cnt { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 20px; text-align: right; }
.ci-dots { display: inline-flex; gap: 2.5px; align-items: center; }
.ci-dot { width: 5px; height: 5px; border-radius: 50%; }
.ci-W { background: #e8e1ca; } .ci-U { background: #6baee8; } .ci-B { background: #9f86bd; }
.ci-R { background: #e07b68; } .ci-G { background: #73bd82; } .ci-C { background: #7a8394; }

/* ==================== MAIN PANE & HEADERS ==================== */
.main-pane { min-width: 0; display: flex; flex-direction: column; padding-bottom: 36px; }
.page-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 11, 14, 0.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-row {
  height: 52px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.seg {
  display: inline-flex; padding: 2px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border); gap: 2px;
}
.seg button {
  border: 0; background: transparent; color: var(--text-2); height: 26px; padding: 0 11px;
  border-radius: 5px; font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background .1s, color .1s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); }

/* Controls & Buttons */
.btn {
  height: 28px; padding: 0 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  text-decoration: none; transition: border-color .1s, color .1s, background .1s;
}
.btn:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.btn.primary { background: var(--text); border-color: var(--text); color: #0a0b0e; font-weight: 600; }
.btn.primary:hover { background: #ffffff; border-color: #ffffff; color: #0a0b0e; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(255,255,255,0.06); border-color: transparent; }
.btn.danger { color: var(--rose); }
.btn.danger:hover { background: rgba(216,100,117,0.12); border-color: rgba(216,100,117,0.3); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 11.5px; }
.icon-btn {
  width: 28px; height: 28px; padding: 0; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--text-3); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.icon-btn.danger:hover { background: rgba(216,100,117,0.14); color: var(--rose); }

.meta-chip {
  height: 22px; padding: 0 8px; border-radius: 5px; font-size: 11px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.meta-chip.btn-chip { cursor: pointer; }
.meta-chip.btn-chip:hover { border-color: var(--border-strong); color: var(--text); }
.meta-chip.built { color: var(--sage); border-color: rgba(94,185,137,0.28); background: rgba(94,185,137,0.08); }
.meta-chip.exact strong { color: var(--sage); }
.meta-chip.trim { color: var(--amber); border-color: rgba(219,160,70,0.28); background: rgba(219,160,70,0.08); cursor: pointer; }
.meta-chip.trim:hover { background: rgba(219,160,70,0.15); }

/* Subbar */
.subbar {
  height: 42px; padding: 0 24px; border-top: 1px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.tabs { display: flex; align-items: center; gap: 16px; height: 42px; flex-shrink: 0; }
.tab {
  position: relative; height: 100%; display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: transparent; color: var(--text-3); font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px; background: var(--accent); }
.tab span { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.controls-bar { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.input, .select {
  height: 27px; padding: 0 8px; border-radius: 6px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); outline: none;
}
.select {
  padding-right: 22px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center;
}
.input:focus, .select:hover, .select:focus { border-color: var(--border-strong); }
.select option { background: var(--surface-2); color: var(--text); }
.input::placeholder { color: var(--text-3); }

/* Dropdown */
.menu-wrap { position: relative; }
.dropdown {
  display: none; position: absolute; right: 0; top: 34px; min-width: 230px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 4px; box-shadow: 0 16px 40px rgba(0,0,0,0.65); z-index: 100;
}
.dropdown.open { display: block; }
.dropdown button, .dropdown a {
  width: 100%; height: 30px; padding: 0 9px; border: 0; border-radius: 5px;
  background: transparent; color: var(--text); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; text-decoration: none;
}
.dropdown button:hover, .dropdown a:hover { background: rgba(255,255,255,0.06); }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.sub { color: var(--text-3); font-size: 11px; }

/* Scryfall Search Dropdown */
.sf-wrap { position: relative; }
.sf-results {
  display: none; position: absolute; left: 0; top: 32px; width: 340px; max-height: 360px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 4px; box-shadow: 0 18px 42px rgba(0,0,0,0.72); z-index: 110;
}
.sf-results.open { display: block; }
.sf-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 7px; border-radius: 6px; font-size: 12px; }
.sf-item:hover { background: rgba(255,255,255,0.05); }
.sf-item-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sf-thumb { width: 25px; height: 35px; border-radius: 3px; object-fit: cover; flex-shrink: 0; }
.sf-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-sub { font-size: 11px; color: var(--text-3); }
.sf-acts { display: flex; gap: 4px; flex-shrink: 0; }

/* ==================== WORKSPACE & SUMMARY DRAWER ==================== */
.workspace { padding: 18px 24px 24px; }
.hidden { display: none !important; }

.stats-drawer {
  display: grid; grid-template-columns: 1fr 220px 240px; gap: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 14px 18px; margin-bottom: 18px; align-items: start;
}
.sec-label { font-size: 11px; font-weight: 500; color: var(--text-3); margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center; }
.curve { display: flex; align-items: flex-end; gap: 10px; height: 64px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.bar-val { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar { width: 100%; max-width: 26px; background: rgba(212,168,83,0.38); border-top: 1.5px solid var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.bar-lbl { font-size: 10.5px; color: var(--text-3); }
.pips-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.pip-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); font-size: 12px; font-variant-numeric: tabular-nums; }
.pip-left { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.mana-dot { width: 8px; height: 8px; border-radius: 50%; }
.role-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.role-bar { flex: 1; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; max-width: 96px; }
.role-fill { height: 100%; border-radius: 99px; background: var(--text-2); }
.role-fill.ok { background: var(--sage); }
.role-fill.warn { background: var(--amber); }
.role-fill.low { background: var(--rose); }

/* ==================== DECKLIST SHELL ==================== */
.mox-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 24px; align-items: start; }
.mox-shell.no-rail { grid-template-columns: 1fr; }
.left-rail { position: sticky; top: 110px; display: flex; flex-direction: column; gap: 10px; }
.rail-img { width: 100%; border-radius: var(--radius-card); box-shadow: 0 12px 28px rgba(0,0,0,0.55); display: block; cursor: pointer; }
.rail-box { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12px; }
.rail-price-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rail-price { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.rail-link { color: var(--text-2); text-decoration: none; font-size: 11px; }
.rail-link:hover { color: var(--text); text-decoration: underline; }
.rail-note { color: var(--text-2); line-height: 1.48; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border); }
.rail-revisit { color: var(--amber); font-size: 11.5px; margin-top: 6px; line-height: 1.4; }
.printings-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border); }
.print-chip { font-size: 10.5px; padding: 1.5px 6px; border-radius: 4px; background: var(--bg); border: 1px solid var(--border); color: var(--text-2); }
.print-chip.foil { border-color: rgba(212,168,83,0.35); color: #edd193; }

/* Compact Columns */
.compact-cols { column-count: 3; column-gap: 24px; }
@media (max-width: 1460px) { .compact-cols { column-count: 2; } }
.group-block { break-inside: avoid; margin-bottom: 20px; }
.group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding-bottom: 5px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
}
.group-head h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: -0.01em; }
.group-head span { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.c-row {
  position: relative;
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto 64px 14px;
  align-items: center; gap: 6px; padding: 3px 5px; border-radius: 5px;
  font-size: 12.5px; cursor: pointer; transition: background .07s;
}
.c-row:hover { background: rgba(255,255,255,0.045); }
.c-row.out { opacity: 0.38; }
.c-row.out:hover { opacity: 0.85; }
.c-chk {
  width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  color: transparent; background: transparent; cursor: pointer; padding: 0;
}
.c-chk.in { background: rgba(94,185,137,0.16); border-color: rgba(94,185,137,0.6); color: var(--sage); }
.c-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.c-name .q { color: var(--text-3); margin-right: 4px; font-variant-numeric: tabular-nums; }
.foil-tag { font-size: 9.5px; color: var(--accent); margin-left: 4px; font-weight: 600; opacity: 0.85; }
.dfc-tag { font-size: 9.5px; color: var(--text-3); margin-left: 3px; }

.c-price-slot { position: relative; display: flex; align-items: center; justify-content: flex-end; min-width: 0; }
.c-p { text-align: right; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-p.free { color: var(--sage); font-weight: 500; }
.c-p.in-built { color: var(--sky); font-size: 11px; }
.c-p.shared { color: var(--amber); font-size: 11px; }
.c-p.over { color: var(--rose); }
.c-row:hover .c-price-slot.has-move .c-p { opacity: 0; }
.row-act-btn {
  display: none; position: absolute; right: 0; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-2); font-size: 10px; font-weight: 500;
  padding: 1px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.c-row:hover .row-act-btn { display: inline-flex; }
.row-act-btn:hover { color: var(--text); border-color: var(--text-3); }

.dot-btn { border: 0; background: transparent; padding: 2px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-radius: 99px; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-leaning_in { background: var(--sage); }
.dot-considering { background: var(--amber); }
.dot-leaning_cut { background: var(--rose); }
.dot-passed_for_now { background: var(--text-3); }
.dot-empty { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--border-strong); opacity: 0.22; }
.c-row:hover .dot-empty { opacity: 0.85; }

.mana-row { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
.ms {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 14px; height: 14px; padding: 0 2.5px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; line-height: 1; color: #111317;
}
.ms-W { background: #ede6d1; } .ms-U { background: #85c0f0; } .ms-B { background: #b19cc7; }
.ms-R { background: #e8907e; } .ms-G { background: #8ec998; } .ms-C { background: #bec4ce; }
.ms-N { background: #2d323e; color: #d9dde6; }

/* Stacks, Grid, Table */
.stacks-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 22px 14px; align-items: start; }
.stack-col { display: flex; flex-direction: column; }
.stack-cards { position: relative; padding-bottom: 225px; }
.stack-card { position: relative; margin-bottom: -217px; border-radius: var(--radius-card); overflow: hidden; cursor: pointer; box-shadow: 0 -2px 10px rgba(0,0,0,0.55); transition: transform .15s, opacity .15s; }
.stack-card:last-child { margin-bottom: 0; }
.stack-card:hover { transform: translateY(-10px); z-index: 20; }
.stack-card.out { opacity: 0.38; filter: saturate(0.4); }
.stack-card img { width: 100%; display: block; border-radius: var(--radius-card); }

.role-section { margin-bottom: 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 16px 14px; }
.card-item { display: flex; flex-direction: column; transition: opacity .15s; }
.card-item.out { opacity: 0.4; filter: saturate(0.45); }
.card-item.out:hover { opacity: 0.95; filter: saturate(1); }
.card-art { position: relative; aspect-ratio: 488 / 680; border-radius: var(--radius-card); overflow: hidden; background: var(--surface); cursor: pointer; box-shadow: 0 5px 16px rgba(0,0,0,0.4); transition: transform .14s; }
.card-art:hover { transform: translateY(-2px); }
.card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-art .hover-note { position: absolute; left: 7px; right: 7px; bottom: 7px; background: rgba(10,11,14,0.92); backdrop-filter: blur(8px); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 8px; font-size: 11px; line-height: 1.38; color: var(--text); opacity: 0; pointer-events: none; transition: opacity .12s; }
.card-art:hover .hover-note { opacity: 1; }
.card-foot { padding: 6px 2px 0; display: flex; flex-direction: column; gap: 3px; }
.foot-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.c-title { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.foot-bot { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--text-3); }
.toggle-chip { padding: 1.5px 7px; border-radius: 4px; font-size: 10.5px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--text-2); }
.toggle-chip:hover { border-color: var(--border-strong); color: var(--text); }
.toggle-chip.in { background: rgba(94,185,137,0.12); border-color: rgba(94,185,137,0.3); color: var(--sage); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
table.tbl th { text-align: left; padding: 6px 8px; font-size: 11px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border); }
table.tbl td { padding: 0 8px; height: 34px; border-bottom: 1px solid rgba(255,255,255,0.045); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.tbl tr { cursor: pointer; }
table.tbl tr:hover td { background: rgba(255,255,255,0.035); }
table.tbl tr.out td { opacity: 0.42; }

/* ==================== CLEAN METRIC STRIP (Stripe/Linear style) ==================== */
.metric-strip {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  overflow: hidden; margin-bottom: 14px;
}
.metric-strip.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.m-cell { padding: 12px 16px; border-right: 1px solid var(--border); transition: background .1s; }
.m-cell:last-child { border-right: 0; }
.m-cell.clickable { cursor: pointer; }
.m-cell.clickable:hover { background: rgba(255,255,255,0.03); }
.m-cell.active { background: rgba(212,168,83,0.07); box-shadow: inset 0 -2px 0 var(--accent); }
.m-lbl { font-size: 11px; color: var(--text-3); font-weight: 500; }
.m-val { font-size: 18px; font-weight: 600; margin-top: 3px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.m-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Collection Filters */
.col-filters {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.ci-btn {
  width: 24px; height: 24px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.18);
  color: #111317; font-size: 10.5px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; opacity: 0.45;
  transition: opacity .1s, transform .1s;
}
.ci-btn:hover { opacity: 0.85; }
.ci-btn.on { opacity: 1; border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.22); }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; font-size: 12px; color: var(--text-2); }

/* ==================== MATH & GOLDFISH ==================== */
.inline-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 12.5px;
  background: rgba(219,160,70,0.08); border: 1px solid rgba(219,160,70,0.24); color: #ebd09b;
}
.math-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.math-subtabs { display: inline-flex; align-items: center; gap: 4px; }
.math-subtab {
  border: 0; background: transparent; color: var(--text-3); padding: 6px 11px;
  border-radius: 6px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: background .1s, color .1s;
}
.math-subtab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.math-subtab.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
.math-subtab .cnt {
  font-size: 10.5px; color: var(--text-3); background: var(--bg);
  padding: 1px 6px; border-radius: 99px; font-variant-numeric: tabular-nums;
}
.math-controls { display: inline-flex; align-items: center; gap: 8px; }

.math-stage { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.math-stage.odds-split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.math-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px;
}
.math-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.math-card-head h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.math-card-head .meta { font-size: 11.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.math-divider { height: 1px; background: var(--border); margin: 18px 0; }

/* Visual Mana Curve + Castability Chart */
.curve-chart {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px;
  align-items: end; padding: 6px 4px 2px;
}
.curve-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.curve-plot {
  width: 100%; height: 128px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  position: relative; border-bottom: 1px solid var(--border); padding-bottom: 2px;
}
.curve-count { font-size: 11px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.curve-bar-track {
  width: 34px; max-width: 78%; border-radius: 5px 5px 2px 2px; overflow: hidden;
  background: rgba(255,255,255,0.06); position: relative; min-height: 4px;
  display: flex; align-items: flex-end;
}
.curve-bar-fill { width: 100%; border-radius: 4px 4px 2px 2px; transition: height .2s; }
.curve-bar-fill.ok { background: linear-gradient(180deg, rgba(94,185,137,0.85), rgba(94,185,137,0.35)); }
.curve-bar-fill.warn { background: linear-gradient(180deg, rgba(219,160,70,0.88), rgba(219,160,70,0.35)); }
.curve-bar-fill.bad { background: linear-gradient(180deg, rgba(224,108,117,0.88), rgba(224,108,117,0.35)); }
.curve-bar-fill.empty { background: var(--surface-3); }
.curve-mv { font-size: 11.5px; font-weight: 600; color: var(--text); }
.curve-rate { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.curve-delay { font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Commander Cast Trajectory Rows */
.traj-list { display: flex; flex-direction: column; gap: 9px; }
.traj-row {
  display: grid; grid-template-columns: 98px 1fr 122px 86px; gap: 12px; align-items: center;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.traj-turn { font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.traj-tag { font-size: 9.5px; font-weight: 500; padding: 1px 5px; border-radius: 4px; background: rgba(212,168,83,0.14); color: var(--accent); }
.traj-bar-box { display: flex; align-items: center; gap: 9px; }
.traj-track { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.traj-fill { height: 100%; border-radius: 99px; background: var(--sage); }
.traj-fill.warn { background: var(--amber); }
.traj-fill.bad { background: var(--rose); }
.traj-pct { width: 42px; text-align: right; font-weight: 600; color: var(--text); }
.traj-screw { font-size: 11.5px; color: var(--text-3); text-align: right; }
.traj-screw.hot { color: var(--amber); }
.traj-screw.bad { color: var(--rose); }
.traj-land { font-size: 11.5px; color: var(--text-3); text-align: right; }

/* Color Bullet Meters (Karsten Audit) */
.color-audit-list { display: flex; flex-direction: column; gap: 14px; }
.color-row { display: flex; flex-direction: column; gap: 6px; }
.color-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.color-id { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text); }
.color-nums { display: inline-flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--text-3); }
.color-nums strong { color: var(--text); font-weight: 600; }
.color-delta { font-weight: 600; min-width: 38px; text-align: right; }
.bullet-track { position: relative; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: visible; }
.bullet-fill { height: 100%; border-radius: 99px; }
.bullet-target {
  position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 2px;
  background: rgba(255,255,255,0.75); box-shadow: 0 0 6px rgba(0,0,0,0.65);
}
.color-bottleneck {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; color: var(--text-3);
}
.bottleneck-btn {
  border: 0; background: transparent; padding: 0; color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
}
.bottleneck-btn:hover { color: var(--accent); }

/* Actionable Diagnostics List */
.diag-list { display: flex; flex-direction: column; gap: 8px; }
.diag-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 11px; border-radius: 7px;
  font-size: 12px; line-height: 1.42; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--border);
}
.diag-dot { width: 7px; height: 7px; border-radius: 99px; margin-top: 5px; flex-shrink: 0; }
.diag-dot.bad { background: var(--rose); }
.diag-dot.warn { background: var(--amber); }
.diag-dot.ok { background: var(--sage); }

/* Hypergeometric Odds & What-If Calculator */
.odds-list { display: flex; flex-direction: column; gap: 10px; }
.odds-row { display: grid; grid-template-columns: 1fr 48px 136px; gap: 10px; align-items: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.odds-cnt { text-align: right; color: var(--text-3); font-size: 11.5px; }
.whatif-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.whatif-inputs { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.whatif-inputs input {
  width: 50px; height: 26px; padding: 0 7px; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 12px; font-variant-numeric: tabular-nums; text-align: center;
}
.whatif-result { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--sage); }

/* Combos List */
.combo-item { padding: 9px 0; border-bottom: 1px solid var(--border); }
.combo-item:last-child { border-bottom: 0; }
.combo-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.combo-head a { color: var(--text); text-decoration: none; font-size: 12.5px; font-weight: 500; }
.combo-head a:hover { color: var(--accent); }
.combo-prod { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

/* AI Pods Lab */
.pod-builder {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px;
}
.pod-builder-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0;
}
.pod-builder-opts {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding-top: 10px; border-top: 1px solid var(--border);
}
.pod-builder-opts select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 5px 9px; font-size: 12px; height: 28px; outline: none; cursor: pointer;
}
.pod-builder-opts select:focus { border-color: var(--accent); }
.pod-cmd-preview {
  margin-top: 10px; padding: 8px 11px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 10px;
  overflow-x: auto;
}
.pod-runs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pod-run-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 15px 16px; display: flex; flex-direction: column; gap: 10px;
}
.pod-run-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pod-run-tags { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pod-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 54px 140px; gap: 10px; align-items: center;
  padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.045); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.pod-row:last-child { border-bottom: 0; }
.pod-row.winner .pod-name { color: var(--text); font-weight: 600; }
.pod-name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-score { text-align: right; color: var(--text-3); font-size: 11.5px; }
.pod-log-toggle { font-size: 11px; color: var(--text-3); cursor: pointer; user-select: none; }
.pod-log-lines {
  margin-top: 6px; padding: 8px 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10.5px; color: var(--text-3);
  line-height: 1.5;
}

.lab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 14px 16px; }
.panel h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-tbl { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.metric-tbl th { text-align: left; padding: 5px 6px; font-size: 11px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border); }
.metric-tbl td { padding: 6px; border-bottom: 1px solid rgba(255,255,255,0.045); }
.pct-bar-wrap { display: inline-flex; align-items: center; gap: 8px; width: 100%; }
.pct-bar { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; max-width: 100px; }
.pct-fill { height: 100%; border-radius: 99px; background: var(--sage); }
.pct-fill.warn { background: var(--amber); }
.pct-fill.bad { background: var(--rose); }

/* Goldfish Tabletop */
.gf-tabletop { display: grid; grid-template-columns: 192px minmax(0, 1fr); gap: 16px; align-items: start; }
.gf-cmdr-col { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 12px; }
.gf-cmdr-card { cursor: pointer; transition: transform .12s; }
.gf-cmdr-card:hover { transform: translateY(-2px); }
.gf-cmdr-card img { width: 100%; border-radius: var(--radius-card); display: block; box-shadow: 0 8px 20px rgba(0,0,0,0.55); }
.gf-cmdr-card.cast img { opacity: 0.35; filter: saturate(0.3); }
.gf-zone { margin-bottom: 12px; }
.gf-cards {
  display: flex; flex-wrap: wrap; gap: 11px; min-height: 150px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; align-items: flex-start;
}
.gf-card { width: 136px; cursor: pointer; transition: transform .14s; position: relative; }
.gf-card:hover { transform: translateY(-5px); z-index: 10; }
.gf-card img { width: 100%; border-radius: var(--radius-card); display: block; box-shadow: 0 6px 16px rgba(0,0,0,0.5); }
.gf-card-hint {
  position: absolute; left: 8px; right: 8px; bottom: 8px; text-align: center;
  background: rgba(10,11,14,0.92); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 10.5px; font-weight: 500; padding: 3px 6px; border-radius: 5px;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.gf-card:hover .gf-card-hint { opacity: 1; }
.gf-log { margin-top: 12px; font-size: 11.5px; color: var(--text-3); max-height: 220px; overflow-y: auto; line-height: 1.5; border-top: 1px solid var(--border); padding-top: 8px; }

/* ==================== BOTTOM STATUS BAR ==================== */
.bottombar {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; z-index: 55;
  background: rgba(14,16,21,0.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); height: 34px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums;
}
.bottom-left, .bottom-right { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.bottom-left strong, .bottom-right strong { color: var(--text); font-weight: 500; }
.legend-inline { display: inline-flex; align-items: center; gap: 10px; }
.legend-inline span { display: inline-flex; align-items: center; gap: 4px; }

/* ==================== REFINED MODALS (Linear/Raycast style) ==================== */
.modal-bg {
  display: none; position: fixed; inset: 0; background: rgba(4,5,8,0.72);
  backdrop-filter: blur(6px); z-index: 140; align-items: center; justify-content: center; padding: 24px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px;
  max-width: 740px; width: 100%; max-height: 86vh; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,0.75);
}
.modal.wide { max-width: 820px; }
.modal-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
}
.modal-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 11px 18px; border-top: 1px solid var(--border); background: var(--sidebar);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0;
  font-size: 12px; color: var(--text-3);
}

/* Hairline Deck Manager Rows (Zero box-in-box slop!) */
.mgr-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.mgr-table { width: 100%; border-collapse: collapse; }
.mgr-table tr { border-bottom: 1px solid var(--border); transition: background .08s; }
.mgr-table tr:last-child { border-bottom: 0; }
.mgr-table tr:hover { background: rgba(255,255,255,0.025); }
.mgr-table td { padding: 9px 6px; vertical-align: middle; }
.mgr-title { font-size: 13px; font-weight: 500; color: var(--text); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.mgr-title:hover { color: var(--accent); }
.mgr-meta { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mgr-seg {
  display: inline-flex; padding: 2px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
}
.mgr-seg button {
  border: 0; background: transparent; color: var(--text-3); height: 22px; padding: 0 9px;
  border-radius: 4px; font-size: 11px; font-weight: 500; cursor: pointer;
}
.mgr-seg button.on-built { background: rgba(94,185,137,0.18); color: var(--sage); }
.mgr-seg button.on-unbuilt { background: var(--surface-3); color: var(--text); }
.mgr-row-acts { display: inline-flex; align-items: center; gap: 2px; opacity: 0.35; transition: opacity .1s; }
.mgr-table tr:hover .mgr-row-acts { opacity: 1; }

.modal-card-grid { display: grid; grid-template-columns: 248px 1fr; gap: 20px; }
.modal-art img { width: 100%; border-radius: var(--radius-card); display: block; }
.oracle-box { white-space: pre-wrap; font-size: 12.5px; line-height: 1.5; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 11px 13px; margin: 10px 0; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 11px; color: var(--text-3); font-weight: 500; }
.field textarea, .field input, .field select { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 7px 9px; font-size: 12.5px; outline: none; }
.field textarea:focus, .field input:focus { border-color: var(--border-strong); }
.diff-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.diff-box { background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; font-size: 12px; }

.toast {
  position: fixed; bottom: 46px; right: 20px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
  padding: 8px 14px; border-radius: 7px; font-size: 12px; display: none; z-index: 220;
  box-shadow: 0 12px 30px rgba(0,0,0,0.55);
}
