:root {
    color-scheme: dark;
    --page: #0a0a0d;
    --surface: #131318;
    --surface-2: #1a1a21;
    --stroke: rgba(255, 255, 255, 0.07);
    --stroke-strong: rgba(255, 255, 255, 0.12);
    --text: #f5f5f7;
    --muted: #a3a3ad;
    --quiet: #6e6e78;
    --accent: #ff3347;
    --accent-soft: rgba(255, 51, 71, 0.12);
    --download: #ff5a6b;
    --upload: #ffae5c;
    --ping: #7cc4ff;
    --jitter: #b8a1ff;
    --good: #3ddc97;
    --warn: #ffc15e;
    --bad: #ff6b6b;
    --radius: 22px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    background: var(--page);
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--page);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(60rem 36rem at 78% -8%, rgba(255, 51, 71, 0.14), transparent 70%),
        radial-gradient(40rem 30rem at -10% 40%, rgba(255, 138, 92, 0.06), transparent 70%);
}

a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

/* Top bar */

.topbar,
.page {
    position: relative;
    z-index: 1;
    width: min(1160px, calc(100% - 48px));
    margin-inline: auto;
}

.topbar {
    display: flex;
    height: 76px;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
}

.brand img { display: block; border-radius: 9px; }

.brand__name {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: #d9d9df;
}

.brand__name strong { font-weight: 750; color: #fff; }

.topbar__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--stroke-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: #e4e4ea;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 150ms ease, border-color 150ms ease;
}

.topbar__link:hover {
    border-color: rgba(255, 51, 71, 0.45);
    background: var(--accent-soft);
}

/* Layout */

.page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 520px);
    grid-template-areas:
        "copy    test"
        "usage   test"
        "history test"
        "explain explain"
        "footer  footer";
    column-gap: 56px;
    row-gap: 28px;
    padding-top: 40px;
    align-items: start;
}

.copy { grid-area: copy; padding-top: 28px; }
.test-card { grid-area: test; }
.usage { grid-area: usage; }
.history { grid-area: history; }
.explain { grid-area: explain; margin-top: 36px; }
.page-footer { grid-area: footer; }

/* Copy */

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 7px 13px;
    border: 1px solid rgba(255, 51, 71, 0.25);
    border-radius: 999px;
    background: var(--accent-soft);
    color: #ffb3bb;
    font-size: 13px;
    font-weight: 600;
}

.eyebrow__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(255, 51, 71, 0.8);
}

h1 {
    margin: 22px 0 18px;
    font-size: clamp(42px, 5.6vw, 68px);
    font-weight: 780;
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.accent {
    background: linear-gradient(95deg, #ff3347, #ff8a5c);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lede {
    max-width: 480px;
    margin: 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.6;
}

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin: 26px 0 0;
    padding: 0;
    list-style: none;
}

.facts li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #cfcfd6;
    font-size: 14px;
}

.facts li span[aria-hidden="true"] { color: var(--good); font-weight: 700; }

/* Test card */

.test-card {
    padding: 24px;
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(26, 26, 33, 0.96), rgba(19, 19, 24, 0.96));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.test-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.server { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.server__label {
    color: var(--quiet);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.server__select {
    width: min(280px, 100%);
    max-width: 100%;
    margin-top: 2px;
    padding: 8px 34px 8px 12px;
    border: 1px solid var(--stroke-strong);
    border-radius: 12px;
    background-color: #1d1d25;
    background-image: linear-gradient(45deg, transparent 50%, #a3a3ad 50%), linear-gradient(135deg, #a3a3ad 50%, transparent 50%);
    background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    color: #f0f0f5;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.server__select:hover:not(:disabled) { border-color: rgba(255, 51, 71, 0.45); }
.server__select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.server__select:disabled { cursor: progress; opacity: 0.65; }
.server__select option { background: #1d1d25; color: #f0f0f5; }

.server__name {
    min-height: 16px;
    overflow: hidden;
    color: var(--quiet);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: 1px solid var(--stroke-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #d4d4db;
    font-size: 13px;
    font-weight: 600;
}

.status-pill::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.status-pill[data-state="running"] { color: var(--upload); border-color: rgba(255, 174, 92, 0.3); background: rgba(255, 174, 92, 0.08); }
.status-pill[data-state="running"]::before { animation: pulse 900ms ease-in-out infinite alternate; }
.status-pill[data-state="ready"] { color: var(--good); border-color: rgba(61, 220, 151, 0.3); background: rgba(61, 220, 151, 0.08); }
.status-pill[data-state="error"] { color: var(--bad); border-color: rgba(255, 107, 107, 0.3); background: rgba(255, 107, 107, 0.08); }

/* Gauge */

.gauge {
    position: relative;
    width: min(320px, 100%);
    aspect-ratio: 1;
    margin: 6px auto -34px;
}

.gauge__svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.gauge__track,
.gauge__fill {
    fill: none;
    stroke-width: 14px;
    stroke-linecap: round;
    /* 270° arc starting bottom-left; arc length = 2πr × 0.75 */
    stroke-dasharray: 556.06 1000;
    transform: rotate(135deg);
    transform-origin: 150px 150px;
}

.gauge__track { stroke: #25252e; }

.gauge__fill {
    stroke-dashoffset: 556.06;
    transition: stroke-dashoffset 260ms ease-out;
    filter: drop-shadow(0 0 10px rgba(255, 51, 71, 0.45));
}

.gauge__ticks text {
    fill: #6e6e78;
    font-size: 11px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: middle;
}

.gauge__knob {
    fill: #fff;
    stroke: var(--accent);
    stroke-width: 4px;
    opacity: 0;
    transition: opacity 200ms ease;
}

.gauge__knob.is-visible { opacity: 1; }

.gauge__readout {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 34px 0 0;
}

.gauge__label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.gauge__value {
    margin: 4px 0 2px;
    font-size: clamp(46px, 11vw, 62px);
    font-weight: 750;
    line-height: 1;
    letter-spacing: -0.05em;
    font-variant-numeric: tabular-nums;
}

.gauge__unit {
    min-height: 18px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 500;
}

.progress {
    width: 62%;
    height: 4px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 999px;
    background: #25252e;
}

.progress__bar {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ff3347, #ff8a5c);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 200ms ease-out;
}

.status-message {
    min-height: 22px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

/* Steps */

.steps {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin: 16px 0 18px;
    padding: 0;
    list-style: none;
}

.step {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--quiet);
    font-size: 14px;
    font-weight: 600;
    transition: color 150ms ease;
}

.step__dot {
    width: 9px;
    height: 9px;
    border: 2px solid #3a3a44;
    border-radius: 50%;
    transition: all 150ms ease;
}

.step.is-active { color: #fff; }
.step.is-active .step__dot { border-color: var(--upload); background: var(--upload); box-shadow: 0 0 10px rgba(255, 174, 92, 0.7); }
.step.is-done { color: #cfeee0; }
.step.is-done .step__dot { border-color: var(--good); background: var(--good); }

/* Start button */

.start-button {
    display: flex;
    width: 100%;
    min-height: 56px;
    align-items: center;
    justify-content: center;
    gap: 11px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(100deg, #ff3347, #ff6b57);
    box-shadow: 0 14px 34px rgba(255, 51, 71, 0.3);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 17px;
    font-weight: 750;
    transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.start-button:hover:not(:disabled) {
    filter: brightness(1.07);
    box-shadow: 0 18px 40px rgba(255, 51, 71, 0.38);
    transform: translateY(-1px);
}

.start-button:active:not(:disabled) { transform: translateY(1px); }

.start-button:disabled {
    cursor: progress;
    background: #2a2a33;
    box-shadow: none;
    color: #c7c7cf;
}

.start-button__icon { font-size: 13px; }
.start-button.is-running .start-button__icon { animation: pulse 900ms ease-in-out infinite alternate; }

/* Results */

.results {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.metric {
    position: relative;
    min-width: 0;
    padding: 14px 16px 13px;
    overflow: hidden;
    border: 1px solid var(--stroke);
    border-radius: 16px;
    background: var(--surface-2);
}

.metric::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--metric-color);
    content: "";
}

.metric--download { --metric-color: var(--download); }
.metric--upload { --metric-color: var(--upload); }
.metric--ping { --metric-color: var(--ping); }
.metric--jitter { --metric-color: var(--jitter); }

.metric__label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.metric__label span[aria-hidden="true"] { color: var(--metric-color); font-size: 15px; }

.metric__reading {
    margin: 8px 0 2px;
    color: var(--muted);
    font-size: 14px;
}

.metric__reading strong {
    margin-right: 3px;
    color: #fff;
    font-size: 28px;
    font-weight: 720;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
}

.metric__note {
    display: block;
    overflow: hidden;
    color: var(--quiet);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transfer-note {
    margin: 14px 0 0;
    color: var(--quiet);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

/* Usage verdict */

.usage {
    padding: 22px;
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    background: rgba(19, 19, 24, 0.7);
}

.usage__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.usage h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.usage__hint { flex: 0 0 auto; color: var(--quiet); font-size: 13px; white-space: nowrap; }

.usage__list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.usage__item {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    color: #dcdce3;
    font-size: 15px;
}

.usage__state {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3a3a44;
}

.usage__item em {
    color: var(--quiet);
    font-size: 13px;
    font-style: normal;
    font-weight: 600;
}

.usage__item[data-state="ok"] .usage__state { background: var(--good); box-shadow: 0 0 10px rgba(61, 220, 151, 0.55); }
.usage__item[data-state="ok"] em { color: var(--good); }
.usage__item[data-state="limit"] .usage__state { background: var(--warn); }
.usage__item[data-state="limit"] em { color: var(--warn); }
.usage__item[data-state="ko"] .usage__state { background: var(--bad); }
.usage__item[data-state="ko"] em { color: var(--bad); }

.usage__note {
    margin: 12px 0 0;
    color: var(--quiet);
    font-size: 12px;
}

/* Share */

.share-button {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin-top: 10px;
    border: 1px solid var(--stroke-strong);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: #e8e8ee;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 650;
    transition: background 150ms ease, border-color 150ms ease;
}

.share-button:hover { border-color: rgba(255, 51, 71, 0.45); background: var(--accent-soft); }
.share-button[hidden] { display: none; }

/* History */

.history {
    padding: 22px;
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    background: rgba(19, 19, 24, 0.7);
}

.history h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.history__clear {
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--quiet);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.history__clear:hover { color: var(--accent); }
.history__clear[hidden] { display: none; }

.history__summary {
    margin: 0 0 12px;
    color: #dcdce3;
    font-size: 14px;
    font-weight: 600;
}

.history__list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.history__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 14px;
    row-gap: 2px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
}

.history__when { color: var(--quiet); font-size: 13px; font-variant-numeric: tabular-nums; }
.history__values { color: #e6e6ec; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.history__server { grid-column: 1 / -1; overflow: hidden; color: var(--quiet); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.history__empty {
    margin: 0;
    color: var(--quiet);
    font-size: 13px;
    line-height: 1.5;
}

/* Explanations */

.explain h2 {
    margin: 0 0 16px;
    font-size: 24px;
    font-weight: 720;
    letter-spacing: -0.03em;
}

.explain__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.explain__card {
    padding: 22px;
    border: 1px solid var(--stroke);
    border-radius: 18px;
    background: rgba(19, 19, 24, 0.7);
}

.explain__icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 18px;
    font-weight: 700;
}

.explain__icon--download { color: var(--download); }
.explain__icon--upload { color: var(--upload); }
.explain__icon--ping { color: var(--ping); }

.explain h3 {
    margin: 14px 0 6px;
    font-size: 16px;
    font-weight: 680;
}

.explain p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

/* Footer */

.page-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 10px;
    padding: 22px 0 34px;
    border-top: 1px solid var(--stroke);
    color: var(--quiet);
    font-size: 13px;
    line-height: 1.5;
}

@keyframes pulse {
    from { opacity: 0.35; }
    to { opacity: 1; }
}

/* Responsive */

@media (max-width: 980px) {
    .page {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "copy"
            "test"
            "usage"
            "history"
            "explain"
            "footer";
        row-gap: 22px;
        padding-top: 16px;
    }

    .copy { padding-top: 8px; }
    .test-card { width: min(560px, 100%); justify-self: center; }
    .usage,
    .history { width: min(560px, 100%); justify-self: center; }
    .explain { margin-top: 12px; }
}

@media (max-width: 720px) {
    .explain__grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
    .topbar,
    .page { width: calc(100% - 32px); }

    .topbar { height: 64px; }
    .topbar__link { padding: 8px 12px; font-size: 13px; }

    h1 { margin-top: 18px; }
    .lede { font-size: 16px; }
    .facts { flex-direction: column; gap: 8px; }

    .test-card { padding: 18px 16px; border-radius: 20px; }
    .steps { gap: 14px; }
    .step { font-size: 13px; }
    .metric { padding: 12px 13px; }
    .metric__reading strong { font-size: 24px; }
    .usage { padding: 18px 16px; }
    .usage h2 { font-size: 17px; }

    .page-footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
