:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #7c5cff;
  --accent-hover: #9678ff;
  --w: #f0e68c;
  --u: #6cb4ee;
  --b: #b19cd9;
  --r: #ff6b6b;
  --g: #7dce82;
  --c: #c0c0c0;
  --m: #ff9f43;
  --success: #3dd68c;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding: 1.5rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--muted);
  margin-top: 0.4rem;
  font-size: 0.95rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: #fff;
}

.card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

code {
  background: #252830;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Upload */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
  position: relative;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.08);
}

.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-area label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  pointer-events: none;
  color: var(--muted);
}

.upload-icon {
  font-size: 2.2rem;
}

.status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.status.info {
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #93c5fd;
}

.status.success {
  background: rgba(61, 214, 140, 0.12);
  border: 1px solid rgba(61, 214, 140, 0.35);
  color: var(--success);
}

.status.error {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: var(--danger);
}

/* Stats & Tabs */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-pill {
  background: #252830;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-pill strong {
  color: var(--text);
}

.color-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.color-tab {
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #252830;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.color-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.color-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.color-tab .count {
  opacity: 0.75;
  margin-left: 0.25rem;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.card-item {
  background: #252830;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-item .name {
  font-weight: 500;
  color: var(--text);
}

.card-item .meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.card-item .qty {
  background: #1a1d24;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.color-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.W { background: var(--w); }
.dot.U { background: var(--u); }
.dot.B { background: var(--b); }
.dot.R { background: var(--r); }
.dot.G { background: var(--g); }
.dot.C { background: var(--c); }

/* Commander picker */
.commander-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.commander-picker label {
  width: 100%;
  color: var(--muted);
  font-size: 0.9rem;
}

select {
  flex: 1;
  min-width: 220px;
  background: #252830;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

button {
  background: #252830;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}

button:hover {
  border-color: var(--accent);
  color: #fff;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Deck output */
.deck-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.deck-header h3 {
  font-size: 1.15rem;
}

.deck-actions {
  display: flex;
  gap: 0.5rem;
}

.deck-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.deck-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.deck-col h4 {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.deck-col ul {
  list-style: none;
  font-size: 0.85rem;
}

.deck-col li {
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(42, 47, 58, 0.6);
}

.deck-col li:last-child {
  border-bottom: none;
}

.decklist-raw {
  background: #12151a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 300px;
  color: var(--muted);
}

footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.tiny {
  font-size: 0.75rem;
  margin-top: 0.35rem;
  opacity: 0.7;
}

/* Scrollbar */
.card-grid::-webkit-scrollbar,
.decklist-raw::-webkit-scrollbar {
  width: 6px;
}
.card-grid::-webkit-scrollbar-track,
.decklist-raw::-webkit-scrollbar-track {
  background: transparent;
}
.card-grid::-webkit-scrollbar-thumb,
.decklist-raw::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

@media (max-width: 600px) {
  body {
    padding: 1rem;
  }
  header h1 {
    font-size: 1.45rem;
  }
  .commander-picker {
    flex-direction: column;
    align-items: stretch;
  }
  select, button {
    width: 100%;
  }
}
