/**
 * ==========================================================
 * TypingTutor.Online
 * Compact Lesson Information Bar v3.4
 * File: css/lesson.css
 * ==========================================================
 */

#courseModePanel {
    box-sizing: border-box;
    width: min(1480px, calc(100% - 34px));
    margin: 0 auto;
}

.lesson-information-card,
.typing-practice-card,
.statistics-panel,
.lesson-controls-card,
.keyboard-guidance-card,
.hands-guidance-card {
    background: var(--surface, #ffffff);
    border: 1px solid #e7ebf2;
    box-shadow: 0 14px 38px rgba(15, 23, 42, 0.06);
}

/* ==========================================================
   COMPACT LESSON INFORMATION BAR
========================================================== */

.lesson-information-card {
    display: grid;
    grid-template-columns:
        minmax(250px, 1.15fr)
        minmax(410px, 1.55fr)
        minmax(330px, 1.15fr);
    gap: 12px;
    align-items: center;

    min-height: 92px;
    margin: 12px 0 14px;
    padding: 12px 14px;

    border-radius: 16px;
}

.lesson-identity {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.lesson-book-icon {
    display: grid;
    place-items: center;

    width: 54px;
    height: 54px;

    border-radius: 50%;
    background: linear-gradient(145deg, #f8faff, #edf3ff);

    font-size: 27px;
}

.lesson-count {
    display: block;
    margin-bottom: 3px;

    color: #172033;
    font-size: 12px;
    font-weight: 800;
}

#lessonTitle {
    margin: 0;

    color: #1260f5;
    font-family: "Poppins", sans-serif;
    font-size: clamp(16px, 1.2vw, 20px);
    line-height: 1.2;
}

#lessonDescription {
    margin: 6px 0 0;
    overflow: hidden;

    color: #475569;
    font-size: 11px;
    line-height: 1.4;

    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ==========================================================
   COMPACT META CARDS
========================================================== */

.lesson-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.lesson-meta-card {
    display: grid;
    align-content: center;

    min-height: 66px;
    padding: 8px 7px;

    text-align: center;

    border: 1px solid #e3e8f0;
    border-radius: 10px;
    background: linear-gradient(180deg, #fafbfe, #f5f7fb);
}

.lesson-meta-card > span {
    color: #64748b;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.lesson-meta-card strong {
    margin-top: 4px;

    color: #0f172a;
    font-size: 16px;
    line-height: 1;
}

.lesson-meta-card small {
    margin-top: 5px;
    overflow: hidden;

    color: #475569;
    font-size: 9px;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.meta-time {
    display: inline-flex;
    justify-content: center;
    gap: 4px;
    align-items: center;
}

.lesson-info-progress-track {
    overflow: hidden;

    height: 6px;
    margin-top: 8px;

    border-radius: 999px;
    background: #dfe5ef;
}

#lessonInfoProgressFill {
    width: 0;
    height: 100%;

    border-radius: inherit;
    background: #1769ff;

    transition: width .2s ease;
}

/* ==========================================================
   COMPACT ADVICE
========================================================== */

.lesson-advice-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px 10px;

    min-height: 66px;
    padding: 9px 11px;

    border: 1px solid #f3dfb3;
    border-radius: 12px;
    background: linear-gradient(135deg, #fffdf8, #fff8ea);
}

.lesson-advice-panel p {
    display: grid;
    grid-template-columns: 17px auto 1fr;
    gap: 3px;
    align-items: start;

    margin: 0;
    overflow: hidden;

    color: #111827;
    font-size: 9px;
    line-height: 1.35;
}

.lesson-advice-panel p > span:first-child {
    font-size: 12px;
}

.lesson-advice-panel p > span:last-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ==========================================================
   PRACTICE AREA
========================================================== */

.lesson-practice-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 176px;
    gap: 14px;
    align-items: stretch;
}

.typing-practice-card {
    min-width: 0;
    overflow: hidden;
    border-radius: 20px;
}

.practice-toolbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px 18px;
}

.stage-label,
.time-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1f2937;
    font-size: 13px;
}

.time-left {
    justify-self: center;
    color: #1769ff;
    font-size: 15px;
    font-weight: 600;
}

.quiet-button {
    justify-self: end;
    padding: 10px 15px;
    color: #334155;
    background: #ffffff;
    border: 1px solid #dce3ed;
    border-radius: 11px;
    font-weight: 600;
    cursor: pointer;
}

.quiet-button:hover {
    border-color: #1769ff;
    color: #1769ff;
}

#lessonText {
    box-sizing: border-box;
    height: 255px;
    min-height: 255px;
    max-height: 255px;
    overflow-x: hidden;
    overflow-y: hidden;
    padding: 30px 28px 44px;
    color: #172033;
    outline: none;
    border-top: 1px solid #e4e9f1;
    border-bottom: 1px solid #e4e9f1;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, .7), transparent 16%, transparent 84%, rgba(248, 250, 252, .7)),
        #ffffff;
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(20px, 2vw, 28px);
    font-weight: 500;
    line-height: 2.1;
    letter-spacing: .11em;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

#lessonText::-webkit-scrollbar {
    display: none;
}

.lesson-character {
    position: relative;
    display: inline;
    border-radius: 5px;
    transition: color .12s ease, background .12s ease, box-shadow .12s ease;
}

.future-character {
    color: #172033;
}

.typed-character {
    color: #18a85b;
}

.wrong-character {
    color: #e11d48;
    background: rgba(225, 29, 72, .11);
    box-shadow: inset 0 -3px 0 #e11d48;
}

.current-character {
    z-index: 2;
    color: #ffffff;
    background: #1769ff;
    box-shadow: 0 4px 15px rgba(23, 105, 255, .28);
}

.lesson-paused #lessonText {
    opacity: .45;
    filter: blur(1px);
}

.lesson-paused .typing-practice-card {
    position: relative;
}

.lesson-paused .typing-practice-card::after {
    content: attr(data-pause-message);
    position: absolute;
    inset: 60px 0 54px;
    z-index: 5;
    display: grid;
    place-items: center;
    color: #0f172a;
    font-size: 18px;
    font-weight: 800;
    pointer-events: none;
}

.practice-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 18px;
    padding: 0 18px 14px;
}

.character-progress-wrap {
    min-width: 0;
    color: #475569;
    font-size: 12px;
}

.character-progress-track {
    overflow: hidden;
    height: 3px;
    margin-bottom: 10px;
    border-radius: 999px;
    background: #e2e8f0;
}

#progressFill {
    width: 0;
    height: 100%;
    background: #22c55e;
    transition: width .2s ease;
}

.practice-footer-actions {
    display: flex;
    gap: 18px;
    align-items: center;
    color: #475569;
    font-size: 12px;
}

.error-summary {
    color: #dc2626;
}

.text-button {
    padding: 4px;
    color: #334155;
    background: transparent;
    border: 0;
    font-weight: 700;
    cursor: pointer;
}

.statistics-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border-radius: 16px;
}

.statistics-panel .stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 49px;
    padding: 8px 10px;
    border: 1px solid #dfe5ee;
    border-radius: 13px;
    background: #ffffff;
}

.statistics-panel .label {
    color: #52617a;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.statistics-panel .stat > span:last-child {
    color: #1769ff;
    font-size: 22px;
    font-weight: 800;
}

.statistics-panel .stat:nth-child(2) > span:last-child {
    color: #16a34a;
}

.statistics-panel .stat:nth-child(3) > span:last-child {
    color: #dc2626;
}

.typing-controls-grid {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 315px;
    gap: 14px;
    align-items: stretch;
    margin-top: 16px;
}

.lesson-controls-card,
.keyboard-guidance-card,
.hands-guidance-card {
    border-radius: 20px;
}

.lesson-controls-card {
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 18px;
}

.control-button {
    min-height: 49px;
    border-radius: 11px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.pause-button {
    color: #ffffff;
    border: 0;
    background: linear-gradient(135deg, #1769ff, #0f5ce5);
    box-shadow: 0 10px 22px rgba(23, 105, 255, .23);
}

.end-button {
    color: #ef4444;
    border: 1px solid #ef4444;
    background: #ffffff;
}

.auto-advance-option {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 38px;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
    color: #1f2937;
    font-size: 12px;
    line-height: 1.45;
    cursor: pointer;
}

.auto-advance-option input {
    position: absolute;
    opacity: 0;
}

.toggle-track {
    position: relative;
    width: 36px;
    height: 21px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .18s ease;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .2);
    transition: transform .18s ease;
}

.auto-advance-option input:checked + .toggle-track {
    background: #1769ff;
}

.auto-advance-option input:checked + .toggle-track::after {
    transform: translateX(15px);
}

.keyboard-tip-button {
    margin-top: 10px;
    min-height: 44px;
    padding: 8px 10px;
    color: #1769ff;
    border: 1px solid #dce3ed;
    border-radius: 11px;
    background: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.keyboard-guidance-card {
    min-width: 0;
    padding: 14px 14px 12px;
}

#keyboardContainer {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.home-row-guide {
    display: flex;
    justify-content: center;
    gap: 6px;
    align-items: center;
    margin-top: 10px;
    color: #1f2937;
    font-size: 12px;
}

.home-row-guide span {
    display: grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 5px;
    border-radius: 6px;
    background: #f1f5f9;
}

.home-row-guide .active-home-key,
.keyboard-tips-visible .home-row-guide span:nth-of-type(5) {
    color: #ffffff;
    background: #1769ff;
}

.hands-guidance-card {
    display: grid;
    grid-template-rows: 1fr auto;
    min-width: 0;
    padding: 10px;
}

#handsContainer {
    width: 100%;
    height: 230px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(241, 245, 249, .72), rgba(248, 250, 252, .35));
    box-shadow: none;
}

.hands-guidance-card p {
    margin: 2px 0 6px;
    text-align: center;
    color: #1f2937;
    font-size: 12px;
    font-weight: 700;
}

.full-text-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .72);
    backdrop-filter: blur(5px);
}

.full-text-modal.hidden {
    display: none;
}

.full-text-card {
    width: min(800px, 100%);
    max-height: 80vh;
    overflow: auto;
    padding: 22px;
    border-radius: 18px;
    background: #ffffff;
}

.full-text-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.full-text-heading h2 {
    margin: 0;
}

#closeFullTextButton {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #eef2f7;
    font-size: 25px;
    cursor: pointer;
}

#fullLessonText {
    margin: 20px 0 0;
    white-space: pre-wrap;
    color: #334155;
    font: 16px/1.8 "JetBrains Mono", monospace;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 1250px) {

    .lesson-information-card {
        grid-template-columns:
            minmax(250px, 1fr)
            minmax(390px, 1.45fr);
    }

    .lesson-advice-panel {
        grid-column: 1 / -1;
        grid-template-columns: repeat(4, 1fr);
        min-height: 0;
    }

    .typing-controls-grid {
        grid-template-columns: 200px minmax(0, 1fr);
    }

    .hands-guidance-card {
        grid-column: 1 / -1;
        width: min(420px, 100%);
        justify-self: center;
    }

}

@media (max-width: 900px) {

    #courseModePanel {
        width: min(100% - 18px, 800px);
    }

    .lesson-information-card {
        grid-template-columns: 1fr;
    }

    .lesson-meta-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .lesson-advice-panel {
        grid-template-columns: 1fr 1fr;
    }

    .lesson-practice-grid {
        grid-template-columns: 1fr;
    }

    .statistics-panel {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .statistics-panel .stat {
        display: grid;
        justify-items: center;
        min-width: 0;
        padding: 9px 5px;
    }

    .typing-controls-grid {
        grid-template-columns: 1fr;
    }

    .lesson-controls-card {
        grid-template-columns: 1fr 1fr;
    }

    .auto-advance-option,
    .keyboard-tip-button {
        margin-top: 0;
    }

}

@media (max-width: 650px) {

    .lesson-information-card {
        padding: 11px;
    }

    .lesson-identity {
        grid-template-columns: 48px 1fr;
    }

    .lesson-book-icon {
        width: 46px;
        height: 46px;
        font-size: 23px;
    }

    #lessonDescription {
        display: none;
    }

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

    .lesson-advice-panel {
        grid-template-columns: 1fr;
    }

    .practice-toolbar {
        grid-template-columns: 1fr auto;
    }

    .time-left {
        justify-self: end;
    }

    .quiet-button {
        grid-column: 1 / -1;
        width: 100%;
    }

    #lessonText {
        height: 225px;
        min-height: 225px;
        max-height: 225px;
        padding: 25px 16px 38px;
        font-size: 18px;
        letter-spacing: .06em;
    }

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

    .statistics-panel .stat:last-child {
        grid-column: 1 / -1;
    }

    .lesson-controls-card {
        grid-template-columns: 1fr;
    }

    .home-row-guide {
        flex-wrap: wrap;
    }

}

@media (prefers-reduced-motion: reduce) {

    #lessonText,
    #progressFill,
    #lessonInfoProgressFill,
    .lesson-character {
        scroll-behavior: auto;
        transition: none;
    }

}


/* ==========================================================
   COMPACT LIVE STATISTICS v3.4
========================================================== */

@media (min-width: 901px) {

    .lesson-practice-grid {
        grid-template-columns:
            minmax(0, 1fr)
            clamp(158px, 11.5vw, 176px);
    }

    .statistics-panel {
        gap: 6px;
        padding: 9px;
        border-radius: 16px;
    }

    .statistics-panel .stat {
        min-height: 47px;
        padding: 7px 9px;
        border-radius: 10px;
    }

    .statistics-panel .label {
        font-size: 8px;
        letter-spacing: 0.04em;
    }

    .statistics-panel .stat > span:last-child {
        font-size: 17px;
    }

}


/* ==========================================================
   AUTOMATIC INACTIVITY PAUSE v4.3
========================================================== */

.lesson-paused .typing-practice-card::after {
    padding: 20px;
    text-align: center;
    white-space: normal;
    line-height: 1.45;
}

.lesson-paused .typing-practice-card[data-pause-message]::after {
    content: attr(data-pause-message);
}



/* ==========================================================
   FOCUS LESSON BAR v4.4
========================================================== */

.lesson-focus-bar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(230px, 1.1fr) minmax(480px, 2fr) auto;
    gap: 12px;
    align-items: center;

    min-height: 54px;
    margin: 8px 0 10px;
    padding: 7px 9px 7px 12px;

    background: var(--surface, #ffffff);
    border: 1px solid var(--border-soft, #e7ebf2);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
}

.lesson-focus-main {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    min-width: 0;
}

.lesson-focus-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--surface-alt, #eef4ff);
    font-size: 19px;
}

.lesson-focus-title {
    min-width: 0;
}

.lesson-focus-title > span {
    display: block;
    color: var(--text-light, #475569);
    font-size: 9px;
    font-weight: 800;
}

.lesson-focus-title h2 {
    margin: 2px 0 0;
    overflow: hidden;
    color: var(--primary, #1769ff);
    font-family: var(--font-heading, "Poppins", sans-serif);
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.lesson-focus-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
}

.lesson-focus-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 30px;
    padding: 5px 7px;
    color: var(--text-light, #475569);
    background: var(--surface-alt, #f8fafc);
    border: 1px solid var(--border-soft, #e3e8f0);
    border-radius: 8px;
    font-size: 9px;
    white-space: nowrap;
}

.lesson-focus-meta strong {
    color: var(--text-muted, #64748b);
    font-size: 7px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.lesson-focus-meta b {
    color: var(--text, #0f172a);
    font-size: 10px;
}

.lesson-focus-progress {
    display: grid !important;
    grid-template-columns: auto auto;
    min-width: 110px;
}

.lesson-focus-track {
    grid-column: 1 / -1;
    display: block;
    overflow: hidden;
    width: 100%;
    height: 4px;
    margin-top: 2px;
    border-radius: 999px;
    background: var(--border-soft, #dfe5ef);
}

#lessonInfoProgressFill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--primary, #1769ff);
}

.lesson-tips-button {
    min-width: 94px;
    min-height: 34px;
    padding: 6px 10px;
    color: var(--primary, #1769ff);
    background: var(--surface, #ffffff);
    border: 1px solid var(--border, #dce3ed);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
}

.lesson-tips-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding: 9px;
    background: color-mix(in srgb, var(--warning, #f59e0b) 8%, var(--surface, #ffffff));
    border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 30%, var(--border, #dce3ed));
    border-radius: 10px;
}

.lesson-tips-panel[hidden] {
    display: none !important;
}

.lesson-tips-panel p {
    display: grid;
    grid-template-columns: 16px auto 1fr;
    gap: 3px;
    align-items: start;
    margin: 0;
    min-width: 0;
    color: var(--text, #111827);
    font-size: 9px;
    line-height: 1.4;
}

.lesson-tips-panel p span:last-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.lesson-description-line {
    grid-column: 1 / -1;
}

.hidden-metadata {
    display: none;
}

@media (max-width: 1100px) {
    .lesson-focus-bar {
        grid-template-columns: minmax(210px, 1fr) minmax(350px, 1.7fr) auto;
    }

    .lesson-focus-meta > span:nth-child(2),
    .lesson-focus-meta > span:nth-child(3) {
        display: none;
    }
}

@media (max-width: 800px) {
    .lesson-focus-bar {
        grid-template-columns: 1fr auto;
    }

    .lesson-focus-meta {
        grid-column: 1 / -1;
        justify-content: flex-start;
        overflow-x: auto;
    }

    .lesson-tips-panel {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 520px) {
    .lesson-focus-main {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .lesson-focus-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .lesson-focus-title h2 {
        font-size: 13px;
    }

    .lesson-tips-panel {
        grid-template-columns: 1fr;
    }
}


/* ==========================================================
   COMPACT LIVE STATISTICS v4.6
========================================================== */

@media (min-width: 901px) {

    .lesson-practice-grid {
        grid-template-columns:
            minmax(0, 1fr)
            clamp(158px, 11.5vw, 176px);
    }

    .statistics-panel {
        gap: 6px;
        padding: 9px;
        border-radius: 16px;
    }

    .statistics-panel .stat {
        min-height: 47px;
        padding: 7px 9px;
        border-radius: 10px;
    }

    .statistics-panel .label {
        font-size: 8px;
        letter-spacing: 0.04em;
    }

    .statistics-panel .stat > span:last-child {
        font-size: 17px;
    }

}


/* ==========================================================
   AUTOMATIC INACTIVITY PAUSE v4.6
========================================================== */

.lesson-paused .typing-practice-card::after {
    content: attr(data-pause-message);
    padding: 20px;
    text-align: center;
    white-space: normal;
    line-height: 1.45;
}

.lesson-paused .typing-practice-card[data-pause-message]::after {
    content: attr(data-pause-message);
}



/* ==========================================================
   DYNAMIC TARGET ROW GUIDE v4.6
========================================================== */

.target-row-guide {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    min-width: 0;
    margin-top: 10px;
    color: var(--text, #1f2937);
    font-size: 11px;
}

.target-row-guide > strong {
    flex: 0 0 auto;
    color: var(--text, #1f2937);
    font-size: 11px;
}

.target-row-keys {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.target-row-key {
    display: grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    color: var(--text-light, #475569);
    background: var(--surface-alt, #f1f5f9);
    border: 1px solid var(--border-soft, #e5eaf1);
    border-radius: 5px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    transition:
        color .15s ease,
        background-color .15s ease,
        border-color .15s ease,
        box-shadow .15s ease,
        transform .15s ease;
}

.target-row-key-active {
    color: #ffffff;
    background: var(--primary, #1769ff);
    border-color: var(--primary, #1769ff);
    box-shadow: 0 0 0 3px rgba(23, 105, 255, .13);
    transform: translateY(-1px);
}

html[data-theme="dark"] .target-row-key {
    color: var(--text-light);
    background: var(--surface-alt);
    border-color: var(--border);
}

html[data-theme="dark"] .target-row-key-active {
    color: #ffffff;
    background: var(--primary);
    border-color: #75a5ff;
}

@media (prefers-color-scheme: dark) {

    html[data-theme="system"] .target-row-key {
        color: var(--text-light);
        background: var(--surface-alt);
        border-color: var(--border);
    }

    html[data-theme="system"] .target-row-key-active {
        color: #ffffff;
        background: var(--primary);
        border-color: #75a5ff;
    }

}

@media (max-width: 650px) {

    .target-row-guide {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .target-row-keys {
        justify-content: flex-start;
    }

    .target-row-key {
        min-width: 20px;
        height: 20px;
        padding-inline: 4px;
        font-size: 8px;
    }

}

@media (prefers-reduced-motion: reduce) {

    .target-row-key {
        transition: none;
    }

}


/* ==========================================================
   ATTRACTIVE LESSON ROW BUTTONS v4.7
   Keeps the same compact size, but improves appearance.
========================================================== */

.lesson-meta-card {
    position: relative;
    overflow: hidden;

    min-height: 66px;
    padding: 8px 8px;

    border: 1px solid #dde6f2;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.92),
        0 6px 14px rgba(15, 23, 42, 0.05);

    transition:
        transform .16s ease,
        box-shadow .16s ease,
        border-color .16s ease;
}

.lesson-meta-card::before {
    content: "";

    position: absolute;
    top: 0;
    left: 0;
    right: 0;

    height: 4px;

    border-radius: 12px 12px 0 0;
    background: #1769ff;
}

.lesson-meta-card::after {
    content: "";

    position: absolute;
    right: -14px;
    top: -14px;

    width: 42px;
    height: 42px;

    border-radius: 50%;
    background: rgba(23, 105, 255, 0.08);
    pointer-events: none;
}

.lesson-meta-card > span {
    position: relative;
    z-index: 1;

    color: #64748b;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lesson-meta-card strong {
    position: relative;
    z-index: 1;

    margin-top: 4px;

    color: #0f172a;
    font-size: 16px;
    line-height: 1.05;
    font-weight: 800;
}

.lesson-meta-card small {
    position: relative;
    z-index: 1;

    margin-top: 5px;

    color: #526277;
    font-size: 9px;
    font-weight: 600;
}

.lesson-meta-grid .lesson-meta-card:nth-child(1) {
    background: linear-gradient(180deg, #fbfdff 0%, #f4f8ff 100%);
    border-color: #dbe7ff;
}

.lesson-meta-grid .lesson-meta-card:nth-child(1)::before {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.lesson-meta-grid .lesson-meta-card:nth-child(1)::after {
    background: rgba(59, 130, 246, 0.10);
}

.lesson-meta-grid .lesson-meta-card:nth-child(2) {
    background: linear-gradient(180deg, #fcfbff 0%, #f7f3ff 100%);
    border-color: #e7dcff;
}

.lesson-meta-grid .lesson-meta-card:nth-child(2)::before {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

.lesson-meta-grid .lesson-meta-card:nth-child(2)::after {
    background: rgba(139, 92, 246, 0.10);
}

.lesson-meta-grid .lesson-meta-card:nth-child(3) {
    background: linear-gradient(180deg, #fffdf8 0%, #fff8ec 100%);
    border-color: #f3e0b8;
}

.lesson-meta-grid .lesson-meta-card:nth-child(3)::before {
    background: linear-gradient(90deg, #f59e0b, #f97316);
}

.lesson-meta-grid .lesson-meta-card:nth-child(3)::after {
    background: rgba(245, 158, 11, 0.10);
}

.lesson-meta-grid .lesson-meta-card:nth-child(4) {
    background: linear-gradient(180deg, #f8fff9 0%, #effcf2 100%);
    border-color: #d7f0df;
}

.lesson-meta-grid .lesson-meta-card:nth-child(4)::before {
    background: linear-gradient(90deg, #16a34a, #22c55e);
}

.lesson-meta-grid .lesson-meta-card:nth-child(4)::after {
    background: rgba(34, 197, 94, 0.10);
}

.lesson-meta-grid .lesson-meta-card:nth-child(5) {
    background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
    border-color: #d7e4fb;
}

.lesson-meta-grid .lesson-meta-card:nth-child(5)::before {
    background: linear-gradient(90deg, #0ea5e9, #2563eb);
}

.lesson-meta-grid .lesson-meta-card:nth-child(5)::after {
    background: rgba(14, 165, 233, 0.10);
}

.lesson-info-progress-track {
    overflow: hidden;

    height: 7px;
    margin-top: 8px;

    border-radius: 999px;
    background: linear-gradient(180deg, #e4ebf5, #dfe6f1);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

#lessonInfoProgressFill {
    border-radius: inherit;
    background: linear-gradient(90deg, #1769ff 0%, #2f8cff 100%);
    box-shadow: 0 0 10px rgba(23, 105, 255, 0.28);
}

html[data-theme="dark"] .lesson-meta-card {
    border-color: #2b3545;
    background: linear-gradient(180deg, #141d29 0%, #101722 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.02),
        0 10px 20px rgba(0, 0, 0, 0.20);
}

html[data-theme="dark"] .lesson-meta-card::after {
    opacity: 0.55;
}

html[data-theme="dark"] .lesson-meta-card > span {
    color: #8fa0b7;
}

html[data-theme="dark"] .lesson-meta-card strong {
    color: #f3f7ff;
}

html[data-theme="dark"] .lesson-meta-card small {
    color: #a6b4c8;
}

html[data-theme="dark"] .lesson-info-progress-track {
    background: linear-gradient(180deg, #1a2432, #182230);
}

@media (prefers-color-scheme: dark) {

    html[data-theme="system"] .lesson-meta-card {
        border-color: #2b3545;
        background: linear-gradient(180deg, #141d29 0%, #101722 100%);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.02),
            0 10px 20px rgba(0, 0, 0, 0.20);
    }

    html[data-theme="system"] .lesson-meta-card::after {
        opacity: 0.55;
    }

    html[data-theme="system"] .lesson-meta-card > span {
        color: #8fa0b7;
    }

    html[data-theme="system"] .lesson-meta-card strong {
        color: #f3f7ff;
    }

    html[data-theme="system"] .lesson-meta-card small {
        color: #a6b4c8;
    }

    html[data-theme="system"] .lesson-info-progress-track {
        background: linear-gradient(180deg, #1a2432, #182230);
    }

}

@media (max-width: 900px) {

    .lesson-meta-card {
        min-height: 64px;
    }

}


/* ==========================================================
   EDUCATIONAL META CHIPS v4.8
   Attractive, readable, and the same compact row height.
========================================================== */

.lesson-focus-meta {
    gap: 8px;
}

.lesson-focus-meta > span {
    position: relative;
    overflow: hidden;

    min-height: 34px;
    padding: 6px 10px;

    border-radius: 10px;
    border: 1px solid #dbe6f5;

    background:
        linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .95),
        0 5px 12px rgba(15, 23, 42, .05);
}

.lesson-focus-meta > span::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: #2563eb;
}

.lesson-focus-meta > span:nth-child(2) {
    border-color: #e5dcfb;
    background: linear-gradient(180deg, #ffffff, #f8f4ff);
}

.lesson-focus-meta > span:nth-child(2)::before {
    background: #8b5cf6;
}

.lesson-focus-meta > span:nth-child(3) {
    border-color: #f1dfb8;
    background: linear-gradient(180deg, #fffefa, #fff8ea);
}

.lesson-focus-meta > span:nth-child(3)::before {
    background: #f59e0b;
}

.lesson-focus-meta > span:nth-child(4) {
    border-color: #d7eedf;
    background: linear-gradient(180deg, #fbfffc, #f0fbf3);
}

.lesson-focus-meta > span:nth-child(4)::before {
    background: #22c55e;
}

.lesson-focus-meta > span:nth-child(5) {
    border-color: #d9e5fa;
    background: linear-gradient(180deg, #fbfdff, #eff5ff);
}

.lesson-focus-meta > span:nth-child(5)::before {
    background: #0ea5e9;
}

.lesson-focus-meta strong {
    color: #66758b;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .055em;
}

.lesson-focus-meta b {
    color: #111827;
    font-size: 13px;
    font-weight: 850;
}

.lesson-focus-progress {
    min-width: 132px;
}

.lesson-focus-track {
    height: 5px;
    margin-top: 3px;
    background: #dfe7f2;
}

#lessonInfoProgressFill {
    background: linear-gradient(90deg, #1769ff, #39a0ff);
    box-shadow: 0 0 8px rgba(23, 105, 255, .24);
}

.lesson-tips-button {
    min-width: 110px;
    min-height: 38px;
    padding: 7px 12px;

    color: #ffffff;
    border: 0;

    background:
        linear-gradient(135deg, #2780ff, #1769ff);

    box-shadow:
        0 7px 16px rgba(23, 105, 255, .20);

    font-size: 11px;
    font-weight: 800;
}

.lesson-tips-button:hover {
    background:
        linear-gradient(135deg, #3690ff, #0f5de8);
    transform: translateY(-1px);
}

/* ==========================================================
   READABLE LIVE STATISTICS v4.8
========================================================== */

@media (min-width: 901px) {

    .lesson-practice-grid {
        grid-template-columns:
            minmax(0, 1fr)
            clamp(170px, 12vw, 190px);
    }

    .statistics-panel {
        gap: 7px;
        padding: 10px;
    }

    .statistics-panel .stat {
        min-height: 54px;
        padding: 9px 11px;
    }

    .statistics-panel .label {
        font-size: 10px;
        font-weight: 800;
        letter-spacing: .045em;
    }

    .statistics-panel .stat > span:last-child {
        font-size: 21px;
        line-height: 1;
    }

}

/* ==========================================================
   CLEANER LESSON CONTROLS v4.8
========================================================== */

.lesson-controls-card {
    min-height: 0;
    align-content: start;
    padding: 14px;
}

.control-button {
    min-height: 45px;
    font-size: 14px;
}

.keyboard-tip-button {
    min-height: 42px;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.25;
}

/* The old auto-advance toggle was removed from index.html. */
.auto-advance-option {
    display: none !important;
}

/* End Lesson closes the active lesson and returns to lesson selection. */
.lesson-closed .lesson-focus-bar,
.lesson-closed .lesson-practice-grid,
.lesson-closed .typing-controls-grid {
    display: none !important;
}

/* ==========================================================
   DARK / SYSTEM THEME
========================================================== */

html[data-theme="dark"] .lesson-focus-meta > span {
    color: var(--text);
    border-color: #334155;
    background: linear-gradient(180deg, #172131, #111827);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.025),
        0 7px 16px rgba(0,0,0,.18);
}

html[data-theme="dark"] .lesson-focus-meta strong {
    color: #9aabc0;
}

html[data-theme="dark"] .lesson-focus-meta b {
    color: #f8fafc;
}

html[data-theme="dark"] .lesson-focus-track {
    background: #273449;
}

@media (prefers-color-scheme: dark) {

    html[data-theme="system"] .lesson-focus-meta > span {
        color: var(--text);
        border-color: #334155;
        background: linear-gradient(180deg, #172131, #111827);
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.025),
            0 7px 16px rgba(0,0,0,.18);
    }

    html[data-theme="system"] .lesson-focus-meta strong {
        color: #9aabc0;
    }

    html[data-theme="system"] .lesson-focus-meta b {
        color: #f8fafc;
    }

    html[data-theme="system"] .lesson-focus-track {
        background: #273449;
    }

}

@media (max-width: 1100px) {

    .lesson-focus-meta > span {
        padding-inline: 9px;
    }

    .lesson-focus-meta strong {
        font-size: 8px;
    }

    .lesson-focus-meta b {
        font-size: 12px;
    }

}


/* ==========================================================
   COMPACT PRACTICE ROW v4.9
========================================================== */

/*
 * The old Keyboard Tips control was not providing real tips.
 * It has been removed to keep the learner focused and save space.
 */
.keyboard-tip-button,
.auto-advance-option {
    display: none !important;
}

/*
 * Stop the left controls card from stretching to the full keyboard
 * height. The bottom row now uses only the height it actually needs.
 */
.typing-controls-grid {
    align-items: start;
    gap: 10px;
    margin-top: 10px;
}

.lesson-controls-card {
    align-self: start;
    gap: 8px;
    min-height: 0;
    padding: 10px;
    border-radius: 15px;
}

.control-button {
    min-height: 40px;
    border-radius: 9px;
    font-size: 13px;
}

.pause-button {
    box-shadow: 0 7px 16px rgba(23, 105, 255, .18);
}

/*
 * Reduce empty space around the keyboard while preserving every key.
 */
.keyboard-guidance-card {
    padding: 8px 9px 7px;
    border-radius: 15px;
}

/*
 * Make the hands panel shorter and keep the illustration centered.
 */
.hands-guidance-card {
    align-self: stretch;
    grid-template-rows: minmax(0, 1fr) auto;
    padding: 7px;
    border-radius: 15px;
}

#handsContainer {
    height: 178px;
    border-radius: 18px;
}

.hands-guidance-card p {
    margin: 1px 0 3px;
    font-size: 10px;
}

/*
 * The guide remains useful, but uses less vertical space.
 */
.target-row-guide {
    gap: 5px;
    margin-top: 5px;
    font-size: 10px;
}

.target-row-guide > strong {
    font-size: 10px;
}

.target-row-keys {
    gap: 3px;
}

.target-row-key {
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    font-size: 8px;
}

/*
 * High-specificity light-theme rule:
 * the expected target key must remain blue with white text.
 * This also overrides the removed old tips-mode nth-child rule.
 */
html[data-theme="light"] .target-row-guide .target-row-key.target-row-key-active,
html:not([data-theme]) .target-row-guide .target-row-key.target-row-key-active {
    color: #ffffff !important;
    background: #1769ff !important;
    border-color: #1769ff !important;
    box-shadow: 0 0 0 3px rgba(23, 105, 255, .14) !important;
}

/* Remove any visual effect from an old cached class. */
.keyboard-tips-visible .home-row-guide span:nth-of-type(5) {
    color: inherit;
    background: inherit;
}

/* Restore the actual expected key after the cached-class reset. */
.keyboard-tips-visible .target-row-guide .target-row-key.target-row-key-active {
    color: #ffffff !important;
    background: var(--primary, #1769ff) !important;
    border-color: var(--primary, #1769ff) !important;
}

@media (min-width: 901px) {

    .typing-controls-grid {
        grid-template-columns:
            180px
            minmax(0, 1fr)
            245px;
    }

}

@media (max-width: 1100px) {

    #handsContainer {
        height: 160px;
    }

}

@media (max-width: 900px) {

    .typing-controls-grid {
        grid-template-columns: 1fr;
    }

    .lesson-controls-card {
        grid-template-columns: 1fr 1fr;
    }

    .hands-guidance-card {
        width: min(360px, 100%);
        justify-self: center;
    }

}


/* ==========================================================
   KEYBOARD CONTROL STRIP v5.0
========================================================== */

/*
 * Remove the old left-side controls card entirely.
 * Pause and End Lesson now sit above the keyboard.
 */
.lesson-controls-card {
    display: none !important;
}

.typing-controls-grid {
    grid-template-columns:
        minmax(0, 1fr)
        315px;

    gap: 14px;
    align-items: stretch;
    margin-top: 10px;
}

.keyboard-guidance-card {
    min-width: 0;
    padding: 10px 12px 10px;
    border-radius: 18px;
}

.keyboard-control-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;

    width: min(420px, 100%);
    margin: 0 auto 10px;
}

.keyboard-control-strip .control-button {
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 800;
}

.keyboard-control-strip .pause-button {
    color: #ffffff;
    border: 0;
    background:
        linear-gradient(
            135deg,
            #2b7cff,
            #1769ff
        );
    box-shadow:
        0 7px 16px rgba(23, 105, 255, .20);
}

.keyboard-control-strip .end-button {
    color: #ef4444;
    border: 1px solid #ef4444;
    background: var(--surface, #ffffff);
}

.keyboard-control-strip .pause-button:hover,
.keyboard-control-strip .end-button:hover {
    transform: translateY(-1px);
}

/*
 * Restore comfortable keyboard spacing and keep the card compact
 * without shrinking the labels into tiny text.
 */
#keyboardContainer {
    overflow: hidden;
}

.target-row-guide {
    margin-top: 8px;
}

/*
 * Hands remain beside the keyboard, but no longer inherit the
 * old three-column control layout.
 */
.hands-guidance-card {
    width: 100%;
    min-width: 0;
}

/*
 * The actual active Target Row key remains clearly visible.
 */
html[data-theme="light"] .target-row-key.target-row-key-active,
html:not([data-theme]) .target-row-key.target-row-key-active {
    color: #ffffff !important;
    background: #1769ff !important;
    border-color: #1769ff !important;
}

@media (max-width: 1250px) {

    .typing-controls-grid {
        grid-template-columns:
            minmax(0, 1fr)
            270px;
    }

    .hands-guidance-card {
        grid-column: auto;
        width: 100%;
        justify-self: stretch;
    }

}

@media (max-width: 900px) {

    .typing-controls-grid {
        grid-template-columns: 1fr;
    }

    .hands-guidance-card {
        width: min(390px, 100%);
        justify-self: center;
    }

}

@media (max-width: 520px) {

    .keyboard-control-strip {
        grid-template-columns: 1fr;
    }

}


/* ==========================================================
   FOOTER LESSON CONTROLS v5.1
========================================================== */

/*
 * Pause and End Lesson now sit inside the lesson footer,
 * exactly between character progress and Error/Reset.
 */
.practice-footer {
    grid-template-columns:
        minmax(150px, 1fr)
        minmax(300px, 430px)
        auto;

    align-items: center;
    gap: 14px;

    padding:
        8px 18px
        12px;
}

.practice-footer-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;

    width: 100%;
    max-width: 430px;
    justify-self: center;
}

.practice-footer-controls .control-button {
    min-height: 38px;
    padding: 7px 14px;

    border-radius: 9px;

    font-size: 12px;
    font-weight: 800;
}

.practice-footer-controls .pause-button {
    color: #ffffff;
    border: 0;

    background:
        linear-gradient(
            135deg,
            #2d7fff,
            #1769ff
        );

    box-shadow:
        0 6px 14px rgba(23, 105, 255, .18);
}

.practice-footer-controls .end-button {
    color: #ef4444;
    border: 1px solid #ef4444;
    background: var(--surface, #ffffff);
}

.practice-footer-controls .control-button:hover {
    transform: translateY(-1px);
}

.character-progress-wrap {
    align-self: center;
}

.practice-footer-actions {
    align-self: center;
    white-space: nowrap;
}

/*
 * Since controls moved out of the keyboard card, remove the old
 * space reserved for the strip.
 */
.keyboard-control-strip {
    display: none !important;
}

.keyboard-guidance-card {
    padding-top: 10px;
}

/* Responsive footer controls */
@media (max-width: 1000px) {

    .practice-footer {
        grid-template-columns:
            minmax(120px, 1fr)
            minmax(260px, 360px)
            auto;

        gap: 10px;
    }

}

@media (max-width: 760px) {

    .practice-footer {
        grid-template-columns: 1fr auto;
    }

    .practice-footer-controls {
        grid-column: 1 / -1;
        grid-row: 2;

        max-width: none;
    }

}

@media (max-width: 480px) {

    .practice-footer {
        grid-template-columns: 1fr;
    }

    .practice-footer-actions {
        justify-self: start;
    }

    .practice-footer-controls {
        grid-column: 1;
    }

}


/* ==========================================================
   CENTERED FOOTER CONTROLS v5.2
========================================================== */

.practice-footer {
    grid-template-columns:
        minmax(0, 1fr)
        auto
        minmax(0, 1fr);

    align-items: center;
}

.practice-footer-controls {
    width: min(430px, 42vw);
    max-width: 430px;
    justify-self: center;
}

.practice-footer-actions {
    justify-self: end;
}

.character-progress-wrap {
    justify-self: start;
}

@media (max-width: 760px) {

    .practice-footer {
        grid-template-columns: 1fr auto;
    }

    .practice-footer-controls {
        grid-column: 1 / -1;
        grid-row: 2;

        width: 100%;
        max-width: none;
    }

}



/* ==========================================================
   SAFE LESSON TEXT POSITION FIX v8.3
========================================================== */

/*
 * Preserve the complete lesson layout while moving the visible
 * practice rows slightly upward and keeping the final row clear
 * of the footer controls.
 */
#lessonText {
    overflow-x: hidden !important;
    overflow-y: auto !important;

    padding-top: 14px !important;
    padding-bottom: 34px !important;

    scroll-padding-top: 14px;
    scroll-padding-bottom: 34px;

    scrollbar-width: none;
    overscroll-behavior: contain;
}

#lessonText::-webkit-scrollbar {
    display: none;
}

/*
 * Remove only the decorative text fades that can partially cover
 * the first or last visible row. No structural layout rules are
 * changed here.
 */
.typing-window-shell::before,
.typing-window-shell::after {
    display: none !important;
}

/* Medium-height desktop and laptop screens */
@media (max-height: 820px) and (min-width: 761px) {

    #lessonText {
        padding-top: 10px !important;
        padding-bottom: 30px !important;
    }

}

/* Tablet and mobile */
@media (max-width: 760px) {

    #lessonText {
        padding-top: 12px !important;
        padding-bottom: 28px !important;
    }

}


/* ==========================================================
   WRONG CURRENT CHARACTER FEEDBACK v8.5
========================================================== */

/*
 * A wrong key keeps the learner on the same character, so that
 * character receives both .wrong-character and .current-character.
 * The normal current-character yellow styling previously overrode
 * the red error styling. This combined rule makes the error visible.
 */
#lessonText .current-character.wrong-character {
    color: #ffffff !important;
    background: #dc2626 !important;

    box-shadow:
        0 0 0 4px rgba(220, 38, 38, 0.18),
        inset 0 -3px 0 #991b1b !important;

    animation: wrong-character-pulse .42s ease-in-out;
}

@keyframes wrong-character-pulse {

    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    50% {
        transform: translateX(2px);
    }

    75% {
        transform: translateX(-1px);
    }

    100% {
        transform: translateX(0);
    }

}

html[data-reduced-motion="true"]
#lessonText .current-character.wrong-character {
    animation: none;
}
