@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg:      oklch(98% 0.003 260);
  --surface: oklch(95% 0.008 260);
  --fg:      oklch(18% 0.02 260);
  --muted:   oklch(52% 0.03 260);
  --border:  oklch(85% 0.02 260);
  --accent:  oklch(58% 0.20 25);

  --success: oklch(55% 0.16 145);
  --warn:    oklch(65% 0.16 80);
  --danger:  oklch(55% 0.20 25);

  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Monaco, 'Cascadia Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --max-content: 1200px;
  --nav-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

html { scroll-behavior: smooth; }

/* Engineering grid background — light, precise, faint */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, transparent 70%);
}

h1, h2, h3, h4, h5, p, ul, ol, figure {
  margin: 0;
  padding: 0;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }

input, textarea, select {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
  background: var(--bg);
}

input::placeholder, textarea::placeholder { color: var(--muted); }

textarea { resize: vertical; min-height: 96px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  color: var(--fg);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

/* Typography */
.display {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 650;
}

h1, .h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 650;
}

h2, .h2 {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-weight: 620;
}

h3, .h3 {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 600;
}

h4, .h4 {
  font-size: 15px;
  line-height: 1.3;
  font-weight: 620;
}

.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }

.text-sm { font-size: 13px; line-height: 1.45; }
.text-xs { font-size: 12px; line-height: 1.4; letter-spacing: 0.01em; }
.text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.caps {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 600;
}

/* Layout */
.container {
  position: relative;
  z-index: 1;
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 24px;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

.section { padding: 64px 0; }
.section-sm { padding: 32px 0; }

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Navigation */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-height);
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-inner {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: grid;
  place-items: center;
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 520;
  color: var(--muted);
  transition: color .12s ease, background .12s ease;
}

.nav-links a:hover { color: var(--fg); background: var(--surface); }
.nav-links a.active { color: var(--accent); background: color-mix(in oklch, var(--accent) 8%, transparent); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  color: var(--fg);
  border-radius: var(--radius-sm);
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 820px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    gap: 4px;
  }
  .nav-links.open a { width: 100%; }
  .nav-toggle { display: block; }
}

/* Cards */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.card-hover {
  transition: transform .16s cubic-bezier(.2, 0, .2, 1), border-color .16s ease, box-shadow .16s ease;
}

.card-hover:hover,
.card-hover:focus-visible {
  border-color: color-mix(in oklch, var(--accent) 55%, var(--border));
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(0,0,0,0.09);
}

.card-hover:active {
  transform: translateY(-1px);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

table a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--accent) 40%, var(--border));
  text-underline-offset: 3px;
  transition: color .12s ease;
}

table a:hover {
  color: var(--accent);
}

.card-title {
  font-size: 16px;
  font-weight: 620;
  margin-bottom: 8px;
}

.card-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 560;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: transform .08s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.16);
}

.btn-primary:hover {
  background: oklch(52% 0.20 25);
  box-shadow: 0 6px 18px color-mix(in oklch, var(--accent) 28%, transparent), inset 0 1px 0 rgba(255,255,255,0.18);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: oklch(48% 0.20 25);
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
}

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

.btn-secondary:hover {
  background: var(--surface);
  border-color: color-mix(in oklch, var(--accent) 50%, var(--border));
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(1px);
  background: color-mix(in oklch, var(--surface) 80%, var(--border));
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--fg);
  background: var(--surface);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in oklch, var(--danger) 30%, var(--border));
}

.btn-danger:hover {
  background: color-mix(in oklch, var(--danger) 8%, transparent);
}

.btn-lg { padding: 14px 24px; font-size: 15px; }

.btn-on-dark {
  background: rgba(255,255,255,0.08);
  color: var(--bg);
  border-color: rgba(255,255,255,0.2);
}

.btn-on-dark:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.35);
  color: var(--bg);
  transform: translateY(-1px);
}

.btn-on-dark:active {
  transform: translateY(1px);
  background: rgba(255,255,255,0.06);
}

/* Forms */
.form-group { margin-bottom: 20px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* Tags / Badges */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 580;
  letter-spacing: 0.01em;
}

.tag-accent { background: color-mix(in oklch, var(--accent) 10%, transparent); color: var(--accent); border: 1px solid color-mix(in oklch, var(--accent) 25%, var(--border)); }
.tag-success { background: color-mix(in oklch, var(--success) 10%, transparent); color: var(--success); border: 1px solid color-mix(in oklch, var(--success) 22%, var(--border)); }
.tag-warn { background: color-mix(in oklch, var(--warn) 12%, transparent); color: var(--warn); border: 1px solid color-mix(in oklch, var(--warn) 22%, var(--border)); }
.tag-danger { background: color-mix(in oklch, var(--danger) 10%, transparent); color: var(--danger); border: 1px solid color-mix(in oklch, var(--danger) 22%, var(--border)); }
.tag-neutral { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

/* Progress */
.progress {
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .4s ease;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in oklch, var(--border) 50%, var(--surface));
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background .12s ease;
}

tbody tr:hover td {
  background: color-mix(in oklch, var(--bg) 70%, var(--surface));
}

tbody tr:hover a {
  color: var(--accent);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 540;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s ease, border-color .12s ease;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
}

.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-color: var(--accent); }

/* Utility */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}

.empty-state .h3 { color: var(--fg); margin-bottom: 8px; }

/* Metric card */
.metric-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 6px;
  color: var(--fg);
}

.metric-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 520;
}

/* Chart bars */
.bar-stack {
  display: flex;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}

.bar-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

/* Avatar grid */
.avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.avatar-row:last-child { border-bottom: none; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 620;
  color: var(--fg);
  flex-shrink: 0;
}

/* Logs */
.log-line {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.log-line:last-child { border-bottom: none; }

.log-time { color: var(--muted); margin-right: 10px; }

/* Page header */
.page-header {
  padding: 32px 0 24px;
}

.page-header h1 { margin-bottom: 8px; }
.page-header p { color: var(--muted); max-width: 65ch; }

/* Variant preview */
.variant-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.variant-header {
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.variant-body {
  padding: 20px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--surface);
  border-radius: 999px;
  outline: none;
  padding: 0;
  border: 1px solid var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--fg);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  z-index: 200;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* Loading & empty states */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, color-mix(in oklch, var(--bg) 60%, var(--surface)) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

.animate-pulse { animation: pulse 1.6s ease-in-out infinite; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: slideIn .25s ease both; }

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .7s cubic-bezier(.2, 0, .2, 1), transform .7s cubic-bezier(.2, 0, .2, 1);
}

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

.reveal-delay-1 { transition-delay: .08s; }
.reveal-delay-2 { transition-delay: .16s; }
.reveal-delay-3 { transition-delay: .24s; }
.reveal-delay-4 { transition-delay: .32s; }

/* Count-up number */
.count-up {
  font-variant-numeric: tabular-nums;
}

/* Engineering tick marks for metric cards */
.metric-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  position: relative;
}

.metric-ticks::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent 0%, var(--border) 10%, var(--border) 90%, transparent 100%);
}

.metric-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.metric-tick::before {
  content: '';
  width: 1px;
  height: 6px;
  background: var(--border);
}

/* Table row action reveal */
.row-action {
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .16s ease, transform .16s ease, color .12s ease;
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
  white-space: nowrap;
}

tbody tr:hover .row-action {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}

/* Mission-control CTA */
.cta-mission {
  position: relative;
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius-lg);
  padding: 80px 64px;
  text-align: center;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

.cta-mission::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 20px color-mix(in oklch, var(--accent) 60%, transparent);
}

.cta-mission::after {
  content: '';
  position: absolute;
  top: 18px;
  right: 24px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #17c964;
  box-shadow: 0 0 0 4px rgba(23, 201, 100, 0.2);
  animation: statusPulse 2s ease-in-out infinite;
}

.cta-mission-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 4.2vw, 52px);
  letter-spacing: -0.03em;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.cta-mission-subtitle {
  color: rgba(255,255,255,0.65);
  max-width: 56ch;
  margin: 0 auto 36px;
  line-height: 1.6;
  font-size: 17px;
  position: relative;
  z-index: 1;
}

@media (max-width: 640px) {
  .cta-mission { padding: 56px 24px; }
}

/* Wind tunnel airflow SVG overlay */
.windtunnel {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.45;
}

.windtunnel-line {
  fill: none;
  stroke: var(--bg);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 240 120;
  animation: airflow 14s linear infinite;
}

.windtunnel-line:nth-child(2) { animation-delay: -3.5s; opacity: 0.7; }
.windtunnel-line:nth-child(3) { animation-delay: -7s; opacity: 0.5; }
.windtunnel-line:nth-child(4) { animation-delay: -10.5s; opacity: 0.35; }

@keyframes airflow {
  0% { stroke-dashoffset: 360; }
  100% { stroke-dashoffset: 0; }
}

/* Typewriter cursor */
.typewriter-cursor {
  display: inline-block;
  width: 8px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

/* Timeline progress animation */
.timeline-progress-animated {
  width: 0%;
  transition: width 1.2s cubic-bezier(.2, 0, .2, 1);
}

.timeline-progress-animated.animate {
  width: 55%;
}

/* Parallax hero image */
.hero-bg img {
  will-change: transform;
}

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

/* Print */
@media print {
  body::before { display: none; }
  .nav { position: static; }
  .card { break-inside: avoid; }
}
