/* English typing practice page */
.typing-page {
    padding: clamp(45px, 6vw, 75px) 0 80px;
}

.typing-shell {
    max-width: 1120px;
}

.typing-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 25px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.typing-head h1 {
    font-size: clamp(42px, 6vw, 68px);
    letter-spacing: -0.07em;
}

.typing-head p:not(.eyebrow) {
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
}

.typing-head-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.typing-head-actions .button {
    min-height: 38px;
    padding: 7px 13px;
    font-size: 10px;
}

.typing-app {
    position: relative;
    margin-top: 22px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.typing-app-top {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 2px 2px 17px;
}

.typing-segment {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-soft);
}

.typing-seg {
    padding: 7px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.typing-seg:hover {
    color: var(--text);
}

.typing-seg.is-active {
    background: var(--surface-raised);
    color: var(--text);
    box-shadow: 0 1px 5px rgba(20, 30, 22, 0.08);
}

.typing-durations {
    display: flex;
    gap: 3px;
}

.typing-durations button {
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.typing-durations button:hover {
    border-color: var(--line);
    color: var(--text);
}

.typing-durations button.is-active {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.typing-restart {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.typing-restart:hover {
    border-color: var(--line-strong);
    color: var(--text);
}

.typing-restart .icon {
    width: 13px;
    height: 13px;
}

.typing-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--line);
    overflow: hidden;
}

.typing-stat {
    display: flex;
    flex-direction: column;
    min-height: 89px;
    padding: 12px 15px;
    background: var(--surface);
}

.typing-stat--accent {
    background: var(--accent-soft);
}

.typing-stat > span {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.typing-stat strong {
    margin-top: auto;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.typing-stat--accent strong {
    color: var(--accent-strong);
}

.typing-stat small {
    margin-top: 4px;
    color: var(--faint);
    font-size: 8px;
}

.typing-progress {
    height: 4px;
    margin: 13px 1px 0;
    overflow: hidden;
    border-radius: 99px;
    background: var(--surface-muted);
}

.typing-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width 0.1s linear;
}

.typing-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 13px 2px 11px;
}

.typing-lessons {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.typing-lessons button {
    padding: 5px 9px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
}

.typing-lessons button:hover {
    color: var(--text);
}

.typing-lessons button.is-active {
    background: var(--surface-muted);
    color: var(--text-soft);
    font-weight: 600;
}

.typing-status {
    color: var(--faint);
    font-size: 9px;
    white-space: nowrap;
}

.typing-stage {
    position: relative;
    height: clamp(290px, 41vh, 410px);
    overflow: auto;
    padding: 28px 31px;
    border: 1px solid rgba(200, 245, 106, 0.13);
    border-radius: var(--radius);
    outline: 0;
    background:
        radial-gradient(circle at 82% 15%, rgba(194, 91, 53, 0.19), transparent 34%),
        radial-gradient(circle at 18% 80%, rgba(127, 201, 170, 0.1), transparent 32%),
        #101712;
    color: #edf2e6;
    cursor: text;
    scrollbar-width: thin;
    scrollbar-color: rgba(237, 242, 230, 0.25) transparent;
}

.typing-stage:focus {
    border-color: rgba(200, 245, 106, 0.44);
    box-shadow: 0 0 0 3px rgba(200, 245, 106, 0.07);
}

.typing-stage::-webkit-scrollbar {
    width: 5px;
}

.typing-stage::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: rgba(237, 242, 230, 0.25);
}

.typing-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(237, 242, 230, 0.45);
    font-size: 13px;
}

.typing-text {
    position: relative;
    max-width: 970px;
    margin: 0 auto;
    font-family: var(--font-mono);
    font-size: clamp(19px, 2.2vw, 27px);
    font-weight: 500;
    letter-spacing: 0.005em;
    line-height: 1.95;
    white-space: pre-wrap;
    overflow-wrap: normal;
    word-break: normal;
    user-select: none;
}

.typing-char {
    position: relative;
    border-radius: 3px;
    color: rgba(237, 242, 230, 0.31);
    transition: color 0.08s ease, background-color 0.08s ease;
}

.typing-char.is-correct {
    color: #f0f4eb;
}

.typing-char.is-wrong {
    color: #ff9b88;
    background: rgba(255, 113, 128, 0.1);
    text-decoration: underline;
    text-decoration-color: rgba(255, 155, 136, 0.8);
    text-underline-offset: 4px;
}

.typing-char.is-current {
    color: #d3fa7e;
    background: rgba(200, 245, 106, 0.12);
}

.typing-char.is-current::before {
    content: "";
    position: absolute;
    top: 0.18em;
    bottom: 0.18em;
    left: -1px;
    width: 2px;
    border-radius: 1px;
    background: #c8f56a;
    animation: typing-caret 1.05s steps(2, start) infinite;
}

@keyframes typing-caret {
    50% {
        opacity: 0;
    }
}

.typing-stage.is-shaking {
    animation: stage-shake 0.16s ease;
}

@keyframes stage-shake {
    25% {
        transform: translateX(-1px);
    }
    75% {
        transform: translateX(1px);
    }
}

.typing-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    padding: 17px 8px 12px;
    border-bottom: 1px solid var(--line);
}

.typing-key-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.typing-key-row--space {
    margin-top: 1px;
}

.typing-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 27px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-raised);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.typing-key--home {
    position: relative;
}

.typing-key--home::after {
    content: "";
    position: absolute;
    bottom: 3px;
    left: 50%;
    width: 5px;
    height: 1px;
    border-radius: 1px;
    background: var(--line-strong);
    transform: translateX(-50%);
}

.typing-key--space {
    width: 245px;
    height: 24px;
    font-size: 8px;
    letter-spacing: 0.1em;
}

.typing-key.is-next {
    border-color: #b7e25a;
    background: #c8f56a;
    color: #11150e;
    box-shadow: 0 0 0 3px rgba(200, 245, 106, 0.12);
}

.typing-key--home.is-next::after {
    background: #5b711f;
}

.typing-footer {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 11px 2px 1px;
    color: var(--faint);
    font-size: 9px;
}

.typing-result {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: rgba(10, 16, 12, 0.58);
    backdrop-filter: blur(5px);
}

.typing-result[hidden] {
    display: none;
}

.typing-result-card {
    width: min(440px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    text-align: center;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.3);
}

.typing-result-card h2 {
    margin-top: 4px;
    font-size: 31px;
}

.typing-result-main {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 7px;
    margin: 15px 0 18px;
}

.typing-result-main strong {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 65px;
    line-height: 1;
}

.typing-result-main span {
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: 9px;
}

.typing-result-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--line);
}

.typing-result-grid div {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 4px;
    background: var(--surface);
}

.typing-result-grid span {
    color: var(--faint);
    font-size: 8px;
}

.typing-result-grid strong {
    font-family: var(--font-mono);
    font-size: 13px;
}

.typing-result-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 19px;
}

.typing-result-actions .button {
    min-height: 40px;
    padding: 8px 15px;
    font-size: 11px;
}

.typing-notes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding-top: 25px;
}

.typing-notes > div {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.typing-notes p {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.8;
}

@media (max-width: 820px) {
    .typing-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .typing-head-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

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

    .typing-meta-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .typing-stage {
        padding: 23px 21px;
    }

    .typing-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .typing-key {
        width: 35px;
        height: 24px;
        font-size: 8px;
    }

    .typing-key--space {
        width: 190px;
    }

    .typing-notes {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

@media (max-width: 620px) {
    .typing-page {
        padding-top: 32px;
    }

    .typing-head h1 {
        font-size: 42px;
    }

    .typing-app {
        padding: 10px;
        border-radius: var(--radius);
    }

    .typing-app-top {
        flex-wrap: wrap;
        gap: 8px;
        padding-bottom: 11px;
    }

    .typing-restart {
        margin-left: 0;
    }

    .typing-seg {
        padding: 6px 9px;
        font-size: 10px;
    }

    .typing-durations button {
        padding: 6px 8px;
    }

    .typing-stat {
        min-height: 75px;
        padding: 9px 11px;
    }

    .typing-stat strong {
        font-size: 23px;
    }

    .typing-stage {
        height: 300px;
        padding: 19px 15px;
    }

    .typing-text {
        font-size: 18px;
        line-height: 1.9;
    }

    .typing-keyboard {
        display: none;
    }

    .typing-footer {
        padding-top: 8px;
    }

    .typing-result-card {
        padding: 21px;
    }

    .typing-result-main strong {
        font-size: 52px;
    }

    .typing-result-grid strong {
        font-size: 11px;
    }

    .typing-result-actions {
        flex-direction: column;
    }

    .typing-result-actions .button {
        width: 100%;
    }
}
