:root {
  --bg: #ffffff;
  --surface: #f6f7f8;
  --text: #16191d;
  --muted: #5f6b76;
  --border: #e1e5e9;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f4f2;
  --warn-bg: #fff7e0;
  --warn-ink: #6b4e00;
  --radius: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --surface: #1a1e21;
    --text: #e8ebee;
    --muted: #9aa5af;
    --border: #2b3136;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --accent-soft: #123532;
    --warn-bg: #3a2f10;
    --warn-ink: #f5d78a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 1.5rem 0 .75rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header / footer */
.site-header { border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.site-header nav { display: flex; gap: 1.25rem; }
.site-header nav a { color: var(--text); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }
.demo-banner { background: var(--warn-bg); color: var(--warn-ink); text-align: center; padding: .4rem 16px; font-size: .9rem; }
.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; padding: 1.5rem 0; color: var(--muted); font-size: .85rem; }
.site-footer a { color: var(--muted); }

/* Language and currency */
.site-header nav { align-items: center; }
.prefs { position: relative; }
.prefs summary { list-style: none; cursor: pointer; padding: .2rem .55rem; border: 1px solid var(--border); border-radius: 999px; font-size: .85rem; white-space: nowrap; }
.prefs summary::-webkit-details-marker { display: none; }
.prefs[open] summary { border-color: var(--accent); }
.prefs-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 15rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.prefs-panel fieldset { border: 0; padding: 0; margin: 0 0 .6rem; }
.prefs-panel legend { font-weight: 600; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.prefs-panel label { display: flex; gap: .45rem; align-items: center; padding: .15rem 0; font-size: .9rem; cursor: pointer; }
.prefs-panel button { width: 100%; padding: .45rem; }
.js .prefs-panel button { display: none; }

/* Home */
.hero { max-width: 720px; margin: 3rem auto 2rem; text-align: center; }
.hero h1 { font-size: 2.1rem; }
.lede { color: var(--muted); font-size: 1.1rem; margin: 0 0 1.5rem; }
.alt { margin: 1rem 0 .5rem; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.chips a { display: inline-block; padding: .3rem .75rem; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--text); font-size: .9rem; }
.chips a:hover { border-color: var(--accent); color: var(--accent); }
.browse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.5rem; }
.browse ul { list-style: none; padding: 0; margin: 0; font-size: .95rem; }
.browse li { padding: .15rem 0; }

/* Device search + autocomplete */
.device-search { display: flex; gap: .5rem; max-width: 640px; margin: 0 auto; }
.combo { position: relative; flex: 1; }
input, button { font: inherit; color: inherit; }
input[type=search], input[type=number] {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, .btn {
  padding: .65rem 1rem; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; display: inline-block;
}
.btn { padding: .35rem .7rem; font-size: .9rem; }
#device-suggestions {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .25rem 0; list-style: none;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .12); text-align: left;
}
#device-suggestions li { padding: .5rem .8rem; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
#device-suggestions li[aria-selected=true], #device-suggestions li:hover { background: var(--accent-soft); }
#device-suggestions .type { color: var(--muted); font-size: .85rem; }
.result-list { padding-left: 1.2rem; }

/* Device page */
.crumbs { margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.note { background: var(--surface); border-left: 3px solid var(--accent); padding: .6rem .9rem; border-radius: 0 var(--radius) var(--radius) 0; }
.slot-summary { padding-left: 1.2rem; }
.slot h2 .muted { font-size: .95rem; display: block; margin-top: .15rem; }
.more { font-weight: 600; }
.tag { display: inline-block; font-size: .75rem; padding: 0 .4rem; border-radius: 4px; background: var(--warn-bg); color: var(--warn-ink); }

/* Spec search */
.search-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2rem; align-items: start; }
.filters details > summary { font-weight: 600; cursor: pointer; margin-bottom: .5rem; }
.filters fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; }
.filters legend { font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.filters label { display: flex; align-items: center; gap: .4rem; font-size: .9rem; padding: .1rem 0; cursor: pointer; }
.filters .count { margin-left: auto; color: var(--muted); font-size: .8rem; }
.filters .range { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.filters .range legend { width: 100%; }
.filters .range input { width: 6rem; padding: .4rem .5rem; }
.filter-actions { display: flex; align-items: center; gap: 1rem; }
.js .filters .apply { display: none; }
.results-bar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .9rem; color: var(--muted); margin-bottom: .5rem; }
.results-bar strong { color: var(--text); }
#results.loading { opacity: .5; transition: opacity .15s; }
.pager { display: flex; justify-content: center; gap: 1.5rem; margin: 1.5rem 0; }

/* Offer table */
table.offers { width: 100%; border-collapse: collapse; font-size: .9rem; }
.offers th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 2px solid var(--border); padding: .5rem; }
.offers td { border-bottom: 1px solid var(--border); padding: .55rem .5rem; vertical-align: middle; }
.offers tbody tr:hover { background: var(--surface); }
.offers .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.offers .ppu { font-weight: 700; }
.offers .title { min-width: 14rem; }
.offers .spec { display: block; font-size: .8rem; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.cond { font-size: .8rem; padding: .05rem .4rem; border-radius: 4px; background: var(--surface); }
.cond-new { background: var(--accent-soft); }
.prose { max-width: 680px; }
.narrow { max-width: 480px; }
.flash { list-style: none; padding: 0; margin: 1rem 0 0; }
.flash li { padding: .6rem .9rem; border-radius: var(--radius); background: var(--surface); border-left: 3px solid var(--accent); }
.flash .flash-error { border-left-color: #d03b3b; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.check, .stack-form label.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: normal; }
.check input { margin-top: .25rem; }
.stack-form label { display: block; margin-bottom: .9rem; font-weight: 600; }
.stack-form input[type=email], .stack-form input[type=number] { display: block; width: 100%; margin-top: .3rem; padding: .6rem .8rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.stack-form .errorlist { color: #d03b3b; margin: -.6rem 0 .8rem; padding-left: 1rem; font-size: .9rem; }
.newsletter { max-width: 520px; margin-bottom: 1.5rem; }
.newsletter > label { display: block; margin-bottom: .4rem; color: var(--text); }
.newsletter-row { display: flex; gap: .5rem; margin-bottom: .4rem; }
.newsletter-row input { flex: 1; min-width: 0; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.newsletter-row button { padding: .5rem .9rem; }
.buy .alert-link { display: block; font-size: .75rem; color: var(--muted); text-align: center; margin-top: .25rem; }

@media (max-width: 800px) {
  .search-layout { grid-template-columns: 1fr; gap: 1rem; }
  .filters details:not([open]) { margin-bottom: 0; }
  .hero { margin-top: 2rem; }
  .hero h1 { font-size: 1.6rem; }
  .device-search { flex-direction: column; }
  /* Table collapses into cards */
  .offers thead { display: none; }
  .offers, .offers tbody, .offers tr, .offers td { display: block; width: 100%; }
  .offers tr { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .75rem; }
  .offers td { border: 0; padding: .15rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .offers td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
  .offers tr { display: flex; flex-direction: column; }
  .offers td.title { order: -1; min-width: 0; text-align: left; padding-bottom: .3rem; display: block; }
  .offers td.title .name { font-weight: 600; }
  .offers td.title::before { content: none; }
  .offers td.buy { justify-content: flex-end; padding-top: .4rem; }
  .offers td.buy::before { content: none; }
}
