/* =============================================
   StudyVault — Dark Financial Theme
   ============================================= */

/* ----- CSS Variables ----- */
:root {
    /* Backgrounds */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2236;
    --bg-card: #151d2e;
    --bg-card-hover: #1c2640;
    --bg-input: #0d1320;
    --bg-sidebar: #0c1121;

    /* Accents */
    --gold: #d4a853;
    --gold-light: #e8c97a;
    --gold-dark: #b8922e;
    --gold-glow: rgba(212, 168, 83, 0.15);
    --green: #10b981;
    --green-light: #34d399;
    --green-dark: #059669;
    --green-glow: rgba(16, 185, 129, 0.15);
    --red: #ef4444;
    --red-light: #f87171;
    --red-glow: rgba(239, 68, 68, 0.15);
    --blue: #3b82f6;
    --blue-light: #60a5fa;
    --blue-glow: rgba(59, 130, 246, 0.15);
    --purple: #8b5cf6;
    --purple-glow: rgba(139, 92, 246, 0.15);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0a0e17;

    /* Borders */
    --border: #1e293b;
    --border-light: #2a3a52;
    --border-gold: rgba(212, 168, 83, 0.3);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-gold: 0 0 20px rgba(212, 168, 83, 0.1);

    /* Dimensions */
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transitions */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- Reset ----- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

input,
textarea,
select {
    font-family: inherit;
    color: inherit;
}

ul,
ol {
    list-style: none;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    box-shadow: var(--shadow-gold);
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.sidebar-toggle {
    display: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-nav {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gold-glow);
    color: var(--gold);
    border: 1px solid var(--border-gold);
}

.nav-item.active svg {
    stroke: var(--gold);
}

.sidebar-subjects {
    padding: 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    overflow-y: auto;
    flex: 1;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 14px;
    margin-bottom: 8px;
}

.sidebar-subject {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
}

.sidebar-subject:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-subject .subject-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(4px);
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ----- Header ----- */
.main-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.menu-btn {
    display: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
}

.menu-btn:hover {
    background: var(--bg-tertiary);
}

.search-container {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-card-hover);
}

.search-result-type {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.search-result-type.course {
    background: var(--blue-glow);
    color: var(--blue);
}

.search-result-type.synthesis {
    background: var(--purple-glow);
    color: var(--purple);
}

.search-result-type.note {
    background: var(--green-glow);
    color: var(--green);
}

.search-result-type.subject {
    background: var(--gold-glow);
    color: var(--gold);
}

.header-date {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ----- Page Content ----- */
.page-content {
    flex: 1;
    padding: 28px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-secondary);
    transition: var(--transition);
}

.breadcrumb a:hover {
    color: var(--gold);
}

.breadcrumb .separator {
    opacity: 0.4;
}

/* =============================================
   CARDS
   ============================================= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.card-gold {
    border-color: var(--border-gold);
}

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

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}

.card-badge.gold {
    background: var(--gold-glow);
    color: var(--gold);
}

.card-badge.green {
    background: var(--green-glow);
    color: var(--green);
}

.card-badge.blue {
    background: var(--blue-glow);
    color: var(--blue);
}

.card-badge.red {
    background: var(--red-glow);
    color: var(--red);
}

/* ----- Grid Layouts ----- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ----- Stat Cards ----- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.3rem;
}

.stat-icon.gold {
    background: var(--gold-glow);
}

.stat-icon.green {
    background: var(--green-glow);
}

.stat-icon.blue {
    background: var(--blue-glow);
}

.stat-icon.purple {
    background: var(--purple-glow);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ----- Subject Cards ----- */
.subject-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.subject-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--subject-color, var(--gold));
    opacity: 0;
    transition: var(--transition);
}

.subject-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.subject-card:hover::before {
    opacity: 1;
}

.subject-card-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.subject-card-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.subject-card-stats {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.subject-card-progress {
    margin-top: 12px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.subject-card-progress-bar {
    height: 100%;
    border-radius: 2px;
    background: var(--subject-color, var(--gold));
    transition: width 0.6s ease;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--text-inverse);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(212, 168, 83, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.btn-danger {
    background: var(--red-glow);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-ghost {
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.btn-ai {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
}

.btn-ai:hover {
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
    transform: translateY(-1px);
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =============================================
   FORMS
   ============================================= */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* =============================================
   TOAST
   ============================================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 280px;
}

.toast.success {
    border-left: 3px solid var(--green);
}

.toast.error {
    border-left: 3px solid var(--red);
}

.toast.info {
    border-left: 3px solid var(--blue);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* =============================================
   LOADING
   ============================================= */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 23, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 42px;
    height: 42px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Inline loader */
.loader-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.loader-dots {
    display: flex;
    gap: 6px;
}

.loader-dots span {
    width: 8px;
    height: 8px;
    background: var(--gold);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loader-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0.4);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =============================================
   PROGRESS BAR
   ============================================= */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold));
}

.progress-bar.green {
    background: linear-gradient(90deg, var(--green-dark), var(--green));
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* =============================================
   FLASHCARD
   ============================================= */
.flashcard-container {
    perspective: 1000px;
    max-width: 500px;
    margin: 0 auto;
}

.flashcard {
    width: 100%;
    min-height: 280px;
    position: relative;
    cursor: pointer;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: var(--bg-tertiary);
    border-color: var(--green);
}

.flashcard-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.flashcard-text {
    font-size: 1.1rem;
    line-height: 1.6;
}

.flashcard-counter {
    text-align: center;
    margin: 16px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

/* =============================================
   QUIZ
   ============================================= */
.quiz-question {
    margin-bottom: 28px;
}

.quiz-question-text {
    font-size: 1.05rem;
    font-weight: 500;
    margin-bottom: 14px;
    line-height: 1.5;
}

.quiz-question-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quiz-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.quiz-choice:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.quiz-choice.selected {
    border-color: var(--gold);
    background: var(--gold-glow);
}

.quiz-choice.correct {
    border-color: var(--green);
    background: var(--green-glow);
}

.quiz-choice.incorrect {
    border-color: var(--red);
    background: var(--red-glow);
}

.quiz-choice-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    flex-shrink: 0;
    transition: var(--transition);
    position: relative;
}

.quiz-choice.selected .quiz-choice-radio {
    border-color: var(--gold);
}

.quiz-choice.selected .quiz-choice-radio::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: var(--gold);
    border-radius: 50%;
}

.quiz-score {
    text-align: center;
    padding: 32px;
}

.quiz-score-value {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.quiz-score-label {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.quiz-explanation {
    margin-top: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--gold);
}

/* =============================================
   CHAPTER / COURSE LIST
   ============================================= */
.chapter-section {
    margin-bottom: 24px;
}

.chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.chapter-header:hover {
    background: var(--bg-card-hover);
}

.chapter-title {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chapter-arrow {
    transition: transform var(--transition);
    color: var(--text-muted);
}

.chapter-header.open .chapter-arrow {
    transform: rotate(90deg);
}

.course-list {
    padding-left: 8px;
}

.course-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border-left: 2px solid transparent;
}

.course-item:hover {
    background: var(--bg-card);
    border-left-color: var(--gold);
}

.course-item-title {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.course-item-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.course-item-status.draft {
    background: var(--text-muted);
}

.course-item-status.completed {
    background: var(--green);
}

.course-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* =============================================
   EDITOR
   ============================================= */
.editor-container {
    margin-top: 16px;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    flex-wrap: wrap;
}

.editor-toolbar button {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition: var(--transition);
}

.editor-toolbar button:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.editor-content {
    min-height: 300px;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    outline: none;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.editor-content:focus {
    border-color: var(--gold);
}

/* =============================================
   FILE UPLOAD
   ============================================= */
.file-drop-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
    border-color: var(--gold);
    background: var(--gold-glow);
}

.file-drop-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.file-drop-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.file-drop-text strong {
    color: var(--gold);
}

.file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.file-item-icon {
    font-size: 1.2rem;
}

.file-item-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* =============================================
   TABS
   ============================================= */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 10px 18px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

/* =============================================
   FAVORITE BUTTON
   ============================================= */
.fav-btn {
    color: var(--text-muted);
    transition: var(--transition);
}

.fav-btn:hover {
    color: var(--gold);
}

.fav-btn.active {
    color: var(--gold);
}

/* =============================================
   TAGS
   ============================================= */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    border: 1px solid;
}

.tag.ai {
    background: var(--purple-glow);
    color: var(--purple);
    border-color: rgba(139, 92, 246, 0.2);
}

.tag.manual {
    background: var(--green-glow);
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.2);
}

/* =============================================
   NOTE CARDS
   ============================================= */
.note-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: var(--transition);
    cursor: pointer;
}

.note-card:hover {
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.note-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.note-card-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* =============================================
   SYNTHESIS VIEW
   ============================================= */
.synthesis-content {
    line-height: 1.8;
    font-size: 0.95rem;
}

.synthesis-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 20px 0 10px;
    color: var(--gold);
}

.synthesis-content ul {
    padding-left: 20px;
    margin: 8px 0;
}

.synthesis-content li {
    list-style: disc;
    margin: 4px 0;
    color: var(--text-secondary);
}

.synthesis-content strong {
    color: var(--text-primary);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .menu-btn {
        display: flex;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-content {
        padding: 16px;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .flashcard {
        min-height: 220px;
    }

    .flashcard-text {
        font-size: 0.95rem;
    }

    .toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: auto;
    }
}

@media (max-width: 480px) {

    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .main-header {
        padding: 0 12px;
    }

    .search-input {
        font-size: 0.8rem;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

/* =============================================
   READONLY MODE (Non-admin users)
   ============================================= */
.readonly-mode .btn-primary[onclick*="create"],
.readonly-mode .btn-primary[onclick*="Create"],
.readonly-mode .btn-primary[onclick*="add"],
.readonly-mode .btn-primary[onclick*="Add"],
.readonly-mode .btn-primary[onclick*="generate"],
.readonly-mode .btn-primary[onclick*="Generate"],
.readonly-mode .btn-ai,
.readonly-mode .btn-danger,
.readonly-mode [data-admin-only] {
    display: none !important;
}

/* =============================================
   TAGS & STATUS BADGES
   ============================================= */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.tag.pending {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.tag.approved {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.tag.rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* =============================================
   ADMIN STYLES
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.stats-grid .stat-card {
    padding: 16px;
}

.stats-grid .stat-card.attention {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.05);
}

/* Form select dark bg */
.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Sidebar user info area */
#sidebarUserInfo {
    margin-top: auto;
}

/* Admin nav section */
#adminNav .nav-item {
    padding: 8px 14px;
}