/* ===== Fonts ===== */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-mono-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/plex-mono-500.woff2') format('woff2');
}

/* ===== Tokens ===== */
:root {
  --bg: #020617;
  --fg: #DDE7F0;
  --fg-dim: #94A3B8;
  --accent-clean: #38BDF8;
  --accent-filter: #A3E635;
  --accent-noisy: #334155;
  --border: #1E293B;

  --phase-noisy: 0;
  --phase-clean: 0;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --max-content: 720px;
  --max-prose: 70ch;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent-clean); outline-offset: 2px; border-radius: 2px; }

/* ===== Shell ===== */
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  padding: 1.5rem 2rem;
}
.site-header .wordmark {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--fg);
}

.site-footer {
  padding: 1.5rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--fg-dim);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.site-footer a { color: var(--fg-dim); }
.site-footer a:hover { color: var(--fg); }

/* ===== Landing hero ===== */
main.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  gap: 2rem;
}

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-filter);
  border: 1px solid var(--accent-filter);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
}

.headline {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(1.75rem, 5vw, 3rem);
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--fg);
}

.subline {
  max-width: var(--max-content);
  color: var(--fg-dim);
  font-size: 1.0625rem;
}

.capabilities {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--fg-dim);
}

/* ===== Waveform hero visual ===== */
.waveform {
  width: min(100%, 720px);
  height: 160px;
  display: block;
  overflow: visible;
}
.waveform .filter-line {
  stroke: var(--accent-filter);
  stroke-width: 1;
  filter: drop-shadow(0 0 6px var(--accent-filter));
  opacity: 0.7;
}
.waveform .trace-noisy {
  stroke: var(--accent-noisy);
  stroke-width: 1.5;
  fill: none;
  transform: translateX(calc(var(--phase-noisy) * 1px));
  transition: transform 30ms linear;
}
.waveform .trace-clean {
  stroke: var(--accent-clean);
  stroke-width: 1.5;
  fill: none;
  transform: translateX(calc(var(--phase-clean) * 1px));
  transition: transform 30ms linear;
}

/* ===== Prose pages (privacy, terms) ===== */
main.prose {
  flex: 1;
  width: 100%;
  max-width: var(--max-prose);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
main.prose h1 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}
main.prose .updated {
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  margin-bottom: 2rem;
}
main.prose h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.0625rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--fg);
}
main.prose p, main.prose li { color: var(--fg); }
main.prose p + p { margin-top: 1rem; }
main.prose ul { padding-left: 1.25rem; list-style: disc; }
main.prose li + li { margin-top: 0.4rem; }
main.prose a { color: var(--accent-clean); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* ===== Guide ===== */
:root {
  --guide-bg: #080B10;
  --guide-surface: #10161D;
  --guide-surface-2: #151E27;
  --guide-line: #26323E;
  --guide-soft: #AAB7C4;
  --guide-muted: #7C8A99;
  --guide-ink: #EEF6FC;
  --guide-cyan: #38BDF8;
  --guide-green: #A3E635;
  --guide-amber: #FBBF24;
  --guide-rose: #FB7185;
}

.guide-body {
  background:
    linear-gradient(180deg, #0B1117 0%, var(--guide-bg) 42%, #07090D 100%);
  overflow-x: hidden;
}
.guide-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.8), transparent 70%);
}
.guide-body .site-header,
.guide-body .site-footer,
.guide-body .guide-main {
  position: relative;
}

.guide-nav {
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0.625rem 2rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: rgba(8, 11, 16, 0.9);
  backdrop-filter: blur(14px);
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100vw;
  min-height: 3.25rem;
  min-width: 0;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 10;
  scrollbar-width: none;
}
.guide-nav::-webkit-scrollbar { display: none; }
.guide-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  color: var(--guide-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.375rem 0.75rem;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}
.guide-nav a:hover {
  color: var(--guide-ink);
  border-color: rgba(255,255,255,0.12);
  text-decoration: none;
}
.guide-nav a[aria-current="page"] {
  color: #061017;
  background: var(--guide-cyan);
  border-color: var(--guide-cyan);
  text-decoration: none;
}

.guide-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  min-width: 0;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}
.guide-main a:not(.guide-button):not(.guide-card) {
  color: var(--guide-cyan);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.guide-main p,
.guide-main li {
  color: var(--guide-soft);
}
.guide-main code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--guide-ink);
  background: #18222D;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}

.guide-hero,
.guide-page-header {
  padding: 1rem 0 3rem;
}
.guide-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  align-items: center;
  gap: 2rem;
}
.guide-page-header {
  max-width: 860px;
}
.guide-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--guide-green);
  margin-bottom: 0.75rem;
}
.guide-hero h1,
.guide-page-header h1 {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--guide-ink);
  line-height: 1.06;
  letter-spacing: 0;
}
.guide-hero h1 {
  font-size: clamp(2.25rem, 5vw, 4.5rem);
  max-width: 10ch;
}
.guide-page-header h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  max-width: 13ch;
}
.guide-lead {
  color: var(--guide-soft);
  font-size: clamp(1.0625rem, 2vw, 1.25rem);
  line-height: 1.7;
  max-width: 68ch;
  margin-top: 1rem;
}
.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.guide-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--guide-cyan);
  background: var(--guide-cyan);
  color: #061017;
}
.guide-button.secondary {
  background: transparent;
  color: var(--guide-ink);
  border-color: rgba(255,255,255,0.16);
}
.guide-button:hover,
.guide-button:focus-visible {
  text-decoration: none;
  transform: translateY(-1px);
}

.guide-stats,
.guide-quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.guide-stats span,
.guide-quick-list span {
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(16, 22, 29, 0.72);
  color: var(--guide-soft);
  padding: 0.65rem 0.8rem;
}
.guide-stats strong,
.guide-quick-list strong {
  display: block;
  color: var(--guide-ink);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin-bottom: 0.1rem;
}

.signal-panel,
.route-panel {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(21,30,39,0.95), rgba(12,17,23,0.95));
  box-shadow: 0 24px 80px rgba(0,0,0,0.28);
  padding: 1rem;
}
.signal-panel {
  min-height: 330px;
  display: grid;
  gap: 1rem;
}
.signal-header,
.route-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--guide-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.signal-light {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--guide-green);
  box-shadow: 0 0 18px rgba(163,230,53,0.7);
}
.signal-stack {
  display: grid;
  gap: 0.75rem;
}
.signal-row {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255,255,255,0.03);
}
.signal-row strong {
  color: var(--guide-ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
}
.meter {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  align-items: end;
  gap: 0.25rem;
  height: 72px;
  margin-top: 0.7rem;
}
.meter i {
  display: block;
  min-height: 8px;
  border-radius: 3px 3px 0 0;
  background: var(--guide-line);
}
.signal-row.raw .meter i:nth-child(2n),
.signal-row.raw .meter i:nth-child(5n) { background: #496070; }
.signal-row.clean .meter i:nth-child(-n+11) { background: var(--guide-cyan); }
.signal-row.clean .meter i:nth-child(n+12) { background: var(--guide-green); }
.signal-row.raw .meter i:nth-child(1) { height: 34%; }
.signal-row.raw .meter i:nth-child(2) { height: 78%; }
.signal-row.raw .meter i:nth-child(3) { height: 26%; }
.signal-row.raw .meter i:nth-child(4) { height: 92%; }
.signal-row.raw .meter i:nth-child(5) { height: 44%; }
.signal-row.raw .meter i:nth-child(6) { height: 88%; }
.signal-row.raw .meter i:nth-child(7) { height: 38%; }
.signal-row.raw .meter i:nth-child(8) { height: 66%; }
.signal-row.raw .meter i:nth-child(9) { height: 30%; }
.signal-row.raw .meter i:nth-child(10) { height: 84%; }
.signal-row.raw .meter i:nth-child(11) { height: 48%; }
.signal-row.raw .meter i:nth-child(12) { height: 76%; }
.signal-row.raw .meter i:nth-child(13) { height: 36%; }
.signal-row.raw .meter i:nth-child(14) { height: 62%; }
.signal-row.raw .meter i:nth-child(15) { height: 28%; }
.signal-row.raw .meter i:nth-child(16) { height: 52%; }
.signal-row.clean .meter i:nth-child(1) { height: 22%; }
.signal-row.clean .meter i:nth-child(2) { height: 38%; }
.signal-row.clean .meter i:nth-child(3) { height: 58%; }
.signal-row.clean .meter i:nth-child(4) { height: 74%; }
.signal-row.clean .meter i:nth-child(5) { height: 70%; }
.signal-row.clean .meter i:nth-child(6) { height: 50%; }
.signal-row.clean .meter i:nth-child(7) { height: 32%; }
.signal-row.clean .meter i:nth-child(8) { height: 46%; }
.signal-row.clean .meter i:nth-child(9) { height: 66%; }
.signal-row.clean .meter i:nth-child(10) { height: 78%; }
.signal-row.clean .meter i:nth-child(11) { height: 56%; }
.signal-row.clean .meter i:nth-child(12) { height: 34%; }
.signal-row.clean .meter i:nth-child(13) { height: 24%; }
.signal-row.clean .meter i:nth-child(14) { height: 30%; }
.signal-row.clean .meter i:nth-child(15) { height: 42%; }
.signal-row.clean .meter i:nth-child(16) { height: 28%; }
.signal-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}
.signal-footer span {
  border-radius: 8px;
  background: #0B1117;
  padding: 0.55rem 0.65rem;
  color: var(--guide-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.signal-footer strong {
  display: block;
  color: var(--guide-ink);
  font-size: 0.95rem;
  margin-bottom: 0.1rem;
}

.guide-section {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 2.5rem 0;
}
.section-heading {
  max-width: 760px;
  margin-bottom: 1.25rem;
}
.section-heading h2,
.guide-section h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.18;
  color: var(--guide-ink);
  letter-spacing: 0;
  margin-bottom: 0.5rem;
}
.section-heading p {
  color: var(--guide-soft);
}

.guide-card-grid,
.feature-grid,
.node-grid,
.qa-grid {
  display: grid;
  gap: 0.9rem;
}
.guide-card-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.node-grid,
.qa-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.guide-card,
.feature-card,
.node-card,
.qa-card,
.step-card {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(16, 22, 29, 0.82);
  padding: 1rem;
}
.guide-card {
  min-height: 100%;
  color: var(--guide-soft);
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.guide-card:hover {
  border-color: var(--guide-cyan);
  background: rgba(21, 30, 39, 0.96);
  transform: translateY(-2px);
  text-decoration: none;
}
.guide-card .kicker,
.feature-card .kicker,
.node-card .kicker,
.qa-card .kicker {
  display: block;
  color: var(--guide-green);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.guide-card h3,
.feature-card h3,
.node-card h3,
.qa-card h3 {
  color: var(--guide-ink);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.25;
  margin-bottom: 0.45rem;
}
.guide-card p,
.feature-card p,
.node-card p,
.qa-card p {
  font-size: 0.95rem;
  line-height: 1.6;
}

.steps {
  display: grid;
  gap: 0.9rem;
  list-style: none;
  padding: 0;
}
.step-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
}
.step-number {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #061017;
  background: var(--guide-green);
  font-family: var(--font-mono);
  font-weight: 500;
}
.step-card h2 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
}
.step-card p + p,
.step-card p + ul,
.step-card ul + p,
.feature-card p + ul,
.node-card p + ul,
.qa-card p + ul {
  margin-top: 0.75rem;
}
.step-card ul,
.feature-card ul,
.node-card ul,
.qa-card ul,
.guide-callout ul {
  list-style: disc;
  padding-left: 1.1rem;
}
.step-card li + li,
.feature-card li + li,
.node-card li + li,
.qa-card li + li,
.guide-callout li + li {
  margin-top: 0.35rem;
}

.guide-callout {
  border: 1px solid rgba(56,189,248,0.28);
  border-left: 4px solid var(--guide-cyan);
  border-radius: 8px;
  background: rgba(56,189,248,0.08);
  padding: 1rem 1.1rem;
  margin-top: 1.25rem;
}
.guide-callout strong {
  color: var(--guide-ink);
}

.mode-strip,
.route-steps,
.preset-strip {
  display: grid;
  gap: 0.75rem;
}
.mode-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.route-steps,
.preset-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.route-panel {
  margin-top: 1.5rem;
}
.route-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
}
.route-node {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  padding: 0.8rem;
  min-width: 0;
}
.route-node strong {
  display: block;
  color: var(--guide-ink);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.route-node span {
  display: block;
  color: var(--guide-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
  overflow-wrap: anywhere;
}
.route-arrow {
  color: var(--guide-cyan);
  font-family: var(--font-mono);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.tag-list span {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  color: var(--guide-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
}
.tag-list .warn {
  color: var(--guide-amber);
  border-color: rgba(251,191,36,0.35);
}
.tag-list .hot {
  color: var(--guide-rose);
  border-color: rgba(251,113,133,0.35);
}

.qa-card h2 {
  color: var(--guide-ink);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}
.qa-card strong {
  color: var(--guide-ink);
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .site-header { padding: 1.25rem 1.25rem; }
  .site-footer { padding: 1.25rem 1.25rem; }
  main.hero { padding: 1.25rem; gap: 1.5rem; }
  .waveform { height: 120px; }
  .guide-nav { padding: 0.5rem 1.25rem; font-size: 0.75rem; }
  .guide-main { padding: 2rem 1.25rem 4rem; }
  .guide-hero,
  .guide-page-header { padding-bottom: 2.25rem; }
  .guide-hero { grid-template-columns: 1fr; }
  .guide-hero h1,
  .guide-page-header h1 { max-width: none; }
  .guide-card-grid,
  .feature-grid,
  .node-grid,
  .qa-grid,
  .mode-strip,
  .route-steps,
  .preset-strip,
  .signal-footer { grid-template-columns: 1fr; }
  .step-card { grid-template-columns: 1fr; }
  .route-line {
    grid-template-columns: 1fr;
  }
  .route-arrow {
    text-align: center;
  }
}

@media (min-width: 721px) and (max-width: 980px) {
  .guide-hero { grid-template-columns: 1fr; }
  .guide-card-grid,
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-strip { grid-template-columns: 1fr; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .waveform .trace-noisy,
  .waveform .trace-clean {
    transform: none;
    transition: none;
  }
}
