/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0e0f13;
  --bg2: #161820;
  --bg3: #1e2030;
  --bg4: #252840;
  --border: #2e3150;
  --accent: #7c6af7;
  --accent2: #a78bfa;
  --accent-glow: rgba(124,106,247,.25);
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --orange: #fb923c;
  --text: #e2e4f0;
  --text2: #8b8fa8;
  --text3: #5a5f7a;
  --w: #f9fafb; --u: #60a5fa; --b: #6b21a8; --r: #ef4444; --g: #22c55e;

  /* Mana symbol colors */
  --mana-w: #fef9c3; --mana-u: #3b82f6; --mana-b: #9333ea;
  --mana-r: #ef4444;  --mana-g: #22c55e;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,.45);
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: .4px; }

.mana {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 8px; font-weight: bold; color: #000;
}
.mana.w { background: var(--mana-w); }
.mana.u { background: var(--mana-u); color: #fff; }
.mana.b { background: var(--mana-b); color: #fff; }
.mana.r { background: var(--mana-r); color: #fff; }
.mana.g { background: var(--mana-g); color: #fff; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  font-size: .72rem; padding: 4px 10px; border-radius: 20px;
  font-weight: 600; letter-spacing: .3px;
}
.badge-pending  { background: var(--bg4); color: var(--text2); }
.badge-ready    { background: rgba(74,222,128,.15); color: var(--green); border: 1px solid rgba(74,222,128,.3); }
.badge-building { background: rgba(251,191,36,.15); color: var(--yellow); border: 1px solid rgba(251,191,36,.3); }
.badge-error    { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.3); }
.badge-stale    { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.3); }
.badge-aging    { background: rgba(251,191,36,.15); color: var(--yellow); border: 1px solid rgba(251,191,36,.3); }

.header-status-group { display: flex; align-items: center; gap: 8px; }

.btn-update {
  background: rgba(124,106,247,.15); color: var(--accent2);
  border: 1px solid var(--accent); border-radius: 20px;
  padding: 4px 12px; font-size: .72rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-update:hover { background: rgba(124,106,247,.3); }
.btn-update.stale {
  background: rgba(248,113,113,.15); color: var(--red);
  border-color: var(--red); animation: pulse-stale 2s infinite;
}
@keyframes pulse-stale {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}

/* ── Download overlay ─────────────────────────────────────────────────── */
.download-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(3px);
}
.download-box {
  background: var(--bg2); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 32px 40px; min-width: 380px;
  box-shadow: 0 0 40px var(--accent-glow);
  display: flex; flex-direction: column; gap: 12px;
}
.download-title   { font-size: 1rem; font-weight: 700; color: var(--text); }
.download-message { font-size: .83rem; color: var(--text2); min-height: 1.2em; }
.download-bar-bg  { background: var(--bg4); border-radius: 6px; height: 10px; overflow: hidden; }
.download-bar-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .3s ease; }
.download-pct     { font-size: .78rem; color: var(--text2); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Main Layout ──────────────────────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }

/* ── Auth ─────────────────────────────────────────────────────────────── */
.auth-panel {
  max-width: 420px;
  margin: 42px auto;
}
.auth-note {
  color: var(--text2);
  font-size: .86rem;
  margin-bottom: 18px;
  line-height: 1.45;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-form label {
  font-size: .78rem;
  color: var(--text2);
  font-weight: 700;
}
.auth-form input {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .9rem;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
#auth-confirm-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}
.auth-actions .btn-primary { margin-top: 0; }
.auth-status {
  min-height: 1.2em;
  color: var(--text2);
  font-size: .82rem;
  line-height: 1.4;
}
.auth-status.error { color: var(--red); }
.auth-status.ok { color: var(--green); }
.auth-link-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--accent2);
  cursor: pointer;
  font-size: .82rem;
  padding: 2px 0;
  text-align: left;
  width: fit-content;
}
.auth-link-btn:hover { color: var(--text); text-decoration: underline; }

/* ── Panels ───────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }
.panel-inner {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-top: 16px;
}
.panel-inner h3 { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text2); margin-bottom: 14px; }

/* ── Drop Zone ────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.drop-icon { font-size: 2.5rem; margin-bottom: 10px; }
.drop-zone p { color: var(--text2); font-size: .9rem; line-height: 1.7; }
.link-label { color: var(--accent2); cursor: pointer; text-decoration: underline; }
code { background: var(--bg4); padding: 1px 5px; border-radius: 3px; font-size: .85em; }

/* ── Divider ──────────────────────────────────────────────────────────── */
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.divider span { color: var(--text3); font-size: .8rem; white-space: nowrap; }

/* ── Paste Area ───────────────────────────────────────────────────────── */
textarea {
  width: 100%; height: 180px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: .82rem; resize: vertical;
  transition: border-color .2s;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* ── Options Row ──────────────────────────────────────────────────────── */
.options-row {
  display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0;
  align-items: flex-end;
}
.option-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 160px; }
.option-group label { font-size: .78rem; color: var(--text2); font-weight: 600; }
.option-group input[type="text"], .option-group select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: .88rem;
}
.option-group input:focus, .option-group select:focus { outline: none; border-color: var(--accent); }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .88rem; color: var(--text2); }
.checkbox-label input { accent-color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 12px 32px; font-size: .95rem; font-weight: 700;
  cursor: pointer; transition: opacity .15s, transform .1s;
  display: block; width: 100%; margin-top: 8px;
}
.btn-primary:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary {
  background: var(--bg4); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: .84rem; font-weight: 700;
  cursor: pointer; transition: border-color .15s, transform .1s;
}
.btn-secondary:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ── Loading ──────────────────────────────────────────────────────────── */
#loading-panel { text-align: center; padding: 60px; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-msg { color: var(--text2); }

/* ── Commander Header ─────────────────────────────────────────────────── */
.commander-header {
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg4) 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 28px;
  margin-bottom: 20px;
  box-shadow: 0 0 30px var(--accent-glow);
}
.commander-header h2 { font-size: 1.4rem; margin-bottom: 6px; }
.commander-header .subtitle { color: var(--text2); font-size: .9rem; }
a.commander-name-link { color: inherit; text-decoration: none; }
a.commander-name-link:hover { text-decoration: underline; }
.commander-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.commander-detail-card {
  background: rgba(14,15,19,.45);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.commander-detail-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.commander-detail-name { font-size: .9rem; font-weight: 700; margin-bottom: 3px; }
.commander-detail-link { color: var(--text); text-decoration: none; }
.commander-detail-link:hover { color: var(--accent2); text-decoration: underline; }
.commander-type { color: var(--text2); font-size: .76rem; line-height: 1.35; }
.commander-mana {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
  min-width: 72px;
}
.mana-symbol {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: .65rem;
  font-weight: 800;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.12);
}
.mana-symbol-generic { background: var(--bg4); color: var(--text); }
.mana-symbol-W { background: #fef3c7; color: #4b5563; }
.mana-symbol-U { background: #60a5fa; color: #fff; }
.mana-symbol-B { background: #7c3aed; color: #fff; }
.mana-symbol-R { background: #ef4444; color: #fff; }
.mana-symbol-G { background: #22c55e; color: #062814; }
.mana-symbol-hybrid { color: #fff; }
.commander-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.commander-facts span,
.commander-keywords span {
  background: var(--bg4);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: .7rem;
}
.commander-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.commander-oracle {
  color: var(--text);
  font-size: .78rem;
  line-height: 1.45;
  max-height: 7.3em;
  overflow: auto;
}
.color-pip {
  display: inline-flex; width: 20px; height: 20px; border-radius: 50%;
  align-items: center; justify-content: center;
  font-size: .6rem; font-weight: bold; margin-right: 3px;
}
.pip-W { background: #fef9c3; color: #333; }
.pip-U { background: #3b82f6; color: #fff; }
.pip-B { background: #6b21a8; color: #fff; }
.pip-R { background: #ef4444; color: #fff; }
.pip-G { background: #22c55e; color: #fff; }
.pip-C { background: #9ca3af; color: #fff; }

/* ── Tab Nav ──────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent; color: var(--text2);
  border: none; border-radius: 5px;
  padding: 8px 18px; font-size: .85rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.tab-btn:hover { color: var(--text); background: var(--bg3); }
.tab-btn.active { background: var(--accent); color: #fff; }

/* ── Tab Content ──────────────────────────────────────────────────────── */
.tab-content.hidden { display: none; }

/* ── Stat Cards ───────────────────────────────────────────────────────── */
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.stat-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px;
  text-align: center;
}
.stat-label { font-size: .72rem; color: var(--text2); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--accent2); }

/* ── Mana Curve Bar Chart ─────────────────────────────────────────────── */
.bar-chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 120px; padding-bottom: 24px; position: relative;
}
.bar-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 4px; height: 100%;
  justify-content: flex-end;
}
.bar {
  width: 100%; background: var(--accent);
  border-radius: 4px 4px 0 0; min-height: 2px;
  transition: height .4s ease;
  position: relative;
}
.bar:hover { opacity: .8; }
.bar-count {
  font-size: .68rem; color: var(--text2); font-weight: 600;
}
.bar-label { font-size: .68rem; color: var(--text3); }

/* ── Donut Chart ──────────────────────────────────────────────────────── */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.legend { flex: 1; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: .78rem; margin-bottom: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Role Bars ────────────────────────────────────────────────────────── */
.role-bars { display: flex; flex-direction: column; gap: 8px; }
.role-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 8px; }
.role-label { font-size: .8rem; color: var(--text2); text-align: right; }
.role-bar-bg { background: var(--bg4); border-radius: 4px; height: 10px; overflow: hidden; }
.role-bar-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.role-count { font-size: .8rem; color: var(--text2); }

/* ── Warn / Error Lists ───────────────────────────────────────────────── */
.warn-list li, .issue-list li {
  padding: 8px 10px; border-radius: 5px;
  font-size: .84rem; margin-bottom: 5px; line-height: 1.4;
}
.warn-list li { background: rgba(251,191,36,.08); color: var(--yellow); border-left: 3px solid var(--yellow); }
.error-list li { background: rgba(248,113,113,.08); color: var(--red); border-left: 3px solid var(--red); }
.empty-note { color: var(--text3); font-size: .85rem; padding: 8px 0; }

/* ── Validation Status ────────────────────────────────────────────────── */
.validation-status {
  border-radius: var(--radius-sm); padding: 16px 20px;
  font-size: 1rem; font-weight: 700; margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
}
.valid-ok   { background: rgba(74,222,128,.1); color: var(--green); border: 1px solid rgba(74,222,128,.3); }
.valid-fail { background: rgba(248,113,113,.1); color: var(--red); border: 1px solid rgba(248,113,113,.3); }

/* ── Synergy Clusters ─────────────────────────────────────────────────── */
.cluster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 14px; margin-bottom: 16px; }
.cluster-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}
.cluster-card.high   { border-left: 3px solid var(--green); }
.cluster-card.medium { border-left: 3px solid var(--yellow); }
.cluster-card.low    { border-left: 3px solid var(--text3); }
.cluster-name { font-weight: 700; font-size: .9rem; margin-bottom: 4px; }
.cluster-desc { font-size: .78rem; color: var(--text2); margin-bottom: 8px; line-height: 1.4; }
.cluster-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.cluster-tag {
  background: var(--bg4); color: var(--text2);
  font-size: .7rem; padding: 2px 7px; border-radius: 10px;
}
a.cluster-tag {
  display: inline-block;
  text-decoration: none;
}
a.cluster-tag:hover {
  color: var(--text);
  text-decoration: underline;
}
.strength-badge {
  float: right; font-size: .68rem; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
}
.strength-high   { background: rgba(74,222,128,.15); color: var(--green); }
.strength-medium { background: rgba(251,191,36,.15); color: var(--yellow); }
.strength-low    { background: rgba(90,95,122,.2); color: var(--text3); }

/* ── Tag Cloud ────────────────────────────────────────────────────────── */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--bg4); color: var(--text2);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 4px 11px; font-size: .78rem;
}
a.tag {
  display: inline-block;
  text-decoration: none;
}
a.tag:hover {
  color: var(--text);
  text-decoration: underline;
}
.tag.gc-tag { background: rgba(124,106,247,.12); color: var(--accent2); border-color: var(--accent); }

/* ── Bracket Display ──────────────────────────────────────────────────── */
.bracket-display {
  display: flex; gap: 14px; margin-bottom: 16px; flex-wrap: wrap;
}
.bracket-box {
  flex: 1; min-width: 180px;
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
  transition: all .2s;
}
.bracket-box.active {
  border-color: var(--accent);
  background: rgba(124,106,247,.08);
  box-shadow: 0 0 20px var(--accent-glow);
}
.bracket-num { font-size: 2.4rem; font-weight: 900; color: var(--accent2); }
.bracket-label { font-size: .78rem; color: var(--text2); margin-top: 4px; }
.bracket-reasoning { margin-top: 14px; }
.bracket-reasoning h3 { font-size: .82rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.reasoning-item { font-size: .83rem; color: var(--text); padding: 6px 10px; background: var(--bg3); border-radius: 5px; margin-bottom: 5px; line-height: 1.4; }

/* ── AI Panel ─────────────────────────────────────────────────────────── */
.ai-panel { }
.advisor-sections { display: flex; flex-direction: column; gap: 14px; }
.advisor-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px 18px;
}
.advisor-section h3 {
  color: var(--accent2);
  margin-bottom: 12px;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .8px;
}
.advisor-text-card {
  background: linear-gradient(135deg, var(--bg3), var(--bg4));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .9rem;
  line-height: 1.7;
}
.advisor-text-card p + p { margin-top: 10px; }
.ai-summary {
  background: linear-gradient(135deg, var(--bg3), var(--bg4));
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 20px; margin-bottom: 16px; line-height: 1.7;
  font-size: .9rem;
}
.ai-summary h3 { color: var(--accent2); margin-bottom: 10px; font-size: .82rem; text-transform: uppercase; letter-spacing: .8px; }
.suggestion-list { display: flex; flex-direction: column; gap: 8px; }
.suggestion-item {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: .85rem; line-height: 1.5;
  border-left: 3px solid var(--accent);
}
.ai-unavailable {
  color: var(--text2); text-align: center; padding: 40px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}

/* ── Card Table ───────────────────────────────────────────────────────── */
.card-filter-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.card-filter-row input { flex: 1; }
.card-filter-row input, .card-filter-row select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: .88rem;
}
.card-filter-row .btn-secondary { white-space: nowrap; }
#card-table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
#card-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
#card-table th {
  background: var(--bg4); color: var(--text2);
  padding: 10px 12px; text-align: left;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .6px;
  position: sticky; top: 0;
  border-bottom: 1px solid var(--border);
}
#card-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
#card-table tr:hover td { background: var(--bg3); }
.card-name-link { color: var(--accent2); text-decoration: none; }
.card-name-link:hover { text-decoration: underline; }
.gc-dot { color: var(--accent); font-weight: bold; }
.rarity-c { color: var(--text3); }
.rarity-u { color: #94a3b8; }
.rarity-r { color: #fbbf24; }
.rarity-m { color: #f87171; }
.not-found-row td { color: var(--red); background: rgba(248,113,113,.05); }

/* ── Plan Tab ─────────────────────────────────────────────────────────── */
.plan-framework-note {
  font-size: .8rem; color: var(--text2); margin-bottom: 14px; line-height: 1.5;
}
.plan-advice {
  font-size: .83rem; color: var(--text); line-height: 1.6;
  padding: 10px; background: var(--bg4); border-radius: 5px;
}
.plan-notes-list { margin-top: 10px; }
.plan-note {
  font-size: .8rem; color: var(--text2); padding: 5px 8px;
  border-left: 2px solid var(--border); margin-bottom: 4px; line-height: 1.4;
}
.plan-note.warn { border-color: var(--yellow); color: var(--yellow); }
.target-editor {
  display: flex; flex-direction: column; gap: 10px;
}
.target-editor-note {
  font-size: .78rem; color: var(--text2); line-height: 1.45;
}
.editable-role-list {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.editable-role-tag {
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(124, 106, 247, .16);
  color: var(--accent2);
  border: 1px solid rgba(124, 106, 247, .38);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: .8rem; font-weight: 700;
  max-width: 280px;
}
.role-tag-main {
  display: flex; align-items: center; gap: 6px;
}
.role-kind {
  color: var(--text3);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
}
.role-tag-description {
  color: var(--text2);
  font-size: .72rem;
  font-weight: 500;
  line-height: 1.35;
}
.role-remove-btn {
  flex: 0 0 auto;
  width: 18px; height: 18px; display: inline-grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .1); color: var(--text2);
  cursor: pointer; line-height: 1; font-size: .9rem;
}
.role-remove-btn:hover { background: var(--red); color: white; }
.detected-role-list {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.detected-role-item {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg3);
  padding: 9px;
}
.detected-role-head {
  display: flex; justify-content: space-between; gap: 8px;
  color: var(--text); font-size: .78rem; font-weight: 700;
}
.detected-role-head span:last-child {
  color: var(--text3); font-size: .68rem; text-transform: uppercase; white-space: nowrap;
}
.detected-role-desc {
  color: var(--text2); font-size: .74rem; line-height: 1.4; margin-top: 4px;
}
.detected-role-evidence {
  color: var(--accent2); font-size: .72rem; line-height: 1.35; margin-top: 5px;
}
.target-control-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.target-control-row input,
.target-control-row select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: .84rem;
}
.target-control-row input { flex: 1; min-width: 180px; }
.target-control-row select#target-role-select { flex: 1.2; min-width: 230px; }
.target-control-row label {
  color: var(--text2); font-size: .78rem; font-weight: 700;
}
.target-submit-btn {
  width: auto; margin: 0; padding: 9px 14px; font-size: .84rem;
}

/* Coverage grid */
.coverage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 10px; }
.coverage-card {
  background: var(--bg4); border-radius: var(--radius-sm);
  padding: 12px 14px; border-left: 3px solid var(--border);
}
.coverage-card.ok     { border-color: var(--green); }
.coverage-card.close  { border-color: var(--yellow); }
.coverage-card.low    { border-color: var(--red); }
.coverage-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.coverage-name { font-size: .82rem; font-weight: 700; }
.coverage-nums { font-size: .78rem; color: var(--text2); }
.coverage-bar-bg { background: var(--bg2); border-radius: 4px; height: 8px; overflow: hidden; }
.coverage-bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }
.coverage-delta { font-size: .72rem; margin-top: 5px; }
.delta-ok    { color: var(--green); }
.delta-close { color: var(--yellow); }
.delta-low   { color: var(--red); }

/* Dual bar chart (actual vs target) */
.dual-bar-chart {
  display: flex; align-items: flex-end; gap: 5px;
  height: 130px; padding-bottom: 24px;
}
.dual-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; }
.dual-bars { display: flex; gap: 2px; align-items: flex-end; width: 100%; }
.bar-actual  { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-target  { flex: 1; background: var(--border); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .6; }
.dual-legend { display: flex; gap: 12px; margin-top: 8px; font-size: .72rem; color: var(--text2); }
.dual-legend span { display: flex; align-items: center; gap: 4px; }
.legend-sq { width: 10px; height: 10px; border-radius: 2px; }

/* Playtest table */
.playtest-table-wrap { overflow-x: auto; }
.playtest-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.playtest-table th {
  background: var(--bg4); color: var(--text2); padding: 7px 10px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); text-align: center;
}
.playtest-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.playtest-table tr:last-child td { border-bottom: none; }
.playtest-table .cat-col { text-align: left; font-weight: 600; color: var(--text); }

/* Mulligan guide */
.mulligan-section { margin-bottom: 12px; }
.mulligan-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--text2); font-weight: 700; margin-bottom: 6px; }
.mulligan-hand { display: flex; flex-wrap: wrap; gap: 5px; }
.hand-card {
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 8px; font-size: .76rem; color: var(--text2);
}
a.hand-card {
  display: inline-block;
  text-decoration: none;
}
a.hand-card:hover {
  color: var(--text);
  text-decoration: underline;
}
.keep-rule { background: rgba(74,222,128,.08); border-left: 2px solid var(--green); padding: 5px 8px; border-radius: 3px; font-size: .8rem; margin-bottom: 4px; }
.mull-rule { background: rgba(248,113,113,.08); border-left: 2px solid var(--red); padding: 5px 8px; border-radius: 3px; font-size: .8rem; margin-bottom: 4px; }

/* Sequencing */
.sequence-list { display: flex; flex-direction: column; gap: 6px; }
.seq-row {
  display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: start;
  padding: 8px; background: var(--bg4); border-radius: 5px;
}
.seq-turn {
  font-size: .72rem; font-weight: 900; color: var(--accent2);
  text-align: center; padding-top: 2px;
  border-right: 1px solid var(--border);
}
.seq-content { }
.seq-priority { font-size: .8rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.seq-notes { font-size: .75rem; color: var(--text2); line-height: 1.4; }

/* PTV (path to victory) */
.ptv-box { border-radius: var(--radius-sm); padding: 12px 14px; }
.ptv-high   { background: rgba(74,222,128,.08); border: 1px solid rgba(74,222,128,.3); }
.ptv-medium { background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.3); }
.ptv-low    { background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.3); }
.ptv-label  { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; margin-bottom: 6px; }
.ptv-high .ptv-label   { color: var(--green); }
.ptv-medium .ptv-label { color: var(--yellow); }
.ptv-low .ptv-label    { color: var(--red); }
.ptv-summary { font-size: .82rem; color: var(--text); line-height: 1.5; margin-bottom: 8px; }
.ptv-detail  { font-size: .76rem; color: var(--text2); }
.inline-card-link { color: var(--accent2); text-decoration: none; }
.inline-card-link:hover { color: var(--text); text-decoration: underline; }

/* Card Role Table */
#card-role-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
#card-role-table th {
  background: var(--bg4); color: var(--text2); padding: 8px 12px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
#card-role-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
#card-role-table tr:hover td { background: var(--bg3); }
#card-role-table tr.overlap-row td { background: rgba(124,106,247,.05); }
.role-tag {
  display: inline-block; font-size: .68rem; padding: 1px 6px; border-radius: 8px;
  margin-right: 3px; margin-bottom: 2px; font-weight: 600;
}
.role-Lands           { background: rgba(120,113,108,.2); color: #a8a29e; }
.role-Card-Advantage  { background: rgba(96,165,250,.15); color: var(--blue); }
.role-Ramp            { background: rgba(74,222,128,.15); color: var(--green); }
.role-Removal         { background: rgba(248,113,113,.15); color: var(--red); }
.role-Mass-Disruption { background: rgba(251,146,60,.15); color: var(--orange); }
.role-Plan-Cards      { background: rgba(124,106,247,.15); color: var(--accent2); }
.sub-Enabler  { color: #86efac; font-size: .7rem; }
.sub-Payoff   { color: var(--yellow); font-size: .7rem; }
.sub-Enhancer { color: var(--accent2); font-size: .7rem; }
.overlap-chip { background: rgba(124,106,247,.2); color: var(--accent2); font-size: .68rem; padding: 1px 6px; border-radius: 8px; }

/* ── Moxfield import ──────────────────────────────────────────────────── */
.moxfield-row {
  display: flex; gap: 8px; align-items: center;
}
.moxfield-row input {
  flex: 1;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: .88rem;
  transition: border-color .2s;
}
.moxfield-row input:focus { outline: none; border-color: var(--accent); }
.btn-import {
  background: var(--bg4); color: var(--accent2);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 9px 18px; font-size: .85rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-import:hover:not(:disabled) { background: rgba(124,106,247,.2); }
.btn-import:disabled { opacity: .5; cursor: not-allowed; }
.moxfield-status {
  font-size: .8rem; padding: 6px 10px;
  border-radius: var(--radius-sm); margin-top: 6px;
}
.moxfield-ok  { background: rgba(74,222,128,.1); color: var(--green); border: 1px solid rgba(74,222,128,.25); }
.moxfield-err { background: rgba(248,113,113,.1); color: var(--red);   border: 1px solid rgba(248,113,113,.25); }

/* ── EDHREC panel ─────────────────────────────────────────────────────── */
.edhrec-panel h3 { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.edhrec-link {
  font-size: .72rem; color: var(--accent2); text-decoration: none;
  font-weight: 400; text-transform: none; letter-spacing: 0;
}
.edhrec-link:hover { text-decoration: underline; }
.edhrec-subtitle {
  font-size: .75rem; color: var(--text2); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .5px;
}
.edhrec-budget-note {
  margin-bottom: 10px;
  font-size: .76rem;
  color: var(--text2);
  line-height: 1.45;
}
.edhrec-table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.edhrec-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.edhrec-table th {
  background: var(--bg4); color: var(--text2); padding: 7px 12px;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); text-align: left;
}
.edhrec-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.edhrec-table th:nth-child(2),
.edhrec-table th:nth-child(3),
.edhrec-table th:nth-child(4),
.edhrec-table th:nth-child(5),
.edhrec-table td:nth-child(2),
.edhrec-table td:nth-child(3),
.edhrec-table td:nth-child(4),
.edhrec-table td:nth-child(5) { text-align: center; }
.edhrec-table tr:last-child td { border-bottom: none; }
.edhrec-table tr:hover td { background: var(--bg4); }
.edhrec-row-in-deck td { opacity: .6; }
.edhrec-num { font-variant-numeric: tabular-nums; color: var(--text2); text-align: center; }
.edhrec-in-deck-badge {
  font-size: .65rem; padding: 1px 5px; border-radius: 6px;
  background: rgba(74,222,128,.12); color: var(--green);
  border: 1px solid rgba(74,222,128,.25); margin-left: 4px;
}
.edhrec-source-hs  { background: rgba(124,106,247,.15); color: var(--accent2); font-size: .68rem; padding: 1px 6px; border-radius: 8px; }
.edhrec-source-top { background: rgba(96,165,250,.12);  color: var(--blue);    font-size: .68rem; padding: 1px 6px; border-radius: 8px; }
.edhrec-already-have {
  font-size: .78rem; color: var(--text2); cursor: pointer;
  list-style: none; padding: 4px 0;
}
.edhrec-already-have:hover { color: var(--text); }

/* ── Sort indicators ──────────────────────────────────────────────────── */
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: var(--text); }
th[data-sort].sort-asc::after  { content: ' ↑'; color: var(--accent); font-size: .75em; }
th[data-sort].sort-desc::after { content: ' ↓'; color: var(--accent); font-size: .75em; }

/* ── Focus card links (Plan tab Commander Role) ───────────────────────── */
a.focus-card-link {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  background: rgba(124,106,247,.12); border: 1px solid rgba(124,106,247,.3);
  color: var(--accent2); font-size: .78rem; text-decoration: none;
  transition: background .15s, border-color .15s;
}
a.focus-card-link:hover {
  background: rgba(124,106,247,.25); border-color: rgba(124,106,247,.5);
  color: var(--text);
}

/* ── Utilities ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; }
}

/* ── Creativity Score Panel ──────────────────────────────────────────────── */
.creativity-panel { margin-bottom: 14px; }

.creativity-avg-link {
  font-size: .72rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 10px;
  vertical-align: middle;
  opacity: .75;
  color: var(--accent2);
}
.creativity-avg-link:hover { opacity: 1; }

.creativity-score-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 4px;
}

.creativity-score-display {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  min-width: 72px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.creativity-score-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.creativity-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .3px;
}

.creativity-explanation {
  font-size: .83rem;
  color: var(--text2);
  line-height: 1.45;
}

.creativity-overlap-note {
  font-size: .75rem;
  color: var(--text3);
  margin-top: 2px;
}

.creativity-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg4);
}

.creativity-summary {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .6px;
  cursor: pointer;
  padding: 8px 12px;
  list-style: none;
  user-select: none;
}

.creativity-summary:hover { color: var(--text); }

.creativity-details[open] .creativity-summary {
  border-bottom: 1px solid var(--border);
}

.creativity-table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.creativity-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.creativity-table th {
  background: var(--bg3);
  color: var(--text2);
  font-weight: 700;
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .5px;
  padding: 7px 12px;
  text-align: left;
  white-space: nowrap;
}
.creativity-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.creativity-table tr:last-child td { border-bottom: none; }
.creativity-table tr:hover td { background: var(--bg3); }
.creativity-type { color: var(--text2); white-space: nowrap; }
.creativity-num  { font-variant-numeric: tabular-nums; color: var(--text2); white-space: nowrap; }
.creativity-cmc-ci { display: inline-flex; align-items: center; gap: 3px; }
.creativity-cmc {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: .78rem;
  color: var(--text2);
  min-width: 14px;
  text-align: right;
}

.creativity-subcategory {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text2);
}

@media (max-width: 640px) {
  .creativity-score-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .creativity-score-display { font-size: 2.4rem; min-width: unset; }
}
