:root {
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: #4f46e5;
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: #4338ca;
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-bg: #f5f6fa;
    --bs-body-color: #1f2937;
    --bs-border-color: #e5e7eb;
    --bs-border-radius: 0.6rem;
    --lms-surface: #ffffff;
    --lms-muted: #6b7280;
    --lms-sidebar: #111827;
    --lms-sidebar-hover: #1f2937;
    --lms-success: #16a34a;
    --lms-warning: #d97706;
    --lms-danger: #dc2626;
    --lms-radius: 0.9rem;
    --lms-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

body {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.btn-primary {
    --bs-btn-bg: #4f46e5;
    --bs-btn-border-color: #4f46e5;
    --bs-btn-hover-bg: #4338ca;
    --bs-btn-hover-border-color: #4338ca;
    --bs-btn-active-bg: #3730a3;
    --bs-btn-active-border-color: #3730a3;
    --bs-btn-disabled-bg: #4f46e5;
    --bs-btn-disabled-border-color: #4f46e5;
}

.btn-outline-primary {
    --bs-btn-color: #4f46e5;
    --bs-btn-border-color: #4f46e5;
    --bs-btn-hover-bg: #4f46e5;
    --bs-btn-hover-border-color: #4f46e5;
    --bs-btn-active-bg: #4338ca;
    --bs-btn-active-border-color: #4338ca;
}

.card {
    --bs-card-border-color: var(--bs-border-color);
    --bs-card-border-radius: var(--lms-radius);
    --bs-card-cap-bg: transparent;
    box-shadow: var(--lms-shadow);
}

.card-header {
    font-weight: 600;
    padding-block: 0.85rem;
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.3rem;
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible {
    border-color: #818cf8;
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.18);
}

.modal-content {
    border: 0;
    border-radius: var(--lms-radius);
}

.modal-header {
    border-bottom-color: var(--bs-border-color);
}

.modal-footer {
    border-top-color: var(--bs-border-color);
}

.confirm-icon {
    font-size: 2.2rem;
    line-height: 1;
    margin-bottom: 0.6rem;
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(92vw, 380px);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-head h2 {
    font-size: 1.15rem;
    font-weight: 650;
    margin: 0;
}

.page-head .actions {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    background: var(--lms-surface);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--lms-radius);
    box-shadow: var(--lms-shadow);
    height: 100%;
}

.stat-icon {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 0.8rem;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
    flex: none;
}

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

.stat-label {
    color: var(--lms-muted);
    font-size: 0.8rem;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--lms-muted);
}

.empty-state i {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.subject-logo {
    flex: none;
    border-radius: 22%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: #eef2ff;
}

.subject-logo-sm { width: 1.9rem; height: 1.9rem; font-size: 0.7rem; }
.subject-logo-md { width: 2.9rem; height: 2.9rem; font-size: 0.95rem; }
.subject-logo-lg { width: 4.5rem; height: 4.5rem; font-size: 1.4rem; }
.subject-logo-xl { width: 6.5rem; height: 6.5rem; font-size: 2rem; }

.subject-logo-ph {
    background: hsl(var(--h) 70% 93%);
    color: hsl(var(--h) 55% 32%);
}

.progress.progress-thin {
    height: 0.4rem;
    background: #e5e7eb;
}

.progress-bar {
    background-color: #4f46e5;
}

.progress-bar.bg-success {
    background-color: var(--lms-success) !important;
}

.text-muted-2 {
    color: var(--lms-muted);
}

.fs-xs {
    font-size: 0.75rem;
}

.avatar {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
    font-size: 0.72rem;
}

.badge {
    font-weight: 600;
}

.rich-content {
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.rich-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

.rich-content pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 0.9rem 1rem;
    border-radius: 0.6rem;
    overflow-x: auto;
}

.rich-content blockquote {
    border-left: 4px solid #c7d2fe;
    padding-left: 1rem;
    color: #4b5563;
    margin-left: 0;
}

.rich-content .ql-align-center { text-align: center; }
.rich-content .ql-align-right { text-align: right; }
.rich-content .ql-align-justify { text-align: justify; }
.rich-content .ql-indent-1 { padding-left: 3em; }
.rich-content .ql-indent-2 { padding-left: 6em; }
.rich-content .ql-indent-3 { padding-left: 9em; }
.rich-content table { border-collapse: collapse; width: 100%; }
.rich-content td,
.rich-content th { border: 1px solid #e5e7eb; padding: 0.4rem 0.6rem; }

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
