.browse-layout {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.browse-filters {
  flex: 0 0 240px;
  width: 240px;
  padding: 20px;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);

  animation: browse-filters-in 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 120ms;
}

.browse-filters-tabs {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 4px;
}

.browse-filters-tab {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 160ms ease, color 160ms ease;
}

.browse-filters-tab:hover {
  opacity: 0.9;
}

.browse-filters-tab.active {
  opacity: 1;
  color: var(--text);
  cursor: default;
}

.browse-filters-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.browse-sort-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.browse-sort-row:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.browse-sort-row input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.browse-sort-row .browse-tick {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 140ms ease, background 140ms ease;
  position: relative;
}

.browse-sort-row .browse-tick::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
  transform: scale(0);
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.browse-sort-row:hover .browse-tick {
  border-color: var(--text);
}

.browse-sort-row input[type="radio"]:checked + .browse-tick {
  background: var(--text);
  border-color: var(--text);
}

.browse-sort-row input[type="radio"]:checked + .browse-tick::after {
  transform: scale(1);
}

.browse-sort-row input[type="radio"]:focus-visible + .browse-tick {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.browse-filters-subtitle {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.browse-filters-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.browse-filters-body[hidden] {
  display: none;
}

.browse-filters-group-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.browse-filters-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.browse-filters-row:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.browse-filters-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.browse-filters-row .browse-tick {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 140ms ease, background 140ms ease;
  position: relative;
}

.browse-filters-row .browse-tick::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transform-origin: center;
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.browse-filters-row:hover .browse-tick {
  border-color: var(--text);
}

.browse-filters-row input[type="checkbox"]:checked + .browse-tick {
  background: var(--text);
  border-color: var(--text);
}

.browse-filters-row input[type="checkbox"]:checked + .browse-tick::after {
  transform: rotate(-45deg) translate(1px, -1px) scale(1);
}

.browse-filters-row input[type="checkbox"]:focus-visible + .browse-tick {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.browse-filters-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.browse-card {
  position: relative;
}

.browse-add {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.browse-add:hover,
.browse-add:focus-visible {
  color: var(--text);
  border-color: var(--text);
  outline: none;
}

.browse-add.is-added {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
  font-size: 13px;
}

.browse-add.is-added:hover,
.browse-add.is-added:focus-visible {
  color: var(--text);
  border-color: var(--text);
}

.browse-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.browse-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 14, 0.5);
  animation: browse-detail-fade 160ms ease-out both;
}

.browse-detail-panel {
  position: relative;
  width: min(1040px, 100%);
  height: min(720px, 92vh);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28), 0 6px 16px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  animation: browse-detail-in 200ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.browse-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.browse-detail-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.browse-detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.browse-detail-add {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--surface);
  cursor: pointer;
  transition: filter 0.12s ease, opacity 0.12s ease;
}

.browse-detail-add:hover,
.browse-detail-add:focus-visible {
  filter: brightness(1.1);
  outline: none;
}

.browse-detail-add.is-added {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
  filter: none;
}

.browse-detail-add.is-added:hover,
.browse-detail-add.is-added:focus-visible {
  color: var(--text);
  border-color: var(--text);
  filter: none;
}

.browse-detail-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.12s ease, color 0.12s ease;
}

.browse-detail-close:hover,
.browse-detail-close:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
  outline: none;
}

.browse-detail-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.browse-detail-subtitle {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.browse-detail-body {
  flex: 1 1 auto;
  min-height: 200px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  overflow: hidden;
  font-size: 14px;
  color: var(--text);
}

.browse-detail-sidebar {
  padding: 24px 22px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: color-mix(in srgb, var(--surface) 96%, var(--text) 4%);
}

.detail-sidebar-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-sidebar-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-stat-big {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.detail-stat-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.detail-stat-text {
  font-size: 14px;
  color: var(--text);
}

.detail-price-main {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.detail-price-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.detail-price-tier {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.detail-model-id {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-model-id code {
  flex: 1 1 auto;
  font-size: 12px;
  padding: 4px 8px;
  background: var(--chip-bg, var(--accent-soft));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-copy {
  flex: 0 0 auto;
  font: inherit;
  font-size: 11.5px;
  padding: 4px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.detail-copy:hover {
  color: var(--text);
  border-color: var(--text);
}

.browse-detail-main {
  padding: 24px 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-section-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-prose {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.detail-caps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.detail-caps li {
  font-size: 12.5px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 999px;
}

.detail-benchmarks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-bench-row {
  display: grid;
  grid-template-columns: 96px 1fr 48px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.detail-bench-name {
  color: var(--muted);
}

.detail-bench-bar {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.detail-bench-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.detail-bench-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 500;
}

.detail-bench-note {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
}

.detail-meta {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  font-size: 13px;
}

.detail-meta dt {
  color: var(--muted);
}

.detail-meta dd {
  margin: 0;
  color: var(--text);
}

.detail-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.detail-link {
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: border-color 0.12s ease;
}

.detail-link:hover {
  border-color: var(--text);
}

@media (max-width: 720px) {
  .browse-detail-body {
    grid-template-columns: 1fr;
  }
  .browse-detail-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

@keyframes browse-detail-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes browse-detail-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.browse-results {
  flex: 1 1 auto;
  min-width: 0;
}

.browse-results-status {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.browse-results .card-grid {
  padding: 0 0 24px;
}

@keyframes browse-filters-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 1024px) {
  .browse-layout {
    flex-direction: column;
  }

  .browse-filters {
    flex: 0 0 auto;
    width: auto;
    animation: none;
  }
}

/* ── Mobile toolbar (sticky filter/sort buttons) ─────────────────
   Hidden on desktop; revealed at ≤ 720px below. PCPartPicker-style
   bar that lives just below the layer pill and lets users open the
   filters drawer without scrolling past a giant filter block. */
.browse-mobile-toolbar {
  display: none;
}

.browse-mobile-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.browse-mobile-btn:hover,
.browse-mobile-btn:focus-visible {
  border-color: var(--text);
  outline: none;
}

.browse-mobile-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  line-height: 1;
}

.browse-mobile-badge[hidden] { display: none; }

.browse-drawer-backdrop {
  display: none;
}

.browse-drawer-close {
  display: none;
}

.browse-drawer-footer {
  display: none;
}

/* ── Mobile (≤ 720px) ─────────────────────────────────────────────
   PCPartPicker-style layout: sticky filter/sort toolbar; filters
   panel slides up as a bottom-sheet drawer; results render as
   compact one-tap rows instead of full attribute cards. */
@media (max-width: 720px) {
  .browse-mobile-toolbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    gap: 8px;
    margin: 0 -14px 12px;
    padding: 10px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  .browse-layout {
    gap: 0;
  }

  /* Filters panel becomes a bottom-sheet drawer. Hidden by default;
     a `.is-open` class on the <aside> reveals it. */
  .browse-filters {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: auto;
    max-height: 80vh;
    margin: 0;
    padding: 16px 16px 0;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.18);
    transform: translateY(100%);
    transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
    animation: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .browse-filters.is-open {
    transform: translateY(0);
  }

  .browse-filters-tabs {
    position: relative;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
  }

  .browse-drawer-close {
    display: inline-flex;
    position: absolute;
    right: -4px;
    top: -6px;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
  }

  .browse-drawer-close:hover {
    color: var(--text);
    background: var(--accent-soft);
  }

  .browse-filters-body,
  .browse-sort-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
  }

  .browse-drawer-footer {
    display: flex;
    gap: 10px;
    padding: 12px 0 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  .browse-drawer-clear,
  .browse-drawer-apply {
    flex: 1 1 0;
    padding: 12px 14px;
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: filter 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  }

  .browse-drawer-clear {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
  }

  .browse-drawer-clear:hover {
    border-color: var(--text);
  }

  .browse-drawer-apply {
    background: var(--text);
    border: 1px solid var(--text);
    color: var(--surface);
  }

  .browse-drawer-apply:hover {
    filter: brightness(1.1);
  }

  .browse-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 15, 14, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }

  .browse-drawer-backdrop.is-open {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  /* Compact PCPP-style result rows: single column, horizontal layout,
     name + chip strip + add button. The full dl is hidden and replaced
     by a chip row built from the same data. */
  .browse-results .card-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0;
  }

  .browse-results .browse-card {
    padding: 12px 48px 12px 14px;
    border-radius: 10px;
  }

  .browse-results .browse-card h3 {
    margin: 0 0 6px;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.25;
  }

  /* Replace the stacked dl with a flat chip strip on mobile. */
  .browse-results .browse-card dl {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 11.5px;
  }

  .browse-results .browse-card dt {
    display: none;
  }

  .browse-results .browse-card dd {
    margin: 0;
    padding: 2px 8px;
    background: var(--accent-soft);
    color: var(--text);
    border-radius: 999px;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .browse-add {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .browse-results-status {
    font-size: 12px;
    margin-bottom: 6px;
  }

  /* Detail overlay tweaks (unchanged from before) */
  .browse-detail-overlay {
    padding: 12px;
  }

  .browse-detail-panel {
    width: 100%;
    height: calc(100vh - 24px);
    max-height: none;
    border-radius: 12px;
  }

  .browse-detail-header {
    padding: 14px 16px;
    gap: 10px;
  }

  .browse-detail-title-wrap {
    flex-wrap: wrap;
    gap: 4px 10px;
  }

  .browse-detail-title {
    font-size: 16px;
  }

  .browse-detail-body {
    grid-template-columns: 1fr;
  }

  .browse-detail-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
    gap: 14px;
  }

  .browse-detail-main {
    padding: 16px;
    gap: 18px;
  }

  .detail-bench-row {
    grid-template-columns: 80px 1fr 40px;
    gap: 8px;
    font-size: 12.5px;
  }

  /* Lock scroll on body while drawer is open. */
  body.browse-drawer-open {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .browse-filters {
    animation: none;
  }
}

/* ── Pagination ─────────────────────────────────────────────────── */
.browse-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 32px 0 16px;
}

.browse-pagination[hidden] { display: none; }

.browse-pagination-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  min-width: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.browse-pagination-btn:hover:not(:disabled):not(.is-active) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.browse-pagination-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.browse-pagination-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}

.browse-pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.browse-pagination-dots {
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
  user-select: none;
}
