/* ===== Fast.com-Inspired Design ===== */
:root {
    --bg: #1a1a1a;
    --card: #242424;
    --border: #333;
    --primary: #10B981;
    --primary-light: #34D399;
    --text: #e5e5e5;
    --text-dim: #888;
    --text-muted: #666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ===== Header ===== */
header {
    padding: 2rem 0 1rem;
    text-align: center;
}

.logo-icon {
    margin-bottom: 0.5rem;
}

.brand {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}

.brand span {
    color: var(--primary);
}

/* ===== Main ===== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem 2rem;
    width: 100%;
    max-width: 700px;
}

.speed-label {
    font-size: 1.25rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.speed-display {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.speed-number {
    font-size: 8rem;
    font-weight: 300;
    line-height: 1;
    letter-spacing: -6px;
    color: var(--text-dim);
    transition: color 0.3s;
}

.speed-number.active {
    color: var(--text);
}

.speed-number.testing {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.speed-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 1.5rem;
    gap: 0.5rem;
}

.speed-unit {
    font-size: 1.5rem;
    color: var(--text-dim);
    font-weight: 400;
}

.restart-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
    pointer-events: none;
}

.restart-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.restart-btn:hover {
    background: var(--primary);
    color: var(--bg);
}

.restart-btn svg {
    width: 18px;
    height: 18px;
}

.restart-btn.spinning svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ===== More Info Button ===== */
.more-info-btn {
    padding: 0.75rem 2rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.more-info-btn:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* ===== Info Panel ===== */
.info-panel {
    width: 100%;
    max-width: 500px;
    margin-top: 2rem;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.info-section h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.latency-cols {
    display: flex;
    gap: 1.5rem;
}

.latency-col {
    text-align: center;
}

.latency-col .label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.latency-col .value,
.upload-value {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text);
}

.latency-col .value small,
.upload-value small {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 2px;
}

.info-details {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
}

.detail span:first-child {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.detail span:last-child {
    color: var(--text);
}

.info-data {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.settings-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem 0.75rem;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-btn:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

.hidden {
    display: none !important;
}

/* ===== Footer ===== */
footer {
    padding: 2rem;
    text-align: center;
    width: 100%;
}

.footer-icons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--card);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
}

.powered {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.powered a {
    color: var(--primary);
    text-decoration: none;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-box {
    background: var(--card);
    border-radius: 8px;
    width: 90%;
    max-width: 360px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
}

.setting {
    margin-bottom: 1rem;
}

.setting>label:not(.checkbox) {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.input-group input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.btn-reset,
.btn-save {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-reset:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

.btn-save {
    background: var(--primary);
    border: none;
    color: white;
    font-weight: 500;
}

.btn-save:hover {
    background: var(--primary-light);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .speed-number {
        font-size: 5rem;
        letter-spacing: -3px;
    }

    .speed-meta {
        padding-top: 1rem;
    }

    .speed-unit {
        font-size: 1.25rem;
    }

    .info-row {
        flex-direction: column;
        gap: 1.5rem;
    }

    .info-details {
        flex-direction: column;
        gap: 0.5rem;
    }
}