@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;
  --warn: #ffb454;
  --err: #ff6b5e;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter Tight", "Inter", sans-serif;

  /* the one knob the JS reads at boot: pixels of rail per second of elapsed time */
  --pps: 3px;
}

*,
*::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;
}

.base {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- header ---- */

.head {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand keys"
    "brand controls";
  align-items: start;
  gap: 10px clamp(16px, 3vw, 40px);
  padding: 14px clamp(14px, 2.6vw, 30px) 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}

.brand {
  grid-area: brand;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mark {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lime);
}

.title {
  margin: 0;
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(19px, 3.4vw, 30px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.sub {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.keys {
  grid-area: keys;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px 10px;
}

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

.kinput {
  flex: 1 1 190px;
  min-width: 0;
  padding: 5px 9px;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  outline: none;
}
.kinput::placeholder { color: var(--faint); }
.kinput:focus-visible {
  border-color: var(--lime);
  box-shadow: 0 0 0 1px var(--lime) inset;
}

.khint {
  flex: 1 1 100%;
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

.btn,
.drq {
  flex: none;
  padding: 5px 11px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 100ms linear, border-color 100ms linear, background-color 100ms linear;
}
.btn:hover { border-color: var(--dim); }
.btn:focus-visible,
.drq:focus-visible { outline: 1px solid var(--lime); outline-offset: 1px; }

.controls {
  grid-area: controls;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px 12px;
  max-width: 40ch;
  justify-self: end;
}

.drq[aria-pressed="true"] {
  color: var(--field);
  background: var(--lime);
  border-color: var(--lime);
}
.drq[aria-pressed="false"] { color: var(--dim); }

.drqnote {
  flex: 1 1 100%;
  margin: 0;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.5;
  text-align: right;
}
.drqnote code { color: var(--dim); font-size: 1em; }

.copy.ok {
  color: var(--field);
  background: var(--lime);
  border-color: var(--lime);
}

/* ---- stage: gutter | rail | readout ---- */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(54px, 8vw, 84px) minmax(0, 1fr) clamp(200px, 26vw, 320px);
}

.gutter {
  position: relative;
  border-right: 1px solid var(--rule);
  background: var(--panel);
  overflow: hidden;
}

.axis {
  position: absolute;
  right: 9px;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: top 90ms linear;
}
.axis.away { display: none; }
.axis.zero { color: var(--lime); opacity: 0.6; }


/* the rail itself */

.rail {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  overscroll-behavior: contain;
}
.rail::-webkit-scrollbar { width: 8px; }
.rail::-webkit-scrollbar-thumb { background: #2a2a26; border-radius: 4px; }
.rail::-webkit-scrollbar-track { background: transparent; }

.inner {
  position: relative;
  min-height: 100%;
  padding: 18px 18px 22px 0;
}

/* the vertical spine of the timeline */
.spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 30px;
  width: 1px;
  background: linear-gradient(to bottom, var(--rule), var(--rule) 92%, transparent);
}

/* a ten-second boundary: a dashed ruler line across the rail */
.gridline {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed #31312c;
  pointer-events: none;
  z-index: 0;
}

/* one tick per log line */
.tick {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 0 10px;
  height: 22px;
  margin-top: -11px;
  padding: 0 10px 0 24px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font-family: var(--mono);
  cursor: pointer;
}

.tick .dot {
  grid-column: 1;
  justify-self: center;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
  border: 1px solid var(--field);
  box-shadow: 0 0 0 1px var(--rule);
  transition: background-color 120ms linear, box-shadow 120ms linear;
}

.tick .tt-txt {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  background: var(--field);
  padding: 1px 4px 1px 0;
}

.tick .tt-lv {
  display: inline-block;
  min-width: 5ch;
  margin-right: 0.9ch;
  color: var(--faint);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* a same-instant burst: dot stays truthful, the crowded label yields */
.tick.crowded .tt-txt { opacity: 0; }
.tick.crowded:hover .tt-txt,
.tick.crowded:focus-visible .tt-txt { opacity: 1; }

.tick:hover .dot,
.tick:focus-visible .dot,
.tick.active .dot {
  background: var(--lime);
  box-shadow: 0 0 0 1px var(--lime), 0 0 8px rgba(250, 255, 105, 0.5);
}
.tick:hover .tt-txt,
.tick:focus-visible .tt-txt,
.tick.active .tt-txt { color: var(--lime); }
.tick:focus-visible {
  outline: 1px solid var(--rule);
  outline-offset: 0;
}

.tick[data-level="warn"] .dot { background: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.tick[data-level="warn"] .tt-txt { color: var(--warn); }
.tick[data-level="warn"]:hover .dot,
.tick[data-level="warn"].active .dot { box-shadow: 0 0 0 1px var(--warn), 0 0 8px rgba(255, 180, 84, 0.5); }

.tick[data-level="error"] .dot { background: var(--err); box-shadow: 0 0 0 1px var(--err); }
.tick[data-level="error"] .tt-txt { color: var(--err); }

.tick[data-level="debug"] .tt-txt { color: var(--dim); }

.tick .need {
  color: var(--lime);
  font-weight: 700;
}

.empty {
  margin: 0;
  padding: 6px 0 0 52px;
  color: var(--faint);
  font-size: 11.5px;
  font-style: italic;
  max-width: 52ch;
  line-height: 1.6;
}

/* ---- readout: full text of the hovered tick ---- */

.readout {
  border-left: 1px solid var(--rule);
  background: var(--panel);
  padding: 16px clamp(12px, 1.8vw, 20px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.rlabel {
  margin: 0 0 9px;
  color: var(--faint);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rmeta {
  margin: 0 0 7px;
  color: var(--faint);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.copy-sink {
  position: fixed;
  top: -1000px;
  left: 0;
  opacity: 0;
  pointer-events: none;
}

.rtext {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.rtext.lit { color: var(--lime); }
.rtext.pending { color: var(--faint); font-style: italic; }

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

.status {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 8px clamp(14px, 2.6vw, 30px);
  border-top: 1px solid var(--rule);
  background: var(--panel);
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  overflow: hidden;
}

.led {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  align-self: center;
  transition: background-color 120ms linear;
}

.stext {
  flex: none;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.status[data-state="connecting"] .led { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
.status[data-state="connecting"] .stext { color: var(--warn); }

.status[data-state="open"] .led { background: var(--lime); box-shadow: 0 0 6px var(--lime); }
.status[data-state="open"] .stext { color: var(--lime); }

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

.sep { color: var(--faint); flex: none; }
.scount,
.sscale,
.selapsed { color: var(--faint); flex: none; font-variant-numeric: tabular-nums; }

.surl {
  margin-left: auto;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  direction: rtl;
  text-align: right;
}

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

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

@media (max-width: 820px) {
  .head {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "keys"
      "controls";
    gap: 9px;
  }
  .keys { flex-wrap: nowrap; }
  .kinput { flex: 1 1 auto; }
  .klabel { flex: none; }
  .khint { display: none; }

  .controls { justify-content: flex-start; max-width: none; }
  .drqnote { text-align: left; }
  .drq { flex: 0 1 auto; font-size: 10px; padding: 5px 8px; }

  .stage {
    grid-template-columns: 46px minmax(0, 1fr);
    position: relative;
  }
  /* the readout becomes a bottom sheet, rising only for a chosen tick */
  .readout {
    display: block;
    position: absolute;
    left: 46px;
    right: 0;
    bottom: 0;
    max-height: 45%;
    border-left: 0;
    border-top: 1px solid var(--lime);
    background: var(--panel-hi);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 160ms ease-out, visibility 0s linear 160ms;
    z-index: 5;
  }
  .readout.show {
    transform: translateY(0);
    visibility: visible;
    transition: transform 160ms ease-out, visibility 0s;
  }
  .rlabel { margin-bottom: 6px; }

  .tick { grid-template-columns: 12px minmax(0, 1fr); padding-left: 20px; }
  .spine { left: 26px; }
  .tick .tt-txt { font-size: 11px; }
  .tick { height: 24px; margin-top: -12px; }
  .gridline { right: 0; }

  .status { gap: 7px; font-size: 10px; padding: 7px 14px; }
  .sscale { display: none; }
  .surl { display: none; }
  .scount, .selapsed { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .status[data-state="connecting"] .led { animation: none; }
  .btn, .drq, .led, .dot, .axis, .tick .dot, .readout { transition: none; }
}
