/**
 * TELC B1 — Современный минималистичный дизайн
 *
 * ПРИНЦИПЫ ДИЗАЙНА 2025:
 * ✨ Минимализм — чистый, воздушный интерфейс без лишних элементов
 * ⬜ White space — щедрые отступы (spacing-sm до spacing-xl)
 * 🌈 Градиенты — плавные переходы цветов для акцентов и заголовков
 * 📐 Grid — адаптивная сетка через CSS Grid (auto-fit, minmax)
 * 🌗 Dark mode — автоматическая поддержка через @media (prefers-color-scheme: dark)
 * 🔤 Inter — современный шрифт Google Fonts с вариативными весами
 * ♿ Accessibility — prefers-reduced-motion, семантичная разметка, WCAG контраст
 *
 * ЦВЕТОВАЯ ПАЛИТРА:
 * - Приглушенные, успокаивающие тона
 * - 4 градиента для разных разделов (Lesen, Hören, Schreiben, Sprechen)
 * - Автоматическое переключение на темную тему
 */

/* ============================================
   ТОКЕНЫ ДИЗАЙНА 2025
   ============================================ */

:root {
    /* Типографика */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Отступы (white space) */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 3rem;
    --spacing-xl: 4rem;

    /* Анимация */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);

    /* Радиусы */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    /* Градиенты */
    --gradient-accent-1: linear-gradient(135deg, #6366f1, #4f46e5);
    --gradient-accent-2: linear-gradient(135deg, #8b5cf6, #7c3aed);
    --gradient-accent-3: linear-gradient(135deg, #ec4899, #db2777);
    --gradient-accent-4: linear-gradient(135deg, #f59e0b, #ea580c);
}

/* ============================================
   СВЕТЛАЯ ТЕМА (по умолчанию)
   ============================================ */

:root,
html[data-theme="light"] {
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-surface-muted: #f8f9fa;
    --color-text: #1a1a1a;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-shadow: rgba(0, 0, 0, 0.06);
    --color-shadow-md: rgba(0, 0, 0, 0.10);
    --color-shadow-lg: rgba(0, 0, 0, 0.15);

    /* Акценты */
    --color-accent-1: #6366f1;
    --color-accent-2: #8b5cf6;
    --color-accent-3: #ec4899;
    --color-accent-4: #f59e0b;

    /* Состояния */
    --color-focus: #6366f1;
    --color-focus-ring: rgba(99, 102, 241, 0.2);

    /* Compatibility aliases */
    --color-card-bg: var(--color-surface);
    --color-text-light: var(--color-text-muted);
}

/* ============================================
   ТЁМНАЯ ТЕМА
   ============================================ */

html[data-theme="dark"] {
    --color-bg: #0a0a0a;
    --color-surface: #1a1a1a;
    --color-surface-muted: #171717;
    --color-text: #f5f5f5;
    --color-text-muted: #a3a3a3;
    --color-border: #2d2d2d;
    --color-shadow: rgba(0, 0, 0, 0.3);
    --color-shadow-md: rgba(0, 0, 0, 0.5);
    --color-shadow-lg: rgba(0, 0, 0, 0.7);

    /* Акценты - чуть ярче для тёмного фона */
    --color-accent-1: #818cf8;
    --color-accent-2: #a78bfa;
    --color-accent-3: #f472b6;
    --color-accent-4: #fbbf24;

    /* Состояния */
    --color-focus: #818cf8;
    --color-focus-ring: rgba(129, 140, 248, 0.3);

    /* Compatibility aliases */
    --color-card-bg: var(--color-surface);
    --color-text-light: var(--color-text-muted);
}

/* ============================================
   СИСТЕМНАЯ ТЕМА (prefers-color-scheme)
   ============================================ */

/* Применяем системную тему, только если пользователь не выбрал тему вручную */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --color-bg: #0a0a0a;
        --color-surface: #1a1a1a;
        --color-surface-muted: #171717;
        --color-text: #f5f5f5;
        --color-text-muted: #a3a3a3;
        --color-border: #2d2d2d;
        --color-shadow: rgba(0, 0, 0, 0.3);
        --color-shadow-md: rgba(0, 0, 0, 0.5);
        --color-shadow-lg: rgba(0, 0, 0, 0.7);

        --color-accent-1: #818cf8;
        --color-accent-2: #a78bfa;
        --color-accent-3: #f472b6;
        --color-accent-4: #fbbf24;

        --color-focus: #818cf8;
        --color-focus-ring: rgba(129, 140, 248, 0.3);
    }
}

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

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    padding: var(--spacing-md);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    width: 100%;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown 0.6s ease-out;
}

.title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--spacing-xs);
    background: linear-gradient(135deg, var(--color-accent-1), var(--color-accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--color-text-light);
    font-weight: 300;
}

/* Cards Grid */
.main-content {
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

/* Card Styles */
.card {
    background: var(--color-card-bg);
    border-radius: 24px;
    padding: var(--spacing-lg);
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: var(--transition);
    box-shadow: 0 4px 6px var(--color-shadow);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
}

/* Explanation details */
.text-explanation {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: linear-gradient(180deg, var(--color-surface-muted), var(--color-surface));
    box-shadow: 0 12px 24px var(--color-shadow);
}

.text-explanation-summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--color-text);
    transition: var(--transition-fast);
}

.text-explanation-summary::-webkit-details-marker {
    display: none;
}

.text-explanation-summary::marker {
    content: '';
}

.text-explanation-summary::after {
    content: '+';
    font-size: 0.85em;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.text-explanation[open] .text-explanation-summary::after {
    content: '-';
    opacity: 0.9;
}

.text-explanation-summary:hover {
    background: var(--color-surface);
}

.text-explanation-summary:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.text-explanation-content {
    margin-top: 0.6rem;
    display: grid;
    gap: 0.4rem;
    color: var(--color-text-muted);
}

.text-explanation[open] .text-explanation-content {
    animation: explanation-in 0.35s ease-out;
}

.text-explanation-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

.text-explanation-text,
.text-explanation-evidence {
    margin: 0;
}

.text-explanation-evidence {
    font-style: italic;
}

.gap-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    margin: 0 2px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-muted);
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.9em;
    line-height: 1;
}

@keyframes explanation-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .text-explanation[open] .text-explanation-content {
        animation: none;
    }
    .text-explanation-summary::after {
        transition: none;
    }
}

/* Status lines */
.text-status-line {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.86rem;
    color: var(--color-text-muted);
}

.text-status-line + .text-status-line {
    margin-top: 0.15rem;
}

.richtig,
.falsch,
.text-status.is-correct .text-status-line:first-child,
.text-status.is-wrong .text-status-line:first-child {
    padding-left: 0.55rem;
    border-left: 2px solid transparent;
    border-radius: 2px;
    color: var(--color-text);
}

.richtig,
.text-status.is-correct .text-status-line:first-child {
    border-left-color: rgba(34, 197, 94, 0.55);
}

.falsch,
.text-status.is-wrong .text-status-line:first-child {
    border-left-color: rgba(239, 68, 68, 0.55);
}

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

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px var(--color-shadow);
}

.card-icon {
    font-size: 3.5rem;
    margin-bottom: var(--spacing-sm);
    transition: var(--transition);
}

.card:hover .card-icon {
    transform: scale(1.1);
}

.card-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.card-description {
    font-size: 1rem;
    color: var(--color-text-light);
    font-weight: 300;
}

/* Индивидуальные цвета для карточек */
.card-lesen {
    --gradient-start: var(--color-accent-1);
    --gradient-end: #4f46e5;
}

.card-horen {
    --gradient-start: var(--color-accent-2);
    --gradient-end: #7c3aed;
}

.card-schreiben {
    --gradient-start: var(--color-accent-3);
    --gradient-end: #db2777;
}

.card-sprechen {
    --gradient-start: var(--color-accent-4);
    --gradient-end: #ea580c;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    color: var(--color-text-light);
    font-weight: 300;
    animation: fadeIn 0.6s ease-out 0.4s both;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .card {
        padding: var(--spacing-md);
    }

    body {
        padding: var(--spacing-sm);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ============================================
   ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ (левый верхний угол)
   ============================================ */

.theme-toggle {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--color-shadow);
    transition: var(--transition-fast);
    font-size: 1.25rem;
    color: var(--color-text);
}

/* Переключатель темы теперь находится в site-header */
.site-nav .theme-toggle {
    /* Убрано fixed позиционирование, теперь кнопка остается в navigation */
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px var(--color-shadow-md);
    border-color: var(--color-focus);
}

.theme-toggle:active {
    transform: scale(1);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* Адаптив для переключателя */
@media (max-width: 768px) {
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
}

/* ============================================
   ОБЩИЙ HEADER (для всех страниц)
   ============================================ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-sm) var(--spacing-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 1px 3px var(--color-shadow);
}

.site-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: var(--transition-fast);
}

.site-logo:hover {
    color: var(--color-accent-1);
}

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

.site-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.938rem;
    font-weight: 500;
    transition: var(--transition-fast);
    cursor: pointer;
    font-family: inherit;
}

.back-btn:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-focus);
    transform: translateX(-2px);
}

.back-btn:active {
    transform: translateX(0);
}

.back-btn:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* Адаптив для header */
@media (max-width: 768px) {
    .site-header {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .site-logo {
        font-size: 1.125rem;
    }

    .back-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .auth-widget {
        width: 100%;
        justify-content: flex-end;
    }

    .auth-email {
        display: none;
    }
}

/* ============================================
   LESEN PAGE - Task Cards (Минимализм 2025)
   ============================================ */

/* Task Card Container */
.task-card {
    background: var(--color-card-bg);
    border-radius: 24px;
    padding: var(--spacing-lg);
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    transition: var(--transition);
    box-shadow: 0 2px 8px var(--color-shadow);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid transparent;
}

/* Градиентный акцент - тонкая полоска сверху */
.task-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent, linear-gradient(90deg, var(--color-accent-1), var(--color-accent-2)));
    opacity: 0.8;
}

/* Subtle Hover Lift */
.task-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 24px var(--color-shadow);
    border-color: rgba(99, 102, 241, 0.1);
}

/* ============================================
   MONETIZATION UI
   ============================================ */

.auth-widget {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
}

.auth-email {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
}

.auth-btn {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.auth-btn:hover {
    border-color: var(--color-focus);
    transform: translateY(-1px);
}

.auth-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.auth-btn.secondary {
    background: transparent;
}

.auth-hidden {
    display: none;
}

#premium-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--color-accent-1);
    color: white;
}

.premium-hidden {
    display: none;
}

.gate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.gate-overlay[hidden] {
    display: none;
}

.gate-content {
    max-width: 420px;
    width: 100%;
    background: #121212;
    color: #f5f5f5;
    border-radius: 24px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.gate-content h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.gate-content p {
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.75);
}

.gate-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gate-btn.primary {
    background: linear-gradient(135deg, #47b0ff, #00d4ff);
    color: #0b0b0b;
}

.gate-btn.premium {
    background: linear-gradient(135deg, #ffb347, #ffcc33);
    color: #1a1206;
}

.gate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.gate-link {
    background: transparent;
    border: none;
    color: #93c5fd;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}

.gate-locked {
    overflow: hidden;
}

/* ============================================
   ADBLOCK GATE
   ============================================ */

.adblock-gate {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.2s ease-out;
}

.adblock-gate[hidden] {
    display: none;
}

.adblock-gate-content {
    max-width: 520px;
    width: 100%;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    border: 1px solid var(--color-border);
    box-shadow: 0 20px 50px var(--color-shadow-lg);
    animation: slideUp 0.3s ease-out;
}

.adblock-gate-content h2 {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

.adblock-gate-content p {
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.adblock-gate-message-en {
    margin-top: -0.75rem;
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.adblock-gate-actions {
    display: flex;
    justify-content: center;
}

.adblock-gate-btn {
    border: none;
    border-radius: var(--radius-full);
    padding: 0.75rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--color-accent-1);
    color: #fff;
    cursor: pointer;
    transition: var(--transition-fast);
    min-width: 220px;
}

.adblock-gate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 20px var(--color-shadow);
}

.adblock-gate-btn:active {
    transform: translateY(0);
}

.adblock-locked {
    overflow: hidden;
}

html.adblock-checking body > * {
    visibility: hidden;
}

html.adblock-checking #adblock-gate,
html.adblock-checking #adblock-gate * {
    visibility: visible;
}

@media (max-width: 720px) {
    .adblock-gate-content {
        padding: 1.5rem;
    }

    .adblock-gate-btn {
        width: 100%;
    }
}

/* ============================================
   CUSTOM CONSENT DIALOG (Fallback)
   ============================================ */

.consent-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

.consent-dialog-overlay[hidden] {
    display: none;
}

.consent-dialog-overlay[aria-hidden="true"] {
    animation: fadeOut 0.3s ease-out;
    pointer-events: none;
}

.consent-dialog-content {
    max-width: 480px;
    width: 100%;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 24px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 20px 50px var(--color-shadow-lg);
    border: 1px solid var(--color-border);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.consent-dialog-content h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.consent-dialog-content p {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: var(--color-text-muted);
}

.consent-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    margin-bottom: 0.75rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    transition: var(--transition-fast);
}

.consent-btn.primary {
    background: linear-gradient(135deg, var(--color-accent-1), var(--color-accent-2));
    color: white;
}

.consent-btn.secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.consent-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px var(--color-shadow-md);
}

.consent-btn:active {
    transform: translateY(0);
}

.consent-btn:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

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

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

/* Responsive */
@media (max-width: 480px) {
    .consent-dialog-content {
        padding: 1.5rem;
    }

    .consent-dialog-content h2 {
        font-size: 1.25rem;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .consent-dialog-overlay,
    .consent-dialog-content {
        animation: none !important;
    }
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    grid-template-areas:
        "main"
        "bottom";
}

.ad-sidebar {
    width: 300px;
}

.ad-sidebar.left {
    grid-area: left;
    display: none;
}

.ad-sidebar.right {
    grid-area: right;
    display: none;
}

.main-content {
    grid-area: main;
}

.ad-bottom {
    grid-area: bottom;
    display: none;
    width: 100%;
    margin-top: var(--spacing-lg);
}

/* Task container width control */
.task-container,
.main-content {
    max-width: 80%;
    margin: 0 auto;
}

body.ads-visible .task-container,
body.ads-visible .main-content {
    max-width: 100%;
}

body.ads-visible .content-wrapper {
    grid-template-columns: 300px minmax(0, 1fr) 300px;
    grid-template-areas:
        "left main right"
        "bottom bottom bottom";
    align-items: start;
}

body.ads-visible .ad-sidebar {
    display: block;
    position: sticky;
    top: 5rem;
}

body.ads-visible .ad-bottom {
    display: block;
}

@media (max-width: 1200px) {
    body.ads-visible .content-wrapper {
        grid-template-columns: minmax(0, 1fr);
    }

    body.ads-visible .ad-sidebar {
        display: none;
    }
}

@media (max-width: 640px) {
    body {
        padding: var(--spacing-xs);
    }

    .task-container,
    .main-content {
        max-width: 100% !important;
        padding: var(--spacing-sm);
    }
}

@media (max-width: 360px) {
    body {
        padding: 0.5rem;
    }

    .task-container,
    .main-content {
        padding: 0;
    }
}

/* ============================================
   ACCOUNT PAGE
   ============================================ */

.account-page .account-container {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-xl);
    display: grid;
    gap: var(--spacing-lg);
}

.account-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 24px;
    padding: var(--spacing-lg);
    box-shadow: 0 10px 24px var(--color-shadow);
}

.account-grid {
    display: grid;
    gap: var(--spacing-lg);
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.account-card h2 {
    margin-bottom: 0.75rem;
}

.account-placeholder {
    border: 1px dashed var(--color-border);
    background: var(--color-surface-muted);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.account-placeholder strong {
    display: block;
    font-weight: 600;
}

.account-placeholder p {
    margin: 0.35rem 0 0;
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.account-form {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.account-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--color-bg);
}

.account-input:disabled {
    background: var(--color-surface-muted);
    color: var(--color-text-light);
    cursor: not-allowed;
}

.account-label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 0.35rem;
}

.account-button {
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1.1rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--color-accent-1);
    color: white;
    font-family: inherit;
}

.account-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.account-button.secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.account-note {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: var(--color-surface-muted);
    font-size: 0.85rem;
}

.auth-error {
    margin-top: 0.75rem;
    color: #f87171;
    font-size: 0.85rem;
    display: none;
}

.auth-error-visible {
    display: block;
}

/* Focus state для accessibility */
.task-card:focus,
.task-card:focus-visible {
    outline: 3px solid var(--color-accent-1);
    outline-offset: 3px;
}

/* Task Card Header */
.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.task-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text);
    flex: 1;
}

/* Badge для статуса */
.task-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.task-badge.completed {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.task-badge.in-progress {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.task-badge.not-started {
    background: rgba(107, 114, 128, 0.15);
    color: var(--color-text-light);
}

/* Task Description */
.task-card-description {
    font-size: 0.938rem;
    color: var(--color-text-light);
    line-height: 1.6;
    margin-bottom: var(--spacing-xs);
}

/* Task Meta Info */
.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    align-items: center;
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-top: auto;
    padding-top: var(--spacing-sm);
    border-top: 1px solid rgba(107, 114, 128, 0.1);
}

.task-meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.task-meta-icon {
    font-size: 1rem;
    opacity: 0.7;
}

/* Task Tags */
.task-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: var(--spacing-xs);
}

.task-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--color-accent-1);
    font-weight: 500;
}

/* Gradient Variants - используем accent из manifest */
.task-card[data-accent="blue"] {
    --card-accent: linear-gradient(90deg, #3b82f6, #2563eb);
}

.task-card[data-accent="purple"] {
    --card-accent: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

.task-card[data-accent="pink"] {
    --card-accent: linear-gradient(90deg, #ec4899, #db2777);
}

.task-card[data-accent="orange"] {
    --card-accent: linear-gradient(90deg, #f59e0b, #ea580c);
}

.task-card[data-accent="green"] {
    --card-accent: linear-gradient(90deg, #10b981, #059669);
}

.task-card[data-accent="indigo"] {
    --card-accent: linear-gradient(90deg, #6366f1, #4f46e5);
}

/* Animation - Staggered Fade In */
.task-card {
    animation: taskFadeIn 0.5s ease-out backwards;
}

.task-card:nth-child(1) { animation-delay: 0.05s; }
.task-card:nth-child(2) { animation-delay: 0.1s; }
.task-card:nth-child(3) { animation-delay: 0.15s; }
.task-card:nth-child(4) { animation-delay: 0.2s; }
.task-card:nth-child(5) { animation-delay: 0.25s; }
.task-card:nth-child(6) { animation-delay: 0.3s; }

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

/* Difficulty Indicator */
.difficulty-dots {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.difficulty-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-text-light);
    opacity: 0.3;
}

.difficulty-dot.active {
    opacity: 1;
    background: var(--color-accent-1);
}

/* Responsive adjustments for Lesen page */
@media (max-width: 768px) {
    .task-card {
        padding: var(--spacing-md);
    }

    .task-card-title {
        font-size: 1rem;
    }

    .task-meta {
        font-size: 0.813rem;
    }
}


/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
    .task-card {
        border: 2px solid var(--color-text);
    }

    .task-badge {
        border: 1px solid currentColor;
    }
}

/* Reduced motion - disable staggered animations */
@media (prefers-reduced-motion: reduce) {
    .task-card {
        animation: none !important;
    }
}

/* ============================================
   ПОДСВЕТКА РЕЗУЛЬТАТОВ ПОИСКА
   ============================================ */

mark {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: var(--color-text);
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
    font-weight: 600;
}

html[data-theme="dark"] mark {
    background: linear-gradient(135deg, #713f12 0%, #854d0e 100%);
    color: #fef3c7;
}
