/* --- CORE THEME & CSS VARIABLES --- */
:root {
    --brand-color: #B91C1C;
    --brand-hover: #991B1B;
    --brand-gradient: linear-gradient(135deg, var(--brand-color), #DC2626);
    --bg-dark: #090D16;
    --bg-card: rgba(18, 24, 38, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --danger-color: #EF4444;
    --success-color: #10B981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 80px; /* For mobile bottom nav */
}

/* Background Glowing Orbs */
.bg-glow-1 {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -2;
    filter: blur(60px);
    pointer-events: none;
}

.bg-glow-2 {
    position: fixed;
    bottom: -10%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -2;
    filter: blur(60px);
    pointer-events: none;
}

/* --- GLASSMORPHISM PANELS --- */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-navbar {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.glass-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-input, .glass-input, .glass-select, select {
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #f8fafc;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: all 0.25s ease;
    backdrop-filter: blur(12px);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.form-input:hover, .glass-input:hover, .glass-select:hover, select:hover {
    border-color: rgba(99, 102, 241, 0.5);
    background-color: rgba(15, 23, 42, 0.88);
}

.form-input:focus, .glass-input:focus, .glass-select:focus, select:focus {
    border-color: #6366f1;
    background-color: rgba(15, 23, 42, 0.95);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25), 0 0 15px rgba(99, 102, 241, 0.2);
}

select option {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    padding: 12px 14px;
}

/* --- BUTTONS --- */
.btn-primary {
    background: var(--brand-gradient);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px 24px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Custom Grade Pill Selector */
.grade-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.grade-pill {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-weight: 500;
}

.grade-pill:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.grade-pill.active {
    background: var(--brand-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3); /* Based on --brand-color red */
    font-weight: 600;
}

/* Fix Autofill styling for dark theme */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px rgba(18, 24, 38, 0.95) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
    border-radius: 12px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 12px 20px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-tool {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-tool:hover {
    background: var(--brand-color);
    border-color: var(--brand-color);
}

.btn-icon-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-danger:hover {
    background: var(--danger-color);
    color: white;
}

/* --- SCREENS --- */
.screen {
    width: 100%;
    min-height: 100vh;
}

.screen.hidden, .tab-content.hidden, .modal.hidden, .hidden {
    display: none !important;
}

/* --- LOGIN SCREEN --- */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px 36px;
    text-align: center;
}

.logo-container {
    margin-bottom: 16px;
}

.logo-emoji {
    font-size: 56px;
    display: inline-block;
}

.logo-emoji img {
    background: transparent;
    padding: 0;
    border: none !important;
    outline: none !important;
    border-radius: 24px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    max-width: 220px;
    height: auto !important;
    display: inline-block;
}

.brand-emoji img {
    background: transparent;
    padding: 0;
    border-radius: 6px;
    height: 32px !important;
    width: auto;
}

.login-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, #FFFFFF, #94A3B8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}

.input-wrapper input:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.error-banner, .success-banner {
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 20px;
    font-weight: 500;
}

.error-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
}

.success-banner {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6EE7B7;
}

.login-card .btn-primary {
    width: 100%;
    margin-top: 10px;
}

.login-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- MAIN LAYOUT --- */
.main-layout {
    display: flex;
    min-height: calc(100vh - 70px);
}

/* Desktop Sidebar */
.sidebar {
    width: 260px;
    margin: 20px 0 20px 20px;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--brand-gradient);
    color: white;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.25);
}

.nav-icon {
    font-size: 20px;
}

.content-area {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

/* --- DASHBOARD TAB --- */
.dashboard-header {
    margin-bottom: 24px;
}

.dashboard-header h2, .vocab-header h2, .branding-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 4px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
}

.stat-details h3 {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-number {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-primary);
}

.dashboard-banner {
    padding: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border-left: 4px solid var(--brand-color);
}

.banner-content h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.banner-content p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    max-width: 600px;
}

.banner-icon {
    font-size: 48px;
}

/* --- PDF TAB --- */
.pdf-toolbar {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-badge, .zoom-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.pdf-viewer-container {
    min-height: 500px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow: auto;
    background: rgba(9, 13, 22, 0.6);
    margin-bottom: 16px;
}

.pdf-canvas-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.pdf-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.quick-translate-bar {
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.translate-result-box {
    width: 100%;
    margin-top: 12px;
    padding: 14px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
}

/* --- VOCABULARY TAB --- */
.vocab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.flashcard-arena {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 36px;
}

.flashcard {
    width: 100%;
    max-width: 500px;
    min-height: 240px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    position: relative;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(24, 32, 47, 0.9));
    border: 2px solid rgba(59, 130, 246, 0.3);
}

.flashcard:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--brand-color);
}

.card-lang {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--brand-color);
    margin-bottom: 12px;
}

.flashcard h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
}

.flip-hint {
    font-size: 12px;
    color: var(--text-secondary);
    position: absolute;
    bottom: 16px;
}

.card-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.card-count-badge {
    font-weight: 700;
    font-size: 16px;
}

.vocab-table-wrapper {
    overflow-x: auto;
    padding: 20px;
}

.vocab-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.vocab-table th {
    padding: 14px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
}

.vocab-table td {
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 15px;
}

/* --- AI TUTOR TAB --- */
.ai-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    padding: 24px;
}

.ai-header {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.ai-title-box {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-avatar {
    font-size: 36px;
    width: 54px;
    height: 54px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-status {
    font-size: 13px;
    color: var(--success-color);
    margin-top: 2px;
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 10px;
    margin-bottom: 20px;
}

.msg {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.5;
}

.msg-ai {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--glass-border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.msg-user {
    background: var(--brand-gradient);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-sender {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    opacity: 0.8;
}

.ai-input-bar {
    display: flex;
    gap: 12px;
}

/* --- BRANDING TAB --- */
.branding-card {
    padding: 32px;
    max-width: 800px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.color-picker-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.color-picker-wrapper input[type="color"] {
    width: 50px;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
}

/* --- MODAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 440px;
    padding: 32px;
}

.modal-content h3 {
    margin-bottom: 20px;
    font-family: 'Outfit', sans-serif;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Global PDF Split Layout */
.pdf-split-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 120px);
    overflow: hidden;
}

.pdf-left-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.pdf-right-sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;
}

.pdf-viewer-container {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(10, 10, 20, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    position: relative;
    padding: 10px;
}

@media (max-width: 900px) {
    .pdf-left-panel {
        height: 50vh !important;
        flex: none !important;
    }
    .pdf-right-sidebar {
        height: 50vh !important;
        overflow-y: auto !important;
        padding-bottom: 30px !important;
        flex: none !important;
    }
}







/* PDF.js Text Layer CSS */
.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 1 !important;
    line-height: 1.0;
}
.textLayer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}
::selection {
    background: rgba(0, 0, 255, 0.3);
}
.textLayer ::selection {
    background: rgba(0, 0, 255, 0.3);
}

.btn-review-success {
    background: rgba(46, 204, 113, 0.15);
    border: 1px solid rgba(46, 204, 113, 0.4);
    color: #6ee7b7;
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(46, 204, 113, 0.1);
}
.btn-review-success:hover {
    background: rgba(46, 204, 113, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.25);
    color: #fff;
}

.btn-review-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1);
}
.btn-review-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.25);
    color: #fff;
}


/* Responsive font sizing and word wrap for flashcards */
.flashcard-front h3, .flashcard-back h3 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    font-size: clamp(1.2rem, 4vw, 2rem);
    max-height: 100%;
    overflow: visible;
}
.card-notes {
    font-size: 0.9rem;
    color: #a1a1aa;
    margin-top: 10px;
    word-wrap: break-word;
}


.pdf-tool-btn {
    background: transparent;
    color: #cbd5e1;
    border: 1px solid transparent;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pdf-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.pdf-tool-btn.active {
    background: #8b5cf6;
    color: white;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

/* Flashcard 3D Flip */
.flashcard {
    perspective: 1000px;
    padding: 0 !important; /* Remove padding from outer container */
    background: transparent !important;
    border: none !important;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 240px;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 240px;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(24, 32, 47, 0.9));
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    box-sizing: border-box;
}

.flashcard-back {
    transform: rotateY(180deg);
}

/* --- AI 3D Avatar Animations --- */
.ai-sidebar-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    animation: pulseGlow 2s infinite alternate;
}

.ai-avatar-main {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.7);
    border: 2px solid rgba(0, 255, 255, 0.5);
    animation: floatRobot 3s ease-in-out infinite;
    margin-right: 15px;
}

@keyframes floatRobot {
    0% { transform: translateY(0px) rotate(0deg); box-shadow: 0 0 15px rgba(0, 255, 255, 0.5); }
    50% { transform: translateY(-8px) rotate(3deg); box-shadow: 0 10px 25px rgba(0, 255, 255, 0.9); }
    100% { transform: translateY(0px) rotate(0deg); box-shadow: 0 0 15px rgba(0, 255, 255, 0.5); }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 5px rgba(0, 255, 255, 0.3); }
    100% { box-shadow: 0 0 15px rgba(0, 255, 255, 0.8); }
}


/* --- RESPONSIVE MOBILE / TABLET DESIGN (PWA) --- */
@media (max-width: 900px) {
    body {
        padding-bottom: 80px; /* Space for bottom nav */
    }

    .main-layout {
        flex-direction: column;
    }

    /* PDF Split Layout for Mobile */
    .pdf-split-layout {
        flex-direction: column;
        height: auto;
    }
    
    .pdf-viewer-container {
        max-height: none;
        min-height: 0;
        overflow-y: visible;
        border-radius: 12px;
        border: 1px solid rgba(255,255,255,0.1);
        -webkit-overflow-scrolling: touch;
        flex-direction: column;
        align-items: center;
    }
    
    .pdf-right-sidebar {
        width: 100%;
        height: auto;
        overflow: visible;
        padding-right: 0;
    }
    
    .ai-tutor-section {
        min-height: 400px;
    }

    /* Transform Sidebar to Bottom Navigation Bar for Tablets & Phones! */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 72px;
        margin: 0;
        padding: 8px 12px;
        border-radius: 24px 24px 0 0;
        border-top: 1px solid var(--glass-border);
        border-bottom: none;
        z-index: 500;
        background: rgba(15, 23, 42, 0.92);
        backdrop-filter: blur(28px);
    }

    .nav-links {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        height: 100%;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 6px 12px;
        font-size: 11px;
        border-radius: 12px;
        text-align: center;
    }

    .nav-icon {
        font-size: 22px;
    }

    .content-area {
        padding: 16px;
        margin-bottom: 60px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-banner {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .nav-text {
        font-size: 10px;
    }

    .top-navbar {
        padding: 10px 16px;
    }

    .brand-title {
        font-size: 15px;
    }

    .user-name {
        display: none; /* Hide username on tiny screens to save space */
    }
}


.pdf-canvas-wrapper, .pdf-bottom-controls {
    flex-shrink: 0;
}

/* Modern Pen Settings Buttons */
.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 2px 5px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}
.color-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%);
    border-radius: 50%;
}
.color-btn:hover {
    transform: translateY(-3px) scale(1.1);
    border-color: rgba(255,255,255,0.8);
    box-shadow: 0 5px 15px currentColor; /* glow matches background color if currentColor works, else a general glow */
}
.color-btn.active {
    border: 3px solid white;
    transform: scale(1.2);
    box-shadow: 0 0 15px currentColor, inset 0 2px 4px rgba(0,0,0,0.5);
}

.size-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.size-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.3);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}
.size-btn.active {
    background: rgba(99, 102, 241, 0.2); /* Indigo glow */
    border-color: #818cf8;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}
.size-btn.active div {
    background: #818cf8 !important;
    box-shadow: 0 0 8px #818cf8;
}

/* Mnemonic Emoji Animations */
@keyframes emoji-slide-right {
    0% { transform: translateX(-30px); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateX(30px); opacity: 0; }
}
@keyframes emoji-slide-left {
    0% { transform: translateX(30px); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateX(-30px); opacity: 0; }
}
@keyframes emoji-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}
@keyframes emoji-shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}
@keyframes emoji-spin {
    100% { transform: rotate(360deg); }
}
@keyframes emoji-wiggle {
    0%, 100% { transform: skewX(0); }
    25% { transform: skewX(-15deg); }
    75% { transform: skewX(15deg); }
}
@keyframes emoji-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.anim-slide-right { animation: emoji-slide-right 2s infinite ease-in-out; display: inline-block; }
.anim-slide-left { animation: emoji-slide-left 2s infinite ease-in-out; display: inline-block; }
.anim-bounce { animation: emoji-bounce 1s infinite ease-in-out; display: inline-block; }
.anim-shake { animation: emoji-shake 0.5s infinite ease-in-out; display: inline-block; }
.anim-spin { animation: emoji-spin 2s infinite linear; display: inline-block; }
.anim-wiggle { animation: emoji-wiggle 1s infinite ease-in-out; display: inline-block; }
.anim-pulse { animation: emoji-pulse 1.5s infinite ease-in-out; display: inline-block; }

/* Modern Speaker Button */
.modern-speak-btn {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    vertical-align: middle;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

.modern-speak-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
    transform: scale(1.1);
}

.modern-speak-btn:active {
    transform: scale(0.9);
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
}

.modern-speak-btn svg {
    width: 20px;
    height: 20px;
}

.btn-review-info {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: #c7d2fe;
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.05);
}

.btn-review-info:hover {
    background: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.25);
    color: #fff;
}
