@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/of-jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/of-jetbrains-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter Tight";
  src: url("/fonts/of-inter-tight-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --field: #121211;
  --panel: #1a1a18;
  --panel-hi: #242420;
  --rule: #2b2b27;
  --ink: #e8e8e2;
  --dim: #7a7a72;
  --faint: #4a4a44;
  --lime: #faff69;
  --lime-soft: rgba(250, 255, 105, 0.14);
  --warn: #ffb454;
  --warn-soft: rgba(255, 180, 84, 0.16);
  --err: #ff6b5e;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display: "Inter Tight", "Inter", sans-serif;
}

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

html { height: 100%; }

body {
  margin: 0;
  height: 100%;
  background: var(--field);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

.page {
  height: 100vh;
  height: 100dvh;
  max-width: 1360px;
  margin: 0 auto;
  padding: clamp(14px, 2.2vh, 26px) clamp(14px, 2.6vw, 34px) 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

/* ---- banner ---- */

.banner {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--panel-hi);
  font-family: var(--display);
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.mark { color: var(--lime); }
.crumb { color: var(--dim); font-weight: 400; letter-spacing: 0.13em; }
.claim { color: var(--ink); opacity: 0.36; font-weight: 400; letter-spacing: 0.12em; }

/* ---- controls ---- */

.controls {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}

.keyrow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
  margin: 0;
}

.klabel {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.kinput {
  width: 15ch;
  padding: 6px 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.2;
}
.kinput::placeholder { color: var(--faint); }
.kinput:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }

.kbtn,
.copybtn,
.drqbtn {
  padding: 6px 11px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 120ms linear, background-color 120ms linear, color 120ms linear;
}
.kbtn:hover,
.copybtn:hover { border-color: var(--lime); color: var(--lime); }

.khint { color: var(--faint); font-size: 10.5px; letter-spacing: 0.03em; }

.ctlrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  flex: 1 1 420px;
  min-width: 0;
}

.drqbtn {
  flex: none;
  min-width: 15ch;
  border-color: var(--rule);
  color: var(--dim);
}
.drqbtn[aria-pressed="true"] {
  border-color: var(--lime);
  background: var(--lime-soft);
  color: var(--lime);
}

.drqnote {
  flex: 1 1 260px;
  margin: 0;
  min-width: 0;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.5;
}
.drqnote strong { color: var(--dim); font-weight: 700; }

.copybtn { flex: none; }
.copybtn.done { border-color: var(--lime); color: var(--lime); }

/* ---- stage ---- */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: 16px;
}

/* ---- diagram ---- */

.diagram {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  border: 1px solid var(--panel-hi);
  border-radius: 3px;
  background: var(--panel);
}

.dhead,
.thead {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.dtitle,
.ttitle {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.dstate,
.tcount {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.diagram[data-gate="on"] .dstate { color: var(--lime); }

.flowzone {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.62fr);
  gap: 12px;
}

/* funnel column */

.funnelcol {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.intakerow {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.iline { flex: 1 1 auto; height: 1px; background: var(--rule); }

.funnel {
  position: relative;
  flex: 1 1 auto;
  min-height: 170px;
  overflow: hidden;
}

.funnel::before,
.funnel::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(0.5% 0%, 99.5% 0%, 63% 100%, 37% 100%);
}
.funnel::before { background: var(--rule); }
.funnel::after {
  inset: 1.5px;
  clip-path: polygon(0.6% 0%, 99.4% 0%, 62.6% 100%, 37.4% 100%);
  background: linear-gradient(180deg, rgba(36, 36, 32, 0.55), rgba(18, 18, 17, 0.96));
}

/* the gate line */

.gate {
  position: absolute;
  top: 58%;
  left: 50%;
  width: 47%;
  height: 2px;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
}

.gatebar {
  position: absolute;
  inset: 0;
  background: var(--warn);
  transform-origin: 50% 50%;
  opacity: 0.9;
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1), opacity 320ms linear, background-color 320ms linear;
}
.gatebar::before,
.gatebar::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 2px;
  height: 10px;
  background: inherit;
}
.gatebar::before { left: 0; }
.gatebar::after { right: 0; }

.diagram[data-gate="on"] .gatebar {
  background: var(--lime);
  opacity: 0.42;
  transform: scaleX(0.16);
}

.gateword {
  position: absolute;
  top: 58%;
  left: 50%;
  transform: translate(-50%, 30%);
  z-index: 4;
  padding: 2px 6px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--field);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--warn);
  white-space: nowrap;
  pointer-events: none;
  transition: color 320ms linear, border-color 320ms linear;
}
.diagram[data-gate="on"] .gateword {
  color: var(--lime);
  border-color: var(--lime-soft);
}

/* chips */

.chipwrap {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  will-change: transform;
  transform: translateY(0);
  transition: transform 1650ms cubic-bezier(0.34, 0.02, 0.32, 1);
}

.chipwrap.go { transform: translateY(96%); }
.chipwrap.hold { transform: translateY(47%); }

.chip {
  position: absolute;
  top: 0;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 17px;
  margin-left: -39px;
  border: 1px solid var(--dim);
  border-radius: 2px;
  background: var(--panel-hi);
  color: var(--ink);
  font-size: 9px;
  letter-spacing: 0.1em;
  line-height: 1;
  white-space: nowrap;
  transition: opacity 280ms linear, border-color 240ms linear, color 240ms linear;
}

.chip.admitted {
  border-color: var(--lime);
  color: var(--lime);
  opacity: 0;
}

/* admitted strip */

.outrow {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.outstrip {
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}

.ochip {
  flex: none;
  width: 15px;
  height: 8px;
  border-radius: 1px;
  background: var(--lime);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 220ms linear, transform 260ms ease-out;
}
.ochip.in { opacity: 0.75; transform: translateY(0); }

.ocount {
  flex: none;
  color: var(--lime);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

/* waiting room */

.wroom {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid var(--panel-hi);
}

.whead {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.wcount {
  color: var(--warn);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  opacity: 0.5;
}
.diagram[data-gate="off"] .wcount { opacity: 1; }

.wstack {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  padding-right: 2px;
  overflow: hidden;
}

.wchip {
  flex: none;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px dashed var(--warn);
  border-radius: 2px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 9px;
  letter-spacing: 0.1em;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 260ms linear, transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.wchip.in { opacity: 1; transform: translateX(0); }
.wchip.leaving {
  opacity: 0;
  transform: translateX(-16px);
}

.wmore {
  flex: none;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.dnote {
  flex: none;
  margin: 0;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.5;
}
.dnote.live { color: var(--dim); }

/* ---- tail ---- */

.tail {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 12px 14px;
  border: 1px solid var(--panel-hi);
  border-radius: 3px;
  background: var(--panel);
  overflow: hidden;
}
.tail .thead { padding-right: 14px; }

.out {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 12px;
  font-size: 11px;
  line-height: 1.62;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  overscroll-behavior: contain;
}
.out::-webkit-scrollbar { width: 7px; }
.out::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }

.ln {
  display: grid;
  grid-template-columns: 8.4ch 5.2ch minmax(0, 1fr);
  gap: 0 10px;
  padding: 1px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ln .lts { color: var(--faint); font-variant-numeric: tabular-nums; }
.ln .llv { text-transform: uppercase; letter-spacing: 0.06em; }
.ln .ltx { color: var(--ink); }

.ln.lv-info .llv { color: var(--dim); }
.ln.lv-warn .llv { color: var(--warn); }
.ln.lv-error .llv { color: var(--err); }
.ln.lv-debug .llv { color: var(--faint); }

.ln.gate-on .ltx { color: var(--lime); }
.ln.gate-off .ltx { color: var(--ink); }

.ln.gap { margin-top: 6px; }

.pending {
  color: var(--faint);
  font-size: 11px;
  line-height: 1.7;
}

.offscreen {
  position: absolute;
  left: -9999px;
  top: 0;
  opacity: 0;
}

/* ---- status ---- */

.status {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 9px 0 11px;
  border-top: 1px solid var(--panel-hi);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.led {
  flex: none;
  align-self: center;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  transition: background-color 200ms linear;
}
.status[data-state="connecting"] .led { background: var(--warn); animation: pulse 1s steps(1) infinite; }
.status[data-state="open"] .led { background: var(--lime); }
.status[data-state="closed"] .led { background: var(--err); }

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

.stext { color: var(--ink); }
.status[data-state="open"] .stext { color: var(--lime); }
.status[data-state="closed"] .stext { color: var(--err); }

.sdiv { color: var(--faint); }
.scount { font-variant-numeric: tabular-nums; }
.serr {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--err);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site {
  flex: none;
  margin-left: auto;
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 120ms linear, border-color 120ms linear;
}
.site:hover,
.site:focus-visible { color: var(--lime); border-bottom-color: var(--lime); outline: none; }

/* ---- narrow ---- */

@media (max-width: 940px) {
  .page { height: auto; min-height: 100dvh; overflow: visible; }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .diagram { min-height: 420px; }
  .tail { min-height: 300px; }
  .out { max-height: 320px; }
}

@media (max-width: 560px) {
  .flowzone { grid-template-columns: minmax(0, 1fr); }
  .wroom {
    padding-left: 0;
    padding-top: 8px;
    border-left: 0;
    border-top: 1px solid var(--panel-hi);
  }
  .wstack { flex-direction: row; flex-wrap: wrap; max-height: 62px; }
  .ln { grid-template-columns: 1fr; gap: 0; }
  .ln .lts,
  .ln .llv { font-size: 9.5px; }
  .khint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chip,
  .chipwrap,
  .wchip,
  .ochip,
  .gatebar,
  .gateword { transition-duration: 1ms; }
  .status[data-state="connecting"] .led { animation: none; }
}
