:root {
    --bg-light: #fbfcfe;
    --card-bg: rgba(255, 255, 255, 0.88);
    --primary: #277eff;
    --primary-dark: #1d4ed8;
    --secondary: #0ea5e9;
    --accent: #dc2626;
    --text-main: #0f172a;
    --text-dim: #475569;
    --text-muted: #64748b;
    --glass-border: rgba(39, 126, 255, 0.18);
    --surface-subtle: #f1f5f9;
    --font-main: 'Outfit', 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    background-color: var(--bg-light);
    background-image:
        radial-gradient(circle at 1px 1px, rgba(39, 126, 255, 0.08) 1px, transparent 0);
    background-size: 28px 28px;
    color: var(--text-main);
    font-family: var(--font-main);
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%;
    max-width: 850px;
    padding: 16px;
    padding-top: 86px;
    padding-bottom: 48px;
    z-index: 10;
    position: relative;
    margin: 0 auto;
}

/* ─── Top Bar (Integrated White Glass Header) ─── */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px max(16px, calc((100vw - 850px) / 2));
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.84);
    border-bottom: 1px solid rgba(39, 126, 255, 0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.back-js-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 6px 14px;
    border-radius: 10px;
    background: rgba(39, 126, 255, 0.07);
    border: 1px solid rgba(39, 126, 255, 0.20);
    color: #1e293b;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.back-js-link:hover {
    background: rgba(39, 126, 255, 0.14);
    border-color: rgba(39, 126, 255, 0.42);
    color: var(--primary-dark);
}

.lang-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 6px 12px;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.76rem;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    color: var(--text-main);
    background: rgba(39, 126, 255, 0.08);
}

.lang-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(39, 126, 255, 0.28);
}

.timer-display {
    background: rgba(39, 126, 255, 0.07);
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid rgba(39, 126, 255, 0.18);
    font-size: 0.78rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.timer-display .mono {
    font-family: var(--font-mono);
    color: var(--primary-dark);
    font-weight: 700;
    margin-left: 4px;
}

/* ─── STEMIndex Pro Wordmark (Cloud Aura + Breakout X, No Left SVG) ─── */
.stemindex-brand {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    margin-bottom: 16px;
    padding: 6px 18px;
    isolation: isolate;
}

.stemindex-brand::before {
    content: "";
    position: absolute;
    inset: -14px -28px;
    background: radial-gradient(ellipse at 62% 50%, rgba(39, 126, 255, 0.26) 0%, rgba(14, 165, 233, 0.20) 42%, rgba(56, 189, 248, 0.08) 68%, transparent 84%);
    filter: blur(20px);
    border-radius: 999px;
    z-index: -1;
    pointer-events: none;
}

.stemindex-wordmark {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(2.25rem, 6.5vw, 3.25rem);
    line-height: 1;
    letter-spacing: -0.04em;
    margin: 0;
}

.stemindex-wordmark .stem-part {
    font-weight: 900;
    background: linear-gradient(135deg, #1e3a8a 0%, #277eff 62%, #0284c7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stemindex-wordmark .index-part {
    font-weight: 500;
    color: #0f172a;
    letter-spacing: -0.024em;
}

.stemindex-wordmark .x-part {
    display: inline-block;
    font-weight: 900;
    font-size: 1.14em;
    line-height: 1;
    margin-left: -0.028em;
    transform-origin: left bottom;
    transform: skewX(-6deg);
    background: linear-gradient(135deg, #277eff 0%, #0ea5e9 55%, #38bdf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(14, 165, 233, 0.30));
}

/* ─── Screens ─── */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ─── Frosted White Aurora Card ─── */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--glass-border);
    border-radius: clamp(18px, 4vw, 28px);
    padding: clamp(20px, 5vw, 42px);
    box-shadow: 0 20px 50px -12px rgba(39, 126, 255, 0.14), 0 4px 14px -4px rgba(15, 23, 42, 0.04);
    margin: 0 auto;
    width: 100%;
    text-align: center;
}

.main-card { max-width: 800px; }
.quiz-card { max-width: 850px; min-height: 400px; display: flex; flex-direction: column; text-align: left; }
.results-card { max-width: 800px; text-align: center; }

/* ─── Typography ─── */
h1 {
    font-size: clamp(1.6rem, 5.5vw, 2.6rem);
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.15;
    color: var(--text-main);
}

h2 {
    font-size: clamp(1.15rem, 3.8vw, 1.65rem);
    margin-bottom: 20px;
    color: var(--text-main);
    line-height: 1.35;
}

.highlight {
    background: linear-gradient(135deg, #1d4ed8 0%, #277eff 65%, #0ea5e9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: clamp(0.92rem, 2.5vw, 1.08rem);
    color: var(--text-dim);
    margin: 0 auto 26px;
    max-width: 600px;
    line-height: 1.55;
}

/* ─── Badge ─── */
.badge {
    display: inline-block;
    background: rgba(39, 126, 255, 0.09);
    color: var(--primary-dark);
    padding: 5px 14px;
    border-radius: 100px;
    font-size: clamp(0.68rem, 2vw, 0.78rem);
    font-weight: 800;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: 1px solid rgba(39, 126, 255, 0.22);
    width: fit-content;
}

/* ─── Intro Stats ─── */
.intro-stats {
    display: flex;
    gap: clamp(16px, 5vw, 44px);
    margin-bottom: 26px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-radius: 16px;
    background: rgba(39, 126, 255, 0.04);
    border: 1px solid rgba(39, 126, 255, 0.12);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-val {
    font-size: clamp(1.35rem, 5vw, 2.1rem);
    font-weight: 900;
    color: var(--primary-dark);
}

.stat-label {
    font-size: clamp(0.62rem, 1.8vw, 0.74rem);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ─── Inputs & Forms ─── */
.user-info input,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    padding: 13px 16px;
    min-height: 48px;
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: max(1rem, 0.96rem);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.user-info input {
    margin-bottom: 16px;
}

.user-info input::placeholder,
input::placeholder {
    color: #94a3b8;
}

.user-info input:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(39, 126, 255, 0.18);
}

.guest-signin-hint {
    font-size: 0.84rem;
    color: var(--text-dim);
    margin: -4px 0 18px;
}

.guest-signin-hint a {
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.guest-signin-hint a:hover {
    text-decoration: underline;
}

/* ─── PISA Badge ─── */
.pisa-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #f8fafc;
    padding: 10px 16px;
    border-radius: 12px;
    margin-bottom: 22px;
    border: 1px solid #e2e8f0;
    font-size: clamp(0.72rem, 2vw, 0.82rem);
    font-weight: 600;
    color: var(--text-dim);
    flex-wrap: wrap;
}

/* ─── Buttons ─── */
.btn {
    padding: 14px 28px;
    min-height: 48px;
    border-radius: 14px;
    font-family: inherit;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    width: 100%;
    box-shadow: 0 10px 24px -6px rgba(39, 126, 255, 0.38);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px -6px rgba(39, 126, 255, 0.48);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-main);
    border: 1.5px solid #cbd5e1;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary-dark);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* ─── Welcome Actions & Resume ─── */
.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.resume-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px 14px;
    border-radius: 14px;
    text-align: left;
}

.resume-box > label,
.resume-box > span {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-dim);
    display: block;
    margin-bottom: 8px;
}

.resume-input-group {
    display: flex;
    gap: 8px;
}

.resume-input-group input {
    flex: 1;
    margin-bottom: 0 !important;
    min-height: 42px;
    padding: 8px 12px !important;
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-size: 0.88rem;
}

.btn-icon {
    background: rgba(39, 126, 255, 0.12);
    color: var(--primary-dark);
    border: 1px solid rgba(39, 126, 255, 0.28);
    border-radius: 10px;
    padding: 0 16px;
    min-height: 42px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 800;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--primary);
    color: #ffffff;
}

/* ─── Progress Bar ─── */
.progress-container {
    width: 100%;
    max-width: 850px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.progress-bar-bg {
    flex-grow: 1;
    height: 8px;
    background: rgba(39, 126, 255, 0.12);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.3s ease;
}

.progress-text {
    font-family: var(--font-mono);
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-dim);
    white-space: nowrap;
}

/* ─── Quiz Options ─── */
.options-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
    flex-grow: 1;
}

.option {
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: var(--text-main);
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    padding: clamp(13px, 3vw, 18px);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: clamp(0.9rem, 2.4vw, 1.02rem);
    font-weight: 500;
}

.option:hover {
    background: #f8fbff;
    border-color: rgba(39, 126, 255, 0.45);
}

.option.selected {
    background: rgba(39, 126, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.option-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #94a3b8;
    flex-shrink: 0;
    transition: all 0.18s ease;
}

.option.selected .option-dot {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: inset 0 0 0 3px #ffffff;
}

.quiz-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.quiz-footer .btn { flex: 1; }

/* ─── Instructions Box ─── */
.folio-highlight-box {
    background: rgba(39, 126, 255, 0.06);
    padding: 20px;
    border-radius: 16px;
    border: 1.5px dashed rgba(39, 126, 255, 0.38);
    margin-bottom: 22px;
    text-align: center;
}

.folio-highlight-number {
    color: var(--primary-dark);
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.4rem;
}

.folio-highlight-sub {
    font-size: 0.88rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.instructions-list {
    text-align: left;
    color: var(--text-dim);
    margin-bottom: 28px;
    line-height: 1.6;
    list-style: none;
    padding: 0;
}

.instructions-list li {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.instructions-list strong {
    color: var(--text-main);
}

/* ─── Discreet Admin Footer & Modal ─── */
.discreet-footer {
    position: fixed;
    bottom: 10px;
    right: 10px;
    opacity: 0.25;
    transition: opacity 0.3s ease;
    z-index: 50;
}

.discreet-footer:hover { opacity: 1; }

.admin-dot-btn {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.modal {
    display: none !important;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex !important; }

.modal-content {
    max-width: 380px;
    width: 90%;
    text-align: center;
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ─── Soft Blue & Sky Aurora Background (Matches jovenesstem.com) ─── */
.bg-elements {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(90px);
    border-radius: 50%;
}

.blob-1 {
    width: 560px;
    height: 560px;
    background: rgba(39, 126, 255, 0.16);
    top: -180px;
    left: -140px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: rgba(14, 165, 233, 0.14);
    bottom: -140px;
    right: -120px;
}

.blob-3 {
    width: 380px;
    height: 380px;
    background: rgba(0, 168, 150, 0.08);
    top: 38%;
    left: 52%;
    transform: translate(-50%, -50%);
}

/* ─── Survey Form ─── */
.survey-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 20px 0 0;
    text-align: left;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label,
.toggle-item label {
    font-size: 0.84rem;
    color: var(--text-dim);
    font-weight: 700;
}

.toggle-group,
.mini-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.toggle-group .toggle-btn,
.mini-toggle .toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 9px 12px;
    min-height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.toggle-group .toggle-btn.active,
.mini-toggle .toggle-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(39, 126, 255, 0.28);
}

.toggle-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.toggle-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mini-toggle { width: fit-content; }
.mini-toggle .toggle-btn { padding: 6px 18px; min-width: 60px; }

/* ─── Score & Verdict Display ─── */
.score-display { margin: 22px 0 12px; }

.score-circle {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
}

#finalScore {
    font-size: clamp(3.2rem, 11vw, 5rem);
    font-weight: 900;
    color: var(--primary);
}

.score-total {
    font-size: clamp(1.1rem, 4vw, 1.7rem);
    font-weight: 700;
    color: var(--text-muted);
}

.visually-hidden {
    position: absolute;
    clip-path: inset(50%);
    overflow: hidden;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    white-space: nowrap;
}

.back-js-link:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.clerk-status-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(39, 126, 255, 0.08);
    border: 1px solid rgba(39, 126, 255, 0.25);
    color: var(--primary-dark);
    font-size: 0.86rem;
    font-weight: 600;
    text-align: center;
}

.verdict-card {
    text-align: left;
    margin: 22px 0;
    padding: 24px 22px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(39, 126, 255, 0.07) 0%, rgba(14, 165, 233, 0.06) 100%);
    border: 1.5px solid rgba(39, 126, 255, 0.24);
}

.verdict-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-dark);
    background: rgba(39, 126, 255, 0.11);
    border: 1px solid rgba(39, 126, 255, 0.24);
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 10px;
}

.verdict-title {
    font-size: clamp(1.12rem, 3vw, 1.35rem);
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.verdict-desc {
    font-size: 0.94rem;
    color: var(--text-dim);
    line-height: 1.55;
    margin: 0 0 12px 0;
}

.verdict-focus {
    font-size: 0.86rem;
    color: var(--text-dim);
    margin: 0 0 14px 0;
}

.verdict-focus strong {
    color: var(--primary-dark);
}

.verdict-disclaimer {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 12px 0 0 0;
    line-height: 1.45;
}

.verdict-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.verdict-actions .btn {
    width: auto;
    flex: 1;
    min-width: 220px;
    text-decoration: none;
}

.cat-breakdown-list {
    display: grid;
    gap: 12px;
    margin: 20px 0;
    text-align: left;
}

.cat-breakdown-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 16px;
}

.cat-breakdown-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.cat-breakdown-track {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.cat-breakdown-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(39, 126, 255, 0.10);
    border: 1px solid rgba(39, 126, 255, 0.25);
    color: var(--primary-dark);
}

/* ─── Responsive Breakpoints ─── */
@media (min-width: 600px) {
    #app {
        padding: 20px;
        padding-top: 96px;
    }
    .form-row { grid-template-columns: 1fr 1fr; }
    .toggle-grid { grid-template-columns: 1fr 1fr; }
    .quiz-card { min-height: 480px; }
}

@media (min-width: 900px) {
    .welcome-actions {
        flex-direction: row;
        align-items: stretch;
    }
    .welcome-actions .btn-primary { flex: 1; }
    .resume-box { flex: 1; }
}

@media (max-width: 420px) {
    .top-bar { padding: 8px 12px; }
    .quiz-footer { flex-direction: column; }
    .quiz-footer .btn { width: 100%; }
}
