/* Клик-Реш — общий фундамент стилей.
   Подключается ПЕРЕД inline <style>, чтобы локальные правки страницы переопределяли базу. */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

/* Стек с кириллицей: если Google Fonts недоступен, остаются системные шрифты */
:root {
    --kr-font-sans: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Helvetica Neue', Arial, 'Noto Sans', 'Noto Sans Cyrillic', 'DejaVu Sans',
        sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
}

/* ---------- Сброс ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}
* {
    margin: 0;
    padding: 0;
    font-family: var(--kr-font-sans);
}

html {
    -webkit-text-size-adjust: 100%;
    font-family: var(--kr-font-sans);
}
img, svg, video { max-width: 100%; height: auto; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- Дизайн-токены (переменные) ---------- */
:root {
    --base-font-size: 16px;

    /* Цвета бренда */
    --color-primary: #ff9f43;
    --color-primary-dark: #e67e22;
    --color-accent-1: #3a7ca5;
    --color-accent-2: #4a9f8c;
    --color-text: #2c3e50;
    --color-bg: #f5f6f8;
    --color-card: #ffffff;
    --color-success: #27ae60;
    --color-danger:  #c0392b;
    --color-muted:   #7f8c8d;

    /* Радиусы и тени */
    --border-radius-xl: 50px;
    --border-radius-lg: 40px;
    --border-radius-md: 30px;
    --border-radius-sm: 20px;
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.15);

    /* Типографика и отступы */
    --header-padding: 0.8rem 2rem;
    --logo-size: 1.8rem;
    --logo-img-size: 50px;
    --btn-padding: 0.6rem 1.8rem;
    --modal-max-width: 500px;

    /* Анимации */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Фон как на главной (index.html): слой формул + координатная сетка */
.kr-index-background {
    background-color: #f5f6f8;
    background-image:
        url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%233a7ca5' opacity='0.12' font-style='italic'%3E%3Ctext x='15' y='30' font-size='14'%3Ea² + b² = c²%3C/text%3E%3Ctext x='100' y='55' font-size='11'%3Eπ ≈ 3.14%3C/text%3E%3Ctext x='10' y='80' font-size='13'%3Ey = kx + b%3C/text%3E%3Ctext x='115' y='105' font-size='10'%3ES = v·t%3C/text%3E%3Ctext x='20' y='130' font-size='12'%3E√x + √y = 7%3C/text%3E%3Ctext x='80' y='155' font-size='11'%3E42 ÷ 6 = 7%3C/text%3E%3Ctext x='15' y='180' font-size='13'%3Esin²α+cos²α=1%3C/text%3E%3C/g%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg width='250' height='250' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%234a9f8c' opacity='0.10' font-style='italic'%3E%3Ctext x='30' y='35' font-size='15'%3EA = πr²%3C/text%3E%3Ctext x='150' y='60' font-size='12'%3EP = 2(a+b)%3C/text%3E%3Ctext x='20' y='90' font-size='13'%3Ex² + 5x + 6 = 0%3C/text%3E%3Ctext x='140' y='115' font-size='11'%3E½ + ⅓ = ⅚%3C/text%3E%3Ctext x='35' y='145' font-size='14'%3E∑ n=1 to ∞%3C/text%3E%3Ctext x='130' y='170' font-size='12'%3EΔ = b²-4ac%3C/text%3E%3Ctext x='25' y='200' font-size='13'%3E3! = 3·2·1 = 6%3C/text%3E%3Ctext x='120' y='230' font-size='11'%3Ef(x) = x³-3x%3C/text%3E%3C/g%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg width='300' height='300' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23e67e22' opacity='0.08' font-style='italic'%3E%3Ctext x='50' y='40' font-size='16'%3E100% of 50 = 50%3C/text%3E%3Ctext x='180' y='70' font-size='13'%3E0.5 = ½ = 50%%3C/text%3E%3Ctext x='20' y='110' font-size='14'%3Eaₙ = a₁+(n-1)d%3C/text%3E%3Ctext x='160' y='140' font-size='12'%3Elog₂8 = 3%3C/text%3E%3Ctext x='40' y='175' font-size='15'%3E∫ x dx = x²/2%3C/text%3E%3Ctext x='170' y='210' font-size='13'%3Elim(n→∞) 1/n = 0%3C/text%3E%3Ctext x='30' y='245' font-size='14'%3E%3C/text%3E%3Ctext x='120' y='275' font-size='12'%3E%3C/text%3E%3C/g%3E%3C/svg%3E"),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 39px,
            rgba(180, 190, 200, 0.25) 39px,
            rgba(180, 190, 200, 0.25) 40px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 39px,
            rgba(180, 190, 200, 0.25) 39px,
            rgba(180, 190, 200, 0.25) 40px
        );
    background-size:
        200px 200px,
        250px 250px,
        300px 300px,
        100% 100%,
        100% 100%;
    background-position:
        0 0,
        120px 80px,
        250px 150px,
        0 0,
        0 0;
    background-repeat: repeat, repeat, repeat, repeat, repeat;
}

/* ---------- Доступность: reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .carousel-track { transition: none !important; }
    .logo:hover .logo-img,
    .btn:hover,
    .feature-card:hover,
    .close-btn:hover { transform: none !important; }
}

/* ---------- Утилиты ---------- */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* Базовый стиль для focus-visible — единообразный во всём приложении */
:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Подсказка: кнопка вверху, всплывающее окошко ---------- */
#taskModal .modal-content { position: relative; }
#taskModal #hintArea {
    position: absolute;
    top: 0.9rem;
    right: 3.2rem;          /* левее кнопки закрытия */
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
#taskModal #hintButton {
    margin-top: 0 !important;
    padding: 0.4rem 0.9rem !important;
    font-size: 0.85rem !important;
    border-radius: 20px !important;
}
#taskModal #hintText {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    width: min(280px, 70vw);
    max-width: 280px;
    margin-top: 0 !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.18);
    z-index: 6;
}
.more-hint-btn {
    margin-top: 0.6rem;
    background: #f39c12;
    color: #fff;
    border: none;
    border-radius: 18px;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}
.more-hint-btn:hover { background: #e67e22; }

/* ---------- Модалка выбора аватара ---------- */
#avatarPickerOverlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center; justify-content: center;
    z-index: 10001;
}
.avatar-picker {
    background: #fff;
    border-radius: 24px;
    padding: 1.4rem;
    max-width: 480px; width: 92%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.avatar-picker-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; font-size: 1.1rem;
}
.avatar-picker-close {
    background: none; border: none; font-size: 1.6rem; cursor: pointer; color: #7f8c8d;
}
.avatar-picker-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.7rem;
}
.avatar-pick-item {
    border: 3px solid transparent; border-radius: 16px;
    padding: 0.4rem; text-align: center; cursor: pointer;
    transition: 0.2s; background: #f7f9fc; font-size: 0.85rem;
}
.avatar-pick-item img { width: 100%; height: auto; max-width: 80px; }
.avatar-pick-item:hover { background: #fff3e0; }
.avatar-pick-item.active {
    border-color: #f39c12; background: #fff3e0;
}

/* ---------- Бэйдж награды в заголовке задания ---------- */
.task-reward-badge {
    display: inline-block;
    background: #fff3e0;
    color: #2c3e50;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    margin-left: 0.4rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* ---------- Лайтбокс для иллюстраций задач ---------- */
#taskModal img { cursor: zoom-in; }

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 2rem;
    cursor: zoom-out;
}
.lightbox-img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
    position: absolute;
    top: 1rem; right: 1.2rem;
    background: rgba(255,255,255,0.9);
    color: #2c3e50;
    border: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ---------- Базовое body (страницы переопределяют фон) ---------- */
body {
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* ---------- Техподдержка: фикс. футер + модалка (как на главной / student) ---------- */
html.kr-support-footer-pad {
    scroll-padding-bottom: 4rem;
}
html.kr-support-footer-pad body {
    padding-bottom: 3.75rem;
}

.kr-support-ticket-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem env(safe-area-inset-bottom, 0.5rem);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(245, 246, 248, 0.98));
    border-top: 3px solid var(--color-primary);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.1);
}

.kr-support-ticket-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 800;
    font-size: 0.95rem;
    color: #fff;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    box-shadow: 0 6px 18px rgba(230, 126, 34, 0.35);
    cursor: pointer;
    transition: var(--transition-smooth);
    min-height: 44px;
}

.kr-support-ticket-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

/* id + !important: перебивает локальные .modal и flex-раскладку body на student/teacher */
#supportTicketModal {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    z-index: 10050 !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    background: rgba(58, 124, 165, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#supportTicketModal.active {
    display: flex !important;
}

#supportTicketModal .kr-support-modal-dialog {
    position: relative;
    width: 100%;
    max-width: min(var(--modal-max-width), 96vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem 2.25rem 1.75rem;
    background: #fff;
    border-radius: var(--border-radius-lg);
    border: 5px solid #f39c12;
    box-shadow: 0 28px 50px -18px #3a7ca5, 0 0 0 10px #4a9f8c;
}

#supportTicketModal .kr-support-modal-close {
    position: absolute;
    top: 0.85rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    font-size: 1.85rem;
    line-height: 1;
    color: var(--color-accent-1);
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

#supportTicketModal .kr-support-modal-close:hover {
    color: var(--color-primary-dark);
    transform: rotate(90deg);
}

#supportTicketModal h2 {
    color: #e67e22;
    font-size: 1.55rem;
    margin: 0 2.5rem 0.75rem 0;
    font-weight: 800;
}

#supportTicketModal .kr-support-lead {
    color: var(--color-muted);
    font-size: 0.92rem;
    margin: 0 0 1rem;
    line-height: 1.45;
}

#supportTicketModal .kr-support-hint {
    background: #fff8ef;
    border: 1px dashed #f39c12;
    border-radius: 14px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #7d4d00;
}

#supportTicketModal .kr-support-hint a {
    color: #2980b9;
    font-weight: 700;
}

#supportTicketModal .kr-support-field {
    margin-bottom: 1rem;
}

#supportTicketModal .kr-support-field label {
    display: block;
    font-weight: 700;
    color: var(--color-accent-1);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

#supportTicketModal .kr-support-req {
    color: #c0392b;
}

#supportTicketModal .kr-support-field input,
#supportTicketModal .kr-support-field textarea {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 3px solid #f39c12;
    border-radius: 18px;
    font: inherit;
    font-size: 0.95rem;
    background: #fefefe;
}

#supportTicketModal .kr-support-field textarea {
    min-height: 120px;
    resize: vertical;
    border-radius: 22px;
}

#supportTicketModal .kr-support-field input:focus,
#supportTicketModal .kr-support-field textarea:focus {
    outline: none;
    border-color: var(--color-accent-2);
    box-shadow: 0 0 0 3px rgba(74, 159, 140, 0.2);
}

#supportTicketModal .kr-support-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

#supportTicketModal .kr-support-submit {
    padding: 0.65rem 1.4rem;
    border: none;
    border-radius: 22px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #27ae60, #1e8449);
    cursor: pointer;
    min-height: 44px;
}

#supportTicketModal .kr-support-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#supportTicketModal .kr-support-cancel {
    padding: 0.65rem 1.2rem;
    border: 2px solid #bdc3c7;
    border-radius: 22px;
    background: #ecf0f1;
    font-weight: 700;
    color: #34495e;
    cursor: pointer;
    min-height: 44px;
}

#supportTicketModal .kr-support-msg {
    margin-top: 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #27ae60;
}

#supportTicketModal .kr-support-msg:empty {
    display: none;
}

/* Прокрутка без видимой полосы в модальных окнах */
.modal-content,
#profileModal .modal-content,
#supportTicketModal .kr-support-modal-dialog,
.avatar-editor-card,
.profile-content {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-content::-webkit-scrollbar,
#profileModal .modal-content::-webkit-scrollbar,
#supportTicketModal .kr-support-modal-dialog::-webkit-scrollbar,
.avatar-editor-card::-webkit-scrollbar,
.profile-content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}
