/* Manual vectorizer — shared styles */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --border: #2e3344;
  --text: #e8eaef;
  --text-muted: #9aa3b5;
  --accent: #6b8afd;
  --accent-hover: #8aa4ff;
  --set: #3dd68c;
  --set-bg: rgba(61, 214, 140, 0.15);
  --negative: #f07178;
  --negative-bg: rgba(240, 113, 120, 0.15);
  --unset: #4a5168;
  --disabled: #2a2f3d;
  --disabled-text: #5c6378;
  --tooltip-bg: #2a3042;
  --radius: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

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

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

header nav {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
}

header nav a {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  background: var(--surface-2);
}

header nav a.active {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toolbar input[type="text"],
.toolbar select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.toolbar select {
  min-width: 220px;
  max-width: min(360px, 100%);
}

.toolbar input[type="text"] {
  min-width: 180px;
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.mode-toggle button {
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.mode-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.mode-toggle button:not(.active):hover {
  background: var(--border);
  color: var(--text);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

main {
  padding: 1rem 1.5rem 3rem;
}

.category-section {
  margin-bottom: 1.5rem;
}

.collapsible {
  margin-bottom: 0.35rem;
}

.collapsible-group {
  margin-left: 0.75rem;
  margin-bottom: 0.5rem;
}

.collapsible-trigger {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  margin: 0 0 0.5rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.collapsible-trigger:hover {
  background: rgba(107, 138, 253, 0.08);
}

.collapsible-trigger-category {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.65rem;
}

.collapsible-trigger-group {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.collapsible-chevron {
  flex-shrink: 0;
  width: 1rem;
  color: var(--accent);
  opacity: 0.85;
  font-size: 0.75rem;
}

.collapsible-label {
  flex: 1;
}

.collapsible.is-collapsed .collapsible-body {
  display: none;
}

.collapsible-body {
  margin-bottom: 0.25rem;
}

/* Weights table collapsible sections */
table.weights-table tbody.collapsible-tbody.is-collapsed tr:not(.collapsible-trigger-row) {
  display: none;
}

table.weights-table tr.collapsible-trigger-row td {
  background: var(--surface-2);
  padding: 0.35rem 0.75rem;
}

table.weights-table tbody.collapsible-category tr.collapsible-trigger-row td {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

table.weights-table tbody.collapsible-group tr.collapsible-trigger-row td {
  background: rgba(107, 138, 253, 0.08);
  font-size: 0.82rem;
  color: var(--text-muted);
}

table.weights-table .collapsible-trigger {
  margin: 0;
  padding: 0.15rem 0;
}

table.weights-table-nested {
  width: 100%;
  margin: 0.25rem 0 0.5rem;
  border: none;
}

table.weights-table tr.collapsible-nest-row > td {
  padding: 0.25rem 0.5rem 0.25rem 1.25rem;
  background: transparent;
  border-bottom: none;
}

table.weights-table tr.collapsible-nest-row:hover td {
  background: transparent;
}

.category-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.subcategory-section {
  margin-bottom: 1.25rem;
}

.subcategory-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.subcategory-section h3::before {
  content: "▸ ";
  color: var(--accent);
  opacity: 0.7;
}

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

.skill-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 64px;
  padding: 0.55rem 0.65rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}

.skill-btn:hover:not(.disabled) {
  border-color: var(--accent);
}

.skill-btn .skill-name {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.skill-btn .skill-state {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.skill-btn.state-set {
  border-color: var(--set);
  background: var(--set-bg);
}

.skill-btn.state-set .skill-state {
  color: var(--set);
}

.skill-btn.state-negative {
  border-color: var(--negative);
  background: var(--negative-bg);
}

.skill-btn.state-negative .skill-state {
  color: var(--negative);
}

.skill-btn.state-partial {
  border-color: var(--accent);
  background: rgba(107, 138, 253, 0.12);
}

.skill-btn.state-partial .skill-state {
  color: var(--accent);
}

.skill-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--disabled);
  color: var(--disabled-text);
  border-color: var(--disabled);
}

.skill-btn .rank-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: color 0.15s;
}

.skill-btn.ranked {
  min-height: 80px;
  transition: border-color 0.15s, background 0.15s;
}

.skill-btn.ranked.rank-has-value {
  border-color: color-mix(in srgb, var(--rank-color) 60%, var(--border));
  background: color-mix(in srgb, var(--rank-color) 14%, var(--surface));
}

.skill-btn.ranked.rank-has-value .rank-value {
  color: var(--rank-color);
}

.skill-btn input[type="range"] {
  width: 100%;
  margin-top: 0.35rem;
  accent-color: var(--text-muted);
  height: 6px;
  appearance: none;
  background: transparent;
}

.skill-btn.ranked.rank-has-value input[type="range"] {
  accent-color: var(--rank-color);
}

.skill-btn input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--rank-color, var(--border)) 0 var(--rank-fill, 0%),
    var(--surface-2) var(--rank-fill, 0%) 100%
  );
}

.skill-btn input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
}

.skill-btn input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--rank-color, var(--border));
}

.skill-btn input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--rank-color, var(--accent));
  cursor: pointer;
}

.skill-btn input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--rank-color, var(--accent));
  cursor: pointer;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(420px, 90vw);
  max-height: min(360px, 60vh);
  overflow: auto;
  padding: 0.85rem 1rem;
  background: var(--tooltip-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.45;
  pointer-events: none;
  white-space: pre-wrap;
}

.tooltip .tooltip-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

/* Weights page */
.weights-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: calc(100vh - 220px);
}

table.weights-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

table.weights-table .weights-col-key {
  width: 34%;
}

table.weights-table .weights-col-label {
  width: 22%;
}

table.weights-table .weights-col-weight {
  width: 14%;
}

table.weights-table .weights-col-default {
  width: 12%;
}

table.weights-table .weights-col-override {
  width: 18%;
}

table.weights-table th.weights-col-weight,
table.weights-table td.weights-col-weight,
table.weights-table th.weights-col-default,
table.weights-table td.weights-col-default,
table.weights-table th.weights-col-override,
table.weights-table td.weights-col-override {
  text-align: center;
}

table.weights-table input[type="number"] {
  width: 72px;
  max-width: 100%;
}

table.weights-table .weights-folder-group .weights-folder-name {
  padding-left: 1.5rem;
}

table.weights-table .weights-folder-row td {
  background: var(--surface-2);
}

table.weights-table .weights-folder-group td {
  background: rgba(107, 138, 253, 0.08);
}

table.weights-table .weights-folder-category .collapsible-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.weights-table input[type="number"].weight-overridden {
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-muted) 8%, var(--surface));
  border-color: var(--border);
  opacity: 0.72;
  cursor: not-allowed;
}

table.weights-table input[type="number"].weight-impact {
  color: var(--weight-color);
  border-color: color-mix(in srgb, var(--weight-color) 55%, var(--border));
  background: color-mix(in srgb, var(--weight-color) 16%, var(--surface));
}

table.weights-table input[type="number"].weight-disabled {
  color: var(--negative);
  border-color: color-mix(in srgb, var(--negative) 55%, var(--border));
  background: var(--negative-bg);
}

table.weights-table input[type="number"].weight-inert {
  color: var(--text-muted);
  background: var(--surface);
  border-color: var(--border);
}

.priority-toggle {
  min-width: 4.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.priority-toggle.priority-high {
  border-color: var(--set);
  color: var(--set);
  background: var(--set-bg);
}

.priority-toggle.priority-low {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(107, 138, 253, 0.12);
}

.priority-toggle:hover {
  filter: brightness(1.08);
}

table.weights-table th,
table.weights-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.weights-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 1;
}

table.weights-table tr:hover td {
  background: rgba(107, 138, 253, 0.06);
}

table.weights-table input[type="number"] {
  width: 72px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

table.weights-table .axis-key {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stats-bar strong {
  color: var(--text);
}

.empty-notice {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.catalog-source {
  padding: 0.75rem 1.25rem 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* Results page */
.results-hero {
  margin: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.results-hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.results-hero-card {
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.results-hero-card .results-hero-name {
  font-size: 1.35rem;
}

.results-hero-card .results-hero-stats {
  margin-top: 0.85rem;
}

.results-hero-card .results-stat-value {
  font-size: 1.25rem;
}

.results-hero-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.results-hero-name {
  margin-top: 0.35rem;
  font-size: 2rem;
  font-weight: 700;
}

.results-hero-id {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.results-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

.results-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--set);
}

.results-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.meta-badges-compact {
  margin-top: 0.35rem;
}

.meta-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.results-table-wrap {
  margin: 0 1.5rem 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.results-table th,
table.results-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.results-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
}

table.results-table tr.results-row {
  cursor: pointer;
}

table.results-table tr.results-row:hover td {
  background: var(--surface-2);
}

.results-type-name {
  font-weight: 600;
}

.results-type-id {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.match-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}

.match-bar-wrap span {
  min-width: 2.5rem;
  font-variant-numeric: tabular-nums;
}

.match-bar {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--set));
  min-width: 4px;
}

.contributions-block {
  margin-top: 1rem;
}

.contributions-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.contributions-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.contributions-list li {
  margin: 0.2rem 0;
}

.contributions-list code {
  font-size: 0.8rem;
}

.contributions-list span {
  color: var(--negative);
  font-variant-numeric: tabular-nums;
}

.results-detail-row td {
  background: var(--bg);
}

@media (max-width: 640px) {
  .skill-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
