:root {
  color-scheme: light;
  --ink: #18202b;
  --muted: #687386;
  --line: #d9e0e8;
  --panel: #ffffff;
  --soft: #f4f7fa;
  --surface: #eef3f7;
  --surface-strong: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0a514c;
  --warn: #9a3412;
  --blue: #2458a6;
  --shadow: 0 18px 45px rgba(34, 45, 62, 0.12);
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --chip-blue-bg: #edf4ff;
  --chip-blue-ink: #1e4f99;
  --chip-ok-bg: #e8f5f3;
  --chip-ok-ink: #0a514c;
  --chip-warn-bg: #fff4de;
  --chip-warn-ink: #8a4b05;
  --chip-error-bg: #fee7df;
  --chip-error-ink: #9a3412;
  --tag-bg: #f8fafc;
  --tag-ink: #405064;
  --tag-line: #dce6ef;
  --tag-value-bg: #eef8f1;
  --tag-value-line: #cfe8d6;
  --tag-value-ink: #1d6b3c;
  --tag-thermal-bg: #eef5ff;
  --tag-thermal-line: #d7e4fb;
  --tag-thermal-ink: #2458a6;
  --spec-tag-bg: #eef5f4;
  --spec-tag-ink: #0a514c;
  --card-soft-bg: #fbfcff;
  --button-bg: #ffffff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ecf2fb;
  --muted: #9eaac1;
  --line: #273244;
  --panel: #111927;
  --soft: #162131;
  --surface: #08111d;
  --surface-strong: #0d1725;
  --accent: #15a094;
  --accent-dark: #76d8ce;
  --warn: #ff8a65;
  --blue: #6ea8ff;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
  --topbar-bg: rgba(10, 17, 29, 0.9);
  --chip-blue-bg: #162840;
  --chip-blue-ink: #9fc3ff;
  --chip-ok-bg: #12312d;
  --chip-ok-ink: #8ce5da;
  --chip-warn-bg: #3b2a14;
  --chip-warn-ink: #ffd18b;
  --chip-error-bg: #3d1f1a;
  --chip-error-ink: #ffab91;
  --tag-bg: #172334;
  --tag-ink: #c1cede;
  --tag-line: #2b3b52;
  --tag-value-bg: #173326;
  --tag-value-line: #27543e;
  --tag-value-ink: #99e0b0;
  --tag-thermal-bg: #15283f;
  --tag-thermal-line: #28466d;
  --tag-thermal-ink: #9dc0ff;
  --spec-tag-bg: #17302b;
  --spec-tag-ink: #95e2d7;
  --card-soft-bg: #0e1622;
  --button-bg: #121d2d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
  color-scheme: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 44px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.auth-panel {
  display: inline-flex;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.auth-panel-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.auth-summary {
  max-width: 260px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: right;
}

.auth-inline-status {
  max-width: 300px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: right;
}

.auth-inline-status[data-tone="ok"] {
  color: var(--accent-dark);
}

.auth-inline-status[data-tone="warn"] {
  color: var(--warn);
}

.auth-launchers {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.auth-page-layout {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.auth-page-shell {
  display: grid;
  gap: 16px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-page-shell-head p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

.auth-page-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-page-status[data-tone="ok"] {
  color: var(--accent-dark);
}

.auth-page-status[data-tone="warn"] {
  color: var(--warn);
}

.auth-page-form {
  display: grid;
  gap: 12px;
}

.auth-page-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface-strong);
  color: var(--ink);
}

.auth-page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-page-actions > * {
  flex: 1 1 180px;
}

.auth-page-actions-stack {
  display: grid;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.source-pill,
.theme-toggle,
.ghost-button,
.jimms-link,
.jimms-cart-button,
.product-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
}

.theme-toggle {
  min-height: 40px;
  padding: 0 12px;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle[aria-pressed="true"] {
  border-color: var(--blue);
  color: var(--blue);
}

.source-pill {
  max-width: 46vw;
  padding: 9px 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.82fr) minmax(520px, 1.18fr);
  gap: 22px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 44px) 42px;
}

.builder,
.catalog {
  min-width: 0;
}

.builder-head,
.catalog-head,
.toolbar,
.summary,
.compatibility {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.builder-head,
.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.65rem, 3vw, 2.25rem);
}

h2 {
  font-size: 1.2rem;
}

.builder-head p,
.catalog-head p,
.desc,
.sku,
.stock {
  color: var(--muted);
}

.builder-head p,
.catalog-head p {
  margin-top: 5px;
}

.ghost-button,
.jimms-link,
.jimms-cart-button {
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
}

.ghost-button:hover,
.jimms-link:hover,
.jimms-cart-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.part-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.part-row {
  display: grid;
  grid-template-columns: minmax(115px, 0.44fr) minmax(0, 1fr) minmax(96px, auto) 36px;
  align-items: start;
  min-height: 82px;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.part-select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  align-self: center;
}

.part-select.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.selected-part {
  min-width: 0;
  color: var(--muted);
  align-self: center;
}

.selected-part strong,
.selected-part span,
.selected-details {
  display: block;
}

.selected-part strong {
  color: var(--ink);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.selected-part span {
  margin-top: 3px;
  font-size: 0.88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.selected-details {
  margin-top: 5px;
  color: #405064;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.part-price {
  align-self: center;
  justify-self: end;
  font-weight: 800;
  white-space: nowrap;
}

.remove-button {
  align-self: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.remove-button:hover {
  color: var(--warn);
  border-color: #f0b69d;
}

.summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding: 18px;
}

.summary span {
  color: var(--muted);
  font-weight: 700;
}

.summary strong {
  font-size: 1.55rem;
}

.build-actions {
  margin-top: 14px;
}

.saved-builds-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.saved-builds-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.saved-builds-head strong {
  display: block;
}

.saved-builds-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.build-name-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.build-name-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface-strong);
  color: var(--ink);
}

.saved-builds-actions {
  display: flex;
  gap: 10px;
}

.saved-builds-list {
  display: grid;
  gap: 8px;
}

.saved-build-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-soft-bg);
}

.saved-build-copy {
  min-width: 0;
}

.saved-build-copy strong,
.saved-build-copy span {
  display: block;
}

.saved-build-copy strong {
  overflow-wrap: anywhere;
}

.saved-build-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.saved-build-row button {
  min-width: 72px;
}

.jimms-cart-button {
  width: 100%;
  font-weight: 800;
}

.jimms-cart-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #f4f7fb;
  border-color: var(--line);
}

.compatibility {
  margin-top: 14px;
  padding: 16px;
}

.benchmarks {
  margin-top: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.benchmarks-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.benchmarks-head span {
  min-width: 92px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--chip-blue-bg);
  color: var(--chip-blue-ink);
  font-size: 0.8rem;
  font-weight: 850;
  text-align: center;
}

.benchmarks-note {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.4;
}

.benchmark-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.benchmark-game {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-soft-bg);
  padding: 12px;
}

.benchmark-game h3 {
  font-size: 1rem;
}

.benchmark-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.benchmark-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  font-size: 0.92rem;
}

.benchmark-row span {
  color: var(--muted);
}

.benchmark-row strong {
  white-space: nowrap;
}

.compatibility-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compatibility-head span {
  min-width: 58px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--chip-ok-bg);
  color: var(--chip-ok-ink);
  font-size: 0.8rem;
  font-weight: 850;
  text-align: center;
}

.compatibility[data-status="warn"] .compatibility-head span {
  background: var(--chip-warn-bg);
  color: var(--chip-warn-ink);
}

.compatibility[data-status="error"] .compatibility-head span {
  background: var(--chip-error-bg);
  color: var(--chip-error-ink);
}

.compatibility ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.compatibility li {
  position: relative;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.4;
}

.compatibility li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.compatibility .compat-ok::before {
  background: var(--accent);
}

.compatibility .compat-warn::before {
  background: #c27803;
}

.compatibility .compat-error::before {
  background: var(--warn);
}

.toolbar {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.tab-button[aria-selected="true"] {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.search input,
.filters input,
.filters select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface-strong);
  color: var(--ink);
}

.filters {
  display: grid;
  grid-template-columns: minmax(145px, 1fr) minmax(140px, 1fr) minmax(130px, 1fr) minmax(86px, 0.55fr) minmax(86px, 0.55fr) auto;
  gap: 10px;
  align-items: end;
}

.filters label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.filters select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 15px top 19px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 10px top 19px / 6px 6px no-repeat,
    var(--surface-strong);
  padding: 0 32px 0 12px;
}

.check-filter {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink) !important;
}

.check-filter input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--accent);
  background: var(--surface-strong);
}

.catalog-head {
  margin-top: 14px;
}

.products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.product-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 12px;
  min-height: 210px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-visual {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(36, 88, 166, 0.16)),
    #f7fafc;
  border: 1px solid var(--line);
}

.product-visual::before,
.product-visual::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 2px solid var(--accent);
  border-radius: 6px;
}

.product-visual::after {
  inset: 29px 14px;
  border-color: var(--blue);
  border-left: 0;
  border-right: 0;
}

.product-visual.has-image {
  display: grid;
  place-items: center;
  background: var(--surface-strong);
}

.product-visual.has-image::before,
.product-visual.has-image::after {
  content: none;
}

.product-visual img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.product-copy {
  min-width: 0;
}

.product-card h3 {
  display: -webkit-box;
  min-height: 42px;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.sku {
  margin-top: 7px;
  font-size: 0.86rem;
  font-weight: 750;
}

.product-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.product-details span {
  padding: 4px 7px;
  border: 1px solid var(--tag-line);
  border-radius: 8px;
  background: var(--tag-bg);
  color: var(--tag-ink);
  font-size: 0.78rem;
  font-weight: 760;
}

.product-details span[data-tone="value"] {
  background: var(--tag-value-bg);
  border-color: var(--tag-value-line);
  color: var(--tag-value-ink);
}

.product-details span[data-tone="thermal"] {
  background: var(--tag-thermal-bg);
  border-color: var(--tag-thermal-line);
  color: var(--tag-thermal-ink);
}

.desc,
.stock {
  margin-top: 8px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.stock {
  color: var(--accent-dark);
  font-weight: 750;
}

.spec-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.spec-tags span {
  padding: 4px 7px;
  border-radius: 8px;
  background: var(--spec-tag-bg);
  color: var(--spec-tag-ink);
  font-size: 0.78rem;
  font-weight: 750;
}

.product-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.price {
  font-size: 1.15rem;
}

.product-actions button {
  min-width: 86px;
  min-height: 40px;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.product-actions button:hover {
  background: var(--accent-dark);
}

.empty,
.loading {
  grid-column: 1 / -1;
  padding: 28px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .layout,
  .products {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  .builder-head,
  .catalog-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .auth-panel,
  .auth-launchers {
    width: 100%;
  }

  .auth-panel,
  .auth-launchers {
    justify-content: stretch;
  }

  .auth-panel-copy {
    width: 100%;
  }

  .auth-summary,
  .auth-inline-status {
    max-width: none;
    text-align: left;
  }

  .auth-launchers button,
  .auth-panel > .ghost-button {
    width: 100%;
  }

  .source-pill {
    max-width: none;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .part-row {
    grid-template-columns: 1fr 36px;
  }

  .part-select,
  .selected-part,
  .part-price {
    grid-column: 1 / -1;
  }

  .remove-button {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .product-card {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .product-visual {
    width: 62px;
    height: 62px;
  }
}
