@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-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --case: #0b0d0a;
  --case-hi: #14180f;
  --bezel: #191d15;
  --bezel-2: #23281d;
  --bezel-edge: #2f3527;

  --tube: #04070a;
  --tube-2: #060b0d;

  --phos: #74ff9d;
  --phos-dim: rgba(116, 255, 157, 0.55);
  --phos-faint: rgba(116, 255, 157, 0.28);
  --phosphor-glow: rgba(116, 255, 157, 0.5);

  --amber: #ffc65c;
  --red: #ff6b5e;

  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter Tight", system-ui, sans-serif;

  --scan: rgba(0, 0, 0, 0.3);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  padding: clamp(12px, 2.4vw, 34px);
  background:
    radial-gradient(120% 90% at 50% 0%, #131711 0%, #080a07 55%, #050604 100%);
  color: var(--phos);
  font-family: var(--mono);
  -webkit-text-size-adjust: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- the case ---------- */

.case {
  width: min(1080px, 100%);
  height: min(780px, calc(100dvh - 2 * clamp(12px, 2.4vw, 34px)));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.4vw, 16px);
  padding: clamp(12px, 1.6vw, 20px);
  border-radius: 22px;
  background:
    linear-gradient(180deg, var(--bezel-2) 0%, var(--bezel) 42%, #12150f 100%);
  border: 1px solid var(--bezel-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 34px 70px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* ---------- bezel top ---------- */

.bezel-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px clamp(2px, 0.6vw, 8px) 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6d7a63;
}

.brand {
  color: #cfdcc6;
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: 0.2em;
  white-space: nowrap;
}
.brand-slash { color: var(--phos); opacity: 0.6; margin: 0 2px; }
.brand-sub { color: #6d7a63; font-weight: 400; letter-spacing: 0.14em; }

.plate {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #2b3124;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7);
  font-size: 10px;
  letter-spacing: 0.18em;
}
.plate + .plate { margin-left: 0; }
.plate-meta {
  margin-left: auto;
  color: #59654f;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  padding-right: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40ch;
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a4234;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.8);
}
.state { color: #7f8c74; }

/* LED per state */
.case[data-state="connecting"] .led { background: var(--amber); box-shadow: 0 0 8px var(--amber), 0 0 2px #000 inset; }
.case[data-state="connecting"] .state { color: var(--amber); }
.case[data-state="open"] .led { background: var(--phos); box-shadow: 0 0 9px var(--phosphor-glow), 0 0 2px #000 inset; }
.case[data-state="open"] .state { color: var(--phos); }
.case[data-state="closed"] .led { background: var(--red); box-shadow: 0 0 8px rgba(255, 107, 94, 0.7), 0 0 2px #000 inset; }
.case[data-state="closed"] .state { color: var(--red); }

/* ---------- the tube ---------- */

.screen {
  position: relative;
  min-height: 0;
  border-radius: 12px;
  padding: clamp(8px, 1vw, 13px);
  background: #05070a;
  border: 1px solid #050806;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.9),
    inset 0 0 34px rgba(0, 0, 0, 0.9);
}

.glass {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, 1.6vw, 22px) clamp(14px, 1.9vw, 26px) clamp(12px, 1.5vw, 18px);
  border-radius: 9px;
  background:
    radial-gradient(120% 115% at 50% 40%, #0a1a12 0%, #061009 70%, #030805 100%);
  overflow: hidden;
}

.out {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  font-size: clamp(12px, 1.22vw, 14.5px);
  line-height: 1.68;
  scrollbar-width: thin;
  scrollbar-color: #1e3327 transparent;
  overscroll-behavior: contain;
}
.out::-webkit-scrollbar { width: 7px; }
.out::-webkit-scrollbar-thumb { background: #1c3126; border-radius: 4px; }
.out::-webkit-scrollbar-track { background: transparent; }

/* ---------- boot text ---------- */

.boot { padding-bottom: 2px; }
.boot-line {
  margin: 0 0 4px;
  color: var(--phos-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 0 0 6px rgba(116, 255, 157, 0.16);
}
.boot-line em { color: var(--phos); font-style: normal; }
.dim { opacity: 0.5; }

/* ---------- received lines ---------- */

.logline {
  display: grid;
  grid-template-columns: auto 5.5ch minmax(0, 1fr);
  align-items: baseline;
  gap: 0 1ch;
  padding: 1px 0;
  text-shadow: 0 0 7px rgba(116, 255, 157, 0.26);
  animation: line-in 180ms ease-out both;
}

@keyframes line-in {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: none; }
}

.ll-ts {
  color: rgba(116, 255, 157, 0.4);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.ll-lvl {
  text-transform: lowercase;
  color: var(--phos-dim);
  letter-spacing: 0.06em;
}
.ll-txt {
  color: var(--phos);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.logline.is-warn .ll-lvl { color: var(--amber); }
.logline.is-warn .ll-txt { color: #c8f2c0; }
.logline.is-error .ll-lvl { color: var(--red); }
.logline.is-error .ll-txt { color: #ffc2bb; text-shadow: 0 0 8px rgba(255, 107, 94, 0.4); }
.logline.is-debug .ll-lvl,
.logline.is-trace .ll-lvl { color: rgba(116, 255, 157, 0.3); }
.logline.is-debug .ll-txt,
.logline.is-trace .ll-txt { color: var(--phos-dim); }

.logline.is-notice .ll-txt { color: var(--amber); }
.logline.is-notice .ll-lvl { color: rgba(255, 198, 92, 0.7); }

/* highlight the literal the whole page exists for */
.api-key-literal { color: var(--amber); text-shadow: 0 0 9px rgba(255, 198, 92, 0.45); }

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

.tail {
  display: flex;
  align-items: baseline;
  gap: 0.9ch;
  padding-top: clamp(8px, 1.1vw, 13px);
  margin-top: 4px;
  border-top: 1px solid rgba(116, 255, 157, 0.1);
  font-size: clamp(12px, 1.22vw, 14.5px);
  line-height: 1.6;
  flex: none;
  text-shadow: 0 0 7px rgba(116, 255, 157, 0.22);
}

.tail-ps1 { color: var(--phos); opacity: 0.85; flex: none; }

.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.02em;
  align-self: center;
  background: var(--phos);
  box-shadow: 0 0 10px var(--phosphor-glow);
  transform: translateY(0.12em);
  animation: blink 1.05s steps(1, end) infinite;
}

@keyframes blink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

.case:not([data-state="open"]) .cursor { animation: none; opacity: 0.32; }

.tail-note {
  color: var(--phos-faint);
  font-size: 0.92em;
  letter-spacing: 0.03em;
}

/* ---------- overlays: scanlines + vignette ---------- */

.scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--scan) 0px,
    var(--scan) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 1;
  z-index: 2;
}

.vig {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background:
    radial-gradient(115% 100% at 50% 48%, transparent 58%, rgba(0, 0, 0, 0.42) 86%, rgba(0, 0, 0, 0.7) 100%),
    linear-gradient(180deg, rgba(160, 255, 190, 0.045) 0%, transparent 14%);
}

/* ---------- front panel ---------- */

.panel {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.9fr);
  gap: clamp(10px, 1.4vw, 18px);
  padding: clamp(10px, 1.3vw, 15px) clamp(6px, 0.8vw, 10px) 2px;
}

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

.sw-cap {
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6f7d64;
}

.sw-body {
  display: flex;
  align-items: stretch;
  gap: 7px;
  min-width: 0;
}

.field {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 5px;
  border: 1px solid #333c2c;
  background: #0a0d08;
  color: var(--phos);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.85), inset 0 0 12px rgba(116, 255, 157, 0.05);
  outline: none;
  transition: border-color 120ms linear, box-shadow 120ms linear;
}
.field::placeholder { color: rgba(116, 255, 157, 0.24); }
.field:focus-visible {
  border-color: rgba(116, 255, 157, 0.55);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(116, 255, 157, 0.25), 0 0 12px rgba(116, 255, 157, 0.14);
}

.key-btn,
.copy,
.toggle {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 120ms linear, background 120ms linear, color 120ms linear, box-shadow 120ms linear;
}

.key-btn,
.copy {
  flex: none;
  padding: 9px 14px;
  border: 1px solid #3a4432;
  background: linear-gradient(180deg, #232a1d, #171c12);
  color: #c3d3b8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 4px rgba(0, 0, 0, 0.6);
}
.key-btn:hover,
.copy:hover,
.key-btn:focus-visible,
.copy:focus-visible {
  border-color: rgba(116, 255, 157, 0.5);
  color: var(--phos);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 12px rgba(116, 255, 157, 0.18);
}
.key-btn:active,
.copy:active { transform: translateY(1px); }

.copy.is-done {
  border-color: rgba(116, 255, 157, 0.7);
  color: var(--phos);
  background: linear-gradient(180deg, #2b3a24, #1b2415);
  box-shadow: 0 0 14px rgba(116, 255, 157, 0.25);
}

/* the DRQ switch */

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px 8px 12px;
  border: 1px solid #3a4432;
  background: linear-gradient(180deg, #1e2419, #14190f);
  color: #8d9c81;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.6);
  width: 100%;
  justify-content: flex-start;
}
.toggle:hover,
.toggle:focus-visible {
  border-color: rgba(116, 255, 157, 0.45);
  outline: none;
}

.toggle-led {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2f3a28;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.9);
  transition: background 120ms linear, box-shadow 120ms linear;
}

.toggle-sep { margin: 0 0.5ch; opacity: 0.4; }
.toggle-txt { letter-spacing: 0.1em; }

.toggle[aria-pressed="true"] {
  border-color: rgba(116, 255, 157, 0.6);
  color: var(--phos);
  background: linear-gradient(180deg, #24321c, #16200f);
}
.toggle[aria-pressed="true"] .toggle-led {
  background: var(--phos);
  box-shadow: 0 0 10px var(--phosphor-glow), inset 0 0 2px #000;
}

.sw-note {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: #5c6854;
  font-family: var(--sans);
}

/* keeps the copy fallback's textarea out of the flow and off the glass */
.clip-hold {
  position: fixed;
  top: -1000px;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- phone ---------- */

@media (max-width: 760px) {
  body { padding: 10px; align-items: stretch; }
  .case {
    height: auto;
    min-height: calc(100dvh - 20px);
    border-radius: 16px;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .panel { grid-template-columns: 1fr; gap: 12px; }
  .bezel-top { font-size: 10px; letter-spacing: 0.12em; gap: 10px; flex-wrap: wrap; }
  .plate-meta { max-width: 100%; }
  .logline { grid-template-columns: auto 6ch minmax(0, 1fr); gap: 0 0.7ch; }
  .screen { padding: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; opacity: 1; }
  .case:not([data-state="open"]) .cursor { opacity: 0.32; }
  .logline { animation: none; }
  .field, .key-btn, .copy, .toggle, .toggle-led { transition: none; }
  .key-btn:active, .copy:active { transform: none; }
}
