:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-card: #1b222c;
  --bg-card-hover: #222b37;
  --border: #2a3340;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  /* Single global accent for all brands. Trying yellow (fallback: BMW blue #1c69d4). */
  --accent: #f5c518;
  --accent-soft: rgba(245, 197, 24, 0.16);
  --accent-glow: rgba(245, 197, 24, 0.28);
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: radial-gradient(1200px 600px at 50% -200px, #1a2536 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: rgba(14, 17, 22, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark { color: var(--accent); margin-right: 2px; }
.brand-accent { color: var(--accent); }
.brand-sub { color: var(--text-dim); font-weight: 600; }

.search-wrap { flex: 1; display: flex; justify-content: flex-end; }
#search {
  width: 100%;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
#search::placeholder { color: var(--text-dim); }

/* Breadcrumb */
.breadcrumb {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 0;
  font-size: 14px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* Main */
.app {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

.page-title { margin: 6px 0 4px; font-size: 26px; letter-spacing: -0.4px; }
.page-sub { margin: 0 0 22px; color: var(--text-dim); font-size: 15px; max-width: 70ch; }

/* Grid of cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.14s ease, background 0.14s, border-color 0.14s;
}
.card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: #3a4757;
}

.card-media {
  aspect-ratio: 16 / 10;
  background: #0b0e13;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: contain; display: block; }

.card-body { padding: 13px 15px 16px; }
.card-title { font-size: 16px; font-weight: 650; margin: 0 0 3px; }
.card-meta { font-size: 13px; color: var(--text-dim); }
.card-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
  margin-top: 8px;
}

/* Brand card logo variant */
.brand-card .card-media { background: #fff; padding: 26px; }
.brand-card .card-media img { object-fit: contain; }

/* Detail page */
.detail {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
  align-items: start;
}
.detail-media {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b0e13;
  aspect-ratio: 16 / 10;
  display: flex; align-items: center; justify-content: center;
}
.detail-media img { width: 100%; height: 100%; object-fit: contain; }

.spec-list { list-style: none; margin: 18px 0 0; padding: 0; }
.spec-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.spec-list .k { color: var(--text-dim); }
.spec-list .v { font-weight: 600; text-align: right; }

.years-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  margin-top: 10px;
}

/* Facelift comparison strip */
.facelift-hint { margin: -6px 0 14px; color: var(--text-dim); font-size: 13.5px; }
.facelift-strip {
  display: flex;
  gap: 14px;
  align-items: stretch;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.facelift-card {
  margin: 0;
  flex: 1 1 0;
  min-width: 260px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  display: flex;
  flex-direction: column;
  transition: border-color 0.14s, transform 0.14s;
}
.facelift-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.facelift-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #0b0e13;
  display: flex; align-items: center; justify-content: center;
}
.facelift-media img { width: 100%; height: 100%; object-fit: contain; }
.facelift-tag {
  position: absolute; top: 10px; left: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase;
  background: rgba(0,0,0,0.62); color: #fff;
  border-radius: 999px; padding: 3px 10px;
  backdrop-filter: blur(4px);
}
.facelift-card figcaption { padding: 13px 15px 16px; }
.facelift-name { font-size: 16px; font-weight: 650; }
.facelift-years { font-size: 13px; color: var(--accent); font-weight: 600; margin: 2px 0 7px; }
.facelift-changes { font-size: 13.5px; color: var(--text-dim); line-height: 1.45; }
.facelift-arrow {
  align-self: center;
  color: var(--text-dim);
  font-size: 26px;
  flex: 0 0 auto;
  opacity: 0.6;
}

/* Photo carousel */
.carousel { position: absolute; inset: 0; overflow: hidden; }
.car-track { display: flex; height: 100%; width: 100%; transition: transform 0.28s ease; }
.slide { flex: 0 0 100%; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.slide img { width: 100%; height: 100%; object-fit: contain; }
.car-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(10, 13, 18, 0.72); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s, background 0.15s;
  backdrop-filter: blur(3px); z-index: 3;
}
.car-prev { left: 8px; }
.car-next { right: 8px; }
.tl-media:hover .car-btn, .detail-media:hover .car-btn, .carousel:hover .car-btn { opacity: 1; }
.car-btn:hover { background: var(--accent); border-color: var(--accent); }
.car-count {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  font-size: 11px; font-weight: 600; color: #fff;
  background: rgba(10, 13, 18, 0.7); border-radius: 999px; padding: 2px 8px;
  backdrop-filter: blur(3px);
}
.car-dots {
  position: absolute; bottom: 8px; left: 0; right: 0; z-index: 3;
  display: flex; gap: 6px; justify-content: center;
}
.car-dot {
  width: 7px; height: 7px; border-radius: 50%; padding: 0; cursor: pointer;
  border: none; background: rgba(255, 255, 255, 0.4);
  transition: background 0.15s, transform 0.15s;
}
.car-dot.active { background: #fff; transform: scale(1.3); }
/* touch devices: keep arrows visible since there's no hover */
@media (hover: none) {
  .car-btn { opacity: 0.9; }
}

/* Evolution timeline (vertical, left rail, grouped by generation) */
.timeline { position: relative; margin-top: 10px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 84px; top: 10px; bottom: 10px;
  width: 2px;
  background: linear-gradient(var(--border), var(--border));
}

/* Generation group */
.tl-gen { position: relative; }
.tl-gen + .tl-gen { margin-top: 60px; }
.tl-gen-head {
  position: relative;
  padding-left: 116px;
  min-height: 30px;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px;
  margin-bottom: 14px;
}
.tl-gen-node {
  position: absolute; left: 75px; top: 1px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent);
  border: 4px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
  z-index: 2;
}
.tl-gen-name { font-size: 23px; font-weight: 800; letter-spacing: -0.4px; }
.tl-gen-range { color: var(--text-dim); font-weight: 600; font-size: 14px; }
.tl-gen-count {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 2px 9px;
}
.tl-gen-phases { display: flex; flex-direction: column; gap: 14px; }

/* A phase row inside a generation */
.tl-phase { position: relative; padding-left: 116px; }
.tl-year { position: absolute; left: 0; top: 4px; width: 66px; text-align: right; font-weight: 800; font-size: 14px; color: var(--text-dim); }
.tl-dot {
  position: absolute; left: 79px; top: 6px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}
.tl-dot--fl { background: var(--bg); border: 3px solid var(--accent); }
.tl-card {
  display: flex; gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.14s, transform 0.14s;
}
.tl-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tl-media {
  position: relative;
  flex: 0 0 300px; width: 300px;
  aspect-ratio: 16 / 10;
  background: #0b0e13;
  display: flex; align-items: center; justify-content: center;
}
.tl-media img { width: 100%; height: 100%; object-fit: contain; }
.tl-tag {
  position: absolute; top: 10px; left: 10px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  background: rgba(0,0,0,0.62); color: #fff;
  border-radius: 999px; padding: 3px 10px; backdrop-filter: blur(4px);
}
.tl-body { padding: 15px 18px; }
.tl-head { font-size: 18px; font-weight: 700; }
.tl-years { color: var(--accent); font-weight: 600; font-size: 13.5px; margin: 6px 0 9px; }
.tl-note { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 0 0 12px; }
.tl-link { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 13.5px; }
.tl-link:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .timeline::before { left: 8px; }
  .tl-gen-head { padding-left: 34px; }
  .tl-gen-node { left: 0; width: 16px; height: 16px; }
  .tl-phase { padding-left: 34px; }
  .tl-year { position: static; display: inline-block; width: auto; text-align: left; margin-bottom: 4px; }
  .tl-dot { left: 2px; }
  .tl-card { flex-direction: column; }
  .tl-media { width: 100%; flex: none; }
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(6, 8, 11, 0.9);
  backdrop-filter: blur(6px);
  padding: 30px;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lb-inner { margin: 0; max-width: 1100px; max-height: 90vh; display: flex; flex-direction: column; gap: 12px; }
.lb-inner img {
  max-width: 100%; max-height: 82vh; object-fit: contain;
  border-radius: 10px; background: #0b0e13;
}
.lb-inner figcaption { text-align: center; color: var(--text); font-size: 15px; font-weight: 600; }
.lb-close {
  position: absolute; top: 18px; right: 22px;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(22,27,34,0.85); color: var(--text);
  font-size: 18px; cursor: pointer;
}
.lb-close:hover { border-color: var(--accent); }

@media (max-width: 720px) {
  .facelift-arrow { display: none; }
  .facelift-card { min-width: 78%; }
}

.card-years { color: var(--accent); font-weight: 600; }

.cat-count {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 1px 8px; margin-left: 4px;
  vertical-align: middle;
}

/* Section heading */
.section-head {
  margin: 34px 0 14px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}

/* Category heading (brand page) — prominent, well-separated blocks */
.section-head.cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 60px 0 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 22px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: -0.2px;
  color: var(--text);
}
/* First category sits closer to the page subtitle */
.section-head.cat-head:first-of-type {
  margin-top: 28px;
}
.section-head.cat-head::before {
  content: "";
  flex: 0 0 auto;
  width: 4px;
  height: 22px;
  border-radius: 2px;
  background: var(--accent);
}
.section-head.cat-head .cat-count {
  font-size: 12px;
  padding: 2px 9px;
}

/* Empty / not found */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.empty h2 { color: var(--text); margin-bottom: 8px; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 22px;
  color: var(--text-dim);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(245, 197, 24, 0.35);
}
.site-footer a:hover { border-bottom-color: var(--accent); }

/* Placeholder image (when no photo) */
.ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1c2634, #12181f);
  color: #4d5b6b;
  font-size: 13px;
  text-align: center;
  padding: 12px;
  flex-direction: column;
  gap: 6px;
}
.ph svg { width: 46px; height: 46px; opacity: 0.6; }

/* "Photo needed" marker — a known gap, styled distinctly from a broken image */
.ph--needed {
  background: repeating-linear-gradient(45deg, #171d26, #171d26 10px, #141a22 10px, #141a22 20px);
  border: 1.5px dashed #3b4a5c;
  color: #d9a441;
  gap: 3px;
}
.ph--needed svg { opacity: 0.85; width: 34px; height: 34px; }
.ph--needed .ph-main { font-weight: 700; font-size: 13px; color: #e0b055; }
.ph--needed .ph-sub { font-size: 11px; color: #7d8b9a; }

@media (max-width: 720px) {
  .detail { grid-template-columns: 1fr; }
  .site-header { gap: 12px; padding: 12px 16px; }
  .app, .breadcrumb { padding-left: 16px; padding-right: 16px; }
}

/* ---------- photo attribution ---------- */
.slide { position: relative; }
.credit-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  background: rgba(14, 17, 22, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.18s ease, background 0.18s ease;
  backdrop-filter: blur(3px);
}
.slide:hover .credit-badge,
.detail-media:hover .credit-badge,
.carousel:hover .credit-badge { opacity: 0.85; }
.credit-badge:hover { opacity: 1; background: var(--accent); color: #000; border-color: var(--accent); }

/* ---------- credits page ---------- */
.credits-page { max-width: 900px; }
.credits-intro { color: var(--text-dim); font-size: 15px; line-height: 1.6; max-width: 75ch; margin: 4px 0 18px; }
.credits-intro a { color: var(--accent); }
.lic-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.lic-chip {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px;
}
.credits-count { color: var(--text-dim); font-size: 13px; margin: 0 0 10px; }
.credit-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.credit-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr auto;
  gap: 14px;
  align-items: baseline;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.cr-title { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-title:hover { color: var(--accent); text-decoration: underline; }
.cr-author { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-lic { color: var(--text-dim); text-align: right; white-space: nowrap; }
.cr-lic a { color: var(--accent); text-decoration: none; }
.cr-lic a:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .credit-row { grid-template-columns: 1fr auto; }
  .cr-author { grid-column: 1; color: var(--text-dim); font-size: 12px; }
  .cr-lic { grid-column: 2; }
}
