:root {
  color-scheme: light dark;

  &:has(> head > meta[name='color-scheme'][content='dark']) {
    color-scheme: dark;
  }

  &:has(> head > meta[name='color-scheme'][content='light']) {
    color-scheme: light;
  }

  --bg: light-dark(#f6f6f4, #09090b);
  --surface: light-dark(#ffffff, #111114);
  --surface-raised: light-dark(#efefe9, #18181d);
  --header-bg: light-dark(rgba(246, 246, 244, 0.88), rgba(9, 9, 11, 0.88));
  --border: light-dark(rgba(17, 17, 17, 0.1), rgba(255, 255, 255, 0.1));
  --border-strong: light-dark(rgba(17, 17, 17, 0.2), rgba(255, 255, 255, 0.2));
  --ink: light-dark(#111113, #f5f5f7);
  --ink-muted: light-dark(#52555c, #9a9ea8);
  --ink-dim: light-dark(#767a83, #666a73);
  --btn-primary-bg: light-dark(#111113, #f5f5f7);
  --btn-primary-fg: light-dark(#ffffff, #09090b);
  --btn-primary-hover: light-dark(#2a2a2e, #dcdce2);
  --signal-green: light-dark(#15803d, #22c55e);
  --signal-amber: light-dark(#b45309, #f59e0b);
  --signal-red: light-dark(#b91c1c, #ef4444);
  --mono: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-x: clip;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.container {
  width: min(1180px, calc(100% - 2.5rem));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.nav-links a {
  transition: color 0.18s ease;
}

.nav-links a:hover {
  color: var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.theme-toggle:hover {
  background: var(--surface-raised);
}

/* Branching toggle label strictly via CSS color-scheme without relying on JS classes */
.theme-toggle .label-to-dark {
  display: inline;
}
.theme-toggle .label-to-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name='color-scheme'][content='light']))
    .theme-toggle
    .label-to-dark {
    display: none;
  }
  :root:not(:has(> head > meta[name='color-scheme'][content='light']))
    .theme-toggle
    .label-to-light {
    display: inline;
  }
}

:root:has(> head > meta[name='color-scheme'][content='dark'])
  .theme-toggle
  .label-to-dark {
  display: none;
}
:root:has(> head > meta[name='color-scheme'][content='dark'])
  .theme-toggle
  .label-to-light {
  display: inline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.78rem 1.25rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-raised);
}

.btn-compact {
  padding: 0.52rem 0.95rem;
  font-size: 0.84rem;
}

@media (prefers-reduced-motion: no-preference) {
  .btn:active {
    transform: scale(0.98);
  }
}

/* Hero */
.hero {
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.22fr);
  gap: 3rem;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1.25rem;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal-green);
}

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.2rem, 4.4vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
  font-weight: 700;
}

.hero-lead {
  margin: 0 0 1.75rem;
  font-size: 1.04rem;
  color: var(--ink-muted);
  max-width: 48ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.build-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, max-content));
  gap: 1.4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.meta-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  margin-bottom: 0.2rem;
}

.meta-value {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink);
}

/* Instrument Bezel */
.bezel {
  background: #111114;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 12px;
  box-shadow: light-dark(
    0 24px 60px rgba(0, 0, 0, 0.16),
    0 32px 80px rgba(0, 0, 0, 0.65)
  );
}

.bezel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 10px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #888c96;
}

.bezel-screen {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #000;
}

.bezel-screen img {
  display: block;
  width: 100%;
  height: auto;
}

/* Section base */
.section {
  padding: 4rem 0;
  border-bottom: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.section-index {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.section h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.6vw, 2.15rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.section-note {
  margin: 0;
  max-width: 44ch;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

/* Brand Icon Rail */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.catalog-item {
  background: var(--surface);
  padding: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.catalog-item img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.catalog-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
}

.catalog-mode {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Spec Cards */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.spec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.6rem;
}

.spec-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-dim);
  margin-bottom: 0.65rem;
}

.spec-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.08rem;
  letter-spacing: -0.015em;
}

.spec-card p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* Interactive Validator Sandbox */
.validator-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.6rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.75rem;
  align-items: center;
}

.validator-form {
  display: flex;
  gap: 0.6rem;
}

.validator-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.84rem;
}

.validator-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--surface-raised);
  color: var(--ink-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
}

.chip:hover {
  color: var(--ink);
  border-color: var(--border-strong);
}

.validator-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.validator-result[data-state='allowed'] {
  border-color: var(--signal-green);
  color: var(--signal-green);
}

.validator-result[data-state='blocked'] {
  border-color: var(--signal-red);
  color: var(--signal-red);
}

/* Matrix Table (responsive-table pattern with @container stacked mobile cards) */
.table-wrap {
  overflow: auto;
  max-inline-size: 100%;
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.compat-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  text-align: left;
  --label-2: 'Android Automotive OS';
  --label-3: 'Android Auto';
  --label-4: 'Apple CarPlay';
}

.compat-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
}

.compat-table th,
.compat-table td {
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.compat-table tbody tr:last-child th,
.compat-table tbody tr:last-child td {
  border-bottom: none;
}

.compat-table thead th {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: var(--surface-raised);
}

.compat-table tbody th {
  color: var(--ink);
  font-weight: 600;
  background: var(--surface);
}

.compat-table td {
  color: var(--ink-muted);
}

@container (width < 640px) {
  .compat-table,
  .compat-table thead,
  .compat-table tbody,
  .compat-table tr,
  .compat-table th,
  .compat-table td {
    display: block;
  }

  .compat-table thead {
    display: none;
  }

  .compat-table tbody {
    padding: 0.75rem;
    display: grid;
    gap: 0.75rem;
    background: var(--bg);
  }

  .compat-table tbody tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
  }

  .compat-table tbody th {
    padding: 0.85rem 1rem;
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
  }

  .compat-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
  }

  .compat-table tbody td:last-child {
    border-bottom: none;
  }

  .compat-table tbody td::before {
    font-family: var(--mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-dim);
  }

  .compat-table tbody td:nth-child(2)::before {
    content: var(--label-2);
  }

  .compat-table tbody td:nth-child(3)::before {
    content: var(--label-3);
  }

  .compat-table tbody td:nth-child(4)::before {
    content: var(--label-4);
  }
}

.tag-yes {
  color: var(--signal-green);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
}

.tag-no {
  color: var(--signal-red);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
}

.tag-cond {
  color: var(--signal-amber);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
}

/* Install Steps & Checksum */
.install-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
}

.install-steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-muted);
  display: grid;
  gap: 0.55rem;
  font-size: 0.9rem;
}

.checksum-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
  word-break: break-all;
}

.checksum-box strong {
  display: block;
  color: var(--ink);
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Footer */
.site-footer {
  padding: 2.25rem 0;
  color: var(--ink-dim);
  font-size: 0.82rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Scroll-Driven Entry Animations (modern-web-guidance: motion + scroll-entry-exit-effects) */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes section-reveal {
      from {
        opacity: 0.15;
        transform: translateY(20px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .reveal {
      animation: section-reveal auto linear backwards;
      animation-timeline: view();
      animation-range: entry 0% entry 32%;
    }
  }
}

.reveal-fallback {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}

.reveal-fallback.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .hero-grid,
  .spec-grid,
  .validator-box,
  .install-card {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }

  .hero {
    padding: 3rem 0 2.75rem;
  }

  .section {
    padding: 3rem 0;
  }
}

@media (max-width: 600px) {
  .container {
    width: min(1180px, calc(100% - 1.5rem));
  }

  .header-inner {
    min-height: 60px;
    gap: 0.65rem;
  }

  .brand {
    gap: 0.55rem;
    min-width: 0;
  }

  .brand img {
    width: 30px;
    height: 30px;
  }

  .brand-name {
    font-size: 0.98rem;
  }

  .brand-tag {
    display: none;
  }

  .header-actions {
    gap: 0.45rem;
    flex-shrink: 0;
  }

  .theme-toggle {
    padding: 0.48rem 0.65rem;
    font-size: 0.74rem;
    min-height: 38px;
  }

  .btn-compact {
    padding: 0.48rem 0.78rem;
    font-size: 0.78rem;
    min-height: 38px;
  }

  .hero {
    padding: 2.1rem 0 2.2rem;
  }

  .hero-grid {
    gap: 2rem;
  }

  .eyebrow {
    font-size: 0.66rem;
    margin-bottom: 0.9rem;
  }

  .hero h1 {
    font-size: clamp(1.9rem, 8.2vw, 2.5rem);
  }

  .hero-lead {
    font-size: 0.95rem;
    margin-bottom: 1.35rem;
  }

  .hero-actions {
    flex-direction: column;
    gap: 0.6rem;
  }

  .hero-actions .btn {
    width: 100%;
    padding: 0.88rem 1.1rem;
  }

  .build-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .meta-value {
    font-size: 0.74rem;
  }

  .bezel {
    padding: 9px;
    border-radius: 14px;
  }

  .bezel-bar {
    font-size: 0.62rem;
    padding: 2px 4px 8px;
  }

  .bezel-meta-extra {
    display: none;
  }

  .section {
    padding: 2.5rem 0;
  }

  .section-head {
    margin-bottom: 1.35rem;
    gap: 0.75rem;
  }

  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-item {
    padding: 0.8rem 0.75rem;
    gap: 0.6rem;
    min-width: 0;
  }

  .catalog-item > div {
    min-width: 0;
  }

  .catalog-item img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .catalog-name {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .catalog-mode {
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .spec-card,
  .validator-box,
  .install-card {
    padding: 1.2rem;
  }

  .validator-form {
    flex-direction: column;
  }

  .validator-form .btn {
    width: 100%;
    padding: 0.78rem 1rem;
  }

  .chip {
    padding: 0.38rem 0.7rem;
    font-size: 0.72rem;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }
}
