/* --- 1. THEME VARIABLES (DARK DEFAULT & CRISP WHITE LIGHT MODE) --- */
:root {
    color-scheme: dark;
    --bg-main: #090d16;
    --bg-surface: rgba(15, 23, 42, 0.94);
    --bg-card: #162032;
    --bg-input: #090d16;
    --border-color: rgba(56, 189, 248, 0.3);
    --border-subtle: #26354d;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-cyan: #38bdf8;
    --accent-green: #10b981;
    --accent-purple: #c084fc;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --grid-line: rgba(56, 189, 248, 0.04);
    --float-color: rgba(56, 189, 248, 0.12);
    --shadow-main: 0 20px 50px rgba(0, 0, 0, 0.5);
    --shadow-card-3d: 0 25px 55px rgba(0, 0, 0, 0.55);
    --shadow-btn-3d: 0 5px 0px rgba(0, 0, 0, 0.25);
}

html.light-theme,
body.light-theme {
    color-scheme: only light;
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #f1f5f9;
    --bg-input: #ffffff;
    --border-color: rgba(2, 132, 199, 0.35);
    --border-subtle: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #475569;
    --accent-cyan: #0284c7;
    --accent-green: #059669;
    --accent-purple: #7e22ce;
    --accent-amber: #d97706;
    --accent-red: #dc2626;
    --grid-line: rgba(2, 132, 199, 0.06);
    --float-color: rgba(2, 132, 199, 0.10);
    --shadow-main: 0 12px 32px rgba(15, 23, 42, 0.07);
    --shadow-card-3d: 0 18px 40px rgba(15, 23, 42, 0.12);
    --shadow-btn-3d: 0 4px 0px #cbd5e1;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

html {
    background-color: var(--bg-main);
    -webkit-text-size-adjust: 100%;
}

body { 
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(6, 182, 212, 0.10) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 45%),
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    color: var(--text-main); 
    min-height: 100vh; 
    overflow-x: hidden; 
    position: relative;
    transition: background-color 0.25s, color 0.25s;
}

body.light-theme {
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.06) 0%, transparent 45%),
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
}

/* Floating Science Elements Layer */
#lab-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none !important; z-index: 0; overflow: hidden;
}
.floating-chem {
    position: absolute; bottom: -80px;
    color: var(--float-color);
    font-weight: 900; user-select: none;
    pointer-events: none !important;
    animation: floatUp linear infinite;
    direction: ltr;
}
@keyframes floatUp {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { transform: translateY(-115vh) rotate(360deg); opacity: 0; }
}

/* Critical Fix: transform: none at 100% prevents WebKit/Blink hit-testing bugs on buttons */
@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.98) translateY(8px); }
    100% { opacity: 1; transform: none; }
}
.screen-animate { animation: fadeInScale 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* --- GLOBAL BUTTON HIT-TESTING & MOBILE TOUCH FIXES --- */
button,
.primary-btn,
.secondary-btn,
.nav-tab,
.sub-pill,
.mc-btn,
.reactor-choice-btn,
.powerup-btn,
.auth-tab,
.pomo-mode-btn,
.tut-btn-next,
.tut-skip-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    cursor: pointer;
}

/* Critical Fix: Prevent inner <span> elements from splitting mousedown/mouseup targets */
button > *,
a.secondary-btn > * {
    pointer-events: none;
}

/* --- BUTTONS --- */
.primary-btn { 
    background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
    color: #022c22; font-size: 18px; font-weight: 900; padding: 15px 32px; 
    border: none; border-radius: 14px; cursor: pointer; 
    letter-spacing: 0.5px;
    box-shadow: 0 4px 0px #059669, 0 8px 18px rgba(16, 185, 129, 0.25); 
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.06); }
.primary-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0px #059669; }
.primary-btn:disabled { background: #64748b; color: #cbd5e1; box-shadow: 0 4px 0px #475569; cursor: not-allowed; }

.secondary-btn {
    background: var(--bg-card); border: 2px solid var(--border-subtle); color: var(--text-main);
    padding: 10px 18px; border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 800; transition: 0.18s;
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.secondary-btn:hover:not(:disabled) { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.secondary-btn:active:not(:disabled) { transform: translateY(1px); }
.secondary-btn.active-filter { background: rgba(56, 189, 248, 0.15); border-color: var(--accent-cyan); color: var(--accent-cyan); }
.danger-btn:hover:not(:disabled) { background: rgba(248, 113, 113, 0.15); color: #ef4444; border-color: #ef4444; }

/* --- PROFESSIONAL LANDING PAGE & ONBOARDING WRAPPER --- */
#Onboarding-wrapper {
    position: relative; z-index: 2; min-height: 100vh;
    display: flex; flex-direction: column; justify-content: space-between; align-items: center;
    padding: 80px 24px 30px; text-align: center;
}
.floating-top-controls {
    position: fixed; top: 16px; inset-inline-end: 24px; z-index: 50;
    display: flex; gap: 10px; flex-wrap: wrap;
    pointer-events: none;
}
.floating-top-controls > * {
    pointer-events: auto;
    box-shadow: var(--shadow-main);
}

/* --- SCREEN 1: PROFESSIONAL SAAS LANDING PAGE --- */
#hero-screen { 
    max-width: 1080px; width: 100%; margin: auto 0;
}
.hero-main-card {
    background: var(--bg-surface); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 2px solid var(--border-color); padding: 55px 45px; border-radius: 30px;
    box-shadow: var(--shadow-main); margin-bottom: 28px; position: relative; overflow: hidden;
}
.lab-badge {
    display: inline-block; background: rgba(6, 182, 212, 0.15); border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan); font-size: 13px; font-weight: 800;
    letter-spacing: 0.5px; padding: 7px 18px; border-radius: 30px; margin-bottom: 18px;
}
#hero-screen h1,
#hero-main-title { 
    font-size: 64px; 
    font-weight: 900; 
    margin-bottom: 12px; 
    line-height: 1.4; 
    padding-bottom: 10px;
    display: block;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.hero-lead {
    font-size: 20px; color: var(--text-muted); max-width: 760px; margin: 0 auto 32px;
    font-weight: 600; line-height: 1.7;
}
.hero-cta-group {
    display: flex; justify-content: center; align-items: center; gap: 16px; flex-wrap: wrap;
}
.hero-trust-strip {
    display: flex; justify-content: center; gap: 28px; flex-wrap: wrap;
    margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border-subtle);
    color: var(--text-muted); font-size: 14px; font-weight: 800;
}
.hero-trust-item { display: flex; align-items: center; gap: 8px; }

/* Landing Page: Goal & Features Grid */
.landing-info-grid {
    display: grid; grid-template-columns: 1.15fr 1.85fr; gap: 24px; margin-bottom: 28px; text-align: start;
}
.goal-card {
    background: var(--bg-surface); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 2px solid var(--accent-cyan); border-radius: 26px; padding: 32px;
    box-shadow: var(--shadow-main); display: flex; flex-direction: column; justify-content: space-between;
    background-image: radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 65%);
}
.goal-card h2 {
    font-size: 24px; font-weight: 900; color: var(--accent-cyan); margin-bottom: 12px;
    display: flex; align-items: center; gap: 10px;
}
.goal-card p {
    font-size: 15.5px; color: var(--text-main); line-height: 1.75; font-weight: 600; margin-bottom: 18px;
}
.goal-highlight-tag {
    background: var(--bg-card); border: 1px solid var(--border-subtle); padding: 12px 16px;
    border-radius: 14px; font-size: 13.5px; font-weight: 800; color: var(--accent-green);
}

.features-showcase-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px;
}
.feature-mini-card {
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 22px; padding: 22px; box-shadow: var(--shadow-main); transition: 0.2s;
}
.feature-mini-card:hover { border-color: var(--accent-cyan); transform: translateY(-3px); }
.feature-mini-card .f-icon {
    font-size: 26px; margin-bottom: 10px; display: inline-block;
    background: var(--bg-card); padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border-subtle);
}
.feature-mini-card h3 { font-size: 17px; font-weight: 900; margin-bottom: 6px; color: var(--text-main); }
.feature-mini-card p { font-size: 13.5px; color: var(--text-muted); font-weight: 600; line-height: 1.55; }

/* --- OFFICIAL FOOTER (LANDING & WORKSPACE) --- */
.site-footer {
    width: 100%; max-width: 1080px; margin: 20px auto 0;
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: 20px; padding: 20px 30px;
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;
    font-size: 14px; color: var(--text-muted); font-weight: 700;
}
.footer-support-link {
    color: var(--accent-cyan); text-decoration: none; font-weight: 900;
    background: rgba(56, 189, 248, 0.12); border: 1px solid var(--accent-cyan);
    padding: 6px 14px; border-radius: 10px; transition: 0.2s; direction: ltr; display: inline-block;
}
.footer-support-link:hover { background: var(--accent-cyan); color: #ffffff; }

/* --- SCREEN 1.5: AUTHENTICATION WALL --- */
#auth-screen { width: 100%; max-width: 500px; margin: auto 0; }
.auth-card {
    background: var(--bg-surface); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 2px solid var(--border-color); padding: 42px 38px; border-radius: 28px;
    box-shadow: var(--shadow-main);
}
.auth-tabs {
    display: flex; background: var(--bg-input); padding: 6px; border-radius: 14px;
    margin-bottom: 24px; border: 2px solid var(--border-subtle);
}
.auth-tab {
    flex: 1; padding: 12px; font-size: 15px; font-weight: 800; color: var(--text-muted);
    background: transparent; border: none; border-radius: 10px; cursor: pointer; transition: 0.2s;
}
.auth-tab.active { background: var(--bg-card); color: var(--accent-cyan); }
.auth-title { font-size: 26px; font-weight: 900; margin-bottom: 8px; }
.auth-subtitle { font-size: 15px; color: var(--text-muted); margin-bottom: 22px; font-weight: 600; }
.auth-field { text-align: start; margin-bottom: 18px; }
.auth-field label { display: block; font-size: 13px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }

/* --- FULL-SCREEN DESKTOP & MOBILE WORKSPACE (LOCKED SINGLE-LINE NAVBAR) --- */
#app-workspace {
    display: none; position: relative; z-index: 2;
    min-height: 100vh; width: 100%; flex-direction: column;
}

.app-navbar {
    width: 100%; background: var(--bg-surface); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-bottom: 2px solid var(--border-subtle); padding: 12px 24px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    flex-wrap: nowrap;
    position: sticky; top: 0; z-index: 20; box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.brand-logo {
    font-size: 22px; font-weight: 900; display: flex; align-items: center; gap: 8px;
    color: var(--accent-cyan); cursor: pointer; user-select: none;
    white-space: nowrap; flex-shrink: 0;
}

.nav-links {
    display: flex; gap: 4px; background: var(--bg-card); padding: 5px;
    border-radius: 14px; border: 1px solid var(--border-subtle);
    flex-wrap: nowrap; justify-content: center; align-items: center;
}
.nav-tab {
    padding: 8px 14px; border-radius: 10px; border: none; background: transparent;
    color: var(--text-muted); font-size: 13.5px; font-weight: 800; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0;
}
.nav-tab:hover { color: var(--text-main); }
.nav-tab.active { background: var(--accent-cyan); color: #022c22; box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3); }
body.light-theme .nav-tab.active { color: #ffffff; }

#nav-pomo-pill {
    display: none; background: rgba(16, 185, 129, 0.15); border: 1px solid var(--accent-green);
    color: var(--accent-green); padding: 6px 12px; border-radius: 20px; font-weight: 900; font-size: 13px;
    cursor: pointer; direction: ltr; white-space: nowrap; flex-shrink: 0;
}
.app-main { flex: 1; width: 100%; max-width: 1340px; margin: 0 auto; padding: 36px 36px 20px; }
.app-section { display: none; width: 100%; }
.app-section.active { display: block; }

/* --- SECTION 1: FULL-PAGE DASHBOARD --- */
.section-header-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 28px; flex-wrap: wrap; gap: 15px;
}
.section-title { font-size: 34px; font-weight: 900; }
.section-subtitle { font-size: 16px; color: var(--text-muted); font-weight: 600; margin-top: 4px; }

.stats-grid-full { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; margin-bottom: 28px; }
.stat-panel {
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 22px; padding: 28px 22px; box-shadow: var(--shadow-main);
    text-align: start; position: relative; overflow: hidden;
}
.stat-panel .stat-icon { font-size: 28px; margin-bottom: 10px; display: inline-block; }
.stat-panel .stat-number { font-size: 44px; font-weight: 900; color: var(--accent-cyan); line-height: 1.1; margin-bottom: 6px; }
.stat-panel .stat-label { font-size: 13.5px; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }

.dashboard-bottom-grid { display: grid; grid-template-columns: 1.8fr 1.2fr; gap: 24px; }
.focus-panel {
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 22px; padding: 30px; box-shadow: var(--shadow-main);
}
.focus-panel h3 { font-size: 20px; font-weight: 900; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.focus-panel p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; font-weight: 600; line-height: 1.6; }
.focus-badges { display: flex; flex-wrap: wrap; gap: 10px; min-height: 48px; align-items: center; }
.focus-badge { background: rgba(248, 113, 113, 0.15); border: 2px solid #f87171; color: #ef4444; padding: 8px 18px; border-radius: 20px; font-size: 16px; font-weight: 800; }

/* --- SECTION 2: STUDY VAULT (TABLES, FLASHCARDS & FORMULA BUILDER) --- */
.sub-nav-pills {
    display: flex; gap: 10px; background: var(--bg-surface); padding: 8px;
    border-radius: 16px; border: 2px solid var(--border-subtle); width: fit-content; flex-wrap: wrap;
}
.sub-pill {
    padding: 10px 20px; border-radius: 11px; border: none; background: transparent;
    color: var(--text-muted); font-size: 15px; font-weight: 800; cursor: pointer; transition: 0.2s;
}
.sub-pill.active { background: var(--accent-cyan); color: #022c22; }
body.light-theme .sub-pill.active { color: #ffffff; }

.table-controls {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    margin-bottom: 24px; flex-wrap: wrap;
}
.search-box { max-width: 380px; width: 100%; }
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }

.tables-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; margin-bottom: 32px; }
.chem-table-card {
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 24px; padding: 28px; box-shadow: var(--shadow-main);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.chem-table-card h3 { font-size: 22px; font-weight: 900; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.chem-table { width: 100%; min-width: 320px; border-collapse: collapse; text-align: start; }
.chem-table th {
    padding: 12px 14px; font-size: 12.5px; font-weight: 800; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border-subtle);
    white-space: nowrap;
}
.chem-table td {
    padding: 14px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--border-subtle);
}
.chem-table tr:last-child td { border-bottom: none; }
.chem-table tr:hover td { background: rgba(56, 189, 248, 0.05); }

.symbol-pill {
    display: inline-block; background: var(--bg-card); border: 1px solid var(--border-subtle);
    padding: 4px 12px; border-radius: 8px; font-weight: 900; color: var(--accent-cyan); min-width: 55px; text-align: center;
    direction: ltr;
}
.valency-badge {
    display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 800; white-space: nowrap;
}
.val-Monovalent { background: rgba(56, 189, 248, 0.15); color: var(--accent-cyan); border: 1px solid var(--accent-cyan); }
.val-Divalent { background: rgba(192, 132, 252, 0.15); color: var(--accent-purple); border: 1px solid var(--accent-purple); }
.val-Trivalent { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid var(--accent-green); }
.val-Tetravalent { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid var(--accent-amber); }
.val-Zero-valent { background: rgba(148, 163, 184, 0.18); color: var(--text-muted); border: 1px solid var(--text-muted); }

/* --- VERTICAL 3D FLASHCARDS (color = valency) --- */
#study-cards-view { display: none; text-align: center; max-width: 900px; margin: 0 auto; }
.deck-filters { display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
#fc-notice-banner {
    display: none; margin: 0 auto 20px; max-width: 480px; padding: 10px 18px;
    border-radius: 14px; background: rgba(16, 185, 129, 0.15); border: 1px solid var(--accent-green);
    color: var(--accent-green); font-size: 14px; font-weight: 800;
}

/* One color per valency, used everywhere (cards, tables, legend) */
.fc-theme-Monovalent  { --vc: var(--accent-cyan);   --vc-soft: rgba(56, 189, 248, 0.16);  --vf1: #0ea5e9; --vf2: #0369a1; }
.fc-theme-Divalent    { --vc: var(--accent-purple); --vc-soft: rgba(192, 132, 252, 0.16); --vf1: #9333ea; --vf2: #6b21a8; }
.fc-theme-Trivalent   { --vc: var(--accent-green);  --vc-soft: rgba(16, 185, 129, 0.16);  --vf1: #059669; --vf2: #065f46; }
.fc-theme-Tetravalent { --vc: var(--accent-amber);  --vc-soft: rgba(245, 158, 11, 0.18);  --vf1: #d97706; --vf2: #92400e; }
.fc-theme-Zero-valent { --vc: var(--text-muted);    --vc-soft: rgba(148, 163, 184, 0.18); --vf1: #64748b; --vf2: #334155; }

.fc-legend { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 auto 18px; max-width: 520px; }
.fc-legend-chip {
    display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px;
    font-size: 12.5px; font-weight: 800; color: var(--text-muted);
    background: var(--bg-surface); border: 2px solid var(--border-subtle); transition: 0.2s;
}
.fc-legend-chip::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--vc); }
.fc-legend.reveal .fc-legend-chip.on { color: var(--text-main); border-color: var(--vc); background: var(--vc-soft); }

.fc-deck-stage {
    position: relative; width: 325px; height: 475px;
    margin: 10px auto 40px; perspective: 1400px; direction: ltr;
    touch-action: pan-y;
}
.fc-stack-card {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 22px; pointer-events: none !important;
    box-shadow: var(--shadow-card-3d);
}
.fc-stack-1 { transform: translateY(9px) scale(0.965); opacity: 0.7; }
.fc-stack-2 { transform: translateY(18px) scale(0.93); opacity: 0.4; }

.flashcard-scene {
    width: 100%; height: 100%; position: relative; z-index: 5;
    cursor: pointer; user-select: none; transform-style: preserve-3d;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease;
}
.flashcard-scene.throw-left { transform: translate3d(-135%, -18px, 0) rotate(-16deg) scale(0.88) !important; opacity: 0; }
.flashcard-scene.throw-right { transform: translate3d(135%, -18px, 0) rotate(16deg) scale(0.88) !important; opacity: 0; }
.flashcard-scene.deal-from-right { transition: none !important; transform: translate3d(85%, 18px, -80px) rotate(12deg) scale(0.85) !important; opacity: 0; }
.flashcard-scene.deal-from-left { transition: none !important; transform: translate3d(-85%, 18px, -80px) rotate(-12deg) scale(0.85) !important; opacity: 0; }

.flashcard-inner {
    width: 100%; height: 100%; position: relative; transform-style: preserve-3d;
    transition: transform 0.52s cubic-bezier(0.34, 1.45, 0.64, 1);
}
.flashcard-Inner-no-anim { transition: none !important; }
.flashcard-scene.is-flipped .flashcard-inner { transform: rotateY(180deg); }

.fc-face {
    position: absolute; width: 100%; height: 100%; top: 0; left: 0;
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-card-3d);
    display: flex; flex-direction: column; text-align: center;
}
html[dir="rtl"] .fc-face { direction: rtl; }
html[dir="ltr"] .fc-face { direction: ltr; }
.fc-front { pointer-events: auto; }
.fc-back { transform: rotateY(180deg); pointer-events: none; }
.flashcard-scene.is-flipped .fc-front { pointer-events: none; }
.flashcard-scene.is-flipped .fc-back { pointer-events: auto; }

.fc-band {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 13px 16px; background: var(--vc-soft); border-bottom: 4px solid var(--vc);
    font-size: 14px; font-weight: 900; color: var(--text-main);
}
.fc-count { font-size: 12.5px; font-weight: 800; color: var(--text-muted); direction: ltr; }
.fc-body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 14px 18px; min-height: 0; }
.fc-foot { padding: 11px 14px; font-size: 11.5px; font-weight: 800; color: var(--text-muted); border-top: 1px solid var(--border-subtle); }

/* FRONT: solid valency color + white text (back stays neutral) */
.fc-front { background: linear-gradient(160deg, var(--vf1), var(--vf2)); border-color: var(--vf2); }
.fc-front .fc-band { background: rgba(255, 255, 255, 0.16); border-bottom: 4px solid rgba(255, 255, 255, 0.55); color: #ffffff; }
.fc-front .fc-count { color: rgba(255, 255, 255, 0.85); }
.fc-front .fc-big-symbol { color: #ffffff; text-shadow: 0 4px 18px rgba(0, 0, 0, 0.28); }
.fc-front .fc-prompt { color: rgba(255, 255, 255, 0.92); }
.fc-front .fc-foot { color: rgba(255, 255, 255, 0.88); border-top-color: rgba(255, 255, 255, 0.28); }

.fc-big-symbol { font-size: 76px; font-weight: 900; color: var(--vc); line-height: 1.05; direction: ltr; }
.fc-prompt { font-size: 15px; font-weight: 800; color: var(--text-muted); }

.fc-big-name { font-size: 32px; font-weight: 900; color: var(--text-main); line-height: 1.2; word-break: break-word; }
.fc-alt { font-size: 14px; font-weight: 700; color: var(--text-muted); margin-top: -4px; direction: ltr; }
.fc-ion-row { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.fc-ion-pill {
    font-size: 22px; font-weight: 900; color: var(--vc); direction: ltr;
    padding: 4px 16px; border-radius: 12px; background: var(--vc-soft); border: 2px solid var(--vc);
}
.fc-val-row { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 800; color: var(--text-muted); }
.fc-dots { display: inline-flex; gap: 4px; direction: ltr; }
.fc-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vc); }
.fc-dot.zero { background: transparent; border: 2px solid var(--vc); }
.fc-charge { font-size: 14px; font-weight: 800; color: var(--text-main); line-height: 1.6; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 8px 12px; width: 100%; }
.fc-sibs-label { font-size: 12px; font-weight: 800; color: var(--text-muted); margin-top: 2px; }
.fc-sibs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; direction: ltr; }
.fc-sib { font-size: 13px; font-weight: 900; color: var(--vc); background: var(--vc-soft); border-radius: 8px; padding: 3px 9px; }
.fc-sib.more { color: var(--text-muted); background: transparent; }
.fc-controls { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Valency colors in the reference tables */
.symbol-pill.sp-Monovalent  { color: var(--accent-cyan);   border-color: var(--accent-cyan); }
.symbol-pill.sp-Divalent    { color: var(--accent-purple); border-color: var(--accent-purple); }
.symbol-pill.sp-Trivalent   { color: var(--accent-green);  border-color: var(--accent-green); }
.symbol-pill.sp-Tetravalent { color: var(--accent-amber);  border-color: var(--accent-amber); }
.symbol-pill.sp-Zero-valent { color: var(--text-muted);    border-color: var(--text-muted); }

/* --- SUB-VIEW 2C: INTERACTIVE FORMULA BUILDER --- */
#study-builder-view { display: none; max-width: 960px; margin: 0 auto; }
.builder-card {
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 26px; padding: 36px; box-shadow: var(--shadow-main);
}
.builder-selectors { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: center; margin-bottom: 30px; }
.ion-select-box { background: var(--bg-card); border: 2px solid var(--border-subtle); border-radius: 18px; padding: 20px; text-align: start; }
.ion-select-box label { display: block; font-size: 13px; font-weight: 800; color: var(--text-muted); margin-bottom: 10px; }
.ion-select {
    width: 100%; padding: 14px; font-size: 16px; font-weight: 800;
    background: var(--bg-input); color: var(--text-main);
    border: 2px solid var(--border-subtle); border-radius: 12px; outline: none; cursor: pointer;
}
.ion-select:focus { border-color: var(--accent-cyan); }
.swap-steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 28px; }
.swap-step-box { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 18px; padding: 20px; text-align: center; }
.swap-step-num { font-size: 12px; font-weight: 900; color: var(--accent-cyan); margin-bottom: 8px; }
.swap-step-val { font-size: 28px; font-weight: 900; margin: 8px 0; direction: ltr; }
.formula-result-banner {
    background: radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.16) 0%, transparent 75%), var(--bg-card);
    border: 2px solid var(--accent-green); border-radius: 22px; padding: 28px; text-align: center;
}
.final-formula-text { font-size: 56px; font-weight: 900; color: var(--accent-green); letter-spacing: 1px; direction: ltr; }
.final-compound-name { font-size: 22px; font-weight: 800; color: var(--text-main); margin-top: 6px; }

/* --- SECTION 3: TRAINING HUB & QUIZ ARENA --- */
.exam-cards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-top: 20px; }
.exam-mode-card {
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow-main);
    display: flex; flex-direction: column; justify-content: space-between;
    transition: transform 0.2s, border-color 0.2s; text-align: start;
}
.exam-mode-card:hover { transform: translateY(-4px); border-color: var(--accent-cyan); }
.exam-badge { display: inline-block; padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 800; margin-bottom: 14px; width: fit-content; }
.exam-mode-card h3 { font-size: 24px; font-weight: 900; margin-bottom: 10px; }
.exam-mode-card p { font-size: 15px; color: var(--text-muted); font-weight: 600; line-height: 1.6; margin-bottom: 22px; }
.exam-specs { list-style: none; margin-bottom: 24px; border-top: 1px solid var(--border-subtle); padding-top: 16px; }
.exam-specs li { font-size: 14px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }

#quiz-arena-wrapper { display: none; max-width: 780px; margin: 0 auto; text-align: center; }
.quiz-card { background: var(--bg-surface); border: 2px solid var(--border-color); border-radius: 28px; padding: 45px; box-shadow: var(--shadow-main); }
.progress-container { width: 100%; height: 10px; background: var(--bg-card); border-radius: 10px; overflow: hidden; margin-bottom: 25px; border: 1px solid var(--border-subtle); }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green)); width: 0%; transition: width 0.3s ease; }

.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; font-size: 16px; color: var(--text-muted); font-weight: 800; flex-wrap: wrap; gap: 10px; }
.tag { background: rgba(6, 182, 212, 0.15); padding: 8px 18px; border-radius: 20px; color: var(--accent-cyan); font-weight: 800; border: 1px solid var(--accent-cyan); }

.prompt-title { font-size: 16px; color: var(--text-muted); margin-bottom: 12px; font-weight: 800; }
.question-text { font-size: 46px; font-weight: 900; color: var(--text-main); margin-bottom: 35px; min-height: 65px; direction: ltr; }

.text-input-row { display: flex; gap: 14px; margin-bottom: 20px; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"] { 
    flex: 1; padding: 16px 20px; font-size: 18px; font-weight: 700; 
    background: var(--bg-input); border: 3px solid var(--border-subtle); border-radius: 16px; 
    color: var(--text-main); outline: none; transition: 0.2s; width: 100%; 
}
input:focus { border-color: var(--accent-cyan); }
input.input-error {
    border-color: var(--accent-red) !important;
    background-color: rgba(239, 68, 68, 0.06);
}
#auth-error:not(:empty) {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 10px 14px;
    border-radius: 12px;
}
.mc-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}
.mc-btn {
    flex: 1 1 calc(33.333% - 12px);
    min-width: 145px;
    background: var(--bg-card);
    border: 3px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 16px;
    font-weight: 900;
    padding: 14px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.08s ease, border-color 0.15s ease, background-color 0.15s ease;
    box-shadow: var(--shadow-btn-3d);
}
.mc-btn:hover:not(:disabled) { border-color: var(--accent-cyan); }
.mc-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.mc-btn:disabled { cursor: default; opacity: 0.88; }
.mc-btn:hover:not(:disabled) { border-color: var(--accent-cyan); }
.mc-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.mc-btn:disabled { cursor: default; opacity: 0.88; }
.key-hint { display: block; font-size: 11px; color: var(--text-muted); margin-top: 5px; font-weight: 700; }

.feedback-msg { min-height: 28px; font-size: 18px; font-weight: 800; margin-top: 15px; }
.feedback-correct { color: var(--accent-green); }
.feedback-wrong { color: var(--accent-red); }
.feedback-warning { color: var(--accent-amber); } 
.tries-text { color: var(--accent-red); font-weight: 800; margin-inline-start: 12px; }
.hint-text { font-size: 14px; color: var(--text-muted); margin-top: 22px; font-weight: 600; }

@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-8px); } 100% { transform: translateX(0); } }
.shake { animation: shake 0.3s ease-in-out; }
.mc-btn.correct-choice { border-color: #10b981 !important; background-color: rgba(16, 185, 129, 0.18); opacity: 1; }
.mc-btn.wrong-choice { border-color: #ef4444 !important; background-color: rgba(239, 68, 68, 0.18); opacity: 1; }

/* --- SECTION 3.5: MINI-GAME (تحدي فرط الشحنة - VALENCY REACTOR BLITZ) --- */
.arcade-container {
    max-width: 920px; margin: 0 auto;
    background: var(--bg-surface); border: 2px solid var(--border-color);
    border-radius: 28px; padding: 36px; box-shadow: var(--shadow-main);
    text-align: center; position: relative; overflow: hidden;
}
.reactor-hud {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px;
}
.hud-box {
    background: var(--bg-card); border: 2px solid var(--border-subtle);
    border-radius: 16px; padding: 14px 10px;
}
.hud-label { font-size: 12px; font-weight: 800; color: var(--text-muted); margin-bottom: 4px; }
.hud-val { font-size: 26px; font-weight: 900; color: var(--accent-cyan); direction: ltr; }
.reactor-core-stage {
    background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.16) 0%, transparent 70%), var(--bg-card);
    border: 3px solid var(--border-subtle); border-radius: 24px;
    padding: 36px 24px; margin-bottom: 22px; position: relative;
    min-height: 230px; display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.reactor-atom-orb {
    width: 125px; height: 125px; border-radius: 50%;
    background: var(--bg-surface); border: 4px solid var(--accent-cyan);
    box-shadow: 0 0 35px rgba(56, 189, 248, 0.35);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    margin-bottom: 14px; animation: pulseOrb 1.8s infinite ease-in-out; direction: ltr;
}
@keyframes pulseOrb {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
.orb-symbol { font-size: 40px; font-weight: 900; color: var(--accent-cyan); }
.reactor-prompt { font-size: 24px; font-weight: 900; color: var(--text-main); margin-top: 6px; }
.reactor-subprompt { font-size: 14px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.reactor-choices-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px;
}
.reactor-choice-btn {
    background: var(--bg-card); border: 3px solid var(--border-subtle);
    color: var(--text-main); font-size: 18px; font-weight: 900;
    padding: 18px 16px; border-radius: 18px; cursor: pointer; transition: transform 0.08s ease, border-color 0.15s ease;
    box-shadow: var(--shadow-btn-3d);
}
.reactor-choice-btn:hover:not(:disabled) { border-color: var(--accent-cyan); }
.reactor-choice-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.powerups-bar {
    display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;
    padding-top: 16px; border-top: 1px solid var(--border-subtle);
}
.powerup-btn {
    background: var(--bg-card); border: 2px solid var(--accent-purple);
    color: var(--text-main); padding: 10px 18px; border-radius: 14px;
    font-size: 13.5px; font-weight: 800; cursor: pointer; transition: 0.2s;
}
.powerup-btn:hover:not(:disabled) { background: rgba(192, 132, 252, 0.2); }
.powerup-btn:disabled { opacity: 0.4; border-color: var(--border-subtle); cursor: not-allowed; }

/* --- EXAM RESULTS MODAL --- */
#exam-results-modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 13, 22, 0.8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    z-index: 100; justify-content: center; align-items: center; padding: 20px; text-align: center;
}
body.light-theme #exam-results-modal {
    background: rgba(15, 23, 42, 0.55);
}
.results-card {
    background: var(--bg-surface); border: 2px solid var(--border-color);
    border-radius: 28px; padding: 45px 40px; max-width: 560px; width: 100%;
    box-shadow: var(--shadow-main); max-height: 92vh; overflow-y: auto;
}
.results-score-circle {
    width: 150px; height: 150px; border-radius: 50%; margin: 20px auto;
    border: 8px solid var(--accent-cyan); display: flex; flex-direction: column;
    justify-content: center; align-items: center; background: var(--bg-card);
}
.results-score-circle .big-pct { font-size: 40px; font-weight: 900; color: var(--accent-cyan); }
.results-score-circle .raw-fraction { font-size: 15px; font-weight: 800; color: var(--text-muted); }

/* --- SECTION 4: STUDY TIMER --- */
.pomo-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 30px; align-items: start; }
.pomo-timer-card, .pomo-settings-card {
    background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 26px; padding: 40px; box-shadow: var(--shadow-main);
}
.pomo-timer-card { text-align: center; }
.pomo-modes { display: flex; justify-content: center; gap: 10px; margin-bottom: 30px; flex-wrap: wrap; }
.pomo-mode-btn {
    padding: 10px 20px; border-radius: 12px; border: 2px solid var(--border-subtle);
    background: var(--bg-card); color: var(--text-muted); font-weight: 800; cursor: pointer; transition: 0.2s;
}
.pomo-mode-btn.active { border-color: var(--accent-cyan); color: var(--accent-cyan); background: rgba(56, 189, 248, 0.1); }
.pomo-clock { font-size: 96px; font-weight: 900; letter-spacing: 2px; margin: 15px 0 25px; font-variant-numeric: tabular-nums; color: var(--text-main); direction: ltr; }
.pomo-controls { display: flex; justify-content: center; gap: 14px; margin-top: 25px; flex-wrap: wrap; }

.pomo-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; text-align: start; }
.pomo-field label { display: block; font-size: 12.5px; font-weight: 800; color: var(--text-muted); margin-bottom: 6px; }
.pomo-field input { padding: 12px 14px; font-size: 17px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; margin: 18px 0 24px; font-weight: 700; cursor: pointer; text-align: start; }
.checkbox-row input { width: 20px; height: 20px; accent-color: var(--accent-cyan); }

/* --- INTERACTIVE SPOTLIGHT TUTORIAL SYSTEM (MOBILE-SAFE) --- */
#tutorial-overlay { display: none; position: fixed; inset: 0; z-index: 9999; pointer-events: auto; overflow: hidden; }
#tutorial-spotlight {
    position: fixed; border-radius: 20px;
    box-shadow: 0 0 0 9999px rgba(6, 10, 19, 0.80), 0 0 30px rgba(56, 189, 248, 0.65);
    border: 3px solid var(--accent-cyan); pointer-events: none !important;
    transition: top 0.32s cubic-bezier(0.22, 1, 0.36, 1), left 0.32s cubic-bezier(0.22, 1, 0.36, 1), width 0.32s cubic-bezier(0.22, 1, 0.36, 1), height 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
    z-index: 10000;
}
#tutorial-popover {
    position: fixed; z-index: 10001; width: 390px; max-width: calc(100vw - 24px);
    background: var(--bg-surface); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border: 2px solid var(--accent-cyan); border-radius: 24px; padding: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65), 0 0 25px rgba(56, 189, 248, 0.2);
    transition: top 0.32s cubic-bezier(0.22, 1, 0.36, 1), left 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    text-align: start;
}
body.light-theme #tutorial-popover {
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25), 0 0 20px rgba(2, 132, 199, 0.15);
}
.tut-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tut-step-badge { background: rgba(56, 189, 248, 0.15); border: 1px solid var(--accent-cyan); color: var(--accent-cyan); font-size: 12px; font-weight: 900; padding: 4px 12px; border-radius: 20px; }
.tut-skip-btn { background: transparent; border: none; color: var(--text-muted); font-size: 13px; font-weight: 800; cursor: pointer; transition: 0.2s; padding: 4px 8px; }
.tut-skip-btn:hover { color: #ef4444; }
.tut-title { font-size: 20px; font-weight: 900; color: var(--text-main); margin-bottom: 8px; }
.tut-desc { font-size: 14.5px; color: var(--text-muted); font-weight: 600; line-height: 1.6; margin-bottom: 18px; }
.tut-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--border-subtle); padding-top: 14px; }
.tut-dots { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.tut-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-subtle); transition: 0.25s; }
.tut-dot.active { width: 20px; border-radius: 10px; background: var(--accent-cyan); }
.tut-nav-btns { display: flex; gap: 8px; flex-shrink: 0; }
.tut-btn-next { background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%); color: #022c22; font-weight: 900; font-size: 14px; padding: 10px 18px; border: none; border-radius: 12px; cursor: pointer; }
body.light-theme .tut-btn-next { color: #ffffff; }

/* --- RESPONSIVE & MOBILE OPTIMIZATIONS --- */
@media (max-width: 980px) {
    .stats-grid-full, .reactor-hud { grid-template-columns: repeat(2, 1fr); }
    .landing-info-grid, .exam-cards-grid, .dashboard-bottom-grid, .pomo-layout, .tables-layout, .builder-selectors, .swap-steps-grid { grid-template-columns: 1fr; }
    .app-main { padding: 22px 16px; }
    .pomo-clock { font-size: 68px; }
}

@media (max-width: 768px) {
    /* Keep onboarding controls cleanly positioned and non-overlapping on phones */
    .floating-top-controls {
        position: static;
        width: 100%;
        justify-content: center;
        padding: 14px 12px 0;
        z-index: 10;
    }
    #Onboarding-wrapper {
        padding: 18px 14px 24px;
    }
    /* Hide desktop keyboard hints on touch phones */
    .key-hint { display: none; }
}

    .mc-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}
.mc-btn {
    flex: 1 1 calc(33.333% - 12px);
    min-width: 145px;
    background: var(--bg-card);
    border: 3px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 16px;
    font-weight: 900;
    padding: 14px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.08s ease, border-color 0.15s ease, background-color 0.15s ease;
    box-shadow: var(--shadow-btn-3d);
}

@media (max-width: 550px) {
    .stats-grid-full, .features-showcase-grid, .reactor-choices-grid, .pomo-settings-grid { grid-template-columns: 1fr; }
    .text-input-row, .mc-row { flex-direction: column; }
    .fc-deck-stage { width: 276px; height: 430px; }
    .fc-big-symbol { font-size: 62px; }
    .fc-big-name { font-size: 27px; }
    .fc-body { gap: 8px; padding: 10px 14px; }
    .hero-main-card, .auth-card, .quiz-card, .pomo-timer-card, .pomo-settings-card, .chem-table-card, .builder-card, .arcade-container, .focus-panel, .exam-mode-card {
        padding: 22px 15px; border-radius: 20px;
    }
    #hero-screen h1 { font-size: 34px; }
    .hero-lead { font-size: 16px; margin-bottom: 22px; }
    .section-title { font-size: 24px; }
    .question-text { font-size: 32px; min-height: 46px; margin-bottom: 24px; }
    .final-formula-text { font-size: 42px; }
    .pomo-clock { font-size: 56px; }
    .site-footer { flex-direction: column; text-align: center; padding: 16px; }
    .results-card { padding: 28px 18px; }
}
/* =====================================================================
   MOBILE UX OVERHAUL  (bottom tab bar + menu sheet + compact layouts)
   ===================================================================== */
:root { --nav-solid: #0f172a; }
html.light-theme, body.light-theme { --nav-solid: #ffffff; }

.nav-short, .menu-only { display: none; }
.nav-icon { line-height: 1; }
.floating-chem { will-change: transform, opacity; }
@supports (height: 100dvh) {
    body, #app-workspace, #Onboarding-wrapper { min-height: 100dvh; }
}

/* ---- Tablet & phone navigation: bottom tab bar + top bar + menu sheet ---- */
@media (max-width: 1024px) {
    #app-workspace { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }

    /* backdrop-filter would turn the navbar into the containing block of the fixed bar below */
    .app-navbar {
        background: var(--nav-solid); -webkit-backdrop-filter: none; backdrop-filter: none;
        padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top, 0px));
        gap: 10px; min-height: 54px;
    }
    .brand-logo { font-size: 20px; margin-inline-end: auto; }
    #nav-pomo-pill { padding: 5px 10px; font-size: 12.5px; }

    .nav-links {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
        background: var(--nav-solid); border: none; border-top: 2px solid var(--border-subtle);
        border-radius: 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.18);
    }
    .nav-tab {
        flex-direction: column; justify-content: center; gap: 3px;
        padding: 7px 2px; min-width: 0; border-radius: 12px;
        font-size: 11px; font-weight: 800; line-height: 1.15; white-space: normal; text-align: center;
    }
    .nav-tab .nav-icon { font-size: 21px; }
    .nav-long { display: none; }
    .nav-short { display: inline; }

}

/* ---- Small laptops / tablets landscape: the full navbar needs ~1290px, so use compact labels ---- */
@media (min-width: 1025px) and (max-width: 1340px) {
    .nav-long { display: none; }
    .nav-short { display: inline; }
    .nav-tab { padding: 8px 11px; }
    .app-navbar { padding-inline: 16px; }
}

/* ---- Phones ---- */
@media (max-width: 768px) {
    .app-main { padding: 16px 12px 12px; }
    .section-header-bar { margin-bottom: 18px; gap: 12px; }
    .section-title { font-size: 22px; line-height: 1.35; }
    .section-subtitle { font-size: 13.5px; line-height: 1.55; }

    .dash-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px !important; width: 100%; }
    .dash-actions .primary-btn { grid-column: 1 / -1; order: -1; width: 100%; }
    .dash-actions .secondary-btn { width: 100%; padding: 12px 6px; font-size: 13px; }

    .stats-grid-full { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
    .stat-panel { padding: 14px 12px; border-radius: 18px; }
    .stat-panel .stat-icon { font-size: 22px; margin-bottom: 4px; }
    .stat-panel .stat-number { font-size: 30px; }
    .stat-panel .stat-label { font-size: 11.5px; letter-spacing: 0; text-transform: none; }
    .focus-panel { padding: 18px 16px; border-radius: 18px; }
    .dashboard-bottom-grid { gap: 14px; }

    /* study vault */
    .sub-nav-pills { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .sub-pill { padding: 9px 4px; font-size: 12px; line-height: 1.3; text-align: center; }
    .table-controls { gap: 10px; margin-bottom: 16px; }
    .search-box { max-width: none; }
    .filter-group, .deck-filters {
        flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start;
        margin-inline: -12px; padding: 2px 12px 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .filter-group::-webkit-scrollbar, .deck-filters::-webkit-scrollbar { display: none; }
    .filter-group > *, .deck-filters > * { flex-shrink: 0; white-space: nowrap; padding: 9px 14px; font-size: 13px; }
    .chem-table-card { padding: 14px 10px; border-radius: 18px; }
    .chem-table-card h3 { font-size: 16px; margin-bottom: 10px; }
    .chem-table th { padding: 8px 6px; font-size: 11px; }
    .chem-table td { padding: 10px 6px; font-size: 14px; }
    .tables-layout { gap: 14px; margin-bottom: 14px; }
    .fc-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .fc-controls > :nth-child(2) { order: 3; grid-column: 1 / -1; }
    .fc-controls button { padding: 13px 8px !important; font-size: 15px !important; }
    .swap-steps-grid { gap: 10px; }
    .swap-step-box { padding: 14px; }
    .swap-step-val { font-size: 24px; }
    .formula-result-banner { padding: 18px 12px; }
    .builder-selectors { gap: 10px; }
    .ion-select-box { padding: 14px; }

    /* exams */
    .exam-cards-grid { gap: 14px; }
    .top-bar { font-size: 13px; margin-bottom: 18px; gap: 8px; }
    .tag { padding: 5px 12px; }
    .mc-row { gap: 10px; }
    .mc-btn { flex: 0 0 auto; width: 100%; min-width: 0; padding: 13px 10px; font-size: 15px; }

    /* reactor */
    .reactor-hud { gap: 8px; margin-bottom: 14px; }
    .hud-box { padding: 9px 6px; border-radius: 14px; }
    .hud-val { font-size: 19px; }
    .hud-label { font-size: 10.5px; }
    .reactor-core-stage { padding: 22px 14px; min-height: 0; }
    .reactor-atom-orb { width: 96px; height: 96px; }
    .reactor-choices-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .reactor-choice-btn { padding: 14px 8px; font-size: 15px; min-height: 58px; }
    .powerups-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 12px; }
    .powerup-btn { padding: 9px 4px; font-size: 11.5px; line-height: 1.3; display: flex; flex-direction: column; align-items: center; gap: 2px; }

    /* study timer */
    .pomo-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 20px; }
    .pomo-mode-btn { padding: 10px 4px; font-size: 12.5px; }
    .pomo-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .pomo-controls #pomo-start-btn { grid-column: 1 / -1; }
    .pomo-layout { gap: 16px; }

    /* modal */
    #exam-results-modal { padding: 12px; }
    .results-card { padding: 24px 16px; max-height: 94vh; max-height: 94dvh; }
    .site-footer { margin-top: 12px; }

    /* guided tour: bottom sheet (never covers the spotlight) */
    #tutorial-popover.tut-sheet {
        left: 12px !important; right: 12px !important; top: auto !important;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: auto; max-width: none;
        padding: 14px 16px 12px; border-radius: 20px; transition: none;
    }
    #tutorial-popover.tut-sheet.tut-top { top: calc(66px + env(safe-area-inset-top, 0px)) !important; bottom: auto; }
    .tut-sheet .tut-title { font-size: 17px; margin-bottom: 6px; }
    .tut-sheet .tut-desc { font-size: 13.5px; line-height: 1.55; margin-bottom: 10px; }
    .tut-sheet .tut-top-row { margin-bottom: 8px; }
    .tut-sheet .tut-footer { padding-top: 10px; }
    .tut-sheet .tut-dots { display: none; }
    .tut-sheet .tut-nav-btns { width: 100%; }
    .tut-sheet .tut-nav-btns > * { flex: 1; }
}

/* ---- Small phones ---- */
@media (max-width: 550px) {
    .stats-grid-full { grid-template-columns: 1fr 1fr; }
    .fc-deck-stage { width: min(276px, 80vw); height: auto; aspect-ratio: 276 / 430; }
    .mc-row { flex-direction: column; }
}

/* ---- Touch devices: keyboard hints are meaningless ---- */
@media (hover: none) and (pointer: coarse) {
    .key-hint, .hint-text { display: none !important; }
}

/* ---- Guided tour: never let the page scroll underneath ---- */
#tutorial-overlay { touch-action: none; overscroll-behavior: contain; }
#tutorial-popover { max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
html.tour-active, html.tour-active body { overscroll-behavior: none; }

/* ---- Respect reduced-motion (also saves battery) ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
    .floating-chem { display: none; }
}

/* ==========================================================================
   MULTI-PAGE ADDITIONS (landing / login / signup / root gateway)
   ========================================================================== */
a.secondary-btn, a.primary-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.skip-link { position: absolute; top: -60px; inset-inline-start: 12px; z-index: 100; background: var(--accent-cyan); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 800; text-decoration: none; transition: top 0.2s; }
.skip-link:focus { top: 10px; }
.hero-cta-group { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }
.landing-section { max-width: 1080px; width: 100%; margin: 34px auto 0; text-align: start; }
.landing-section > h2 { font-size: 26px; font-weight: 900; margin-bottom: 18px; text-align: center; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.step-card { background: var(--bg-surface); border: 2px solid var(--border-subtle); border-radius: 20px; padding: 22px; }
.step-num { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-cyan); color: #fff; display: grid; place-items: center; font-weight: 900; margin-bottom: 12px; }
.step-card h3 { font-size: 18px; font-weight: 900; margin-bottom: 6px; }
.step-card p { font-size: 15px; color: var(--text-muted); font-weight: 600; line-height: 1.7; }
.faq-list { display: flex; flex-direction: column; gap: 12px; }
.faq-list details { background: var(--bg-surface); border: 2px solid var(--border-subtle); border-radius: 16px; padding: 4px 18px; }
.faq-list summary { cursor: pointer; font-weight: 900; font-size: 16.5px; padding: 14px 0; list-style-position: inside; }
.faq-list details[open] { border-color: var(--accent-cyan); }
.faq-list details p { padding: 0 0 16px; color: var(--text-muted); font-weight: 600; line-height: 1.8; font-size: 15.5px; }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.footer-links a { color: var(--text-muted); font-weight: 800; font-size: 14px; text-decoration: none; }
.footer-links a:hover { color: var(--accent-cyan); }

.auth-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 900; color: var(--accent-cyan); text-decoration: none; margin-bottom: 14px; }
.google-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 50px; padding: 10px 16px; border-radius: 14px; background: #ffffff; color: #1f1f1f; border: 2px solid #dadce0; font-size: 16px; font-weight: 800; cursor: pointer; transition: 0.2s; font-family: inherit; }
.google-btn:hover:not(:disabled) { background: #f6f8fc; border-color: #c0c4cc; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.google-btn:disabled { opacity: 0.65; cursor: wait; }
.google-btn svg { width: 22px; height: 22px; flex: none; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-muted); font-weight: 800; font-size: 14px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 2px; background: var(--border-subtle); border-radius: 2px; }
.auth-switch { margin: 6px 0 14px; font-size: 15px; font-weight: 700; color: var(--text-muted); }
.auth-switch a { color: var(--accent-cyan); font-weight: 900; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 52px !important; }
.pw-toggle svg { width: 22px; height: 22px; display: block; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--accent-cyan); }
.pw-toggle { display: flex; align-items: center; justify-content: center; position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); background: transparent; border: none; cursor: pointer; font-size: 20px; padding: 8px; color: var(--text-muted); line-height: 1; }
.auth-note { font-size: 13px; color: var(--text-muted); font-weight: 600; margin: 4px 0 14px; line-height: 1.7; }

/* Root language gateway page */
.gateway-card { max-width: 560px; width: 100%; margin: auto; background: var(--bg-surface); border: 2px solid var(--border-color); border-radius: 28px; padding: 40px 32px; text-align: center; box-shadow: var(--shadow-main); }
.gateway-card h1 { font-size: 34px; font-weight: 900; margin-bottom: 8px; }
.gateway-card p { color: var(--text-muted); font-weight: 700; margin-bottom: 22px; }
.gateway-links { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 480px) { .auth-card { padding: 30px 20px; } .gateway-card { padding: 30px 20px; } }

/* ---------- Legal pages (privacy / terms) ---------- */
.legal-main { width: 100%; display: flex; justify-content: center; padding: 70px 0 10px; }
.legal-card {
    width: 100%; max-width: 820px; background: var(--bg-surface); border: 2px solid var(--border-subtle);
    border-radius: 26px; padding: 36px 40px; box-shadow: var(--shadow-main); text-align: start;
}
.legal-card .auth-brand { display: inline-block; margin-bottom: 14px; }
.legal-title { font-size: 34px; font-weight: 900; margin: 0 0 6px; }
.legal-updated { color: var(--text-muted); font-weight: 700; font-size: 14px; margin: 0 0 18px; }
.legal-intro { line-height: 1.9; font-weight: 500; margin: 0 0 22px; }
.legal-toc { background: rgba(56, 189, 248, 0.07); border: 1px solid var(--border-color); border-radius: 16px; padding: 16px 22px; margin-bottom: 10px; }
.legal-toc strong { display: block; margin-bottom: 8px; color: var(--accent-cyan); }
.legal-toc ol { margin: 0; padding-inline-start: 22px; columns: 2; column-gap: 28px; }
.legal-toc li { margin: 4px 0; font-weight: 700; font-size: 14.5px; break-inside: avoid; }
.legal-toc a { color: var(--text-main); text-decoration: none; }
.legal-toc a:hover { color: var(--accent-cyan); text-decoration: underline; }
.legal-sec { margin-top: 26px; scroll-margin-top: 80px; }
.legal-sec h2 { font-size: 21px; font-weight: 900; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.legal-num { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 10px; background: var(--accent-cyan); color: #04121f; font-size: 14px; font-weight: 900; }
.legal-sec p, .legal-sec li { line-height: 1.9; font-weight: 500; color: var(--text-main); }
.legal-sec b { font-weight: 900; }
.legal-sec p { margin: 0 0 10px; }
.legal-sec ul { margin: 0 0 10px; padding-inline-start: 24px; }
.legal-sec li { margin: 6px 0; }
.legal-card a:not(.primary-btn):not(.secondary-btn):not(.auth-brand) { color: var(--accent-cyan); word-break: break-word; }
.legal-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 34px; }
.auth-consent { font-size: 12.5px; line-height: 1.7; color: var(--text-muted); font-weight: 600; text-align: center; margin: 0 0 12px; }
.auth-consent a { color: var(--accent-cyan); font-weight: 800; white-space: nowrap; }
@media (max-width: 640px) {
    .legal-main { padding-top: 64px; }
    .legal-card { padding: 22px 18px; border-radius: 20px; }
    .legal-title { font-size: 26px; }
    .legal-toc ol { columns: 1; }
}

/* ---------- Dashboard (improved) ---------- */
.dash-hero {
    display: grid; grid-template-columns: 1fr auto; gap: 10px 36px; align-items: center;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(192, 132, 252, 0.12)), var(--bg-surface);
    border: 2px solid var(--border-color); border-radius: 26px; padding: 30px 34px; margin-bottom: 24px; box-shadow: var(--shadow-main);
}
.dash-hero-text { grid-column: 1; grid-row: 1 / span 2; min-width: 0; }
.dash-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; }
.dash-chip { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 13.5px; }
.dash-chip b { color: var(--accent-cyan); }
.dash-cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.dash-cta-row .primary-btn { padding: 13px 26px; font-size: 15px; }
.dash-ring {
    grid-column: 2; grid-row: 1; width: 156px; height: 156px; border-radius: 50%; display: grid; place-items: center; justify-self: center;
    background: conic-gradient(var(--accent-cyan) calc(var(--p) * 1%), rgba(148, 163, 184, 0.25) 0);
}
.dash-ring-inner { width: 124px; height: 124px; border-radius: 50%; background: var(--bg-card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.dash-ring-inner b { font-size: 42px; font-weight: 900; color: var(--accent-cyan); line-height: 1; }
.dash-ring-inner small { font-size: 12.5px; font-weight: 800; color: var(--text-muted); }
.dash-ring-note { grid-column: 2; grid-row: 2; text-align: center; max-width: 200px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); line-height: 1.6; justify-self: center; }

.dash-block-title { font-size: 20px; font-weight: 900; margin: 4px 0 14px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.quick-tile {
    display: flex; align-items: center; gap: 14px; text-align: start; width: 100%;
    background: var(--bg-surface); border: 2px solid var(--border-subtle); border-radius: 20px; padding: 16px 18px;
    cursor: pointer; color: var(--text-main); font-family: inherit; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.quick-tile:hover, .quick-tile:focus-visible { transform: translateY(-3px); border-color: var(--accent-cyan); box-shadow: var(--shadow-main); outline: none; }
.quick-ico {
    flex: 0 0 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px;
    background: rgba(148, 163, 184, 0.15); border: 1px solid var(--border-subtle);
    background: color-mix(in srgb, var(--c) 18%, transparent); border-color: color-mix(in srgb, var(--c) 45%, transparent);
}
.quick-txt { min-width: 0; }
.quick-txt b { display: block; font-size: 16px; font-weight: 900; }
.quick-txt small { display: block; font-size: 12.5px; color: var(--text-muted); font-weight: 600; margin-top: 2px; line-height: 1.5; }

.dash-practice-btn { margin-top: 18px; display: inline-flex; align-items: center; justify-content: center; }
.dash-tip-panel { background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), transparent), var(--bg-surface); }
.focus-panel .dash-tip-text { font-size: 17px; line-height: 1.9; color: var(--text-main); font-weight: 700; margin: 0; }
.dash-footer-actions { display: flex; justify-content: flex-end; margin-top: 22px; }
.dash-reset-btn { opacity: .8; padding: 8px 16px; font-size: 13px; }

@media (max-width: 900px) {
    .quick-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-hero { grid-template-columns: 1fr; padding: 24px 22px; }
    .dash-hero-text { grid-row: auto; order: 2; }
    .dash-ring { grid-column: 1; grid-row: auto; order: 1; }
    .dash-ring-note { grid-column: 1; grid-row: auto; order: 1; max-width: none; }
}
@media (max-width: 560px) {
    .quick-grid { grid-template-columns: 1fr; gap: 10px; }
    .quick-tile { padding: 12px 14px; }
    .dash-ring { width: 128px; height: 128px; }
    .dash-ring-inner { width: 100px; height: 100px; }
    .dash-ring-inner b { font-size: 34px; }
    .dash-cta-row .primary-btn, .dash-cta-row .secondary-btn { flex: 1 1 100%; }
}

/* Clickable feature cards */
a.feature-mini-card { display: block; text-decoration: none; color: inherit; cursor: pointer; }
a.feature-mini-card:focus-visible { outline: 3px solid var(--accent-cyan); outline-offset: 3px; }
/* Footer: copyright | links | support on ONE row */
.site-footer { padding: 14px 24px; gap: 10px 18px; font-size: 13px; flex-wrap: wrap; }
.site-footer .footer-links { gap: 6px 14px; }
.site-footer .footer-links a { font-size: 13px; }
.site-footer .footer-support-link { padding: 5px 12px; font-size: 13px; white-space: nowrap; }
@media (max-width: 1100px) { .site-footer { justify-content: center; text-align: center; } }

/* Logo + fixed top bar */
.brand-img { width: 30px; height: 30px; border-radius: 8px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.auth-brand .brand-img { width: 28px; height: 28px; }
.site-topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 18px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 4px 18px rgba(0,0,0,0.18); }
.top-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--accent-cyan); font-weight: 900; font-size: 19px; text-decoration: none; white-space: nowrap; min-width: 0; }
.site-topbar .floating-top-controls { position: static; inset: auto; width: auto; padding: 0; flex-wrap: nowrap; gap: 8px; justify-content: flex-end; pointer-events: auto; }
.site-topbar .floating-top-controls > * { box-shadow: none; white-space: nowrap; padding: 7px 12px; font-size: 13px; }
@media (max-width: 768px) { #Onboarding-wrapper { padding-top: 74px; } }
@media (max-width: 480px) {
    .site-topbar { padding-inline: 10px; gap: 6px; }
    .top-brand { font-size: 15px; gap: 6px; }
    .top-brand .brand-img { width: 26px; height: 26px; }
    .site-topbar .floating-top-controls { gap: 5px; }
    .site-topbar .floating-top-controls > * { padding: 6px 8px; font-size: 11.5px; }
}

/* ==========================================================================
   SLIDE-OUT MENU (hamburger), SETTINGS PAGE, EMAIL SIGN-IN EXTRAS
   ========================================================================== */
[hidden] { display: none !important; }
a.brand-logo, a.nav-tab { text-decoration: none; }
body.drawer-open { overflow: hidden; }

/* ---- hamburger button: three lines that turn into an X ---- */
.burger-btn {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 44px; height: 44px; padding: 0; border-radius: 12px; cursor: pointer;
    background: var(--bg-card); border: 2px solid var(--border-subtle); color: var(--text-main); transition: border-color .18s, background .18s;
}
.burger-btn:hover, .burger-btn:focus-visible, .burger-btn.is-open { border-color: var(--accent-cyan); outline: none; }
.burger-lines { position: relative; display: block; width: 20px; height: 14px; }
.burger-lines i { position: absolute; inset-inline: 0; height: 2.5px; border-radius: 2px; background: currentColor; transition: transform .25s ease, opacity .18s ease, top .25s ease; }
.burger-lines i:nth-child(1) { top: 0; }
.burger-lines i:nth-child(2) { top: 5.75px; }
.burger-lines i:nth-child(3) { top: 11.5px; }
.burger-btn.is-open .burger-lines i:nth-child(1) { top: 5.75px; transform: rotate(45deg); }
.burger-btn.is-open .burger-lines i:nth-child(2) { opacity: 0; }
.burger-btn.is-open .burger-lines i:nth-child(3) { top: 5.75px; transform: rotate(-45deg); }

/* ---- drawer (slides in from the end side: right in English, left in Arabic) ---- */
#nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(2, 6, 23, .55); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
#nav-backdrop.open { opacity: 1; pointer-events: auto; }
.nav-drawer {
    position: fixed; top: 0; bottom: 0; inset-inline-end: 0; z-index: 60; width: min(340px, 88vw);
    display: flex; flex-direction: column; background: var(--nav-solid);
    border-inline-start: 2px solid var(--border-color); box-shadow: -18px 0 46px rgba(0, 0, 0, .4);
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(104%); visibility: hidden;
    transition: transform .28s cubic-bezier(.16, 1, .3, 1), visibility 0s linear .28s;
}
html[dir="rtl"] .nav-drawer { transform: translateX(-104%); box-shadow: 18px 0 46px rgba(0, 0, 0, .4); }
.nav-drawer.open, html[dir="rtl"] .nav-drawer.open { transform: none; visibility: visible; transition-delay: 0s; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 12px 16px; padding-inline: 16px 12px; border-bottom: 1px solid var(--border-subtle); }
.drawer-user { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 6px; border-radius: 14px; text-decoration: none; color: var(--text-main); }
.drawer-user:hover, .drawer-user:focus-visible { background: var(--bg-card); outline: none; }
.drawer-avatar {
    flex: 0 0 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; direction: ltr;
    font-size: 22px; font-weight: 900; color: var(--accent-cyan); border: 2px solid var(--accent-cyan);
    background: linear-gradient(160deg, rgba(56, 189, 248, .2), rgba(16, 185, 129, .1)), var(--bg-card);
}
.drawer-user-txt { min-width: 0; display: flex; flex-direction: column; }
.drawer-user-txt b { font-size: 16px; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-user-txt small { font-size: 12.5px; color: var(--text-muted); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
.drawer-close { flex: 0 0 40px; height: 40px; border-radius: 12px; border: 2px solid var(--border-subtle); background: transparent; color: var(--text-muted); font-size: 16px; font-weight: 900; cursor: pointer; }
.drawer-close:hover, .drawer-close:focus-visible { color: var(--text-main); border-color: var(--accent-cyan); outline: none; }
.drawer-list { flex: 1; overflow-y: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.drawer-sep { height: 1px; background: var(--border-subtle); margin: 8px 6px; flex: none; }
.drawer-item {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: none; border-radius: 12px;
    background: transparent; color: var(--text-main); font-family: inherit; font-size: 15px; font-weight: 800; text-align: start; text-decoration: none; cursor: pointer; transition: background .15s;
}
.drawer-item:hover, .drawer-item:focus-visible { background: var(--bg-card); outline: none; }
.drawer-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-cyan); }
.drawer-item.active { background: rgba(56, 189, 248, .13); color: var(--accent-cyan); }
.drawer-item.active::before { content: ''; position: absolute; inset-inline-start: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: var(--accent-cyan); }
.drawer-ico { flex: 0 0 26px; text-align: center; font-size: 20px; line-height: 1; }
.drawer-item .menu-only { display: inline; }
.drawer-danger:hover, .drawer-danger:focus-visible { background: rgba(239, 68, 68, .14); color: #ef4444; }
@media (prefers-reduced-motion: reduce) {
    .nav-drawer, #nav-backdrop, .burger-lines i { transition: none; }
}

/* ---- email sign-in extras ---- */
input[type="email"] { text-align: start; }
.forgot-row { text-align: end; margin: -6px 0 12px; }
.forgot-row a { color: var(--accent-cyan); font-weight: 800; font-size: 14px; text-decoration: none; }
.forgot-row a:hover { text-decoration: underline; }
.auth-info:not(:empty) { background: rgba(16, 185, 129, .12); border: 1px solid var(--accent-green); color: var(--accent-green); padding: 10px 14px; border-radius: 12px; margin-bottom: 15px; font-size: 15px; font-weight: 800; line-height: 1.6; }
.rs-h { font-size: 22px; font-weight: 900; margin-bottom: 8px; }
.rs-err { font-size: 15px; margin: 0 0 14px; min-height: 0; }
.rs-err:empty { display: none; }
#rs-done .primary-btn, #rs-error .primary-btn, #rs-error .secondary-btn { text-align: center; }

/* ==========================================================================
   SETTINGS PAGE
   ========================================================================== */
.settings-main { max-width: 1100px; }
.set-head { display: flex; align-items: center; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.el-tile {
    position: relative; flex: none; width: 84px; height: 84px; display: grid; place-items: center; direction: ltr;
    border: 2px solid var(--accent-cyan); border-radius: 14px; box-shadow: var(--shadow-main);
    background: linear-gradient(160deg, rgba(56, 189, 248, .18), rgba(16, 185, 129, .1)), var(--bg-card);
}
.el-tile small { position: absolute; top: 7px; left: 10px; font-size: 12px; font-weight: 800; color: var(--text-muted); }
.el-tile b { font-size: 38px; font-weight: 900; color: var(--accent-cyan); letter-spacing: -1px; }
.set-head-txt { flex: 1; min-width: 200px; }
.set-title { font-size: 32px; font-weight: 900; line-height: 1.2; }
.set-who { color: var(--text-muted); font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.set-chip { border: 1px solid var(--border-subtle); background: var(--bg-surface); padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 800; }

.set-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
.set-rail { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 4px; }
.set-rail-link {
    display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; text-decoration: none;
    color: var(--text-muted); font-weight: 800; font-size: 15px; border-inline-start: 4px solid transparent; transition: background .15s, color .15s;
}
.set-rail-link:hover, .set-rail-link:focus-visible { background: var(--bg-card); color: var(--text-main); outline: none; }
.set-rail-link.active { background: var(--bg-surface); color: var(--accent-cyan); border-inline-start-color: var(--accent-cyan); }
.set-sec > h2 { font-size: 22px; font-weight: 900; margin: 0 0 12px; }
.set-rows { background: var(--bg-surface); border: 2px solid var(--border-subtle); border-radius: 20px; overflow: hidden; }
.set-row:not([hidden]) ~ .set-row:not([hidden]), .set-row:not([hidden]) ~ .set-callout:not([hidden]) { border-top: 1px solid var(--border-subtle); }
.set-row-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; }
.set-row-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.set-row-txt b { font-size: 16px; font-weight: 900; }
.set-val { font-size: 15px; font-weight: 700; color: var(--accent-cyan); overflow-wrap: anywhere; }
.set-val:empty { display: none; }
.set-desc { font-size: 13.5px; color: var(--text-muted); font-weight: 600; line-height: 1.6; }
.set-desc:empty { display: none; }
.set-row-ctl { flex: none; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.set-act { padding: 9px 16px; font-size: 14px; }
.set-badge { display: inline-block; align-self: flex-start; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 800; border: 1px solid var(--border-subtle); }
.set-badge.ok { color: var(--accent-green); border-color: var(--accent-green); background: rgba(16, 185, 129, .1); }
.set-badge.warn { color: var(--accent-amber); border-color: var(--accent-amber); background: rgba(245, 158, 11, .1); }

.set-edit { padding: 6px 22px 22px; background: rgba(56, 189, 248, .045); border-top: 1px dashed var(--border-subtle); }
.set-edit > * { max-width: 460px; }
.set-edit .auth-field { margin-bottom: 14px; margin-top: 14px; }
.set-edit .auth-field label { text-transform: none; letter-spacing: 0; font-size: 14px; }
.set-edit input[type="text"], .set-edit input[type="password"], .set-edit input[type="email"] { padding: 12px 16px; font-size: 16px; border-width: 2px; border-radius: 12px; }
.set-note { font-size: 14px; line-height: 1.8; color: var(--text-muted); font-weight: 600; margin: 14px 0 0; }
.set-hint { font-size: 12.5px; line-height: 1.7; color: var(--text-muted); font-weight: 600; margin: -6px 0 6px; }
.set-callout { margin: 0; padding: 14px 22px; font-size: 14px; font-weight: 700; line-height: 1.7; border-inline-start: 4px solid var(--accent-amber); background: rgba(245, 158, 11, .09); }
.set-edit .set-callout { max-width: 460px; margin-top: 14px; border-radius: 10px; }
.set-callout-danger { border-inline-start-color: var(--accent-red); background: rgba(239, 68, 68, .09); }
.set-msg { min-height: 0; margin: 4px 0 12px; font-size: 14.5px; font-weight: 800; line-height: 1.6; }
.set-msg:empty { display: none; }
.set-msg.bad { color: var(--accent-red); } .set-msg.ok { color: var(--accent-green); }
.set-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.set-save { font-size: 15px; padding: 11px 22px; }
.set-danger-save { background: linear-gradient(180deg, #f87171, #ef4444); color: #fff; box-shadow: 0 4px 0 #b91c1c; }
.set-danger-save:disabled { background: #64748b; box-shadow: 0 4px 0 #475569; }

.seg { display: inline-flex; border: 2px solid var(--border-subtle); border-radius: 12px; overflow: hidden; background: var(--bg-card); }
.seg-btn { padding: 8px 16px; border: none; background: transparent; color: var(--text-muted); font-family: inherit; font-size: 14px; font-weight: 800; text-decoration: none; cursor: pointer; white-space: nowrap; }
.seg-btn:hover, .seg-btn:focus-visible { color: var(--text-main); outline: none; }
.seg-btn.active { background: var(--accent-cyan); color: #022c22; }
body.light-theme .seg-btn.active { color: #fff; }
.switch { position: relative; width: 54px; height: 30px; flex: none; border-radius: 999px; border: none; background: #64748b; cursor: pointer; direction: ltr; transition: background .2s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.switch.on { background: var(--accent-green); }
.switch.on i { transform: translateX(24px); }
.switch:focus-visible { outline: 3px solid var(--accent-cyan); outline-offset: 3px; }
.set-toast {
    position: fixed; z-index: 80; inset-inline: 16px; bottom: 28px; margin-inline: auto; width: fit-content; max-width: min(560px, calc(100vw - 32px));
    background: var(--nav-solid); color: var(--text-main); border: 2px solid var(--accent-cyan); border-radius: 14px; padding: 13px 20px;
    font-size: 15px; font-weight: 800; line-height: 1.6; box-shadow: var(--shadow-card-3d); opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .22s, transform .22s;
}
.set-toast.show { opacity: 1; transform: none; }

@media (max-width: 1024px) {
    .set-toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 800px) {
    .set-layout { grid-template-columns: 1fr; gap: 16px; }
    .set-rail { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
    .set-rail::-webkit-scrollbar { display: none; }
    .set-rail-link { flex: none; border-inline-start: none; border-bottom: 3px solid transparent; border-radius: 10px; padding: 9px 14px; }
    .set-rail-link.active { border-bottom-color: var(--accent-cyan); }
}
@media (max-width: 640px) {
    .set-title { font-size: 26px; }
    .el-tile { width: 68px; height: 68px; } .el-tile b { font-size: 30px; }
    .set-row-main { flex-wrap: wrap; padding: 16px; }
    .set-row-ctl { width: 100%; justify-content: flex-start; }
    .set-edit { padding: 4px 16px 18px; }
    .set-callout { padding: 12px 16px; }
    .set-btns .primary-btn, .set-btns .secondary-btn { flex: 1 1 100%; }
}

/* forgot-password links + forgot mode of the "add email" form */
.set-link { background: none; border: none; padding: 8px 0 0; font-family: inherit; font-size: 13.5px; font-weight: 800; color: var(--accent-cyan); cursor: pointer; }
.set-link:hover, .set-link:focus-visible { text-decoration: underline; outline: none; }
.forgot-only { display: none; }
.set-edit.is-forgot .forgot-only { display: block; }
.set-edit.is-forgot .need-cur { display: none; }
