:root {
  --bg: #08090f;
  --panel: #12141f;
  --panel-soft: #191b29;
  --border: #2c3145;
  --text: #f4f5fb;
  --muted: #a2a8ba;
  --accent: #7567f0;
  --accent-strong: #9d93ff;
  --cyan: #62d0ff;
  --danger: #ff6b6b;
  --warning: #f6bd60;
  --ok: #31d0aa;
  --shadow: 0 18px 44px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
a,
select {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: .62rem .95rem;
}

button:hover:not(:disabled) {
  filter: brightness(1.07);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b0d14;
  color: var(--text);
  padding: .55rem .75rem;
}

pre,
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

pre {
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  border-radius: 8px;
  background: #090b0f;
  color: #dbe7ef;
  font-size: .8rem;
  line-height: 1.55;
  padding: .9rem;
  white-space: pre;
}

code {
  border-radius: 4px;
  background: #0a0d12;
  color: #dbe7ef;
  padding: .12rem .3rem;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 9, 15, .92);
  padding: .8rem clamp(1rem, 3vw, 2rem);
}

.qw-logo {
  display: inline-flex;
  align-items: baseline;
  gap: .08em;
  color: var(--text);
  font-weight: 400;
  letter-spacing: .12em;
  text-decoration: none;
}

.qw-logo .word {
  font-size: clamp(1.15rem, 2.5vw, 1.8rem);
}

.qw-logo .w {
  color: var(--accent);
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  font-weight: 700;
}

.nav-action {
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 700;
  padding: .55rem .85rem;
  text-decoration: none;
}

.page,
.footer {
  width: 100%;
  margin: 0 auto;
}

.page {
  min-height: calc(100vh - 73px);
  padding: .9rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 560px);
  gap: .9rem;
  align-items: stretch;
}

.primary-stack {
  display: grid;
  gap: .9rem;
  min-width: 0;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: .9rem;
}

.tools-header {
  display: grid;
  gap: .15rem;
  margin-bottom: .65rem;
}

.tools-header h1,
.test-header h2 {
  margin: 0;
  font-size: 1rem;
}

.tools-header p,
.test-header p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  overflow-wrap: anywhere;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .35rem;
  margin-bottom: .65rem;
}

.tab-btn {
  min-height: 32px;
  border-color: var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  padding: .38rem .45rem;
  font-size: .82rem;
}

.tab-btn.active {
  border-color: rgba(117, 103, 240, .72);
  background: rgba(117, 103, 240, .18);
  color: var(--text);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-note {
  color: var(--muted);
  font-size: .88rem;
  margin: 0 0 .7rem;
}

.endpoint-list {
  display: grid;
  gap: .4rem;
  margin: 0;
  padding-left: 1.15rem;
}

.endpoint-list code {
  font-size: .78rem;
}

.command-console {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #05070a;
  margin-bottom: .5rem;
}

.command-console:last-child {
  margin-bottom: 0;
}

.command-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border-bottom: 1px solid var(--border);
  background: #0a0d14;
  padding: .38rem .5rem .38rem .65rem;
}

.command-head span {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.command-head button {
  min-height: 28px;
  border-color: rgba(117, 103, 240, .48);
  background: rgba(117, 103, 240, .16);
  color: var(--text);
  font-size: .78rem;
  padding: .24rem .55rem;
}

.command-console pre {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .45rem;
  border-radius: 0;
  background: transparent;
  font-size: .74rem;
  line-height: 1.42;
  max-height: 9rem;
  overflow-x: auto;
  padding: .62rem;
}

.prompt {
  color: var(--ok);
  font-weight: 800;
}

.speed-panel {
  display: grid;
  align-content: start;
  gap: .85rem;
}

.test-header {
  display: grid;
  gap: .25rem;
}

.size-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.size-controls label {
  display: grid;
  gap: .35rem;
}

.size-controls span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.meter-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: .1rem 0 .45rem;
}

.meter {
  position: relative;
  display: grid;
  width: min(380px, 48vh, 78vw);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent) calc(var(--progress, 0) * 1%), #282b3f 0);
}

.meter::after {
  position: absolute;
  inset: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #0c0e16;
  content: "";
}

.meter-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.speed {
  font-size: clamp(3.2rem, 9vw, 5rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.unit {
  color: var(--muted);
  font-size: .95rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status {
  color: var(--cyan);
  font-size: .95rem;
  margin-top: .35rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  justify-content: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
}

.secondary-layout {
  margin-top: .9rem;
}

.stat {
  display: grid;
  gap: .2rem;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: .85rem;
}

.stat small {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
}

.stat strong {
  overflow-wrap: anywhere;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head h2,
.whoami-detail h3 {
  margin: 0;
}

.section-head h2 {
  font-size: 1.05rem;
}

.section-head p {
  color: var(--muted);
  font-size: .9rem;
  margin: .25rem 0 0;
}

.section-head p span {
  color: var(--cyan);
  font-weight: 700;
}

.identity-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
}

.identity-item {
  display: grid;
  gap: .2rem;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: .85rem;
}

.identity-item small {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
}

.identity-item strong {
  overflow-wrap: anywhere;
}

.whoami-detail {
  margin-top: 1rem;
}

.whoami-detail h3 {
  font-size: .9rem;
  margin-bottom: .55rem;
}

.header-list {
  display: grid;
  gap: .45rem;
  margin: 0;
}

.header-list div {
  display: grid;
  grid-template-columns: minmax(120px, .42fr) minmax(0, 1fr);
  gap: .7rem;
  border-bottom: 1px solid rgba(44, 49, 69, .72);
  padding-bottom: .45rem;
}

.header-list dt,
.header-list dd {
  min-width: 0;
}

.header-list dt {
  color: var(--muted);
  font-size: .82rem;
}

.header-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .82rem;
}

.terminal {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #05070a;
  min-width: 0;
}

.terminal-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
}

.terminal-head strong {
  margin-left: .25rem;
  font-size: .9rem;
}

.dot {
  width: .68rem;
  height: .68rem;
  border-radius: 50%;
  background: var(--danger);
}

.dot:nth-child(2) {
  background: var(--warning);
}

.dot:nth-child(3) {
  background: var(--ok);
}

.terminal-body {
  height: 100%;
  min-height: 420px;
  overflow: auto;
  padding: 1rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .88rem;
}

.log-line {
  min-height: 1.45rem;
  overflow-wrap: anywhere;
}

.time {
  color: #728095;
}

.info {
  color: var(--ok);
  font-weight: 700;
}

.cursor {
  display: inline-block;
  width: .55rem;
  height: 1rem;
  animation: blink 1s steps(1) infinite;
  background: var(--accent-strong);
  vertical-align: text-bottom;
}

.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  padding: .8rem .9rem 1rem;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .terminal-body {
    min-height: 240px;
  }

  .identity-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-action {
    width: 100%;
    text-align: center;
  }

  .stats,
  .size-controls,
  .identity-grid,
  .header-list div {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .command-head {
    align-items: center;
    flex-direction: row;
  }

  .command-head button {
    width: auto;
  }
}
