:root {
  --orange: #ff7a00;
  --orange-dark: #e06b00;
  --orange-soft: #fff1e0;
  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --ink-4: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f1f3f5;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #0ea5e9;
  --accent-dark: #0369a1;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 8px 24px rgba(17, 24, 39, 0.08), 0 2px 6px rgba(17, 24, 39, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* Defensive defaults so a partial CSS load still produces something sane. */
svg { width: 1em; height: 1em; vertical-align: middle; flex-shrink: 0; }
img { max-width: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

a { color: inherit; }
button { font-family: inherit; }

/* ===================================================================
   Topbar
   =================================================================== */
.topbar {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  color: #fff;
  border-bottom: 3px solid var(--orange);
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand {
  display: flex; align-items: center; gap: 14px;
  color: #fff; text-decoration: none;
}
.brand-mark {
  width: 44px; height: 44px;
  background: var(--orange);
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(255, 122, 0, 0.35);
  flex-shrink: 0;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-title {
  font-size: 17px; font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 1px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* back link becomes a pill button */
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff; text-decoration: none;
  padding: 8px 14px 8px 12px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.back-link:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}
.back-link:active { transform: translateY(1px); }
.back-link svg { width: 16px; height: 16px; }

/* region picker */
.region-picker {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 8px 6px 12px;
  border-radius: 8px;
  transition: border-color 0.15s;
}
.region-picker:hover { border-color: rgba(255, 255, 255, 0.22); }
.region-picker .region-icon {
  width: 16px; height: 16px; color: rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
}
.region-picker select {
  background: transparent;
  color: #fff;
  border: none;
  padding: 2px 22px 2px 0;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%23ffffff" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath d="M6 9l6 6 6-6"/%3E%3C/svg%3E');
  background-repeat: no-repeat;
  background-position: right 2px center;
}
.region-picker select:focus { outline: none; }
.region-picker select option { background: var(--ink); color: #fff; }

/* ===================================================================
   Main / footer
   =================================================================== */
main {
  max-width: 1400px; width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}
.sitefoot {
  padding: 24px; text-align: center;
  font-size: 12px; color: var(--ink-4);
  border-top: 1px solid var(--line);
  background: var(--card);
}

/* ===================================================================
   Filters
   =================================================================== */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px;
  background: var(--card);
  padding: 12px; border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  border: 1px solid var(--line);
}
.filter-search {
  position: relative; flex: 1 1 260px; min-width: 200px;
}
.filter-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-4); pointer-events: none;
}
.filter-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--card); color: var(--ink);
  font-family: inherit;
}
.filter-search input:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.15);
}

.filters select, .filters button {
  padding: 10px 32px 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--card); color: var(--ink);
  font-family: inherit;
  appearance: none; -webkit-appearance: none;
  background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%239ca3af" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath d="M6 9l6 6 6-6"/%3E%3C/svg%3E');
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 140px;
}
.filters select:hover { border-color: var(--ink-4); }
.filters select:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.15);
}
.filters button#clearBtn {
  cursor: pointer; background-image: none; padding: 10px 16px;
  min-width: auto; color: var(--ink-3); font-weight: 500;
}
.filters button#clearBtn:hover { background: var(--line-soft); color: var(--ink); }

.results-meta {
  color: var(--ink-3); font-size: 13px;
  margin-bottom: 14px; padding: 0 4px;
  font-weight: 500;
}

/* ===================================================================
   Card grid
   =================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: #d1d5db;
}
.card-thumb {
  aspect-ratio: 16 / 10;
  width: 100%;
  background: linear-gradient(135deg, #f1f3f5 0%, #e9ecef 100%);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb.is-placeholder { background: linear-gradient(135deg, #f1f3f5, #e9ecef); }
.card-thumb.is-placeholder img {
  object-fit: contain; padding: 28px; opacity: 0.6;
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-make {
  font-size: 11px; color: var(--ink-4);
  letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;
}
.card-years {
  font-size: 12px; color: var(--accent);
  font-weight: 600; white-space: nowrap;
  background: #f0f9ff; padding: 2px 8px; border-radius: 10px;
}
.card-model {
  font-size: 18px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em; line-height: 1.3;
  margin: 2px 0 4px;
}
.card-meta { font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.card-meta > div { display: flex; gap: 4px; flex-wrap: wrap; }
.card-meta b {
  color: var(--ink-4); font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
  min-width: 60px;
}
.card-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 6px; }

/* ===================================================================
   Chips
   =================================================================== */
.chip {
  background: #eef2f7; color: #3a5a80;
  font-size: 11px; padding: 3px 9px; border-radius: 12px;
  display: inline-block;
  font-weight: 500;
  border: 1px solid transparent;
}
.chip.key {
  background: var(--orange-soft); color: var(--orange-dark);
  border-color: #ffe0c2; font-weight: 600;
}

/* ===================================================================
   Pager
   =================================================================== */
.pager { margin-top: 24px; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.pager button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.pager button:hover:not([disabled]) { background: var(--line-soft); border-color: var(--ink-4); }
.pager button[disabled] { opacity: 0.35; cursor: default; }
.pager .current {
  background: var(--orange); color: #fff;
  border-color: var(--orange);
  box-shadow: 0 1px 4px rgba(255, 122, 0, 0.35);
}
.pager .current:hover { background: var(--orange); border-color: var(--orange); }

/* ===================================================================
   Detail view
   =================================================================== */
.detail-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.detail-head {
  display: flex; gap: 28px; align-items: flex-start;
  padding: 28px;
  background: linear-gradient(135deg, #fafbfc 0%, #f4f6f9 100%);
  border-bottom: 1px solid var(--line);
}
.detail-hero {
  flex: 0 0 320px; aspect-ratio: 16/10;
  background: var(--card);
  border-radius: var(--radius-sm); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-hero.is-placeholder {
  background: linear-gradient(135deg, #f1f3f5 0%, #e9ecef 100%);
}
.detail-hero.is-placeholder img { object-fit: contain; padding: 32px; opacity: 0.6; }

.detail-title-block { flex: 1; min-width: 0; }
.detail-title .make {
  font-size: 12px; color: var(--ink-4);
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700;
  margin-bottom: 4px;
}
.detail-title .model {
  font-size: 32px; font-weight: 700; line-height: 1.15;
  letter-spacing: -0.02em; color: var(--ink);
}
.detail-title .code {
  font-size: 15px; color: var(--ink-3); margin-top: 6px;
  font-weight: 500;
}
.detail-years {
  display: inline-block; margin-top: 12px;
  background: #f0f9ff; color: var(--accent-dark);
  font-size: 15px; font-weight: 600;
  padding: 4px 12px; border-radius: 14px;
  border: 1px solid #bae6fd;
}
.detail-tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.detail-tags .chip { font-size: 12px; padding: 4px 10px; }
.detail-score {
  margin-top: 14px; background: #fff7ed; color: var(--orange-dark);
  border: 1px solid #ffd9a8; border-radius: var(--radius-sm);
  padding: 8px 14px; display: inline-block; font-size: 13px;
  font-weight: 500;
}
.detail-score b { font-size: 17px; font-weight: 700; }

/* ===================================================================
   Tabs
   =================================================================== */
.tabs-wrap {
  border-bottom: 1px solid var(--line);
  background: var(--card);
  padding: 0 28px;
  position: sticky; top: 73px; z-index: 5;
}
.tabs {
  display: flex; flex-wrap: wrap; gap: 2px;
}
.tab {
  background: transparent; border: none; cursor: pointer;
  padding: 14px 18px; font-size: 14px; font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  position: relative;
  top: 1px;
  font-family: inherit;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
  font-weight: 600;
}

.tab-content { padding: 28px; }

/* ===================================================================
   KV grid + sections
   =================================================================== */
.detail-section { margin-bottom: 28px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section h3 {
  margin: 0 0 14px; font-size: 11px; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 28px;
}
.kv-grid > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kv-label {
  font-size: 11px; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.kv-value {
  font-size: 14px; color: var(--ink); font-weight: 500;
  word-break: break-word;
}
.muted { color: var(--ink-4); }

.long-text {
  white-space: pre-wrap; font-family: inherit;
  background: #fafbfc; padding: 16px 18px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--orange);
  font-size: 14px; line-height: 1.65; color: var(--ink-2);
  margin: 0;
}

/* ===================================================================
   Images panel
   =================================================================== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.image-tile {
  margin: 0; background: var(--card);
  border-radius: var(--radius-sm); overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  transition: transform 0.15s, box-shadow 0.15s;
}
.image-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.image-tile a { display: block; background: #f1f3f5; }
.image-tile img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  display: block;
}
.image-tile figcaption {
  padding: 10px 12px; font-size: 12px; color: var(--ink-2);
  border-top: 1px solid var(--line); font-weight: 500;
}

/* ===================================================================
   Videos panel — proper poster cards
   =================================================================== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.video-note {
  background: #fff7ed; border: 1px solid #ffd9a8; color: #9a3412;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin: 0 0 18px; font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
}
.video-note svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; color: var(--orange); }
.video-note strong { font-weight: 600; }

.video-card {
  background: var(--card);
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line);
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none; color: inherit; display: block;
}
.video-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--orange); }
.video-poster {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  position: relative;
  display: grid; place-items: center;
  overflow: hidden;
}
.video-poster::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 30% 40%, rgba(255, 122, 0, 0.15), transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(14, 165, 233, 0.12), transparent 45%);
}
.video-play {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255, 122, 0, 0.95); color: #fff;
  display: grid; place-items: center;
  z-index: 1;
  box-shadow: 0 4px 20px rgba(255, 122, 0, 0.4);
  transition: transform 0.15s, background 0.15s;
}
.video-card:hover .video-play {
  transform: scale(1.1);
  background: var(--orange);
}
.video-play svg { width: 26px; height: 26px; margin-left: 3px; }
.video-filename {
  position: absolute; bottom: 10px; left: 12px; right: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; color: rgba(255, 255, 255, 0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.video-body {
  padding: 14px 16px;
}
.video-name { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.video-cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; font-size: 13px; color: var(--orange);
  font-weight: 600;
}
.video-cta svg { width: 14px; height: 14px; }

/* ===================================================================
   Summary scores
   =================================================================== */
.summary-list { list-style: none; padding: 0; margin: 0; }
.summary-list li {
  display: grid; grid-template-columns: 120px 1fr auto;
  gap: 18px; align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.summary-list li:last-child { border-bottom: none; }
.summary-value {
  font-weight: 600; color: var(--ink); font-size: 14px;
}
.summary-desc { font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.summary-score {
  background: var(--orange); color: #fff; font-weight: 700;
  padding: 3px 11px; border-radius: 12px; font-size: 13px;
  min-width: 34px; text-align: center;
}

/* ===================================================================
   Empty state
   =================================================================== */
.empty {
  background: var(--card); padding: 60px 40px;
  border-radius: var(--radius); text-align: center;
  color: var(--ink-4); border: 1px dashed var(--line);
}

/* ===================================================================
   Responsive
   =================================================================== */
@media (max-width: 720px) {
  .topbar-inner { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .brand-title { font-size: 15px; }
  .brand-sub { display: none; }
  .back-link span { display: none; }
  .back-link { padding: 8px; }
  main { padding: 16px; }
  .detail-head { flex-direction: column; padding: 20px; gap: 18px; }
  .detail-hero { flex-basis: auto; width: 100%; }
  .detail-title .model { font-size: 24px; }
  .tabs-wrap { padding: 0 16px; position: static; }
  .tab-content { padding: 20px; }
  .summary-list li { grid-template-columns: 100px 1fr; grid-row-gap: 6px; }
  .summary-list .summary-score { grid-column: 2; justify-self: start; }
}
