@import url('https://fonts.googleapis.com/css2?family=Marck+Script&family=Nunito:wght@400;600;700;800;900&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    /* Основная палитра — современный индиго вместо "тетрадных" тонов */
    --primary: #6D5AE6;
    --primary-dark: #5642C9;
    --primary-light: #EEEAFC;
    --pink: #E667A0;
    --pink-light: #FCEAF2;
    --bg: #F5F4FB;
    --card-bg: #FFFFFF;
    --border: #EAE7F5;
    --ink: #241E33;
    --muted: #8A8398;
    --success: #34C77B;
    --success-light: #E8F9F0;
    --warning: #F6B93B;
    --warning-light: #FDF3E1;
    --danger: #F0576B;
    --danger-light: #FDEBEE;

    /* Совместимость со старыми именами переменных, чтобы всё перекрасилось разом */
    --plum: var(--primary);
    --plum-dark: var(--primary-dark);
    --lavender: #B4A9F5;
    --lavender-pale: var(--primary-light);
    --parchment: var(--bg);
    --parchment-line: var(--border);
    --pen-red: var(--danger);
    --gold: var(--warning);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: 'Nunito', sans-serif; font-weight: 800; color: var(--ink); margin-top: 0; }

/* ==== Каркас: боковое меню + основная область ==== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #FBFAFF 0%, var(--primary-light) 100%);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.sidebar-brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 50%; }
.sidebar-brand span { font-family: 'Marck Script', cursive; font-weight: 400; font-size: 1.5em; color: var(--ink); line-height: 1.1; }
.brand-subtitle { font-size: 0.52em; color: #A39EB0; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; margin-top: -3px; white-space: nowrap; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 13px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.9em;
    position: relative;
}
.sidebar-nav a:hover { background: #fff; color: var(--primary-dark); text-decoration: none; }
.sidebar-nav a.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 4px 12px rgba(109, 90, 230, 0.35); }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .nav-count {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.72em;
    font-weight: 800;
    border-radius: 50%;
    min-width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 10px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
}
.sidebar-user .avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; flex-shrink: 0;
}
.sidebar-user .info { min-width: 0; flex: 1; }
.sidebar-user .name { font-weight: 800; font-size: 0.88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role { font-size: 0.75em; color: var(--muted); }
.sidebar-logout {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 13px;
    margin-top: 4px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.88em;
}
.sidebar-logout:hover { background: var(--danger-light); color: var(--danger); text-decoration: none; }
.sidebar-logout svg { width: 17px; height: 17px; flex-shrink: 0; }

/* Роль-специфичная окраска бокового меню (как на референсе) */
.role-student .sidebar { background: linear-gradient(165deg, var(--primary) 0%, var(--primary-dark) 100%); border-right: none; }
.role-student .sidebar-brand span { color: #fff; }
.role-student .sidebar-nav a { color: rgba(255,255,255,0.75); }
.role-student .sidebar-nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.role-student .sidebar-nav a.active { background: #fff; color: var(--primary-dark); box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
.role-student .sidebar-user { border-top-color: rgba(255,255,255,0.18); }
.role-student .sidebar-user .name { color: #fff; }
.role-student .sidebar-user .role { color: rgba(255,255,255,0.65); }
.role-student .sidebar-user .avatar { background: rgba(255,255,255,0.2); }
.role-student .sidebar-logout { color: rgba(255,255,255,0.7); }
.role-student .sidebar-logout:hover { background: rgba(255,255,255,0.15); color: #fff; }

.role-parent .sidebar { background: linear-gradient(180deg, #FFFBFD 0%, var(--pink-light) 100%); }
.role-parent .sidebar-nav a.active { background: linear-gradient(135deg, var(--pink), #d8508c); color: #fff; box-shadow: 0 4px 12px rgba(230, 103, 160, 0.35); }
.role-parent .sidebar-nav a:hover { background: #fff; color: var(--pink); }
.role-parent .sidebar-user .avatar { background: linear-gradient(135deg, var(--pink), #d8508c); }


.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-inline {
    display: flex; justify-content: flex-end; align-items: center;
    gap: 12px;
    padding: 16px 28px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 28px 60px; width: 100%; }

/* Лендинг/логин без сайдбара — облегчённая шапка */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    color: var(--ink);
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar nav a { color: var(--ink); font-weight: 700; }

/* ==== Карточки ==== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(36, 30, 51, 0.04);
}

/* ==== Статистика (как в референсе — крупные цифры сверху) ==== */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 2px 10px rgba(36, 30, 51, 0.04);
}
.stat-card .num { font-size: 1.9em; font-weight: 900; color: var(--ink); line-height: 1.1; }
.stat-card .label { font-size: 0.85em; color: var(--muted); font-weight: 700; margin-top: 2px; }
.stat-card .sub { font-size: 0.78em; color: var(--success); font-weight: 700; margin-top: 4px; }

.brand-logo { display: flex; align-items: center; gap: 12px; }
.brand-logo img { height: 44px; width: 44px; object-fit: contain; }
.brand-logo span { font-family: 'Marck Script', cursive; font-weight: 400; font-size: 1.7em; color: var(--ink); }

/* ==== Кнопки ==== */
.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.92em;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    box-shadow: 0 2px 8px rgba(109, 90, 230, 0.28);
    transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; transform: translateY(-1px); box-shadow: 0 5px 14px rgba(109, 90, 230, 0.35); }
.btn:active { transform: translateY(0); }
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); box-shadow: none; }
.btn-secondary:hover { background: #E1DCFA; color: var(--primary-dark); box-shadow: none; transform: none; }
.btn-danger { background: var(--danger); box-shadow: 0 2px 8px rgba(240, 87, 107, 0.28); }
.btn-success { background: var(--success); box-shadow: 0 2px 8px rgba(52, 199, 123, 0.28); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--primary-light); color: var(--primary-dark); font-weight: 800; font-size: 0.85em; }
tr:last-child td { border-bottom: none; }

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 0.95em;
    font-family: 'Nunito', sans-serif;
    background: var(--card-bg);
    color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
label { font-weight: 700; font-size: 0.88em; color: var(--muted); display: block; margin-bottom: 4px; }

/* ==== Оценки — плоские цветные чипы вместо "ручки" ==== */
.grade {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 9px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: #fff;
    background: var(--muted);
    margin: 2px;
}
.grade-5 { background: #2E7FE0; }
.grade-4 { background: var(--success); }
.grade-3 { background: var(--warning); }
.grade-2 { background: var(--danger); }
.grade-1 { background: #7a1f1f; }
.grade-fraction { width: auto; padding: 0 8px; font-size: 0.85em; }

/* ==== Ввод оценки прямо с клавиатуры (как в Excel) ==== */
.grade-input {
    -webkit-appearance: none;
    appearance: none;
    -webkit-text-fill-color: #fff; /* iOS иначе может показывать системный чёрный текст поверх */
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-align: center;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    padding: 0;
    margin: 0;
    color: #fff;
    background: var(--muted);
    -webkit-box-shadow: none;
    box-shadow: none;
}
.grade-input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.grade-input.grade-empty { background: #fff !important; color: var(--ink) !important; -webkit-text-fill-color: var(--ink) !important; border: 1px dashed var(--border); }
.grade-input.grade-empty::placeholder { color: var(--border); font-weight: 400; }
.grade-input.grade-5 { background: #2E7FE0 !important; color: #fff !important; }
.grade-input.grade-4 { background: var(--success) !important; color: #fff !important; }
.grade-input.grade-3 { background: var(--warning) !important; color: #fff !important; }
.grade-input.grade-2 { background: var(--danger) !important; color: #fff !important; }
.grade-input.grade-1 { background: #7a1f1f !important; color: #fff !important; }

.badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 800;
}
.jamaliki-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: linear-gradient(135deg, var(--warning), #f8cc6e);
    color: #6b4f00;
    padding: 7px 16px;
    border-radius: 20px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    box-shadow: 0 2px 8px rgba(246, 185, 59, 0.35);
}
.jamaliki-badge img { width: 18px; height: 18px; }
.xp-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: linear-gradient(135deg, var(--primary), var(--lavender));
    color: #fff;
    padding: 7px 16px;
    border-radius: 20px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    box-shadow: 0 2px 8px rgba(109, 90, 230, 0.35);
}
.xp-badge img { width: 16px; height: 16px; }
.xp-spin { animation: xp-shine 4s ease-in-out infinite; }
@keyframes xp-shine {
    0%, 80%, 100% { filter: brightness(1) drop-shadow(0 0 0 transparent); transform: scale(1); }
    88% { filter: brightness(1.6) drop-shadow(0 0 4px rgba(180,169,245,0.9)); transform: scale(1.15); }
    94% { filter: brightness(1) drop-shadow(0 0 0 transparent); transform: scale(1); }
}
.jamalik-shine { animation: jamalik-shine 5s ease-in-out infinite; animation-delay: 1.5s; }
@keyframes jamalik-shine {
    0%, 82%, 100% { filter: brightness(1) drop-shadow(0 0 0 transparent); transform: scale(1); }
    90% { filter: brightness(1.7) drop-shadow(0 0 5px rgba(246,185,59,0.9)); transform: scale(1.15); }
    96% { filter: brightness(1) drop-shadow(0 0 0 transparent); transform: scale(1); }
}

.login-box { max-width: 400px; margin: 70px auto; }
.login-box h1 { text-align: center; font-family: 'Marck Script', cursive; font-weight: 400; color: var(--primary-dark); font-size: 2.4em; }

.notif { background: var(--primary-light); border-left: 4px solid var(--primary); padding: 12px 16px; border-radius: 10px; margin-bottom: 10px; color: var(--ink); }

.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }

/* ==== Вкладки предметов — современные пилюли ==== */
.subject-tabs { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding: 4px 2px 10px; }
.subject-tab {
    padding: 10px 20px; border-radius: 24px; font-weight: 800; font-size: 0.85em;
    color: #fff; opacity: 0.6; cursor: pointer; white-space: nowrap; border: none;
    transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.subject-tab:hover { opacity: 0.85; text-decoration: none; transform: translateY(-1px); }
.subject-tab.active { opacity: 1; box-shadow: 0 4px 12px rgba(0,0,0,0.18); transform: translateY(-1px); }
.subject-tab-add {
    padding: 10px 18px; border-radius: 24px; background: var(--border); color: var(--primary-dark);
    font-weight: 800; font-size: 0.85em; cursor: pointer; border: none; transition: background 0.15s ease;
}
.subject-tab-add:hover { background: var(--lavender); color: #fff; }

/* ==== Журнал — чёткая белая карточка, ничего не сливается ==== */
.journal-sheet {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 4px 16px rgba(36, 30, 51, 0.06);
}
.journal-date-picker {
    display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.journal-scroll { overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.journal-scroll::-webkit-scrollbar { height: 10px; }
.journal-scroll::-webkit-scrollbar-track { background: var(--bg); border-radius: 10px; }
.journal-scroll::-webkit-scrollbar-thumb { background: var(--lavender); border-radius: 10px; }
.journal-scroll table { min-width: 600px; }
.journal-scroll th.today-col, .journal-scroll td.today-col { background: var(--primary-light); }
.journal-scroll th.sticky-col, .journal-scroll td.sticky-col {
    position: sticky; left: 0; z-index: 2;
    background: #fff;
    box-shadow: 2px 0 5px rgba(36,30,51,0.08);
    text-align: left;
}
.journal-scroll th.sticky-col { z-index: 3; background: var(--bg); }

/* ==== Расписание — настенная таблица ==== */
.timetable-poster {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(36, 30, 51, 0.06);
    border: 1px solid var(--border);
}
.timetable-title { text-align: center; font-weight: 900; font-size: 1.15em; color: var(--ink); margin-bottom: 14px; }
.timetable-scroll { overflow-x: auto; }
.timetable-grid { width: 100%; border-collapse: separate; border-spacing: 4px; min-width: 480px; }
.timetable-grid th { background: var(--primary); color: #fff; padding: 8px 6px; border-radius: 8px; font-size: 0.8em; font-weight: 800; }
.timetable-grid th.today-day { background: var(--warning); color: #6b4f00; }
.timetable-grid td.time-col {
    background: var(--bg); color: var(--primary-dark); font-family: 'JetBrains Mono', monospace;
    font-weight: 700; font-size: 0.8em; padding: 10px 8px; border-radius: 8px; text-align: center; white-space: nowrap;
}
.timetable-grid td.cell { background: var(--primary-light); border-radius: 8px; text-align: center; padding: 10px 8px; font-size: 0.82em; font-weight: 700; color: var(--primary-dark); }
.timetable-grid td.cell.empty { background: var(--bg); }
.timetable-grid td.cell.today-day { box-shadow: inset 0 0 0 2px var(--warning); }

/* Расписание — карточки-таймлайн (используется в некоторых списках управления) */
.schedule-day-group { margin-bottom: 16px; }
.schedule-day-title { display: inline-block; background: var(--primary); color: #fff; font-weight: 800; font-size: 0.85em; padding: 5px 16px; border-radius: 20px; margin-bottom: 10px; }
.schedule-day-title.today { background: var(--warning); color: #6b4f00; }
.schedule-slot { display: flex; align-items: center; gap: 14px; background: var(--card-bg); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; padding: 10px 16px; margin-bottom: 8px; }
.schedule-slot .time { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--primary-dark); font-size: 1.05em; min-width: 58px; }
.schedule-slot .subject { font-weight: 700; flex: 1; }
.schedule-slot .class-tag { font-size: 0.8em; color: var(--muted); }

/* Чат-пузыри */
.bubble-me { background: var(--primary-light); }
.bubble-them { background: var(--bg); border: 1px solid var(--border); }

/* ==== Путь ученика ==== */
.path-track { display: flex; align-items: center; overflow-x: auto; padding: 14px 4px 20px 4px; gap: 2px; }
.path-step { display: flex; flex-direction: column; align-items: center; min-width: 58px; opacity: 0.35; flex-shrink: 0; }
.path-step.done { opacity: 0.7; }
.path-step.current { opacity: 1; }
.path-step .icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.3em; background: var(--primary-light); border: 2px solid transparent; }
.path-step.current .icon { background: linear-gradient(135deg, var(--primary), var(--lavender)); border-color: var(--warning); box-shadow: 0 0 0 4px var(--primary-light); transform: scale(1.15); }
.path-step .label { font-size: 0.68em; text-align: center; margin-top: 6px; font-weight: 700; color: var(--primary-dark); max-width: 64px; }
.path-connector { flex: 1; height: 3px; background: var(--border); min-width: 16px; }
.path-connector.done { background: var(--lavender); }

.xp-bar-outer { background: var(--border); border-radius: 20px; height: 16px; overflow: hidden; margin: 8px 0; }
.xp-bar-inner { background: linear-gradient(90deg, var(--primary), var(--lavender)); height: 100%; border-radius: 20px; transition: width 0.4s ease; }

/* ==== Иконки-кнопки в чате ==== */
.composer-icons { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary-dark);
    font-size: 1.15em; cursor: pointer; border: none;
    transition: background 0.15s ease, transform 0.1s ease; flex-shrink: 0;
}
.icon-btn:hover { background: var(--primary); color: #fff; transform: scale(1.06); }
.icon-btn.recording { background: var(--danger); color: #fff; animation: pulse-rec 1.1s infinite; }
@keyframes pulse-rec { 0% { box-shadow: 0 0 0 0 rgba(240, 87, 107, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(240, 87, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(240, 87, 107, 0); } }
.composer-chip { font-size: 0.8em; color: var(--primary-dark); background: var(--bg); border: 1px solid var(--border); padding: 4px 10px; border-radius: 14px; }
.composer-chip:empty { display: none; }

/* ==== Стикеры ==== */
.sticker-panel {
    max-height: 220px; overflow-y: auto;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px; margin-bottom: 10px;
}
.sticker-pack-label { font-size: 0.72em; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin: 6px 0 4px; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.sticker-thumb { border: none; background: none; padding: 4px; border-radius: 8px; cursor: pointer; transition: background 0.12s ease, transform 0.12s ease; }
.sticker-thumb:hover { background: var(--primary-light); transform: scale(1.08); }
.sticker-thumb img { width: 100%; height: auto; display: block; pointer-events: none; }
.chat-row .chat-bubble.sticker-bubble { background: transparent !important; border: none !important; padding: 0 !important; box-shadow: none !important; }

/* ==== Голосовые сообщения — свой плеер ==== */
.voice-msg { display: flex; align-items: center; gap: 8px; min-width: 180px; margin-top: 2px; }
.voice-play-btn {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
    border: none; background: var(--primary); color: #fff;
    font-size: 0.85em; cursor: pointer; display: flex; align-items: center; justify-content: center;
    padding: 0 0 0 2px;
}
.chat-row.me .voice-play-btn { background: rgba(255,255,255,0.9); color: var(--primary); }
.voice-progress { flex: 1; height: 4px; background: rgba(0,0,0,0.12); border-radius: 4px; cursor: pointer; position: relative; }
.chat-row.me .voice-progress { background: rgba(255,255,255,0.35); }
.voice-progress-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 4px; }
.chat-row.me .voice-progress-fill { background: #fff; }
.voice-time { font-size: 0.72em; opacity: 0.75; flex-shrink: 0; min-width: 30px; }

/* ==== Пересылка сообщений ==== */
.forward-widget { display: inline-block; position: relative; margin-top: 3px; }
.forward-widget summary {
    list-style: none; cursor: pointer;
    font-size: 0.72em; color: var(--muted); opacity: 0.6;
    display: inline-block; padding: 2px 4px;
}
.forward-widget summary:hover { opacity: 1; color: var(--primary); }
.forward-widget summary::-webkit-details-marker { display: none; }

/* ==== Колокольчик уведомлений ==== */
.bell-wrap { position: relative; display: inline-block; }
.bell-btn-wrap { background: var(--primary-light); color: var(--primary-dark); }
.bell-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: 0.65em; font-weight: 800; border-radius: 50%; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.bell-panel {
    display: none; position: absolute; top: 46px; right: 0; width: 300px; max-height: 400px; overflow-y: auto;
    background: var(--card-bg); color: var(--ink);
    border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(36,30,51,0.18);
    padding: 14px; z-index: 50; text-align: left;
    opacity: 0; transform: translateY(-8px) scale(0.98); transition: opacity 0.16s ease, transform 0.16s ease; pointer-events: none;
}
.bell-panel::before { content: ''; position: absolute; top: -7px; right: 14px; width: 14px; height: 14px; background: var(--card-bg); border-left: 1px solid var(--border); border-top: 1px solid var(--border); transform: rotate(45deg); }
.bell-panel.open { display: block; opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ==== Фото по клику ==== */
.photo-toggle-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-light); color: var(--primary-dark); border: none; padding: 8px 14px; border-radius: 20px; font-weight: 700; font-size: 0.85em; cursor: pointer; }
.photo-toggle-btn:hover { background: var(--primary); color: #fff; }
.photo-reveal { display: none; margin-top: 8px; }
.photo-reveal.shown { display: block; animation: fadeInPhoto 0.2s ease; }
@keyframes fadeInPhoto { from { opacity: 0; transform: scale(0.97);} to { opacity: 1; transform: scale(1);} }

.count-badge { display: inline-flex; align-items: center; justify-content: center; background: var(--danger); color: #fff; font-size: 0.7em; font-weight: 800; border-radius: 50%; min-width: 18px; height: 18px; padding: 0 4px; margin-left: 4px; vertical-align: middle; }

/* ==== Тесты — красивые карточки вопросов ==== */
.quiz-question-card { position: relative; padding-left: 62px; }
.quiz-qnum {
    position: absolute; left: 20px; top: 22px;
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--lavender));
    color: #fff; font-weight: 900; font-size: 0.95em;
    display: flex; align-items: center; justify-content: center;
}
.quiz-qtext { font-weight: 800; font-size: 1.05em; margin: 0 0 14px; color: var(--ink); }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    position: relative;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.quiz-option:hover { border-color: var(--lavender); background: var(--primary-light); }
.quiz-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.quiz-option:has(input:checked) { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 2px 8px rgba(109,90,230,0.18); }
.quiz-option:has(input:checked) .quiz-option-letter { background: var(--primary); color: #fff; }
.quiz-option-letter {
    flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
    background: var(--bg); color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.85em;
    transition: background 0.15s ease, color 0.15s ease;
}
.quiz-option-text { flex: 1; }

/* ==== Чаты — в стиле мессенджеров (ВК/Телеграм/WhatsApp) ==== */
.chat-wrap { display: flex; height: 72vh; min-height: 420px; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(36,30,51,0.06); border: 1px solid var(--border); }
.chat-sidebar { width: 260px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; background: var(--bg); }
.chat-sidebar-group { padding: 12px 14px 4px; font-size: 0.72em; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.chat-contact {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.12s ease;
}
.chat-contact:hover { background: var(--primary-light); text-decoration: none; }
.chat-contact.active { background: #fff; border-left-color: var(--primary); }
.chat-unread-badge {
    margin-left: auto; flex-shrink: 0;
    background: var(--danger); color: #fff;
    font-size: 0.72em; font-weight: 800;
    min-width: 20px; height: 20px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 6px;
}
.chat-contact-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: #fff; font-size: 1em;
    background: linear-gradient(135deg, var(--primary), var(--lavender));
}
.chat-contact-avatar.group { background: linear-gradient(135deg, var(--pink), #d8508c); }
.chat-contact-avatar.role-student { background: linear-gradient(135deg, #3E9BC1, #2C7A9E); }
.chat-contact-avatar.role-parent { background: linear-gradient(135deg, #F6B93B, #E09A1F); }
.chat-contact-avatar.role-teacher { background: linear-gradient(135deg, #6D5AE6, #4B2E5A); }
.chat-sender.role-student { color: #2C7A9E; }
.chat-sender.role-parent { color: #B8790A; }
.chat-contact-info { min-width: 0; flex: 1; }
.chat-contact-name { font-weight: 700; font-size: 0.9em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-role { font-size: 0.74em; color: var(--muted); }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 800; color: var(--ink); flex-shrink: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.chat-row { display: flex; margin-bottom: 6px; }
.chat-row.me { justify-content: flex-end; }
.chat-row.them { justify-content: flex-start; }
.chat-bubble-wrap { max-width: 70%; }
.chat-sender { font-size: 0.72em; font-weight: 700; color: var(--primary-dark); margin-bottom: 2px; padding: 0 4px; }
.chat-bubble {
    padding: 9px 14px;
    border-radius: 16px;
    font-size: 0.92em;
    line-height: 1.4;
    word-wrap: break-word;
}
.chat-row.me .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-row.them .chat-bubble { background: #fff; color: var(--ink); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-bubble img { max-width: 200px; border-radius: 10px; margin-top: 4px; display: block; }
.chat-bubble audio { margin-top: 4px; max-width: 220px; }
.chat-time { font-size: 0.65em; color: var(--muted); margin-top: 2px; padding: 0 4px; }
.chat-row.me .chat-time { text-align: right; }

.chat-composer-bar { padding: 12px 16px; border-top: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.chat-composer-bar textarea { margin-bottom: 8px; }
.chat-empty-state { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 0.9em; }

@media (max-width: 860px) {
    .chat-wrap { flex-direction: column; height: auto; }
    .chat-sidebar { width: 100%; max-height: 160px; border-right: none; border-bottom: 1px solid var(--border); }
    .chat-main { height: 60vh; }
}

/* ==== ДЗ — структурированные карточки ==== */
.hw-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 5px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(36,30,51,0.05);
}
.hw-card.status-pending { border-left-color: var(--warning); }
.hw-card.status-submitted { border-left-color: var(--primary); }
.hw-card.status-graded { border-left-color: var(--success); }
.hw-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.hw-card-title { font-weight: 800; font-size: 1.02em; margin: 0 0 4px; }
.hw-card-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hw-progress-track { background: var(--bg); border-radius: 20px; height: 8px; overflow: hidden; margin-top: 8px; width: 100%; }
.hw-progress-fill { background: linear-gradient(90deg, var(--primary), var(--lavender)); height: 100%; border-radius: 20px; }
.hw-student-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 10px;
    margin-top: 8px;
}
.hw-student-name { font-weight: 700; min-width: 120px; }

/* ==== Входящие работы (мессенджер-стиль) у учителя ==== */
.hw-inbox-student { border-bottom: 1px solid var(--border); padding: 10px 0; }
.hw-inbox-student summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    font-weight: 700;
}
.hw-inbox-student summary::-webkit-details-marker { display: none; }
.hw-inbox-count {
    background: var(--primary); color: #fff;
    font-size: 0.78em; font-weight: 800;
    padding: 2px 9px; border-radius: 12px;
}
.hw-inbox-item { background: var(--bg); border-radius: 12px; padding: 12px; margin: 10px 0 0 42px; }
.btn-grade-quick {
    width: 30px; height: 30px; border-radius: 8px; border: none;
    color: #fff; font-weight: 800; font-family: 'JetBrains Mono', monospace;
    cursor: pointer; font-size: 0.9em;
}
.btn-grade-quick.grade-5 { background: #2E7FE0; }
.btn-grade-quick.grade-4 { background: var(--success); }
.btn-grade-quick.grade-3 { background: var(--warning); }
.btn-grade-quick.grade-2 { background: var(--danger); }
.btn-grade-quick:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ==== Простые вкладки (переключатель классов, категорий) ==== */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a {
    padding: 8px 18px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.88em;
}
.tabs a:hover { background: var(--lavender); color: #fff; text-decoration: none; }
.tabs a.active { background: var(--primary); color: #fff; }

/* ==== Переключатель классов — яркие цветные плашки ==== */
.class-switcher { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.class-switch-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 22px 12px 12px;
    border-radius: 50px;
    background: var(--class-color, var(--primary));
    border: none;
    color: #fff;
    font-weight: 800;
    font-size: 0.95em;
    opacity: 0.55;
    box-shadow: 0 3px 8px rgba(36,30,51,0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.class-switch-btn .dot {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: rgba(255,255,255,0.28);
    display: flex; align-items: center; justify-content: center;
    font-size: 1em;
}
.class-switch-btn .dot::before { content: '📔'; }
.class-switch-btn:hover { opacity: 0.8; text-decoration: none; transform: translateY(-2px); }
.class-switch-btn.active {
    opacity: 1;
    box-shadow: 0 10px 22px rgba(36,30,51,0.28);
    transform: translateY(-4px) scale(1.05);
}

/* ==== Мобильная кнопка-гамбургер и затемнение фона ==== */
.mobile-menu-btn {
    display: none;
    position: fixed; top: 14px; left: 16px; z-index: 300;
    width: 46px; height: 46px; border-radius: 50%;
    background: var(--primary); color: #fff; border: none;
    font-size: 1.3em; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(75,46,90,0.3);
}
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(36,30,51,0.45);
    z-index: 190; opacity: 0; transition: opacity 0.2s ease;
}
.sidebar-backdrop.show { display: block; opacity: 1; }

@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .mobile-menu-btn { display: flex; }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 200;
        flex-direction: column;
        padding: 20px 16px;
        box-shadow: 6px 0 24px rgba(0,0,0,0.15);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-brand { padding: 4px 8px 22px; }
    .sidebar-nav { flex-direction: column; flex: 1; }
    .container { padding: 16px 14px 32px; }

    h2 { font-size: 1.25em; }
    .card { padding: 16px; border-radius: 14px; }
    .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .num { font-size: 1.5em; }

    .topbar-inline { padding: 12px 14px 12px 70px; }
    .flex-between { flex-direction: column; align-items: stretch; }
    .flex-between > * { width: 100%; }

    table { font-size: 0.85em; }
    .class-switcher { gap: 8px; }
    .class-switch-btn { padding: 10px 16px 10px 8px; font-size: 0.85em; }
    .class-switch-btn .dot { width: 24px; height: 24px; }

    .hw-card { padding: 14px; }
    .hw-student-row { flex-direction: column; align-items: stretch; }

    .journal-scroll table, .timetable-grid { min-width: 520px; }
    .journal-scroll th, .journal-scroll td { min-width: 90px; }
    .journal-scroll th.sticky-col, .journal-scroll td.sticky-col { min-width: 90px; max-width: 110px; }
    .mobile-scroll-hint { display: block !important; }
}

@media (max-width: 480px) {
    .stat-row { grid-template-columns: 1fr 1fr; }
    .path-track { gap: 0; }
    .quiz-question-card { padding-left: 54px; }
}
