:root {
    --primary-color: #39ff14;
    --primary-light: #70ff5c;
    --secondary-color: #111111;
    --background-color: #0b1a0e;
    --card-bg: rgba(20, 30, 20, 0.9);
    --text-main: #FFFFFF;
    --text-muted: #cccccc;
    --grammar-color: #39ff14;
    --reading-color: #22ff00;
    --grammar-gradient: linear-gradient(135deg, #0b1a0e, #111);
    --reading-gradient: linear-gradient(135deg, #0b1a0e, #111);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--background-color);
    background-image: 
        linear-gradient(30deg, transparent 48%, rgba(57, 255, 20, 0.15) 48%, rgba(57, 255, 20, 0.15) 52%, transparent 52%),
        linear-gradient(-30deg, transparent 48%, rgba(57, 255, 20, 0.15) 48%, rgba(57, 255, 20, 0.15) 52%, transparent 52%),
        linear-gradient(90deg, transparent 48%, rgba(57, 255, 20, 0.15) 48%, rgba(57, 255, 20, 0.15) 52%, transparent 52%),
        repeating-linear-gradient(90deg, rgba(10, 30, 10, 0.8) 0px, rgba(10, 30, 10, 0.8) 50px, rgba(5, 15, 5, 0.8) 50px, rgba(5, 15, 5, 0.8) 100px);
    background-size: 60px 104.4px, 60px 104.4px, 100% 104.4px, 100px 100%;
    background-attachment: fixed;
    color: var(--text-main);
    overflow-x: hidden;
    overflow-y: scroll; /* Force vertical scrollbar to prevent layout shifts/trembling */
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--secondary-color);
    background-image: repeating-linear-gradient(45deg, #000 0px, #000 10px, #1a1a1a 10px, #1a1a1a 20px);
    padding: 20px 30px;
    border-radius: 20px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(57, 255, 20, 0.5);
    border: 2px solid var(--primary-color);
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo i {
    font-size: 2rem;
    color: var(--primary-color);
}

.logo h1 {
    font-family: 'Orbitron', sans-serif;
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 900;
}

.subject-badge {
    background: var(--secondary-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-right: 15px;
    box-shadow: 0 0 5px var(--primary-color);
}

.user-info .stars {
    background: #FEF3C7;
    color: #D97706;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Dashboard */
.welcome-section {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-section h2 {
    font-size: 2.5rem;
    color: var(--text-main);
    margin-bottom: 10px;
}

.welcome-section p {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.books-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.book-card {
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 0;
    width: 400px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(57, 255, 20, 0.2);
    transition: all 0.3s ease;
}

.book-card:hover {
    transform: translateY(-5px) translateX(-5px);
    box-shadow: 9px 9px 0px rgba(57, 255, 20, 0.3), inset 0 0 25px rgba(57, 255, 20, 0.5);
}

.book-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 0;
    border: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--primary-color);
    position: relative;
    z-index: 2;
}

.grammar-book .book-icon {
    background: var(--grammar-gradient);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.4);
}

.reading-book .book-icon {
    background: var(--reading-gradient);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.4);
}

.book-info {
    position: relative;
    z-index: 2;
}

.book-info h3 {
    font-size: 2rem;
    margin-bottom: 10px;
    font-family: 'Orbitron', 'Cairo', sans-serif;
    font-weight: 900;
}

.grammar-book h3 { color: var(--grammar-color); }
.reading-book h3 { color: var(--reading-color); }

.book-info p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.card-decoration {
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    opacity: 0.1;
    z-index: 1;
}

.grammar-book .card-decoration { background: var(--grammar-color); }
.reading-book .card-decoration { background: var(--reading-color); }

/* Lesson Section */
.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 40px;
    gap: 20px;
}

.back-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    padding: 10px 20px;
    border-radius: 0;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 2px 2px 0px rgba(57, 255, 20, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Orbitron', 'Cairo', sans-serif;
    font-weight: 700;
    color: var(--primary-color);
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--primary-color);
    color: var(--secondary-color);
    transform: translateX(0px);
    box-shadow: 0 0 15px var(--primary-color);
}

.section-header h2 {
    font-size: 2.2rem;
    color: var(--primary-color);
    font-family: 'Orbitron', 'Cairo', sans-serif;
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.lesson-card {
    background: var(--card-bg);
    border-radius: 0;
    padding: 20px;
    text-align: center;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid var(--primary-color);
}

.lesson-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-light);
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.4);
}

.lesson-emoji-container {
    width: 100%;
    height: 140px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--primary-color);
    border-radius: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4.5rem;
    box-shadow: inset 0 0 15px rgba(57, 255, 20, 0.1);
    transition: transform 0.3s ease;
}

.lesson-card:hover .lesson-emoji-container {
    transform: scale(1.1) rotate(5deg);
}

.lesson-card h4 {
    font-size: 1.2rem;
    color: var(--text-main);
}

/* Interactive TTS Highlight on Whiteboard */
.tts-word {
    opacity: 0.3;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    border-radius: 4px;
    padding: 0 2px;
}
.tts-word.active {
    opacity: 1;
    background-color: #ffeb3b;
    color: #000;
}
.tts-word.finished {
    opacity: 1;
    background-color: transparent;
    color: inherit;
}

/* --- Interactive Teacher Classroom --- */
.classroom-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fdfbf7;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.whiteboard {
    background: #2e7d32;
    border: 15px solid #8d6e63;
    border-radius: 10px;
    width: 100%;
    max-width: 800px;
    min-height: 250px;
    padding: 20px;
    color: #fff;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 10px 20px rgba(0,0,0,0.2);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.whiteboard::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 10%;
    width: 80%;
    height: 10px;
    background: #5d4037;
    border-radius: 0 0 5px 5px;
}

.wb-content {
    animation: fadeIn 0.5s ease-in-out;
}

.wb-title {
    font-size: 2rem;
    color: #ffd54f;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.wb-text {
    font-size: 1.5rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.wb-example {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    border-left: 5px solid #ffca28;
    margin: 10px 0;
    font-size: 1.4rem;
}

.teacher-area {
    display: flex;
    align-items: flex-start;
    width: 100%;
    max-width: 800px;
    gap: 20px;
    margin-top: 10px;
}

.teacher-avatar {
    width: 120px;
    height: 120px;
    background: #e1f5fe;
    border-radius: 50%;
    border: 4px solid #0288d1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    flex-shrink: 0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.speech-bubble {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    flex-grow: 1;
    font-size: 1.2rem;
    line-height: 1.6;
    color: #333;
    border: 2px solid #e0e0e0;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    right: -20px;
    top: 30px;
    border-width: 10px;
    border-style: solid;
    border-color: transparent transparent transparent #e0e0e0;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    right: -16px;
    top: 30px;
    border-width: 10px;
    border-style: solid;
    border-color: transparent transparent transparent #fff;
}

.teacher-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 15px;
    align-items: center;
}

.btn-teacher {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-teacher:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-teacher:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.step-indicator {
    font-size: 1.1rem;
    color: #7f8c8d;
    font-weight: bold;
}

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

/* --- Dictation Styles --- */
.dictation-container {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    padding: 20px;
    border: 2px solid var(--neon-green);
    color: white;
}
.dictation-header {
    text-align: center;
    margin-bottom: 20px;
}
.dictation-header h3 {
    color: var(--neon-green);
    font-size: 2rem;
    margin-bottom: 5px;
}
.dictation-header p {
    font-size: 1.2rem;
    color: #ccc;
}
.sub-tabs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}
.dictation-sub-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid var(--neon-green);
    border-radius: 20px;
    padding: 8px 15px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.dictation-sub-btn.active, .dictation-sub-btn:hover {
    background: var(--neon-green);
    color: black;
}
.dictation-workspace {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.dictation-controls {
    display: flex;
    gap: 15px;
}
.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cosmic-btn {
    background: linear-gradient(45deg, #1e88e5, #0d47a1);
    color: white;
    box-shadow: 0 0 10px rgba(30, 136, 229, 0.5);
}
.btn-secondary {
    background: #555;
    color: white;
}
.success-btn {
    background: linear-gradient(45deg, #4caf50, #2e7d32);
    color: white;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}
.action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}
.canvas-wrapper {
    background: #000; /* Space black background for canvas */
    border: 3px solid #66ff66; /* Neon green border */
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
    width: 100%;
    max-width: 600px;
}
#dictation-board {
    width: 100%;
    border-radius: 8px;
    cursor: crosshair;
}
.dictation-answer {
    background: rgba(255, 255, 255, 0.9);
    color: black;
    font-size: 3rem;
    font-weight: bold;
    padding: 20px 40px;
    border-radius: 15px;
    margin-top: 20px;
    border: 3px dashed var(--neon-green);
    text-align: center;
}

/* Voice Coach Styles */
.mic-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    background: var(--primary-color);
    color: white;
    font-size: 2.5rem;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.mic-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(0,0,0,0.3);
}

.mic-btn.listening {
    background: #e74c3c;
    animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
        transform: scale(1);
    }
    70% {
        box-shadow: 0 0 0 30px rgba(231, 76, 60, 0);
        transform: scale(1.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
        transform: scale(1);
    }
}

.voice-coach-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    padding: 30px;
    margin-top: 20px;
}
