.typing-container {
    max-width: 900px;
    margin: 0 auto;
}

/* ── Settings ── */

.typing-settings {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.typing-setting-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

.typing-pills {
    display: flex;
    gap: 4px;
}

.typing-pill {
    padding: 6px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

.typing-pill:hover {
    border-color: var(--emerald);
    color: var(--text-primary);
}

.typing-pill.active {
    background: rgba(5, 150, 105, .15);
    border-color: var(--emerald);
    color: var(--emerald-light);
}

/* ── Main ── */

.typing-main {
    margin-bottom: 20px;
}

/* ── Stats ── */

.typing-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.typing-stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.typing-stat-val {
    font-family: 'Space Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 36px;
}

.typing-stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Progress ── */

.typing-progress {
    height: 4px;
    background: rgba(255, 255, 255, .06);
    border-radius: 2px;
    margin-bottom: 24px;
    overflow: hidden;
}

.typing-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--emerald), var(--emerald-light));
    border-radius: 2px;
    transition: width .3s;
    box-shadow: 0 0 8px rgba(52, 211, 153, .4);
}

/* ── Text area ── */

.typing-text-area {
    font-family: 'Space Mono', monospace;
    font-size: 20px;
    line-height: 1.8;
    min-height: 160px;
    padding: 20px;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(0, 0, 0, .2);
    margin-bottom: 20px;
    cursor: text;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.typing-placeholder {
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
}

.typing-text-area .char {
    position: relative;
    transition: color .1s;
}

.typing-text-area .char.current {
    color: var(--text-primary);
}

.typing-text-area .char.current::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: var(--emerald-light);
    border-radius: 1px;
    animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.typing-text-area .char.correct {
    color: var(--emerald-light);
}

.typing-text-area .char.incorrect {
    color: #f87171;
    background: rgba(248, 113, 113, .12);
    border-radius: 3px;
}

.typing-text-area .char.waiting {
    color: var(--text-muted);
}

/* ── Hidden input ── */

.typing-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 0;
    height: 0;
}

/* ── Actions ── */

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

.typing-start-btn,
.typing-restart-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 36px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .25s;
}

.typing-start-btn svg,
.typing-restart-btn svg {
    width: 20px;
    height: 20px;
}

.typing-start-btn {
    background: linear-gradient(135deg, var(--emerald), #059669);
    color: #fff;
    box-shadow: 0 4px 20px rgba(5, 150, 105, .3);
}

.typing-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(5, 150, 105, .45);
}

.typing-restart-btn {
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.typing-restart-btn:hover {
    border-color: var(--emerald);
    background: rgba(5, 150, 105, .08);
}

/* ── Results ── */

.typing-results {
    margin-bottom: 20px;
    animation: fadeInUp .4s ease both;
}

.typing-results-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 20px;
    text-align: center;
    color: var(--text-primary);
}

.typing-results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.typing-result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, .03);
}

.typing-result-icon svg {
    width: 22px;
    height: 22px;
}

.typing-result-val {
    font-family: 'Space Mono', monospace;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.typing-result-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── History ── */

.typing-history {
    margin-bottom: 20px;
}

.typing-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.typing-history-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.typing-clear-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}

.typing-clear-btn svg {
    width: 15px;
    height: 15px;
}

.typing-clear-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, .1);
}

.typing-history-list {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.typing-history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .02);
    font-size: 13px;
}

.typing-history-item .hi-cpm {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    color: var(--emerald-light);
    min-width: 60px;
}

.typing-history-item .hi-acc {
    color: var(--text-secondary);
    min-width: 50px;
}

.typing-history-item .hi-meta {
    color: var(--text-muted);
    flex: 1;
    text-align: right;
    font-size: 12px;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .typing-settings {
        gap: 14px;
    }

    .typing-setting-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .typing-pill {
        padding: 5px 12px;
        font-size: 12px;
    }

    .typing-text-area {
        font-size: 16px;
        line-height: 1.7;
        padding: 16px;
        min-height: 120px;
    }

    .typing-stats {
        gap: 14px;
    }

    .typing-stat-val {
        font-size: 20px;
    }

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

    .typing-result-val {
        font-size: 26px;
    }

    .typing-start-btn,
    .typing-restart-btn {
        padding: 12px 28px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .typing-text-area {
        font-size: 14px;
        padding: 12px;
    }

    .typing-history-item {
        flex-wrap: wrap;
        gap: 8px;
    }
}
