/* ==========================================================================
   AlNajdi — Core UI: nav, buttons, inputs, cards, modals, toasts
   ========================================================================== */

/* ─── Top navigation (Baims-style) ─────────────────────────────── */
.top-nav {
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 32px;
    align-items: center;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800;
    color: var(--text);
    flex-shrink: 0;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    flex-shrink: 0;
}
.brand-mark img { width: 26px; height: 26px; display: block; object-fit: contain; }
.brand-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -.015em;
    color: var(--text);
    display: inline-flex;
    align-items: baseline;
}
.brand-name-baims { color: #0ea5e9; font-weight: 700; }
.brand-name-x {
    font-size: .72em;
    font-weight: 600;
    color: var(--text-mute);
    margin: 0 .18em;
}
[data-theme="dark"] .brand-name-baims { color: #38bdf8; }
.top-nav-links {
    display: flex;
    gap: 4px;
    align-items: center;
}
.top-nav-link {
    padding: 8px 16px;
    border-radius: var(--r-full);
    color: var(--text-soft);
    font-weight: 600;
    font-size: 14px;
    transition: background .15s, color .15s;
}
.top-nav-link:hover { background: var(--bg-elev-2); color: var(--text); }
.top-nav-link.active { background: var(--brand-50); color: var(--brand-700); }
.admin-entry { border: 1px solid var(--border); }
.top-nav-right {
    display: flex; gap: 8px; align-items: center;
}
.mode-switch {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0;
    border: 1px solid var(--border); border-radius: var(--r-full);
    background: var(--bg-elev-2); color: var(--text-soft);
    font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.mode-switch[aria-pressed="true"] { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.mode-switch:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.top-nav-search {
    flex: 1;
    max-width: 420px;
    position: relative;
    min-width: 0;
}
.top-nav-search .input {
    padding-inline-start: 40px;
    background: var(--bg-elev-2);
    border-color: transparent;
    font-size: 14px;
    text-align: start;
    unicode-bidi: plaintext;
}
.top-nav-search-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-start: 14px;
    color: var(--text-mute);
    opacity: .6;
    pointer-events: none;
}
.account-menu { display: block; position: relative; }
[dir="rtl"] .top-nav-right .account-menu { order: 1; }
.account-menu-trigger {
    user-select: none;
}
.account-menu-trigger[aria-expanded="true"] { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.account-profile-pill {
    min-width: 0;
    height: 38px;
    padding: 4px 12px 4px 5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    direction: ltr;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-full);
    background: var(--bg-elev);
    color: var(--text);
    text-decoration: none;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.account-profile-pill:hover { border-color: var(--brand-400); background: var(--bg-elev-2); transform: translateY(-1px); }
.account-profile-pill:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.account-menu-avatar {
    width: 28px;
    height: 28px;
    flex: none;
    display: inline-grid;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--bg-elev-2);
    color: var(--text-soft);
}
.account-menu-avatar-image { width: 100%; height: 100%; display: block; object-fit: cover; }
.account-menu-avatar-emoji { font-size: 21px; line-height: 1; }
.account-menu-avatar-fallback { display: inline-grid; place-items: center; }
.account-menu-name {
    max-width: 118px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 800;
}
.account-menu-popover {
    display: grid;
    gap: 4px;
    min-width: 196px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-elev);
    box-shadow: var(--shadow-lg);
}
.account-menu-label { color: var(--text-mute); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.account-menu-phone { font-size: 15px; font-weight: 800; letter-spacing: .01em; }
.account-menu-logout { width: 100%; margin-top: 6px; }

/* ─── Student profile dashboard ────────────────────────────────── */
.profile-page { max-width: 1120px; padding-bottom: 56px; }
.profile-dashboard { display: grid; gap: 28px; }
.profile-loading { min-height: 58vh; }
.profile-hero {
    display: grid;
    gap: 30px;
    margin-top: 28px;
    padding: 38px 42px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 30px;
    background:
        radial-gradient(circle at 8% 0%, color-mix(in oklab, var(--brand-300) 16%, transparent), transparent 31%),
        var(--bg-elev);
    box-shadow: var(--shadow);
}
.profile-identity {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 42px;
    align-items: center;
}
.profile-identity-copy { min-width: 0; text-align: start; }
.profile-verified-phone { margin: 10px 0 0; color: var(--text-soft); font-size: 17px; font-weight: 800; }
/* `.phone-ltr` keeps the number LTR; realign it to the page's start edge so it
   sits with the name and verified note instead of drifting to the left. */
[dir="rtl"] .profile-verified-phone { text-align: right; }
.profile-private-note {
    margin: 10px 0 0;
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-mute);
    font-size: 13px;
    font-weight: 650;
}
.profile-avatar-wrap {
    position: relative;
    width: 188px;
    height: 188px;
}
.profile-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--bg-elev);
    background: var(--bg-elev-2);
    color: var(--text-mute);
    box-shadow: 0 0 0 2px var(--brand-300), 0 18px 44px rgba(15, 23, 42, .18);
}
.profile-avatar-preset {
    border-color: var(--bg-elev);
    background: var(--bg-elev-2);
    font-size: 126px;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--brand-300), 0 18px 44px rgba(15, 23, 42, .18);
}
.profile-avatar-edit {
    position: absolute;
    inset-inline-end: 0;
    bottom: 1px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--bg);
    border-radius: 13px;
    background: var(--brand-600);
    color: var(--on-brand);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .18s ease, background .18s ease;
}
.profile-avatar-edit:hover { transform: translateY(-2px) scale(1.04); background: var(--brand-700); }
.profile-avatar-edit:disabled { cursor: wait; opacity: .7; }
.profile-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.profile-name {
    margin: 0;
    max-width: 100%;
    font-family: var(--font-display);
    font-size: clamp(34px, 5vw, 52px);
    line-height: 1.2;
    overflow-wrap: anywhere;
}
.profile-name-row { display: flex; align-items: center; justify-content: flex-start; gap: 12px; max-width: 100%; }
.profile-name-edit {
    width: 38px;
    height: 38px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-elev);
    color: var(--text-mute);
    cursor: pointer;
}
.profile-name-edit:hover { border-color: var(--brand-300); color: var(--brand-700); }
.profile-name-form { width: min(100%, 460px); display: grid; gap: 10px; }
.profile-name-input { text-align: start; font-size: 20px; font-weight: 800; }
.profile-name-actions { display: flex; justify-content: flex-start; gap: 8px; }
.profile-name-error { margin: 0; color: var(--bad); font-size: 13px; font-weight: 700; }
.profile-picture-hint { margin: 10px 0 0; color: var(--text-mute); font-size: 14px; }
.profile-upload-error { margin: 10px 0 0; color: var(--bad); font-weight: 700; font-size: 13px; }
.profile-progress-banner {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient(110deg, var(--brand-50), var(--bg-elev-2));
}
.profile-progress-banner-copy { min-width: 0; display: flex; align-items: center; gap: 14px; }
.profile-progress-banner-icon,
.profile-stat-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-500);
    color: var(--on-brand);
}
.profile-progress-banner-icon { width: 46px; height: 46px; border-radius: 15px; }
.profile-progress-banner strong { display: block; font-size: 17px; }
.profile-progress-banner p { margin: 3px 0 0; color: var(--text-mute); font-size: 13px; }
.profile-statistics { display: grid; gap: 16px; }
.profile-statistics-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.profile-statistics-heading h2 { margin: 0; font-family: var(--font-display); font-size: 25px; }
.profile-statistics-heading > span { color: var(--text-mute); font-weight: 900; }
.profile-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.profile-stat-card {
    min-width: 0;
    display: grid;
    grid-template-columns: 42px 1fr;
    grid-template-rows: auto auto;
    gap: 3px 12px;
    align-items: center;
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg-elev);
}
.profile-stat-icon { width: 42px; height: 42px; grid-row: 1 / 3; border-radius: 13px; }
.profile-stat-card strong { font-size: 22px; line-height: 1; }
.profile-stat-card > span:last-child { overflow-wrap: anywhere; color: var(--text-mute); font-size: 12px; font-weight: 700; }
.profile-enrollments {
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 26px;
    background: var(--bg-elev);
    box-shadow: var(--shadow-xs);
}
.profile-section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}
.profile-section-kicker { color: var(--brand-600); font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.profile-section-heading h2 { margin: 4px 0 0; font-family: var(--font-display); font-size: 24px; }
.profile-subject-count {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 900;
}
.profile-subject-list { display: grid; gap: 12px; }
.profile-subject-card {
    display: block;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg);
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.profile-subject-card:hover { transform: translateY(-2px); border-color: var(--brand-300); box-shadow: var(--shadow); }
.profile-subject-top { display: flex; align-items: center; gap: 14px; }
.profile-subject-icon {
    width: 44px;
    height: 44px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: var(--brand-50);
    color: var(--brand-700);
}
.profile-subject-copy { flex: 1; min-width: 0; }
.profile-subject-copy h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.profile-subject-copy p { margin: 4px 0 0; color: var(--text-mute); font-size: 13px; }
.profile-progress-number { flex: none; color: var(--brand-700); font-size: 17px; }
.profile-progress-track { height: 8px; margin-top: 15px; overflow: hidden; border-radius: 999px; background: var(--bg-elev-2); }
.profile-progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-500), var(--brand-700)); transition: width .35s ease; }
.profile-empty { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.profile-empty p { margin: 0; }
.profile-actions { display: flex; justify-content: center; padding: 24px 0 0; }
.profile-error { margin-top: 80px; }
.loader-small { width: 18px; height: 18px; border-width: 2px; }

.profile-avatar-backdrop { position: fixed; inset: 0; z-index: 3100; background: rgba(3, 5, 10, .76); backdrop-filter: blur(8px); }
.profile-avatar-viewport { position: fixed; inset: 0; z-index: 3101; display: grid; place-items: center; padding: 20px; }
.profile-avatar-dialog {
    width: min(100%, 470px);
    max-height: min(760px, calc(100dvh - 32px));
    overflow: auto;
    padding: 24px;
    border: 1px solid var(--border-strong);
    border-radius: 28px;
    background: var(--bg-elev);
    color: var(--text);
    box-shadow: var(--shadow-pop);
}
.profile-avatar-dialog-head { position: relative; min-height: 38px; display: grid; place-items: center; }
.profile-avatar-title { margin: 0; padding-inline: 42px; text-align: center; font: 900 26px/1.3 var(--font-display); }
.profile-avatar-close {
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-mute);
    cursor: pointer;
}
.profile-avatar-close:hover { background: var(--bg-elev-2); color: var(--text); }
.profile-avatar-preview { width: 166px; height: 166px; margin: 18px auto 12px; }
.profile-avatar-preview .profile-avatar { width: 100%; height: 100%; }
.profile-avatar-preview .profile-avatar-preset { font-size: 112px; }
.profile-avatar-subtitle { margin: 0 0 14px; font-size: 16px; font-weight: 900; }
.profile-avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.profile-avatar-option {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 2px solid transparent;
    border-radius: 17px;
    background: var(--bg-elev-2);
    font: inherit;
    font-size: 35px;
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.profile-avatar-option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--border-strong); }
.profile-avatar-option.selected { border-color: var(--brand-500); background: var(--brand-50); box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--brand-500); }
.profile-avatar-option-blobatar { width: 72%; height: 72%; display: block; }
.profile-avatar-dialog .profile-upload-error { text-align: center; }
.profile-avatar-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.profile-avatar-dialog-actions .btn { min-height: 48px; }

@media (max-width: 760px) {
    .profile-page { padding-inline: 14px; }
    .profile-dashboard { gap: 22px; }
    .profile-hero { margin-top: 16px; padding: 28px 18px 20px; border-radius: 24px; }
    .profile-identity { grid-template-columns: 1fr; justify-items: center; gap: 20px; }
    .profile-identity-copy { text-align: center; }
    .profile-avatar-wrap { width: 156px; height: 156px; }
    .profile-avatar-preset { font-size: 105px; }
    .profile-name-row, .profile-name-actions { justify-content: center; }
    .profile-name-input { text-align: center; }
    .profile-private-note { justify-content: center; }
    .profile-progress-banner { align-items: stretch; flex-direction: column; }
    .profile-progress-banner .btn { width: 100%; }
    .profile-stat-grid { grid-template-columns: 1fr 1fr; }
    .profile-enrollments { padding: 18px 14px; border-radius: 20px; }
    .profile-subject-card { padding: 14px; }
    .profile-subject-icon { width: 40px; height: 40px; }
    .profile-progress-number { font-size: 15px; }
    .profile-avatar-dialog { padding: 20px 16px; border-radius: 24px; }
    .profile-avatar-title { font-size: 23px; }
    .profile-avatar-grid { grid-template-columns: repeat(4, 1fr); }
    .profile-avatar-dialog-actions { grid-template-columns: 1fr; }
}
.phone-ltr {
    direction: ltr;
    unicode-bidi: isolate;
    font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
    .top-nav-inner {
        display: flex; flex-wrap: wrap; align-items: center;
        justify-content: space-between;
        gap: 8px 10px; padding: 10px 14px;
    }
    .top-nav-search { display: none; }
    /* Keep the admin Creator/Moderator tabs reachable — wrap to a 2nd row */
    .top-nav-links { order: 3; width: 100%; justify-content: center; gap: 4px; }
    .top-nav-link { padding: 7px 13px; font-size: 13px; }
    .account-profile-pill { max-width: 142px; }
    .account-menu-name { max-width: 92px; font-size: 13px; }
}

/* Mobile drawer toggle */
.nav-toggle { display: none; }
@media (max-width: 720px) {
    .nav-toggle { display: inline-flex; }
}

/* ─── Page layout containers ────────────────────────────────────── */
.page-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 20px 80px;
}
.page-head { margin-bottom: 24px; }
.page-title {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.02em;
}
.muted { color: var(--text-mute); }
.muted.small { font-size: 13px; }
.muted.xsmall { font-size: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; align-items: center; }
.row.gap-2 { gap: 8px; }
.row.gap-3 { gap: 12px; }
.row.gap-4 { gap: 16px; }

.bg-grain { background: var(--bg); }

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .08s;
    white-space: nowrap;
}
.btn:hover:not(:disabled) {
    background: var(--bg-elev-2);
    border-color: var(--border-strong);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
    background: var(--brand-500);
    color: var(--on-brand);
    border-color: var(--brand-500);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) {
    background: var(--brand-600);
    border-color: var(--brand-600);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-elev-2); border-color: transparent; }

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

.btn-lg  { padding: 14px 22px; font-size: 15px; border-radius: var(--r-lg); }
.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-glass {
    background: rgba(255,255,255,.18);
    color: white;
    border-color: rgba(255,255,255,.3);
    backdrop-filter: blur(8px);
}
.btn-glass:hover { background: rgba(255,255,255,.28); }
.btn-glass-danger {
    background: rgba(220, 38, 38, .85);
    color: white;
    border-color: transparent;
}
.btn-glass-danger:hover { background: rgba(220, 38, 38, 1); }

.icon-btn {
    width: 38px; height: 38px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    border-radius: var(--r-full);
    color: var(--text-soft);
    cursor: pointer;
    font-size: 16px;
}
.icon-btn:hover { background: var(--bg-elev-2); color: var(--text); }

.student-greeting {
    position: relative;
    isolation: isolate;
    margin: 0 0 18px;
    padding: 10px 0;
    display: block;
    overflow: hidden;
    border: 0;
    background: transparent;
    color: var(--text);
    box-shadow: none;
}
.student-greeting-copy { min-width: 0; }
.student-greeting-copy h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 22px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}
.student-greeting-text { min-width: 0; }
.student-greeting-emoji {
    display: inline-flex;
    flex: none;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 38px;
    line-height: 1;
    filter: drop-shadow(0 8px 13px rgba(15, 23, 42, .25));
    transform-origin: 72% 78%;
    animation: student-greeting-wave 1.8s ease-in-out infinite;
}
.student-greeting.returning .student-greeting-emoji {
    transform-origin: 50% 50%;
    animation-name: student-greeting-float;
}
@keyframes student-greeting-wave {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    18% { transform: rotate(18deg) translateY(-4px); }
    38% { transform: rotate(-8deg) translateY(0); }
    58% { transform: rotate(18deg) translateY(-4px); }
    78% { transform: rotate(0deg) translateY(0); }
}
@keyframes student-greeting-float {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    50% { transform: translateY(-8px) rotate(8deg) scale(1.08); }
}
.profile-setup-modal { overflow: hidden; }
.profile-setup-visual {
    position: relative;
    width: 92px;
    height: 92px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    border-radius: 30px;
    background: linear-gradient(145deg, rgba(59, 130, 246, .2), rgba(124, 58, 237, .22));
    font-size: 42px;
}
.profile-setup-visual i {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-400);
}
.profile-setup-visual i:nth-of-type(1) { top: 12px; inset-inline-end: 9px; }
.profile-setup-visual i:nth-of-type(2) { bottom: 17px; inset-inline-start: 5px; width: 5px; height: 5px; }
.profile-setup-visual i:nth-of-type(3) { bottom: 7px; inset-inline-end: 19px; width: 4px; height: 4px; }
.profile-setup-error { margin: 0 0 10px; color: var(--bad); font-size: 13px; }
@media (max-width: 720px) {
    .student-greeting { padding: 8px 0; }
    .student-greeting-copy h2 { gap: 12px; font-size: 22px; }
    .student-greeting-emoji { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
    .student-greeting-emoji { animation: none; }
}

/* ─── Inputs ────────────────────────────────────────────────────── */
.input, .textarea, .select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-elev);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font: inherit;
    font-size: 14.5px;
    transition: border-color .12s, box-shadow .12s;
}
/* Native number-input spinners render dark-on-dark in the dark theme (the
   invisible up/down arrows). WebKit won't let us recolor them, so hide them —
   the field still accepts typed numbers and ↑/↓ arrow keys. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.input:focus, .textarea:focus, .select:focus {
    outline: 0;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.field { margin-bottom: 14px; }
.label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-soft);
    font-size: 13px;
}
.section-h {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 24px 0 12px;
}

/* Phone with prefix */
.phone-prefix {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 14px;
    background: var(--bg-elev-2);
    border: 1.5px solid var(--border);
    border-inline-end: 0;
    border-radius: var(--r-md) 0 0 var(--r-md);
    font-weight: 700;
    color: var(--text-soft);
    font-size: 14.5px;
}
.phone-input {
    border-radius: 0 var(--r-md) var(--r-md) 0;
}

/* OTP cells */
.otp-cell {
    text-align: center;
    font-size: 22px !important;
    font-weight: 800 !important;
    width: 46px !important;
    padding: 10px 0 !important;
}

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-xs);
}
.card-tight { padding: 14px 16px; }
.row-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-xs);
    transition: border-color .12s;
}
.row-card:hover { border-color: var(--border-strong); }
.row-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.row-card-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.row-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ─── Pills ─────────────────────────────────────────────────────── */
.pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    background: var(--bg-elev-2);
    color: var(--text-soft);
    border-radius: var(--r-full);
    font-size: 12px;
    font-weight: 600;
}
.pill.brand { background: var(--brand-50); color: var(--brand-700); }
.pill.bad   { background: var(--bad-bg); color: var(--bad); }
.pill.warn  { background: var(--warn-bg); color: var(--warn); }
.pill.gold  { background: rgba(234, 151, 18, .12); color: var(--gold); }
.pill.coral { background: var(--bad-bg); color: var(--bad); }
.pill.baims { background: rgba(37, 99, 235, .12); color: #1d4ed8; }
[data-theme="dark"] .pill.baims { background: rgba(96, 165, 250, .18); color: #93c5fd; }

/* ─── Baims subscriber gate ─────────────────────────────────────── */
.baims-lock { display: flex; flex-direction: column; gap: 18px; }
.baims-lock-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-inline-end: 34px;
}
.baims-lock-icon {
    width: 46px; height: 46px; flex: none;
    display: grid; place-items: center;
    border-radius: 14px;
    background: color-mix(in oklab, var(--bad) 12%, var(--bg-elev));
    color: var(--bad);
}
.baims-lock-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: -.01em;
    color: var(--text);
}
.baims-lock-body {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev-2);
    line-height: 1.95;
    color: var(--text-soft);
}
.baims-link { color: var(--brand-700); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.baims-lock-actions { display: grid; gap: 10px; }
.baims-lock-action { width: 100%; min-height: 50px; font-size: 15px; }
.baims-open-btn {
    background: #38bdf8;
    border-color: #38bdf8;
    color: #fff;
    font-weight: 800;
}
.baims-open-btn:hover:not(:disabled) { background: #0ea5e9; border-color: #0ea5e9; color: #fff; }
.baims-open-logo { width: 20px; height: 20px; flex: none; object-fit: contain; }
.baims-whatsapp-btn { background: #25d366; border-color: #25d366; color: #fff; }
.baims-whatsapp-btn:hover:not(:disabled) { background: #1ebe5b; border-color: #1ebe5b; }
.baims-book-btn { background: #0ea5e9; border-color: #0ea5e9; color: #082f49; }
.baims-book-btn:hover:not(:disabled) { background: #0284c7; border-color: #0284c7; }
[data-theme="dark"] .baims-book-btn { background: #38bdf8; border-color: #38bdf8; }
[data-theme="dark"] .baims-book-btn:hover:not(:disabled) { background: #0ea5e9; border-color: #0ea5e9; }
.baims-lock-modal { max-width: 460px; }
.btn-baims { background: rgba(37, 99, 235, .1); border-color: rgba(37, 99, 235, .35); color: #1d4ed8; }
.btn-baims:hover:not(:disabled) { background: rgba(37, 99, 235, .18); border-color: rgba(37, 99, 235, .55); }
[data-theme="dark"] .btn-baims { background: rgba(96, 165, 250, .16); border-color: rgba(96, 165, 250, .4); color: #93c5fd; }
[data-theme="dark"] .btn-baims:hover:not(:disabled) { background: rgba(96, 165, 250, .24); border-color: rgba(96, 165, 250, .6); }
.chapter-card.locked { cursor: pointer; }

/* ─── Empty state ───────────────────────────────────────────────── */
.empty {
    padding: 60px 24px;
    text-align: center;
    color: var(--text-mute);
}
.empty p { margin: 0 0 6px; }

/* ─── Tabs ──────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}
.tab-btn {
    padding: 12px 18px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    color: var(--text-mute);
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand-700); border-bottom-color: var(--brand-500); }

/* ─── Toolbar (search + action) ─────────────────────────────────── */
.toolbar {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    margin-bottom: 8px;
}
.toolbar .input { flex: 1; min-width: 200px; }

/* ─── Modals ────────────────────────────────────────────────────── */
.modal-back {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .55);
    display: none;
    place-items: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}
.modal-back.open { display: grid; }
.modal {
    background: var(--bg-elev);
    border-radius: var(--r-xl);
    padding: 28px;
    max-width: 460px;
    width: 100%;
    box-shadow: var(--shadow-pop);
    position: relative;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.modal-md { max-width: 580px; }
.modal-lg { max-width: 760px; }
@media (max-width: 600px) {
    .modal-back { padding: 0; align-items: flex-end; }
    .modal {
        padding: 20px 16px;
        border-radius: var(--r-xl) var(--r-xl) 0 0;
        max-height: 92vh;
        max-width: none;
    }
    .modal-md, .modal-lg { max-width: none; }
}
.modal-title {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.01em;
}
.modal-sub {
    margin: 0 0 20px;
    color: var(--text-mute);
    font-size: 14px;
}
.modal-close {
    position: absolute;
    top: 16px; inset-inline-end: 16px;
    width: 32px; height: 32px;
    display: grid; place-items: center;
    background: transparent;
    border: 0;
    border-radius: var(--r-full);
    cursor: pointer;
    color: var(--text-mute);
    font-size: 16px;
}
.modal-close:hover { background: var(--bg-elev-2); }

/* ─── Confirm dialog (replaces window.confirm) ──────────────────── */
.confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: rgba(9, 9, 11, .58);
    backdrop-filter: blur(6px);
}
.confirm-viewport {
    position: fixed;
    inset: 0;
    z-index: 4001;
    display: grid;
    place-items: center;
    padding: 20px;
}
.confirm-dialog { width: 100%; max-width: 420px; }
.confirm-message { overflow-wrap: anywhere; }
.confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}
.confirm-actions .btn { min-height: 46px; }
@media (max-width: 600px) {
    .confirm-viewport { padding: 0; align-items: end; }
    .confirm-dialog { max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; }
}

.course-autocomplete {
    position: relative;
}
.doctor-autocomplete {
    position: relative;
}
.doctor-autocomplete-control {
    position: relative;
}
.doctor-autocomplete-control .input {
    min-height: 46px;
    padding-inline: 42px 40px;
}
.doctor-autocomplete-icon,
.doctor-autocomplete-chevron {
    position: absolute;
    z-index: 1;
    top: 50%;
    color: var(--text-mute);
    pointer-events: none;
    transform: translateY(-50%);
}
.doctor-autocomplete-icon { inset-inline-start: 14px; }
.doctor-autocomplete-chevron {
    inset-inline-end: 14px;
    transition: transform .16s ease;
}
.doctor-autocomplete.open .doctor-autocomplete-chevron {
    transform: translateY(-50%) rotate(180deg);
}
.doctor-autocomplete:focus-within .doctor-autocomplete-icon {
    color: var(--brand-700);
}
.doctor-autocomplete-hint {
    margin: 7px 0 0;
    line-height: 1.55;
}
.course-autocomplete-hint {
    margin: 6px 0 0;
}
.course-suggestions {
    position: absolute;
    z-index: 20;
    inset-inline: 0;
    top: calc(100% + 6px);
    max-height: min(320px, 42vh);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev);
    box-shadow: var(--shadow-pop);
}
.doctor-suggestions {
    position: absolute;
    z-index: 20;
    inset-inline: 0;
    top: calc(100% + 6px);
    max-height: min(320px, 42vh);
    overflow-y: auto;
    padding: 7px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--bg-elev);
    box-shadow: var(--shadow-pop);
}
.doctor-suggestions-title {
    padding: 5px 9px 7px;
    color: var(--text-mute);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.course-suggestion {
    width: 100%;
    min-height: 54px;
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    grid-template-areas:
        "code name"
        "code alt";
    align-items: center;
    gap: 2px 12px;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text);
    text-align: start;
    cursor: pointer;
}
.course-suggestion:hover,
.course-suggestion.active {
    background: var(--brand-50);
}
.doctor-suggestion {
    width: 100%;
    min-height: 46px;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: background-color .12s, border-color .12s;
}
.doctor-suggestion:hover,
.doctor-suggestion.active {
    background: var(--brand-50);
    border-color: var(--brand-100);
}
.doctor-suggestion-avatar {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--bg-elev-2);
    color: var(--text-soft);
}
.doctor-suggestion.active .doctor-suggestion-avatar {
    background: var(--brand-100);
    color: var(--brand-700);
}
.doctor-suggestion-name {
    min-width: 0;
    overflow: hidden;
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doctor-suggestion-check {
    color: var(--brand-700);
}
.doctor-suggestions-empty {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    color: var(--text-mute);
    font-size: 13px;
}
.course-suggestion-code {
    grid-area: code;
    color: var(--brand-700);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    font-weight: 800;
    text-align: left;
}
.course-suggestion-name {
    grid-area: name;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
}
.course-suggestion-alt {
    grid-area: alt;
    min-width: 0;
    color: var(--text-mute);
    font-size: 12px;
}
@media (max-width: 600px) {
    .course-suggestion {
        grid-template-columns: 78px minmax(0, 1fr);
        gap: 2px 8px;
    }
}

/* ─── Toasts ────────────────────────────────────────────────────── */
.alnajdi-toaster {
    font-family: inherit;
}
.alnajdi-toast {
    border-color: var(--border) !important;
    border-radius: var(--r-md) !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: inherit !important;
    font-weight: 600 !important;
}

/* ─── First-account tutorial ──────────────────────────────────── */
.tutorial-backdrop {
    position: fixed;
    inset: 0;
    min-height: 100dvh;
    z-index: 1100;
    background: rgba(9, 9, 11, .58);
    backdrop-filter: blur(6px);
    transition: opacity .18s ease;
}
.tutorial-backdrop[data-starting-style],
.tutorial-backdrop[data-ending-style] { opacity: 0; }
.tutorial-viewport {
    position: fixed;
    inset: 0;
    z-index: 1101;
    display: grid;
    place-items: center;
    overflow-y: auto;
    padding: 24px;
}
.tutorial-popup {
    --tutorial-accent: var(--brand-500);
    width: min(100%, 520px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: var(--bg-elev);
    box-shadow: var(--shadow-pop);
    color: var(--text);
    transition: opacity .18s ease, transform .18s ease;
}
.tutorial-popup[data-starting-style],
.tutorial-popup[data-ending-style] { opacity: 0; transform: translateY(10px) scale(.985); }
.tutorial-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 14px;
}
.tutorial-head > div { min-width: 0; flex: 1 1 180px; }
.tutorial-kicker,
.tutorial-step { display: block; }
.tutorial-kicker {
    color: color-mix(in oklab, var(--tutorial-accent) 82%, var(--text));
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.tutorial-step { margin-top: 3px; color: var(--text-mute); font-size: 12px; font-weight: 700; }
.tutorial-skip {
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--r-full);
    background: transparent;
    color: color-mix(in oklab, var(--tutorial-accent) 82%, var(--text));
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
}
.tutorial-skip:hover:not(:disabled) { background: var(--bg-elev-2); }
.tutorial-visual {
    position: relative;
    height: 220px;
    margin: 0 24px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 24px;
    background:
        radial-gradient(circle at 16% 12%, color-mix(in oklab, var(--tutorial-accent) 18%, transparent), transparent 34%),
        repeating-linear-gradient(90deg, transparent 0 26px, color-mix(in oklab, var(--border) 48%, transparent) 27px),
        var(--bg-elev-2);
}
.tutorial-visual::after {
    content: "";
    position: absolute;
    width: 150px;
    height: 150px;
    inset-inline-end: -55px;
    bottom: -75px;
    border-radius: 50%;
    background: color-mix(in oklab, var(--tutorial-accent) 12%, transparent);
}
.tutorial-visual-number {
    position: absolute;
    top: 10px;
    inset-inline-start: 16px;
    color: color-mix(in oklab, var(--tutorial-accent) 42%, transparent);
    font: 900 64px/1 var(--font-display);
    letter-spacing: -.08em;
}
.tutorial-mini-card {
    position: relative;
    z-index: 1;
    width: min(76%, 340px);
    display: grid;
    grid-template-columns: 58px 1fr 34px;
    gap: 12px;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-elev);
    box-shadow: var(--shadow-lg);
    transform: rotate(-1.5deg);
}
.tutorial-visual-chapter .tutorial-mini-card { transform: rotate(1.5deg); }
.tutorial-visual-question .tutorial-mini-card { transform: none; }
.tutorial-icon-tile {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    grid-row: span 2;
    border-radius: 17px;
    background: var(--tutorial-accent);
    color: white;
}
.tutorial-mini-copy { display: grid; gap: 9px; }
.tutorial-mini-copy i,
.tutorial-mini-row b {
    display: block;
    width: 54%;
    height: 7px;
    border-radius: var(--r-full);
    background: var(--text-mute);
    opacity: .5;
}
.tutorial-mini-copy i.wide { width: 82%; background: var(--text); opacity: .72; }
.tutorial-mini-check {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: color-mix(in oklab, var(--tutorial-accent) 14%, var(--bg-elev));
    color: var(--tutorial-accent);
}
.tutorial-mini-row {
    grid-column: 1 / -1;
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elev-2);
}
.tutorial-mini-row i {
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-mute);
    border-radius: 50%;
}
.tutorial-mini-row.selected { border-color: var(--tutorial-accent); background: color-mix(in oklab, var(--tutorial-accent) 9%, var(--bg-elev)); }
.tutorial-mini-row.selected i { border-color: var(--tutorial-accent); background: var(--tutorial-accent); }
.tutorial-mini-row:nth-last-child(1) b { width: 43%; }
.tutorial-copy { padding: 22px 28px 6px; text-align: center; }
.tutorial-title {
    margin: 0;
    outline: none;
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 900;
    line-height: 1.25;
    letter-spacing: -.025em;
}
.tutorial-description {
    max-width: 430px;
    margin: 9px auto 0;
    color: var(--text-mute);
    font-size: 16px;
    line-height: 1.65;
}
.tutorial-error { margin: 10px 24px 0; color: var(--bad); font-size: 13px; font-weight: 700; text-align: center; }
.tutorial-dots { min-height: 28px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.tutorial-dots span { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--border-strong); transition: width .16s ease, background .16s ease; }
.tutorial-dots span.active { width: 24px; background: var(--tutorial-accent); }
.tutorial-actions {
    display: grid;
    grid-template-columns: minmax(100px, auto) minmax(150px, 1fr);
    gap: 10px;
    padding: 16px 24px 22px;
    border-top: 1px solid var(--border);
}
.tutorial-actions .btn { min-height: 48px; }
.feature-tour-shade {
    position: fixed;
    z-index: 2000;
    background: rgba(7, 8, 11, .72);
    backdrop-filter: blur(3px);
    pointer-events: auto;
    transition:
        top .42s cubic-bezier(.22, 1, .36, 1),
        right .42s cubic-bezier(.22, 1, .36, 1),
        bottom .42s cubic-bezier(.22, 1, .36, 1),
        left .42s cubic-bezier(.22, 1, .36, 1),
        width .42s cubic-bezier(.22, 1, .36, 1),
        height .42s cubic-bezier(.22, 1, .36, 1);
}
.feature-tour-target-blocker,
.feature-tour-focus-ring {
    position: fixed;
    border-radius: 15px;
}
.feature-tour-target-blocker {
    z-index: 2001;
    background: transparent;
    cursor: default;
}
.feature-tour-focus-ring {
    z-index: 2002;
    border: 2px solid var(--tour-accent);
    box-shadow:
        0 0 0 5px color-mix(in oklab, var(--tour-accent) 28%, transparent),
        0 10px 32px rgba(0, 0, 0, .28);
    pointer-events: none;
    animation: feature-tour-pulse 1.5s ease-in-out infinite;
    transition:
        top .42s cubic-bezier(.22, 1, .36, 1),
        left .42s cubic-bezier(.22, 1, .36, 1),
        width .42s cubic-bezier(.22, 1, .36, 1),
        height .42s cubic-bezier(.22, 1, .36, 1),
        opacity .24s ease,
        transform .24s ease;
}
.feature-tour-focus-ring.transitioning {
    opacity: 0;
    transform: scale(.97);
    animation: none;
}
.feature-tour-popup {
    position: fixed;
    z-index: 2004;
    overflow: visible;
    padding: 18px;
    border: 1px solid color-mix(in oklab, var(--tour-accent) 34%, var(--border));
    border-radius: 22px;
    background: var(--bg-elev);
    box-shadow: var(--shadow-pop);
    color: var(--text);
    outline: none;
    transition: opacity .32s cubic-bezier(.22, 1, .36, 1), transform .32s cubic-bezier(.22, 1, .36, 1);
}
.feature-tour-popup[data-starting-style],
.feature-tour-popup[data-ending-style] { opacity: 0; transform: translateY(7px) scale(.985); }
.feature-tour-popup.transitioning {
    opacity: 0;
    transform: translateY(8px) scale(.985);
    pointer-events: none;
}
.feature-tour-popup::before {
    content: "";
    position: absolute;
    left: var(--tour-arrow-x);
    width: 16px;
    height: 16px;
    border-inline-start: 1px solid color-mix(in oklab, var(--tour-accent) 34%, var(--border));
    border-block-start: 1px solid color-mix(in oklab, var(--tour-accent) 34%, var(--border));
    background: var(--bg-elev);
}
.feature-tour-popup[data-placement="below"]::before {
    top: -9px;
    transform: translateX(-50%) rotate(45deg);
}
.feature-tour-popup[data-placement="above"]::before {
    bottom: -9px;
    transform: translateX(-50%) rotate(225deg);
}
.feature-tour-head {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 11px;
    align-items: center;
}
.feature-tour-head > div { min-width: 0; }
.feature-tour-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: color-mix(in oklab, var(--tour-accent) 14%, var(--bg-elev));
    color: var(--tour-accent);
}
.feature-tour-head .tutorial-skip { align-self: start; color: var(--tour-accent); }
.feature-tour-title {
    margin: 18px 0 0;
    outline: none;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 900;
    line-height: 1.28;
    letter-spacing: -.02em;
}
.feature-tour-description {
    margin: 8px 0 0;
    color: var(--text-mute);
    font-size: 14px;
    line-height: 1.65;
}
.feature-tour-actions {
    display: grid;
    grid-template-columns: minmax(86px, auto) minmax(128px, 1fr);
    gap: 9px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.feature-tour-actions .btn { min-height: 44px; }
@keyframes feature-tour-pulse {
    0%, 100% { box-shadow: 0 0 0 4px color-mix(in oklab, var(--tour-accent) 22%, transparent), 0 10px 32px rgba(0, 0, 0, .24); }
    50% { box-shadow: 0 0 0 9px color-mix(in oklab, var(--tour-accent) 7%, transparent), 0 10px 32px rgba(0, 0, 0, .32); }
}
@media (max-width: 600px) {
    .tutorial-viewport { padding: 12px; align-items: center; }
    .tutorial-popup { max-height: calc(100dvh - 24px); overflow-y: auto; border-radius: 26px; }
    .tutorial-head { padding: 18px 18px 12px; }
    .tutorial-visual { height: 205px; margin: 0 18px; }
    .tutorial-mini-card { width: 86%; grid-template-columns: 50px 1fr 30px; padding: 13px; }
    .tutorial-icon-tile { width: 50px; height: 50px; }
    .tutorial-copy { padding: 20px 20px 4px; }
    .tutorial-title { font-size: 24px; }
    .tutorial-description { font-size: 15px; }
    .tutorial-actions { padding: 14px 18px 18px; }
    .feature-tour-popup { padding: 16px; border-radius: 19px; }
    .feature-tour-title { margin-top: 15px; font-size: 20px; }
    .feature-tour-description { font-size: 13.5px; }
    .feature-tour-actions { margin-top: 15px; }
}
@media (prefers-reduced-motion: reduce) {
    .feature-tour-shade,
    .feature-tour-focus-ring,
    .feature-tour-popup { transition: none; }
    .feature-tour-focus-ring { animation: none; }
}

/* lucide-animated renders a wrapper so its Motion transforms remain isolated. */
.animated-icon { display: inline-flex; align-items: center; justify-content: center; }

/* ─── Loader ────────────────────────────────────────────────────── */
.loader {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2.5px solid color-mix(in srgb, currentColor 28%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}
.btn:not(.btn-primary) .loader {
    border-color: rgba(0, 0, 0, .15);
    border-top-color: var(--brand-600);
}
@keyframes spin { to { transform: rotate(360deg); } }

.question-batch-loader {
    display: grid;
    place-items: center;
    min-height: 56px;
    color: var(--text-mute);
}

/* Best-effort deterrent: keep the app out of printed pages and save-as-PDF. */
@media print {
    body { display: none !important; }
}
