:root {
  --bg: #070b09;
  --bg-elev: #0d1411;
  --bg-card: #111b16;
  --bg-card-hover: #16241d;
  --border: #1e3328;
  --border-bright: #2c4c3b;
  --text: #e6f0ea;
  --text-muted: #93aba0;
  --text-dim: #627a6f;
  --accent: #38e59a;
  --accent-dim: rgba(56, 229, 154, 0.14);
  --amber: #f5b942;
  --amber-dim: rgba(245, 185, 66, 0.14);
  --blue: #58b4ff;
  --blue-dim: rgba(88, 180, 255, 0.14);
  --red: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(56, 229, 154, 0.09), transparent 70%),
    linear-gradient(rgba(56, 229, 154, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 229, 154, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 100% 100%, 32px 32px, 32px 32px, 100% 100%;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(7, 11, 9, 0.82);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bg);
  background: var(--accent);
  border-radius: 5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 0.92rem;
}

.nav-links a {
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-cta {
  padding: 7px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent) !important;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
}

.nav-cta:hover {
  background: var(--accent);
  color: var(--bg) !important;
}

/* Hero */
.hero {
  padding: 64px 0 48px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 18px;
}

.hero-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.hero h1 {
  font-size: clamp(2.1rem, 4.8vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}

.hero h1 span {
  color: var(--accent);
}

.hero-sub {
  max-width: 760px;
  font-size: 1.08rem;
  color: var(--text-muted);
  margin: 0 0 26px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #04110a;
}

.btn-primary:hover {
  background: #5ef0af;
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-bright);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

/* Spec Strip */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
  margin-bottom: 34px;
}

.spec-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.spec-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.spec-val {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.spec-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Viewer Frame */
.viewer-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.viewer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab-btn {
  padding: 6px 13px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  border-color: var(--border-bright);
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.viewer-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 460px;
  padding: 24px;
  background: radial-gradient(circle at center, #13221b 0%, #090f0c 75%);
  cursor: zoom-in;
}

.viewer-stage.light-bg {
  background: #f6f7f6;
}

.viewer-stage img {
  max-width: 100%;
  max-height: 540px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.55));
  transition: opacity 0.2s ease;
}

.viewer-stage.light-bg img {
  filter: none;
}

.viewer-hint {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Sections */
section {
  padding: 56px 0;
  border-top: 1px solid var(--border);
}

.section-kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 6px;
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

.section-desc {
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 0 28px;
}

/* Downloads Grid */
.cdn-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.cdn-url {
  color: var(--amber);
  word-break: break-all;
}

.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.dl-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.16s, background 0.16s, transform 0.16s;
}

.dl-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.dl-card.featured {
  grid-column: span 2;
  border-color: rgba(56, 229, 154, 0.45);
  background: linear-gradient(135deg, rgba(56, 229, 154, 0.08), var(--bg-card) 60%);
}

@media (max-width: 700px) {
  .dl-card.featured {
    grid-column: span 1;
  }
}

.dl-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dl-name {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.dl-tag {
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}

.dl-tag.amber {
  background: var(--amber-dim);
  color: var(--amber);
}

.dl-tag.blue {
  background: var(--blue-dim);
  color: var(--blue);
}

.dl-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

.dl-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.dl-actions {
  display: flex;
  gap: 8px;
}

.mini-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-bright);
  background: var(--bg-elev);
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s;
}

.mini-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.mini-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04110a;
}

.mini-btn.primary:hover {
  background: #5ef0af;
  color: #04110a;
}

/* Memory Map Bar */
.mem-bar {
  display: flex;
  width: 100%;
  height: 58px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-bright);
  margin-bottom: 16px;
  font-family: var(--mono);
}

.mem-seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 0.74rem;
  text-align: center;
  border-right: 1px solid rgba(0, 0, 0, 0.35);
}

.mem-seg:last-child {
  border-right: none;
}

.mem-sram { flex: 8; background: rgba(56, 229, 154, 0.22); color: var(--accent); }
.mem-open { flex: 6; background: rgba(255, 255, 255, 0.04); color: var(--text-dim); }
.mem-xtide { flex: 1.5; background: rgba(88, 180, 255, 0.22); color: var(--blue); }
.mem-bios { flex: 1.5; background: rgba(245, 185, 66, 0.24); color: var(--amber); }

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

th {
  font-family: var(--mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

td code {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
}

/* Stackup */
.stackup {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.82rem;
  border: 1px solid var(--border);
}

.layer-fcu { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.35); }
.layer-in1 { background: rgba(56, 229, 154, 0.12); border-color: rgba(56, 229, 154, 0.35); }
.layer-in2 { background: rgba(245, 185, 66, 0.12); border-color: rgba(245, 185, 66, 0.35); }
.layer-bcu { background: rgba(88, 180, 255, 0.12); border-color: rgba(88, 180, 255, 0.35); }

/* Retro CRT Terminal */
.terminal {
  background: #040906;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(56, 229, 154, 0.06);
}

.terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0c1510;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.term-dots {
  display: flex;
  gap: 6px;
}

.term-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-bright);
}

.term-body {
  padding: 18px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  color: #4af6a8;
  min-height: 290px;
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  text-shadow: 0 0 8px rgba(74, 246, 168, 0.35);
}

.term-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: #07100b;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.term-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #4af6a8;
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* Code viewer */
.code-box {
  background: #080e0b;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.code-pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  max-height: 400px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: #cfe4d8;
}

/* BOM Controls */
.bom-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  padding: 9px 14px;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 5, 0.92);
  backdrop-filter: blur(8px);
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #0d1411;
}

.lightbox.light-bg img {
  background: #f6f7f6;
  padding: 12px;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  color: var(--text);
  font-family: var(--mono);
  cursor: pointer;
}

/* Footer */
footer {
  padding: 36px 0 48px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.88rem;
}

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

@media (max-width: 780px) {
  .nav-links {
    display: none;
  }
  .viewer-stage {
    min-height: 280px;
  }
}
