/* SPEEDTEST — high-tech / hacker terminal UI. Pure CSS, no CDN, no web fonts. */

:root {
  --bg: #04070a;
  --bg-panel: rgba(7, 16, 14, 0.72);
  --line: rgba(0, 255, 156, 0.14);
  --line-soft: rgba(0, 255, 156, 0.07);
  --green: #00ff9c;
  --green-dim: #0b8a5c;
  --cyan: #00e5ff;
  --lime: #c6ff00;
  --amber: #ffb000;
  --red: #ff3860;
  --ink: #d6ffe9;
  --muted: #4f7d6c;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --glow: 0 0 12px rgba(0, 255, 156, 0.45);
  --r: 4px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--mono);
  overflow-x: hidden;
  padding-bottom: 40px;
  position: relative;
}
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }
[hidden] { display: none !important; }

/* Background FX ----------------------------------------------------- */
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(120% 100% at 50% 0%, #000 40%, transparent 90%);
}

.scanlines {
  position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: .45;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px);
  mix-blend-mode: multiply;
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(1000px 600px at 50% -10%, rgba(0,255,156,.10), transparent 60%),
    radial-gradient(800px 500px at 90% 10%, rgba(0,229,255,.06), transparent 55%);
}

.topbar, .console, .foot { position: relative; z-index: 2; }

/* Header ------------------------------------------------------------ */
.topbar {
  max-width: 1080px; margin: 0 auto; padding: 20px 22px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; letter-spacing: 2px; }
.brand-glyph { font-size: 22px; filter: drop-shadow(0 0 8px var(--green)); }
.brand-name { font-size: 22px; font-weight: 800; color: var(--ink); text-shadow: var(--glow); }
.brand-name .hl { color: var(--green); }
.brand-caret { color: var(--green); font-weight: 800; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.sysbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 1px; color: var(--muted);
  border: 1px solid var(--line); padding: 6px 11px; border-radius: var(--r);
  background: var(--bg-panel);
}
.chip .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green); animation: pulseDot 1.6s ease-in-out infinite;
}
.chip .dot.busy { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.chip .dot.err  { background: var(--red);   box-shadow: 0 0 8px var(--red); }
@keyframes pulseDot { 50% { opacity: .35; } }

/* Console panel ----------------------------------------------------- */
.console {
  max-width: 1080px; margin: 10px auto 0; padding: 16px 22px 0;
  display: flex; flex-direction: column; gap: 14px;
  border-top: 1px solid var(--line);
}

/* Tabs -------------------------------------------------------------- */
.tabbar {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px;
}
@media (max-width: 720px) { .tabbar { grid-template-columns: 1fr 1fr; } }

.tab {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; color: var(--muted); cursor: default;
  font-family: var(--mono); transition: border-color .2s, box-shadow .2s, background .2s;
  position: relative; overflow: hidden;
}
.tab::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: transparent; transition: background .2s, box-shadow .2s;
}
.tab.active { border-color: rgba(0,255,156,.5); background: rgba(0,255,156,.05); }
.tab.active::before { background: var(--green); box-shadow: 0 0 10px var(--green); }
.tab.live { border-color: rgba(0,229,255,.6); box-shadow: 0 0 20px rgba(0,229,255,.14); }
.tab.live::before { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.tab-ic { font-size: 15px; color: var(--green); }
.tab.active .tab-ic { text-shadow: 0 0 10px var(--green); }
.tab-meta { display: flex; flex-direction: column; gap: 3px; }
.tab-name { font-size: 11px; letter-spacing: 2px; color: var(--muted); }
.tab-val { display: flex; align-items: baseline; gap: 5px; }
.tab-val b { font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: -.5px; }
.tab.active .tab-val b { color: var(--green); text-shadow: var(--glow); }
.tab-val small { font-size: 11px; color: var(--muted); }

/* Progress ---------------------------------------------------------- */
.progress-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; letter-spacing: 1px; color: var(--muted); margin-bottom: 7px;
}
#progressPct { color: var(--green); font-weight: 700; }
.progress-track {
  position: relative; height: 12px; border: 1px solid var(--line); border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, rgba(0,255,156,.05) 0 6px, transparent 6px 12px),
    #050b09;
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--green), var(--lime));
  box-shadow: 0 0 14px rgba(0,255,156,.6);
  transition: width .2s ease;
}
.progress-fill.dl { background: linear-gradient(90deg, #0891b2, var(--cyan)); box-shadow: 0 0 14px rgba(0,229,255,.6); }
.progress-fill.ul { background: linear-gradient(90deg, #84cc16, var(--lime)); box-shadow: 0 0 14px rgba(198,255,0,.55); }
.progress-fill.ping { background: linear-gradient(90deg, var(--green-dim), var(--green)); }
#progressPhase .ph-dl { color: var(--cyan); }
#progressPhase .ph-ul { color: var(--lime); }
.progress-scan {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  width: 40px; transform: translateX(-60px); opacity: 0;
}
.running .progress-scan { opacity: 1; animation: sweep 1.3s linear infinite; }
@keyframes sweep { to { transform: translateX(1200px); } }

/* Quality summary --------------------------------------------------- */
.quality {
  display: flex; align-items: stretch; gap: 14px;
  border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px;
  background: rgba(5,11,9,.5);
}
.q-grade {
  flex: 0 0 auto; width: 74px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 42px; font-weight: 800; border-radius: 6px;
  color: #041109; background: var(--green); box-shadow: 0 0 18px rgba(0,255,156,.4);
  line-height: 1;
}
.q-grade.g-b { background: var(--cyan); box-shadow: 0 0 18px rgba(0,229,255,.4); }
.q-grade.g-c { background: var(--lime); box-shadow: 0 0 18px rgba(198,255,0,.4); }
.q-grade.g-d { background: var(--amber); box-shadow: 0 0 18px rgba(251,191,36,.4); }
.q-grade.g-e { background: #ff7a1a; box-shadow: 0 0 18px rgba(255,122,26,.4); color: #fff; }
.q-grade.g-f { background: var(--red); box-shadow: 0 0 18px rgba(255,56,96,.4); color: #fff; }
.q-items { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: center; }
.q-i { display: flex; flex-direction: column; gap: 3px; }
.q-l { font-size: 10px; letter-spacing: 1px; color: var(--muted); }
.q-i b { font-size: 22px; font-weight: 800; color: var(--ink); }
.q-u { font-size: 11px; color: var(--muted); }
.q-grade-label b { color: var(--green); text-shadow: var(--glow); }
@media (max-width: 640px) {
  .q-items { grid-template-columns: repeat(2, 1fr); }
  .q-grade { width: 60px; font-size: 34px; }
}

/* Gauge + chart row ------------------------------------------------- */
.speed-main { display: flex; gap: 18px; align-items: stretch; }
.gauge-col { flex: 0 0 42%; max-width: 410px; display: flex; flex-direction: column; justify-content: center; }
@media (max-width: 860px) {
  .speed-main { flex-direction: column; }
  .gauge-col { flex: none; width: 100%; max-width: 440px; margin: 0 auto; }
}

/* Gauge ------------------------------------------------------------- */
.gauge-stage { position: relative; width: 100%; margin: 0 auto; }
.gauge { width: 100%; height: auto; display: block; }

.arc-track { stroke: rgba(0,255,156,.10); stroke-width: 14; }
.arc-progress { stroke-width: 14; transition: stroke-dashoffset .12s linear; }

#ticks line { stroke: rgba(0,255,156,.30); stroke-width: 2; }
#ticks line.major { stroke: rgba(0,255,156,.7); stroke-width: 2.5; }
#ticks text { fill: var(--muted); font-family: var(--mono); font-size: 12px; font-weight: 700; }

.needle line {
  stroke: var(--green); stroke-width: 3; stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--green));
  transform-origin: 200px 200px;
  transition: transform .12s cubic-bezier(.22,.61,.36,1);
}
.needle-hub { fill: #041109; stroke: var(--green); stroke-width: 3; filter: drop-shadow(0 0 6px var(--green)); }

/* GO / live value inside gauge -------------------------------------- */
.gauge-center {
  position: absolute; left: 50%; top: 59%; transform: translate(-50%, -50%);
  display: grid; place-items: center;
}
.go-btn {
  position: relative; display: grid; place-items: center;
  width: 128px; height: 128px; border-radius: 50%;
  border: 2px solid var(--green); cursor: pointer;
  background: radial-gradient(circle at 50% 42%, #072a1f 0%, #041009 72%);
  color: var(--green); font-family: var(--mono);
  box-shadow: 0 0 22px rgba(0,255,156,.28), inset 0 0 18px rgba(0,255,156,.10);
  transition: transform .15s, box-shadow .25s, border-color .25s;
}
.go-btn::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 1px dashed rgba(0,255,156,.30); animation: spin 12s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.go-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 34px rgba(0,255,156,.45), inset 0 0 18px rgba(0,255,156,.14); }
.go-btn:active:not(:disabled) { transform: scale(.97); }
.go-btn:disabled { cursor: default; }

.go-go { font-size: 30px; font-weight: 800; letter-spacing: 4px; text-indent: 4px; color: #b8ffe4; text-shadow: 0 0 6px rgba(0,255,156,.55); }
.go-live { display: none; flex-direction: column; align-items: center; line-height: 1; }
.go-live b { font-size: 38px; font-weight: 800; color: var(--ink); text-shadow: 0 0 10px rgba(0,255,156,.45); letter-spacing: -1px; }
.go-unit { font-size: 12px; color: var(--muted); font-style: normal; margin-top: 5px; letter-spacing: 2px; }

.restart-hint {
  display: block; margin: 14px auto 0; padding: 8px 18px;
  font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 2px;
  color: #041109; background: var(--green); border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: 0 0 16px rgba(0,255,156,.45); transition: transform .15s, box-shadow .2s;
}
.restart-hint:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(0,255,156,.6); }
.restart-hint:active { transform: scale(.97); }

.go-btn.running, .go-btn.done {
  background: radial-gradient(circle at 50% 42%, rgba(4,16,9,.9) 0%, rgba(4,10,8,.55) 72%);
  box-shadow: 0 0 18px rgba(0,255,156,.18); border-color: rgba(0,255,156,.35);
}
.go-btn.running .go-go, .go-btn.done .go-go { display: none; }
.go-btn.running .go-live, .go-btn.done .go-live { display: flex; }
.go-btn.running::after { animation-duration: 2.4s; border-color: rgba(0,229,255,.45); }
.go-btn.done { cursor: pointer; }

/* Live chart -------------------------------------------------------- */
.chart-panel {
  flex: 1 1 0; min-width: 0;
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px;
  background: rgba(5,11,9,.5); display: flex; flex-direction: column; gap: 8px;
}
.chart-block { flex: 1 1 0; display: flex; flex-direction: column; min-height: 0; }
.chart-block + .chart-block { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.chart-legend { display: flex; align-items: center; gap: 18px; font-size: 12px; margin-bottom: 4px; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); letter-spacing: 1px; }
.chart-legend .lg i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.chart-legend .lg-dl i { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.chart-legend .lg-ul i { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.chart-title { margin-left: auto; color: var(--muted); }
.chart { width: 100%; flex: 1 1 auto; min-height: 120px; display: block; }
@media (max-width: 860px) { .chart { min-height: 120px; } }
@media (max-width: 560px) { .chart { min-height: 110px; } }

/* Target-server advanced input -------------------------------------- */
.server-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.server-input {
  flex: 1; min-width: 200px; max-width: 340px;
  background: #050b09; border: 1px solid var(--line); color: var(--green);
  font-family: var(--mono); font-size: 13px; padding: 8px 12px; border-radius: 4px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.server-input:focus { border-color: var(--green); box-shadow: 0 0 10px rgba(0,255,156,.25); }
.server-note { font-size: 11px; letter-spacing: .5px; }
.server-note.warn { color: var(--amber); }

/* Footer ------------------------------------------------------------ */
.foot {
  max-width: 1080px; margin: 0 auto; padding: 22px 22px 12px;
  font-size: 11px; letter-spacing: .5px; text-align: center;
}

/* Controls under gauge ---------------------------------------------- */
.controls {
  display: flex; align-items: center; justify-content: center; gap: 22px; flex-wrap: wrap;
  padding: 4px 0 2px;
}
.ctrl-group { display: flex; align-items: center; gap: 12px; }
.ctrl-label { font-size: 11px; letter-spacing: 2px; color: var(--muted); }
.ctrl-divider { width: 1px; height: 26px; background: var(--line); }
@media (max-width: 560px) { .ctrl-divider { display: none; } .controls { gap: 14px; } }

.segmented {
  display: inline-flex; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg-panel); padding: 3px; gap: 2px;
}
.segmented button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 1px;
  padding: 7px 13px; border-radius: 3px; transition: .2s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active {
  color: #041109; background: var(--green);
  box-shadow: 0 0 12px rgba(0,255,156,.5);
}


/* Mobile responsive tweaks ------------------------------------------ */
@media (max-width: 860px) {
  .chart-panel { gap: 12px; }
  .chart-block { flex: none; }
  .chart { flex: none; height: 150px; min-height: 150px; }
}
@media (max-width: 560px) {
  .topbar { padding: 16px 16px 8px; }
  .brand-name { font-size: 18px; }
  .console { padding-left: 16px; padding-right: 16px; }


  .controls { flex-direction: column; align-items: stretch; gap: 12px; }
  .ctrl-group { flex-direction: column; align-items: stretch; gap: 8px; }
  .ctrl-label { text-align: left; }
  .segmented { overflow-x: auto; }
  .tab-val b { font-size: 18px; }
  .go-btn { width: 116px; height: 116px; }
  .chart { height: 130px; min-height: 130px; }
}

