:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --primary: #38bdf8;
    --secondary: #818cf8;
    --accent: #f472b6;
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --backdrop: rgba(0, 0, 0, 0.6);
    
    /* Status Colors */
    --status-1: #ef4444; /* 🟥 Red */
    --status-2: #f97316; /* 🟧 Orange */
    --status-3: #facc15; /* 🟨 Yellow */
    --status-4: #22c55e; /* 🟩 Green */
    
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode {
    --bg-dark: #fdfdfe; /* Brighter background */
    --bg-card: rgba(255, 255, 255, 0.95); /* More opaque cards for visibility */
    --text-main: #0f172a;
    --text-dim: #475569;
    --glass: rgba(0, 0, 0, 0.02);
    --glass-bg: rgba(255, 255, 255, 0.9); /* Brighter floating windows */
    --glass-border: rgba(0, 0, 0, 0.08);
    --backdrop: rgba(255, 255, 255, 0.4);
    --shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(129, 140, 248, 0.12) 0px, transparent 50%);
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: smooth;
    transition: background 0.5s ease, color 0.5s ease;
}

body.light-mode {
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(129, 140, 248, 0.08) 0px, transparent 50%);
}

body.modal-open {
    overflow: hidden;
}

/* Glassmorphism Sidebar/Nav */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 100;
}

main {
    margin-left: 260px;
    padding: 2rem;
    max-width: 1200px;
}

.nav-item {
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.nav-item:hover, .nav-item.active {
    background: var(--glass);
    color: var(--primary);
    border: 1px solid var(--glass-border);
}

.nav-item.active {
    box-shadow: inset 0 0 10px rgba(56, 189, 248, 0.1);
}

/* Tabs and Content Area */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

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

/* Cards & Forms */
.card {
    box-shadow: var(--shadow);
}

/* UI Toggle Selector */
.ui-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 4px;
    margin-bottom: 1.5rem;
    width: fit-content;
}

.ui-toggle-btn {
    padding: 8px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: var(--transition);
}

.ui-toggle-btn.active {
    background: var(--primary);
    color: white;
}

h1, h2, h3 {
    margin-bottom: 1rem;
    font-weight: 700;
}

.title-gradient {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

input, select, textarea {
    width: 100%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-main);
    transition: var(--transition);
    min-width: 80px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

/* Question List Layout */
.question-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.status-1 { background: var(--status-1); }
.status-2 { background: var(--status-2); }
.status-3 { background: var(--status-3); }
.status-4 { background: var(--status-4); }

/* Status Step Picker */
.status-picker {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.status-dot {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0.3;
    transition: var(--transition);
}

.status-dot.active {
    opacity: 1;
    transform: scale(1.1);
}

/* Filters */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Sliding Toggle for Part */
.part-toggle {
    display: flex;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    padding: 4px;
    width: fit-content;
}

.part-option {
    padding: 6px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.part-option.active {
    background: var(--primary);
    color: white;
}

/* Multi-Add Field */
.multi-field {
    border-left: 2px solid var(--primary);
    padding-left: 1rem;
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 992px) {
    main { padding: 1.5rem; }
}

/* Smart Edit Interface */
.edit-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    height: 100%;
}

.edit-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--glass-border);
}

.edit-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.edit-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.edit-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
}

.keyword-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    background: var(--glass);
    padding: 12px;
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
}

.keyword-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.keyword-tag:hover {
    border-color: var(--primary);
}

.keyword-tag input {
    width: auto;
    margin: 0;
}

.session-edit-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    transition: var(--transition);
}

.session-edit-card:hover {
    border-color: var(--primary);
    background: var(--glass);
}

.session-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-edit-badge {
    padding: 4px 10px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 50px;
}

.session-edit-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
}

.session-edit-inputs input {
    text-align: center;
    font-weight: 700;
}

/* Status Icons in Modal */
.status-select-group {
    display: flex;
    gap: 10px;
    background: var(--glass);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.status-option {
    flex: 1;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    font-size: 1.2rem;
}

.status-option:hover {
    transform: scale(1.05);
}

.status-option.active {
    border-color: var(--text-main);
    box-shadow: 0 0 15px rgba(var(--primary), 0.2);
}

.status-option.s1 { background: var(--status-1); }
.status-option.s2 { background: var(--status-2); }
.status-option.s3 { background: var(--status-3); }
.status-option.s4 { background: var(--status-4); }

/* Animation for the full modal */
#full-edit-modal .modal {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    padding: 0;
    overflow: hidden;
    background: #0b0f1a;
    display: flex;
    flex-direction: column;
}

#full-edit-modal .modal-body {
    flex: 1;
    max-height: none;
    padding: 2.5rem;
    overflow-y: auto;
}

.modal-header {
    padding: 1.2rem 2.5rem;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-footer {
    padding: 1.5rem 2rem;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

@media (max-width: 768px) {
    .nav-header { display: none; }
    
    html { font-size: 14px; } /* Global scaling */
    
    nav {
        width: 100%;
        height: 60px;
        flex-direction: row;
        top: auto;
        bottom: 0;
        padding: 0;
        justify-content: space-around;
        align-items: center;
        border-right: none;
        border-top: 1px solid var(--glass-border);
        border-radius: 20px 20px 0 0;
    }
    
    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px;
        flex: 1;
        border-radius: 0;
        font-size: 0.7rem;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    .nav-item i { font-size: 1.2rem; }
    .nav-item span { display: block; font-size: 0.65rem; }

    main {
        margin-left: 0;
        margin-bottom: 70px;
        padding: 1rem;
        width: 100%;
    }

    .card { padding: 1rem; }
    
    /* Study Room Specifics */
    .study-filter-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .filter-card-left, .filter-card-right {
        width: 100% !important;
    }

    .subject-slide {
        padding: 8px 15px;
        font-size: 0.75rem;
    }

    /* Merged Nav Optimization */
    .merged-nav {
        flex-direction: row !important;
        overflow-x: auto;
        white-space: nowrap;
        gap: 0;
    }
    .merged-nav-item {
        flex: 1;
        padding: 12px 5px !important;
        border-right: 1px solid var(--glass-border) !important;
        border-bottom: none !important;
        min-width: 0;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center;
    }
    .merged-nav-item:last-child {
        border-right: none !important;
    }
    .merged-nav-value {
        display: none !important;
    }
    .merged-nav-label {
        font-size: 0.7rem !important;
        color: var(--text-dim);
        font-weight: 700;
        text-transform: uppercase;
        display: block;
    }
    .merged-nav-item.active {
        border-bottom: 2px solid var(--primary) !important;
        background: rgba(56, 189, 248, 0.1) !important;
    }
    .merged-nav-item.active .merged-nav-label {
        color: var(--primary);
    }
    .merged-dropdown {
        display: none !important;
    }
    
    /* Grid Adjustments */
    .params-grid, #params-legacy, #params-common {
        grid-template-columns: 1fr !important;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* Parameter lists adjustments */
    .param-list {
        max-height: none !important;
    }
    
    .param-item {
        padding: 10px;
    }
    
    .param-item span {
        font-size: 0.85rem;
    }

    /* Modal spacing */
    .modal {
        padding: 1.5rem;
        width: 95%;
    }
    
    /* Subject structure preview */
    #subject-preview-container {
        padding: 0;
    }
    #full-edit-modal .modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .edit-layout {
        grid-template-columns: 1fr;
    }
    
    .edit-sidebar {
        padding-right: 0;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        padding-bottom: 1.5rem;
    }

    #edit-q-sessions-list {
        grid-template-columns: 1fr !important;
    }
}

/* UI 2: WordPress Admin Style */
.wp-editor {
    background: #f1f1f1 !important;
    color: #32373c !important;
}

/* Jodit Editor Overrides */
#edit-ui-1-content .jodit-container {
    border: 1px solid var(--glass-border) !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

#edit-ui-1-content .jodit-toolbar__box {
    background: rgba(255, 255, 255, 0.05) !important;
    border-bottom: 1px solid var(--glass-border) !important;
}

#edit-ui-2-content .jodit-container {
    border: 1px solid #ccd0d4 !important;
    border-radius: 0 !important;
}

#edit-ui-2-content .jodit-toolbar__box {
    background: #f5f5f5 !important;
    border-bottom: 1px solid #ccd0d4 !important;
}

.wp-top-bar {
    background: #fff;
    border-bottom: 1px solid #ccd0d4;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.wp-main-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.wp-content-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wp-title-section {
    background: transparent;
}

.wp-title-input {
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
    padding: 10px 15px;
    font-size: 1.7rem;
    font-weight: 600;
    color: #32373c;
    border-radius: 0;
    min-height: 60px;
    resize: none;
}

.wp-editor-box {
    background: #fff;
    border: 1px solid #ccd0d4;
    display: flex;
    flex-direction: column;
}

.wp-editor-toolbar {
    background: #f5f5f5;
    border-bottom: 1px solid #ccd0d4;
    padding: 10px;
    display: flex;
    gap: 10px;
}

.wp-editor-toolbar span {
    font-size: 0.8rem;
    padding: 4px 10px;
    background: #fff;
    border: 1px solid #ccc;
    cursor: pointer;
}

.wp-editor-toolbar span.active {
    background: #eee;
    border-color: #999;
}

.wp-body-input {
    width: 100%;
    min-height: 400px;
    border: none;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #32373c;
    background: #fff;
    resize: vertical;
}

.tox-tinymce {
    border: none !important;
}

/* Ensure TinyMCE dropdowns/dialogs are above our modal */
.tox-tinymce-aux {
    z-index: 10001 !important;
}

.wp-editor-footer {
    padding: 8px 15px;
    background: #f5f5f5;
    border-top: 1px solid #ccd0d4;
    font-size: 0.75rem;
    color: #555;
}

.wp-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wp-metabox {
    background: #fff;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.wp-metabox-header {
    border-bottom: 1px solid #eee;
    padding: 10px 15px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #23282d;
}

.wp-metabox-body {
    padding: 15px;
}

.wp-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.wp-meta-row i {
    width: 16px;
    color: #82878c;
}

.wp-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #555;
}

/* --- New Component Styles --- */

.search-results-box {
    background: #1a1a1a;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 200px;
    overflow-y: auto;
    position: absolute;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.search-result-item {
    padding: 10px 15px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: 0.2s;
}

.search-result-item:hover {
    background: var(--primary);
    color: white;
}

.selected-q-box .card {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: 10px;
    position: relative;
}

.wp-table {
    border-collapse: collapse;
    width: 100%;
    background: transparent;
}

.wp-table th, .wp-table td {
    border-bottom: 1px solid var(--glass-border);
    padding: 10px;
    vertical-align: middle;
}

.wp-table th {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
}

.wp-input-minimal {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid transparent !important;
    padding: 5px !important;
    width: 100% !important;
    color: var(--text-main) !important;
    font-size: 0.85rem !important;
    transition: 0.2s !important;
}

.wp-input-minimal:focus {
    border-bottom-color: var(--primary) !important;
    background: rgba(255,255,255,0.05) !important;
    box-shadow: none !important;
}

.preview-text, .preview-answer {
    resize: vertical;
    min-height: 40px;
}

/* Ensure form groups with absolute children have positioning */
.form-group {
    position: relative;
}

.wp-input, .wp-select-plain {
    background: #fff;
    border: 1px solid #ddd;
    color: #32373c;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.wp-input-minimal {
    border: none;
    border-bottom: 1px solid #ddd;
    background: transparent;
    padding: 2px;
    font-size: 0.85rem;
    color: #32373c;
}

.wp-btn-primary {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 6px 15px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 1px 0 #005a87;
}

.wp-btn-secondary {
    background: #f7f7f7;
    color: #007cba;
    border: 1px solid #007cba;
    padding: 5px 15px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
}

.wp-session-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.wp-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.wp-tag-cloud .keyword-tag {
    background: #fff;
    border: 1px solid #ccc;
    color: #333;
    padding: 2px 8px;
}

/* --- Exam Paper Responsive --- */
.exam-container {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    background: transparent; 
}

.exam-paper-responsive {
    width: 100%;
    background: white;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    color: #000 !important;
    font-family: "Times New Roman", Times, serif;
    position: relative;
    line-height: 1.6;
    border-radius: 8px;
    container-type: inline-size;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .exam-container {
        padding: 30px;
    }
    .exam-paper-responsive {
        padding: 40px 60px;
    }
}


/* Dark mode overrides for text inside Exam Paper */
.exam-paper-responsive * {
    color: #000 !important;
}

.exam-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #000;
    padding-bottom: 15px;
    width: 100%;
}

/* Ensure header lines don't break, they scale instead */
.exam-header h1, 
.exam-header h2, 
.exam-header .sub-info {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    /* Scales font size based on container width - Made even smaller */
    font-size: clamp(0.45rem, 3.2cqw, 0.9rem);
    margin: 2px 0;
}

.exam-header h1 {
    font-weight: 700;
    margin-bottom: 2px;
}

.exam-header h2 {
    font-weight: 700;
    margin-bottom: 2px;
}

.exam-header .sub-info {
    margin-top: 10px;
    line-height: 1.6;
}

.exam-section-header {
    text-align: center;
    font-weight: bold;
    text-decoration: underline;
    margin: 20px 0 10px 0;
    text-transform: uppercase;
}

.exam-instruction {
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.exam-part-label {
    min-width: 20px;
}

/* Exam Collapsible Answer */
.exam-question-item {
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
    padding: 5px;
}

.exam-question-item:hover {
    background: rgba(0,0,0,0.03);
}

.exam-answer-section {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-left: 4px solid #1a1a1a;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
}

.exam-question-item.expanded .exam-answer-section {
    display: block;
}

.exam-answer-title {
    font-weight: bold;
    font-size: 0.75rem;
    color: #555;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.exam-answer-content {
    color: #333;
    white-space: pre-wrap;
}

.page-break-divider {
    width: 100%;
    height: 1px;
    border-bottom: 2px dashed rgba(255,255,255,0.1);
    margin: 20px 0;
    text-align: center;
    position: relative;
}

.page-break-divider::after {
    content: "PAGE BREAK";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1c23;
    padding: 0 10px;
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* Study Page - PDF Look */
.study-page {
    background: #ffffff;
    color: #1a1a1a;
    padding: 40px;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-width: 900px;
    margin: 0 auto;
    min-height: 80vh;
    line-height: 1.6;
}

.topic-section {
    margin-bottom: 40px;
}

.topic-header {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    color: #000;
    text-transform: uppercase;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.topic-header-num {
    font-size: 1.4rem;
    margin-right: 10px;
}

.question-block {
    margin-bottom: 25px;
    cursor: pointer;
    transition: background 0.2s;
    padding: 10px;
    border-radius: 8px;
    position: relative;
}

.question-block:hover {
    background: #f8fafc;
}

.question-header {
    display: flex;
    gap: 10px;
    font-weight: 600;
    font-size: 1.05rem;
    color: #1e293b;
    margin-bottom: 8px;
}

.question-num {
    flex-shrink: 0;
    color: #475569;
}

.question-text {
    flex: 1;
}

.sub-questions-list {
    margin-left: 45px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sub-question {
    display: flex;
    gap: 10px;
    font-size: 0.95rem;
}

.sub-q-num {
    font-weight: 600;
    color: #64748b;
    width: 25px;
}

.answer-panel {
    margin-top: 15px;
    margin-left: -20px;
    margin-right: -20px;
    padding: 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    display: none;
    font-size: 0.95rem;
    white-space: pre-wrap;
    color: #1e293b;
    animation: slideDown 0.2s ease-out;
}

.question-block.expanded .answer-panel {
    display: block;
}

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

.qs-meta {
    margin-top: 10px;
    margin-left: 45px;
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    gap: 15px;
}

/* Status Battery Indicator */
.status-battery {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
    width: fit-content;
    border: 1px solid #ddd;
    transition: all 0.2s ease;
}

.status-battery:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

.battery-bar {
    width: 12px;
    height: 12px;
    background: #e0e0e0;
    border-radius: 1px;
}

/* Level 1: Red (1 bar) */
.status-1 .bar-1 { background: #ff4757; }

/* Level 2: Orange (2 bars) */
.status-2 .bar-1, .status-2 .bar-2 { background: #ffa502; }

/* Level 3: Yellow (3 bars) */
.status-3 .bar-1, .status-3 .bar-2, .status-3 .bar-3 { background: #eccc68; }

/* Level 4: Green (4 bars) */
.status-4 .bar-1, .status-4 .bar-2, .status-4 .bar-3, .status-4 .bar-4 { background: #2ed573; }

.question-block {
    position: relative;
}

.question-block .status-battery {
    position: absolute;
    right: -15px;
    top: 30px;
}

/* Dark mode overrides for study page if needed, but user wants PDF look which is usually light */
@media (prefers-color-scheme: dark) {
    /* We keep the study page light even in dark mode for that "book" feel, or slightly off-white */
    .study-page {
        background: #fdfdfd;
    }
}

@media (max-width: 600px) {
    .study-page {
        padding: 20px;
    }
    .sub-questions-list, .answer-panel, .qs-meta {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }
    
    .grid-layout {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Subject Grid Selection */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.subject-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.subject-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0.7;
}

.subject-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    background: rgba(255, 255, 255, 0.08);
}

.subject-card i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.subject-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.subject-card p {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.subject-card .qs-count {
    font-size: 0.75rem;
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 50px;
    border: 1px solid rgba(56, 189, 248, 0.2);
    margin-top: 5px;
}

/* Study Structure Box */
.study-structure-box {
    background: #ffffff;
    color: #1a1a1a;
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    font-family: 'Inter', sans-serif;
}

.study-structure-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #000;
    text-align: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 25px;
    text-transform: uppercase;
}

.structure-part {
    margin-bottom: 30px;
}

.structure-part-header {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 6px;
    border-left: 5px solid #38bdf8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.structure-part-label {
    font-weight: 900;
    font-size: 1.1rem;
    color: #333;
}

.structure-topic-item {
    margin-bottom: 15px;
    padding-left: 10px;
}

.structure-topic-link {
    font-weight: 700;
    font-size: 1rem;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
    padding: 5px 0;
}

.structure-topic-link:hover {
    color: #38bdf8;
    padding-left: 5px;
}

.structure-subtopic-list {
    padding-left: 25px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 5px;
}

.structure-subtopic-link {
    font-size: 0.9rem;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
}

.structure-subtopic-link:hover {
    color: #818cf8;
    padding-left: 5px;
}

/* Smooth Fade In for questions */
#questions-container {
    animation: fadeInQ 0.3s ease-out;
}

/* Header Center Toggle */
.header-center-toggle {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

@media (max-width: 768px) {
    .hide-mobile-title {
        display: none !important;
    }
    .header-center-toggle {
        position: static;
        transform: none;
        flex: 1;
        display: flex;
        justify-content: center;
    }
}

@media (min-width: 769px) {
    .hide-mobile-title {
        display: block !important;
    }
}

/* Hover Floating Window (Tooltip) */
.bridged-session-badge {
    position: relative;
    cursor: help;
}

.bridged-tooltip {
    visibility: hidden;
    width: 350px;
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-main);
    text-align: left;
    border-radius: 8px;
    padding: 15px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -175px;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 1px solid var(--primary);
    backdrop-filter: blur(10px);
    pointer-events: none;
    line-height: 1.5;
}

.bridged-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--primary) transparent transparent transparent;
}

.bridged-session-badge:hover .bridged-tooltip {
    visibility: visible;
    opacity: 1;
}

.bridged-tooltip .tooltip-header {
    font-weight: 800;
    color: var(--primary);
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 8px;
    padding-bottom: 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.bridged-tooltip .tooltip-content {
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 10px;
}

.bridged-tooltip .tooltip-answer {
    font-size: 0.8rem;
    color: var(--secondary);
    border-top: 1px solid var(--glass-border);
    padding-top: 8px;
}
