:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1c2128;
  --muted: #5b6573;
  --border: #dfe3e8;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --good: #1a7f37;
  --good-bg: #dcfce7;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --bad: #b42318;
  --bad-bg: #fee4e2;
  --series-1: #1f6feb;
  --series-2: #d97706;
  --series-3: #7c3aed;
  --series-4: #0f766e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #161b22;
    --text: #e6edf3;
    --muted: #9aa4b2;
    --border: #2d333b;
    --accent: #4c8dff;
    --accent-text: #0b1220;
    --good: #4ade80;
    --good-bg: #12301d;
    --warn: #f2c14e;
    --warn-bg: #362a0c;
    --bad: #ff7b72;
    --bad-bg: #3b1714;
    --series-1: #6ea8ff;
    --series-2: #f5a524;
    --series-3: #b794f6;
    --series-4: #2dd4bf;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
img { max-width: 100%; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.2; margin: 1.5rem 0 1rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
/* max() keeps the 16px gutter clear of the notch in landscape. */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }
.empty { padding: 1rem 1.25rem; background: var(--surface); border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; }
.brand-text { display: grid; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 1.1rem; }
nav[aria-label="Main"] { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
nav[aria-label="Main"] a { color: var(--muted); text-decoration: none; }
@media (hover: hover) { nav[aria-label="Main"] a:hover { color: var(--text); } }
.site-footer { margin-top: 3rem; padding: 1.5rem 0 calc(2rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); font-size: 0.875rem; }
.crumbs { margin-top: 1.25rem; font-size: 0.875rem; color: var(--muted); }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 1.5rem 2.5rem; align-items: center; padding: 1.5rem 0 0.5rem; }
.hero h1 { margin-top: 0; }
.hero .lede { margin: 0; }
.picker.hero-picker { grid-template-columns: 1fr 1fr; margin: 0; padding: 1.25rem; }
.hero-picker .picker-model, .hero-picker button, .picker-hint { grid-column: 1 / -1; }
.picker-hint { margin: -0.25rem 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 1rem; }
}
.picker { display: grid; grid-template-columns: 2fr 1.4fr 1fr auto; gap: 0.75rem; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin: 1.25rem 0 0.5rem; }
.picker.inline { grid-template-columns: 1.4fr 1fr auto; max-width: 640px; }
.picker label { display: grid; gap: 0.3rem; font-size: 0.875rem; color: var(--muted); }
/* 16px stops iOS Safari zooming in when a field is tapped. */
.picker select, .picker input { width: 100%; min-height: 44px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.55rem 0.6rem; }
button { min-height: 44px; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px; padding: 0.6rem 1.1rem; cursor: pointer; }
@media (hover: hover) { button:hover, .cta:hover { filter: brightness(1.08); } .value-card:hover { border-color: var(--accent); } }
@media (max-width: 760px) {
  .picker, .picker.inline { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .picker.hero-picker { grid-template-columns: 1fr; }
}

.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 1rem; }
.listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.listing { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.listing-image { display: block; aspect-ratio: 4 / 3; background: var(--bg); }
.listing-image img { width: 100%; height: 100%; object-fit: contain; }
.listing-body { padding: 0.75rem 1rem 1rem; }
.listing h3 { margin: 0.2rem 0 0.4rem; font-size: 0.95rem; font-weight: 600; line-height: 1.35; }
.listing h3 a { color: var(--text); text-decoration: none; }
.listing h3 a:hover { text-decoration: underline; }
.listing p { margin: 0.3rem 0; }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; text-decoration: none; }
.price-line { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.price { font-size: 1.25rem; font-weight: 700; margin-right: 0.25rem; }
.tag { font-size: 0.75rem; border: 1px solid var(--border); border-radius: 999px; padding: 0.05rem 0.5rem; color: var(--muted); }
.verdict { font-size: 0.875rem; font-weight: 600; }
.verdict.good { color: var(--good); }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 0.05rem 0.55rem; vertical-align: 0.1em; white-space: nowrap; }
.badge.fits { color: var(--good); background: var(--good-bg); }
.badge.conditional { color: var(--warn); background: var(--warn-bg); }
.badge.no { color: var(--bad); background: var(--bad-bg); }
.muted-badge { color: var(--muted); border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.compact td, table.compact th { padding: 0.45rem 0.65rem; }
section > table.compact { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.warnings { margin: 0.35rem 0 0; padding-left: 1.1rem; font-size: 0.825rem; color: var(--warn); }
.rejected { margin-top: 2rem; }
.rejected summary { cursor: pointer; font-weight: 600; }
.rejected ul { font-size: 0.9rem; }
.sort a, .sort strong { margin-right: 0.75rem; }

.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 0.6rem 1.5rem; margin: 0; }
.specs div { border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.specs dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.specs dd { margin: 0.1rem 0 0; }
.notes { padding-left: 1.1rem; color: var(--muted); font-size: 0.9rem; }
.machine-specs { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; }
.two-col h2:first-child { margin-top: 0.5rem; }
@media (max-width: 860px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
.chart-box { position: relative; height: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; }
.prose { max-width: 70ch; }

.deals { margin-top: 1.5rem; }
.deals h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.live-pill { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; color: var(--good); background: var(--good-bg); border-radius: 999px; padding: 0.1rem 0.6rem; }
.live-pill .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--good); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live-pill .dot { animation: none; } }
.listing-body { display: flex; flex-direction: column; flex: 1; }
.cta { margin-top: auto; align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; background: var(--accent); color: var(--accent-text); border-radius: 8px; padding: 0.5rem 0.9rem; }
.listing .cta { margin-top: 0.75rem; }
.empty.watching p { margin: 0; }
.value-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.value-card { display: flex; flex-direction: column; gap: 0.25rem; padding: 0 1rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.value-image { display: block; margin: 0 -1rem 0.5rem; aspect-ratio: 4 / 3; background: var(--bg); }
.value-image img { width: 100%; height: 100%; object-fit: contain; }
.value-card .cta { margin-top: auto; }
.value-card .small:last-of-type { margin-bottom: 0.6rem; }
.no-image { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--muted); font-size: 0.875rem; }
.value-name { font-weight: 600; color: var(--text); text-decoration: none; }
.value-name:hover { text-decoration: underline; }
.value-price { font-size: 1.15rem; font-weight: 700; }

/* Desktop-only and phone-only bits of the stacked tables. */
.rank-prefix, .stack-only { display: none; }

@media (max-width: 640px) {
  /* Header: brand on top, nav as one swipeable row of 44px targets. */
  .header-row { flex-direction: column; align-items: stretch; gap: 0.25rem; padding-bottom: 0; }
  nav[aria-label="Main"] { flex-wrap: nowrap; gap: 0 1.25rem; overflow-x: auto; scrollbar-width: none; }
  nav[aria-label="Main"]::-webkit-scrollbar { display: none; }
  nav[aria-label="Main"] a { flex: none; display: flex; align-items: center; min-height: 44px; }

  /* Tables become one card per row: label on the left, value on the right. */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 0.15rem 0; white-space: normal; }
  table.stack td[data-label] { position: relative; padding-left: 45%; text-align: right; }
  table.stack td[data-label]::before { content: attr(data-label); position: absolute; left: 0; color: var(--muted); font-size: 0.85rem; text-align: left; }
  table.stack .stack-title { padding-bottom: 0.4rem; font-size: 1rem; }
  table.stack .rank-no, table.stack .stack-hide { display: none; }
  table.stack .rank-prefix { display: inline; color: var(--muted); font-weight: 600; margin-right: 0.25rem; }
  table.stack .stack-only { display: inline; }
  table.stack .stack-note { color: var(--muted); padding-top: 0.3rem; }
  table.stack .stack-note:empty { display: none; }

  /* Deal cards: photo on the left so more fit on screen. */
  .listing { flex-direction: row; }
  .listing-image { flex: 0 0 112px; aspect-ratio: auto; }
  .listing-body { min-width: 0; padding: 0.7rem 0.8rem 0.8rem; }
  .listing .cta { align-self: stretch; justify-content: center; }
  .price { font-size: 1.15rem; }

  /* Best value: a swipeable row instead of a tall column. */
  .value-grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 78%; overflow-x: auto;
    scroll-snap-type: x mandatory; scroll-padding: 0 16px; margin: 0 -16px; padding: 0 16px 0.5rem; scrollbar-width: none; }
  .value-grid::-webkit-scrollbar { display: none; }
  .value-card { scroll-snap-align: start; }
  .value-card .cta { align-self: stretch; justify-content: center; }

  .chart-box { height: 220px; padding: 0.5rem; }
  .machine-specs { padding: 0.9rem 1rem; }
}
