/* ============================================================
   Mac Performance Atlas — design system v2 "Midnight Benchmark"
   Dark graphite theme is the default; light theme uses the
   Product Gallery palette (white / #f5f5f7 / #0071e3).
   Layout & character are identical across themes.
   ============================================================ */

:root,
html.dark {
  --bg: #141210;
  --band: #181512;
  --surface: #1c1917;
  --raised: #211d1a;
  --fg: #f5f5f4;
  --muted: #a8a29e;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #34d399;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --accent-contrast: #0c1210;
  --cpu: #60a5fa;
  --gpu: #34d399;
  --cpu-soft: rgba(96, 165, 250, 0.14);
  --gpu-soft: rgba(52, 211, 153, 0.14);
  --track: rgba(255, 255, 255, 0.08);
  --win: rgba(52, 211, 153, 0.1);
  --win-line: #34d399;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --radius-lg: 20px;
  --device-filter: invert(0.88) brightness(1.08);
  color-scheme: dark;
}

html.light {
  --bg: #ffffff;
  --band: #f5f5f7;
  --surface: #ffffff;
  --raised: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.16);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --accent-contrast: #ffffff;
  --cpu: #0071e3;
  --gpu: #059669;
  --cpu-soft: rgba(0, 113, 227, 0.12);
  --gpu-soft: rgba(5, 150, 105, 0.12);
  --track: rgba(0, 0, 0, 0.07);
  --win: rgba(5, 150, 105, 0.1);
  --win-line: #059669;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.06), 0 14px 34px rgba(0, 0, 0, 0.1);
  --device-filter: none;
  color-scheme: light;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.35s ease, color 0.35s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 750;
  margin: 0 0 0.4rem;
}

h2 {
  font-size: 1.4rem;
  letter-spacing: -0.015em;
  font-weight: 700;
  margin: 2.6rem 0 1rem;
}

h3 { font-size: 1.05rem; margin: 0 0 0.5rem; }

code {
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
}

.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); border: 0;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 24px 5rem;
}

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

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  height: 58px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--fg);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.header-search { position: relative; flex: 1; max-width: 340px; }
.header-search input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--band);
  color: var(--fg);
  border-radius: 99px;
  padding: 7px 16px;
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.2s, background 0.2s;
}
.header-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  max-height: 380px;
  overflow-y: auto;
  z-index: 60;
}
.search-dropdown a {
  display: block;
  padding: 9px 14px;
  color: var(--fg);
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}
.search-dropdown a:last-child { border-bottom: 0; }
.search-dropdown a:hover,
.search-dropdown a.active { background: var(--accent-soft); text-decoration: none; }
.search-dropdown .muted { display: block; font-size: 12px; }

.site-header nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.site-header nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 13px;
  border-radius: 99px;
  transition: background 0.2s, color 0.2s;
}
.site-header nav a:hover { color: var(--fg); text-decoration: none; }
.site-header nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: 99px;
  padding: 7px 14px;
  font: 600 13px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s;
}
.theme-btn:active { transform: scale(0.96); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 99px;
  cursor: pointer;
  padding: 10px 20px;
  font: 600 14px/1 inherit;
  font-family: inherit;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1.2),
    box-shadow 0.18s, background 0.2s;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn.ghost { background: transparent; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 1.4rem 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
a.card { display: flex; flex-direction: column; gap: 6px; color: var(--fg); }
a.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  text-decoration: none;
}
.card h3 {
  margin: 0 0 2px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.card .big {
  font-size: 32px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 2px 0;
}
.card .muted, .card .sub { font-size: 13px; color: var(--muted); margin: 0; }
.card p { margin: 2px 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.chip-badge {
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px;
  padding: 3px 10px;
  margin-top: 2px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 1.4rem 0;
}

/* ---------- device art ---------- */
.device-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
}
.device-thumb img {
  width: 100%;
  max-width: 150px;
  height: auto;
  filter: var(--device-filter);
  transition: filter 0.35s;
}
.device-thumb--sm img { max-width: 44px; }
.device-thumb--lg img { max-width: 420px; }

/* ---------- bars ---------- */
.track,
.bar-wrap {
  height: 7px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
  margin-top: 8px;
}
.fill,
.bar {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width 1s cubic-bezier(0.25, 0.9, 0.3, 1);
}
.fill.cpu, .bar.cpu { background: var(--cpu); }
.fill.gpu, .bar.gpu { background: var(--gpu); }
.metric-bar { height: 7px; border-radius: 99px; margin-top: 10px; }
.metric-bar.cpu { background: var(--cpu-soft); }
.metric-bar.gpu { background: var(--gpu-soft); }
.metric-bar i { display: block; height: 100%; border-radius: 99px; }
.metric-bar.cpu i { background: var(--cpu); }
.metric-bar.gpu i { background: var(--gpu); }
.metric-inline { display: flex; align-items: center; gap: 10px; }
.metric-inline .bar-wrap { flex: 1; min-width: 90px; margin: 0; }
.metric-inline .tabular { font-weight: 650; min-width: 3ch; text-align: right; }

.dualbar { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.dualbar .track, .dualbar .bar-wrap { margin: 0; height: 5px; }

/* ---------- hero (home) ---------- */
.hero-panel { margin-bottom: 2.5rem; }
.hero { padding: 2.2rem 0 0.6rem; }
.hero .lede { font-size: 17px; }
.baseline-note {
  color: var(--muted);
  font-size: 14px;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}
.lede { color: var(--muted); max-width: 640px; margin: 0.3rem 0 1.4rem; font-size: 16px; }
.meta { color: var(--muted); font-size: 13.5px; }
.page-head { margin-bottom: 0.6rem; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 1.6rem;
}

/* ---------- model page ---------- */
.model-split {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 34px;
  align-items: stretch;
}
@media (max-width: 880px) { .model-split { grid-template-columns: 1fr; } }

.model-stage {
  background: linear-gradient(160deg, var(--raised), var(--band));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 28px;
  box-shadow: var(--shadow);
}
.model-stage-cap {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); }

.chip-line {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.meta-line { color: var(--muted); font-size: 14px; margin: 0.2rem 0 0; }

.model-note {
  font-size: 13.5px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 14px;
  margin-top: 1.4rem;
}

/* finish swatches */
.swatches { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0.9rem 0 0.2rem; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 0 3px var(--bg);
  transition: transform 0.18s;
}
.swatch:hover { transform: scale(1.15); }
.swatch-label { font-size: 13px; color: var(--muted); margin-left: 2px; }

/* spec list */
.spec-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0 30px;
  margin: 0;
}
.spec-list > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.spec-list dt { color: var(--muted); }
.spec-list dd { margin: 0; font-weight: 550; text-align: right; }

/* ---------- tables ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  text-align: left;
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--accent-soft); }
tr.active-row {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.win-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--win);
  color: var(--win-line);
  font-size: 11.5px;
  font-weight: 700;
  vertical-align: 1px;
  white-space: nowrap;
}

/* ---------- compare ---------- */
.compare-form { margin: 0.4rem 0 1.6rem; }
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 1rem;
}
.config-picker {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  position: relative;
}
.config-picker-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.compare-slot-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.config-picker-control { position: relative; }
.config-picker-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--band);
  color: var(--fg);
  border-radius: 10px;
  padding: 8px 30px 8px 12px;
  font: inherit;
  font-size: 13.5px;
}
.config-picker-input:focus { outline: none; border-color: var(--accent); }
.config-picker-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}
.config-picker-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  position: absolute;
  left: 10px;
  right: 10px;
  z-index: 30;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  max-height: 260px;
  overflow-y: auto;
}
.config-picker-list li {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.config-picker-list li:last-child { border-bottom: 0; }
.config-picker-list li:hover,
.config-picker-list li.active { background: var(--accent-soft); }
.config-picker.is-enhanced .config-picker-select { display: none; }
.config-picker-select {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line-strong);
  background: var(--band);
  color: var(--fg);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
}

.export-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.6rem;
}

/* ---------- rankings ---------- */
.seg-control {
  display: inline-flex;
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px;
  margin: 0.3rem 0 1.4rem;
}
.seg-control a,
.seg-control button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 99px;
  padding: 7px 16px;
  font: 600 13px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.seg-control a:hover { color: var(--fg); text-decoration: none; }
.seg-control a.active,
.seg-control button.active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.rank-row {
  display: grid;
  grid-template-columns: 52px 1fr 92px;
  gap: 16px;
  align-items: center;
  padding: 15px 18px;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.rank-row:hover { background: var(--band); }
.rank-num {
  font-size: 22px;
  font-weight: 750;
  color: var(--muted);
  text-align: center;
  letter-spacing: -0.02em;
}
.ranking-list li:nth-child(-n + 3) .rank-num { color: var(--accent); }
.rank-body a { color: var(--fg); font-weight: 650; font-size: 15px; }
.rank-body .muted { font-size: 12.5px; margin-bottom: 2px; }
.rank-body .bar-wrap { margin-top: 8px; }
.rank-score { font-size: 20px; font-weight: 750; text-align: right; }
.crown {
  font-size: 11px;
  font-weight: 700;
  color: var(--win-line);
  background: var(--win);
  border-radius: 99px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: 2px;
}

/* ---------- filters / forms ---------- */
.filter-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0.4rem 0 1.2rem;
}
.filter-form input,
.filter-form select {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: 10px;
  padding: 9px 13px;
  font: inherit;
  font-size: 13.5px;
  min-width: 150px;
}
.filter-form input:focus,
.filter-form select:focus { outline: none; border-color: var(--accent); }
.filter-form input[type="search"] { flex: 1; max-width: 300px; }

.result-list { list-style: none; margin: 0 0 1.6rem; padding: 0; }
.result-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.result-list li:last-child { border-bottom: 0; }

/* ---------- empty state ---------- */
.empty-state {
  background: var(--band);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  margin: 1.6rem 0;
}
.empty-state p { margin: 0.3rem 0; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 22px 24px 30px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.site-footer p { margin: 0.25rem 0; }

/* ---------- animations ---------- */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- admin ---------- */
.admin-body { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 210px;
  flex: none;
  border-right: 1px solid var(--line);
  background: var(--band);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-sidebar a {
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: 10px;
}
.admin-sidebar a:hover { color: var(--fg); text-decoration: none; }
.admin-sidebar a.active { background: var(--accent-soft); color: var(--accent); }
.admin-main { flex: 1; padding: 26px 30px; min-width: 0; }
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 1.4rem;
}
.admin-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.admin-login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 30px;
}
.form-grid { display: grid; gap: 14px; }
.form-grid label { font-size: 13px; font-weight: 600; color: var(--muted); }
.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--band);
  color: var(--fg);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
}
.form-grid textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 220px; }
.flash-ok, .flash-err {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin: 0.8rem 0;
}
.flash-ok { background: var(--win); color: var(--win-line); }
.flash-err { background: rgba(220, 38, 38, 0.12); color: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .site-header { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .header-search { order: 3; max-width: none; flex-basis: 100%; }
  .container { padding: 1.4rem 16px 4rem; }
  .rank-row { grid-template-columns: 36px 1fr 64px; gap: 10px; padding: 12px 10px; }
  .rank-num { font-size: 17px; }
  .rank-score { font-size: 16px; }
  .model-split { gap: 20px; }
}
