:root {
    --bg: #05060b;
    --card: #11151f;
    --muted: #9aa1b9;
    --text: #f5f7ff;
    --brand: #4caf50;
    --brand-2: #3ea047;
    --accent: #7c4dff;
    --danger: #f44336;
    --border: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.05);
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
    --highlight-correct: rgba(76, 175, 80, 0.24);
    --highlight-wrong: rgba(244, 67, 54, 0.28);
    --highlight-current: rgba(255, 235, 59, 0.28);
}

body {
    background: radial-gradient(1200px at 15% 0, rgba(124, 77, 255, 0.12), transparent),
                radial-gradient(1100px at 90% 10%, rgba(76, 175, 80, 0.15), transparent),
                var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
}

.speed-test-page {
    padding-bottom: 80px;
}

.st-container {
    width: min(1120px, 94%);
    margin: 0 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #1a1f2b;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.btn-lg {
    padding: 14px 22px;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(90deg, var(--brand), var(--accent));
    border-color: transparent;
}

.btn-outline {
    background: transparent;
    color: var(--text);
}

.section {
    padding: 64px 0;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 28px;
    text-align: center;
}

.speed-test-hero {
    padding: 72px 0 48px;
}

.speed-test-hero .hero-inner {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 40px;
    align-items: center;
}

.speed-test-hero .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(76, 175, 80, 0.4);
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
    margin-bottom: 18px;
}

.speed-test-hero h1 {
    font-size: clamp(32px, 5vw, 48px);
    line-height: 1.1;
    margin-bottom: 16px;
}

.speed-test-hero p {
    color: var(--muted);
    margin-bottom: 18px;
}

.speed-test-hero ul {
    list-style: none;
    margin: 0 0 24px;
    padding: 0;
    display: grid;
    gap: 12px;
}

.speed-test-hero li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.speed-test-hero li::before {
    content: '•';
    color: var(--brand);
    font-size: 24px;
    line-height: 1;
}

.speed-test-hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 18px;
}

.hero-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hero-stat span {
    color: var(--muted);
}

.hero-stat strong {
    font-size: 28px;
}

.progress-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(76, 175, 80, 0.12);
    color: var(--brand);
    font-weight: 600;
}

.speed-test-content {
    max-width: 980px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: 32px;
}

.section-header h2 {
    font-size: clamp(28px, 4vw, 40px);
    margin-bottom: 14px;
}

.section-header p {
    color: var(--muted);
    margin: 0 auto;
    max-width: 640px;
}

.test-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 18px;
    margin-bottom: 20px;
}

.control-group {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
}

.duration-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.duration-btn {
    flex: 1;
    min-width: 110px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.duration-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.text-type-select {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #1a1f2b;
    color: var(--text);
}

.session-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.meta-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
}

.meta-card span {
    color: var(--muted);
    font-size: 14px;
}

.meta-card strong {
    font-size: 22px;
}

.test-area {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 36px;
}

.test-text {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    min-height: 160px;
    font-size: 18px;
    line-height: 1.6;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.sample-text {
    color: var(--muted);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Inter', system-ui, sans-serif;
}

.char {
    transition: background-color 0.1s ease;
}

.char.correct {
    background: var(--highlight-correct);
    color: #fff;
}

.char.wrong {
    background: var(--highlight-wrong);
    color: #fff;
}

.char.current {
    background: var(--highlight-current);
    border-bottom: 2px solid var(--accent);
}

.char.line-break-symbol {
    opacity: 0.5;
    font-size: 14px;
    margin-right: 6px;
}

.user-input {
    width: 100%;
    min-height: 130px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #0c111d;
    color: var(--text);
    font-size: 18px;
    line-height: 1.6;
    padding: 18px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.user-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.25);
}

.user-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.test-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.test-results {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px;
    box-shadow: var(--shadow);
    display: none;
}

.test-results.visible {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 24px 0;
}

.result-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}

.result-value {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--brand);
}

.result-label {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
    color: var(--muted);
}

.result-description {
    font-size: 14px;
    color: var(--muted);
    margin-top: 8px;
}

.result-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.detail-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
}

.detail-label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.detail-value {
    font-size: 18px;
    font-weight: 600;
}

.results-actions {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.recommendations-section {
    background: linear-gradient(180deg, rgba(124, 77, 255, 0.1), rgba(124, 77, 255, 0.03));
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.recommendations-section h2,
.history-section h2 {
    text-align: center;
    margin-bottom: 12px;
}

.recommendations-section .subtitle {
    text-align: center;
    color: var(--muted);
    margin-bottom: 32px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.benefit {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

.benefit:hover {
    transform: translateY(-4px);
}

.benefit .icon {
    font-size: 28px;
}

.benefit p {
    color: var(--muted);
}

.section-note {
    margin-top: 24px;
    padding: 18px;
    border-radius: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    text-align: center;
    color: var(--muted);
}

.history-chart {
    margin: 24px 0;
    padding: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    min-height: 220px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-table th {
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
    color: var(--muted);
}

.history-table td {
    color: var(--text);
}

.chart-note {
    text-align: center;
    color: var(--muted);
    margin-top: 12px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 160px;
    color: var(--muted);
}

.speed-test-cta {
    text-align: center;
}

.speed-test-cta p {
    color: var(--muted);
    margin-bottom: 18px;
}

@media (max-width: 1024px) {
    .speed-test-hero .hero-inner {
        grid-template-columns: 1fr;
    }

    .session-meta {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .test-controls {
        flex-direction: column;
    }

    .duration-buttons {
        width: 100%;
    }

    .duration-btn {
        flex: 1 1 100%;
    }

    .session-meta,
    .results-grid,
    .result-details,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .speed-test-hero-cta,
    .test-actions,
    .results-actions {
        flex-direction: column;
    }

    .speed-test-hero-cta .btn,
    .test-actions .btn,
    .results-actions .btn {
        width: 100%;
    }
}

@media (max-width: 540px) {
    .hero-card {
        padding: 18px;
    }

    .test-text,
    .user-input {
        padding: 16px;
        font-size: 16px;
    }

    .meta-card strong {
        font-size: 18px;
    }
}

