:root {
  --primary: #6750A4;
  --on-primary: #FFFFFF;
  --primary-container: #EADDFF;
  --on-primary-container: #21005D;
  --secondary: #625B71;
  --secondary-container: #E8DEF8;
  --on-secondary-container: #1D192B;
  --surface: #FEF7FF;
  --surface-dim: #DED8E1;
  --surface-container: #F3EDF7;
  --surface-container-high: #ECE6F0;
  --on-surface: #1D1B20;
  --on-surface-variant: #49454F;
  --outline: #79747E;
  --outline-variant: #CAC4D0;
  --error: #B3261E;
  --error-container: #F9DEDC;
  --scrim: rgba(0, 0, 0, 0.32);
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15);
  --shadow-2: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px 2px rgba(0,0,0,.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 28px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #D0BCFF;
    --on-primary: #381E72;
    --primary-container: #4F378B;
    --on-primary-container: #EADDFF;
    --secondary: #CCC2DC;
    --secondary-container: #4A4458;
    --on-secondary-container: #E8DEF8;
    --surface: #141218;
    --surface-dim: #141218;
    --surface-container: #211F26;
    --surface-container-high: #2B2930;
    --on-surface: #E6E0E9;
    --on-surface-variant: #CAC4D0;
    --outline: #938F99;
    --outline-variant: #49454F;
    --error: #F2B8B5;
    --error-container: #8C1D18;
    --shadow-1: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.3);
    --shadow-2: 0 1px 3px rgba(0,0,0,.5), 0 4px 8px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}

body {
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--surface);
  color: var(--on-surface);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* focus visible for keyboard nav */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- App bar ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface-container);
  box-shadow: var(--shadow-1);
}
.app-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-bar-icon {
  width: 26px;
  height: 26px;
  color: var(--primary);
  flex: 0 0 auto;
}
.app-bar-home {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  flex: 0 0 auto;
}
.app-bar-home:hover .app-bar-title { color: var(--primary); }
.app-bar-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
}
.app-bar-sub {
  margin-left: auto;
  font-size: 13px;
  color: var(--on-surface-variant);
}

/* ---------- Page ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 32px 16px;
}

/* ---------- Search field (Material filled) ---------- */
.search-section { position: relative; }
.field {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-container-high);
  border-radius: var(--radius-xl);
  padding: 4px 8px 4px 16px;
  min-height: 56px;
  transition: background .15s ease, box-shadow .15s ease;
}
.field:focus-within {
  background: var(--surface-container);
  box-shadow: 0 1px 0 2px var(--primary);
}
.field-icon { width: 24px; height: 24px; color: var(--on-surface-variant); flex: 0 0 auto; }
.field input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--on-surface);
  font-size: 16px;
  padding: 14px 0;
}
.field input::placeholder { color: var(--on-surface-variant); }
.field-clear {
  border: 0;
  background: transparent;
  color: var(--on-surface-variant);
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.field-clear:hover { background: var(--surface-container-high); }

/* ---------- Suggestions dropdown ---------- */
.suggest {
  position: absolute;
  top: 62px;
  left: 0;
  right: 0;
  background: var(--surface-container);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  z-index: 40;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 15px;
}
.suggest-item:hover, .suggest-item.active { background: var(--primary-container); }
.suggest-item .g-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item .g-rating {
  font-size: 12px;
  color: var(--on-surface-variant);
  flex: 0 0 auto;
}
.suggest-item .g-add { color: var(--primary); font-size: 18px; flex: 0 0 auto; }
.suggest-empty { padding: 16px; color: var(--on-surface-variant); font-size: 14px; }
.suggest-item.g-suggest-disabled { opacity: .5; cursor: default; }
.suggest-item.g-suggest-disabled:hover { background: transparent; }

/* ---------- Chips ---------- */
.chips-section { margin: 18px 0 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border-radius: 8px;
  padding: 8px 8px 8px 12px;
  font-size: 14px;
  max-width: 100%;
  animation: pop .18s ease;
}
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-remove {
  border: 0;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.chip .chip-remove:hover { background: var(--scrim); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Sections & cards ---------- */
.section {
  margin-top: 26px;
  animation: fadeUp .3s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.section-title {
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 12px 4px;
  color: var(--on-surface);
}
.card {
  background: var(--surface-container);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-1);
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--on-surface-variant);
}
.empty-state svg { width: 72px; height: 72px; color: var(--primary); opacity: .8; }
.empty-state h2 { font-size: 20px; font-weight: 500; margin: 20px 0 8px 0; }
.empty-state p { font-size: 15px; max-width: 420px; margin: 0 auto; }

/* ---------- Chart (vertical bars) ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  min-height: 280px;
  padding: 16px 4px 0 4px;
}
.chart-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
}
.chart-bar {
  width: 100%;
  max-width: 60px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height .5s cubic-bezier(.22,1,.36,1);
  min-height: 6px;
}
/* vendor colors */
.chart-bar.vendor-nvidia { background: #76b900; }
.chart-bar.vendor-amd    { background: #ed1c24; }
.chart-bar.vendor-intel  { background: #0071c5; }
.chart-bar.vendor-other  { background: var(--secondary-container); }
/* top bar keeps vendor color but brighter */
.chart-bar.top.vendor-nvidia { background: #8cd600; }
.chart-bar.top.vendor-amd    { background: #ff3b47; }
.chart-bar.top.vendor-intel  { background: #0090e8; }
.chart-bar.top.vendor-other  { background: var(--primary); }
.chart-bar-wrap {
  width: 100%;
  max-width: 72px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 200px;
}
.chart-percent { font-size: 12px; color: var(--on-surface-variant); }
.chart-name {
  font-size: 12px;
  color: var(--on-surface-variant);
  text-align: center;
  overflow-wrap: anywhere;
  max-width: 90px;
  line-height: 1.25;
  white-space: pre-line;
}
.chart-year { font-size: 11px; color: var(--on-surface-variant); opacity: .8; }
.chart-leader {
  display: none;
}

/* ---------- Spec table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0; }
.spec-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 14px;
}
.spec-table th, .spec-table td {
  border-bottom: 1px solid var(--outline-variant);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.spec-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-container);
  color: var(--on-surface);
  font-weight: 600;
  font-size: 14px;
  z-index: 2;
}
.spec-table .row-label {
  color: var(--on-surface-variant);
  font-weight: 500;
  white-space: nowrap;
  min-width: 150px;
}
.spec-table thead th.row-label { }
.spec-table .section-row td {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .4px;
}
.spec-table .section-row td.row-label { }
.spec-table .gpu-head {
  cursor: pointer;
  user-select: none;
  position: relative;
}
.spec-table .gpu-head:hover { background: var(--primary-container); }
.spec-table .gpu-head .gpu-year { display: block; font-size: 11px; color: var(--on-surface-variant); font-weight: 400; }
.spec-table .head-rating { display: block; font-size: 12px; color: var(--primary); font-weight: 500; margin-top: 2px; }
.empty-cell { color: var(--on-surface-variant); opacity: .55; }
.spec-table .gpu-head .close-gpu {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  opacity: .6;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spec-table .gpu-head .close-gpu:hover { background: var(--scrim); opacity: 1; }

/* ---------- Mode link ---------- */
.mode-link {
  margin-left: auto;
  background: var(--primary-container);
  color: var(--on-primary-container);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  transition: background .15s;
}
.mode-link:hover { background: var(--primary); color: var(--on-primary); }

/* CPU-specific chart score */
.chart-score {
  font-size: 11px;
  color: var(--on-surface-variant);
  opacity: .8;
}
.cpu-head {
  cursor: pointer;
  user-select: none;
  position: relative;
}
.cpu-head:hover { background: var(--primary-container); }
.cpu-head .head-cpumark {
  display: block;
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  margin-top: 2px;
}
.cpu-head .close-cpu {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  opacity: .6;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cpu-head .close-cpu:hover { background: var(--scrim); opacity: 1; }

/* Highlighted row (CPU Mark) */
.highlight-row td {
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
}
.highlight-row .row-label {
  color: var(--primary);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 13px;
  padding: 24px 16px 20px 16px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-bar-sub { display: none; }
  .page { padding: 16px 12px 28px 12px; }
  .chart { min-height: 230px; gap: 6px; }
  .chart-bar-wrap { height: 170px; }
  .chart-bar { max-width: 52px; }
  .spec-table { min-width: 480px; font-size: 13px; }
  .suggest-item { padding: 14px 16px; font-size: 16px; }
}

@media (max-width: 420px) {
  .chart { gap: 4px; }
  .chart-name { max-width: 76px; font-size: 11px; }
  .chart-bar-wrap { height: 140px; }
  .chart-bar { max-width: 44px; }
}