/* ================= VARIABLES & STYLES ================= */
:root {
    /* Color Palette - Premium Pastels */
    --primary: #8F85F3;
    --primary-light: #F3F1FD;
    --primary-dark: #6C62D2;
    --success: #3EB388;
    --success-light: #EAF8F2;
    --error: #E05D5D;
    --error-light: #FDF2F2;
    --warning: #F5A623;
    --warning-light: #FEF6EB;
    
    --bg-main: #F6F5FB;
    --bg-card: #FFFFFF;
    --text-main: #33394F;
    --text-muted: #84899F;
    --border-color: #ECEAF4;
    
    --font-outfit: 'Outfit', 'Inter', sans-serif;
    --font-inter: 'Inter', sans-serif;
    
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
    
    --shadow: 0 10px 30px rgba(143, 133, 243, 0.05);
    --shadow-hover: 0 15px 35px rgba(143, 133, 243, 0.1);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================= BASIC RESET ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-inter);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-outfit);
    font-weight: 600;
}

button, input, textarea, select {
    outline: none;
}

/* ================= APP CONTAINER LAYOUT ================= */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex blowout */
}

.content-container {
    padding: 40px;
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ================= SIDEBAR (DESKTOP) ================= */
.sidebar {
    width: 280px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar.hidden {
    display: none;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 25px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-family: var(--font-outfit);
    font-weight: 700;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.brand-name {
    font-family: var(--font-outfit);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
}

.brand-name span {
    color: var(--primary);
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--primary-light);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 25px;
    text-align: center;
}

.avatar-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background-color: white;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.avatar-upload-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 26px;
    height: 26px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    border: 2px solid white;
    transition: var(--transition);
}

.avatar-upload-btn:hover {
    transform: scale(1.1);
    background-color: var(--primary-dark);
}

.user-details .user-name {
    font-size: 16px;
    color: var(--text-main);
    margin-bottom: 4px;
    word-break: break-all;
}

.user-badge {
    font-size: 12px;
    background-color: white;
    color: var(--primary-dark);
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.nav-item.active i {
    color: var(--primary);
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--error);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
}

.logout-btn:hover {
    background-color: var(--error-light);
    border-color: transparent;
}

/* ================= HEADER & MOBILE NAVIGATION ================= */
.mobile-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 99;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-score-badge {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    flex: 1;
    padding: 8px 0;
    transition: var(--transition);
}

.mobile-nav-item.active {
    color: var(--primary-dark);
}

.mobile-nav-item i {
    font-size: 20px;
}

/* ================= GENERAL UI CARD ================= */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    padding: 30px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-header {
    margin-bottom: 25px;
}

.card-header h3 {
    font-size: 20px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ================= VIEW TRANSITIONS ================= */
.view {
    display: block;
    animation: fadeIn 0.4s ease;
}

.view.hidden {
    display: none !important;
}

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

/* ================= AUTH VIEW ================= */
.auth-view {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    padding: 40px 30px;
    text-align: center;
}

.auth-header h2 {
    font-size: 32px;
    color: var(--text-main);
    margin-bottom: 6px;
}

.auth-header h2 span {
    color: var(--primary);
}

.auth-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.auth-toggle {
    display: flex;
    background-color: var(--bg-main);
    padding: 5px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
}

.toggle-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: calc(var(--radius-md) - 4px);
    transition: var(--transition);
}

.toggle-btn.active {
    background-color: var(--bg-card);
    color: var(--primary-dark);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: left;
}

.auth-form.hidden {
    display: none;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label i {
    color: var(--primary);
}

.form-group input, .form-group textarea {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    background-color: var(--bg-main);
    transition: var(--transition);
}

.form-group input:focus, .form-group textarea:focus {
    border-color: var(--primary);
    background-color: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(143, 133, 243, 0.1);
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 14px;
    font-weight: 600;
    font-size: 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 8px 20px rgba(143, 133, 243, 0.2);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(143, 133, 243, 0.3);
}

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

/* ================= DASHBOARD GRID & STATS ================= */
.grid-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 30px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.stat-welcome h2 {
    font-size: 26px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.stat-welcome p {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
}

.stat-circle {
    width: 100px;
    height: 100px;
    background-color: var(--primary-light);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 3px solid white;
    box-shadow: 0 4px 15px rgba(143, 133, 243, 0.1);
}

.stat-circle span:first-child {
    font-family: var(--font-outfit);
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1;
}

.stat-circle .circle-lbl {
    font-size: 11px;
    color: var(--primary-dark);
    font-weight: 500;
}

.stat-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.action-card-btn {
    flex: 1;
    padding: 16px;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    transition: var(--transition);
}

.lavender-btn {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.lavender-btn:hover {
    background-color: var(--primary);
    color: white;
}

.mint-btn {
    background-color: var(--success-light);
    color: var(--success);
}

.mint-btn:hover {
    background-color: var(--success);
    color: white;
}

/* ================= LEADERBOARD ================= */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar */
.leaderboard-list::-webkit-scrollbar, .practice-sidebar::-webkit-scrollbar {
    width: 6px;
}
.leaderboard-list::-webkit-scrollbar-thumb, .practice-sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.leader-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    border-radius: var(--radius-md);
    background-color: var(--bg-main);
    border: 1px solid transparent;
    transition: var(--transition);
}

.leader-item:hover {
    border-color: var(--border-color);
    background-color: var(--bg-card);
    transform: translateX(3px);
}

.leader-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.leader-rank {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background-color: var(--border-color);
    color: var(--text-muted);
}

.leader-item.rank-1 .leader-rank {
    background-color: #FFDF00;
    color: white;
}
.leader-item.rank-2 .leader-rank {
    background-color: #C0C0C0;
    color: white;
}
.leader-item.rank-3 .leader-rank {
    background-color: #CD7F32;
    color: white;
}

.leader-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.leader-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
}

.leader-score {
    font-family: var(--font-outfit);
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 16px;
}

/* ================= PRACTICE LAYOUT ================= */
.practice-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    align-items: start;
}

.practice-sidebar h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.filter-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-btn {
    text-align: left;
    border: none;
    background: transparent;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn.active, .filter-btn:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.empty-practice {
    text-align: center;
    padding: 80px 40px;
    color: var(--text-muted);
}

.empty-practice i {
    font-size: 50px;
    color: var(--primary);
    margin-bottom: 20px;
}

.empty-practice h3 {
    color: var(--text-main);
    margin-bottom: 8px;
}

/* Practice Task Card */
.task-card {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

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

.task-tag {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
}

.task-points {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.task-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-main);
}

/* Task Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-item {
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-card);
    transition: var(--transition);
}

.option-item:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.option-radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.option-item.selected {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.option-item.selected .option-radio {
    border-color: var(--primary);
    background-color: var(--primary);
}

.option-item.selected .option-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    background-color: white;
    border-radius: 50%;
}

/* Task Text Input */
.text-answer-input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-main);
    font-size: 15px;
    transition: var(--transition);
}

.text-answer-input:focus {
    border-color: var(--primary);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(143, 133, 243, 0.1);
}

/* Action panel */
.task-actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.task-submit-btn {
    flex: 1;
}

.task-nav-btn {
    background-color: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 20px;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.task-nav-btn:hover {
    background-color: var(--border-color);
}

/* Mistake feedback */
.feedback-box {
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideDown 0.3s ease;
}

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

.feedback-box.correct {
    background-color: var(--success-light);
    border: 1px solid rgba(62, 179, 136, 0.2);
}

.feedback-box.incorrect {
    background-color: var(--error-light);
    border: 1px solid rgba(224, 93, 93, 0.2);
}

.feedback-title {
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.feedback-box.correct .feedback-title { color: var(--success); }
.feedback-box.incorrect .feedback-title { color: var(--error); }

.feedback-desc {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-main);
}

.ai-explain-btn {
    align-self: flex-start;
    border: none;
    background-color: white;
    color: var(--primary-dark);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: var(--transition);
}

.ai-explain-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* AI Explanation Box */
.ai-explanation-result {
    background-color: var(--primary-light);
    border: 1px solid rgba(143, 133, 243, 0.2);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 15px;
    animation: fadeIn 0.4s ease;
}

.ai-explanation-result h4 {
    font-size: 14px;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ai-explanation-result p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
}

.explanation-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-dark);
    font-size: 14px;
    font-weight: 500;
}

/* ================= INTERACTIVE CARDS GAME ================= */
.game-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.game-select-btn {
    flex: 1;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-muted);
    font-weight: 600;
    padding: 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.game-select-btn.active {
    background-color: var(--primary-light);
    border-color: transparent;
    color: var(--primary-dark);
}

.game-workspace {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.game-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    gap: 15px;
}

.progress-bar-bg {
    flex: 1;
    height: 6px;
    background-color: var(--bg-main);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 10px;
    transition: width 0.4s ease;
}

/* Card content */
.card-prompt {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* Stresses word view */
.word-interactive {
    font-family: var(--font-outfit);
    font-size: 36px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 25px 0;
}

.letter-btn {
    font-family: inherit;
    font-weight: inherit;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    cursor: default;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 22px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.letter-btn.vowel {
    background-color: white;
    border-color: var(--primary);
    color: var(--primary-dark);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
    font-weight: 600;
}

.letter-btn.vowel:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
}

.letter-btn.correct-choice {
    background-color: var(--success);
    border-color: transparent;
    color: white !important;
    text-decoration: none;
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(62, 179, 136, 0.3);
}

.letter-btn.wrong-choice {
    background-color: var(--error);
    border-color: transparent;
    color: white !important;
    text-decoration: none;
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(224, 93, 93, 0.3);
}

/* Choices button lists (for spelling) */
.choices-list {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
}

.choice-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: white;
    color: var(--text-main);
    font-family: var(--font-outfit);
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.choice-bubble:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

.choice-bubble.correct {
    background-color: var(--success);
    border-color: transparent;
    color: white;
}

.choice-bubble.wrong {
    background-color: var(--error);
    border-color: transparent;
    color: white;
}

.game-feedback {
    border-radius: var(--radius-md);
    padding: 15px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

.game-feedback.correct {
    background-color: var(--success-light);
    color: var(--success);
}

.game-feedback.incorrect {
    background-color: var(--error-light);
    color: var(--error);
}

/* ================= THEORY LAYOUT ================= */
.theory-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    align-items: start;
}

.theory-sidebar h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.theory-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theory-menu-btn {
    text-align: left;
    border: none;
    background: transparent;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.theory-menu-btn.active, .theory-menu-btn:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.empty-theory {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-muted);
}

.empty-theory i {
    font-size: 40px;
    color: var(--primary);
    margin-bottom: 15px;
}

.theory-main h2 {
    font-size: 24px;
    color: var(--text-main);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* Rendered markdown style in theory */
.theory-content {
    line-height: 1.7;
    color: var(--text-main);
}

.theory-content h3 {
    margin-top: 25px;
    margin-bottom: 12px;
    color: var(--primary-dark);
    font-size: 18px;
}

.theory-content p {
    margin-bottom: 12px;
}

.theory-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.theory-content li {
    margin-bottom: 6px;
}

.theory-content strong {
    color: var(--primary-dark);
}

/* ================= ESSAY WRITING (TASK 27) ================= */
.essay-intro-card {
    margin-bottom: 30px;
}

.essay-header-block {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.essay-badge-22 {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border: 3px solid white;
    box-shadow: 0 4px 15px rgba(143, 133, 243, 0.1);
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.essay-badge-22 span:first-child {
    font-family: var(--font-outfit);
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
}

.essay-badge-22 span:last-child {
    font-size: 9px;
    font-weight: 600;
    text-align: center;
}

.essay-grid {
    display: grid;
    grid-template-columns: 1.2fr 1.5fr;
    gap: 30px;
    align-items: start;
}

.essay-text-panel {
    max-height: 600px;
    overflow-y: auto;
}

.essay-source-content {
    line-height: 1.8;
    font-size: 15px;
    color: var(--text-main);
    margin-top: 15px;
}

.essay-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.essay-form textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    background-color: var(--bg-main);
    resize: vertical;
}

.essay-form textarea:focus {
    background-color: white;
    border-color: var(--primary);
}

/* File Drag & Drop */
.file-drop-area {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    background-color: var(--bg-main);
    transition: var(--transition);
    text-align: center;
}

.file-drop-area:hover, .file-drop-area.dragover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.file-drop-area i {
    font-size: 32px;
    color: var(--primary);
}

.drop-msg {
    font-size: 13px;
    color: var(--text-muted);
}

.preview-container {
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    background-color: white;
    border-radius: calc(var(--radius-md) - 4px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-container img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.remove-file-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background-color: rgba(220, 50, 50, 0.9);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.remove-file-btn:hover {
    background-color: rgb(220, 50, 50);
    transform: scale(1.1);
}

/* Loading Overlay */
.ai-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(246, 245, 251, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.ai-loading-card {
    background-color: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 40px rgba(143, 133, 243, 0.15);
    text-align: center;
    max-width: 500px;
    width: 90%;
    border: 1px solid var(--border-color);
}

.ai-loader {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 25px auto;
}

.spinner-circle {
    width: 100%;
    height: 100%;
    border: 4px solid var(--primary-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.brain-pulse {
    position: absolute;
    top: 25px;
    left: 25px;
    font-size: 30px;
    color: var(--primary);
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; color: var(--primary-dark); }
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    margin-top: 25px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.step {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}

.step i {
    font-size: 14px;
}

.step.active {
    color: var(--primary-dark);
    font-weight: 600;
}

.step.done {
    color: var(--success);
}

/* ================= GRADING RESULTS SCORECARD ================= */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 25px;
}

.results-score-badge {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-family: var(--font-outfit);
}

.results-score-badge span:first-child {
    font-size: 26px;
}

.results-score-badge span:last-child {
    font-size: 14px;
}

.criteria-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.crit-item {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    text-align: center;
}

.crit-name {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.crit-score {
    font-family: var(--font-outfit);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.crit-score.maxed {
    color: var(--success);
}

.crit-score.zero {
    color: var(--error);
}

/* Transcription */
.transcribed-panel {
    background-color: var(--bg-main);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 25px;
}

.transcribed-panel h4, .ai-feedback-panel h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.transcribed-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
    white-space: pre-line;
}

/* Feedback panel */
.ai-feedback-content {
    line-height: 1.8;
    font-size: 15px;
    color: var(--text-main);
    white-space: pre-wrap;
    background-color: var(--primary-light);
    border: 1px solid rgba(143, 133, 243, 0.1);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 10px;
}

.btn-back-to-essay {
    border: none;
    background-color: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    margin-top: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-back-to-essay:hover {
    background-color: var(--border-color);
}

/* ================= GLOBAL TOAST NOTIFICATIONS ================= */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background-color: white;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    min-width: 250px;
    border-left: 5px solid var(--primary);
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--success); color: var(--success); }
.toast.error { border-left-color: var(--error); color: var(--error); }
.toast.info { border-left-color: var(--primary); color: var(--primary-dark); }

/* ================= RESPONSIVE LAYOUTS ================= */
.task-text {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* Mobile Brand Header Navigation elements */
.menu-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.menu-toggle-btn:hover {
    background-color: var(--bg-main);
}

.sidebar-brand-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo-mobile {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-family: var(--font-outfit);
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.brand-name-mobile {
    font-family: var(--font-outfit);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.brand-name-mobile span {
    color: var(--primary);
}

/* Mobile Sidebar & Overlay sliding rules */
.sidebar-overlay {
    display: none;
}

@media (max-width: 992px) {
    .content-container {
        padding: 30px 20px;
    }
    
    .grid-container {
        grid-template-columns: 1fr;
    }
    
    .practice-layout, .theory-layout {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .essay-grid {
        grid-template-columns: 1fr;
    }

    /* Mobile-optimized Horizontal Categories for Practice */
    .practice-sidebar {
        padding: 12px !important;
        margin-bottom: 10px;
        box-shadow: var(--shadow-sm);
    }
    .practice-sidebar h3 {
        display: none !important;
    }
    .filter-buttons {
        flex-direction: row !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        padding-bottom: 5px;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    .filter-buttons::-webkit-scrollbar {
        height: 4px;
    }
    .filter-buttons::-webkit-scrollbar-thumb {
        background-color: var(--primary-light);
        border-radius: 4px;
    }
    .filter-btn {
        flex: 0 0 auto !important;
        padding: 8px 14px !important;
        text-align: center !important;
        font-size: 13px !important;
    }
    .filter-btn.separator {
        display: none !important; /* Hide separator lines on mobile */
    }

    /* Mobile-optimized Horizontal Categories for Theory */
    .theory-sidebar {
        padding: 12px !important;
        margin-bottom: 10px;
        box-shadow: var(--shadow-sm);
    }
    .theory-sidebar h3 {
        display: none !important;
    }
    .theory-menu {
        flex-direction: row !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        padding-bottom: 5px;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    .theory-menu::-webkit-scrollbar {
        height: 4px;
    }
    .theory-menu::-webkit-scrollbar-thumb {
        background-color: var(--primary-light);
        border-radius: 4px;
    }
    .theory-menu-btn {
        flex: 0 0 auto !important;
        padding: 8px 14px !important;
        text-align: center !important;
        font-size: 13px !important;
    }
}

@media (min-width: 769px) {
    .sidebar {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 16px; /* Base font size for readability */
    }
    
    .content-container {
        padding: 15px; /* content padding audit */
        padding-bottom: 90px; /* space for mobile bottom nav */
    }
    
    /* Sliding Sidebar Menu on Mobile */
    .sidebar {
        display: flex !important;
        position: fixed;
        left: -285px;
        top: 0;
        bottom: 0;
        z-index: 1001;
        box-shadow: 5px 0 30px rgba(0,0,0,0.1);
        transition: var(--transition);
        border-right: none;
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(51, 57, 79, 0.4);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: var(--transition);
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
    
    .mobile-header {
        display: flex !important;
    }
    
    .mobile-nav {
        display: flex !important;
    }
    
    /* Mobile font scale */
    h2 {
        font-size: 20px !important;
    }
    
    h3 {
        font-size: 18px !important;
    }
    
    .word-interactive {
        font-size: 30px !important;
        gap: 4px;
    }
    
    .letter-btn {
        width: 36px; /* slightly smaller to fit on small mobile screens */
        height: 36px;
        font-size: 18px;
    }
    
    /* Bigger Touch Targets for Forms */
    .form-group input, .form-group textarea, .text-answer-input {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 48px;
    }
    
    .option-item {
        padding: 16px 20px;
        min-height: 48px;
    }
    
    .submit-btn, .choice-bubble, .game-select-btn, .filter-btn, .theory-menu-btn {
        min-height: 44px; /* touch guidelines compliance */
    }
    
    .criteria-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Partial correctness warning box style */
.feedback-box.partial {
    background-color: var(--warning-light);
    border: 1px solid rgba(245, 166, 35, 0.2);
}
.feedback-box.partial .feedback-title {
    color: var(--warning);
}

/* ================= GLOBAL HIDDEN OVERRIDE ================= */
.hidden {
    display: none !important;
}

/* ================= WHITESPACE & PADDING RULES ================= */
.content-container, .card, .view, .practice-main, .game-workspace, .theory-sidebar, .theory-text-content {
    padding: 20px !important;
}

/* ================= STRING FORMATTING ================= */
.task-text, .feedback-box, .transcribed-content, .theory-content, .chat-message-content, .explanation, #practice-feedback, .game-feedback {
    white-space: pre-wrap;
}

/* ================= READER BOX FOR TASK 22 & 27 ================= */
.reader-box {
    background-color: #f7f6f9;
    border-left: 4px solid var(--primary);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 16px;
    color: var(--text-main);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}
.reader-paragraph {
    line-height: 1.6;
    margin-bottom: 1.5rem;
}
.reader-paragraph:last-child {
    margin-bottom: 0;
}

/* ================= PHYSICAL INTERACTIVE CARDS ================= */
.game-workspace, .task-card {
    border-radius: 12px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.02) !important;
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-card) !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.game-workspace:hover, .task-card:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.09) !important;
}

/* ================= THEORY TABLES ================= */
.theory-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
    text-align: left;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.theory-table th, .theory-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}
.theory-table th {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.theory-table tr:last-child td {
    border-bottom: none;
}
.theory-table tbody tr:nth-of-type(even) {
    background-color: #faf9fd;
}

/* ================= AI CHAT TUTOR VIEW ================= */
.chat-view-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 500px;
    max-height: 800px;
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 15px;
}
.chat-header-info h3 {
    margin: 0;
    font-size: 18px;
    color: var(--primary-dark);
}
.chat-header-info p {
    margin: 5px 0 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.clear-chat-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}
.clear-chat-btn:hover {
    background-color: var(--error-light);
    color: var(--error);
    border-color: transparent;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
}
.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
}
.chat-message.user {
    align-self: flex-end;
    background-color: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}
.chat-message.assistant {
    align-self: flex-start;
    background-color: var(--bg-main);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-color);
}
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 15px;
    align-self: flex-start;
    padding-left: 10px;
}
.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: typingDotWave 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes typingDotWave {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.6; }
    40% { transform: scale(1); opacity: 1; }
}
.chat-suggestions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
.suggestion-chip {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}
.suggestion-chip:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border-color: transparent;
}
.chat-input-area {
    display: flex;
    gap: 10px;
}
.chat-input-area input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: var(--transition);
}
.chat-input-area input:focus {
    border-color: var(--primary);
    background-color: white;
}
.chat-send-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.chat-send-btn:hover {
    background-color: var(--primary-dark);
}


