/* ============================================================
   ABSTRICT · Minimal professional aesthetic
   ============================================================ */
:root {
  --bg: #fafafa;
  --bg-alt: #f5f5f5;
  --bg-warm: #f8f7f4;
  --surface: #ffffff;
  --border: #e5e5e5;
  --border-subtle: #f0f0f0;
  --text: #171717;
  --text-secondary: #737373;
  --text-muted: #a3a3a3;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --teal: #0d9488;
  --stamp: #c8412a;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.03);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --shadow: 0 2px 8px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 24px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
  --ease: cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --ease-bounce: cubic-bezier(.34,1.56,.64,1);
}
body.dark {
  --bg: #0a0a0a;
  --bg-alt: #141414;
  --bg-warm: #111;
  --surface: #1a1a1a;
  --border: #262626;
  --border-subtle: #1f1f1f;
  --text: #fafafa;
  --text-secondary: #a3a3a3;
  --text-muted: #525252;
  --stamp: #c8412a;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 24px rgba(0,0,0,.45);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input { font-family: inherit; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 24px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
body.dark .topbar { background: rgba(10,10,10,.85); }
.brand-link {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px;
  letter-spacing: -.01em;
}
.brand-mark { color: var(--accent); }
.topnav { display: flex; gap: 2px; align-items: center; }
.topnav a {
  padding: 6px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: color 150ms var(--ease), background 150ms var(--ease);
}
.topnav a:hover { color: var(--text); background: var(--bg-alt); }
.topnav a.active { color: var(--text); }
.theme-toggle {
  background: none; border: 1px solid var(--border);
  width: 34px; height: 34px; border-radius: var(--radius);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 15px;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}
.theme-toggle:hover { border-color: var(--text-muted); color: var(--text); }
body.dark .theme-icon-light { display: none; }
body:not(.dark) .theme-icon-dark { display: none; }

/* ---- Builder ---- */
.builder {
  display: grid;
  grid-template-columns: 340px 1fr;
  max-width: 1440px; margin: 0 auto;
  gap: 0;
  min-height: calc(100vh - 52px);
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky; top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex; flex-direction: column;
}
.sidebar-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px;
}
.sidebar-brand { display: flex; flex-direction: column; gap: 2px; }
.sidebar-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.sidebar-build {
  font-family: var(--mono); font-size: 11px;
  color: var(--text-muted);
}

/* Stamp */
.stamp {
  width: 90px; height: 90px;
  color: var(--stamp);
  opacity: .75;
  transform: rotate(-10deg);
  flex-shrink: 0;
  transition: opacity 300ms var(--ease), transform 400ms var(--ease-bounce);
}
.stamp:hover { opacity: 1; transform: rotate(-5deg) scale(1.1); }
.stamp svg { width: 100%; height: 100%; }

/* Tier */
.tier { margin-bottom: 20px; }
.tier-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: 30px; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  position: relative;
}
.tier-seg {
  font-family: var(--mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: .5px;
  text-align: center; line-height: 30px;
  color: var(--text-muted);
  border-right: 1px solid var(--border-subtle);
  transition: background 250ms var(--ease), color 250ms var(--ease);
}
.tier-seg:last-child { border-right: none; }
.tier-seg.active { color: #fff; font-weight: 500; }
.tier-seg[data-tier="budget"].active { background: var(--success); }
.tier-seg[data-tier="mid"].active { background: var(--teal); }
.tier-seg[data-tier="high"].active { background: var(--accent); }
.tier-seg[data-tier="enthusiast"].active { background: var(--stamp); }
.tier-indicator { display: none; }
.tier-text {
  margin-top: 12px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

/* Slots */
.slots { margin-bottom: 16px; }
.slot {
  display: grid; grid-template-columns: 22px 1fr auto;
  gap: 10px; align-items: center;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 120ms var(--ease), transform 120ms var(--ease);
  border-left: 2px solid transparent;
}
.slot:hover { background: var(--bg-alt); }
.slot:active { transform: scale(.99); }
.slot.filled {
  background: rgba(13,148,136,.04);
  border-left-color: var(--teal);
}
.slot-icon { color: var(--text-muted); display: flex; align-items: center; transition: color 150ms var(--ease); }
.slot.filled .slot-icon { color: var(--teal); }
.slot-name { color: var(--text-secondary); font-weight: 500; }
.slot.filled .slot-name { color: var(--text); }
.slot-val {
  font-size: 12px; font-weight: 500;
  text-align: right; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot-val.empty { color: var(--text-muted); font-weight: 400; }

/* Compat */
.compat {
  padding-top: 16px; margin-bottom: 16px;
  border-top: 1px solid var(--border-subtle);
}
.compat-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.compat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.compat-badge {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
}
.compat-badge.all-pass { background: rgba(34,197,94,.08); color: var(--success); }
.compat-badge.has-fail { background: rgba(239,68,68,.08); color: var(--danger); }
.compat-badge.has-warn { background: rgba(245,158,11,.08); color: var(--warning); }
.compat-status {
  font-size: 12px; font-weight: 500; margin-bottom: 8px;
}
.compat-list { list-style: none; }
.compat-list li {
  display: grid; grid-template-columns: 20px 1fr auto;
  gap: 6px; align-items: center;
  padding: 4px 6px; font-size: 11px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: background 120ms var(--ease);
}
.compat-list li:hover { background: var(--bg-alt); }
.compat-list li.ok { border-left-color: var(--success); }
.compat-list li.warn { border-left-color: var(--warning); }
.compat-list li.bad { border-left-color: var(--danger); }
.compat-list li.pending { opacity: .5; border-left-color: var(--border); }
.compat-icon { text-align: center; font-size: 12px; }
.compat-text { color: var(--text-secondary); line-height: 1.3; }
.compat-state { font-family: var(--mono); font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.compat-list li.ok .compat-state { color: var(--success); }
.compat-list li.warn .compat-state { color: var(--warning); }
.compat-list li.bad .compat-state { color: var(--danger); }

/* Tech Summary */
.tech-summary {
  padding-top: 16px; margin-bottom: 16px;
  border-top: 1px solid var(--border-subtle);
}
.tech-head { margin-bottom: 8px; }
.tech-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.tech-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
}
.tech-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  background: var(--bg-alt);
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 150ms var(--ease);
  opacity: .4;
}
.tech-chip.active {
  opacity: 1;
  border-color: var(--border);
}
.tech-chip-icon { font-size: 11px; flex-shrink: 0; }
.tech-chip-key { font-size: 9px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.tech-chip-val { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--text); margin-left: auto; }
.tech-bottleneck {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(245,158,11,.06);
  border: 1px solid rgba(245,158,11,.15);
  border-radius: var(--radius);
  font-size: 11px; color: var(--warning);
  line-height: 1.3;
}
.tech-bottleneck-icon { font-size: 12px; flex-shrink: 0; margin-top: 1px; }

/* Totals */
.totals {
  padding-top: 16px; margin-bottom: 16px;
  border-top: 1px solid var(--border-subtle);
}
.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 3px 0;
}
.total-label { font-size: 12px; color: var(--text-muted); }
.total-value { font-size: 14px; font-weight: 600; font-family: var(--mono); }
.total-accent { color: var(--teal); }

/* Buttons */
.actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}
.btn {
  font-size: 12px; font-weight: 500;
  padding: 9px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms var(--ease);
  text-align: center;
}
.btn:hover { background: var(--bg-alt); border-color: var(--text-muted); }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--text); color: var(--bg);
  border-color: var(--text);
  grid-column: span 2;
}
.btn-primary:hover { opacity: .9; background: var(--text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--border); }

/* ---- Picker ---- */
.picker {
  padding: 20px 24px;
  min-width: 0;
}
.picker-head { margin-bottom: 16px; }
.picker-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.picker-title { font-size: 20px; font-weight: 600; }
.picker-search { display: flex; align-items: center; gap: 8px; }
.picker-search input {
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; padding: 7px 12px;
  min-width: 220px; border-radius: var(--radius);
  outline: none; transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.picker-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.picker-count {
  font-family: var(--mono); font-size: 11px;
  color: var(--text-muted);
}

/* Tabs */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
}
.tab {
  padding: 8px 14px;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
  transition: color 150ms var(--ease);
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab-icon { display: flex; align-items: center; }
.tab-count {
  font-family: var(--mono); font-size: 10px;
  padding: 1px 5px; border-radius: 10px;
  background: var(--bg-alt); color: var(--text-muted);
}
.tab.active .tab-count { background: var(--text); color: var(--bg); }
.tab[data-state="filled"]::before {
  content: ""; width: 5px; height: 5px;
  border-radius: 50%; background: var(--success);
}
.tab.active[data-state="filled"]::before { background: var(--warning); }

/* Filters */
.filters {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter {
  font-family: var(--mono); font-size: 10px;
  padding: 4px 10px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  border-radius: 20px;
  transition: all 150ms var(--ease);
}
.filter:hover { color: var(--text); border-color: var(--text-muted); }
.filter.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  cursor: pointer;
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: border-color 200ms var(--ease), box-shadow 250ms var(--ease), transform 250ms var(--ease-out);
}
.card:hover {
  border-color: var(--text-muted);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 12px rgba(37,99,235,.08);
}
.card.selected::after {
  content: ""; position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--accent);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  border-radius: 50%; z-index: 3;
  animation: checkPop .3s var(--ease-bounce);
}
@keyframes checkPop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
.card-no {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--mono); font-size: 9px;
  background: var(--bg); color: var(--text-muted);
  padding: 2px 6px; border-radius: 4px;
  letter-spacing: .5px; z-index: 2;
  border: 1px solid var(--border-subtle);
}

/* Card illustration */
.card-ill {
  height: 110px;
  background: var(--bg-alt);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
}
.card-ill svg.ill-icon { width: 44px; height: 44px; color: var(--text-muted); opacity: .15; }
.card-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; z-index: 2; padding: 10px;
  transition: transform 400ms var(--ease);
}
.card:hover .card-img { transform: scale(1.03); }
.card-img-fallback {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.spec-badge { text-align: center; padding: 8px; }
.spec-badge-main {
  display: block;
  font-size: 22px; font-weight: 600;
  line-height: 1.1;
}
.spec-badge-sub {
  display: block;
  font-family: var(--mono); font-size: 10px;
  color: var(--teal); margin-top: 4px;
  text-transform: uppercase; letter-spacing: 1px;
}
.spec-badge-detail {
  display: block;
  font-family: var(--mono); font-size: 9px;
  color: var(--text-muted); margin-top: 2px;
}

/* Card body */
.card-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; }
.card-meta {
  font-family: var(--mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-muted); margin-bottom: 4px;
}
.card-title { font-size: 13px; font-weight: 500; line-height: 1.3; margin-bottom: 2px; }
.card-sub { font-size: 11px; color: var(--text-secondary); margin-bottom: 10px; }
.card-specs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px;
  margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
}
.spec-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 5px;
  border-radius: 3px;
  transition: background 100ms var(--ease);
}
.spec-row:hover { background: var(--bg-alt); }
.spec-key { color: var(--text-muted); font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .3px; }
.spec-val { color: var(--text); font-weight: 500; font-size: 10px; }

/* Card price */
.card-price {
  background: var(--bg-warm);
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 600;
  border-top: 1px solid var(--border-subtle);
}
.price-live { color: var(--teal); }
.price-source {
  font-family: var(--mono); font-size: 9px;
  color: var(--text-muted); margin-left: 4px;
}
.price-tier {
  font-family: var(--mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 99px;
}
.price-tier[data-tier="budget"] { background: rgba(34,197,94,.1); color: var(--success); }
.price-tier[data-tier="mid"] { background: rgba(13,148,136,.1); color: var(--teal); }
.price-tier[data-tier="high"] { background: rgba(37,99,235,.1); color: var(--accent); }
.price-tier[data-tier="enthusiast"] { background: rgba(239,68,68,.1); color: var(--danger); }

/* Card links */
.card-links { padding: 0 14px 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px;
  font-family: var(--mono); font-size: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: all 150ms var(--ease);
  cursor: pointer; background: transparent;
}
.card-link:hover { border-color: var(--text-muted); color: var(--text); background: var(--bg-alt); }
.card-link-accent { border-color: var(--accent); color: var(--accent); }
.card-link-accent:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.card-link-teal { border-color: var(--teal); color: var(--teal); }
.card-link-teal:hover { background: var(--teal); color: #fff; border-color: var(--teal); }

/* Card live price */
.card-live-price {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 10px;
  color: var(--teal);
  padding: 3px 8px; border-radius: var(--radius);
  background: rgba(13,148,136,.06);
}

.card-tag {
  position: absolute; bottom: 48px; right: 8px;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  padding: 2px 6px; border-radius: 3px;
}
.card-tag.ok { background: rgba(34,197,94,.1); color: var(--success); }
.card-tag.warn { background: rgba(245,158,11,.1); color: var(--warning); }
.card-tag.bad { background: rgba(239,68,68,.1); color: var(--danger); }

/* Grid empty */
.grid-empty {
  grid-column: 1 / -1; text-align: center;
  padding: 60px 20px; color: var(--text-muted);
}

/* ---- Performance ---- */
.section-perf, .section-lib {
  max-width: 1200px; margin: 0 auto;
  padding: 48px 24px;
  border-top: 1px solid var(--border);
}
.section-head { margin-bottom: 24px; }
.section-head h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.section-head p { font-size: 13px; color: var(--text-secondary); }

.perf-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px;
}
.perf-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  transition: border-color 150ms var(--ease);
}
.perf-card:hover { border-color: var(--text-muted); }
.perf-game {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); margin-bottom: 2px;
}
.perf-name { font-size: 14px; font-weight: 500; margin-bottom: 1px; }
.perf-res { font-size: 11px; color: var(--text-secondary); margin-bottom: 10px; }
.perf-bar {
  position: relative; height: 24px;
  background: var(--bg-alt); border-radius: var(--radius);
  overflow: hidden;
}
.perf-bar-fill {
  height: 100%; width: 0;
  border-radius: var(--radius);
  transition: width 900ms var(--ease);
}
.perf-bar-fill.tier-budget { background: var(--success); }
.perf-bar-fill.tier-mid { background: var(--teal); }
.perf-bar-fill.tier-high { background: var(--accent); }
.perf-bar-fill.tier-enthusiast { background: var(--danger); }
.perf-bar-fps {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
  mix-blend-mode: difference;
}
.perf-ticks {
  display: flex; justify-content: space-between;
  margin-top: 3px;
  font-family: var(--mono); font-size: 9px; color: var(--text-muted);
}
.perf-summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin-top: 24px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.perf-stat {
  text-align: center; padding: 20px;
  border-right: 1px solid var(--border);
}
.perf-stat:last-child { border-right: none; }
.perf-num { display: block; font-size: 28px; font-weight: 600; line-height: 1; margin-bottom: 4px; }
.perf-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---- Library ---- */
.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px;
}
.lib-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  display: flex; flex-direction: column;
  transition: border-color 150ms var(--ease);
}
.lib-card:hover { border-color: var(--text-muted); }
.lib-no { font-family: var(--mono); font-size: 10px; color: var(--text-muted); margin-bottom: 4px; }
.lib-name { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.lib-summary { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.5; }
.lib-meta {
  font-family: var(--mono); font-size: 10px; color: var(--text-muted);
  margin-top: auto; padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between;
}
.lib-actions { display: flex; gap: 4px; margin-top: 8px; }
.lib-actions .btn { flex: 1; padding: 6px; font-size: 11px; }
.lib-empty {
  grid-column: 1 / -1; text-align: center;
  padding: 48px 20px; color: var(--text-muted);
}

/* ---- Footer ---- */
.footer {
  display: flex; justify-content: center; align-items: center; gap: 8px;
  padding: 24px; font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.footer-sep { opacity: .3; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 50px);
  background: var(--text); color: var(--bg);
  font-size: 12px; font-weight: 500;
  padding: 10px 20px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200; opacity: 0;
  transition: opacity 200ms var(--ease), transform 300ms var(--ease-out);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--text); color: var(--bg); }

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px; width: 100%;
  padding: 24px; position: relative;
  animation: modalIn .25s var(--ease-out);
}
@keyframes modalIn {
  0% { opacity: 0; transform: translateY(8px) scale(.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-wide { max-width: 600px; }
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-muted);
  width: 28px; height: 28px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.modal-close:hover { background: var(--bg-alt); color: var(--text); }
.modal-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.modal-card p { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.modal-row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 10px 0;
}
.modal-row input {
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: 7px 10px; font-family: var(--mono); font-size: 11px;
  border-radius: var(--radius); outline: none; color: var(--text);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.modal-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Compare modal */
.compare-head { margin-bottom: 8px; }
.compare-head h3 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.compare-head p { font-size: 12px; color: var(--text-secondary); }
.compare-live { margin: 10px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.compare-live-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: var(--bg-alt);
  border-bottom: 1px solid var(--border-subtle);
}
.compare-live-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; color: var(--success);
}
.compare-live-count { font-family: var(--mono); font-size: 9px; color: var(--text-muted); }
.compare-live-list { list-style: none; }
.compare-offer {
  display: grid; grid-template-columns: 40px 1fr auto;
  gap: 8px; align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.compare-offer:last-child { border-bottom: none; }
.compare-offer.best { background: rgba(34,197,94,.03); }
.offer-img { width: 40px; height: 40px; object-fit: contain; border-radius: 4px; background: var(--bg-alt); padding: 2px; }
.offer-img-empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 16px; width: 40px; height: 40px; background: var(--bg-alt); border-radius: 4px; }
.offer-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.offer-merchant { font-family: var(--mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.offer-title { font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offer-delivery { font-size: 9px; color: var(--text-muted); }
.offer-buy {
  font-size: 13px; font-weight: 600; white-space: nowrap;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  transition: all 150ms var(--ease);
}
a.offer-buy:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.compare-list { list-style: none; margin: 10px 0 0; }
.compare-list a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border);
  background: var(--surface); font-family: var(--mono); font-size: 11px;
  border-radius: var(--radius); transition: all 150ms var(--ease);
  color: var(--text);
}
.compare-list a + a { margin-top: 4px; }
.compare-list a:hover { border-color: var(--text-muted); background: var(--bg-alt); }
.compare-foot { margin-top: 10px; }
.compare-live-loading {
  display: flex; align-items: center; gap: 6px;
  padding: 10px; font-family: var(--mono); font-size: 10px; color: var(--text-muted);
}
.compare-live-note { padding: 10px; font-size: 12px; color: var(--text-secondary); }

@keyframes liveSpin { to { transform: rotate(360deg); } }
.live-spin { display: inline-block; animation: liveSpin 1s linear infinite; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .builder { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .topnav a:not(.active) { display: none; }
}
@media (max-width: 600px) {
  .picker-search input { min-width: 0; flex: 1; }
  .picker-top { flex-direction: column; align-items: stretch; }
  .grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .tech-grid { grid-template-columns: 1fr; }
  .btn-primary { grid-column: 1; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Animations ---- */
@keyframes ruleResolved {
  0% { background: rgba(34,197,94,.12); }
  100% { background: transparent; }
}
.rule-resolved { animation: ruleResolved .9s ease; }

/* ---- Best Value Badge ---- */
.card-best-value {
  position: absolute; top: 8px; right: 32px;
  font-size: 13px; z-index: 3;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.2));
  animation: bestValuePulse 2s ease-in-out infinite;
}
.card.selected .card-best-value { right: 52px; }
@keyframes bestValuePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ---- Generation Badge ---- */
.card-gen {
  position: absolute; top: 30px; right: 8px;
  font-family: var(--mono); font-size: 8px; font-weight: 600;
  padding: 1px 5px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: .3px; z-index: 2;
}
.card-gen.current { background: rgba(34,197,94,.12); color: var(--success); }
.card-gen.previous { background: rgba(245,158,11,.1); color: var(--warning); }
.card-gen.legacy { background: rgba(239,68,68,.08); color: var(--danger); opacity: .7; }

/* ---- Electricity Cost ---- */
.total-row.elec { padding-top: 4px; }
.total-row.elec .total-value { font-size: 11px; color: var(--text-muted); }
.total-label--elec { 
  font-size: 10px; color: var(--text-muted); 
  display: flex; align-items: center; gap: 4px; 
  cursor: help;
}
.elec-settings {
  display: flex; gap: 4px; margin-top: 4px;
}
.elec-settings input {
  background: var(--bg-alt); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 10px; padding: 3px 6px;
  width: 60px; border-radius: 3px; text-align: right;
  color: var(--text); outline: none;
  transition: border-color 150ms var(--ease);
}
.elec-settings input:focus { border-color: var(--accent); }
.elec-settings label { font-size: 10px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }

/* ---- Undo / Redo buttons ---- */
.undo-redo {
  display: flex; gap: 4px;
  padding-top: 8px;
}
.undo-redo .btn { flex: 1; padding: 6px 8px; font-size: 11px; }
.undo-redo .btn:disabled { opacity: .3; pointer-events: none; }

/* ---- Radar Chart ---- */
.radar-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.radar-container {
  display: flex; justify-content: center; align-items: center;
  padding: 16px;
}
.radar-container svg { 
  max-width: 320px; width: 100%; height: auto;
}
.radar-labels {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; margin-top: 12px; max-width: 400px; margin-left: auto; margin-right: auto;
}
.radar-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-secondary);
}
.radar-label-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.radar-label-val { font-family: var(--mono); font-size: 10px; margin-left: auto; color: var(--text); font-weight: 500; }

/* ---- Build Comparison ---- */
.compare-builds {
  margin-top: 16px;
}
.compare-builds-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.compare-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
}
.compare-table th, .compare-table td {
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.compare-table th {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted); font-weight: 500;
  background: var(--bg-alt);
}
.compare-table td:first-child { color: var(--text-secondary); font-weight: 500; }
.compare-table td:nth-child(2), .compare-table td:nth-child(3) { font-family: var(--mono); font-size: 11px; }
.compare-table .better { color: var(--success); font-weight: 600; }
.compare-table .worse { color: var(--danger); opacity: .7; }
.compare-table tr:hover td { background: var(--bg-alt); }
.compare-table .compare-total td { font-weight: 600; border-top: 2px solid var(--border); font-size: 13px; }
.compare-select {
  display: flex; gap: 8px; align-items: center;
}
.compare-select select {
  background: var(--surface); border: 1px solid var(--border);
  font-family: var(--font); font-size: 12px; padding: 6px 10px;
  border-radius: var(--radius); outline: none; color: var(--text);
}
.compare-select select:focus { border-color: var(--accent); }

/* ---- Wizard ---- */
.wizard {
  max-width: 520px;
}
.wizard-steps {
  display: flex; gap: 0; margin-bottom: 20px;
}
.wizard-step-dot {
  flex: 1; text-align: center; position: relative;
  font-size: 10px; color: var(--text-muted);
}
.wizard-step-dot::before {
  content: ''; display: block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--border);
  margin: 0 auto 6px; transition: all 250ms var(--ease);
}
.wizard-step-dot.active { color: var(--text); font-weight: 500; }
.wizard-step-dot.active::before { background: var(--accent); transform: scale(1.4); }
.wizard-step-dot.done { color: var(--success); }
.wizard-step-dot.done::before { background: var(--success); }
.wizard-step-dot::after {
  content: ''; position: absolute; top: 4px; left: 60%;
  width: 80%; height: 1px; background: var(--border);
}
.wizard-step-dot:last-child::after { display: none; }
.wizard-step-dot.done::after { background: var(--success); }

.wizard-body { min-height: 180px; margin-bottom: 16px; }
.wizard-body h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.wizard-body p { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }
.wizard-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.wizard-choice {
  padding: 14px; background: var(--bg-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer; text-align: center;
  transition: all 200ms var(--ease);
}
.wizard-choice:hover { border-color: var(--text-muted); background: var(--surface); }
.wizard-choice.selected { border-color: var(--accent); background: rgba(37,99,235,.04); }
.wizard-choice-icon { font-size: 24px; display: block; margin-bottom: 6px; }
.wizard-choice-label { font-size: 13px; font-weight: 500; }
.wizard-choice-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.wizard-budget-slider {
  display: flex; flex-direction: column; gap: 8px;
}
.wizard-budget-slider input[type="range"] {
  width: 100%; accent-color: var(--accent);
}
.wizard-budget-display {
  font-family: var(--mono); font-size: 18px; font-weight: 600;
  text-align: center; color: var(--accent);
}
.wizard-budget-presets {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
}
.wizard-budget-preset {
  font-family: var(--mono); font-size: 11px;
  padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer; background: transparent;
  color: var(--text-secondary);
  transition: all 150ms var(--ease);
}
.wizard-budget-preset:hover { border-color: var(--text-muted); color: var(--text); }
.wizard-budget-preset.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.wizard-results {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.wizard-results-header {
  padding: 10px 14px; background: var(--bg-alt);
  font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}
.wizard-results-list {
  list-style: none;
}
.wizard-results-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px; font-size: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.wizard-results-list li:last-child { border-bottom: none; }
.wizard-result-name { font-weight: 500; }
.wizard-result-price { font-family: var(--mono); font-size: 11px; color: var(--teal); }
.wizard-foot { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---- Export Card ---- */
.export-preview {
  max-width: 480px; margin: 0 auto;
}
#exportCanvas { display: none; }
.export-preview img { 
  width: 100%; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

/* ---- Library Notes ---- */
.lib-note {
  width: 100%; margin-top: 8px; padding: 6px 8px;
  background: var(--bg-alt); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); font-family: var(--font);
  font-size: 11px; resize: vertical; min-height: 36px;
  color: var(--text); outline: none;
  transition: border-color 150ms var(--ease);
}
.lib-note:focus { border-color: var(--accent); }
.lib-note::placeholder { color: var(--text-muted); }

/* ---- Share QR ---- */
.share-qr { display:flex; flex-direction:column; align-items:center; margin-top:12px; gap:4px; }
.share-qr img { border-radius: var(--radius); border: 1px solid var(--border); }
.share-qr-hint { font-size: 11px; color: var(--text-muted); }

/* ---- Upgrade Panel ---- */
.upgrade-panel {
  padding-top: 16px; margin-bottom: 16px;
  border-top: 1px solid var(--border-subtle);
}
.upgrade-head { margin-bottom: 8px; }
.upgrade-body {
  padding: 10px 12px;
  background: rgba(37,99,235,.04);
  border: 1px solid rgba(37,99,235,.12);
  border-radius: var(--radius);
  font-size: 12px;
}
.upgrade-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.upgrade-item + .upgrade-item { border-top: 1px solid var(--border-subtle); }
.upgrade-from { color: var(--text-muted); font-size: 11px; text-decoration: line-through; }
.upgrade-arrow { color: var(--accent); font-weight: 600; }
.upgrade-to { color: var(--text); font-weight: 500; }
.upgrade-gain { font-family: var(--mono); font-size: 10px; color: var(--success); margin-left: auto; white-space: nowrap; }
.upgrade-cost { font-family: var(--mono); font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.upgrade-empty { color: var(--text-muted); text-align: center; padding: 8px; font-size: 11px; }

/* ---- Bottleneck advanced ---- */
.bottleneck-detail { margin-top: 6px; font-size: 11px; line-height: 1.4; }
.bottleneck-detail strong { color: var(--warning); }
.bottleneck-gauge {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px;
}
.bottleneck-gauge-bar {
  flex: 1; height: 6px; background: var(--bg-alt);
  border-radius: 3px; overflow: hidden;
}
.bottleneck-gauge-fill {
  height: 100%; border-radius: 3px;
  transition: width 600ms var(--ease);
}
.bottleneck-gauge-fill.cpu { background: var(--warning); }
.bottleneck-gauge-fill.gpu { background: var(--accent); }
.bottleneck-gauge-label { font-family: var(--mono); font-size: 10px; color: var(--text-muted); white-space: nowrap; min-width: 40px; }

/* ---- Console vs PC ---- */
.console-compare {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.console-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px;
}
.console-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  text-align: center;
  transition: border-color 150ms var(--ease), transform 250ms var(--ease);
}
.console-card:hover { border-color: var(--text-muted); transform: translateY(-2px); }
.console-card.winner { border-color: var(--success); background: rgba(34,197,94,.03); }
.console-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.console-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.console-multiplier {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  margin: 8px 0;
}
.console-multiplier.win { color: var(--success); }
.console-multiplier.lose { color: var(--danger); }
.console-detail { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.console-no-build { grid-column: 1/-1; text-align: center; color: var(--text-muted); padding: 24px; font-size: 12px; }

/* ---- Sparkline in card ---- */
.card-sparkline {
  height: 24px; margin: 0 14px 4px;
  overflow: visible;
}
.card-sparkline svg { width: 100%; height: 100%; }
.sparkline-hint {
  font-family: var(--mono); font-size: 8px; color: var(--text-muted);
  text-align: right; padding-right: 14px;
}

/* ---- Reddit modal ---- */
#redditMarkdown::selection { background: var(--accent); color: #fff; }

/* ---- Animation canvas ---- */
#animCanvas { background: var(--bg); display: block; }

/* ---- Compat list item transition ---- */
.compat-list li {
  animation: fadeSlideIn .2s ease;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}
