@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;
  --display: "Inter Tight", "Inter", system-ui, sans-serif;

  /* the switch's travel geometry — the knob's two seats */
  --throw-w: 148px;
  --knob-w: 58px;
  --seat-left: 4px;
  --seat-right: calc(var(--throw-w) - var(--knob-w) - 4px);
}

*,
*::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: 14px;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--ink);
  background: var(--panel-hi);
  padding: 0.1em 0.34em;
  border-radius: 2px;
}

.panel {
  height: 100vh;
  height: 100dvh;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 2.6vw, 34px) clamp(16px, 4vw, 56px) 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-hi);
  font-family: var(--display);
  font-weight: 800;
  font-size: 11.5px;
  line-height: 1.4;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.mark { color: var(--lime); }

.claim {
  color: var(--ink);
  opacity: 0.38;
  font-weight: 400;
  letter-spacing: 0.14em;
}

/* ---- access key — one compact inline row ---- */

.keyed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--panel-hi);
  font-size: 11.5px;
  flex: 0 0 auto;
}

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

.keyed-input {
  flex: 0 1 190px;
  min-width: 0;
  padding: 5px 8px;
  background: #0d0d0c;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 120ms ease;
}

.keyed-input::placeholder { color: var(--faint); }

.keyed-input:focus {
  border-color: var(--dim);
  box-shadow: 0 0 0 1px var(--rule);
}

.keyed-btn {
  padding: 5px 12px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.keyed-btn:hover {
  border-color: var(--dim);
  color: var(--lime);
}

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

.keyed-btn[data-attached="true"] {
  border-color: var(--lime);
  color: var(--lime);
}

.keyed-hint {
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

/* ---- the gauge ---- */

.gauge {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "readout lever"
    "meaning meaning";
  align-items: center;
  gap: 4px clamp(20px, 4vw, 56px);
  padding: clamp(14px, 2.4vw, 26px) 0 clamp(12px, 2vw, 20px);
}

/* the large mono readout */

.readout {
  grid-area: readout;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(46px, 9.6vw, 104px);
  line-height: 0.86;
  letter-spacing: -0.055em;
  display: flex;
  align-items: baseline;
  gap: 0.02em;
  color: var(--faint);
  transition: color 260ms ease;
  user-select: none;
}

.readout-word { opacity: 0.5; }

.readout-sign {
  display: inline-block;
  width: 0.62em;
  text-align: center;
  transition: transform 300ms cubic-bezier(0.3, 1.6, 0.5, 1), color 260ms ease;
}

.readout[data-on="true"] { color: var(--lime); }
.readout[data-on="false"] { color: var(--dim); }

.readout[data-on="true"] .readout-sign {
  transform: translateY(-0.06em) scale(1.04);
}

/* the lever assembly */

.lever {
  grid-area: lever;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 12px;
}

.lever-mark {
  position: relative;
  z-index: 2;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--faint);
  transition: color 220ms ease, opacity 220ms ease;
  opacity: 0.5;
}

.lever-mark-off.is-hot { color: var(--dim); opacity: 1; }

.lever-mark-on {
  order: 3;
  opacity: 0.32;
}

.lever-mark-on.is-hot { color: var(--lime); opacity: 1; }

.throw {
  position: relative;
  order: 2;
  display: grid;
  grid-template-rows: auto auto;
  gap: 7px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.throw:focus-visible { outline: none; }

.throw:focus-visible .throw-track {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -2px 6px rgba(0, 0, 0, 0.7),
    0 0 0 2px var(--field),
    0 0 0 3px var(--lime);
}

/* the plinth */

.throw-screws {
  position: absolute;
  inset: -6px 0 auto 0;
  height: 56px;
  border-radius: 4px;
  background: linear-gradient(180deg, #202019, #17170f);
  border: 1px solid #000;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  pointer-events: none;
}

.screw {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #55554c, #14140f 70%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7);
}

.screw:first-child { top: 5px; left: 5px; }
.screw:last-child { bottom: 5px; right: 5px; }

.throw-track {
  position: relative;
  display: block;
  width: var(--throw-w);
  height: 44px;
  margin-top: 0;
  border-radius: 4px;
  background: linear-gradient(180deg, #0b0b0a, #1d1d18 42%, #0e0e0c);
  border: 1px solid #000;
  box-shadow:
    inset 0 2px 7px rgba(0, 0, 0, 0.92),
    inset 0 -1px 0 rgba(255, 255, 255, 0.045),
    0 1px 0 rgba(255, 255, 255, 0.05);
  transition: background 420ms ease;
}

.throw[data-on="true"] .throw-track {
  background: linear-gradient(180deg, #0b0b0a, #26261c 42%, #10100c);
}

/* detent ribs across the travel */

.throw-detent {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.11), transparent);
  pointer-events: none;
}

.throw-detent:nth-child(1) { left: 38%; }
.throw-detent:nth-child(2) { left: 50%; }
.throw-detent:nth-child(3) { left: 62%; }

/* the knob */

.throw-knob {
  position: absolute;
  top: 3px;
  left: var(--seat-left);
  width: var(--knob-w);
  height: calc(44px - 8px);
  border-radius: 3px;
  background: linear-gradient(178deg, #8d8d80 0%, #6e6e63 22%, #4a4a42 58%, #303028 100%);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.85),
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 -2px 3px rgba(0, 0, 0, 0.5) inset;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition:
    left 340ms cubic-bezier(0.34, 1.42, 0.44, 1),
    background 420ms ease,
    box-shadow 340ms ease;
}

.throw[data-on="true"] .throw-knob {
  left: var(--seat-right);
  background: linear-gradient(178deg, #f2f4a8 0%, #d6da6c 22%, #a8ac4d 62%, #7c8038 100%);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.9),
    0 0 14px rgba(250, 255, 105, 0.26),
    0 1px 0 rgba(255, 255, 255, 0.42) inset,
    0 -2px 3px rgba(0, 0, 0, 0.4) inset;
}

/* grip ridges on the knob */

.knob-grip {
  width: 60%;
  height: 34%;
  background: repeating-linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.34) 0 1px,
    transparent 1px 5px
  );
  border-radius: 1px;
  opacity: 0.8;
}

.knob-cap {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset;
}

/* the state caption — flips */

.throw-cap {
  justify-self: start;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
  transition: color 260ms ease;
}

.throw[data-on="true"] .throw-cap { color: var(--lime); }

/* the meaning line */

.meaning {
  grid-area: meaning;
  margin: 0;
  max-width: 74ch;
  font-size: 11.5px;
  line-height: 1.62;
  color: var(--dim);
  letter-spacing: 0.01em;
}

.meaning-on { display: none; }
.meaning-off { display: inline; }
.gauge[data-on="true"] .meaning-on { display: inline; }
.gauge[data-on="true"] .meaning-off { display: none; }

.meaning code { color: var(--ink); }

/* ---- the tail, the bulk of the page ---- */

.tail {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--panel-hi);
  padding-top: 11px;
}

.tail-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  flex: 0 0 auto;
}

.tail-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--dim);
}

.tail-count {
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.06em;
  margin-right: auto;
}

.copy {
  padding: 4px 11px;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.copy:hover { color: var(--lime); border-color: var(--dim); }

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

.copy[data-did="ok"] { color: var(--lime); border-color: var(--lime); }
.copy[data-did="fail"] { color: var(--err); border-color: var(--err); }

.out {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  background: #0d0d0c;
  border: 1px solid var(--panel-hi);
  border-radius: 3px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.62;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.out::-webkit-scrollbar { width: 8px; height: 8px; }
.out::-webkit-scrollbar-track { background: transparent; }
.out::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 4px;
}
.out::-webkit-scrollbar-thumb:hover { background: var(--faint); }

.row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 1px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.r-ts { color: var(--faint); }
.r-lv { color: var(--dim); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.06em; }
.r-tx { color: var(--ink); }

.row[data-level="warn"] .r-lv { color: var(--warn); }
.row[data-level="error"] .r-lv { color: var(--err); }
.row[data-level="error"] .r-tx { color: var(--err); }
.row[data-level="info"] .r-lv { color: var(--faint); }

.row.is-local { opacity: 0.66; }
.row.is-local .r-ts { color: #3a3a34; }

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

.empty[hidden] { display: none; }

/* the execCommand fallback's scratch field, never seen */

.clip-fallback {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

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

.status {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 0 12px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  transition: background 200ms ease, box-shadow 200ms ease;
}

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

.status[data-state="open"] .led {
  background: var(--lime);
  box-shadow: 0 0 7px rgba(250, 255, 105, 0.6);
}

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

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

.sdiv { color: var(--faint); }

.surl {
  color: var(--faint);
  text-transform: none;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.snote {
  color: var(--dim);
  text-transform: none;
  letter-spacing: 0.02em;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.28; }
}

/* ---- reduced motion — the switch still moves, it just stops bouncing ---- */

@media (prefers-reduced-motion: reduce) {
  .throw-knob { transition: left 120ms linear, background 120ms linear; }
  .readout-sign { transition: none; }
  .status[data-state="connecting"] .led { animation: none; opacity: 0.75; }
}

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

@media (max-width: 620px) {
  .gauge {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "readout"
      "lever"
      "meaning";
    gap: 12px;
    justify-items: start;
  }
  .readout { font-size: clamp(40px, 15vw, 72px); }
  .keyed-hint { display: none; }
  .row {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0 8px;
    padding: 3px 0;
  }
  .r-lv { grid-column: 2; }
  .r-tx { grid-column: 1 / -1; margin-top: 1px; }
}
