/* ═══════════════════════════════════════════════════════
   Gradelytics  –  Premium SaaS Design System
   ═══════════════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background-color: var(--surface-alt);
    margin: 0;
    padding: 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* ── Scroll Reveal ── */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
}

/* ── Focus states ── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-heading);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(180deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.08) 100%), var(--primary);
    color: #fff;
    box-shadow: var(--shadow-blue), inset 0 1px 0 rgba(255,255,255,0.22);
}

.btn-primary:hover {
    background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.06) 100%), var(--primary-hover);
    box-shadow: var(--shadow-blue-lg), inset 0 1px 0 rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm), inset 0 2px 4px rgba(0,0,0,0.12);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    background: var(--primary-muted);
}

.btn-full { width: 100%; }

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-icon-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 15px;
    transition: all var(--duration-fast) var(--ease-out);
    background: transparent;
}

.btn-icon-sm--edit {
    color: var(--primary);
}

.btn-icon-sm--edit:hover {
    background: var(--primary-muted);
}

.btn-icon-sm--delete {
    color: var(--danger);
}

.btn-icon-sm--delete:hover {
    background: var(--danger-bg);
}

.btn-icon-sm--primary {
    color: var(--primary);
}

.btn-icon-sm--primary:hover {
    background: var(--primary-muted);
}

/* ── Badge ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-heading);
    border-radius: var(--radius-pill);
    line-height: 1.4;
    letter-spacing: 0.02em;
}

.badge--distinction {
    background: var(--color-growth-muted);
    color: #15782F;
}

.badge--upper {
    background: var(--primary-muted);
    color: var(--primary);
}

.badge--lower {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-light);
}

.badge--pass {
    background: rgba(203, 213, 225, 0.3);
    color: var(--text-light);
}

.badge--fail {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge--default {
    background: var(--surface-alt);
    color: var(--text-light);
}

/* ═══════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════ */
header {
    background: var(--chrome-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--chrome-text);
    padding: 0 var(--sp-6);
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(var(--color-ink-rgb), 0.06);
    transition: background var(--duration-base), box-shadow var(--duration-base);
}

header.scrolled {
    box-shadow: var(--shadow-sm);
}

.navbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
}

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.nav-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.navbar h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--chrome-text);
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════════════════ */
.sidebar {
    width: 240px;
    height: calc(100vh - 56px);
    background: linear-gradient(180deg, var(--chrome-bg) 0%, rgba(var(--color-ink-rgb), 0.02) 100%);
    color: var(--chrome-text);
    position: fixed;
    top: 56px;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
    border-top: 1px solid var(--chrome-border);
    border-right: 1px solid var(--chrome-border);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: var(--sp-5) var(--sp-5) var(--sp-3);
    display: none;
}

.sidebar-logo {
    height: 28px;
    width: auto;
}

.sidebar-menu {
    list-style: none;
    padding: var(--sp-3) var(--sp-3);
    margin: 30px 0 0;
    flex: 1;
}

.sidebar-menu li {
    margin-bottom: 2px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px 14px;
    color: var(--chrome-text);
    opacity: 0.55;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
}

.sidebar-menu li a i {
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-menu li a:hover {
    color: var(--chrome-text);
    opacity: 1;
    background: rgba(var(--color-ink-rgb), 0.12);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.sidebar-menu li a.active {
    color: #fff;
    opacity: 1;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 50%) , var(--primary);
    box-shadow: var(--shadow-blue), inset 0 1px 0 rgba(255,255,255,0.18);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--chrome-border);
    margin-top: auto;
}

.sidebar-username {
    font-size: 13px;
    font-weight: 500;
    color: var(--chrome-text);
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-username i {
    font-size: 18px;
    color: var(--chrome-text);
    opacity: 0.4;
    flex-shrink: 0;
}

.sidebar-footer-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex-shrink: 0;
}

.sidebar-logout {
    background: none;
    border: none;
    color: var(--chrome-text);
    opacity: 0.4;
    font-size: 18px;
    cursor: pointer;
    padding: var(--sp-1);
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast);
    flex-shrink: 0;
}

.sidebar-logout:hover {
    color: var(--chrome-text);
    opacity: 1;
    background: rgba(var(--color-ink-rgb), 0.06);
}

/* Light mode: black sidebar font */
[data-theme="light"] .sidebar {
    color: #000;
}

[data-theme="light"] .sidebar-menu li a {
    color: #000;
    opacity: 0.8;
}

[data-theme="light"] .sidebar-menu li a:hover {
    color: #000;
    opacity: 1;
}

[data-theme="light"] .sidebar-menu li a.active {
    color: #fff;
    opacity: 1;
}

[data-theme="light"] .sidebar-username {
    color: #000;
    opacity: 0.8;
}

[data-theme="light"] .sidebar-username i {
    color: #000;
    opacity: 0.5;
}

[data-theme="light"] .sidebar-logout {
    color: #000;
    opacity: 0.6;
}

[data-theme="light"] .sidebar-logout:hover {
    color: #000;
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════
   Main
   ═══════════════════════════════════════════════════════ */
main {
    margin-left: 240px;
    padding: var(--sp-6);
    min-height: calc(100vh - 56px);
    transition: margin-left var(--duration-slow) var(--ease-out);
}

/* ═══════════════════════════════════════════════════════
   Sections
   ═══════════════════════════════════════════════════════ */
section {
    display: none;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: var(--sp-8);
    margin-bottom: var(--sp-6);
}

section.active {
    display: block;
}

.section-header {
    margin-bottom: var(--sp-6);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.section-header h2 {
    margin: 0 0 var(--sp-1);
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

.section-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--text-light);
}

/* ── Section Tags (like landing page) ── */
.section-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-muted);
    border: 1px solid rgba(var(--primary-rgb), 0.15);
    margin-bottom: var(--sp-2);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-family: var(--font-heading);
}

.section-tag i { font-size: 13px; }

/* ═══════════════════════════════════════════════════════
   Welcome Banner
   ═══════════════════════════════════════════════════════ */
.welcome-banner {
    position: relative;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.08) 0%, rgba(var(--color-accent-rgb), 0.05) 100%);
    border: 1px solid rgba(var(--primary-rgb), 0.12);
    border-radius: var(--radius-xl);
    padding: var(--sp-6) var(--sp-8);
    margin-bottom: var(--sp-6);
    overflow: hidden;
    animation: welcomeFadeIn 0.6s var(--ease-out);
}

.welcome-glow {
    position: absolute;
    top: -80px; right: -80px;
    width: 250px; height: 250px;
    background: radial-gradient(ellipse, rgba(var(--primary-rgb), 0.12) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-6);
    position: relative;
}

.welcome-text { flex: 1; }

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-muted);
    border: 1px solid rgba(var(--primary-rgb), 0.15);
    margin-bottom: var(--sp-3);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-family: var(--font-heading);
}

.welcome-badge i { font-size: 13px; }

.welcome-headline {
    margin: 0 0 var(--sp-1);
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

.welcome-sub {
    margin: 0;
    font-size: 14px;
    color: var(--text-light);
}

.welcome-stats {
    display: flex;
    align-items: center;
    gap: var(--sp-6);
}

.welcome-stat {
    text-align: center;
}

.welcome-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--ink);
    font-family: var(--font-heading);
    line-height: 1.2;
}

.welcome-stat-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.welcome-stat-divider {
    width: 1px;
    height: 40px;
    background: var(--border);
}

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

@media (prefers-reduced-motion: reduce) {
    .welcome-banner { animation: none; }
}

/* ═══════════════════════════════════════════════════════
   Input Section
   ═══════════════════════════════════════════════════════ */
.input-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-5);
    align-items: start;
}

.input-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
    transition: all var(--duration-base) var(--ease-out);
}

.input-card:hover {
    border-color: rgba(var(--primary-rgb), 0.15);
    box-shadow: var(--shadow-sm);
}

.module-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}

.form-row--full {
    grid-template-columns: 1fr;
}

.form-row--thirds {
    grid-template-columns: 1fr 1fr 1fr;
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
}

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

.field input:hover {
    border-color: rgba(var(--primary-rgb), 0.3);
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
    background: var(--surface);
}

/* ── Screenshot card ── */
.screenshot-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.screenshot-card-header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.screenshot-card-header i {
    font-size: 28px;
    color: var(--primary);
    flex-shrink: 0;
}

.screenshot-card-header strong {
    display: block;
    font-size: 14px;
    color: var(--ink);
}

.screenshot-card-header small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
}

.screenshot-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-8) var(--sp-4);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
    cursor: pointer;
    text-align: center;
    transition: all var(--duration-fast) var(--ease-out);
}

.screenshot-dropzone:hover {
    border-color: var(--primary);
    background: var(--primary-muted);
}

.screenshot-dropzone i {
    font-size: 32px;
    color: var(--primary);
}

.screenshot-dropzone span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.screenshot-dropzone small {
    font-size: 12px;
    color: var(--muted);
}

.screenshot-preview {
    position: relative;
}

.screenshot-preview img {
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background var(--duration-fast);
    padding: 0;
}

.remove-btn:hover {
    background: #dc2626;
}

#extract-status {
    font-size: 13px;
    color: var(--text-light);
}

/* ═══════════════════════════════════════════════════════
   Settings
   ═══════════════════════════════════════════════════════ */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-5);
    align-items: start;
}

.settings-col {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

.settings-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.settings-card-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.settings-card-head i {
    font-size: 24px;
    color: var(--primary);
    flex-shrink: 0;
}

.settings-card-head strong {
    display: block;
    font-size: 14px;
    color: var(--ink);
}

.settings-card-head small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.settings-msg {
    min-height: 16px;
    margin: 0;
    font-size: 12.5px;
    color: var(--danger);
    text-align: left;
}

.settings-msg.settings-msg--success {
    color: var(--color-growth);
}

.settings-card--danger {
    border-color: rgba(220, 38, 38, 0.35);
}

.settings-card--danger:hover {
    border-color: rgba(220, 38, 38, 0.55);
    box-shadow: var(--shadow-sm);
}

.settings-card--danger .settings-card-head i {
    color: var(--danger);
}

.settings-danger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
}

.settings-danger-row:first-of-type {
    padding-top: 0;
    border-top: none;
}

.settings-danger-text strong {
    display: block;
    font-size: 14px;
    color: var(--ink);
}

.settings-danger-text small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.settings-name-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}

.settings-name-actions .btn {
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════
   Academic Details Table
   ═══════════════════════════════════════════════════════ */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

#marks-table {
    width: 100%;
    border-collapse: collapse;
}

#marks-table th,
#marks-table td {
    padding: 6px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

#marks-table th {
    background: var(--ink);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: sticky;
    top: 0;
}

#marks-table td {
    font-size: 14px;
}

#marks-table tbody tr {
    transition: all var(--duration-fast) var(--ease-out);
}

#marks-table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

#marks-table tbody tr:nth-child(even) {
    background: var(--surface-alt);
}

#marks-table tbody tr:nth-child(even):hover {
    background: rgba(var(--primary-rgb), 0.03);
}

.td-name {
    font-weight: 600;
    color: var(--ink);
}

.td-mark {
    font-family: var(--font-heading);
    font-weight: 600;
}

.td-actions {
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   Statistics – KPI Cards
   ═══════════════════════════════════════════════════════ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5) var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    transition: all var(--duration-base) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: linear-gradient(90deg, var(--primary), rgba(var(--primary-rgb), 0.4));
    opacity: 0;
    transition: opacity var(--duration-base);
}

.kpi-card:hover {
    border-color: rgba(var(--primary-rgb), 0.25);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

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

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: var(--primary-muted);
    color: var(--primary);
}

.kpi-icon--green {
    background: var(--color-growth-muted);
    color: var(--color-growth);
}

.kpi-icon--purple {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-family: var(--font-heading);
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-heading);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.kpi-unit {
    font-size: 12px;
    color: var(--muted);
}

/* ── Charts ── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    transition: all var(--duration-base) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.chart-card::after {
    content: '';
    position: absolute;
    bottom: -40px; right: -40px;
    width: 120px; height: 120px;
    background: radial-gradient(ellipse, rgba(var(--primary-rgb), 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.chart-card:hover {
    border-color: rgba(var(--primary-rgb), 0.2);
    box-shadow: var(--shadow-md);
}

.chart-title {
    margin: 0 0 var(--sp-4);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-heading);
}

.chart-wrap {
    position: relative;
    height: 260px;
}

.chart-wrap--pie {
    height: 280px;
}

/* ═══════════════════════════════════════════════════════
   Grade Prediction
   ═══════════════════════════════════════════════════════ */
.prediction-card {
    text-align: left;
    background: var(--surface-alt);
    padding: var(--sp-6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    line-height: 1.7;
    font-size: 14px;
    margin-top: var(--sp-4);
    position: relative;
    overflow: hidden;
    transition: all var(--duration-base) var(--ease-out);
}

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

.prediction-card::after {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 100px; height: 100px;
    background: radial-gradient(ellipse, rgba(var(--primary-rgb), 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.prediction-card:empty {
    display: none;
}

#prediction-result h3,
#prediction-result h4,
#prediction-result h5 {
    margin: 12px 0 6px;
    color: var(--ink);
    font-family: var(--font-heading);
}

#prediction-result h3 { font-size: 17px; }
#prediction-result h4 { font-size: 15px; }
#prediction-result h5 { font-size: 14px; }

#prediction-result p { margin: 6px 0; }

#prediction-result ul,
#prediction-result ol {
    margin: 6px 0;
    padding-left: 22px;
}

#prediction-result li { margin: 3px 0; }

#prediction-result code {
    background: var(--primary-muted);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    font-size: 13px;
}

.pred-hero {
    text-align: center;
    padding: var(--sp-5) 0 var(--sp-3);
}
.pred-avg {
    font-size: 56px;
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--avg-color, var(--primary));
    line-height: 1;
}
.pred-avg-unit {
    font-size: 28px;
    font-weight: 600;
    opacity: 0.7;
}
.pred-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted, #8892a4);
    margin-top: 6px;
    font-weight: 600;
}
.pred-compare {
    font-size: 13px;
    color: var(--text-muted, #8892a4);
    margin-top: 4px;
}
.pred-section {
    margin-top: var(--sp-4);
}
.pred-section-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--ink);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pred-section-title i {
    font-size: 18px;
    color: var(--primary);
}
.pred-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pred-item {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    line-height: 1.5;
}
.pred-strength {
    background: var(--color-growth-muted);
    border-left: 3px solid var(--color-growth);
    color: var(--ink);
}
.pred-strategy {
    background: var(--color-primary-muted);
    border-left: 3px solid var(--primary);
    color: var(--ink);
}
.pred-assessment {
    background: var(--surface-alt);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--ink);
    border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════
   AI Analytics Hub
   ═══════════════════════════════════════════════════════ */

.ai-tabs {
    display: flex;
    gap: var(--sp-2);
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
}

.ai-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    font-family: var(--font-body);
    flex: 1;
    justify-content: center;
    min-width: 120px;
}

.ai-tab i {
    font-size: 18px;
    transition: transform var(--duration-base) var(--ease-out);
}

.ai-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-muted);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.ai-tab:hover i {
    transform: scale(1.15);
}

.ai-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-blue);
}

.ai-tab.active i {
    color: white;
}

.ai-content {
    position: relative;
    min-height: 200px;
}

.ai-panel {
    display: none;
    animation: ai-panel-enter 0.35s var(--ease-out);
}

.ai-panel.active {
    display: block;
}

@keyframes ai-panel-enter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-panel-header {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
    padding: var(--sp-5);
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.ai-panel-header i {
    font-size: 32px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-panel-header h3 {
    margin: 0 0 4px 0;
    font-family: var(--font-heading);
    font-size: 18px;
    color: var(--ink);
}

.ai-panel-header p {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-light);
}

/* ── What-If Info ── */
.whatif-info {
    margin-bottom: var(--sp-5);
}

.whatif-weight-bar {
    display: flex;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 8px;
    gap: 2px;
}

.whatif-weight-seg {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    font-family: var(--font-heading);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.whatif-weight-note {
    font-size: 12px;
    color: var(--text-light);
    margin: 0;
}

.whatif-part-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 800;
    font-family: var(--font-heading);
    margin-right: 4px;
}

.whatif-weight-label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
}

.whatif-form {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.whatif-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

.whatif-input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}

.whatif-input-group input {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color var(--duration-fast);
}

.whatif-input-group input:focus {
    border-color: var(--primary);
}

.whatif-result {
    padding: var(--sp-5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    display: none;
}

.whatif-result.show {
    display: block;
    animation: ai-panel-enter 0.35s var(--ease-out);
}

.whatif-class {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-3);
}

.whatif-class-icon {
    font-size: 36px;
}

.whatif-class-info h4 {
    margin: 0 0 2px 0;
    font-size: 20px;
    font-family: var(--font-heading);
}

.whatif-class-info p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

.whatif-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-heading);
}

/* ── Integrated Inline Chat ── */
.ai-chat-inline {
    margin-top: var(--sp-8);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--duration-base) var(--ease-out);
}

.ai-chat-inline:hover {
    box-shadow: var(--shadow-lg);
}

.ai-chat-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-5);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    font-family: var(--font-heading);
    color: var(--ink);
}

.ai-chat-header i {
    font-size: 20px;
    color: var(--primary);
}

.ai-chat-body {
    display: flex;
    flex-direction: column;
    height: 470px;
}

.ai-chat-body .suggested-prompts {
    flex-shrink: 0;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    background: var(--surface);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-pill);
    transition: background var(--duration-fast);
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

.ai-chat-messages .chat-message {
    display: flex;
    max-width: 88%;
}

.ai-chat-messages .chat-message.user {
    align-self: flex-end;
}

.ai-chat-messages .chat-message.assistant {
    align-self: flex-start;
}

.ai-chat-messages .chat-message.user .chat-bubble {
    background: #1e293b;
    color: white;
    border-bottom-right-radius: var(--radius-xs);
}

.ai-chat-messages .chat-message.assistant .chat-bubble {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-xs);
}

.ai-chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border-top: 1px solid var(--border);
    gap: var(--sp-2);
    flex-shrink: 0;
}

.ai-chat-input-area textarea {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: var(--font-body);
    color: var(--text);
    transition: border-color var(--duration-fast);
    max-height: 100px;
    line-height: 1.4;
    background: var(--surface);
}

.ai-chat-input-area textarea::placeholder {
    color: var(--muted);
}

.ai-chat-input-area textarea:focus {
    border-color: var(--primary);
}

.ai-chat-input-area #chat-send-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.08) 100%), var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--duration-fast);
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.20);
}

.ai-chat-input-area #chat-send-btn:hover {
    background: var(--primary-hover);
}

/* ── Weak Area Items ── */
.weak-item {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.weak-item-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.weak-item-content h4 {
    margin: 0 0 2px 0;
    font-size: 14px;
}

.weak-item-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

/* ── Career Item ── */
.career-item {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--surface-alt);
    border-left: 3px solid var(--primary);
}

.career-item-icon {
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--primary);
}

.career-item-content h4 {
    margin: 0 0 2px 0;
    font-size: 14px;
    color: var(--ink);
}

.career-item-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

/* ── Study Tip Item ── */
.tip-item {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--accent-muted, rgba(20, 201, 174, 0.08));
    border-left: 3px solid var(--teal);
}

.tip-item-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--teal);
}

.tip-item-content h4 {
    margin: 0 0 2px 0;
    font-size: 14px;
    color: var(--ink);
}

.tip-item-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

[data-theme="dark"] .ai-panel-header {
    background: var(--surface);
}

[data-theme="dark"] .whatif-input-group input {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .weak-item {
    background: rgba(220, 38, 38, 0.08);
}

[data-theme="dark"] .career-item {
    background: var(--surface);
}

[data-theme="dark"] .tip-item {
    background: rgba(20, 201, 174, 0.08);
}

[data-theme="dark"] .ai-chat-inline {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .ai-chat-header {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--ink);
}

[data-theme="dark"] .ai-chat-body .suggested-prompts {
    border-color: var(--border);
}

[data-theme="dark"] .ai-chat-input-area {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .ai-chat-input-area textarea {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .ai-chat-messages .chat-message.user .chat-bubble {
    background: #2d3748;
    color: #fff;
}

[data-theme="dark"] .ai-chat-messages .chat-message.assistant .chat-bubble {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .ai-tab {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-light);
}

[data-theme="dark"] .ai-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

[data-theme="dark"] .ai-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ═══════════════════════════════════════════════════════
   Achievements
   ═══════════════════════════════════════════════════════ */

/* ── KPI Strip ── */
.achievement-kpi-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

/* ── Next Up ── */
.achievement-next-up {
    display: flex;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-6);
}

.achievement-next-up:empty {
    display: none;
}

.achievement-next-card {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--color-gold-muted);
    border: 1px solid rgba(var(--color-gold-rgb), 0.2);
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    color: #92600A;
    flex: 1;
    min-width: 260px;
}

.achievement-next-card i {
    font-size: 18px;
    color: var(--color-gold);
    flex-shrink: 0;
}

.achievement-next-card strong {
    font-family: var(--font-heading);
}

/* ── Section Groups ── */
.achievement-section-group {
    margin-bottom: var(--sp-6);
}

.achievement-section-title {
    margin: 0 0 var(--sp-4);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--font-heading);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.achievement-section-title i {
    font-size: 16px;
}

.achievement-section-group:empty {
    display: none;
}

/* ── Grid ── */
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--sp-4);
}

.achievement-grid--improvements {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

/* ── Base Card ── */
.achievement-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    transition: all var(--duration-base) var(--ease-out);
    position: relative;
    overflow: hidden;
}

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

/* ── Medal Cards: Earned ── */
.achievement-card--earned {
    background: var(--surface);
}

.achievement-card--earned::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.achievement-card--gold.achievement-card--earned::before {
    background: linear-gradient(90deg, var(--color-gold), #F5C563);
}

.achievement-card--silver.achievement-card--earned::before {
    background: linear-gradient(90deg, var(--silver), #B0BAC6);
}

.achievement-card--bronze.achievement-card--earned::before {
    background: linear-gradient(90deg, var(--bronze), #D49A40);
}

/* ── Medal Cards: Locked ── */
.achievement-card--locked {
    background: var(--surface-alt);
    border-color: var(--border);
}

.achievement-card--locked .achievement-medal-badge {
    filter: grayscale(1) brightness(1.1);
    opacity: 0.5;
}

/* ── Medal Badge ── */
.achievement-card-top {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.achievement-medal-badge {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    position: relative;
}

.achievement-medal-badge--gold {
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 40%, rgba(0,0,0,0.08) 100%), var(--color-gold);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--color-gold-rgb), 0.35);
}

.achievement-medal-badge--silver {
    background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 40%, rgba(0,0,0,0.06) 100%), var(--silver);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 149, 163, 0.3);
}

.achievement-medal-badge--bronze {
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 40%, rgba(0,0,0,0.1) 100%), var(--bronze);
    color: #fff;
    box-shadow: 0 2px 8px rgba(192, 122, 32, 0.3);
}

/* Glossy shine overlay on earned medals */
.achievement-medal-badge::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 8px;
    right: 8px;
    height: 40%;
    background: linear-gradient(180deg, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0) 100%);
    border-radius: 50%;
    pointer-events: none;
}

.achievement-card--locked .achievement-medal-badge::after {
    display: none;
}

.achievement-medal-info {
    flex: 1;
    min-width: 0;
}

.achievement-tier-name {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-heading);
}

.achievement-criteria {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

/* ── Status Badge ── */
.achievement-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    flex-shrink: 0;
}

.achievement-status-badge--earned {
    color: var(--color-growth);
    background: var(--color-growth-muted);
}

.achievement-status-badge--locked {
    color: var(--muted);
    background: rgba(148, 163, 184, 0.12);
}

/* ── Earned Date Caption ── */
.achievement-earned-date {
    font-size: 11px;
    color: var(--muted);
    margin-top: -4px;
}

/* ── Proximity Hint ── */
.achievement-proximity {
    font-size: 12px;
    color: var(--color-gold);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: -2px;
}

.achievement-proximity i {
    font-size: 14px;
}

/* ── Module Chips ── */
.achievement-modules {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--sp-1);
}

.achievement-module-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 13px;
    background: var(--surface-alt);
    border-radius: var(--radius-pill);
    color: var(--text);
}

.achievement-module-chip strong {
    font-family: var(--font-heading);
    color: var(--ink);
}

.achievement-locked-text {
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
}

/* ── Improvement Award Card ── */
.achievement-card--improvement {
    border-left: none;
}

.achievement-card--improvement.achievement-card--earned {
    background: var(--surface);
    border-color: rgba(var(--color-accent-rgb), 0.25);
}

.achievement-card--improvement.achievement-card--earned::before {
    background: linear-gradient(90deg, var(--color-accent), #38D4BF);
}

.achievement-improvement-badge {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 40%, rgba(0,0,0,0.06) 100%), var(--color-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--color-accent-rgb), 0.3);
    position: relative;
}

.achievement-improvement-badge::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 8px;
    right: 8px;
    height: 40%;
    background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%);
    border-radius: var(--radius-md);
    pointer-events: none;
}

.achievement-card--improvement.achievement-card--locked .achievement-improvement-badge {
    filter: grayscale(1) brightness(1.1);
    opacity: 0.5;
}

.achievement-card--improvement.achievement-card--locked .achievement-improvement-badge::after {
    display: none;
}

/* ── Specific Improvement Detail ── */
.achievement-improvement-detail {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    font-family: var(--font-heading);
    margin-top: var(--sp-1);
}

.achievement-improvement-detail strong {
    color: var(--color-accent);
}

/* ── Empty / Early State ── */
.achievement-empty {
    text-align: center;
    padding: var(--sp-12) var(--sp-8);
    grid-column: 1 / -1;
}

.achievement-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--color-gold-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--sp-4);
}

.achievement-empty-icon i {
    font-size: 32px;
    color: var(--color-gold);
}

.achievement-empty h3 {
    margin: 0 0 var(--sp-2);
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-heading);
}

.achievement-empty p {
    margin: 0 0 var(--sp-5);
    font-size: 14px;
    color: var(--muted);
    line-height: 1.6;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.achievement-empty-preview {
    margin-top: var(--sp-5);
    opacity: 0.5;
    pointer-events: none;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Unlock Animation ── */
@keyframes medalUnlock {
    0%   { transform: scale(1); box-shadow: none; }
    30%  { transform: scale(1.08); box-shadow: 0 0 20px rgba(var(--color-gold-rgb), 0.4); }
    60%  { transform: scale(0.97); }
    100% { transform: scale(1); box-shadow: none; }
}

.achievement-card--unlock {
    animation: medalUnlock 0.5s var(--ease-out);
}

@keyframes badgePulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.achievement-medal-badge--pulse {
    animation: badgePulse 0.4s var(--ease-out) 0.1s;
}

@media (prefers-reduced-motion: reduce) {
    .achievement-card--unlock,
    .achievement-medal-badge--pulse {
        animation: none !important;
    }
}

/* ── Edit Module Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(var(--color-ink-rgb), 0.55);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-slow) var(--ease-out);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 480px;
    padding: var(--sp-6);
    transform: scale(0.95) translateY(8px);
    transition: transform var(--duration-slow) var(--ease-out);
}

.modal--sm {
    max-width: 380px;
}

.confirm-text {
    margin: 0 0 var(--sp-5);
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
}

.btn-danger {
    background: linear-gradient(180deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.08) 100%), var(--danger);
    color: #fff;
    box-shadow: 0 4px 14px -2px rgba(220, 38, 38, 0.30), inset 0 1px 0 rgba(255,255,255,0.20);
}

.btn-danger:hover {
    background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.06) 100%), #B91C1C;
    box-shadow: 0 8px 24px -4px rgba(220, 38, 38, 0.35), inset 0 1px 0 rgba(255,255,255,0.22);
    transform: translateY(-1px);
}

.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-5);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-heading);
}

.modal-close {
    background: var(--surface-alt);
    border: none;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--duration-fast);
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
}

/* ── Toast Notification ── */
.toast {
    position: fixed;
    bottom: 90px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10000;
    transform: translateY(8px);
    opacity: 0;
    transition: all var(--duration-slow) var(--ease-out);
    box-shadow: var(--shadow-lg);
}

.toast--visible {
    transform: translateY(0);
    opacity: 1;
}

.toast--success {
    background: #064e3b;
    color: #6ee7b7;
}

.toast--error {
    background: #7f1d1d;
    color: #fca5a5;
}

.toast i {
    font-size: 18px;
}

/* ═══════════════════════════════════════════════════════
   Chat FAB
   ═══════════════════════════════════════════════════════ */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.10) 100%), var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-blue-lg), inset 0 1px 0 rgba(255,255,255,0.25);
    z-index: 9998;
    transition: all var(--duration-base) var(--ease-out);
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(var(--primary-rgb), 0.4);
}

.chat-fab:active {
    transform: scale(1.02);
}

.chat-fab-glow {
    animation: fab-glow 2s ease-out 1;
}

@keyframes fab-glow {
    0%   { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.5), var(--shadow-blue-lg); }
    70%  { box-shadow: 0 0 0 16px rgba(var(--primary-rgb), 0), var(--shadow-blue-lg); }
    100% { box-shadow: var(--shadow-blue-lg); }
}

/* ═══════════════════════════════════════════════════════
   Chat Modal
   ═══════════════════════════════════════════════════════ */
.chat-modal {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 420px;
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: scale(0.92) translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: all var(--duration-slow) var(--ease-out);
    overflow: hidden;
}

.chat-modal.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    background: var(--ink);
    color: white;
    font-weight: 600;
    font-size: 15px;
    font-family: var(--font-heading);
    flex-shrink: 0;
}

.chat-modal-header span {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.chat-modal-header i {
    font-size: 20px;
    color: var(--primary);
}

.chat-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast);
}

.chat-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ── Suggested Prompts ── */
.suggested-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.prompt-btn {
    background: var(--surface-alt);
    color: var(--text-light);
    border: 1px solid var(--border);
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all var(--duration-fast);
    white-space: nowrap;
}

.prompt-btn:hover {
    background: var(--primary-muted);
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.3);
}

/* ── Chat Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.chat-message {
    display: flex;
    max-width: 88%;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-bubble {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
}

.chat-message.user .chat-bubble {
    background: #1e293b;
    color: white;
    border-bottom-right-radius: var(--radius-xs);
}

.chat-message.assistant .chat-bubble {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-xs);
}

.chat-bubble h3,
.chat-bubble h4,
.chat-bubble h5 {
    margin: 8px 0 4px;
    color: var(--ink);
    font-family: var(--font-heading);
}

.chat-bubble h3 { font-size: 15px; }
.chat-bubble h4 { font-size: 14px; }
.chat-bubble h5 { font-size: 13px; }

.chat-bubble p { margin: 4px 0; }

.chat-bubble ul,
.chat-bubble ol {
    margin: 4px 0;
    padding-left: 20px;
}

.chat-bubble li { margin: 2px 0; }

.chat-bubble code {
    background: var(--primary-muted);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    font-size: 13px;
}

/* ── Chat Input ── */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border-top: 1px solid var(--border);
    gap: var(--sp-2);
}

.chat-input-area textarea {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: var(--font-body);
    color: var(--text);
    transition: border-color var(--duration-fast);
    max-height: 100px;
    line-height: 1.4;
}

.chat-input-area textarea::placeholder {
    color: var(--muted);
}

.chat-input-area textarea:focus {
    border-color: var(--primary);
}

#chat-send-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.08) 100%), var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--duration-fast);
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.20);
}

#chat-send-btn:hover {
    background: var(--primary-hover);
}

.clear-chat {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: all var(--duration-fast);
    flex-shrink: 0;
}

.clear-chat:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ── Typing Indicator ── */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--sp-3) var(--sp-4);
    align-items: center;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════
   Menu Toggle
   ═══════════════════════════════════════════════════════ */
.menu-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    font-size: 22px;
    color: var(--chrome-text);
    cursor: pointer;
    z-index: 1100;
    display: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast);
}

.menu-toggle:hover {
    background: rgba(var(--color-ink-rgb), 0.08);
}

/* ═══════════════════════════════════════════════════════
   Dark Theme Overrides
   ═══════════════════════════════════════════════════════ */
[data-theme="dark"] body {
    background-color: var(--surface-alt);
    color: var(--text);
}

[data-theme="dark"] header {
    background: rgba(20, 23, 26, 0.88);
    border-bottom-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] section {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .section-header h2 {
    color: var(--ink);
}

[data-theme="dark"] .badge--distinction {
    background: var(--color-growth-muted);
    color: var(--color-growth);
}

[data-theme="dark"] .badge--upper {
    background: var(--primary-muted);
    color: var(--primary);
}

[data-theme="dark"] .badge--lower {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-light);
}

[data-theme="dark"] .badge--pass {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-light);
}

[data-theme="dark"] .badge--default {
    background: var(--surface-alt);
    color: var(--text-light);
}

[data-theme="dark"] .input-card,
[data-theme="dark"] .screenshot-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .prediction-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .pred-label,
[data-theme="dark"] .pred-compare {
    color: var(--text-muted);
}

[data-theme="dark"] .pred-strength {
    background: rgba(34, 166, 76, 0.15);
    color: var(--text);
}

[data-theme="dark"] .pred-strategy {
    background: rgba(29, 111, 224, 0.15);
    color: var(--text);
}

[data-theme="dark"] .pred-assessment {
    background: var(--surface-alt);
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .pred-section-title {
    color: var(--text);
}

[data-theme="dark"] .module-form input,
[data-theme="dark"] .module-form select,
[data-theme="dark"] #chat-input,
[data-theme="dark"] textarea {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .module-form input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--muted);
}

[data-theme="dark"] #marks-table th {
    background: var(--surface-alt);
    color: var(--text-light);
    border-color: var(--border);
}

[data-theme="dark"] #marks-table td {
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .kpi-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .toast {
    color: #fff;
}

[data-theme="dark"] .modal {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .modal-header h3 {
    color: var(--ink);
}

[data-theme="dark"] .confirm-text {
    color: var(--text-light);
}

[data-theme="dark"] .chat-modal {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .chat-modal-header {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .chat-bubble--user {
    background: var(--primary);
}

[data-theme="dark"] .chat-bubble--bot {
    background: var(--surface-alt);
    color: var(--text);
}

[data-theme="dark"] .prompt-btn {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-light);
}

[data-theme="dark"] .prompt-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

[data-theme="dark"] .achievement-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .achievement-card--locked {
    background: var(--surface-alt);
}

[data-theme="dark"] .screenshot-dropzone {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-light);
}

[data-theme="dark"] .screenshot-dropzone:hover {
    border-color: var(--primary);
}

[data-theme="dark"] .table-wrap {
    border-color: var(--border);
}

[data-theme="dark"] #marks-table tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}

[data-theme="dark"] .btn-outline {
    border-color: var(--border);
    color: var(--text-light);
}

[data-theme="dark"] .btn-outline:hover {
    border-color: var(--primary);
    background: var(--primary-muted);
    color: var(--primary);
}

[data-theme="dark"] .sidebar-footer {
    border-top-color: var(--chrome-border);
}

[data-theme="dark"] .achievement-module-chip {
    background: var(--surface-alt);
    color: var(--text);
}

[data-theme="dark"] .welcome-banner {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1) 0%, rgba(var(--color-accent-rgb), 0.06) 100%);
    border-color: rgba(var(--primary-rgb), 0.15);
}

[data-theme="dark"] .welcome-stat-divider {
    background: var(--border);
}

[data-theme="dark"] .section-tag {
    background: var(--primary-muted);
    border-color: rgba(var(--primary-rgb), 0.2);
    color: var(--primary);
}

[data-theme="dark"] .kpi-card--accent-blue::before {
    background: linear-gradient(90deg, var(--primary), rgba(var(--primary-rgb), 0.3));
}

/* Theme toggle button */
.theme-toggle {
    background: rgba(var(--color-ink-rgb), 0.06);
    border: none;
    color: var(--chrome-text);
    opacity: 0.6;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast);
    margin-left: var(--sp-2);
}

.theme-toggle:hover {
    background: rgba(var(--color-ink-rgb), 0.1);
    opacity: 1;
}

[data-theme="dark"] .theme-toggle {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255,255,255,0.16);
    color: #fff;
}
