:root {
  color-scheme: dark;
  --ink: #171013;
  --panel: #271920;
  --line: #51373e;
  --coral: #ff7254;
  --pink: #ff78ad;
  --amber: #ffd076;
  --white: #fff1e6;
  --muted: #cdb2b5;
  --display: "Bahnschrift", "Aptos Display", "Trebuchet MS", sans-serif;
  --body: "Aptos", "Segoe UI", system-ui, sans-serif;
}

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

body {
  min-width: 280px;
  margin: 0;
  color: var(--white);
  background:
    radial-gradient(ellipse at 67% -14%, #54262f 0, transparent 56%),
    radial-gradient(ellipse at 9% 57%, #442319 0, transparent 47%),
    var(--ink);
  font: 400 1rem/1.5 var(--body);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--amber); }
button { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 5px; }

.shell { width: min(1140px, calc(100% - 5rem)); margin-inline: auto; }

.topbar, .footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.topbar {
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: .68rem;
  font-family: var(--display);
  font-weight: 750;
  letter-spacing: .12em;
}

.wordmark svg { color: var(--coral); flex-shrink: 0; }
.topbar nav, .footer nav { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.45rem; }
.topbar nav a { font-size: .9rem; font-weight: 650; }
.portal-link { padding: .42rem .73rem; border: 1px solid var(--line); border-radius: 100px; }
.portal-link span { padding-inline-start: .18rem; color: var(--coral); }

.test-layout { padding-block: clamp(1.65rem, 4.3vw, 3.75rem) clamp(1.9rem, 4vw, 3.15rem); }
.intro { margin-bottom: clamp(1rem, 3vw, 2.2rem); }

.section-label {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 .65rem;
  color: var(--coral);
  font-size: .86rem;
  font-weight: 750;
}

.section-label span { width: 1.7rem; height: 2px; background: currentColor; }

h1 {
  margin: 0;
  font: 740 clamp(3.4rem, 9.1vw, 8rem)/.94 var(--display);
  letter-spacing: -.082em;
  text-wrap: balance;
}

.commands {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1.2rem;
  margin-top: 1rem;
}

.lead { max-width: 36ch; margin: .2rem 0 0; color: var(--muted); font-size: clamp(.98rem, 1.65vw, 1.16rem); }
.command-controls { min-width: min(21rem, 45%); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }

.start-button, .copy-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .63rem 1rem;
  border-radius: .4rem;
  font-weight: 750;
  cursor: pointer;
}

.start-button {
  color: var(--ink);
  background: var(--coral);
  border: 1px solid transparent;
  box-shadow: 0 0 1.8rem #ff725442;
}

.start-button:hover { background: var(--amber); }
.start-button:active { transform: translateY(1px); }
.start-button:disabled { opacity: .65; cursor: wait; }
.copy-button { color: var(--white); background: transparent; border: 1px solid var(--line); font-size: .81rem; }
.copy-button:hover { border-color: var(--pink); }
.status { min-height: 1.35rem; margin: .45rem 0 0; color: var(--muted); font-size: .8rem; }

.instrument {
  --signal: var(--coral);
  --signal-soft: var(--amber);
  position: relative;
  overflow: hidden;
  border: 1px solid #825057;
  border-radius: .85rem;
  background: var(--panel);
  box-shadow: 0 22px 72px #09040782, inset 0 1px #ffffff18;
}

.instrument[data-phase="latency"] { --signal: var(--amber); --signal-soft: #fff1bb; }
.instrument[data-phase="upload"] { --signal: var(--pink); --signal-soft: #ffd4e7; }
.instrument[data-mode="error"] { --signal: #ffb5c0; }

.instrument-header, .instrument-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .69rem 1rem;
  background: #23171c;
  font-size: .83rem;
}

.instrument-header { border-bottom: 1px solid var(--line); }
.instrument-title, .state { display: flex; align-items: center; gap: .5rem; }
.instrument-title { font-weight: 650; }
.instrument-title svg { flex-shrink: 0; color: var(--coral); }
.state { color: var(--muted); white-space: nowrap; }
.state-light, .signal-live i { width: .48rem; height: .48rem; border-radius: 100%; background: var(--signal); box-shadow: 0 0 .65rem var(--signal); }

.optics {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, .97fr) minmax(0, 1.03fr);
  align-items: center;
  gap: clamp(.45rem, 2vw, 1.75rem);
  padding: .35rem clamp(.7rem, 2.4vw, 1.75rem) .65rem;
  background:
    radial-gradient(ellipse at 35% 35%, #70353b91, transparent 54%),
    linear-gradient(127deg, #3b222b, #1c1317 78%);
}

.fiber {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .57;
  pointer-events: none;
}

.gauge { position: relative; display: grid; place-items: center; }
.dial { display: block; width: min(100%, 460px); height: auto; }
.dial path:not([fill]) { fill: none; }
.guide { stroke: #a56b77; stroke-width: 1; opacity: .58; }
.orbit { stroke: #af7982; stroke-width: 1; opacity: .48; }
.ticks { stroke: #edbbc4; stroke-width: 4; stroke-dasharray: .19 1.78; opacity: .58; }
.track { stroke: #ba7e80; stroke-width: 7; stroke-linecap: round; opacity: .37; }
.inner-track { stroke: #e9acaa; stroke-width: 1; opacity: .45; }
.beam-low { stop-color: #a94c60; }
.beam-mid { stop-color: var(--signal); }
.beam-high { stop-color: var(--signal-soft); }

.beam {
  stroke: url(#beam);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .3s ease-out;
}

.beam-dot { fill: var(--signal); filter: drop-shadow(0 0 6px var(--signal)); opacity: 0; }
.instrument[data-mode="running"] .beam-dot, .instrument[data-mode="complete"] .beam-dot { opacity: 1; }
.scale { fill: var(--white); text-anchor: middle; font: 600 13px var(--body); font-variant-numeric: tabular-nums; }

.readout {
  position: absolute;
  inset: 44% auto auto 50%;
  display: grid;
  min-width: 50%;
  justify-items: center;
  transform: translate(-50%, -33%);
  color: var(--muted);
  font-size: clamp(.7rem, 1.3vw, .87rem);
  text-shadow: 0 1px 10px var(--ink);
}

.readout strong {
  color: var(--white);
  font: 700 clamp(2.95rem, 6.9vw, 5.2rem)/1.04 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.081em;
}

.readout-unit { color: var(--signal-soft); font-weight: 720; }

.signal {
  min-width: 0;
  padding: .85rem .9rem .7rem;
  border: 1px solid #b3738070;
  border-radius: .5rem;
  background: #21161be8;
  box-shadow: inset 0 0 1.65rem #0f080b80;
}

.signal-heading { display: flex; align-items: start; justify-content: space-between; gap: .65rem; }
.signal-heading h2 { margin: 0; font-size: clamp(.88rem, 1.6vw, 1.03rem); line-height: 1.15; }
.signal-heading p { min-height: 1.1rem; margin: .22rem 0 .62rem; color: var(--muted); font-size: .72rem; }
.signal-live { display: inline-flex; align-items: center; gap: .38rem; color: var(--muted); font-size: .72rem; }
.signal-live i { width: .4rem; height: .4rem; box-shadow: none; opacity: .42; }
.instrument[data-mode="running"] .signal-live i { animation: signal-pulse 1.1s ease-in-out infinite alternate; opacity: 1; }

@keyframes signal-pulse {
  from { box-shadow: 0 0 0 var(--signal); }
  to { box-shadow: 0 0 .68rem var(--signal); }
}

.signal-grid { display: grid; grid-template-columns: 2.65rem minmax(0, 1fr); align-items: stretch; }
.signal-axis { display: flex; flex-direction: column; justify-content: space-between; padding: 0 .42rem 0 0; color: var(--muted); font-size: .66rem; text-align: right; font-variant-numeric: tabular-nums; }

.signal-surface {
  height: clamp(5rem, 12vw, 8.6rem);
  border: 1px solid #7b4a54;
  background:
    linear-gradient(to right, #6f444e 1px, transparent 1px) 0 0 / 10% 100%,
    linear-gradient(to bottom, #6f444e 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(#50303b5c, #251820);
}

.signal-surface svg { display: block; width: 100%; height: 100%; overflow: visible; }
.trace { fill: none; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.trace-download { stroke: var(--coral); filter: drop-shadow(0 0 4px #ff7254bb); }
.trace-upload { stroke: var(--pink); filter: drop-shadow(0 0 4px #ff78adbb); }
.point-download { fill: var(--coral); }
.point-upload { fill: var(--pink); }

.signal-legend { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .65rem; margin: .5rem 0 0 2.65rem; color: var(--muted); font-size: .66rem; }
.signal-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.signal-legend span:last-child { margin-inline-start: auto; }
.signal-legend i { width: .72rem; height: 2px; background: var(--coral); }
.signal-legend span:nth-child(2) i { background: var(--pink); }

.test-progress { height: 2px; background: #a56b7744; }
.test-progress span { display: block; width: 0; height: 100%; background: var(--signal); transition: width .25s ease-out; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; background: #22161c; }
.metric { min-width: 0; padding: .68rem .9rem .79rem; }
.metric + .metric { border-inline-start: 1px solid var(--line); }
.metric dt { display: flex; align-items: center; gap: .42rem; color: var(--muted); font-size: .78rem; }
.metric-symbol { display: inline-grid; width: 1.45rem; height: 1.45rem; place-items: center; border-radius: .28rem; background: #ff72541f; color: var(--coral); font-size: .98rem; line-height: 1; }
.metric-symbol.upload { background: #ff78ad22; color: var(--pink); }
.metric-symbol.ping, .metric-symbol.jitter { background: #ffd0761f; color: var(--amber); }
.metric dd { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 .25rem; margin: .25rem 0 0; }
.metric output { color: var(--white); font: 700 clamp(1.42rem, 2.6vw, 2.2rem)/1.06 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.055em; }
.metric dd span { color: var(--muted); font-size: .73rem; white-space: nowrap; }

.instrument-footer { padding-block: .36rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .67rem; }
.instrument-footer strong { color: var(--amber); font-weight: 640; letter-spacing: .06em; }
.measure-note { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 3rem; padding-block: 1.25rem 1.6rem; border-top: 1px solid var(--line); }
.measure-note h2 { margin: 0 0 .35rem; font: 700 .98rem/1.25 var(--display); }
.measure-note p { max-width: 58ch; margin: 0; color: var(--muted); font-size: .85rem; }
.footer { min-height: 66px; border-top: 1px solid var(--line); color: var(--muted); font-size: .77rem; }
.footer-divider { margin-inline: .25rem; color: var(--coral); }

@media (max-width: 920px) {
  .shell { width: min(100% - 3rem, 1140px); }
  .metric { padding-inline: .6rem; }
}

@media (max-width: 610px) {
  .shell { width: calc(100% - 2rem); }
  .topbar { min-height: 64px; }
  .topbar nav { justify-content: end; gap: .35rem .58rem; }
  .topbar nav a { font-size: .75rem; }
  .commands { flex-direction: column; gap: .65rem; margin-top: .65rem; }
  .lead { margin: 0; }
  .command-controls { min-width: 0; }
  .test-layout { padding-block: 1.85rem; }
  h1 { font-size: clamp(3.2rem, 12vw, 4.85rem); text-wrap: initial; }
  .optics { grid-template-columns: minmax(0, 1fr); gap: 0; padding: .16rem .75rem .75rem; }
  .fiber { height: 68%; }
  .dial { width: min(100%, 400px); }
  .signal { padding: .65rem .64rem .48rem; }
  .signal-heading p { margin-bottom: .42rem; }
  .signal-surface { height: 5.3rem; }
  .readout strong { font-size: clamp(3.25rem, 10vw, 5rem); }
}

@media (max-width: 430px) {
  .wordmark { font-size: .72rem; gap: .32rem; }
  .wordmark svg { width: 29px; height: 29px; }
  .topbar { gap: .38rem; }
  .topbar nav { gap: .38rem; }
  .topbar nav a { font-size: .71rem; }
  .portal-link { padding: .25rem .39rem; }
  .instrument-header { padding: .56rem .7rem; font-size: .72rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: .57rem .64rem; }
  .metric:nth-child(3) { border-inline-start: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .measure-note { grid-template-columns: minmax(0, 1fr); }
  .footer { flex-wrap: wrap; padding-block: .8rem; gap: .45rem; }
  .footer nav { gap: .65rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
