:root {
  --void: #0a0908;
  --slag: #14110e;
  --steel: #2e2822;
  --steel-2: #463c34;
  --bone: #efe4d2;
  --mute: #9a8c7a;
  --rust: #c43c18;
  --ember: #e09428;
  --ok: #7a9e62;
  --bad: #d06050;
  --font-display: "Teko", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--void);
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}

body {
  position: relative;
  overflow-x: hidden;
}

a { color: var(--ember); text-decoration: none; }
a:hover { color: var(--bone); }

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--ember);
}

.ico {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  display: block;
}

.grain, .heat {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
}

.grain {
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.heat {
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(196, 60, 24, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 40% at 80% 100%, rgba(224, 148, 40, 0.06), transparent 50%);
}

.mast, .hero, .pipeline, .links, .foot, .log {
  position: relative;
  z-index: 1;
}

/* —— masthead —— */
.mast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem 1.25rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--steel);
  background: linear-gradient(180deg, #1a1511 0%, var(--void) 100%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--bone);
  text-decoration: none;
}

.brand-mark {
  width: 0.7rem;
  height: 0.7rem;
  background: var(--rust);
  box-shadow: 0 0 12px rgba(196, 60, 24, 0.7);
  animation: pulse 2.4s ease-in-out infinite;
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.85rem;
  letter-spacing: 0.08em;
  line-height: 1;
}

.brand-text span { color: var(--rust); }

.modes {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.mode {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  background: transparent;
  border: 1px solid transparent;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.mode:hover { color: var(--bone); border-color: var(--steel); }
.mode.is-active {
  color: var(--void);
  background: var(--ember);
  border-color: var(--ember);
}

.ext {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--steel);
  color: var(--mute);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.pill:hover {
  color: var(--bone);
  border-color: var(--steel-2);
  background: rgba(224, 148, 40, 0.06);
}

/* —— hero / CRT bezel —— */
.hero {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.25rem 2rem;
}

.bezel {
  width: min(980px, 100%);
  background: var(--slag);
  border: 1px solid var(--steel);
  box-shadow:
    0 0 0 1px #000,
    0 28px 70px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(239, 228, 210, 0.05);
}

.bezel-chrome {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid var(--steel);
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lamps { display: flex; gap: 0.35rem; }
.lamp {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--steel-2);
}
.lamp.is-live {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(122, 158, 98, 0.7);
}

.bezel-id {
  margin: 0;
  font-size: 1rem;
  color: var(--mute);
}
.bezel-id .sep { opacity: 0.4; margin: 0 0.25rem; }
#status { color: var(--ok); }

.bezel-path {
  margin: 0 0 0 auto;
  font-size: 0.95rem;
  color: var(--steel-2);
}

.stage {
  position: relative;
  line-height: 0;
  background: #000;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

.scan {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 3px
  );
  opacity: 0.35;
  mix-blend-mode: multiply;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(10, 9, 8, 0.55), rgba(10, 9, 8, 0.82));
  cursor: pointer;
}

.overlay.hidden { display: none; }

.overlay-brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.2rem, 12vw, 6rem);
  letter-spacing: 0.12em;
  line-height: 0.9;
  color: var(--bone);
  text-shadow: 0 0 48px rgba(196, 60, 24, 0.4);
  animation: brand-in 0.85s ease-out both;
}

.overlay-brand::after {
  content: ".FLOW";
  color: var(--rust);
}

.overlay-copy {
  margin: 0;
  max-width: 38ch;
  text-align: center;
  color: var(--mute);
  font-size: 0.82rem;
  animation: fade-up 0.75s 0.12s ease-out both;
}

#start, #stop {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 0;
  cursor: pointer;
}

#start {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--rust);
  color: var(--bone);
  padding: 0.55rem 1.35rem;
  font-size: 1.2rem;
  animation: fade-up 0.75s 0.22s ease-out both;
}

#start:hover { background: var(--ember); color: var(--void); }

#stop {
  background: transparent;
  color: var(--mute);
  border: 1px solid var(--steel);
  padding: 0.25rem 0.7rem;
  font-size: 0.95rem;
}

#stop:disabled { opacity: 0.35; cursor: default; }
#stop:not(:disabled):hover { color: var(--bone); border-color: var(--mute); }

.bezel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.85rem;
  border-top: 1px solid var(--steel);
  color: var(--mute);
  font-size: 0.72rem;
}

#hint { margin: 0; }

/* —— pipeline —— */
.pipeline {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

.pipeline-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
}

.pipe {
  list-style: none;
  margin: 0;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  border: 1px solid var(--steel);
  background: var(--slag);
}

.pipe > li:not(.pipe-arrow) {
  flex: 1 1 8rem;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.55rem;
  row-gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--steel);
}

.pipe-ico {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--ember);
}

.pipe-ico svg { width: 1.35rem; height: 1.35rem; display: block; }

.pipe strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--bone);
}

.pipe span { color: var(--mute); font-size: 0.72rem; }

.pipe-arrow {
  display: flex;
  align-items: center;
  color: var(--steel-2);
  font-size: 1.2rem;
  padding: 0 0.15rem;
}

.pipeline-note {
  margin: 0.85rem 0 0;
  color: var(--mute);
  font-size: 0.8rem;
  max-width: 62ch;
}

.pipeline-note strong { color: var(--bone); font-weight: 500; }

/* —— link cards —— */
.links {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--steel);
  background: var(--slag);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.card:hover {
  border-color: var(--ember);
  background: #1a1511;
  transform: translateY(-1px);
}

.card .ico {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--ember);
}

.card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--bone);
}

.card span {
  display: block;
  color: var(--mute);
  font-size: 0.72rem;
  margin-top: 0.1rem;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  padding: 1.1rem 1.25rem 1.5rem;
  border-top: 1px solid var(--steel);
  color: var(--mute);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}

.foot p { margin: 0; }

.log {
  margin: 0;
  padding: 0.75rem 1.25rem 1.5rem;
  max-height: 10rem;
  overflow: auto;
  font-size: 0.7rem;
  color: var(--ok);
  background: #080706;
  border-top: 1px solid var(--steel);
  white-space: pre-wrap;
}

.log:not([hidden]) { display: block; }
.log .err { color: var(--bad); }

@keyframes brand-in {
  from { opacity: 0; letter-spacing: 0.32em; transform: translateY(10px); }
  to { opacity: 1; letter-spacing: 0.12em; transform: none; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (max-width: 860px) {
  .mast {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .modes, .ext { justify-content: flex-start; width: 100%; }
  .bezel-path { display: none; }
  .links { grid-template-columns: 1fr; }
  .pipe-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-brand, .overlay-copy, #start, .brand-mark { animation: none; }
  .card:hover { transform: none; }
}
