:root {
    --bg-color: #f0f2f5;
    --text-color: #1a1a1a;
    --accent-color: #6366f1;
    --accent-light: #818cf8;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow: 0 12px 40px -12px rgba(31, 38, 135, 0.15);
    --radius: 28px;
    --card-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --card-bg: #ffffff;
    --input-bg: #f8fafc;
    --secondary-text: #64748b;
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
    --other-message-bg: #ffffff;
    --other-message-text: var(--text-color);
}

body.dark-theme {
    --bg-color: #020617;
    --text-color: #f8fafc;
    --accent-color: #818cf8;
    --accent-light: #6366f1;
    --glass-bg: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.5);
    --card-bg: #0f172a;
    --input-bg: #1e293b;
    --secondary-text: #94a3b8;
    --other-message-bg: var(--input-bg);
    --other-message-text: var(--text-color);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100dvh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
    margin: 0;
    padding: 0;
}

#app {
    height: 100%;
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    padding: 20px 16px calc(140px + var(--safe-area-bottom)); /* Увеличен отступ до 140px */
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    scroll-padding-bottom: 140px;
}

.screen.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Custom Scrollbar for Mobile */
::-webkit-scrollbar {
    width: 0px;
    height: 0px;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Glass UI Elements */
.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 30px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--shadow);
}

.main-header {
    width: 100%;
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.user-info span:first-child {
    font-weight: 800;
    font-size: 22px;
    display: block;
}

.user-info span:last-child {
    font-size: 13px;
    opacity: 0.5;
}

/* Glass Nav - Native Feel */
.glass-nav {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    height: 64px;
    border-radius: 20px;
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
}

/* Адаптация под Safe Area для iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .glass-nav {
        bottom: calc(env(safe-area-inset-bottom) + 10px);
    }
}

#app.ready .glass-nav {
    display: flex;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--secondary-text);
    width: 50px;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    font-size: 26px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-btn.active {
    color: var(--accent-color);
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-5px);
}

.nav-btn:active {
    transform: scale(0.9);
}

/* Role & Group Selection */
.role-grid, .groups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
}

.role-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    color: var(--text-color);
}

.role-card:active { transform: scale(0.95); }
.role-card i { font-size: 40px; color: var(--accent-color); }
.role-card span { font-weight: 700; font-size: 13px; }

.groups-grid {
    grid-template-columns: 1fr;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.group-item {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 14px;
    text-align: left;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    color: var(--text-color);
}

.group-item:active { background: #f8f9fa; }
.group-name { font-weight: 800; font-size: 16px; }
.group-dept { font-size: 11px; opacity: 0.5; }

/* Teacher Dashboard */
.teacher-view { display: none; width: 100%; }
.teacher-view.active { display: block; }

.mini-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    color: var(--text-color);
}

.mini-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05));
    pointer-events: none;
}

.student-info h4 { font-size: 14px; font-weight: 800; }
.student-info p { margin-bottom: 0; font-size: 11px; opacity: 0.5; }
.student-gpa { 
    background: var(--accent-light); 
    color: white; 
    padding: 4px 10px; 
    border-radius: 10px; 
    font-weight: 800; 
    font-size: 13px; 
}

/* Diary & Tabs */
.diary-tabs-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 5px 20px 5px;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 10;
    flex-shrink: 0; /* Не даем контейнеру сжиматься */
}

.diary-tabs-container::-webkit-scrollbar {
    display: none;
}

.diary-tab {
    flex: 0 0 auto;
    padding: 10px 18px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: var(--card-bg);
    font-weight: 700;
    font-size: 13px;
    color: var(--secondary-text);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.diary-tab.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

.diary-content { 
    display: none; 
    width: 100%; 
    animation: fadeInSlide 0.4s ease-out forwards;
    margin-top: 10px; /* Отступ от табов */
}

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

.diary-content.active { display: block; }

.grade-item {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    transition: transform 0.2s;
}

.grade-item:active { transform: scale(0.98); }

.grade-item.task-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.grade-item.task-card:active {
    transform: scale(0.98);
    background: rgba(99, 102, 241, 0.05);
}

.resource-card {
    background: linear-gradient(145deg, var(--card-bg), rgba(255,255,255,0.02));
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

body.dark-theme .resource-card {
    background: linear-gradient(145deg, #1e293b, #0f172a);
}

.schedule-item {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 18px;
    display: flex;
    gap: 15px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent-color);
    color: var(--text-color);
}

.schedule-time {
    display: flex;
    flex-direction: column;
    min-width: 60px;
    font-weight: 800;
    font-size: 13px;
    color: var(--accent-color);
}

.schedule-time .end { opacity: 0.5; font-size: 11px; }

/* Buttons */
.btn-main {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--accent-color);
    margin-top: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 30px;
    width: 100%;
}

.key {
    background: var(--card-bg);
    border: none;
    height: 60px;
    border-radius: 16px;
    font-size: 20px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    color: var(--text-color);
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.status-present {
    background: #ecfdf5;
    color: #10b981;
}

.status-absent {
    background: #fef2f2;
    color: #ef4444;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--input-bg);
    border: 2px solid var(--glass-border);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pin-dot.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.2);
}

#pin-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent-color);
    text-align: center;
    font-size: 32px;
    letter-spacing: 15px;
    padding: 10px;
    outline: none;
}

/* Main Screen Layout */
#main-screen {
    justify-content: flex-start;
}

.main-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.user-info { display: flex; flex-direction: column; }
#header-name { font-weight: 800; font-size: 18px; }
#header-status { font-size: 12px; color: #10b981; font-weight: 600; }

.icon-btn {
    background: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow);
}

/* 3D Card */
.card-perspective {
    perspective: 1200px;
    width: 100%;
    height: 220px;
    margin-bottom: 30px;
}

.student-card-3d {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    cursor: pointer;
}

.student-card-3d.flipped {
    transform: rotateY(180deg);
}

.screen main.content {
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-side {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius);
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.card-front {
    background: var(--card-gradient);
    color: white;
}

.card-back {
    background: white;
    color: var(--text-color);
    transform: rotateY(180deg);
}

.card-header { display: flex; justify-content: space-between; align-items: center; }
.card-chip { width: 40px; height: 30px; background: rgba(255,255,255,0.2); border-radius: 6px; }
.card-logo { font-size: 24px; }

#card-name { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
#card-spec { font-size: 12px; opacity: 0.8; }

.card-footer { display: flex; align-items: flex-end; gap: 20px; }
.stat-item { display: flex; flex-direction: column; }
.stat-item .label { font-size: 10px; opacity: 0.7; text-transform: uppercase; }
.stat-item .value { font-size: 18px; font-weight: 800; }

.stars { display: flex; gap: 4px; color: #fbbf24; margin-left: auto; }

/* AI Back Side */
.ai-header { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--accent-color); font-size: 14px; margin-bottom: 15px; }
.ai-text { font-size: 13px; line-height: 1.6; color: #4b5563; overflow-y: auto; flex-grow: 1; }
.card-back-footer { text-align: center; font-size: 10px; opacity: 0.5; margin-top: 10px; }

.stats-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    margin-bottom: 20px; /* Добавлен отступ снизу */
}

.mini-card i { font-size: 24px; color: var(--accent-color); }
.mini-card span { font-weight: 700; font-size: 14px; }

/* Nav */
.glass-nav {
    position: fixed;
    bottom: 25px;
    left: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 30px;
    display: flex;
    justify-content: space-around;
    box-shadow: var(--shadow);
}

.nav-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-btn.active { color: var(--accent-color); background: rgba(99, 102, 241, 0.1); }

/* Loader */
/* Timeline Viz */
.lesson-progress-container {
    margin-top: 15px;
    width: 100%;
}

.timeline-track {
    height: 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 10px;
    position: relative;
    overflow: visible;
    margin: 10px 0;
}

.timeline-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 10px;
    transition: width 1s linear;
}

.timeline-marker {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 16px;
    background: var(--accent-color);
    opacity: 0.5;
}

.timeline-marker.start { left: 0; }
.timeline-marker.end { right: 0; }

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    font-weight: 800;
    opacity: 0.4;
    text-transform: uppercase;
}

/* Navigation Redesign (Modern Pill Style) */
.glass-nav {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 400px;
    height: 75px;
    background: #ffffff;
    border-radius: 40px;
    display: none; /* Hidden by default, shown via .ready */
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.08);
    z-index: 1000;
    border: 1px solid rgba(0,0,0,0.02);
}

body.dark-theme .glass-nav {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#app.ready #student-nav { display: flex !important; }
#app.teacher-ready #teacher-nav { display: flex !important; }

.nav-btn, .t-nav-btn {
    background: none;
    border: none;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn i, .t-nav-btn i {
    font-size: 26px;
    color: #94a3b8; /* Inactive color */
    transition: all 0.3s;
}

.nav-btn.active .nav-icon-wrapper {
    background: rgba(99, 102, 241, 0.1);
}

.t-nav-btn.active .nav-icon-wrapper {
    background: rgba(168, 85, 247, 0.1);
}

.nav-btn.active i {
    color: var(--accent-color);
    transform: scale(1.1);
}

.t-nav-btn.active i {
    color: #a855f7;
    transform: scale(1.1);
}

/* Hide old teacher top nav */
.teacher-tabs-nav {
    display: none !important;
}

/* Adjust screens for new bottom nav */
.screen {
    padding-bottom: 120px !important;
}

.stats-dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 25px;
}

.dashboard-card {
    padding: 20px;
    border-radius: 24px;
    color: white;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.dashboard-card.primary { background: linear-gradient(135deg, #6366f1, #818cf8); }
.dashboard-card.success { background: linear-gradient(135deg, #10b981, #34d399); }

.card-label { font-size: 10px; font-weight: 800; opacity: 0.8; text-transform: uppercase; margin-bottom: 5px; }
.card-value { font-size: 28px; font-weight: 900; margin-bottom: 2px; }
.card-footer { font-size: 9px; opacity: 0.7; font-weight: 600; }

.section-title {
    font-size: 18px;
    font-weight: 900;
    margin-bottom: 15px;
    padding-left: 4px;
}

.dashboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.add-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-bar-container {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar-container input {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 14px;
    width: 100%;
    outline: none;
}

.groups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Skeleton Loader */
@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.skeleton {
    background: linear-gradient(90deg, var(--input-bg) 25%, var(--glass-border) 50%, var(--input-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Выше навигации */
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Поднято с 5000 до 10000, чтобы быть выше всех элементов */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.modal-content {
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
    transform: translateY(0);
}

/* Chat Styles */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.02);
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 4px;
}

.message-row.sent {
    justify-content: flex-end;
}

.message-row.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.sent .message-bubble {
    background: var(--accent-color);
    color: white;
    border-bottom-right-radius: 4px;
    margin-right: 2px;
}

.received .message-bubble {
    background: var(--card-bg);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--glass-border);
    margin-left: 2px;
}

.message-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 10px;
    opacity: 0.7;
}

.sent .message-info {
    color: rgba(255, 255, 255, 0.9);
}

.received .message-info {
    color: var(--text-color);
    opacity: 0.5;
}

.message-status {
    display: flex;
    align-items: center;
}

.message-status i {
    font-size: 14px;
}

/* Advanced 3D Flip Task Card Styles */
.task-card-wrapper {
    perspective: 1200px;
    margin-bottom: 20px;
    width: 100%;
    min-height: 200px;
    transition: min-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-card-wrapper.flipped {
    min-height: 350px; /* Увеличиваем высоту при перевороте */
}

.task-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.task-card-wrapper.flipped .task-card-inner {
    transform: rotateY(180deg);
}

.task-card-front, .task-card-back {
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 24px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.task-card-front {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.task-card-back {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(180deg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.ai-assistant-back-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--glass-border);
}

.ai-chat-history-mini {
    flex: 1;
    overflow-y: auto;
    max-height: 240px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
    padding-right: 8px;
}

/* Custom scrollbar */
.ai-chat-history-mini::-webkit-scrollbar {
    width: 4px;
}
.ai-chat-history-mini::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.ai-input-wrapper-mini {
    display: flex;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
}

.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--glass-border);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    outline: none;
}

.modal-input:focus {
    border-color: var(--accent-color);
    background: var(--card-bg);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-group label {
    margin-left: 4px;
    letter-spacing: 0.5px;
}

/* Teacher Specific */
.teacher-content {
    animation: fadeInSlide 0.3s ease-out;
}

.teacher-tab {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.teacher-tab.active {
    transform: scale(1.05);
}

.assignment-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    transition: all 0.2s;
}

.assignment-card:active {
    transform: scale(0.98);
}

/* Gradebook Table */
.gradebook-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.gradebook-table th, .gradebook-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.gradebook-table th {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 10px;
    opacity: 0.5;
    white-space: nowrap;
}

.gradebook-table td:first-child {
    font-weight: 700;
    position: sticky;
    left: 0;
    background: var(--card-bg);
    z-index: 1;
}

.grade-cell {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s;
}

.grade-cell:hover {
    transform: scale(1.1);
}

.status-badge {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.status-assigned { background: rgba(99, 102, 241, 0.1); color: var(--accent-color); }
.status-submitted { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.status-missing { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.status-graded { background: rgba(168, 85, 247, 0.1); color: #a855f7; }

/* Grade Buttons */
.grade-btn {
    flex: 1;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
}

.grade-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Comment Bank Items */
.bank-item {
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.05);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.bank-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.grading-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .grading-layout {
        grid-template-columns: 1fr;
    }
}

.detailed-grading-modal .modal-content {
    width: 95%;
    max-width: 600px;
}