:root {
  --bg: #0f1116;
  --bg-elev: #171a22;
  --bg-elev-2: #1e222c;
  --border: #2a2f3b;
  --border-strong: #3a4150;
  --text: #e8ebf1;
  --text-dim: #9aa3b2;
  --text-muted: #6b7281;
  --accent: #f5c542;
  --accent-soft: rgba(245, 197, 66, 0.14);
  --ok: #4ade80;
  --warn: #f97316;
  --err: #ef4444;
  --info: #60a5fa;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 16px;
}
.site-header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.accent { color: var(--accent); }
.tagline {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

/* Layout */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.col { display: flex; flex-direction: column; gap: 16px; }

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Form elements */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
input[type="text"], input[type="number"], select {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 14px;
  width: 100%;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled { opacity: 0.5; cursor: not-allowed; }

button {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
button:hover { border-color: var(--accent); }
button:active { background: #12151b; }
button.primary {
  background: var(--accent);
  color: #1b1506;
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.05); }
button.ghost {
  background: transparent;
  color: var(--text-dim);
}

/* Autofill block */
.autofill-grid {
  display: grid;
  grid-template-columns: 100px 1fr 1fr;
  gap: 12px 14px;
  align-items: end;
}
.autofill-grid .realm-field { grid-column: 1 / -1; }
.autofill-grid button { grid-column: 1 / -1; }
@media (max-width: 600px) {
  .autofill-grid { grid-template-columns: 1fr; }
}
.status {
  margin: 12px 0 0;
  font-size: 13px;
  min-height: 1.2em;
  color: var(--text-muted);
}
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.loading { color: var(--info); }
.helper {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Import section */
.import-section-head {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.import-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.simc-textarea {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  display: block;
  margin-bottom: 10px;
}
.simc-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.simc-parse-btn { width: 100%; }

/* Earned remaining hint */
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -2px;
}

/* Setup block */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.weapon-type {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.weapon-type legend {
  padding: 0 6px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.weapon-type label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.weapon-type input[type="radio"] { accent-color: var(--accent); }

/* Slot table */
.slot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.slot-table th, .slot-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.slot-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.slot-table tr:last-child td { border-bottom: none; }
.slot-table .slot-name { color: var(--text-dim); white-space: nowrap; }
.slot-table select {
  padding: 5px 8px;
  font-size: 13px;
}

.track-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  vertical-align: middle;
  text-transform: uppercase;
}
.crafted-badge {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.hero-badge {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.slot-row.autofilled { background: rgba(96, 165, 250, 0.05); }
.slot-row.autofilled .slot-name::after {
  content: " *";
  color: var(--info);
}
.slot-row.below-floor .slot-name { color: var(--warn); }
.slot-row.below-floor::after {
  content: "Use Hero crests first";
}
.slot-row.disabled { opacity: 0.45; }

/* Actions */
.actions { display: flex; gap: 10px; }
.actions button { flex: 1; }

/* KPIs */
.kpi-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 480px) {
  .kpi-card { grid-template-columns: 1fr; }
}
.kpi { text-align: left; }
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  min-height: 1em;
}

/* Plan list */
.summary {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 14px;
}
.plan-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-item {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid transparent;
  font-size: 14px;
}
.plan-item:hover { border-color: var(--border-strong); }
.plan-num {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 13px;
  text-align: right;
}
.plan-desc { color: var(--text); }
.plan-desc .slot-label { font-weight: 500; }
.plan-desc .gain {
  margin-left: 8px;
  color: var(--text-muted);
  font-size: 13px;
}
.plan-crests {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 13px;
}
.plan-week {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
.plan-week.now {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.plan-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

/* Footer */
.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
.site-footer a { color: var(--text-dim); }

dialog {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 520px;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin-top: 0; }
dialog ul { padding-left: 20px; }
dialog li { margin-bottom: 8px; }
dialog button {
  margin-top: 12px;
  float: right;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; }
