/* ========== БАЗОВЫЕ СТИЛИ ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Традиционные китайские цвета */
    --red-primary: #C8102E;
    --red-dark: #8B0000;
    --gold: #D4AF37;
    --gold-light: #F0E68C;
    --black: #1a1a1a;
    --white: #FFFFFF;
    --cream: #FFF8DC;
    --gray-light: #F5F5F5;
    --gray-medium: #CCCCCC;
    --gray-dark: #666666;
    
    /* Акцентные цвета */
    --jade: #00A86B;
    --blue-dark: #003366;
    
    /* Шрифты */
    --font-chinese: 'Noto Serif SC', serif;
    --font-main: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Тени */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    /* Переходы */
    --transition: all 0.3s ease;
}

html {
    height: 100%;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--cream) 0%, var(--white) 100%);
    color: var(--black);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Контент растягивается, подвал всегда внизу экрана,
   даже если на странице мало текста (например, "Грамматика" или профиль) */
.main {
    flex: 1 0 auto;
}

/* ========== ССЫЛКА "ПЕРЕЙТИ К СОДЕРЖИМОМУ" (для клавиатуры/скринридеров) ========== */
/* Спрятана визуально, но появляется по фокусу — так пользователь с клавиатурой
   может сразу перейти к контенту, минуя шапку и меню на каждой странице */
.skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    z-index: 2000;
    background: var(--red-primary);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 0 0 10px 10px;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* ========== УВАЖЕНИЕ К prefers-reduced-motion ========== */
/* Пользователи, попросившие ОС/браузер уменьшить анимации, получают
   мгновенные переходы вместо декоративных transition/animation.
   Функциональность (например, переворот карточки) при этом сохраняется —
   меняется только скорость, а не поведение. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== ШАПКА САЙТА ========== */
.header {
    background: linear-gradient(135deg, var(--red-primary) 0%, var(--red-dark) 100%);
    color: var(--white);
    padding: 20px 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-family: var(--font-chinese);
    font-size: 28px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.logo a:hover,
.logo a:visited,
.logo a:focus {
    color: inherit;
}

.logo span {
    font-family: var(--font-main);
    font-size: 18px;
    font-weight: 400;
    opacity: 0.95;
}

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

.nav-link {
    color: var(--white);
    text-decoration: none;
    font-weight: 400;
    padding: 8px 16px;
    border-radius: 6px;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Без этого правила класс .hidden на ссылке "Админ" ничего не менял
   визуально — кнопка была видна всем независимо от роли */
.nav-link.hidden {
    display: none;
}

/* ========== ГЛАВНАЯ СТРАНИЦА ========== */
.hero {
    text-align: center;
    padding: 60px 20px 40px;
}

.hero-title {
    font-family: var(--font-chinese);
    font-size: 42px;
    color: var(--red-primary);
    margin-bottom: 12px;
    font-weight: 600;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--gray-dark);
    margin-bottom: 40px;
}

.search-box-home {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    background: var(--white);
    padding: 8px;
    border-radius: 50px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--gold-light);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 20px;
    font-size: 16px;
    font-family: var(--font-main);
    background: transparent;
}

.search-button {
    background: var(--red-primary);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.search-button:hover {
    background: var(--red-dark);
    transform: scale(1.05);
}

/* ========== СЕТКА СЛОВАРЕЙ ========== */
.dictionaries {
    padding: 40px 0 80px;
}

/* Переключение между сеткой словарей и результатами глобального поиска
   на главной (проект не использует единый класс .hidden — у каждого
   компонента своё правило, это правило для обоих блоков showHome()) */
.dictionaries.hidden,
.words-section.hidden {
    display: none;
}

.dictionary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

.dictionary-card {
    background: var(--white);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    text-decoration: none;
    color: var(--black);
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--gold-light);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.dictionary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--red-primary), var(--gold));
    transform: scaleX(0);
    transition: var(--transition);
}

.dictionary-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--gold);
}

.dictionary-card:hover::before {
    transform: scaleX(1);
}

.card-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--red-primary);
    margin-bottom: 8px;
}

.card-description {
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 16px;
}

.card-count {
    display: inline-block;
    background: var(--gold-light);
    color: var(--red-dark);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* ========== СТРАНИЦА СЛОВАРЯ ========== */
.breadcrumbs {
    padding: 20px 0;
    font-size: 14px;
}

.breadcrumb-link {
    color: var(--red-primary);
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumb-link:hover {
    color: var(--red-dark);
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 8px;
    color: var(--gray-medium);
}

.breadcrumb-current {
    color: var(--gray-dark);
}

.dictionary-header {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    margin-bottom: 40px;
    box-shadow: var(--shadow-md);
    border-left: 6px solid var(--red-primary);
}

.dictionary-info {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 24px;
}

.dictionary-icon-large {
    font-size: 64px;
    flex-shrink: 0;
}

.dictionary-title {
    font-family: var(--font-chinese);
    font-size: 36px;
    color: var(--red-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.dictionary-subtitle {
    font-size: 16px;
    color: var(--gray-dark);
    margin-bottom: 12px;
}

.dictionary-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 14px;
    color: var(--gray-dark);
}

.meta-item {
    font-weight: 500;
}

.meta-separator {
    color: var(--gray-medium);
}

.search-box-small {
    max-width: 400px;
    display: flex;
    gap: 8px;
    background: var(--gray-light);
    padding: 6px;
    border-radius: 30px;
    border: 1px solid var(--gray-medium);
}

.dictionary-header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.flashcards-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: var(--red-primary);
    color: var(--white);
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: var(--transition);
}

.flashcards-btn:hover {
    background: var(--red-dark);
    box-shadow: var(--shadow-sm);
}

/* ========== СЕТКА СЛОВ ========== */
.words-section {
    padding-bottom: 60px;
}

.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.word-card {
    background: var(--white);
    padding: 24px 20px;
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    color: var(--black);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-light);
    transition: var(--transition);
}

.word-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--gold);
}

/* Бейдж словаря на карточке в результатах глобального поиска —
   в обычной сетке словаря его нет, т.к. там и так понятно, где ты */
.word-card-source {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--red-primary);
    background: rgba(200, 16, 46, 0.08);
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.home-search-results-count {
    text-align: center;
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 20px;
}

.word-chinese {
    font-family: var(--font-chinese);
    font-size: 32px;
    color: var(--red-primary);
    margin-bottom: 8px;
}

.word-pinyin {
    font-size: 16px;
    color: var(--gray-dark);
    font-style: italic;
    margin-bottom: 8px;
}

.word-translation {
    font-size: 14px;
    color: var(--gray-dark);
    font-weight: 500;
}

/* ========== СТРАНИЦА СЛОВА ========== */
.word-detail {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 60px;
}

.word-main {
    background: var(--white);
    padding: 50px 40px;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border-top: 6px solid var(--gold);
}

.word-header {
    text-align: center;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.word-chinese-large {
    font-family: var(--font-chinese);
    font-size: 96px;
    color: var(--red-primary);
    font-weight: 600;
}

.audio-button {
    background: var(--gold);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.audio-button:hover {
    background: var(--gold-light);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.word-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.info-item {
    text-align: center;
}

.info-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-dark);
    margin-bottom: 8px;
    font-weight: 500;
}

.info-value {
    font-size: 20px;
    color: var(--black);
    font-weight: 600;
}

.pinyin-large {
    font-family: var(--font-main);
    font-size: 28px;
    font-style: italic;
    color: var(--red-dark);
}

.tone {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    margin: 0 4px;
}

.tone-1 {
    background: #FFE5E5;
    color: #C8102E;
}

.tone-2 {
    background: #FFF4E5;
    color: #D4AF37;
}

.tone-3 {
    background: #E5F4FF;
    color: #003366;
}

.tone-4 {
    background: #E8F5E9;
    color: #00A86B;
}

/* ========== СЕКЦИИ ДЕТАЛЬНОЙ СТРАНИЦЫ ========== */
.associations-section,
.strokes-section,
.examples-section {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
}

.section-title {
    font-size: 24px;
    color: var(--red-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

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

.association-card {
    background: var(--cream);
    padding: 24px;
    border-radius: 12px;
    border-left: 4px solid var(--gold);
}

.association-text {
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 16px;
    color: var(--black);
}

.association-text:last-of-type {
    margin-bottom: 20px;
}

.association-text strong {
    font-family: var(--font-chinese);
    font-size: 20px;
    color: var(--red-primary);
}

.association-text em {
    color: var(--red-dark);
    font-style: normal;
    font-weight: 600;
}

.association-tip {
    background: var(--gold-light);
    padding: 16px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.6;
}

.association-tip strong {
    color: var(--red-dark);
}

/* ========== ПОРЯДОК НАПИСАНИЯ ========== */
.character-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.character-item {
    background: var(--gray-light);
    padding: 24px;
    border-radius: 12px;
    border: 2px solid var(--gray-medium);
}

.character-display {
    font-family: var(--font-chinese);
    font-size: 80px;
    text-align: center;
    color: var(--red-primary);
    margin-bottom: 20px;
}

.character-info {
    text-align: center;
}

.character-meta {
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 16px;
    font-weight: 500;
}

.stroke-order {
    text-align: left;
}

.stroke-step {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--white);
    border-radius: 6px;
    font-size: 14px;
    border-left: 3px solid var(--gold);
}

.practice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
}

.practice-box {
    aspect-ratio: 1;
    border: 2px dashed var(--gray-medium);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-chinese);
    font-size: 48px;
    color: var(--red-primary);
    background: var(--white);
}

.practice-box.light {
    color: var(--gray-medium);
    opacity: 0.4;
}

/* ========== ПРИМЕРЫ ========== */
.example-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.example-item {
    background: var(--gray-light);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid var(--jade);
}

.example-chinese {
    font-family: var(--font-chinese);
    font-size: 22px;
    color: var(--black);
    margin-bottom: 8px;
}

.example-pinyin {
    font-size: 16px;
    color: var(--gray-dark);
    font-style: italic;
    margin-bottom: 8px;
}

.example-translation {
    font-size: 15px;
    color: var(--red-dark);
    font-weight: 500;
}

/* ========== НАВИГАЦИЯ ========== */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.keyboard-hint {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-dark);
}

.keyboard-hint kbd {
    display: inline-block;
    padding: 2px 7px;
    font-family: inherit;
    font-size: 12px;
    background: var(--gray-light);
    border: 1px solid var(--gray-medium);
    border-bottom-width: 2px;
    border-radius: 4px;
}

.nav-button {
    padding: 12px 24px;
    background: var(--white);
    color: var(--red-primary);
    text-decoration: none;
    border-radius: 8px;
    border: 2px solid var(--red-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.nav-button:hover {
    background: var(--red-primary);
    color: var(--white);
}

.nav-button.back {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--white);
}

.nav-button.back:hover {
    background: var(--gold-light);
    border-color: var(--gold-light);
    color: var(--red-dark);
}

/* ========== ПОДВАЛ ========== */
.footer {
    background: linear-gradient(135deg, var(--red-dark) 0%, var(--black) 100%);
    color: var(--white);
    padding: 36px 0;
    margin-top: auto;
    border-top: 3px solid var(--gold);
    flex-shrink: 0;
}

.footer .container {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.footer-text {
    text-align: center;
    font-size: 14px;
    opacity: 0.9;
    letter-spacing: 0.3px;
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
    .hero-title {
        font-size: 32px;
    }
    
    .hero-subtitle {
        font-size: 16px;
    }
    
    .dictionary-grid {
        grid-template-columns: 1fr;
    }
    
    .words-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .word-chinese-large {
        font-size: 64px;
    }
    
    .word-main,
    .associations-section,
    .strokes-section,
    .examples-section {
        padding: 24px 20px;
    }
    
    .character-breakdown {
        grid-template-columns: 1fr;
    }
    
    .navigation-buttons {
        flex-direction: column;
    }
    
    .nav-button {
        justify-content: center;
    }
    
    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .logo {
        flex-direction: column;
        gap: 4px;
    }

    /* Меню + виджет входа: было в один тесный ряд без переноса — на телефоне
       не помещалось (либо вылезало за экран, либо сплющивалось). Теперь меню
       переносится на несколько строк и центрируется, а не жмётся в одну линию. */
    .header-right {
        flex-direction: column;
        gap: 14px;
        width: 100%;
    }

    .nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .nav-link {
        padding: 7px 12px;
        font-size: 14px;
    }

    .header-auth {
        display: flex;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .word-chinese-large {
        font-size: 48px;
    }
    
    .practice-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .nav {
        gap: 6px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
    }

    .user-badge-name {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ========== УВЕДОМЛЕНИЯ ========== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--red-primary);
    color: var(--white);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
    max-width: 300px;
}

.notification.fade-out {
    animation: slideOutRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ========== СТРАНИЦА ОШИБКИ ========== */
.error-page {
    text-align: center;
    padding: 100px 20px;
}

.error-page h2 {
    font-size: 36px;
    color: var(--red-primary);
    margin-bottom: 16px;
}

.error-page p {
    font-size: 18px;
    color: var(--gray-dark);
    margin-bottom: 32px;
}

/* ========== ПЛАВНАЯ ПРОКРУТКА ========== */
html {
    scroll-behavior: smooth;
}

/* ========== КЛИКАБЕЛЬНЫЙ ЛОГОТИП ========== */
.logo {
    cursor: pointer;
    transition: var(--transition);
}

.logo:hover {
    opacity: 0.9;
}

.logo a:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 4px;
    border-radius: 4px;
}

/* ========== СТРАНИЦА "О ПРОЕКТЕ" ========== */
.about-page {
    padding: 40px 0 80px;
}

.page-title {
    font-family: var(--font-chinese);
    font-size: 42px;
    color: var(--red-primary);
    text-align: center;
    margin-bottom: 60px;
    font-weight: 600;
}

.about-content {
    max-width: 900px;
    margin: 0 auto;
}

.about-section {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border-left: 6px solid var(--gold);
}

.about-subtitle {
    font-size: 24px;
    color: var(--red-primary);
    margin-bottom: 20px;
    font-weight: 600;
}

.about-text {
    font-size: 16px;
    line-height: 1.8;
    color: var(--black);
    margin-bottom: 16px;
}

.about-text:last-child {
    margin-bottom: 0;
}

.about-list {
    list-style: none;
    padding-left: 0;
    margin: 20px 0;
}

.about-list li {
    padding: 12px 0 12px 30px;
    position: relative;
    line-height: 1.6;
    font-size: 16px;
}

.about-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--red-primary);
    font-weight: bold;
    font-size: 18px;
}

.cta-section {
    text-align: center;
    border-left: 6px solid var(--red-primary);
    background: linear-gradient(135deg, var(--cream) 0%, var(--white) 100%);
}

.cta-button {
    background: var(--red-primary);
    color: var(--white);
    border: none;
    padding: 16px 40px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 20px;
    box-shadow: var(--shadow-md);
}

.cta-button:hover {
    background: var(--red-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.about-footer {
    background: var(--gray-light);
    padding: 30px;
    border-radius: 12px;
    margin-top: 40px;
    text-align: center;
}

.about-footnote {
    font-size: 14px;
    color: var(--gray-dark);
    line-height: 1.8;
}

/* ========== СТРАНИЦА "СКОРО ОТКРЫТИЕ" (Грамматика) ========== */
.coming-soon-page {
    padding: 60px 0 100px;
    display: flex;
    justify-content: center;
}

.coming-soon-card {
    background: var(--white);
    max-width: 560px;
    width: 100%;
    padding: 56px 44px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border-top: 6px solid var(--gold);
    text-align: center;
}

.coming-soon-icon {
    font-size: 64px;
    margin-bottom: 20px;
    line-height: 1;
}

.coming-soon-title {
    font-family: var(--font-chinese);
    font-size: 30px;
    color: var(--red-primary);
    font-weight: 600;
    margin-bottom: 14px;
}

.coming-soon-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 12px;
}

.coming-soon-subtext {
    font-size: 15px;
    color: var(--gray-dark);
    line-height: 1.7;
    margin-bottom: 30px;
}

/* ========== СТРАНИЦА ПРОФИЛЯ ========== */
.profile-page {
    padding: 40px 0 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.profile-page .page-title {
    width: 100%;
    max-width: 560px;
    text-align: left;
    margin-bottom: 24px;
}

.profile-card {
    background: var(--white);
    width: 100%;
    max-width: 560px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* --- Верхний блок с аватаром: небольшое "окошко" для фото, как в Telegram --- */
.profile-avatar-section {
    background: linear-gradient(135deg, var(--red-primary) 0%, var(--red-dark) 100%);
    padding: 40px 32px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile-avatar-wrapper {
    position: relative;
    width: 112px;
    height: 112px;
    margin-bottom: 16px;
}

.profile-avatar {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow-md);
    background: var(--gray-light);
    display: block;
}

/* Небольшая круглая кнопка-"окошко" поверх аватара для загрузки фото */
.avatar-upload-btn {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 36px;
    height: 36px;
    background: var(--gold);
    color: var(--red-dark);
    border: 2px solid var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.avatar-upload-btn:hover {
    background: var(--gold-light);
    transform: scale(1.08);
}

.avatar-input-hidden {
    display: none;
}

.profile-info-header {
    color: var(--white);
}

.profile-username {
    font-family: var(--font-chinese);
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-member-since {
    font-size: 13px;
    opacity: 0.85;
}

/* --- Нижний блок: поля профиля, идут друг за другом --- */
.profile-form {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.profile-field {
    display: flex;
    flex-direction: column;
}

.profile-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-dark);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}

/* Поле описания оформлено как карточка "О себе" в Telegram */
.profile-field textarea {
    width: 100%;
    min-height: 96px;
    resize: vertical;
    padding: 14px 16px;
    border: 2px solid var(--gray-light);
    background: var(--gray-light);
    border-radius: 14px;
    font-family: var(--font-main);
    font-size: 15px;
    line-height: 1.6;
    color: var(--black);
    outline: none;
    transition: var(--transition);
}

.profile-field textarea::placeholder {
    color: var(--gray-dark);
    opacity: 0.7;
}

.profile-field textarea:focus {
    border-color: var(--red-primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.profile-char-count {
    align-self: flex-end;
    font-size: 12px;
    color: var(--gray-dark);
    margin-top: 6px;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-save-btn {
    width: 100%;
    padding: 14px;
    background: var(--red-primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.profile-save-btn:hover {
    background: var(--red-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.profile-remove-avatar-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--gray-dark);
    border: 2px solid var(--gray-light);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.profile-remove-avatar-btn:hover {
    border-color: #f5c6cb;
    color: #a71d2a;
    background: #fdecea;
}

.profile-success {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--jade);
    background: rgba(0, 168, 107, 0.1);
    padding: 10px;
    border-radius: 10px;
}

.profile-success.hidden {
    display: none;
}

@media (max-width: 600px) {
    .profile-avatar-section {
        padding: 32px 24px 26px;
    }

    .profile-form {
        padding: 24px;
    }

    .coming-soon-card {
        padding: 40px 26px;
    }
}

/* ========== ШАПКА: АВТОРИЗАЦИЯ ========== */
.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-auth {
    position: relative;
}

.auth-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.auth-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    padding: 6px 6px 6px 14px;
}

.user-badge.hidden,
.auth-overlay.hidden,
.auth-form.hidden,
.auth-error.hidden,
.auth-header-btn.hidden {
    display: none;
}

/* Кнопка-ссылка на профиль в шапке: маленький круглый аватар + имя */
.user-profile-link {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--white);
    font-family: var(--font-main);
}

/* Маленький кружок для аватарки рядом с именем при входе в аккаунт */
.user-badge-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.7);
    display: block;
}

.user-badge-avatar.hidden {
    display: none;
}

.user-badge-name {
    font-size: 14px;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: none;
    border-radius: 50px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ========== МОДАЛЬНОЕ ОКНО АВТОРИЗАЦИИ ========== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.auth-modal {
    position: relative;
    background: var(--white);
    border-radius: 20px;
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.35s ease;
}

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

.auth-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-light);
    color: var(--gray-dark);
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-close:hover {
    background: var(--gray-medium);
    color: var(--black);
    transform: rotate(90deg);
}

.auth-modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-modal-title {
    font-family: var(--font-chinese);
    font-size: 32px;
    color: var(--red-primary);
    margin-bottom: 6px;
}

.auth-modal-subtitle {
    font-size: 15px;
    color: var(--gray-dark);
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--gray-light);
    border-radius: 12px;
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--gray-dark);
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--white);
    color: var(--red-primary);
    box-shadow: var(--shadow-sm);
}

.auth-field {
    margin-bottom: 18px;
}

.auth-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 6px;
}

.auth-field input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-medium);
    border-radius: 10px;
    font-size: 15px;
    font-family: var(--font-main);
    transition: var(--transition);
    outline: none;
}

.auth-field input:focus {
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

.auth-submit {
    width: 100%;
    padding: 14px;
    background: var(--red-primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 6px;
}

.auth-submit:hover {
    background: var(--red-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.auth-error {
    background: #fdecea;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .header-right {
        gap: 12px;
    }

    .nav {
        gap: 8px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 14px;
    }

    .user-badge-name {
        max-width: 80px;
        font-size: 13px;
    }

    .auth-modal {
        padding: 32px 24px 28px;
    }
}

/* ========== СПИСОК ТЕМ ГРАММАТИКИ ========== */
.grammar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.grammar-card {
    display: block;
    background: var(--white);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    border: 2px solid transparent;
}

.grammar-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gold-light);
    transform: translateY(-2px);
}

.grammar-card-level {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--red-primary);
    background: rgba(200, 16, 46, 0.08);
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.grammar-card-title {
    font-family: var(--font-chinese);
    font-size: 18px;
    color: var(--black);
    margin-bottom: 8px;
    line-height: 1.4;
}

.grammar-card-summary {
    font-size: 14px;
    color: var(--gray-dark);
    line-height: 1.5;
}

/* ========== ДЕТАЛЬНАЯ СТРАНИЦА ТЕМЫ ГРАММАТИКИ ========== */
.grammar-detail {
    background: var(--white);
    border-radius: 20px;
    padding: 36px;
    box-shadow: var(--shadow-md);
    max-width: 760px;
    margin: 0 auto;
}

.grammar-detail-level {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--red-primary);
    background: rgba(200, 16, 46, 0.08);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.grammar-detail-title {
    font-family: var(--font-chinese);
    font-size: 26px;
    color: var(--black);
    margin-bottom: 24px;
    line-height: 1.4;
}

.grammar-explanation {
    margin-bottom: 32px;
}

.grammar-paragraph {
    font-size: 15px;
    line-height: 1.8;
    color: var(--black);
    margin-bottom: 16px;
}

.grammar-paragraph:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .grammar-detail {
        padding: 24px 20px;
    }
}

/* ========== АДМИН-ПАНЕЛЬ: ВКЛАДКИ СЕКЦИЙ ========== */
.admin-section-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--gray-light);
}

.admin-section-tab {
    border: none;
    background: none;
    padding: 10px 18px;
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-dark);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.admin-section-tab:hover {
    color: var(--black);
}

.admin-section-tab.active {
    color: var(--red-primary);
    border-bottom-color: var(--red-primary);
}

.admin-section-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.admin-toolbar-count {
    font-size: 14px;
    color: var(--gray-dark);
    font-weight: 600;
}

.admin-textarea-large {
    min-height: 140px;
}

/* ========== АДМИН-ПАНЕЛЬ: СПИСОК СЛОВ ========== */
.admin-page {
    padding: 40px 0 90px;
}

.admin-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-page-header .page-title {
    margin-bottom: 0;
}

.admin-add-btn {
    padding: 12px 22px;
    background: var(--red-primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.admin-add-btn:hover {
    background: var(--red-dark);
    box-shadow: var(--shadow-md);
}

.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.admin-toolbar label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-dark);
}

.admin-toolbar select {
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid var(--gray-light);
    background: var(--white);
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--black);
    cursor: pointer;
}

.admin-word-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-word-row {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--white);
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.admin-word-main {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

.admin-word-chinese {
    font-family: var(--font-chinese);
    font-size: 20px;
    color: var(--red-primary);
}

.admin-word-pinyin {
    font-size: 14px;
    color: var(--gray-dark);
}

.admin-word-translation {
    font-size: 14px;
    color: var(--black);
}

.admin-word-dict-tag {
    font-size: 12px;
    color: var(--gray-dark);
    background: var(--gray-light);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.admin-word-actions {
    display: flex;
    gap: 8px;
}

.admin-edit-btn,
.admin-delete-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: var(--gray-light);
    cursor: pointer;
    font-size: 15px;
    transition: var(--transition);
}

.admin-edit-btn:hover {
    background: var(--gold-light);
}

.admin-delete-btn:hover {
    background: #fdecea;
}

.admin-empty {
    text-align: center;
    color: var(--gray-dark);
    padding: 40px 20px;
}

/* ========== АДМИН-ПАНЕЛЬ: МОДАЛЬНАЯ ФОРМА СЛОВА ========== */
.admin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.admin-overlay.hidden {
    display: none;
}

.admin-modal {
    position: relative;
    background: var(--white);
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.admin-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--gray-light);
    color: var(--gray-dark);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.admin-modal-close:hover {
    background: var(--gold-light);
    color: var(--black);
}

.admin-modal-title {
    font-family: var(--font-chinese);
    font-size: 22px;
    color: var(--red-primary);
    margin-bottom: 20px;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.admin-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
}

.admin-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-dark);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.admin-field input,
.admin-field select,
.admin-field textarea {
    padding: 10px 12px;
    border: 2px solid var(--gray-light);
    background: var(--gray-light);
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--black);
    outline: none;
    transition: var(--transition);
}

.admin-field textarea {
    min-height: 64px;
    resize: vertical;
}

.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
    border-color: var(--red-primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.admin-subsection {
    border-top: 1px solid var(--gray-light);
    padding-top: 16px;
}

.admin-subsection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.admin-subsection-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--black);
}

.admin-add-row-btn {
    border: none;
    background: none;
    color: var(--red-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}

.admin-add-row-btn:hover {
    text-decoration: underline;
}

.admin-char-row,
.admin-example-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr auto;
    gap: 8px;
    margin-bottom: 8px;
}

.admin-char-row input,
.admin-example-row input {
    padding: 8px 10px;
    border: 2px solid var(--gray-light);
    background: var(--gray-light);
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--black);
    outline: none;
}

.admin-char-row input:focus,
.admin-example-row input:focus {
    border-color: var(--red-primary);
    background: var(--white);
}

.admin-remove-row-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--gray-light);
    color: var(--gray-dark);
    cursor: pointer;
    font-size: 13px;
}

.admin-remove-row-btn:hover {
    background: #fdecea;
    color: #a71d2a;
}

.admin-error {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #a71d2a;
    background: #fdecea;
    padding: 10px;
    border-radius: 10px;
}

.admin-error.hidden {
    display: none;
}

.admin-form-actions {
    display: flex;
    justify-content: flex-end;
}

.admin-submit-btn {
    padding: 12px 28px;
    background: var(--red-primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.admin-submit-btn:hover {
    background: var(--red-dark);
}

.admin-submit-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

@media (max-width: 600px) {
    .admin-modal {
        padding: 24px 20px;
    }

    .admin-char-row,
    .admin-example-row {
        grid-template-columns: 1fr;
    }

    .admin-word-row {
        flex-direction: column;
        align-items: flex-start;
    }
}
/* ========== КАРТОЧКИ-МЕМО: ЭКРАН НАСТРОЙКИ ========== */
.flashcards-setup {
    max-width: 480px;
    margin: 40px auto;
    text-align: center;
    background: var(--white);
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: var(--shadow-md);
}

.flashcards-setup-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.flashcards-setup-title {
    font-family: var(--font-chinese);
    font-size: 24px;
    color: var(--red-primary);
    margin-bottom: 10px;
}

.flashcards-setup-subtitle {
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 24px;
    line-height: 1.6;
}

.flashcards-mode-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    text-align: left;
}

.flashcards-mode-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--gray-light);
    border-radius: 12px;
    font-size: 14px;
    color: var(--black);
    cursor: pointer;
}

.flashcards-mode-option input[type="radio"] {
    accent-color: var(--red-primary);
    width: 16px;
    height: 16px;
}

.flashcards-mode-option:has(input:disabled) {
    opacity: 0.5;
    cursor: default;
}

.flashcards-setup-note {
    font-size: 13px;
    color: var(--gray-dark);
    background: var(--gold-light);
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.flashcards-start-btn {
    padding: 14px 32px;
    background: var(--red-primary);
    color: var(--white);
    border: none;
    border-radius: 50px;
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.flashcards-start-btn:hover {
    background: var(--red-dark);
    box-shadow: var(--shadow-md);
}

.flashcards-start-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ========== КАРТОЧКИ-МЕМО: САМА СЕССИЯ ========== */
.flashcards-session {
    max-width: 460px;
    margin: 24px auto 60px;
    text-align: center;
}

.flashcards-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-light);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}

.flashcards-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--red-primary));
    border-radius: 6px;
    transition: width 0.4s ease;
}

.flashcards-counter {
    font-size: 13px;
    color: var(--gray-dark);
    font-weight: 600;
    margin-bottom: 20px;
}

/* Карточка с 3D-переворотом: контейнер задаёт перспективу,
   .flashcard-inner поворачивается на 180°, а обе стороны спрятаны
   друг за другом через backface-visibility */
.flashcard {
    width: 100%;
    height: 300px;
    perspective: 1200px;
    cursor: pointer;
    margin-bottom: 20px;
}

.flashcard:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 4px;
    border-radius: 20px;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s;
    transform-style: preserve-3d;
}

.flashcard.is-flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    border-radius: 20px;
    background: var(--white);
    box-shadow: var(--shadow-md);
    backface-visibility: hidden;
    overflow-y: auto;
}

.flashcard-back {
    transform: rotateY(180deg);
    /* Ассоциация у некоторых слов длинная и не помещается в 260px —
       вместо того чтобы вылезать за пределы карточки (текст был виден
       без фона сверху/снизу), прижимаем контент к верху и даём прокрутку */
    justify-content: flex-start;
    padding-top: 28px;
}

.flashcard-translation {
    flex-shrink: 0;
}

.flashcard-chinese {
    font-family: var(--font-chinese);
    font-size: 48px;
    color: var(--red-primary);
}

.flashcard-pinyin {
    font-size: 18px;
    color: var(--gray-dark);
}

.flashcard-translation {
    font-size: 22px;
    font-weight: 600;
    color: var(--black);
    text-align: center;
}

.flashcard-association {
    font-size: 13px;
    color: var(--gray-dark);
    text-align: center;
    line-height: 1.45;
    flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
    .flashcard-inner {
        transition: none;
    }
}

.flashcards-hint {
    font-size: 13px;
    color: var(--gray-dark);
    min-height: 18px;
    margin-bottom: 16px;
}

.flashcards-answer-buttons {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 18px;
}

.flashcards-answer-buttons.hidden {
    visibility: hidden;
}

.flashcards-answer-btn {
    padding: 12px 26px;
    border-radius: 50px;
    border: 2px solid transparent;
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.flashcards-answer-btn.known {
    background: var(--red-primary);
    color: var(--white);
}

.flashcards-answer-btn.known:hover {
    background: var(--red-dark);
}

.flashcards-answer-btn.unknown {
    background: var(--gray-light);
    color: var(--black);
}

.flashcards-answer-btn.unknown:hover {
    background: var(--gray-medium);
}

.flashcards-exit-btn {
    border: none;
    background: none;
    color: var(--gray-dark);
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

/* ========== КАРТОЧКИ-МЕМО: ЭКРАН ИТОГОВ ========== */
.flashcards-summary {
    max-width: 460px;
    margin: 40px auto;
    text-align: center;
    background: var(--white);
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: var(--shadow-md);
}

.flashcards-summary-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.flashcards-summary-title {
    font-family: var(--font-chinese);
    font-size: 24px;
    color: var(--red-primary);
    margin-bottom: 10px;
}

.flashcards-summary-stats {
    font-size: 16px;
    color: var(--black);
    margin-bottom: 28px;
}

.flashcards-summary-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flashcards-secondary-btn {
    padding: 12px 24px;
    background: none;
    border: 2px solid var(--gray-light);
    border-radius: 50px;
    color: var(--gray-dark);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.flashcards-secondary-btn:hover {
    border-color: var(--gold);
    color: var(--black);
}

@media (max-width: 480px) {
    .flashcard {
        height: 220px;
    }

    .flashcard-chinese {
        font-size: 38px;
    }
}

/* ========== КНОПКА-ТРИГГЕР ТРЕНАЖЁРА НА СТРАНИЦЕ СЛОВА ========== */
.hanzi-trigger-wrapper {
    display: flex;
    justify-content: center;
    margin: 0 0 28px;
}

.hanzi-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 50px;
    border: 2px solid var(--gold);
    background: var(--white);
    color: var(--black);
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.hanzi-trigger-btn:hover {
    background: var(--gold-light);
    box-shadow: var(--shadow-sm);
}

/* ========== МОДАЛЬНОЕ ОКНО ТРЕНАЖЁРА ИЕРОГЛИФОВ ========== */
.hanzi-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.hanzi-overlay.hidden {
    display: none;
}

.hanzi-modal {
    position: relative;
    background: var(--white);
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.hanzi-modal-title {
    font-family: var(--font-chinese);
    font-size: 20px;
    color: var(--red-primary);
    margin-bottom: 6px;
}

.hanzi-modal-word {
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 18px;
}

.hanzi-char-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.hanzi-nav-dot {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 2px solid var(--gray-light);
    background: var(--gray-light);
    font-family: var(--font-chinese);
    font-size: 16px;
    color: var(--black);
    cursor: pointer;
    transition: var(--transition);
}

.hanzi-nav-dot:hover {
    border-color: var(--gold);
}

.hanzi-nav-dot.active {
    border-color: var(--red-primary);
    background: var(--white);
    color: var(--red-primary);
}

.hanzi-writer-stage {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.hanzi-writer-target {
    width: 220px;
    height: 220px;
    background: repeating-linear-gradient(
        var(--gray-light) 0 1px, transparent 1px 100%
    ), repeating-linear-gradient(
        90deg, var(--gray-light) 0 1px, transparent 1px 100%
    );
    background-size: 110px 110px;
    border: 2px solid var(--gray-light);
    border-radius: 12px;
}

.hanzi-char-meta {
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 8px;
    min-height: 20px;
}

.hanzi-quiz-feedback {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-dark);
    margin-bottom: 18px;
    min-height: 20px;
}

.hanzi-quiz-feedback.is-correct {
    color: #2e7d32;
}

.hanzi-quiz-feedback.is-mistake {
    color: #a71d2a;
}

.hanzi-quiz-feedback.is-complete {
    color: var(--red-primary);
}

.hanzi-error {
    font-size: 13px;
    color: #a71d2a;
    padding: 20px;
}

.hanzi-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hanzi-control-btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: 2px solid var(--gray-light);
    background: var(--gray-light);
    color: var(--black);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.hanzi-control-btn:hover {
    border-color: var(--gold);
    background: var(--gold-light);
}

@media (max-width: 480px) {
    .hanzi-modal {
        padding: 24px 18px;
    }

    .hanzi-writer-target {
        width: 180px;
        height: 180px;
    }
}

.learned-toggle-wrapper {
    display: flex;
    justify-content: center;
    margin: 4px 0 28px;
}

.guest-progress-note {
    text-align: center;
    font-size: 13px;
    color: var(--gray-dark);
    background: var(--gold-light);
    padding: 10px 16px;
    border-radius: 10px;
    max-width: 420px;
    margin: -16px auto 28px;
}

.learned-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 50px;
    border: 2px solid var(--red-primary);
    background: var(--white);
    color: var(--red-primary);
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.learned-toggle-btn:hover {
    background: rgba(200, 16, 46, 0.06);
}

.learned-toggle-btn.is-learned {
    background: var(--red-primary);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.learned-toggle-btn.is-learned:hover {
    background: var(--red-dark);
}

.learned-toggle-btn:disabled {
    opacity: 0.6;
    cursor: default;
}
.avatar-remove-btn {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 26px;
    height: 26px;
    background: var(--white);
    color: var(--red-primary);
    border: 2px solid var(--red-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.avatar-remove-btn:hover {
    background: var(--red-primary);
    color: var(--white);
    transform: scale(1.08);
}

/* ========== ВКЛАДКИ ПРОФИЛЯ ========== */
.profile-tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 16px 20px 0;
}

.profile-tab {
    flex: 1;
    max-width: 200px;
    border: none;
    background: var(--gray-light);
    color: var(--gray-dark);
    padding: 12px 20px;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.profile-tab:hover {
    background: var(--gold-light);
    color: var(--black);
}

.profile-tab.active {
    background: var(--red-primary);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.profile-panel {
    padding: 24px 32px 32px;
}

.profile-panel.hidden {
    display: none;
}

.profile-panel .profile-form {
    padding: 0;
}

/* ========== ВКЛАДКА «ПРОГРЕСС»: КОЛЬЦО-ПЕЧАТЬ ========== */
.progress-ring-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

/* Круговой индикатор на conic-gradient: --percent задаётся инлайн из JS */
.progress-ring {
    --percent: 0;
    width: 168px;
    height: 168px;
    border-radius: 50%;
    background: conic-gradient(
        var(--red-primary) calc(var(--percent) * 1%),
        var(--gray-light) calc(var(--percent) * 1%)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    position: relative;
}

/* Внутренний белый круг с золотой каёмкой — оформление в духе китайской печати */
.progress-ring-inner {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: inset 0 0 0 2px var(--gold-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.progress-ring-value {
    font-family: var(--font-chinese);
    font-size: 30px;
    font-weight: 700;
    color: var(--red-primary);
}

.progress-ring-caption {
    font-size: 12px;
    color: var(--gray-dark);
}

/* ========== ВКЛАДКА «ПРОГРЕСС»: КАРТОЧКИ ПО СЛОВАРЯМ ========== */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.progress-card {
    background: var(--gray-light);
    border-radius: 14px;
    padding: 14px 16px;
}

.progress-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
}

.progress-card-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-card-count {
    flex-shrink: 0;
    color: var(--gray-dark);
    font-weight: 500;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background: var(--white);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--red-primary));
    border-radius: 6px;
    transition: width 0.6s ease;
}

/* ========== ВКЛАДКА «ПРОГРЕСС»: ПУСТОЕ СОСТОЯНИЕ ========== */
.progress-empty {
    text-align: center;
    padding: 40px 20px;
}

.progress-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.progress-empty-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 6px;
}

.progress-empty-hint {
    font-size: 14px;
    color: var(--gray-dark);
}

@media (max-width: 600px) {
    .profile-tabs {
        padding: 14px 16px 0;
    }

    .profile-panel {
        padding: 20px 20px 28px;
    }

    .progress-ring {
        width: 144px;
        height: 144px;
    }

    .progress-ring-inner {
        width: 112px;
        height: 112px;
    }
}
