/* ── Auth gate + login form ── */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg, #f8f7ff);
    padding: 24px;
}

.auth-gate-card {
    max-width: 420px;
    width: 100%;
    background: var(--glass, rgba(255,255,255,.82));
    border: 1px solid var(--glass-border, rgba(139,92,246,.14));
    border-radius: var(--radius, 20px);
    padding: 32px 28px;
    text-align: center;
    box-shadow: var(--shadow-lg, 0 20px 60px rgba(109,40,217,.12));
    backdrop-filter: blur(20px);
}

.auth-gate-icon { font-size: 2.8rem; margin-bottom: 12px; }
.auth-gate-card h2 { font-size: 1.25rem; margin-bottom: 8px; font-weight: 800; }
.auth-gate-card p { color: var(--text-muted); font-size: .88rem; line-height: 1.7; margin-bottom: 16px; }
.auth-gate-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 18px 0; color: var(--text-muted); font-size: .78rem;
}
.auth-gate-divider::before, .auth-gate-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--glass-border);
}

.auth-login-form { text-align: right; }
.auth-login-form .auth-field { margin-bottom: 12px; }
.auth-login-form label {
    display: block; font-size: .78rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 6px;
}
.auth-login-form input {
    width: 100%; padding: 12px 14px; border-radius: 12px;
    border: 1px solid var(--glass-border); background: rgba(255,255,255,.7);
    font-family: inherit; font-size: .9rem; transition: border-color .15s;
}
.auth-login-form input:focus {
    outline: none; border-color: var(--purple-400, #a78bfa);
    box-shadow: 0 0 0 3px rgba(139,92,246,.12);
}
.auth-login-btn {
    width: 100%; margin-top: 8px; padding: 13px;
    border: none; border-radius: 12px; font-family: inherit;
    font-weight: 700; font-size: .92rem; cursor: pointer;
    background: linear-gradient(135deg, var(--purple-600, #7c3aed), var(--purple-500, #8b5cf6));
    color: #fff; transition: transform .12s, opacity .12s;
}
.auth-login-btn:hover { transform: translateY(-1px); }
.auth-login-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.auth-login-error {
    color: #dc2626; font-size: .82rem; margin-top: 10px; min-height: 1.2em;
}

.auth-secondary-btn {
    width: 100%; margin-top: 10px; padding: 12px;
    border-radius: 12px; font-family: inherit; font-weight: 700; font-size: .9rem;
    cursor: pointer; background: transparent;
    border: 1px solid var(--glass-border, rgba(139,92,246,.2));
    color: var(--purple-700, #6d28d9); transition: background .12s;
}
.auth-secondary-btn:hover { background: rgba(139,92,246,.08); }

.auth-gate-hint {
    margin: 12px 0 0; font-size: .82rem; color: var(--text-muted); line-height: 1.6;
}

.auth-gate-card {
    max-height: min(92vh, 900px);
    overflow-y: auto;
}

.auth-gate-card.auth-gate-card-register,
.auth-gate-card:has(.auth-register-form) {
    max-width: 520px;
}

.auth-register-form select {
    width: 100%; padding: 12px 14px; border-radius: 12px;
    border: 1px solid var(--glass-border); background: rgba(255,255,255,.7);
    font-family: inherit; font-size: .9rem;
}

.auth-field-exams,
.auth-exam-field {
    margin-top: 2px;
    margin-bottom: 12px;
}
.auth-exam-head,
.auth-exam-field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.auth-exam-head label,
.auth-exam-field-head label {
    margin-bottom: 0 !important;
}
.auth-exam-hint {
    font-size: .72rem;
    color: var(--text-muted);
    font-weight: 500;
}
.auth-exam-hint.has-selection {
    color: var(--purple-600, #7c3aed);
    font-weight: 700;
}

.auth-exam-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    max-height: none;
    overflow: visible;
}

.auth-exam-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    gap: 0;
    margin: 0;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(255, 255, 255, 0.78);
    color: var(--text, #1e1b4b);
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.35;
    cursor: pointer;
    user-select: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .12s;
}
.auth-exam-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
}
.auth-exam-chip-text,
.auth-exam-chip span {
    display: block;
    text-align: center;
}
.auth-exam-chip:hover {
    border-color: rgba(124, 58, 237, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(109, 40, 217, 0.08);
}
.auth-exam-chip:has(input:checked),
.auth-exam-chip.is-selected {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(99, 102, 241, 0.08));
    border-color: rgba(124, 58, 237, 0.45);
    color: var(--purple-700, #6d28d9);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    font-weight: 700;
}
.auth-exam-chip:has(input:checked)::before,
.auth-exam-chip.is-selected::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 7px;
    border-radius: 999px;
    background: var(--purple-600, #7c3aed);
    color: #fff;
    font-size: .65rem;
    font-weight: 800;
    flex-shrink: 0;
}
.auth-exam-chip:has(input:focus-visible) {
    outline: 2px solid rgba(124, 58, 237, 0.45);
    outline-offset: 2px;
}
.auth-exam-empty {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, 0.35);
    background: rgba(248, 250, 252, 0.7);
    color: var(--text-muted);
    font-size: .8rem;
    text-align: center;
}

/* ── Header account menu ── */
.panel-topbar-actions {
    display: flex; align-items: center; gap: 8px;
    direction: ltr;
    flex-shrink: 0;
}
.panel-account-menu {
    position: relative;
    overflow: visible;
    z-index: 120;
}
.panel-account-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(220px, 52vw);
    padding: 4px 6px 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,.85);
    color: var(--purple-700, #6d28d9);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.panel-account-trigger:hover {
    background: rgba(139,92,246,.08);
    border-color: rgba(139,92,246,.28);
}
.panel-account-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 9.5rem;
}
.panel-account-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--purple-50, #f5f3ff);
    color: var(--purple-700, #6d28d9);
    flex-shrink: 0;
}
.panel-account-icon svg { width: 18px; height: 18px; }
/* منوی حساب — موقعیت نهایی با JS (fixed) تا از لبه صفحه نزند بیرون */
.panel-account-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    direction: rtl;
    width: 240px;
    min-width: 220px;
    max-width: calc(100vw - 24px);
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: var(--surface, #fff);
    box-shadow: 0 12px 32px rgba(76, 29, 149, .14);
    z-index: 200;
    display: none;
    box-sizing: border-box;
}
.panel-account-dropdown.is-open {
    display: block;
    position: fixed;
    z-index: 10000;
}
.panel-account-dropdown-head {
    padding: 8px 10px 10px;
    border-bottom: 1px solid rgba(139,92,246,.12);
    margin-bottom: 6px;
}
.panel-account-dropdown-name {
    display: block;
    font-size: .9rem;
    font-weight: 800;
    color: var(--text, #1e1b4b);
}
.panel-account-dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text, #1e1b4b);
    text-decoration: none;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 600;
    cursor: pointer;
    text-align: right;
}
.panel-account-dropdown-item:hover { background: var(--purple-50, #f5f3ff); }
.panel-account-dropdown-item.is-danger { color: #b91c1c; }
.panel-account-dropdown-item.is-danger:hover { background: #fef2f2; }

/* Theme toggle inside account dropdown */
.panel-theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    margin: 2px 0 4px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text, #1e1b4b);
    font-family: inherit;
    font-size: .86rem;
    font-weight: 600;
    cursor: pointer;
    text-align: right;
    direction: rtl;
    box-sizing: border-box;
}
.panel-theme-toggle:hover { background: var(--purple-50, #f5f3ff); }
.panel-theme-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
}
.panel-theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--purple-50, #f5f3ff);
    color: var(--purple-700, #6d28d9);
    flex-shrink: 0;
}
.panel-theme-toggle-icon svg { width: 16px; height: 16px; }
.panel-theme-toggle-text { display: flex; flex-direction: column; gap: 1px; line-height: 1.25; min-width: 0; }
.panel-theme-toggle-text strong { font-size: .86rem; font-weight: 700; }
.panel-theme-toggle-text span,
.panel-theme-toggle-state {
    font-size: .68rem;
    font-weight: 600;
    color: var(--text-muted);
}
.panel-theme-switch-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}
.panel-theme-switch {
    position: relative;
    flex: 0 0 44px;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: #d4d4d8;
    border: 1px solid rgba(113, 113, 122, 0.25);
    overflow: hidden;
    transition: background .18s ease, border-color .18s ease;
}
.panel-theme-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    transition: transform .18s ease;
}
.panel-theme-switch-input:checked + .panel-theme-switch,
.panel-theme-toggle[data-theme="dark"] .panel-theme-switch {
    background: linear-gradient(135deg, var(--purple-600, #7c3aed), var(--purple-500, #8b5cf6));
    border-color: rgba(124, 58, 237, 0.45);
}
.panel-theme-switch-input:checked + .panel-theme-switch::after,
.panel-theme-toggle[data-theme="dark"] .panel-theme-switch::after {
    transform: translateX(18px);
}
.panel-account-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,.65);
    color: var(--purple-700, #6d28d9);
    text-decoration: none; font-size: 1.15rem;
    transition: all .15s; flex-shrink: 0;
}
.panel-account-btn:hover {
    background: rgba(139,92,246,.1);
    border-color: rgba(139,92,246,.3);
    transform: translateY(-1px);
}
.panel-account-btn svg { width: 20px; height: 20px; }

/* ── Account page shared ── */
.panel-account-page .account-header { margin-bottom: 20px; }
.panel-account-page .account-header h1 { font-size: 1.35rem; font-weight: 800; margin-bottom: 4px; }
.panel-account-page .account-header p { color: var(--text-muted); font-size: .88rem; }

.account-hero-card {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, rgba(139,92,246,.12), rgba(99,102,241,.06));
    border: 1px solid rgba(139,92,246,.2);
    border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.account-hero-avatar {
    width: 56px; height: 56px; border-radius: 16px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 800; flex-shrink: 0;
}
.account-hero-info h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 2px; }
.account-hero-info p { font-size: .82rem; color: var(--text-muted); }
.account-hero-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.account-badge {
    font-size: .72rem; font-weight: 600; padding: 4px 10px;
    border-radius: 20px; background: rgba(255,255,255,.6);
    border: 1px solid var(--glass-border);
}

.account-form-card {
    background: var(--glass); border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
    backdrop-filter: blur(12px);
}
.account-form-card h2 { font-size: 1.05rem; font-weight: 800; margin-bottom: 4px; }
.account-form-hint { color: var(--text-muted); font-size: .82rem; margin-bottom: 18px; }
.account-form-grid { display: grid; gap: 14px; }
.account-field label {
    display: block; font-size: .78rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 6px;
}
.account-field input {
    width: 100%; padding: 11px 14px; border-radius: 12px;
    border: 1px solid var(--glass-border); background: rgba(255,255,255,.7);
    font-family: inherit; font-size: .9rem;
}
.account-field input.readonly {
    background: rgba(0,0,0,.04); color: var(--text-muted); cursor: not-allowed;
}
.account-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.account-btn {
    padding: 11px 20px; border-radius: 12px; border: none;
    font-family: inherit; font-weight: 700; font-size: .88rem; cursor: pointer;
    transition: transform .12s, opacity .12s;
}
.account-btn-primary {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-500));
    color: #fff;
}
.account-btn-primary:hover { transform: translateY(-1px); }
.account-btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.credentials-status {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-radius: 12px; margin-bottom: 14px;
    font-size: .85rem;
}
.credentials-status.ok { background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.25); color: #059669; }
.credentials-status.warn { background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25); color: #d97706; }

.account-back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--purple-600); text-decoration: none;
    font-weight: 600; font-size: .88rem; margin-bottom: 16px;
}

@media (max-width: 768px) {
    .account-hero-card { flex-direction: column; text-align: center; }
    .account-hero-badges { justify-content: center; }
}
