:root {
  color-scheme: dark;
  --bg: #070a0c;
  --bg-elevated: #0f1519;
  --panel: #11181d;
  --panel-strong: #161f25;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f5f7f8;
  --muted: #a9b3ba;
  --quiet: #6f7b84;
  --red: #e0001b;
  --red-dark: #9b0014;
  --green: #1fd44d;
  --cyan: #66aaff;
  --amber: #ffd166;
  --steel: #8fa0aa;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
  --radius: 8px;
  --max: 1480px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(224, 0, 27, 0.11), transparent 30%),
    radial-gradient(circle at 73% 8%, rgba(31, 212, 77, 0.1), transparent 22rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 78%);
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

code {
  border: 1px solid rgba(102, 170, 255, 0.2);
  border-radius: 4px;
  background: rgba(102, 170, 255, 0.09);
  color: #d8e9ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.91em;
  padding: 0.08rem 0.24rem;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  transform: translateY(-160%);
  border-radius: 6px;
  background: var(--text);
  color: #090c0f;
  font-weight: 800;
  padding: 0.8rem 1rem;
  text-decoration: none;
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 12, 0.86);
  padding: 0 4vw;
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 38px;
  place-items: center;
  border-radius: 6px;
  background: var(--red);
  box-shadow: 0 12px 26px rgba(224, 0, 27, 0.22);
}

.brand-mark svg {
  width: 42px;
  height: 29px;
  fill: #fff;
  overflow: visible;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.4rem, 2vw, 1.2rem);
}

.site-nav a {
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 750;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  outline: none;
}

.site-nav .nav-cta {
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.section-pad {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(4.2rem, 8vw, 8rem) 4vw;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(520px, 1.25fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  min-height: calc(100svh - 78px);
  padding-top: clamp(2.4rem, 5vw, 4rem);
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.eyebrow {
  margin: 0 0 0.9rem;
  color: #ff495c;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 10.5ch;
  margin-bottom: 1rem;
  font-size: clamp(3.3rem, 6.4vw, 6.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 1rem;
  color: var(--text);
  font-size: clamp(2rem, 4.6vw, 4.8rem);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 1.08rem;
  line-height: 1.22;
}

.hero-lede,
.section-copy p,
.section-heading p + h2 + p {
  color: var(--muted);
  font-size: clamp(1.02rem, 1.6vw, 1.25rem);
}

.hero-lede {
  max-width: 58ch;
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 8px;
  font-weight: 850;
  padding: 0.9rem 1.25rem;
  text-decoration: none;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.button-primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 18px 40px rgba(224, 0, 27, 0.28);
}

.button-primary:hover,
.button-primary:focus-visible {
  background: #ff1632;
}

.button-secondary {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.button-secondary:hover,
.button-secondary:focus-visible {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.08);
}

.button-icon {
  margin-right: 0.55rem;
  font-size: 1.1rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  max-width: 520px;
  margin: 0;
}

.hero-stats div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  padding: 1rem;
}

.hero-stats dt {
  color: var(--text);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
}

.hero-stats dd {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.hero-model {
  min-width: 0;
}

.board-viewer {
  position: relative;
  min-height: min(70svh, 690px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%),
    radial-gradient(circle at 50% 42%, rgba(31, 212, 77, 0.14), transparent 18rem),
    #090d11;
  box-shadow: var(--shadow);
}

#board-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#board-canvas:active {
  cursor: grabbing;
}

.viewer-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 2rem;
}

.board-viewer.is-fallback #board-canvas {
  display: none;
}

.board-viewer.is-fallback .viewer-fallback {
  display: grid;
}

.fallback-board {
  position: relative;
  width: min(88%, 620px);
  aspect-ratio: 2.65 / 1;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 28px;
  background: linear-gradient(145deg, #050607, #242b2f 55%, #020303);
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.07),
    0 34px 70px rgba(0, 0, 0, 0.48);
  transform: rotateX(8deg) rotateY(-12deg);
}

.fallback-pin-row {
  position: absolute;
  left: 10%;
  right: 10%;
  top: -18px;
  height: 24px;
  border-radius: 999px;
  background:
    radial-gradient(circle, #050607 0 38%, #20282d 39% 59%, transparent 61%) 0 0 / 42px 24px repeat-x;
}

.fallback-screen {
  position: absolute;
  inset: 18% 9%;
  display: grid;
  gap: 5px;
}

.fallback-screen div {
  display: grid;
  grid-template-columns: 1fr 1.28fr;
  gap: 6px;
  min-height: 0;
  color: #fff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(0.75rem, 2.1vw, 1.2rem);
}

.fallback-screen span,
.fallback-screen strong,
.fallback-screen em {
  display: flex;
  align-items: center;
  border-radius: 3px;
  background: #101920;
  padding: 0 0.75rem;
}

.fallback-screen b {
  color: var(--cyan);
}

.fallback-screen strong,
.fallback-screen em {
  background: linear-gradient(90deg, #128c2b, #23e053);
  color: #001607;
  font-style: normal;
}

.fallback-screen em {
  background: linear-gradient(90deg, var(--red-dark), var(--red));
  color: #fff;
}

.callout-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.callout-lines path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.5;
  stroke-dasharray: 6 7;
}

.model-callout {
  position: absolute;
  z-index: 3;
  width: clamp(9.5rem, 20%, 12.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(11, 16, 20, 0.74);
  padding: 0.8rem 0.9rem;
  backdrop-filter: blur(12px);
}

.model-callout span {
  display: block;
  color: var(--text);
  font-weight: 850;
}

.model-callout small {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.callout-esp32 {
  left: 3%;
  top: 19%;
}

.callout-usb {
  left: 3%;
  bottom: 27%;
}

.callout-display {
  right: 3%;
  top: 18%;
}

.callout-ui {
  right: 3%;
  bottom: 26%;
}

.callout-watchdog {
  left: 39%;
  top: 4%;
  width: 11.8rem;
}

.callout-json {
  left: 39%;
  bottom: 4%;
  width: 12.2rem;
}

.viewer-hint {
  position: absolute;
  left: 1rem;
  bottom: 1.15rem;
  z-index: 4;
  transform: none;
  margin: 0;
  border: 1px solid rgba(31, 212, 77, 0.2);
  border-radius: 999px;
  background: rgba(31, 212, 77, 0.1);
  color: #dfffe6;
  font-size: 0.84rem;
  padding: 0.45rem 0.75rem;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.feature-band {
  padding-top: clamp(2rem, 5vw, 4rem);
}

.section-heading {
  max-width: 950px;
  margin-bottom: 2rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.feature-card,
.memory-grid article,
.watchdog-card,
.pinout,
.setup-list,
.tech-tags,
.code-panel,
.pipeline-node {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)),
    rgba(12, 18, 22, 0.82);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.22);
}

.feature-card {
  min-height: 250px;
  padding: 1.25rem;
}

.feature-card p,
.memory-grid p,
.watchdog-card small,
.pipeline-node small,
.setup-list li,
.photo-grid figcaption {
  color: var(--muted);
}

.feature-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e1418;
}

.departure-icon {
  background:
    radial-gradient(circle at 50% 50%, transparent 29%, var(--green) 30% 34%, transparent 35%),
    linear-gradient(var(--green), var(--green)) center 12px / 2px 14px no-repeat,
    linear-gradient(90deg, var(--green), var(--green)) 24px 24px / 11px 2px no-repeat,
    #0e1418;
}

.status-icon {
  background:
    linear-gradient(90deg, var(--green) 0 45%, transparent 45% 55%, var(--red) 55%) center / 26px 16px no-repeat,
    #0e1418;
}

.target-icon {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 31%, var(--cyan) 32% 36%, transparent 37%),
    radial-gradient(circle at 50% 50%, var(--red) 0 10%, transparent 11%),
    #0e1418;
}

.dim-icon {
  background:
    linear-gradient(90deg, rgba(255, 209, 102, 0.25), var(--amber)) center / 26px 3px no-repeat,
    radial-gradient(circle at 50% 50%, var(--amber) 0 18%, transparent 19%),
    #0e1418;
}

.split-section {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 1.3rem;
  align-items: start;
}

.section-copy {
  max-width: 640px;
}

.pipeline {
  display: grid;
  grid-column: 2;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.pipeline-node {
  min-height: 170px;
  padding: 1rem;
}

.pipeline-node span {
  display: inline-grid;
  width: 34px;
  height: 34px;
  margin-bottom: 1.25rem;
  place-items: center;
  border: 1px solid rgba(224, 0, 27, 0.4);
  border-radius: 50%;
  color: #ff8794;
  font-size: 0.8rem;
  font-weight: 900;
}

.pipeline-node strong {
  display: block;
  margin-bottom: 0.35rem;
}

.pipeline-arrow {
  display: none;
}

.code-panel {
  grid-column: 2;
  overflow: hidden;
  align-self: stretch;
}

.panel-bar {
  display: flex;
  gap: 0.45rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.8rem 1rem;
}

.panel-bar span {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--red);
}

.panel-bar span:nth-child(2) {
  background: var(--amber);
}

.panel-bar span:nth-child(3) {
  background: var(--green);
}

.code-panel pre {
  margin: 0;
  overflow: auto;
  padding: 1.3rem;
}

.code-panel code {
  border: 0;
  background: transparent;
  color: #dce7ee;
  font-size: clamp(0.82rem, 1.2vw, 1rem);
  line-height: 1.7;
  padding: 0;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.memory-grid article {
  min-height: 230px;
  padding: 1.25rem;
}

.memory-value {
  display: inline-block;
  margin-bottom: 2rem;
  color: var(--green);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 900;
  line-height: 1;
}

.reliability-section {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 1.5rem;
  align-items: center;
}

.watchdog-flow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.watchdog-card {
  min-height: 190px;
  padding: 1.25rem;
}

.watchdog-card span {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 1rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(102, 170, 255, 0.13);
  color: var(--cyan);
  font-weight: 900;
}

.watchdog-card strong {
  display: block;
  margin-bottom: 0.45rem;
}

.watchdog-card.critical {
  border-color: rgba(224, 0, 27, 0.42);
  background:
    linear-gradient(180deg, rgba(224, 0, 27, 0.13), rgba(255, 255, 255, 0.02)),
    rgba(12, 18, 22, 0.86);
}

.watchdog-card.critical span {
  background: rgba(224, 0, 27, 0.18);
  color: #ff8794;
}

.gallery-section {
  padding-top: clamp(2.5rem, 5vw, 5rem);
}

.photo-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1rem;
}

.photo-grid figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-grid figcaption {
  border-top: 1px solid var(--line);
  font-size: 0.94rem;
  padding: 1rem;
}

.hardware-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr;
  gap: 1rem;
  align-items: stretch;
}

.pinout,
.setup-list,
.tech-tags {
  padding: 1.25rem;
}

.pinout table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius);
}

.pinout th,
.pinout td {
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 0;
  text-align: left;
}

.pinout th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pinout tr:last-child td {
  border-bottom: 0;
}

.setup-list ol {
  margin: 0;
  padding-left: 1.15rem;
}

.setup-list li + li {
  margin-top: 0.8rem;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.6rem;
}

.tech-tags span {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 760;
  padding: 0.65rem 0.78rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  color: var(--quiet);
  padding: 1.5rem 4vw 2rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--text);
  outline: none;
}

@media (max-width: 1180px) {
  .hero {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: 10.5ch;
  }

  .board-viewer {
    min-height: 620px;
  }

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

  .split-section,
  .reliability-section,
  .hardware-layout {
    grid-template-columns: 1fr;
  }

  .pipeline,
  .code-panel {
    grid-column: auto;
  }
}

@media (max-width: 780px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 0.9rem;
    padding-block: 1rem;
  }

  .site-nav {
    width: 100%;
    flex-wrap: wrap;
    overflow-x: visible;
    padding-bottom: 0.2rem;
  }

  .section-pad {
    padding-inline: 1rem;
  }

  .hero {
    min-height: auto;
    padding-top: 2.5rem;
  }

  .feature-grid,
  .memory-grid,
  .watchdog-flow,
  .photo-grid,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .board-viewer {
    min-height: 560px;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero-stats div {
    padding: 0.85rem 0.75rem;
  }

  .model-callout {
    width: auto;
    max-width: 44%;
    padding: 0.65rem;
  }

  .model-callout small {
    display: none;
  }

  .callout-esp32,
  .callout-usb {
    left: 0.75rem;
  }

  .callout-display,
  .callout-ui {
    right: 0.75rem;
  }

  .callout-watchdog {
    left: 50%;
    top: 0.8rem;
    transform: translateX(-50%);
  }

  .callout-json {
    left: 50%;
    bottom: 3.8rem;
    transform: translateX(-50%);
  }

  .viewer-hint {
    display: none;
  }
}

@media (max-width: 560px) {
  .brand {
    gap: 0.7rem;
  }

  .brand-mark {
    width: 48px;
    height: 32px;
  }

  .site-nav a {
    font-size: 0.86rem;
    padding: 0.5rem 0.65rem;
  }

  h1 {
    font-size: clamp(2.65rem, 15vw, 4.8rem);
  }

  h2 {
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  .button {
    width: 100%;
  }

  .board-viewer {
    min-height: 510px;
  }

  .model-callout {
    font-size: 0.76rem;
  }

  .photo-grid img {
    aspect-ratio: 3 / 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  #board-canvas {
    cursor: default;
  }
}
