/* ========================================
   Moodle AI - Modern Dark Theme
   ======================================== */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2230;
    --bg-card-hover: #252a3a;
    --bg-input: #161922;
    --bg-sidebar: #141720;

    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b4;
    --text-muted: #636b80;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    --border: #2a2f3e;
    --border-light: #353b4e;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);

    --sidebar-width: 260px;
    --sidebar-collapsed: 68px;

    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ========================================
   Sidebar Navigation
   ======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 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 .material-icons-round {
    font-size: 28px;
    color: var(--accent);
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.sidebar-toggle:hover { background: var(--bg-card); }

.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition);
    margin-bottom: 2px;
    font-size: 14px;
    font-weight: 500;
}

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

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.nav-item .material-icons-round { font-size: 20px; }

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.nav-section-title {
    padding: 0 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn { color: var(--danger) !important; }
.logout-btn:hover { background: var(--danger-bg) !important; }

/* ========================================
   Main Content
   ======================================== */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 30px;
    min-height: 100vh;
}

.main-content-full {
    padding: 0;
    min-height: 100vh;
}

/* ========================================
   Page Header
   ======================================== */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    flex: 1;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    width: 100%;
    margin-top: -8px;
}

.header-actions { display: flex; gap: 8px; }

/* ========================================
   Flash Messages
   ======================================== */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.flash-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.flash-success { border-color: var(--success); }
.flash-success .material-icons-round { color: var(--success); }
.flash-error { border-color: var(--danger); }
.flash-error .material-icons-round { color: var(--danger); }
.flash-warning { border-color: var(--warning); }
.flash-warning .material-icons-round { color: var(--warning); }
.flash-info { border-color: var(--info); }
.flash-info .material-icons-round { color: var(--info); }

.flash-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
    padding: 2px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
}

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

.btn .material-icons-round { font-size: 18px; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.btn-success:hover { opacity: 0.9; color: white; }

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }

.btn-warning {
    background: transparent;
    border-color: var(--warning);
    color: var(--warning);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}
.btn-sm .material-icons-round { font-size: 16px; }

.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-full { width: 100%; justify-content: center; }

.btn-google {
    width: 100%;
    justify-content: center;
    padding: 12px;
    background: white;
    color: #333;
    border: 1px solid #ddd;
    font-weight: 600;
    gap: 10px;
}
.btn-google:hover {
    background: #f5f5f5;
    color: #333;
}

/* ========================================
   Stats Grid
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon .material-icons-round { font-size: 24px; }

.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.purple { background: var(--accent-glow); color: var(--accent); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

/* ========================================
   Section Card
   ======================================== */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
}

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

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.section-header h2 .material-icons-round {
    font-size: 20px;
    color: var(--accent);
}

.section-header p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   Quick Actions
   ======================================== */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.action-btn .material-icons-round { font-size: 18px; }

/* ========================================
   Badge
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }

/* ========================================
   Assignment List
   ======================================== */
.assignment-list { display: flex; flex-direction: column; gap: 4px; }

.assignment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    color: inherit;
    text-decoration: none;
}

.assignment-item:hover {
    background: var(--bg-card-hover);
    color: inherit;
}

.assignment-item.overdue { background: var(--danger-bg); }

.assignment-info h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.assignment-course {
    font-size: 12px;
    color: var(--text-muted);
}

.assignment-meta { display: flex; gap: 8px; align-items: center; }

/* ========================================
   Data Table
   ======================================== */
.assignment-table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.data-table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover td { background: var(--bg-card-hover); }

.assignment-link {
    color: var(--text-primary);
    font-weight: 500;
}
.assignment-link:hover { color: var(--accent); }

.course-tag {
    font-size: 12px;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: 4px;
}

.due-date { font-size: 12px; color: var(--text-secondary); }

.action-buttons { display: flex; gap: 4px; }

.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

/* ========================================
   Filter Tabs
   ======================================== */
.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    width: fit-content;
}

.filter-tab {
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition);
    font-family: inherit;
}

.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   University Cards
   ======================================== */
.university-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.university-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.uni-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.uni-header .material-icons-round {
    color: var(--accent);
    font-size: 24px;
}

.uni-header h3 { font-size: 15px; font-weight: 600; }

.uni-site, .uni-user {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.uni-actions { display: flex; gap: 6px; margin-top: 12px; }

/* Full university cards */
.university-grid-full {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.university-card-full {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.uni-header-full {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.uni-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.uni-icon .material-icons-round { color: var(--accent); font-size: 28px; }

.uni-header-full h2 { font-size: 18px; font-weight: 600; }
.uni-header-full p { font-size: 13px; color: var(--text-secondary); }

.uni-details { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.uni-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.uni-detail .material-icons-round { font-size: 16px; color: var(--text-muted); }

.uni-actions-full { display: flex; gap: 8px; flex-wrap: wrap; }

/* ========================================
   Course Cards
   ======================================== */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.course-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: border-color var(--transition);
}

.course-card:hover { border-color: var(--accent); }

.course-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.course-icon .material-icons-round { color: var(--accent); }

.course-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.course-code { font-size: 12px; color: var(--text-muted); }

/* ========================================
   Lectures
   ======================================== */
.lectures-list { display: flex; flex-direction: column; gap: 8px; }

.course-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    margin-top: 16px;
}

.course-section-header:first-child { margin-top: 0; }

.course-section-header .material-icons-round {
    color: var(--accent);
    font-size: 20px;
}

.course-section-header h2 { font-size: 16px; font-weight: 600; }

.lecture-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.lecture-info {
    display: flex;
    gap: 12px;
}

.lecture-info .material-icons-round {
    color: var(--text-muted);
    margin-top: 2px;
}

.lecture-info h3 { font-size: 14px; font-weight: 600; }
.lecture-info p { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.lecture-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-left: 32px;
}

.file-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.file-badge .material-icons-round { font-size: 14px; }

/* ========================================
   Detail Grid (Assignment Detail)
   ======================================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.detail-header .material-icons-round { color: var(--accent); font-size: 22px; }
.detail-header h2 { font-size: 16px; font-weight: 600; }

.detail-fields { display: flex; flex-direction: column; gap: 14px; }

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

.detail-field label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.detail-field span { font-size: 13px; font-weight: 500; }

.detail-description {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.detail-description h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.description-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.detail-attachments {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.detail-attachments h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    margin-bottom: 6px;
    font-size: 13px;
}

.attachment-item .material-icons-round { color: var(--text-muted); font-size: 18px; }
.att-size { margin-left: auto; font-size: 11px; color: var(--text-muted); }

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Solution */
.solution-card { min-height: 400px; }

.solution-content {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.solution-text {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
}

.solution-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ========================================
   Auto-Submit Settings
   ======================================== */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-info h3 { font-size: 14px; font-weight: 600; }
.setting-info p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.setting-sub { font-size: 11px !important; color: var(--text-muted) !important; }

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 26px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: white;
}

.info-card {
    display: flex;
    gap: 16px;
    background: var(--info-bg);
    border-color: transparent;
}

.info-card > .material-icons-round {
    color: var(--info);
    font-size: 24px;
    margin-top: 2px;
}

.info-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

.info-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-list li {
    font-size: 13px;
    color: var(--text-secondary);
    padding-left: 8px;
    position: relative;
}

.info-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 3px;
    height: 3px;
    background: var(--info);
    border-radius: 50%;
}

/* ========================================
   Auth Pages
   ======================================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-primary);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-icon {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 12px;
}

.auth-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.auth-error {
    padding: 12px 16px;
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-success {
    padding: 12px 16px;
    background: var(--success-bg);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    color: var(--success);
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-footer a { font-weight: 600; }

/* ========================================
   Forms
   ======================================== */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 32px;
    max-width: 600px;
}

.form-header {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.form-header .material-icons-round {
    font-size: 32px;
    color: var(--accent);
}

.form-header h2 { font-size: 18px; font-weight: 600; }
.form-header p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 20px;
    pointer-events: none;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 10px 12px 10px 42px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.form-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ========================================
   Subscription Page
   ======================================== */
.subscription-card {
    width: 100%;
    max-width: 580px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
}

.subscription-info {
    margin: 24px 0;
}

.sub-option {
    padding: 24px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.sub-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--info-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.sub-icon .material-icons-round { color: var(--info); font-size: 24px; }
.sub-icon.premium { background: var(--warning-bg); }
.sub-icon.premium .material-icons-round { color: var(--warning); }

.sub-option h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.sub-option p { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

.sub-email {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--accent);
}

.sub-email .material-icons-round { font-size: 18px; }

.sub-divider {
    text-align: center;
    padding: 10px 0;
    color: var(--text-muted);
    font-size: 12px;
}

.sub-features { margin-top: 24px; }
.sub-features h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

.sub-features ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.sub-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sub-features li .material-icons-round { color: var(--success); font-size: 18px; }

/* ========================================
   Empty States
   ======================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .material-icons-round {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p { font-size: 14px; margin-bottom: 16px; }

.empty-state-page {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state-page .material-icons-round {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state-page h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-page p { font-size: 14px; margin-bottom: 20px; }

/* ========================================
   Toast
   ======================================== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    z-index: 2000;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
    box-shadow: var(--shadow-lg);
}

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

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1024px) {
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .university-grid-full { grid-template-columns: 1fr; }
    .page-header h1 { font-size: 22px; }

    .mobile-menu-btn {
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 99;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-primary);
        cursor: pointer;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 24px; }
}

/* ========================================
   Real-time Progress Bar
   ======================================== */
.progress-container {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

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

.progress-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 600;
}

.progress-header .material-icons-round { color: var(--accent); font-size: 22px; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.progress-bar-wrap {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 14px;
}

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

.progress-stages {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stage {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg-primary);
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.stage .material-icons-round { font-size: 14px; }

.stage.active {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
}

.stage.done {
    background: var(--success-bg);
    color: var(--success);
    border-color: transparent;
}

/* ========================================
   Settings Page
   ======================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

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

.textarea-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition);
}

.textarea-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.select-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition);
    appearance: auto;
}

.select-input:focus {
    outline: none;
    border-color: var(--accent);
}

.number-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.number-input:focus {
    outline: none;
    border-color: var(--accent);
}

.range-input {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-primary);
    border-radius: 3px;
    outline: none;
    margin-top: 4px;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--accent);
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-row input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    padding: 2px;
}

.color-presets {
    display: flex;
    gap: 6px;
}

.color-preset {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.color-preset:hover { transform: scale(1.2); }

.subsection-title {
    font-size: 14px;
    font-weight: 600;
    margin: 20px 0 14px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
}

.setting-row-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.toggle-sm { transform: scale(0.85); }

/* Handwriting Preview */
.preview-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 16px 0;
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.preview-header .material-icons-round { font-size: 18px; }

.handwriting-preview {
    min-height: 120px;
    padding: 24px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.handwriting-preview p {
    color: #2d2d2d;
    font-family: 'Homemade Apple', cursive;
    font-size: 18px;
    line-height: 1.8;
    transition: all 0.3s ease;
}

/* Sticky save bar */
.sticky-save {
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    padding: 16px 0;
    border-top: 1px solid var(--border);
    margin-top: 20px;
    z-index: 10;
}

@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
    .settings-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ========================================
   Language Switcher
   ======================================== */
.lang-switcher {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.lang-switcher .lang-btn,
.public-lang-switcher .lang-btn {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.lang-switcher .lang-btn:hover,
.public-lang-switcher .lang-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.lang-switcher .lang-btn.active,
.public-lang-switcher .lang-btn.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent-hover);
}

.public-lang-switcher {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 4px;
    padding: 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    z-index: 1000;
}

/* ========================================
   RTL Overrides (Arabic)
   ======================================== */
html[dir="rtl"] body,
body.rtl {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Flip sidebar to right */
html[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border);
}

html[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

/* Public lang switcher flips to left */
html[dir="rtl"] .public-lang-switcher {
    right: auto;
    left: 16px;
}

/* Toast/flash anchor flips */
html[dir="rtl"] .flash-messages,
html[dir="rtl"] .toast-container {
    right: auto;
    left: 20px;
}

/* List/text alignment */
html[dir="rtl"] th,
html[dir="rtl"] td,
html[dir="rtl"] .data-table th,
html[dir="rtl"] .data-table td { text-align: right; }

html[dir="rtl"] .info-list,
html[dir="rtl"] .sub-features ul { padding-right: 0; }

html[dir="rtl"] .att-size { margin-left: 0; margin-right: auto; }

/* Form input icons: swap left padding to right */
html[dir="rtl"] .input-wrapper input,
html[dir="rtl"] .input-wrapper textarea {
    padding-left: 12px;
    padding-right: 44px;
}

html[dir="rtl"] .input-wrapper .input-icon {
    left: auto;
    right: 12px;
}

/* Mirror back-arrow icons in RTL since Material Icons don't auto-flip */
html[dir="rtl"] .material-icons-round.flip-rtl,
html[dir="rtl"] [class*="arrow_back"],
html[dir="rtl"] .btn .material-icons-round:first-child {
    /* keep most icons unflipped; only swap arrow_back where used */
}

html[dir="rtl"] .btn .material-icons-round[data-flip],
html[dir="rtl"] span.material-icons-round.flip-rtl {
    transform: scaleX(-1);
}

/* Generic margin-auto flips */
html[dir="rtl"] .ml-auto { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .mr-auto { margin-right: 0; margin-left: auto; }

/* Sidebar toggle on mobile flips */
@media (max-width: 768px) {
    html[dir="rtl"] .main-content { margin-right: 0; }
}

/* Page-header back-arrow: Material Icons need manual flip */
html[dir="rtl"] .page-header .btn-sm > .material-icons-round:first-child {
    transform: scaleX(-1);
}

/* =====================================================================
   v2 — UI/UX Refresh: Sidebar + Settings + Forms + Save Bar
   ===================================================================== */

:root {
    --sidebar-width: 272px;
    --radius-pill: 999px;
    --shadow-glow: 0 0 0 1px rgba(99, 102, 241, 0.35), 0 8px 24px rgba(99, 102, 241, 0.15);
    --gradient-accent: linear-gradient(135deg, #6366f1 0%, #a78bfa 100%);
}

/* ===== Sidebar polish ===== */
.sidebar {
    background: linear-gradient(180deg, #141720 0%, #0f1117 100%);
    border-right-color: rgba(255,255,255,0.04);
    box-shadow: 1px 0 0 rgba(255,255,255,0.02);
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom-color: rgba(255,255,255,0.05);
}

.logo {
    gap: 12px;
}

.logo .material-icons-round {
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-accent);
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.sidebar-nav {
    padding: 16px 12px;
}

.nav-section-title {
    padding: 0 14px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin: 16px 0 6px;
}

.nav-divider { display: none; }

.nav-item {
    position: relative;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 3px;
    font-size: 13.5px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.nav-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(99,102,241,0.18), rgba(99,102,241,0.06));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(99,102,241,0.25);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--gradient-accent);
}

html[dir="rtl"] .nav-item.active::before {
    left: auto;
    right: 0;
    border-radius: 3px 0 0 3px;
}

.nav-item .material-icons-round {
    font-size: 19px;
    color: var(--text-muted);
    transition: color var(--transition);
}

.nav-item:hover .material-icons-round,
.nav-item.active .material-icons-round {
    color: var(--accent);
}

/* Sidebar footer (lang switcher + user info + logout) */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
    background: rgba(0,0,0,0.15);
}

.lang-switcher {
    display: flex;
    gap: 0;
    padding: 3px;
    margin-bottom: 10px;
    border-radius: var(--radius-pill);
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.04);
}

.lang-switcher .lang-btn {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    transition: all var(--transition);
}

.lang-switcher .lang-btn:hover { color: var(--text-primary); }

.lang-switcher .lang-btn.active {
    color: #fff;
    background: var(--gradient-accent);
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

.user-info {
    padding: 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.04);
    margin-bottom: 8px;
    transition: background var(--transition);
}

.user-info:hover { background: rgba(255,255,255,0.06); }

.user-avatar,
.user-avatar-placeholder {
    width: 38px;
    height: 38px;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}

.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-email { font-size: 11px; color: var(--text-muted); }

.logout-btn {
    margin-top: 4px;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-secondary) !important;
    background: transparent;
    transition: all var(--transition);
}

.logout-btn:hover {
    background: rgba(239,68,68,0.08) !important;
    color: var(--danger) !important;
}

.logout-btn .material-icons-round { color: var(--text-muted); }
.logout-btn:hover .material-icons-round { color: var(--danger); }

/* Public-page lang switcher pill */
.public-lang-switcher {
    background: var(--bg-sidebar);
    border-color: rgba(255,255,255,0.06);
    backdrop-filter: blur(12px);
}

.public-lang-switcher .lang-btn {
    border-radius: var(--radius-pill);
    padding: 6px 14px;
}

.public-lang-switcher .lang-btn.active {
    background: var(--gradient-accent);
    color: #fff;
    border-color: transparent;
}

/* ===== Page header polish ===== */
.page-header h1 {
    font-size: 28px;
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Section cards: nicer borders & titles ===== */
.section-card {
    background: linear-gradient(180deg, rgba(30,34,48,0.7), rgba(30,34,48,0.4));
    border-color: rgba(255,255,255,0.06);
    border-radius: 14px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.section-header h2 .material-icons-round {
    font-size: 20px;
    color: var(--accent);
    margin-right: 6px;
    vertical-align: -4px;
}

html[dir="rtl"] .section-header h2 .material-icons-round {
    margin-right: 0;
    margin-left: 6px;
}

/* ===== Settings two-column layout ===== */
.settings-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 28px;
    align-items: flex-start;
}

@media (max-width: 980px) {
    .settings-shell { grid-template-columns: 1fr; }
    .settings-nav { position: static !important; }
}

.settings-nav {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
}

.settings-nav-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 4px 12px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.settings-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.settings-nav a:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.settings-nav a.active {
    color: var(--accent);
    background: rgba(99,102,241,0.12);
}

.settings-nav a .material-icons-round { font-size: 18px; }

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.settings-section {
    background: linear-gradient(180deg, rgba(30,34,48,0.7), rgba(30,34,48,0.45));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 24px;
    scroll-margin-top: 24px;
}

.settings-section-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.settings-section-header .ssh-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--accent-glow);
    color: var(--accent);
}

.settings-section-header .ssh-icon .material-icons-round { font-size: 20px; }

.settings-section-header .ssh-text { flex: 1; min-width: 0; }
.settings-section-header h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.settings-section-header p { font-size: 13px; color: var(--text-secondary); margin: 0; }

.settings-section-header .ssh-control { margin-left: auto; align-self: center; }
html[dir="rtl"] .settings-section-header .ssh-control { margin-left: 0; margin-right: auto; }

/* ===== Form controls polish ===== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group label .val-chip {
    display: inline-block;
    padding: 1px 8px;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(99,102,241,0.12);
    border-radius: var(--radius-pill);
    min-width: 32px;
    text-align: center;
}

html[dir="rtl"] .form-group label .val-chip {
    margin-left: 0;
    margin-right: 6px;
}

.textarea-input,
.select-input,
.number-input,
.input-wrapper input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.textarea-input:focus,
.select-input:focus,
.number-input:focus,
.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.textarea-input { resize: vertical; min-height: 90px; line-height: 1.55; }

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

html[dir="rtl"] .select-input {
    background-position: left 14px center;
    padding-right: 14px;
    padding-left: 36px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Range slider polish */
.range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.06);
    outline: none;
    cursor: pointer;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gradient-accent);
    border: 2px solid #1a1d27;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(99,102,241,0.3), 0 4px 8px rgba(99,102,241,0.3);
    transition: transform var(--transition);
}

.range-input::-webkit-slider-thumb:hover { transform: scale(1.1); }

.range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #1a1d27;
    cursor: pointer;
}

/* Color picker row */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.color-picker-row input[type="color"] {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    padding: 2px;
}

.color-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-preset {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition);
    padding: 0;
}

.color-preset:hover {
    transform: scale(1.1);
    border-color: var(--accent);
}

/* Toggle switch polish */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius-pill);
    transition: background var(--transition);
    cursor: pointer;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
}

html[dir="rtl"] .toggle-slider::before {
    left: auto;
    right: 3px;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--gradient-accent);
    box-shadow: 0 0 0 1px rgba(99,102,241,0.3), 0 0 12px rgba(99,102,241,0.4);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

html[dir="rtl"] .toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(-20px);
}

.toggle-switch.toggle-sm { width: 36px; height: 20px; }
.toggle-switch.toggle-sm .toggle-slider::before { height: 14px; width: 14px; }
.toggle-switch.toggle-sm input:checked + .toggle-slider::before { transform: translateX(16px); }
html[dir="rtl"] .toggle-switch.toggle-sm input:checked + .toggle-slider::before { transform: translateX(-16px); }

/* Setting row (toggle list items) */
.setting-row-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 10px;
    font-size: 13.5px;
    transition: background var(--transition);
}

.setting-row-compact:hover { background: rgba(255,255,255,0.04); }

.setting-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.setting-row:last-child { border-bottom: none; }

.setting-row .setting-info { flex: 1; min-width: 0; }
.setting-row h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.setting-row p { font-size: 13px; color: var(--text-secondary); margin: 0; }
.setting-row .setting-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Settings grid spacing improvements */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

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

@media (max-width: 768px) {
    .settings-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}

.subsection-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* Handwriting preview card */
.preview-card {
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.preview-header h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 0; }
.preview-header .material-icons-round { font-size: 18px; color: var(--accent); }

.handwriting-preview {
    padding: 32px 28px;
    background: #ffffff;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Sticky save bar (frosted glass) ===== */
.sticky-save {
    position: sticky;
    bottom: 0;
    margin-top: 24px;
    padding: 16px 20px;
    background: rgba(15,17,23,0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    box-shadow: 0 -2px 30px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 20;
}

.sticky-save .save-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.sticky-save .save-hint .material-icons-round {
    font-size: 16px;
    vertical-align: -3px;
    margin-right: 4px;
    color: var(--accent);
}

html[dir="rtl"] .sticky-save .save-hint .material-icons-round {
    margin-right: 0;
    margin-left: 4px;
}

.sticky-save button { min-width: 160px; }

/* Sliders use a value chip in label; tweak nicer */
.range-input + .form-hint { margin-top: 8px; }

/* Focus ring (a11y) */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

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

/* Mobile sidebar (collapsed by default on small screens) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    html[dir="rtl"] .sidebar { transform: translateX(100%); }
    html[dir="rtl"] .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 20px; }
    html[dir="rtl"] .main-content { margin-right: 0; }
    .sidebar-toggle { display: inline-flex; }
}

/* ===== Badges with icons + due-cell + filter tabs polish ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.badge .material-icons-round {
    font-size: 14px;
}

.badge-sm {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
}

.due-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.due-cell .due-date {
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Filter tabs polish */
.filter-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    width: fit-content;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 7px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.filter-tab.active {
    color: #fff;
    background: var(--gradient-accent);
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

/* Improve data-table row hover */
.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(99,102,241,0.04);
}

/* =====================================================================
   v3 — Paper Preview Realism + Cards + Empty States + Toasts
   ===================================================================== */

/* ===== Realistic paper backgrounds ===== */

.handwriting-preview {
    position: relative;
    padding: 36px 32px;
    min-height: 200px;
    border-radius: 0;
    overflow: hidden;
    transition: background 0.3s ease;
}

/* Default: clean white with subtle grain */
.handwriting-preview.paper-clean-white,
.handwriting-preview {
    background-color: #ffffff;
    background-image:
        radial-gradient(circle at 30% 20%, rgba(0,0,0,0.015), transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0,0,0,0.01), transparent 50%);
    box-shadow:
        inset 0 0 60px rgba(0,0,0,0.03),
        0 6px 20px rgba(0,0,0,0.4);
}

/* Aged vintage: warm cream paper with vignette + faint stains */
.handwriting-preview.paper-aged-vintage {
    background-color: #f3ead0;
    background-image:
        radial-gradient(ellipse at top left, rgba(160,120,60,0.18), transparent 60%),
        radial-gradient(ellipse at bottom right, rgba(120,80,30,0.22), transparent 55%),
        radial-gradient(circle at 65% 30%, rgba(140,90,40,0.08) 0px, transparent 18px),
        radial-gradient(circle at 25% 75%, rgba(120,80,40,0.06) 0px, transparent 22px);
    box-shadow:
        inset 0 0 80px rgba(120, 70, 20, 0.18),
        0 6px 20px rgba(0,0,0,0.4);
}

/* Lined notebook: horizontal lines with red margin */
.handwriting-preview.paper-lined-notebook {
    background-color: #fbfbff;
    background-image:
        linear-gradient(#a8c5e6 1px, transparent 1px),
        linear-gradient(90deg, transparent 60px, rgba(220,80,80,0.5) 60px, rgba(220,80,80,0.5) 61px, transparent 61px);
    background-size: 100% 28px, 100% 100%;
    background-position: 0 0, 0 0;
    line-height: 28px;
    padding-left: 76px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

html[dir="rtl"] .handwriting-preview.paper-lined-notebook {
    background-image:
        linear-gradient(#a8c5e6 1px, transparent 1px),
        linear-gradient(-90deg, transparent 60px, rgba(220,80,80,0.5) 60px, rgba(220,80,80,0.5) 61px, transparent 61px);
    padding-left: 32px;
    padding-right: 76px;
}

/* Parchment: warm tan with paper-fibre texture */
.handwriting-preview.paper-parchment {
    background-color: #ecd9b5;
    background-image:
        repeating-linear-gradient(45deg, rgba(120,80,40,0.025) 0px, rgba(120,80,40,0.025) 1px, transparent 1px, transparent 5px),
        repeating-linear-gradient(-45deg, rgba(120,80,40,0.025) 0px, rgba(120,80,40,0.025) 1px, transparent 1px, transparent 5px),
        radial-gradient(ellipse at center, transparent 40%, rgba(120,80,30,0.18) 100%);
    box-shadow:
        inset 0 0 80px rgba(140, 100, 50, 0.2),
        0 6px 20px rgba(0,0,0,0.4);
}

/* Blue grid */
.handwriting-preview.paper-blue-grid {
    background-color: #f7faff;
    background-image:
        linear-gradient(rgba(100, 140, 200, 0.25) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 140, 200, 0.25) 1px, transparent 1px);
    background-size: 24px 24px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* The preview text itself: realistic ink */
.handwriting-preview p {
    margin: 0;
    transition: all 0.3s ease;
    text-shadow:
        0.3px 0 0 currentColor,
        -0.2px 0 0 currentColor;
    -webkit-font-smoothing: antialiased;
}

/* Frame the preview like a real paper sheet */
.preview-card {
    background: linear-gradient(135deg, rgba(0,0,0,0.4), rgba(0,0,0,0.2));
    padding: 24px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.06);
}

.preview-card .preview-header {
    margin: -24px -24px 18px;
    padding: 12px 18px;
    border-radius: 14px 14px 0 0;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
}

.handwriting-preview {
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.08);
}

/* ===== Stat cards: hover lift + subtle gradient bg ===== */
.stat-card {
    position: relative;
    background: linear-gradient(180deg, rgba(30,34,48,0.7), rgba(30,34,48,0.4));
    border-color: rgba(255,255,255,0.06);
    border-radius: 14px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--gradient-accent);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99,102,241,0.3);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.stat-card > * { position: relative; z-index: 1; }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    transition: transform var(--transition);
}

.stat-card:hover .stat-icon { transform: scale(1.05); }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ===== Empty states polish ===== */
.empty-state,
.empty-state-page {
    text-align: center;
    padding: 36px 20px;
    color: var(--text-secondary);
}

.empty-state-page {
    padding: 64px 20px;
}

.empty-state .material-icons-round,
.empty-state-page .material-icons-round {
    font-size: 56px;
    color: var(--text-muted);
    margin-bottom: 14px;
    opacity: 0.4;
    display: inline-block;
    padding: 18px;
    background: var(--bg-card);
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.05);
}

.empty-state-page .material-icons-round {
    font-size: 48px;
    padding: 24px;
}

.empty-state-page h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state-page p {
    font-size: 14px;
    margin-bottom: 24px;
}

.empty-state p { margin-top: 8px; font-size: 13px; }

/* ===== Toast notifications ===== */
#toast-container,
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

html[dir="rtl"] #toast-container,
html[dir="rtl"] .toast-container {
    right: auto;
    left: 24px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(30,34,48,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    pointer-events: auto;
    animation: toast-in 0.3s ease;
    min-width: 240px;
    max-width: 380px;
}

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

html[dir="rtl"] .toast { border-left: none; }
html[dir="rtl"] .toast.toast-success { border-right: 3px solid var(--success); }
html[dir="rtl"] .toast.toast-error { border-right: 3px solid var(--danger); }
html[dir="rtl"] .toast.toast-info { border-right: 3px solid var(--info); }

@keyframes toast-in {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

html[dir="rtl"] .toast { animation-name: toast-in-rtl; }
@keyframes toast-in-rtl {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Flash messages match toast style */
.flash-msg {
    background: rgba(30,34,48,0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    padding: 12px 16px;
    animation: toast-in 0.3s ease;
}

.flash-success { border-left: 3px solid var(--success); }
.flash-error { border-left: 3px solid var(--danger); }
.flash-warning { border-left: 3px solid var(--warning); }
.flash-info { border-left: 3px solid var(--info); }

html[dir="rtl"] .flash-msg { border-left: none; }
html[dir="rtl"] .flash-success { border-right: 3px solid var(--success); }
html[dir="rtl"] .flash-error { border-right: 3px solid var(--danger); }
html[dir="rtl"] .flash-warning { border-right: 3px solid var(--warning); }
html[dir="rtl"] .flash-info { border-right: 3px solid var(--info); }

/* ===== Section cards / quick action buttons polish ===== */
.action-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 12px 18px;
    transition: all var(--transition);
}

.action-btn:hover {
    background: rgba(99,102,241,0.1);
    border-color: rgba(99,102,241,0.3);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.action-btn .material-icons-round {
    color: var(--accent);
    font-size: 18px;
}

/* ===== Assignment list & university card polish ===== */
.assignment-item {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 14px 16px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
}

.assignment-item:hover {
    background: rgba(99,102,241,0.06);
    border-color: rgba(99,102,241,0.2);
    transform: translateX(2px);
}

html[dir="rtl"] .assignment-item:hover { transform: translateX(-2px); }

.assignment-item.overdue { border-color: rgba(239,68,68,0.3); }
.assignment-item .assignment-info { flex: 1; min-width: 0; }
.assignment-item h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.assignment-item .assignment-course { font-size: 12px; color: var(--text-muted); }

.university-card-full,
.university-card {
    background: linear-gradient(180deg, rgba(30,34,48,0.7), rgba(30,34,48,0.4));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    transition: all var(--transition);
}

.university-card-full:hover,
.university-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99,102,241,0.3);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* ===== Auth pages: nicer card + entrance ===== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background:
        radial-gradient(ellipse at top, rgba(99,102,241,0.12), transparent 60%),
        radial-gradient(ellipse at bottom right, rgba(167,139,250,0.08), transparent 50%),
        var(--bg-primary);
}

.auth-card,
.subscription-card {
    background: linear-gradient(180deg, rgba(30,34,48,0.85), rgba(20,23,32,0.95));
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 40px 36px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: auth-in 0.4s ease;
}

@keyframes auth-in {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.auth-icon {
    font-size: 48px !important;
    color: var(--accent);
    background: var(--accent-glow);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 12px;
    display: inline-block;
}

.auth-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p { color: var(--text-secondary); font-size: 14px; }

.auth-divider {
    text-align: center;
    margin: 18px 0;
    position: relative;
    color: var(--text-muted);
    font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: rgba(255,255,255,0.08);
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* Detail page polish */
.detail-card {
    background: linear-gradient(180deg, rgba(30,34,48,0.7), rgba(30,34,48,0.4));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 24px;
}

.detail-header h2 { font-size: 17px; font-weight: 600; }
.detail-header .material-icons-round {
    font-size: 22px;
    color: var(--accent);
    margin-right: 8px;
    vertical-align: -4px;
}

html[dir="rtl"] .detail-header .material-icons-round {
    margin-right: 0;
    margin-left: 8px;
}

/* Progress container polish */
.progress-container {
    background: linear-gradient(180deg, rgba(30,34,48,0.85), rgba(20,23,32,0.95));
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(99,102,241,0.15);
}

.progress-bar {
    background: var(--gradient-accent);
    box-shadow: 0 0 12px rgba(99,102,241,0.4);
    transition: width 0.4s ease;
}

.progress-bar-wrap {
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-pill);
    height: 8px;
    overflow: hidden;
}

.progress-bar { height: 100%; border-radius: var(--radius-pill); }


/* =====================================================================
   v4 — Solution Preview Paper Sheet + AI Refine + Print
   ===================================================================== */

.preview-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Inline quick controls above the paper */
.preview-controls {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.pc-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.pc-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
}

.pc-field > span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pc-field input[type="color"] {
    width: 100%;
    min-width: 60px;
    height: 36px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 2px;
    background: transparent;
    cursor: pointer;
}

.pc-field input[type="range"] {
    min-width: 140px;
}

.pc-field .select-input.select-sm,
.pc-field select.select-sm {
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    min-width: 130px;
}

html[dir="rtl"] .pc-field .select-input.select-sm {
    padding: 6px 10px 6px 28px;
}

/* Paper preview stage — centers the sheet, dark backdrop */
.paper-preview-stage {
    background:
        radial-gradient(ellipse at center, rgba(0,0,0,0.4), rgba(0,0,0,0.6)),
        var(--bg-primary);
    padding: 32px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.04);
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

/* The styled paper sheet itself */
.paper-sheet {
    --ink: #2d2d2d;
    --hw-font: "Homemade Apple";
    --hw-size: 18px;
    --hw-line: 1.6;

    position: relative;
    background-color: #ffffff;
    width: 794px;
    max-width: 100%;
    min-height: 1123px;
    padding: 56px 60px;
    box-shadow:
        0 4px 12px rgba(0,0,0,0.25),
        0 20px 60px rgba(0,0,0,0.5);
    border-radius: 2px;
}

/* Page sizes (CSS: 96dpi) */
.paper-sheet.page-a4      { width: 794px;  min-height: 1123px; }
.paper-sheet.page-letter  { width: 816px;  min-height: 1056px; }
.paper-sheet.page-a5      { width: 559px;  min-height: 794px;  }
.paper-sheet.page-legal   { width: 816px;  min-height: 1344px; }

@media (max-width: 900px) {
    .paper-sheet { width: 100%; padding: 36px 28px; min-height: auto; }
}

/* Apply paper textures to the sheet (reuse from preview) */
.paper-sheet.paper-clean-white {
    background-color: #ffffff;
    background-image:
        radial-gradient(circle at 30% 20%, rgba(0,0,0,0.012), transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0,0,0,0.01), transparent 50%);
}
.paper-sheet.paper-aged-vintage {
    background-color: #f3ead0;
    background-image:
        radial-gradient(ellipse at top left, rgba(160,120,60,0.18), transparent 60%),
        radial-gradient(ellipse at bottom right, rgba(120,80,30,0.22), transparent 55%),
        radial-gradient(circle at 65% 30%, rgba(140,90,40,0.08) 0px, transparent 18px),
        radial-gradient(circle at 25% 75%, rgba(120,80,40,0.06) 0px, transparent 22px);
    box-shadow:
        inset 0 0 80px rgba(120, 70, 20, 0.18),
        0 4px 12px rgba(0,0,0,0.25),
        0 20px 60px rgba(0,0,0,0.5);
}
.paper-sheet.paper-lined-notebook {
    background-color: #fbfbff;
    background-image:
        linear-gradient(#a8c5e6 1px, transparent 1px),
        linear-gradient(90deg, transparent 80px, rgba(220,80,80,0.5) 80px, rgba(220,80,80,0.5) 81px, transparent 81px);
    background-size: 100% 32px, 100% 100%;
    background-position: 0 56px, 0 0;
    padding-left: 96px;
}
html[dir="rtl"] .paper-sheet.paper-lined-notebook {
    background-image:
        linear-gradient(#a8c5e6 1px, transparent 1px),
        linear-gradient(-90deg, transparent 80px, rgba(220,80,80,0.5) 80px, rgba(220,80,80,0.5) 81px, transparent 81px);
    padding-left: 60px;
    padding-right: 96px;
}
.paper-sheet.paper-parchment {
    background-color: #ecd9b5;
    background-image:
        repeating-linear-gradient(45deg, rgba(120,80,40,0.025) 0px, rgba(120,80,40,0.025) 1px, transparent 1px, transparent 5px),
        repeating-linear-gradient(-45deg, rgba(120,80,40,0.025) 0px, rgba(120,80,40,0.025) 1px, transparent 1px, transparent 5px),
        radial-gradient(ellipse at center, transparent 40%, rgba(120,80,30,0.18) 100%);
    box-shadow:
        inset 0 0 80px rgba(140, 100, 50, 0.2),
        0 4px 12px rgba(0,0,0,0.25),
        0 20px 60px rgba(0,0,0,0.5);
}

/* The actual handwritten content */
.paper-content {
    font-family: var(--hw-font), cursive;
    font-size: var(--hw-size);
    line-height: var(--hw-line);
    color: var(--ink);
    white-space: pre-wrap;
    word-wrap: break-word;
    outline: none;
    min-height: 200px;
    -webkit-font-smoothing: antialiased;
}

/* When editable, give a subtle highlight */
.paper-content[contenteditable="plaintext-only"]:focus {
    outline: 2px dashed rgba(99,102,241,0.4);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Lined notebook: align line-height to ruled lines */
.paper-sheet.paper-lined-notebook .paper-content {
    line-height: 32px;
}

/* ===== AI refine box ===== */
.refine-box {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(167,139,250,0.05));
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 14px;
}

.refine-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.refine-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.refine-header .material-icons-round {
    color: var(--accent);
    font-size: 22px;
}

.refine-hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.7;
}

.refine-hint code {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11.5px;
    color: var(--text-secondary);
    font-family: inherit;
}

.refine-input-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.refine-input-row .textarea-input {
    flex: 1;
    min-height: 0;
    height: 44px;
    padding: 10px 14px;
    resize: none;
}

.refine-input-row .btn-primary {
    flex-shrink: 0;
    padding: 10px 18px;
}

.refine-status {
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--text-muted);
    min-height: 18px;
}

.refine-status.loading { color: var(--accent); }
.refine-status.success { color: var(--success); }
.refine-status.error   { color: var(--danger); }

.refine-status.loading::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--accent);
    border-right-color: transparent;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: -1px;
    animation: spin 0.6s linear infinite;
}

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

/* ===== Print stylesheet — Save as PDF ===== */
@media print {
    body * { visibility: hidden !important; }
    .paper-sheet, .paper-sheet * {
        visibility: visible !important;
    }
    .paper-sheet {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        width: 100% !important;
        min-height: auto !important;
        padding: 24mm 18mm !important;
        page-break-inside: auto;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .paper-sheet.paper-lined-notebook { padding-left: 32mm !important; }
    html[dir="rtl"] .paper-sheet.paper-lined-notebook { padding-right: 32mm !important; padding-left: 18mm !important; }

    @page {
        margin: 0;
    }
    @page :first { margin: 0; }
}

/* =====================================================================
   v5 — More paper styles + Markdown/Math rendering
   ===================================================================== */

/* Graph paper (5mm grid) */
.paper-sheet.paper-graph-paper {
    background-color: #ffffff;
    background-image:
        linear-gradient(rgba(80, 130, 200, 0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(80, 130, 200, 0.18) 1px, transparent 1px),
        linear-gradient(rgba(80, 130, 200, 0.35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(80, 130, 200, 0.35) 1px, transparent 1px);
    background-size: 19px 19px, 19px 19px, 95px 95px, 95px 95px;
}

/* Engineering pad — pale green tint, fine grid */
.paper-sheet.paper-engineering-pad {
    background-color: #f0f5ec;
    background-image:
        linear-gradient(rgba(60, 130, 70, 0.22) 1px, transparent 1px),
        linear-gradient(90deg, rgba(60, 130, 70, 0.22) 1px, transparent 1px);
    background-size: 19px 19px;
}

/* Yellow legal pad with horizontal lines */
.paper-sheet.paper-yellow-legal {
    background-color: #fff6c8;
    background-image:
        linear-gradient(#cfc278 1px, transparent 1px),
        linear-gradient(90deg, transparent 80px, rgba(220,80,80,0.5) 80px, rgba(220,80,80,0.5) 81px, transparent 81px);
    background-size: 100% 32px, 100% 100%;
    background-position: 0 56px, 0 0;
    padding-left: 96px;
}
html[dir="rtl"] .paper-sheet.paper-yellow-legal {
    background-image:
        linear-gradient(#cfc278 1px, transparent 1px),
        linear-gradient(-90deg, transparent 80px, rgba(220,80,80,0.5) 80px, rgba(220,80,80,0.5) 81px, transparent 81px);
    padding-left: 60px;
    padding-right: 96px;
}

/* Dotted bullet journal */
.paper-sheet.paper-dotted {
    background-color: #fdfdfd;
    background-image: radial-gradient(rgba(120, 140, 170, 0.45) 1.2px, transparent 1.5px);
    background-size: 22px 22px;
    background-position: 11px 11px;
}

/* Cornell notes — left margin + bottom summary line */
.paper-sheet.paper-cornell {
    background-color: #fbfbff;
    background-image:
        linear-gradient(#bcd0e6 1px, transparent 1px),
        linear-gradient(90deg, transparent 180px, rgba(80,120,200,0.6) 180px, rgba(80,120,200,0.6) 181px, transparent 181px);
    background-size: 100% 32px, 100% 100%;
    background-position: 0 56px, 0 0;
    padding-left: 200px;
}
html[dir="rtl"] .paper-sheet.paper-cornell {
    background-image:
        linear-gradient(#bcd0e6 1px, transparent 1px),
        linear-gradient(-90deg, transparent 180px, rgba(80,120,200,0.6) 180px, rgba(80,120,200,0.6) 181px, transparent 181px);
    padding-left: 60px;
    padding-right: 200px;
}

/* Recycled / kraft paper */
.paper-sheet.paper-recycled {
    background-color: #d9c8a4;
    background-image:
        repeating-linear-gradient(0deg, rgba(120,90,40,0.05) 0px, rgba(120,90,40,0.05) 1px, transparent 1px, transparent 4px),
        repeating-linear-gradient(90deg, rgba(120,90,40,0.04) 0px, rgba(120,90,40,0.04) 1px, transparent 1px, transparent 6px),
        radial-gradient(ellipse at center, transparent 30%, rgba(80,60,30,0.18) 100%);
    box-shadow:
        inset 0 0 80px rgba(100, 70, 30, 0.18),
        0 4px 12px rgba(0,0,0,0.25),
        0 20px 60px rgba(0,0,0,0.5);
}

/* Blueprint */
.paper-sheet.paper-blueprint {
    background-color: #1a3a6e;
    color: #ffffff;
    background-image:
        linear-gradient(rgba(255,255,255,0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.18) 1px, transparent 1px);
    background-size: 24px 24px;
}
.paper-sheet.paper-blueprint .paper-content { color: #ffffff; }

/* Cream — soft warm white */
.paper-sheet.paper-cream {
    background-color: #f7efd9;
    background-image:
        radial-gradient(ellipse at top, rgba(180, 150, 90, 0.10), transparent 65%),
        radial-gradient(ellipse at bottom, rgba(180, 150, 90, 0.08), transparent 60%);
}

/* Music staff */
.paper-sheet.paper-music {
    background-color: #ffffff;
    background-image:
        repeating-linear-gradient(180deg,
            transparent 0px, transparent 10px,
            #444 10px, #444 11px,
            transparent 11px, transparent 21px,
            #444 21px, #444 22px,
            transparent 22px, transparent 32px,
            #444 32px, #444 33px,
            transparent 33px, transparent 43px,
            #444 43px, #444 44px,
            transparent 44px, transparent 80px);
}

/* ===== Markdown body (rendered) styling on paper ===== */
.paper-content.is-markdown {
    white-space: normal;
}

.paper-content.is-markdown h1,
.paper-content.is-markdown h2,
.paper-content.is-markdown h3,
.paper-content.is-markdown h4 {
    font-family: var(--hw-font), cursive;
    color: var(--ink);
    margin: 0.6em 0 0.3em;
    line-height: 1.25;
    font-weight: 700;
}

.paper-content.is-markdown h1 { font-size: 1.6em; }
.paper-content.is-markdown h2 { font-size: 1.35em; }
.paper-content.is-markdown h3 { font-size: 1.18em; }
.paper-content.is-markdown h4 { font-size: 1.06em; }

.paper-content.is-markdown p,
.paper-content.is-markdown li {
    margin: 0.4em 0;
}

.paper-content.is-markdown ul,
.paper-content.is-markdown ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

html[dir="rtl"] .paper-content.is-markdown ul,
html[dir="rtl"] .paper-content.is-markdown ol {
    padding-left: 0;
    padding-right: 1.5em;
}

.paper-content.is-markdown strong { font-weight: 700; }
.paper-content.is-markdown em { font-style: italic; }

.paper-content.is-markdown blockquote {
    border-left: 3px solid currentColor;
    padding-left: 1em;
    opacity: 0.75;
    margin: 0.6em 0;
}

html[dir="rtl"] .paper-content.is-markdown blockquote {
    border-left: none;
    border-right: 3px solid currentColor;
    padding-left: 0;
    padding-right: 1em;
}

.paper-content.is-markdown code {
    font-family: 'Fira Code', 'Courier New', monospace;
    background: rgba(0,0,0,0.05);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.92em;
}

.paper-content.is-markdown pre {
    background: rgba(0,0,0,0.06);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.6em 0;
}

.paper-content.is-markdown pre code {
    background: transparent;
    padding: 0;
}

.paper-content.is-markdown table {
    border-collapse: collapse;
    margin: 0.6em 0;
    font-size: 0.95em;
}

.paper-content.is-markdown th,
.paper-content.is-markdown td {
    border: 1px solid rgba(0,0,0,0.2);
    padding: 6px 10px;
    text-align: left;
}

html[dir="rtl"] .paper-content.is-markdown th,
html[dir="rtl"] .paper-content.is-markdown td { text-align: right; }

.paper-content.is-markdown th { font-weight: 700; background: rgba(0,0,0,0.04); }

.paper-content.is-markdown hr {
    border: none;
    border-top: 1px solid currentColor;
    opacity: 0.3;
    margin: 1em 0;
}

/* KaTeX renders to spans — inherit ink color */
.paper-content .katex,
.paper-content .katex * {
    color: inherit !important;
    font-size: 1em;
}

.paper-content .katex-display {
    margin: 0.6em 0;
    text-align: center;
}

/* Edit-mode textarea sits inside the paper sheet, no chrome */
.paper-content-editor {
    width: 100%;
    min-height: 400px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--ink);
    font-family: var(--hw-font), cursive;
    font-size: var(--hw-size);
    line-height: var(--hw-line);
    resize: vertical;
    padding: 0;
}

.paper-content-editor:focus {
    outline: 2px dashed rgba(99,102,241,0.4);
    outline-offset: 4px;
    border-radius: 4px;
}


/* =====================================================================
   v6 — dir="auto" + Realism + Header
   ===================================================================== */

/* The paper-content always treats text by its own direction.
   This prevents page direction from hijacking content language. */
.paper-content {
    unicode-bidi: plaintext;
}

/* Header line at top of paper (name / id / date) */
.paper-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 18px;
    border-bottom: 1px dashed currentColor;
    font-family: var(--hw-font), cursive;
    color: var(--ink);
    opacity: 0.8;
    font-size: 0.95em;
}

.paper-header span {
    white-space: nowrap;
}

/* ===== Letter-jitter spans ===== */
.paper-content .jl {
    transform-origin: 50% 80%;
}

/* Subtle inter-word natural ink flow when ink-flow is on */
.paper-sheet.realism-ink-flow .paper-content {
    text-shadow:
        0.2px 0 0 currentColor,
        -0.15px 0 0 currentColor;
    -webkit-font-smoothing: antialiased;
}

/* ===== Page tilt — slight rotation ===== */
.paper-sheet.realism-tilt {
    transform: rotate(-0.4deg);
    transition: transform 0.2s ease;
}

/* ===== Scanned look — slight blur + JPEG-like noise + warmer tone ===== */
.paper-sheet.realism-scan {
    filter: blur(0.3px) contrast(0.97) saturate(0.92);
    position: relative;
}

.paper-sheet.realism-scan::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 25% 35%, rgba(0,0,0,0.025) 0px, transparent 80px),
        radial-gradient(circle at 75% 70%, rgba(0,0,0,0.02) 0px, transparent 110px),
        repeating-linear-gradient(0deg, rgba(0,0,0,0.012) 0px, rgba(0,0,0,0.012) 1px, transparent 1px, transparent 3px);
    mix-blend-mode: multiply;
}

/* Stronger drop shadow when "paper shadow" is enabled */
.paper-sheet.realism-shadow {
    box-shadow:
        0 6px 16px rgba(0,0,0,0.35),
        0 30px 80px rgba(0,0,0,0.55),
        inset 0 0 1px rgba(0,0,0,0.05) !important;
}

/* Realism toggle row */
.pc-row-toggles {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255,255,255,0.06);
}

.pc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    transition: all var(--transition);
}

.pc-toggle:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.pc-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    position: relative;
    margin: 0;
}

.pc-toggle input[type="checkbox"]:checked {
    background: var(--gradient-accent);
    border-color: transparent;
}

.pc-toggle input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 0px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.pc-toggle:has(input:checked) {
    color: var(--text-primary);
    border-color: rgba(99,102,241,0.35);
    background: rgba(99,102,241,0.12);
}

/* Header fields row above the paper */
.header-fields-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.header-fields-row .textarea-input {
    min-height: 0;
    height: 38px;
    padding: 8px 12px;
    font-size: 13px;
    resize: none;
}

@media (max-width: 760px) {
    .header-fields-row { grid-template-columns: 1fr; }
}

/* Print: keep dir-auto and shadows; drop tilt for clean PDF */
@media print {
    .paper-sheet.realism-tilt { transform: none !important; }
    .paper-sheet.realism-scan { filter: none !important; }
    .paper-sheet.realism-scan::after { display: none !important; }
}

/* =====================================================================
   v7 — Templates (Handwritten / Document / Modern) + Per-course style
   ===================================================================== */

/* Template picker (segmented control) */
.pc-row-template {
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    padding-bottom: 12px;
    border-bottom: 1px dashed rgba(255,255,255,0.06);
}

.template-picker {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.05);
}

.template-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.template-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.template-btn.active {
    color: #fff;
    background: var(--gradient-accent);
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.template-btn .material-icons-round {
    font-size: 18px;
}

/* Course-override chip */
.course-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 5px 14px;
    border-radius: var(--radius-pill);
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.35);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
}

.course-chip.hidden { display: none; }

.course-chip .material-icons-round { font-size: 16px; }

.course-chip .chip-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 4px;
    border: none;
    background: rgba(99,102,241,0.2);
    border-radius: 50%;
    color: inherit;
    cursor: pointer;
    transition: background var(--transition);
}

.course-chip .chip-clear:hover { background: rgba(239,68,68,0.4); color: #fff; }
.course-chip .chip-clear .material-icons-round { font-size: 12px; }

html[dir="rtl"] .course-chip .chip-clear { margin-left: 0; margin-right: 4px; }

/* ===== TEMPLATE: Document — clean typeset academic paper ===== */
.paper-sheet.template-document {
    background-color: #ffffff !important;
    background-image: none !important;
    box-shadow:
        0 4px 14px rgba(0,0,0,0.25),
        0 24px 60px rgba(0,0,0,0.4) !important;
    padding: 72px 80px !important;
    color: #1a1a1a;
}

.paper-sheet.template-document .paper-content {
    color: #1a1a1a;
    font-family: 'Source Serif 4', 'Charter', 'Georgia', 'Times New Roman', serif;
    font-size: 12pt;
    line-height: 1.55;
    white-space: normal;
    text-shadow: none !important;
}

.paper-sheet.template-document .paper-content h1 {
    font-family: 'Source Serif 4', 'Charter', 'Georgia', serif;
    font-size: 22pt;
    font-weight: 700;
    text-align: center;
    margin: 0 0 0.3em;
    border: none;
    color: #111;
    line-height: 1.2;
}

.paper-sheet.template-document .paper-content h2 {
    font-family: 'Source Serif 4', 'Charter', 'Georgia', serif;
    font-size: 15pt;
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.4em;
    color: #111;
    border-bottom: 1px solid #ddd;
    padding-bottom: 4px;
}

.paper-sheet.template-document .paper-content h3 {
    font-size: 13pt;
    font-weight: 700;
    margin-top: 1.1em;
    color: #222;
}

.paper-sheet.template-document .paper-content p {
    margin: 0.6em 0;
    text-align: justify;
    text-justify: inter-word;
}

.paper-sheet.template-document .paper-content code {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    background: #f5f5f7;
    border: 1px solid #e0e0e6;
    color: #1a1a1a;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

.paper-sheet.template-document .paper-content pre {
    background: #f5f5f7;
    border: 1px solid #e0e0e6;
    color: #1a1a1a;
    padding: 14px 16px;
    font-size: 10pt;
}

.paper-sheet.template-document .paper-content blockquote {
    border-left: 3px solid #888;
    background: #fafafa;
    padding: 10px 16px;
    color: #444;
    margin: 0.8em 0;
    font-style: italic;
}

.paper-sheet.template-document .paper-content table {
    margin: 0.8em auto;
    border-collapse: collapse;
}

.paper-sheet.template-document .paper-content th,
.paper-sheet.template-document .paper-content td {
    border: 1px solid #c7c7cc;
    padding: 8px 12px;
}

.paper-sheet.template-document .paper-content th {
    background: #f0f0f3;
    font-weight: 700;
}

.paper-sheet.template-document .paper-header {
    text-align: center;
    border-bottom: 2px solid #1a1a1a;
    border-top: none;
    padding-bottom: 14px;
    margin-bottom: 28px;
    font-family: 'Source Serif 4', 'Charter', serif;
    font-size: 11pt;
    color: #444;
    opacity: 1;
    justify-content: center;
}

.paper-sheet.template-document .paper-header span {
    font-style: italic;
}

/* Document mode: disable handwriting realism effects */
.paper-sheet.template-document.realism-tilt { transform: none; }
.paper-sheet.template-document.realism-scan { filter: none; }
.paper-sheet.template-document.realism-scan::after { display: none; }
.paper-sheet.template-document .paper-content .jl {
    transform: none !important;
    opacity: 1 !important;
    display: inline !important;
}

/* ===== TEMPLATE: Modern Report — colored title bar + sans-serif ===== */
.paper-sheet.template-modern {
    background-color: #ffffff !important;
    background-image: none !important;
    padding: 0 !important;
    box-shadow:
        0 4px 14px rgba(0,0,0,0.25),
        0 24px 60px rgba(0,0,0,0.4) !important;
    color: #1f2937;
    overflow: hidden;
}

.paper-sheet.template-modern .paper-content {
    color: #1f2937;
    font-family: 'Inter', 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 11.5pt;
    line-height: 1.6;
    white-space: normal;
    padding: 56px 64px;
    text-shadow: none !important;
}

.paper-sheet.template-modern .paper-content h1 {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    margin: -56px -64px 32px;
    padding: 36px 64px;
    font-family: 'Inter', sans-serif;
    font-size: 24pt;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.paper-sheet.template-modern .paper-content h2 {
    color: #4f46e5;
    font-family: 'Inter', sans-serif;
    font-size: 16pt;
    font-weight: 700;
    margin-top: 1.6em;
    margin-bottom: 0.4em;
    padding-bottom: 6px;
    border-bottom: 2px solid #4f46e5;
}

.paper-sheet.template-modern .paper-content h3 {
    color: #1e1b4b;
    font-size: 13pt;
    font-weight: 700;
    margin-top: 1.2em;
}

.paper-sheet.template-modern .paper-content p {
    margin: 0.6em 0;
}

.paper-sheet.template-modern .paper-content code {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    background: #eef2ff;
    color: #4338ca;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.92em;
}

.paper-sheet.template-modern .paper-content pre {
    background: #f9fafb;
    border-left: 4px solid #4f46e5;
    color: #1f2937;
    padding: 14px 18px;
    font-size: 10pt;
    border-radius: 0 6px 6px 0;
}

.paper-sheet.template-modern .paper-content blockquote {
    background: #eef2ff;
    border-left: 4px solid #4f46e5;
    padding: 14px 18px;
    color: #312e81;
    margin: 0.8em 0;
    font-style: normal;
    border-radius: 0 6px 6px 0;
}

.paper-sheet.template-modern .paper-content table {
    margin: 0.8em 0;
    border-collapse: collapse;
    border: none;
    width: 100%;
}

.paper-sheet.template-modern .paper-content th {
    background: #4f46e5;
    color: #fff;
    text-align: left;
    padding: 10px 14px;
    border: none;
    font-weight: 600;
}

.paper-sheet.template-modern .paper-content td {
    padding: 8px 14px;
    border: none;
    border-bottom: 1px solid #e5e7eb;
}

.paper-sheet.template-modern .paper-content tr:nth-child(even) td {
    background: #f9fafb;
}

.paper-sheet.template-modern .paper-header {
    background: rgba(79,70,229,0.08);
    color: #312e81;
    padding: 14px 64px;
    margin: -56px -64px 0;
    border: none;
    border-bottom: 1px solid #e0e7ff;
    font-family: 'Inter', sans-serif;
    font-size: 12pt;
    opacity: 1;
    font-weight: 500;
}

/* Modern mode: disable handwriting realism */
.paper-sheet.template-modern.realism-tilt { transform: none; }
.paper-sheet.template-modern.realism-scan { filter: none; }
.paper-sheet.template-modern.realism-scan::after { display: none; }
.paper-sheet.template-modern .paper-content .jl {
    transform: none !important;
    opacity: 1 !important;
    display: inline !important;
}

/* =====================================================================
   v8 — Known Universities picker
   ===================================================================== */

.known-unis-card {
    background: linear-gradient(180deg, rgba(99,102,241,0.08), rgba(167,139,250,0.04));
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 14px;
    padding: 20px 22px;
    margin-bottom: 20px;
}

.known-unis-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.known-unis-header > .material-icons-round {
    font-size: 22px;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.known-unis-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text-primary);
}

.known-unis-header p {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.known-unis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}

.known-uni-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    cursor: pointer;
    text-align: start;
    color: inherit;
    font-family: inherit;
    transition: all var(--transition);
    min-width: 0;
}

.known-uni-chip:hover {
    background: rgba(99,102,241,0.10);
    border-color: rgba(99,102,241,0.35);
    transform: translateY(-1px);
}

.known-uni-chip.active {
    background: rgba(99,102,241,0.18);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(99,102,241,0.4);
}

.known-uni-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--accent-glow);
    color: var(--accent);
}

.known-uni-icon .material-icons-round { font-size: 20px; }

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

.known-uni-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.known-uni-url {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
}

/* =====================================================================
   v9 — Admin pending approvals
   ===================================================================== */
.pending-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pending-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.18);
    border-radius: 10px;
    transition: all var(--transition);
}

.pending-row:hover {
    background: rgba(245,158,11,0.10);
    border-color: rgba(245,158,11,0.3);
}

.pending-row .user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pending-row .user-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.pending-row .user-email { font-size: 12px; color: var(--text-muted); }

.pending-row .user-avatar,
.pending-row .user-avatar-placeholder {
    width: 36px; height: 36px;
}

.pending-actions {
    display: flex;
    gap: 6px;
}

@media (max-width: 700px) {
    .pending-row { grid-template-columns: 1fr; gap: 8px; }
    .pending-actions { justify-content: flex-end; }
}

/* =====================================================================
   v10 — Brand logo (sidebar + auth)
   ===================================================================== */

/* Sidebar mark — replace the prior gradient-square Material Icon */
.logo .logo-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
    flex-shrink: 0;
    background: transparent;
}

/* Auth pages logo */
.auth-logo {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(99,102,241,0.4);
    margin-bottom: 14px;
    display: inline-block;
}

/* Hide the legacy auth-icon (Material) styling when used as image */
img.auth-icon { padding: 0 !important; background: none !important; }

/* =====================================================================
   v11 — "Custom rules active" banner on assignment detail
   ===================================================================== */
.rules-active-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    margin: 12px 0 16px;
    background: linear-gradient(135deg, rgba(16,185,129,0.10), rgba(16,185,129,0.04));
    border: 1px solid rgba(16,185,129,0.30);
    border-radius: 10px;
    font-size: 13px;
}

.rules-active-banner > .material-icons-round {
    font-size: 20px;
    color: var(--success);
    background: rgba(16,185,129,0.15);
    padding: 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

.rules-active-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.rules-active-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

.rules-active-text > span {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rules-edit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    transition: all var(--transition);
    flex-shrink: 0;
}

.rules-edit-link:hover {
    background: rgba(99,102,241,0.15);
    color: var(--accent);
}

.rules-edit-link .material-icons-round { font-size: 18px; }
