.pcspeed-container,
.pcspeed-container * {
    box-sizing: border-box;
}

.pcspeed-container {
    --pcspeed-blue: #2563eb;
    --pcspeed-blue-dark: #1d4ed8;
    --pcspeed-blue-light: #dbeafe;
    --pcspeed-text: #1e293b;
    --pcspeed-muted: #64748b;
    --pcspeed-border: #dbeafe;
    --pcspeed-bg: #ffffff;
    --pcspeed-soft: #f8fafc;
    max-width: 820px;
    margin: 2rem auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--pcspeed-text);
}

.pcspeed-connection {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    border: 1px solid var(--pcspeed-border);
    border-radius: 14px;
    background: var(--pcspeed-border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.pcspeed-connection-item {
    min-width: 0;
    padding: 0.85rem 1rem;
    background: var(--pcspeed-bg);
    text-align: center;
}

.pcspeed-connection-label {
    display: block;
    margin-bottom: 0.25rem;
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.pcspeed-connection-item strong {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    color: #334155;
    font-size: 0.82rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pcspeed-ip-toggle {
    margin-left: 0.35rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--pcspeed-blue);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.pcspeed-test-card {
    padding: 1.5rem 2rem 1.35rem;
    border: 1px solid var(--pcspeed-border);
    border-radius: 18px;
    background: var(--pcspeed-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(37, 99, 235, 0.07);
}

.pcspeed-title {
    margin: 0 0 0.35rem;
    color: var(--pcspeed-text);
    font-size: clamp(1.1rem, 2.6vw, 1.4rem);
    font-weight: 750;
    line-height: 1.25;
    text-align: center;
}

.pcspeed-gauge {
    position: relative;
    width: min(100%, 510px);
    margin: 0 auto;
    aspect-ratio: 360 / 220;
}

.pcspeed-gauge svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.pcspeed-gauge-track,
.pcspeed-gauge-progress {
    fill: none;
    stroke-linecap: round;
    stroke-width: 18;
}

.pcspeed-gauge-track {
    stroke: #e2e8f0;
}

.pcspeed-gauge-progress {
    stroke: url(#pcspeed-gradient-fallback);
    stroke: #2563eb;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 0.3s ease;
}

.pcspeed-needle {
    transform: rotate(-90deg);
    transform-box: view-box;
    transform-origin: 180px 180px;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pcspeed-needle line {
    stroke: #1e293b;
    stroke-linecap: round;
    stroke-width: 5;
}

.pcspeed-needle circle {
    fill: var(--pcspeed-blue);
    stroke: #fff;
    stroke-width: 4;
}

.pcspeed-gauge-value {
    position: absolute;
    left: 50%;
    top: 51%;
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

.pcspeed-gauge-value strong {
    color: var(--pcspeed-text);
    font-size: clamp(2.4rem, 8vw, 4.8rem);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.06em;
    line-height: 1;
}

.pcspeed-gauge-value span {
    color: var(--pcspeed-muted);
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 600;
}

.pcspeed-status {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: fit-content;
    max-width: 100%;
    min-height: 1.35rem;
    margin: clamp(-2.6rem, -6vw, -1.6rem) auto 0.7rem;
    padding: 0 0.35rem;
    color: var(--pcspeed-muted);
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
}

.pcspeed-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}

.pcspeed-container.is-running .pcspeed-status-dot {
    background: var(--pcspeed-blue);
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45);
    animation: pcspeed-pulse 1.4s ease-out infinite;
}

.pcspeed-container.is-finished .pcspeed-status-dot {
    background: #16a34a;
}

@keyframes pcspeed-pulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.42); }
    70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.pcspeed-scale {
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    max-width: 510px;
    margin: 0 auto 1rem;
    color: #94a3b8;
    font-size: 0.72rem;
    text-align: center;
}

.pcspeed-scale span:first-child { text-align: left; }
.pcspeed-scale span:nth-child(6) { text-align: right; }
.pcspeed-scale small {
    position: absolute;
    right: 0;
    top: 1.2rem;
    font-size: 0.62rem;
}

.pcspeed-progress-wrap {
    max-width: 590px;
    margin: 0 auto 1rem;
}

.pcspeed-progress-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.45rem;
    color: var(--pcspeed-muted);
    font-size: 0.74rem;
    font-weight: 600;
}

.pcspeed-progress {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.pcspeed-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--pcspeed-blue);
    transition: width 0.35s ease;
}

.pcspeed-phase-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 auto 1rem;
}

.pcspeed-phase-tabs span {
    min-width: 86px;
    padding: 0.45rem 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    transition: all 0.2s ease;
}

.pcspeed-phase-tabs span.is-active {
    border-color: #93c5fd;
    background: #eff6ff;
    color: var(--pcspeed-blue);
}

.pcspeed-results-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0 auto 1.2rem;
}

.pcspeed-result-card {
    min-width: 0;
    padding: 0.9rem 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: var(--pcspeed-soft);
    text-align: center;
}

.pcspeed-result-card > span {
    display: block;
    margin-bottom: 0.25rem;
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 750;
    letter-spacing: 0.07em;
}

.pcspeed-result-card strong {
    color: var(--pcspeed-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pcspeed-result-card b {
    font-size: 1.15rem;
    font-weight: 750;
}

.pcspeed-result-card small {
    color: var(--pcspeed-muted);
    font-size: 0.68rem;
    font-weight: 600;
}

.pcspeed-download { border-top: 3px solid #2563eb; }
.pcspeed-upload { border-top: 3px solid #60a5fa; }
.pcspeed-ping { border-top: 3px solid #8b5cf6; }
.pcspeed-jitter { border-top: 3px solid #14b8a6; }

.pcspeed-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pcspeed-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 46px;
    padding: 0 1.25rem;
    border-radius: 11px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pcspeed-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.pcspeed-btn-primary {
    border: 1px solid var(--pcspeed-blue);
    background: var(--pcspeed-blue);
    color: #fff;
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.22);
}

.pcspeed-btn-primary:hover:not(:disabled) {
    border-color: var(--pcspeed-blue-dark);
    background: var(--pcspeed-blue-dark);
    transform: translateY(-1px);
}

.pcspeed-btn-secondary {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
}

.pcspeed-btn-secondary:hover:not(:disabled) {
    border-color: #93c5fd;
    background: #eff6ff;
    color: var(--pcspeed-blue);
}

.pcspeed-btn:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.pcspeed-error {
    margin: 0 auto 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: center;
}

.pcspeed-note {
    margin: 0;
    color: #94a3b8;
    font-size: 0.73rem;
    line-height: 1.55;
    text-align: center;
}

.pcspeed-history {
    margin-top: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--pcspeed-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.pcspeed-history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.pcspeed-history-heading > div {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.pcspeed-history-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: #eff6ff;
    color: var(--pcspeed-blue);
    font-size: 1rem;
    font-weight: 700;
}

.pcspeed-history h3 {
    margin: 0;
    color: var(--pcspeed-text);
    font-size: 1rem;
}

.pcspeed-history-heading small {
    color: #94a3b8;
    font-size: 0.68rem;
}

.pcspeed-history-list {
    display: grid;
    gap: 0.55rem;
}

.pcspeed-history-row {
    display: grid;
    grid-template-columns: minmax(130px, 1.2fr) repeat(4, minmax(70px, 0.8fr));
    align-items: center;
    gap: 0.6rem;
    padding: 0.72rem 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    background: #f8fafc;
}

.pcspeed-history-date strong,
.pcspeed-history-metric strong {
    display: block;
    color: #334155;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.pcspeed-history-date small,
.pcspeed-history-metric span {
    display: block;
    color: #94a3b8;
    font-size: 0.62rem;
}

.pcspeed-history-metric {
    text-align: center;
}

.pcspeed-history-empty {
    padding: 1rem;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    color: #94a3b8;
    font-size: 0.78rem;
    text-align: center;
}

@media (max-width: 680px) {
    .pcspeed-container {
        display: flex;
        flex-direction: column;
        margin: 1rem auto;
    }
    .pcspeed-test-card {
        order: 1;
        padding: 1.15rem 1rem;
        border-radius: 15px;
    }
    .pcspeed-title {
        margin-bottom: 0.2rem;
        font-size: 1.08rem;
    }
    .pcspeed-connection {
        order: 2;
        grid-template-columns: 1fr;
        margin-top: 1rem;
        margin-bottom: 0;
    }
    .pcspeed-history { order: 3; }
    .pcspeed-connection-item { padding: 0.65rem 0.8rem; }
    .pcspeed-results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pcspeed-actions { flex-direction: column; }
    .pcspeed-btn { width: 100%; }
    .pcspeed-history-heading { align-items: flex-start; flex-direction: column; }
    .pcspeed-history-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pcspeed-history-date { grid-column: 1 / -1; padding-bottom: 0.45rem; border-bottom: 1px solid #e2e8f0; }
}

@media (prefers-reduced-motion: reduce) {
    .pcspeed-container *,
    .pcspeed-container *::before,
    .pcspeed-container *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
