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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow-x: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
    flex-shrink: 0;
}

.header-right { display: flex; align-items: center; gap: 16px; }

.fullscreen-toggle {
    background: #363636;
    border: 1px solid #4a4a4a;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s ease, transform .1s ease;
}
.fullscreen-toggle:hover { background: #424242; }
.fullscreen-toggle:active { transform: translateY(1px); }

.logo {
    font-size: 20px;
    font-weight: bold;
    color: #4CAF50;
}

.logo a {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease;
}

.logo a:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-link {
    color: #cccccc;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: #3a3a3a;
    color: #ffffff;
}

.nav-link.active {
    background: #4CAF50;
    color: #ffffff;
}



/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    padding: 20px;
    gap: 20px;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Course Progress */
.course-progress { 
    background: #242424; 
    border: 1px solid #3a3a3a; 
    border-radius: 8px; 
    padding: 12px 16px; 
    margin-bottom: 16px; 
}
.cp-label { 
    color: #cccccc; 
    font-size: 13px; 
    margin-bottom: 8px; 
}
.cp-bar { 
    width: 100%; 
    height: 10px; 
    background: #1a1a1a; 
    border: 1px solid #333; 
    border-radius: 6px; 
    overflow: hidden; 
}
.cp-fill { 
    height: 100%; 
    width: 0%; 
    background: linear-gradient(90deg, #4CAF50, #7C4DFF); 
    transition: width .3s ease; 
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2a2a2a;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #3a3a3a;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    color: #888888;
    font-size: 14px;
}

.stat-value {
    font-weight: bold;
    color: #4CAF50;
}

.timer {
    background: #4CAF50;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: bold;
}

/* Typing Area */
.typing-area {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    border: 1px solid #3a3a3a;
}

/* Вьюпорт текста упражнения */
.exercise-viewport {
    height: 123px;
    overflow: hidden;
    position: relative;
}

.exercise-text {
    font-size: 22px;
    line-height: 1.5;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    transition: transform 0.18s ease-out;
    will-change: transform;
}

.exercise-line {
    margin: 0;
}

.character {
    display: inline-block;
    padding: 2px 1px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.character.correct {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.character.incorrect {
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    text-decoration: underline;
}

.character.current {
    background: #4CAF50;
    color: white;
    animation: blink 1s infinite;
}

/* При ошибке подсветим текущий символ красным фоном */
.character.current.error {
    background: #f44336;
    color: #ffffff;
    animation: none;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.5; }
}

.input-area {
    width: 100%;
    height: 60px;
    background: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    padding: 15px;
    font-size: 22px; /* читаемый размер печатаемого текста */
    line-height: 1.5;
    font-weight: 700;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color 0.3s ease;
}

.input-area:focus {
    border-color: #4CAF50;
}

/* Ошибочный ввод — красная окантовка */
.input-area.error {
    border-color: #f44336;
    box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.25);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    width: 92%;
    max-width: 520px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #3a3a3a;
}
.modal-title { font-weight: 700; color: #4CAF50; }
.modal-close { background: transparent; border: none; color: #ccc; font-size: 22px; cursor: pointer; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 16px; }
.auth-form .auth-row { margin-bottom: 10px; }
.auth-actions { display: flex; gap: 10px; margin-top: 6px; }
.auth-alt { color: #aaa; margin-top: 12px; }
.auth-providers { display: flex; gap: 8px; margin-top: 6px; }
.auth-user { display: flex; align-items: center; gap: 12px; }

/* Кнопки в модалке должны быть по размеру текста, а не 32x32 */
.modal .fullscreen-toggle {
    width: auto;
    height: auto;
    padding: 8px 14px;
}

/* Virtual Keyboard */
.keyboard-container {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px 80px; /* Увеличиваем боковые отступы для боковых клавиш */
    border: 1px solid #3a3a3a;
    position: relative; /* Для правильного позиционирования боковых клавиш */
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key {
    width: 50px;
    height: 50px;
    background: #3a3a3a;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.key:hover {
    background: #4a4a4a;
}

.key.active {
    background: #4CAF50;
    color: white;
    transform: scale(1.05);
}

.key.space {
    width: 200px;
}

.key.enter {
    width: 80px;
}

.key.shift {
    width: 80px;
}

.key.ctrl, .key.alt {
    width: 60px;
}

.key .cyrillic {
    font-size: 12px;
    color: #888888;
    position: absolute;
    top: 2px;
    left: 2px;
}

/* Боковые клавиши */
.keyboard-side-left {
    position: absolute;
    left: -60px; /* Позиционируем сбоку от основной клавиатуры */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.keyboard-side-right {
    position: absolute;
    right: -60px; /* Позиционируем сбоку от основной клавиатуры */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Адаптивность для узких экранов - уменьшаем отступ боковых клавиш */
@media (max-width: 1400px) {
    .keyboard-container {
        padding: 20px 70px;
    }
    .keyboard-side-left {
        left: -50px;
    }
    .keyboard-side-right {
        right: -50px;
    }
}

@media (max-width: 1300px) {
    .keyboard-container {
        padding: 20px 60px;
    }
    .keyboard-side-left {
        left: -40px;
    }
    .keyboard-side-right {
        right: -40px;
    }
}

/* Hands */
.hands {
    position: relative;
    margin-top: 20px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

.hand {
    position: relative;
    width: 60px;
    height: 100px;
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
    border: 2px solid #333333;
    border-radius: 30px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.hand.left {
    transform: rotate(-15deg);
}

.hand.right {
    transform: rotate(15deg);
}

.finger {
    position: absolute;
    width: 12px;
    height: 30px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.finger.active {
    background: #4CAF50;
    border-color: #45a049;
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.4);
}

/* Пальцы левой руки - с отступами */
.finger.thumb-left {
    left: 22px;
    top: 62px;
    width: 16px;
    height: 24px;
    border-radius: 8px;
}

.finger.pinky-left {
    left: 6px;
    top: 14px;
}

.finger.ring-left {
    left: 16px;
    top: 12px;
}

.finger.middle-left {
    left: 26px;
    top: 10px;
}

.finger.index-left {
    left: 36px;
    top: 12px;
}

/* Пальцы правой руки - с отступами */
.finger.thumb-right {
    right: 22px;
    top: 62px;
    width: 16px;
    height: 24px;
    border-radius: 8px;
}

.finger.pinky-right {
    right: 6px;
    top: 14px;
}

.finger.ring-right {
    right: 16px;
    top: 12px;
}

.finger.middle-right {
    right: 26px;
    top: 10px;
}

.finger.index-right {
    right: 36px;
    top: 12px;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background: #2a2a2a;
    border-left: 1px solid #3a3a3a;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Smart Hints */
.smart-hints {
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 20px;
}
.smart-hints .sh-header { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.smart-hints .sh-icon { font-size:18px; }
.smart-hints .sh-title { font-weight:700; color:#ffffff; }
.smart-hints .sh-badge { margin-left:auto; font-size:12px; color:#c4a2ff; background:#3a2f52; border:1px solid #4a3f6a; padding:2px 8px; border-radius:12px; }
.smart-hints .sh-empty { color:#aaaaaa; font-size:13px; }
.smart-hints .sh-list { display:flex; flex-direction:column; gap:10px; }
.smart-hints .sh-item { background:#1f1f1f; border:1px solid #343434; border-radius:8px; padding:10px; position:relative; }
.smart-hints .sh-item .sh-item-top { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.smart-hints .sh-chip { font-size:12px; color:#ffffff; background:#4CAF50; border-radius:10px; padding:2px 8px; }
.smart-hints .type-posture .sh-chip { background:#7C4DFF; }
.smart-hints .type-celebrate .sh-chip { background:#FFC107; color:#222; }
.smart-hints .type-progress .sh-chip { background:#66BB6A; }
.smart-hints .type-rhythm .sh-chip { background:#03A9F4; }
.smart-hints .sh-meta { margin-left:auto; font-size:12px; color:#aaaaaa; }
.smart-hints .sh-text { color:#dddddd; font-size:14px; line-height:1.4; }
.smart-hints .sh-pulse { position:absolute; right:10px; top:10px; width:10px; height:10px; border-radius:50%; background:#03A9F4; box-shadow: 0 0 0 0 rgba(3,169,244,0.7); animation: shPulse 1000ms infinite ease-in-out; }

@keyframes shPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(3,169,244,0.5); }
    70% { transform: scale(1.4); box-shadow: 0 0 0 10px rgba(3,169,244,0.0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(3,169,244,0.0); }
}

/* Motivation */
.motivation-section { background: #242424; border: 1px solid #3a3a3a; border-radius: 8px; padding: 14px; margin-bottom: 20px; }
.mot-title { font-weight: bold; color: #4CAF50; margin-bottom: 10px; }
.mot-streak { display: flex; justify-content: space-between; color: #cccccc; margin-bottom: 10px; font-size: 14px; }
.mot-streak .best { color: #aaaaaa; }
.mot-goal { margin-bottom: 10px; }
.mot-goal-label { color: #cccccc; font-size: 13px; margin-bottom: 6px; }
.mot-progress { height: 8px; background: #1a1a1a; border: 1px solid #333; border-radius: 6px; overflow: hidden; }
.mot-progress-bar { height: 100%; background: linear-gradient(90deg, #4CAF50, #7C4DFF); width: 0; transition: width .3s ease; }
.mot-challenge { background: #202020; border: 1px dashed #3a3a3a; border-radius: 8px; padding: 10px; color: #cccccc; font-size: 13px; }
.mot-ch-title { font-weight: bold; margin-bottom: 6px; color: #ffffff; }
.mot-ch-desc { margin-bottom: 4px; }
.mot-ch-progress { color: #aaaaaa; }

.lesson-section {
    margin-bottom: 25px;
}

.lesson-title {
    font-size: 18px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.lesson-title:hover {
    color: #66BB6A;
}

.lesson-title .arrow {
    transition: transform 0.2s ease;
    color: #cccccc;
    display: inline-flex;
}

.lesson-title.expanded .arrow {
    transform: rotate(180deg);
}

.lesson-items {
    margin-left: 12px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.38s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease-out;
    will-change: max-height, opacity;
}

.lesson-items.expanded {
    max-height: 1200px; /* достаточно для контента раздела */
    opacity: 1;
}

.lesson-item {
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #cccccc;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-height: 40px;
}

.lesson-item:hover {
    background: #3a3a3a;
    color: #ffffff;
}

.lesson-item.active {
    background: #4CAF50;
    color: #ffffff;
}

/* Locked lessons */
.lesson-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}
.lesson-item.locked:hover {
    background: transparent;
}
.lesson-item .lock-icon {
    display: inline-flex;
    vertical-align: middle;
    margin-right: 2px;
    color: #b0b0b0;
}

.lesson-item.completed {
    background: linear-gradient(90deg, rgba(76,175,80,0.12), rgba(124,77,255,0.08));
    color: #e0ffe6;
    border: 1px solid rgba(76,175,80,0.25);
}
.lesson-item.completed:hover {
    background: linear-gradient(90deg, rgba(76,175,80,0.18), rgba(124,77,255,0.12));
}
.lesson-item.active.completed {
    background: #4CAF50;
    color: #ffffff;
    border: none;
}
.lesson-item .check-icon {
    margin-left: auto;
    color: #66BB6A;
}

/* Мини-статистика у элементов урока */
.lesson-item-title {
    flex: 1 1 auto;
}
.mini-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    margin-left: auto;
}
.mini-acc {
    color: #66BB6A;
    font-weight: 700;
    font-size: 12px;
}
.mini-wpm {
    color: #9ec9ff;
    font-size: 12px;
}

/* Settings */
.settings {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #3a3a3a;
}

.settings-title {
    font-size: 16px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 15px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-label {
    display: block;
    margin-bottom: 5px;
    color: #cccccc;
    font-size: 14px;
}

.setting-control {
    width: 100%;
    padding: 8px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #ffffff;
    font-size: 14px;
}

.setting-control:focus {
    outline: none;
    border-color: #4CAF50;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #4CAF50;
}

/* Statistics Section */
.statistics-section {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #3a3a3a;
}

.stats-title {
    font-size: 18px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 15px;
}

.error-keys-container {
    margin-bottom: 20px;
}

.error-keys-title {
    font-size: 14px;
    color: #cccccc;
    margin-bottom: 10px;
}

.error-keys-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.error-key-item {
    background: #3a3a3a;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.error-key-item:hover {
    background: #4a4a4a;
}

.error-key-char {
    font-weight: bold;
    color: #f44336;
    font-size: 16px;
}

.error-key-char[title="Пробел"] {
    background: #f44336;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.error-key-count {
    background: #f44336;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.no-errors {
    color: #4CAF50;
    font-style: italic;
    padding: 10px;
    text-align: center;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 6px;
}

.overall-stats {
    border-top: 1px solid #3a3a3a;
    padding-top: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stat-row .stat-label {
    color: #888888;
    font-size: 14px;
}

.stat-row .stat-value {
    font-weight: bold;
    color: #4CAF50;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid #3a3a3a;
    }
}

@media (max-width: 768px) {
    .keyboard {
        transform: scale(0.8);
    }
    
    .typing-area {
        padding: 20px;
    }
    
    .exercise-text {
        font-size: 20px;
    }
    
    .hands {
        gap: 20px;
    }
    
    .hand {
        width: 50px;
        height: 80px;
    }
}

/* Бейдж микротеории на упражнении */
.lesson-item {
    position: relative;
}

.lesson-item.has-microtheory {
    border: 2px solid #45c46a !important;
    box-shadow: 0 0 15px rgba(69, 196, 106, 0.4), inset 0 0 10px rgba(69, 196, 106, 0.1);
    animation: microtheoryPulse 2s ease-in-out infinite;
}

@keyframes microtheoryPulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(69, 196, 106, 0.4), inset 0 0 10px rgba(69, 196, 106, 0.1);
    }
    50% {
        box-shadow: 0 0 25px rgba(69, 196, 106, 0.6), inset 0 0 15px rgba(69, 196, 106, 0.2);
    }
}

.microtheory-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #45c46a 0%, #3a9d5a 100%);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(69, 196, 106, 0.5), 0 0 0 2px #1a1a1a;
    z-index: 10;
    white-space: nowrap;
    animation: badgeBounce 0.5s ease-out;
}

.microtheory-badge .badge-icon {
    font-size: 12px;
    line-height: 1;
}

.microtheory-badge .badge-text {
    line-height: 1;
    letter-spacing: 0.3px;
}

@keyframes badgeBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Дополнительная подсветка для упражнения с микротеорией */
.lesson-item.has-microtheory::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, rgba(69, 196, 106, 0.2) 0%, rgba(69, 196, 106, 0.05) 100%);
    border-radius: 6px;
    z-index: -1;
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.8;
    }
}


