:root {
  --bg: #0f1117;
  --panel: #171a24;
  --panel-2: #1f2330;
  --border: #2a2f3e;
  --text: #e7e9f0;
  --text-dim: #9aa0b4;
  --accent: #7c6cf0;
  --accent-2: #4ecdc4;
  --action: #e0a458;
  --passive: #5ba8f5;
  --danger: #e06c6c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

main {
  padding: 1.5rem 2rem 3rem;
  max-width: 1100px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-header h2 { margin: 0; font-size: 1.2rem; }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.class-tree {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.tree-root {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  background: rgba(124, 108, 240, 0.04);
}

.tree-node { position: relative; }

.tree-children {
  list-style: none;
  margin: 0.6rem 0 0;
  padding-left: 1.4rem;
  border-left: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tree-children .tree-children {
  margin-top: 0.5rem;
}

.tree-node .card {
  margin: 0;
}

.tree-node .card h3 { font-size: 0.98rem; }

.cycle-note {
  color: var(--danger);
  font-size: 0.78rem;
  margin: 0.2rem 0 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }

.card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.card p { margin: 0 0 0.6rem; color: var(--text-dim); font-size: 0.85rem; line-height: 1.4; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin: 0.1rem 0.25rem 0.1rem 0;
  border: 1px solid var(--border);
}
.badge.action { color: var(--action); border-color: var(--action); }
.badge.passive { color: var(--passive); border-color: var(--passive); }
.badge.prereq { color: var(--accent-2); border-color: var(--accent-2); }

.empty-state {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-content.narrow { width: 420px; }

.modal-content h3 { margin-top: 0; }
.modal-content h4 { margin: 0 0 0.25rem; font-size: 0.95rem; color: var(--accent-2); }

label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.9rem;
}

input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; }

.modal-section {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0.4rem;
  margin-bottom: 0.9rem;
}
.hint { font-size: 0.78rem; color: var(--text-dim); margin: 0 0 0.6rem; }

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.inline-form select { flex: 2; }
.inline-form input { flex: 1; }

.new-ability-fields {
  margin-top: 0.6rem;
  padding: 0.7rem;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.new-ability-fields label { margin-bottom: 0.6rem; }
.new-ability-fields label:last-child { margin-bottom: 0; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  background: var(--panel-2);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.list-row .remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}
.spacer { flex: 1; }
