/* ============================================
   Stealth Coach -- Design System & Styles
   Warm, friendly, mobile-first. MVP week.
   ============================================ */

/* ── CSS Custom Properties ─────────────── */
:root {
    /* Brand palette -- warm & trustworthy */
    --primary: #5B5FC7;          /* Warm indigo */
    --primary-dark: #4A4EB5;
    --primary-light: #7B7FD4;
    --primary-bg: #EEEEF9;

    --secondary: #8B5CF6;        /* Violet */
    --secondary-dark: #7C3AED;
    --secondary-light: #A78BFA;
    --secondary-bg: #F5F3FF;

    --accent: #F97066;           /* Coral -- energy, celebration */
    --accent-dark: #E85D52;
    --accent-bg: #FEF0EF;

    --success: #10B981;          /* Emerald */
    --success-dark: #059669;
    --success-bg: #ECFDF5;
    --success-border: #A7F3D0;

    --green: #10B981;
    --green-dark: #059669;
    --green-bg: #ECFDF5;
    --green-border: #A7F3D0;

    --warning: #F59E0B;          /* Amber */
    --warning-bg: #FFFBEB;
    --warning-border: #FDE68A;
    --warning-text: #92400E;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;

    /* Light theme surfaces -- warm whites */
    --bg: #FAFAF7;
    --surface: #FFFFFF;
    --surface-hover: #F5F5F0;
    --text: #1A1A2E;
    --text-primary: #1A1A2E;
    --text-secondary: #52526C;
    --text-muted: #9494A8;
    --border: #E8E8E0;
    --border-light: #F2F2EC;
    --surface-2: #F4F4EE;
    --surface-1: #F8F8F6;
    --surface-alt: #F4F4EE;
    --surface-secondary: #F4F4EE;

    /* Glass / gradients */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(232, 232, 224, 0.85);
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --gradient-accent: linear-gradient(135deg, var(--accent) 0%, #FB923C 100%);
    --gradient-success: linear-gradient(135deg, var(--success) 0%, #34D399 100%);
    --gradient-page: linear-gradient(160deg, #F8F7FF 0%, #EEEbFF 60%, #F3F0FF 100%);
    --gradient-scene: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);
    --quick-step-cool-bg: linear-gradient(135deg, #f7fbff 0%, #eef6ff 55%, #f4fbf5 100%);
    --quick-step-warm-bg: linear-gradient(135deg, #fff7ed 0%, #fffbeb 50%, #f0fdf4 100%);
    --quick-step-badge-bg: #ffffff;
    --quick-step-badge-border: #dbe8f5;
    --quick-step-badge-text: #1e3a5f;
    --quick-step-badge-warm-border: #f0dec8;
    --quick-step-badge-warm-text: #7c2d12;
    --quick-chip-hover-border: #9ac0e4;
    --quick-chip-hover-shadow: rgba(30, 58, 95, 0.1);
    --quick-chip-active-border: #1d4ed8;
    --quick-chip-active-bg: linear-gradient(135deg, #eff6ff 0%, #ecfeff 100%);
    --quick-chip-active-text: #1e3a8a;
    --quick-chip-active-shadow: rgba(29, 78, 216, 0.14);
    --quick-comm-hover-border: #f0b98a;
    --quick-comm-hover-shadow: rgba(124, 45, 18, 0.12);
    --quick-comm-active-border: #c2410c;
    --quick-comm-active-bg: linear-gradient(135deg, #fff7ed 0%, #fefce8 100%);
    --quick-comm-active-shadow: rgba(194, 65, 12, 0.16);
    --progress-snapshot-bg: #F0F4FF;
    --progress-snapshot-border: rgba(99, 102, 241, 0.15);

    /* Shadows -- warm tint */
    --shadow-sm: 0 1px 2px rgba(26, 26, 46, 0.05);
    --shadow: 0 2px 8px rgba(26, 26, 46, 0.07);
    --shadow-md: 0 8px 24px rgba(26, 26, 46, 0.09);
    --shadow-lg: 0 16px 40px rgba(26, 26, 46, 0.11);
    --shadow-xl: 0 24px 56px rgba(26, 26, 46, 0.14);

    /* Radii -- friendly, round */
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --max-width: 480px;             /* Mobile-optimized max width */
    --bottom-nav-height: 64px;

    /* -- Brand logo colours - "Fluent" one colour, "Gym" another --------
       Hard stop at 64% (~6/9 chars) so there is zero blending.
       Light mode: near-black / coral */
    --brand-grad: linear-gradient(
        90deg,
        #1A1A2E 0%, #1A1A2E 64%,
        #F97066 64%, #F97066 100%
    );
}

/* Dark mode tokens (auto, via OS preference) */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #121218;
        --surface: #1C1C26;
        --surface-hover: #26263A;
        --text: #F5F5F0;
        --text-primary: #F5F5F0;
        --text-secondary: #B8B8C8;
        --text-muted: #7E7E94;
        --border: #2E2E40;
        --border-light: #222232;
        --surface-2: #1E1E2B;
        --surface-1: #1A1A26;
        --surface-alt: #1E1E2B;
        --surface-secondary: #1E1E2B;
        --danger-border: rgba(239,68,68,0.3);

        --primary-bg: #1E1B3A;
        --secondary-bg: #2E1065;
        --accent-bg: #3A1A18;
        --success-bg: #0A2E20;
        --green-bg: #0A2E20;
        --warning-bg: #2E1A03;
        --danger-bg: #2E0A0A;

        --success-border: #065F46;
        --green-border: #065F46;
        --warning-border: #92400E;
        --warning-text: #FDE68A;

        --glass-bg: rgba(18, 18, 24, 0.85);
        --glass-border: rgba(46, 46, 64, 0.70);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
        --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
        --shadow-md: 0 12px 26px rgba(0, 0, 0, 0.50);
        --shadow-lg: 0 18px 36px rgba(0, 0, 0, 0.55);
        --shadow-xl: 0 28px 56px rgba(0, 0, 0, 0.60);

        --gradient-page: linear-gradient(160deg, #121218 0%, #17151F 60%, #1A1525 100%);
        --gradient-scene: linear-gradient(135deg, #0B1220 0%, #1E1B4B 100%);
        --quick-step-cool-bg: linear-gradient(135deg, #1A2234 0%, #1B2333 55%, #18281F 100%);
        --quick-step-warm-bg: linear-gradient(135deg, #2B1E16 0%, #2A2718 50%, #18281F 100%);
        --quick-step-badge-bg: #1B2231;
        --quick-step-badge-border: #344666;
        --quick-step-badge-text: #C8D9FF;
        --quick-step-badge-warm-border: #5A3C23;
        --quick-step-badge-warm-text: #FFD4B2;
        --quick-chip-hover-border: #4F6E9B;
        --quick-chip-hover-shadow: rgba(10, 15, 28, 0.55);
        --quick-chip-active-border: #6FA0FF;
        --quick-chip-active-bg: linear-gradient(135deg, #1A2A4A 0%, #183445 100%);
        --quick-chip-active-text: #D7E7FF;
        --quick-chip-active-shadow: rgba(5, 12, 24, 0.7);
        --quick-comm-hover-border: #8A5A37;
        --quick-comm-hover-shadow: rgba(8, 8, 12, 0.5);
        --quick-comm-active-border: #F59E0B;
        --quick-comm-active-bg: linear-gradient(135deg, #3D2514 0%, #2E2A1A 100%);
        --quick-comm-active-shadow: rgba(0, 0, 0, 0.6);
        --progress-snapshot-bg: #202A42;
        --progress-snapshot-border: rgba(147, 197, 253, 0.35);

        /* -- Brand logo colours - DARK MODE - white / coral, hard stop */
        --brand-grad: linear-gradient(
            90deg,
            #ffffff 0%, #ffffff 64%,
            #F97066 64%, #F97066 100%
        );
    }
}

/* ── Reset & Base ──────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── Typography ────────────────────────── */
h1 { font-family: var(--font-heading); font-size: 2rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.025em; }
h2 { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h3 { font-family: var(--font-heading); font-size: 1.25rem; font-weight: 600; line-height: 1.2; }
h4 { font-family: var(--font-heading); font-size: 1.1rem; font-weight: 600; line-height: 1.2; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

/* ── Layout ────────────────────────────── */
.app-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem;
    padding-top: 80px;
    /* Extra bottom padding accounts for safe-area on notched phones */
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 1.5rem);
    min-height: 100vh;
}
.app-container.no-nav {
    padding-top: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    background: var(--gradient-page);
    min-height: 100vh;
}
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.w-full { width: 100%; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.hidden { display: none !important; }

/* ── Navigation ────────────────────────── */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    height: 64px;
}
.navbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    display: flex; align-items: center; gap: 0.5rem;
    text-decoration: none; color: var(--text);
    font-weight: 400; font-size: 1.1rem;
}
.nav-brand:hover { text-decoration: none; }
.brand-icon { font-size: 1.5rem; }
.brand-icon-img { height: 40px; width: auto; max-width: 160px; object-fit: contain; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-bg); color: var(--primary); }
.nav-actions { display: flex; align-items: center; gap: 0.5rem; }
.nav-user-info { font-size: 0.875rem; color: var(--text-secondary); }
.nav-streak { font-weight: 600; color: var(--warning); }

/* ── Bottom Navigation (mobile) ───────── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--border);
    /* Stretch height to include safe-area on notched iPhones */
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex; align-items: stretch;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.bottom-nav-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 0.2rem;
    color: var(--text-muted);
    font-size: 0.65rem; font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: none; border: none;
    text-decoration: none !important;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    min-height: 44px; /* guaranteed touch target */
}
/* Active pill indicator at top of tab */
.bottom-nav-item::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 36px; height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--primary);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bottom-nav-item.active::before { transform: translateX(-50%) scaleX(1); }
.bottom-nav-item .nav-icon { font-size: 1.4rem; line-height: 1; transition: transform 0.2s ease; }
.bottom-nav-item:hover { color: var(--text-secondary); }
.bottom-nav-item:focus,
.bottom-nav-item:active,
.bottom-nav-item:focus-visible { outline: none; text-decoration: none !important; }
.bottom-nav-item span { text-decoration: none !important; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active .nav-icon { transform: scale(1.15) translateY(-1px); }

/* ── Cards ─────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-clickable:active { transform: scale(0.98); }
.card-header { margin-bottom: 1rem; }
.card-title { font-size: 1.1rem; font-weight: 600; }
.card-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem; }
.card-accent-left {
    border-left: 4px solid var(--primary);
    padding-left: calc(1.5rem - 4px);
}
.card-accent-left.green { border-left-color: var(--green); }
.card-accent-left.amber { border-left-color: var(--warning); }
.card-accent-left.pink { border-left-color: var(--secondary); }

/* ── Buttons ───────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    min-height: 44px; /* touch target */
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 10px 20px rgba(99,102,241,0.20);
}
.btn-primary:hover { filter: brightness(1.05) saturate(1.05); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(99,102,241,0.22), 0 10px 20px rgba(99,102,241,0.20); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline {
    background: transparent; color: var(--primary);
    border: 1.5px solid var(--primary);
    transition: var(--transition);
}
.btn-outline:hover { background: var(--primary-bg); box-shadow: 0 0 0 3px rgba(91,95,199,0.10); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-danger { background: var(--danger); color: white; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon {
    background: transparent; border: none; padding: 0.5rem;
    border-radius: var(--radius-sm); font-size: 1.25rem;
    color: var(--text-secondary); transition: var(--transition);
}
.btn-icon:hover { background: var(--surface-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Forms ─────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.consent-label {
    display: flex; align-items: flex-start; gap: 0.625rem;
    font-size: 0.82rem; color: var(--text); cursor: pointer; line-height: 1.5;
}
.consent-label input[type="checkbox"] {
    flex-shrink: 0; width: 1rem; height: 1rem; margin-top: 0.18rem;
    accent-color: var(--primary); cursor: pointer;
}
.consent-label a { color: var(--primary); text-decoration: underline; cursor: pointer; }
.form-label {
    display: block; font-size: 0.875rem; font-weight: 600;
    color: var(--text); margin-bottom: 0.375rem;
}
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-input, .form-select {
    width: 100%;
    padding: 0.75rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    transition: var(--transition);
    outline: none;
    min-height: 48px; /* touch target */
    -webkit-appearance: none; /* consistent on iOS */
    appearance: none;
}
.form-input:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(91,95,199,0.13), 0 1px 4px rgba(91,95,199,0.08);
    background: var(--surface);
}
.form-input::placeholder { color: var(--text-muted); }
/* Dropdown arrow for select elements */
select.form-input, select.form-select {
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
}

/* Compact phone code row used in register/profile forms */
.phone-input-row {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
    overflow: visible;
    position: relative;
}

.phone-input-row .phone-code-select {
    width: 100%;
    max-width: 100%;
    height: 48px !important;
    min-height: 48px !important;
    line-height: 1.1;
    font-size: 0.9rem;
    padding: 0.75rem 1.9rem 0.75rem 0.5rem;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.phone-input-row .phone-number-input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 48px !important;
    min-height: 48px !important;
    font-size: 0.9rem;
    padding: 0.75rem 0.875rem;
}

.phone-code-dropdown {
    position: relative;
    width: 100%;
    min-width: 0;
    z-index: 20;
}

.cc-trigger {
    cursor: pointer;
    width: 100%;
    height: 48px;
    min-height: 48px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1;
    padding: 0.75rem 1.2rem 0.75rem 0.5rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    position: relative;
}

.cc-trigger::after {
    content: '▾';
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
}

.phone-code-dropdown:focus-within .cc-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.12);
}

.cc-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 60;
    width: min(240px, 90vw);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    padding: 0.25rem 0.25rem 0.25rem;
}

.cc-search-wrap {
    padding: 0.1rem 0.1rem 0.3rem;
}

.cc-search-input {
    width: 100%;
    height: 28px;
    min-height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.76rem;
    padding: 0.2rem 0.45rem;
    outline: none;
}

.cc-search-input:focus {
    border-color: var(--primary);
}

.cc-options {
    max-height: 172px;
    overflow-y: auto;
    border-radius: 6px;
}

.cc-option {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-size: 0.82rem;
    line-height: 1.2;
    padding: 0.45rem 0.55rem;
    cursor: pointer;
}

.cc-option:hover,
.cc-option:focus-visible {
    background: var(--surface-alt, #f3f4f6);
    outline: none;
}

@media (max-width: 420px) {
    .phone-input-row {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .cc-trigger {
        font-size: 0.9rem;
        padding-right: 1.1rem;
    }

    .cc-menu {
        width: min(220px, 92vw);
    }

    .cc-options {
        max-height: 168px;
    }
}

/* ── Password toggle eye ─ */
.pw-wrapper { position: relative; }
.pw-wrapper .form-input { width: 100%; box-sizing: border-box; }
.pw-eye {
    position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%);
    cursor: pointer; color: var(--text-muted); display: flex; align-items: center;
    padding: 4px; border-radius: 4px; transition: color 0.15s;
}
.pw-eye:hover { color: var(--text); }

/* ── Selector Cards (for age group, level) ─ */
.selector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.selector-card {
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    background: var(--surface);
    min-height: 80px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.selector-card:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.selector-card.selected { border-color: var(--primary); background: var(--primary-bg); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.selector-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.selector-label { font-weight: 700; font-size: 1rem; }
.selector-sublabel { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.2rem; }
.selector-desc { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }
.selector-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Interest Chips (multi-select) ──────── */
.interest-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    max-height: 380px;
    overflow-y: auto;
    padding: 0.5rem 0;
}
.interest-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.85rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--surface);
    user-select: none;
}
.interest-chip:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.interest-chip.selected {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
    box-shadow: 0 0 0 2px rgba(91,95,199,0.15);
}
.interest-chip .chip-icon { font-size: 1.05rem; }
.interest-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}
.interest-count .count-num { font-weight: 700; color: var(--primary); }

/* ── Dashboard snapshot ─────────────────── */
.progress-snapshot-card {
    background: var(--progress-snapshot-bg);
    border: 1px solid var(--progress-snapshot-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.todays-focus-card {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
}

.todays-focus-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex: 0 0 auto;
    margin-top: 1px;
}

.todays-focus-body {
    flex: 1;
    min-width: 0;
}

.todays-focus-title {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--warning-text);
    margin-bottom: 0.2rem;
}

.todays-focus-text {
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--warning-text);
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: normal;
}

.todays-focus-visual {
    margin-top: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: rgba(0,0,0,0.04);
    color: var(--warning-text);
    font-size: 0.8rem;
    line-height: 1.5;
}

@media (max-width: 420px) {
    .todays-focus-card {
        padding: 0.78rem 0.85rem;
        gap: 0.52rem;
    }

    .todays-focus-visual {
        font-size: 0.76rem;
    }
}

/* ── Quick placement / intro screens ───── */
.quick-placement-shell {
    max-width: 760px;
    margin: 2rem auto 1.5rem;
    padding: 0 1rem;
}

.quick-placement-card {
    padding: 0;
    overflow: hidden;
    border-radius: 1rem;
}

.quick-step-header {
    padding: 1.1rem 1.1rem 0.7rem;
    border-bottom: 1px solid var(--border);
}

.quick-step-header.cool { background: var(--quick-step-cool-bg); }
.quick-step-header.warm { background: var(--quick-step-warm-bg); }

.quick-step-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.24rem 0.58rem;
    border-radius: 999px;
    background: var(--quick-step-badge-bg);
    border: 1px solid var(--quick-step-badge-border);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--quick-step-badge-text);
}

.quick-step-badge.warm {
    border-color: var(--quick-step-badge-warm-border);
    color: var(--quick-step-badge-warm-text);
}

.quick-step-icon {
    font-size: 2rem;
    margin-top: 0.45rem;
}

.quick-step-title {
    margin: 0.2rem 0 0.15rem;
    line-height: 1.25;
}

.quick-step-subtext {
    line-height: 1.55;
    margin: 0 0 0.35rem;
}

.quick-step-body {
    padding: 1rem 1.1rem 1.15rem;
}

.quick-step-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.62rem;
}

.quick-step-meta-label {
    font-size: 0.79rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.quick-step-meta-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.quick-pref-theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.6rem;
    max-width: 100%;
}

.quick-interest-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 0.75rem;
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    justify-content: center;
    min-height: 2.6rem;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    flex-wrap: wrap;
    flex-direction: column;
}

.quick-interest-chip:hover {
    transform: translateY(-2px);
    border-color: var(--quick-chip-hover-border);
    box-shadow: 0 5px 14px var(--quick-chip-hover-shadow);
}

.quick-interest-chip.active {
    border-color: var(--quick-chip-active-border);
    background: var(--quick-chip-active-bg);
    color: var(--quick-chip-active-text);
    box-shadow: 0 7px 16px var(--quick-chip-active-shadow);
}

.quick-interest-chip .chip-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
}

.quick-interest-chip .chip-label {
    font-size: 0.9rem;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    font-weight: 600;
}

.quick-comm-level-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.comm-style-card {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 0.9rem;
    padding: 0.8rem 0.78rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    text-align: left;
    cursor: pointer;
    transition: all .18s ease;
    min-height: 122px;
}

.comm-style-card:hover {
    transform: translateY(-1px);
    border-color: var(--quick-comm-hover-border);
    box-shadow: 0 8px 18px var(--quick-comm-hover-shadow);
}

.comm-style-card.active {
    border-color: var(--quick-comm-active-border);
    background: var(--quick-comm-active-bg);
    box-shadow: 0 9px 20px var(--quick-comm-active-shadow);
}

@media (max-width: 768px) {
    .quick-pref-theme-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .quick-interest-chip {
        padding: 0.55rem 0.7rem;
        font-size: 0.85rem;
        min-height: 2.4rem;
    }

    .quick-interest-chip .chip-icon { font-size: 1.15rem; }
    .quick-interest-chip .chip-label { font-size: 0.85rem; }
}

@media (max-width: 640px) {
    .quick-comm-level-grid { grid-template-columns: 1fr; }
    .comm-style-card { min-height: 0; }
}

@media (max-width: 480px) {
    .quick-pref-theme-grid {
        grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
        gap: 0.45rem;
    }

    .quick-interest-chip {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
        min-height: 2.3rem;
    }

    .quick-interest-chip .chip-icon { font-size: 1rem; }
    .quick-interest-chip .chip-label { font-size: 0.8rem; font-weight: 600; }
}

/* ── Badges ────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-accent { background: var(--accent-bg); color: var(--accent-dark); }
.badge-success { background: var(--success-bg); color: var(--success-dark); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-secondary { background: var(--secondary-bg); color: var(--secondary); }
.badge-muted { background: var(--border-light); color: var(--text-secondary); }

/* ── Profile Chips ─────────────────────── */
.profile-chip {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--border-light);
    color: var(--text-secondary);
    border: 1.5px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
}
.profile-chip--selected {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary);
    font-weight: 600;
}
.profile-chip--related {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border);
    padding-right: 0.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.profile-chip--excluded {
    background: transparent;
    color: var(--text-muted, #aaa);
    border-color: var(--border-light);
    opacity: 0.65;
    padding-right: 0.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.profile-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1;
    padding: 0 0.1rem;
    color: inherit;
    opacity: 0.6;
    border-radius: var(--radius-full);
    transition: opacity 0.1s;
}
.profile-chip-remove:hover { opacity: 1; }
.profile-chip-remove--add {
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.7;
}
.profile-chip[onclick]:hover {
    border-color: var(--primary);
}

/* ── Stat Cards ────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-value-bump {
    animation: stat-value-bump 380ms ease;
}
.stat-value-positive-flash {
    animation: stat-value-positive-flash 520ms ease;
}
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; font-weight: 500; }
.stat-sublabel { font-size: 0.68rem; color: var(--text-secondary); margin-top: 0.1rem; opacity: 0.8; }
.stat-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }

@keyframes stat-value-bump {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.16); }
    70%  { transform: scale(0.96); }
    100% { transform: scale(1); }
}

@keyframes stat-value-positive-flash {
    0% {
        color: var(--text);
        text-shadow: none;
    }
    35% {
        color: var(--success, #16a34a);
        text-shadow: 0 0 14px rgba(34, 197, 94, 0.45);
    }
    100% {
        color: var(--text);
        text-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stat-value-bump {
        animation: none;
    }
    .stat-value-positive-flash {
        animation: none;
    }
}

/* ── Daily Journal accordion ─────────────── */
.ds-list { display: flex; flex-direction: column; gap: 0.4rem; }
.ds-item { 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    overflow: visible;
    height: auto;
}
.ds-item-today { 
    border: 1px solid var(--primary) !important;
    border-radius: 8px !important;
}
.ds-header {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; min-height: 3.25rem; padding: 0.65rem 0.85rem;
    background: var(--surface); border: none; cursor: pointer;
    text-align: left;
    border-radius: 8px;
}
.ds-item-today .ds-header { background: rgba(99,102,241,0.06); }
.ds-date-block { display: flex; flex-direction: column; gap: 0.1rem; }
.ds-day-name { font-weight: 700; font-size: 0.85rem; color: var(--text); line-height: 1.2; }
.ds-date-str { font-size: 0.75rem; color: var(--text-muted); line-height: 1.2; }
.ds-right { display: flex; align-items: center; gap: 0.5rem; }
.ds-chevron { font-size: 0.8rem; color: var(--text-muted); transition: transform 0.2s; }
.ds-body { 
    padding: 0.75rem 0.85rem; 
    background: var(--bg); 
    border-top: 1px solid var(--border-light);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}
.ds-list-scroll {
    height: calc((3.25rem * 5) + (0.4rem * 4));
    overflow-y: auto;
    padding-right: 0.15rem;
}
.ds-score-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.ds-score-label { font-size: 0.75rem; color: var(--text-secondary); width: 5rem; flex-shrink: 0; }
.ds-score-bar-wrap { flex: 1; background: var(--border-light); border-radius: 99px; height: 6px; overflow: hidden; }
.ds-score-bar { height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.ds-score-val { font-size: 0.75rem; font-weight: 700; color: var(--text); width: 2.5rem; text-align: right; }
.ds-milestone-badge { font-size: 0.78rem; font-weight: 700; color: var(--warning); margin-bottom: 0.5rem; }
.ds-stage-change { font-size: 0.78rem; font-weight: 600; margin-top: 0.35rem; color: var(--accent); }
.ds-analysis-label { font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); margin: 0.5rem 0 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ds-section-label { font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); margin: 0 0 0.35rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ds-vocab-row { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.15rem; }
.ds-vocab-chip { font-size: 0.78rem; font-weight: 600; padding: 0.2rem 0.55rem; background: transparent; color: var(--primary); border-radius: 99px; border: 1px solid var(--primary); }
.ds-stat-muted { color: var(--text-muted) !important; }
.ds-bullets { margin: 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--text-secondary); display: flex; flex-direction: column; gap: 0.15rem; }
.ds-narration { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.55; font-style: italic; margin-top: 0.25rem; }
.ds-stat { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.25rem; }
.ds-processing { font-size: 0.82rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; }

/* ── Welcome legacy (keep for safety) ──── */
.welcome-login { font-size: 0.9rem; color: var(--text-secondary); }
.welcome-login a { font-weight: 600; }

/* ── Hero Page -- redesigned landing ─────── */
.hero-page {
    position: relative;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1.5rem;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    text-align: center;
    background: #f8faff;
}

/* Floating orbs */
.hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
    animation: orb-float linear infinite;
}
.hero-orb-1 {
    width: 380px; height: 380px;
    background: radial-gradient(circle, #c7d2fe, #a5b4fc);
    top: -80px; left: -100px;
    animation-duration: 20s;
    animation-name: orb-float-1;
}
.hero-orb-2 {
    width: 300px; height: 300px;
    background: radial-gradient(circle, #bbf7d0, #6ee7b7);
    bottom: -60px; right: -80px;
    animation-duration: 24s;
    animation-name: orb-float-2;
}
.hero-orb-3 {
    width: 220px; height: 220px;
    background: radial-gradient(circle, #fbcfe8, #f9a8d4);
    top: 40%; right: -40px;
    animation-duration: 18s;
    animation-name: orb-float-3;
}
.hero-orb-4 {
    width: 180px; height: 180px;
    background: radial-gradient(circle, #fed7aa, #fbbf24);
    bottom: 20%; left: -30px;
    animation-duration: 22s;
    animation-name: orb-float-4;
}

@keyframes orb-float-1 {
    0%   { transform: translate(0px, 0px) scale(1); }
    33%  { transform: translate(60px, 80px) scale(1.08); }
    66%  { transform: translate(30px, 140px) scale(0.94); }
    100% { transform: translate(0px, 0px) scale(1); }
}
@keyframes orb-float-2 {
    0%   { transform: translate(0px, 0px) scale(1); }
    33%  { transform: translate(-70px, -50px) scale(1.1); }
    66%  { transform: translate(-40px, -120px) scale(0.92); }
    100% { transform: translate(0px, 0px) scale(1); }
}
@keyframes orb-float-3 {
    0%   { transform: translate(0px, 0px) scale(1); }
    50%  { transform: translate(-80px, -60px) scale(1.12); }
    100% { transform: translate(0px, 0px) scale(1); }
}
@keyframes orb-float-4 {
    0%   { transform: translate(0px, 0px) scale(1); }
    50%  { transform: translate(60px, -80px) scale(1.06); }
    100% { transform: translate(0px, 0px) scale(1); }
}

/* Keep content above orbs */
.hero-brand,
.hero-content {
    position: relative;
    z-index: 1;
}

@keyframes hero-bg-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@media (prefers-color-scheme: dark) {
    .hero-page { background: #0d0f1a; }
    .hero-orb-1 { background: radial-gradient(circle, #3730a3, #4338ca); opacity: 0.35; }
    .hero-orb-2 { background: radial-gradient(circle, #065f46, #047857); opacity: 0.35; }
    .hero-orb-3 { background: radial-gradient(circle, #9d174d, #be185d); opacity: 0.3; }
    .hero-orb-4 { background: radial-gradient(circle, #92400e, #b45309); opacity: 0.3; }
}

/* Brand -- compact top section */
.hero-brand {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 1.5rem;
    padding-bottom: 0.5rem;
    gap: 0.4rem;
}
.hero-brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: contain;
    flex-shrink: 0;
}
.hero-brand-logo {
    height: 72px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
}
.brand-logo {
    height: 48px;
    width: auto;
    display: block;
    margin: 0 auto 0.75rem;
    object-fit: contain;
}
.brand-text-logo {
    font-family: 'Rakkas', cursive;
    font-weight: 400 !important;
    color: var(--text);
    line-height: 1;
    display: inline-block;
    height: auto !important;
    width: auto !important;
    object-fit: unset !important;
}
/* Two-tone brand: Fluent = solid text colour, Gym = primary gradient */
.brand-fluent { color: #1A1A2E; }
.hero-page .brand-fluent, .hero-brand .brand-fluent { color: #ffffff; }
.brand-gym {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
@media (prefers-color-scheme: dark) {
    .brand-fluent { color: #ffffff; }
}
.brand-text-logo.brand-icon-img { font-size: 1.6rem; }
.brand-text-logo.hero-brand-logo { font-size: 2.8rem; display: block; }
.brand-text-logo.brand-logo { font-size: 2.2rem; display: block; }
@media (prefers-color-scheme: dark) {
    .hero-brand-logo:not(.brand-text-logo),
    .brand-logo:not(.brand-text-logo),
    .brand-icon-img:not(.brand-text-logo) { filter: invert(1) brightness(2); }
}
.hero-brand-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 2.25rem;
    color: var(--text);
    letter-spacing: -0.03em;
}

/* Main content -- bottom half */
.hero-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    width: 100%;
    max-width: 420px;
    padding-bottom: 0.5rem;
}

.hero-headline {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text);
    margin: 0;
}
.hero-headline-accent {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    line-height: 1.5;
    margin: 0;
    max-width: 320px;
}

/* ── Feature strip (auto-scroll marquee) ─── */
.hero-features-strip {
    width: 100%;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 14%, black 86%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 14%, black 86%, transparent 100%);
    margin: 0;
}
.hero-features-track {
    display: flex;
    gap: 0.75rem;
    width: max-content;
    animation: hfc-scroll 22s linear infinite;
}
.hero-features-track:hover {
    animation-play-state: paused;
}
@keyframes hfc-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
.hfc-card {
    width: 138px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.05rem 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.hfc-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.14);
}
/* Per-card left accent */
.hfc-card:nth-child(4n+1) { border-left: 3px solid #6366F1; }
.hfc-card:nth-child(4n+2) { border-left: 3px solid #8B5CF6; }
.hfc-card:nth-child(4n+3) { border-left: 3px solid #EC4899; }
.hfc-card:nth-child(4n+4) { border-left: 3px solid #10B981; }
.hfc-icon-ring {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    margin-bottom: 0.45rem;
    flex-shrink: 0;
}
.hfc-ring-1 { background: rgba(99,  102, 241, 0.13); }
.hfc-ring-2 { background: rgba(139,  92, 246, 0.13); }
.hfc-ring-3 { background: rgba(236,  72, 153, 0.13); }
.hfc-ring-4 { background: rgba( 16, 185, 129, 0.13); }
.hfc-stat {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 0.2rem;
}
.hfc-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.2;
    margin-bottom: 0.3rem;
}
.hfc-benefit {
    font-size: 0.67rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.35;
}
@media (prefers-color-scheme: dark) {
    .hfc-ring-1 { background: rgba(99,  102, 241, 0.22); }
    .hfc-ring-2 { background: rgba(139,  92, 246, 0.22); }
    .hfc-ring-3 { background: rgba(236,  72, 153, 0.22); }
    .hfc-ring-4 { background: rgba( 16, 185, 129, 0.22); }
}

/* Primary CTA */
.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 2.25rem;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    width: 100%;
    max-width: 320px;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.45), 0 0 0 1px rgba(139,92,246,0.25);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
    letter-spacing: -0.01em;
}
.hero-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.60), 0 0 0 1px rgba(139,92,246,0.35);
    filter: brightness(1.06);
}
.hero-cta:active { transform: scale(0.97) translateY(0); }
.hero-cta-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}
.hero-cta-secondary {
    background: transparent;
    color: var(--primary);
    box-shadow: none;
    border: 1.5px solid #6366F1;
    margin-top: 0;
    font-weight: 600;
    font-size: 0.95rem;
}
.hero-cta-secondary:hover {
    background: var(--surface-2, rgba(99,102,241,0.07));
    box-shadow: none;
    filter: none;
    transform: none;
    color: var(--primary);
    border-color: var(--primary);
}
.hero-cta-arrow {
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}
.hero-cta:hover .hero-cta-arrow { transform: translateX(3px); }

/* ── Progress Hero Header ─────────────── */
.progress-hero-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.4rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.progress-hero-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0.06;
    pointer-events: none;
}
.progress-hero-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(91,95,199,0.25));
}
.progress-hero-text { display: flex; flex-direction: column; gap: 0.3rem; }
.progress-hero-title {
    font-size: 1.35rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin: 0;
}
.progress-hero-meta { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.progress-hero-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}
.progress-hero-divider {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}
.progress-meta-pill {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-full);
    padding: 0.15rem 0.6rem;
    opacity: 0.85;
}

/* ── Page Header ───────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header-with-back { display: flex; align-items: center; gap: 0.75rem; }
.back-btn {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 1.1rem;
    cursor: pointer; transition: var(--transition);
    box-shadow: var(--shadow-sm);
}
.back-btn:hover { background: var(--primary-bg); border-color: var(--primary-light); color: var(--primary); box-shadow: var(--shadow); }
.page-title {
    font-size: 1.5rem; font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
/* Reset gradient clip for emoji so they render as real colored emoji on all devices */
.page-title .page-title-icon {
    -webkit-text-fill-color: initial;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
    display: inline-block;
    font-style: normal;
}
.page-subtitle { font-size: 0.9rem; color: var(--text-secondary); }

/* ── Dashboard ─────────────────────────── */
.dash-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    position: relative;
    overflow: hidden;
}
.dash-hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.dash-hero-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.dash-greeting { font-size: 1.35rem; font-weight: 700; color: var(--text); flex: 1; min-width: 0; }
.dash-streak {
    background: var(--accent-bg);
    color: var(--accent-dark);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 700; font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.dash-date { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; margin: 0.25rem 0; }
.dash-meta { font-size: 0.85rem; color: var(--text-muted); }
.dash-meta span { margin-right: 0.75rem; }
.dash-section-title {
    font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 0.75rem; margin-top: 0.25rem;
}
/* Step progress indicator */
.drill-steps {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 1rem; justify-content: center;
}
.drill-step {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: var(--transition);
}
.drill-step.active { background: var(--primary); width: 28px; border-radius: var(--radius-full); }
.drill-step.done { background: var(--success); }

/* ── Drill Cards (on Dashboard) ────────── */
@keyframes next-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(91,95,199,0.22), var(--shadow); }
    50%       { box-shadow: 0 0 0 6px rgba(91,95,199,0.10), var(--shadow); }
}
.drill-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-left: 4px solid var(--border); /* overridden per-drill below */
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.1rem 1.1rem 1rem;
    display: flex; align-items: center; gap: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 0.75rem;
    position: relative; overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    min-height: 72px; /* guaranteed tap target */
}
.drill-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.drill-card:active { transform: scale(0.98); }
/* Per-drill accent colours */
.drill-card.drill-1 { border-left-color: var(--primary); }
.drill-card.drill-2 { border-left-color: var(--secondary); }
.drill-card.drill-3 { border-left-color: var(--success); }
.drill-card.completed { border-color: var(--success); border-left-color: var(--success); background: var(--success-bg); }
.drill-card.completed .drill-status { color: var(--success); }
/* Next drill pulses gently to draw attention */
.drill-card.next {
    border-color: var(--primary-light); border-left-color: var(--primary);
    animation: next-glow 2.4s ease infinite;
}
.drill-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; flex-shrink: 0;
    background: var(--primary-bg);
}
.drill-card.completed .drill-icon { background: var(--success-bg); }
.drill-info { flex: 1; min-width: 0; }
.drill-name { font-weight: 700; font-size: 0.95rem; }
.drill-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-status {
    font-size: 0.75rem; font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Drill card -- animated start arrow ── */
@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50%       { transform: translateX(6px); opacity: 0.55; }
}
.drill-arrow {
    display: flex; align-items: center; gap: 1px; flex-shrink: 0;
}
.drill-arrow span {
    display: inline-block;
    font-size: 1.2rem; line-height: 1;
    color: var(--primary); font-weight: 800;
    animation: arrowBounce 0.85s ease-in-out infinite;
}
.drill-arrow span:nth-child(2) { animation-delay: 0.13s; }
.drill-arrow span:nth-child(3) { animation-delay: 0.26s; }
.drill-arrow--locked span {
    animation: none;
    color: var(--text-muted);
    opacity: 0.45;
    font-size: 1rem;
}

/* ── Drill card -- done tick ── */
.drill-done-tick {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(34,197,94,0.35);
}

/* ── Drill Detail Pages ────────────────── */
.drill-page { padding-bottom: 2rem; }
.drill-content-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1rem;
    box-shadow: inset 0 2px 8px rgba(99,102,241,0.04), var(--shadow-sm);
}
.drill-passage {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-line;
    text-align: justify;
}
.drill-passage .karaoke-word {
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    border-radius: 0.35rem;
    padding: 0.02rem 0.08rem;
}
.drill-passage .karaoke-word.is-spoken {
    color: var(--success);
}
.drill-passage .karaoke-word.is-current {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}
.drill-passage .karaoke-word.is-current.is-miss {
    color: var(--warning);
    text-decoration-style: wavy;
}
.drill-passage .vocab-highlight {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-weight: 600;
}
/* ── Mystery Word Reveal (Drill 2) ── */
.vocab-blank {
    display: inline-block;
    cursor: pointer;
    position: relative;
    text-align: center;
    vertical-align: baseline;
}
.vocab-blank .blank-slot {
    display: inline-block;
    border: 2px dashed var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.15rem 0.7rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 0.95em;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
    min-width: 3.5rem;
    text-align: center;
}
.vocab-blank .blank-slot:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}
.vocab-blank .blank-hint {
    display: block;
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-muted);
    margin-top: 0.15rem;
    margin-bottom: 0.3rem;
    line-height: 1.3;
}
.vocab-blank.revealed .blank-slot {
    border: none;
    background: var(--success-bg);
    color: var(--success-dark);
    animation: word-reveal 0.5s ease;
    letter-spacing: 0;
}
.vocab-blank.revealed .blank-slot.revealed-word {
    font-weight: 700;
    font-size: 1em;
    padding: 0.15rem 0.4rem;
}
.vocab-blank.revealed .blank-hint {
    display: none;
}
@keyframes word-reveal {
    0%   { transform: scale(0.8); opacity: 0; }
    60%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
}

.grammar-nudge {
    /* margin-top: 1rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #FFF9E6, #FFF3CC);
    border-left: 3px solid #F5A623;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.9rem;
    color: #7A6B2A;
    line-height: 1.5; */
    display: none;
}
.grammar-nudge em { font-style: italic; }

/* ── Drill Page Step Sections (Drill 1 sequential UI) ── */
.drill-step-section {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: border-left-color 0.4s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    box-shadow: var(--shadow-sm);
}
#drill1-step-record { border-left-color: var(--secondary); }
.drill-step-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
.step-badge-2 { background: var(--secondary); }
.drill-step-locked {
    opacity: 0.45;
    pointer-events: none;
}

.drill-actions {
    display: flex; gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.drill-actions #d3-analysis-panel {
    width: 100%;
    flex: 0 0 100%;
}

/* ── Vocab Cards ───────────────────────── */
.vocab-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
}
.vocab-word {
    font-size: 1.25rem; font-weight: 700;
    color: var(--primary);
    display: flex; align-items: center; gap: 0.5rem;
}
.vocab-pos { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); font-style: italic; }
.vocab-hindi { font-size: 0.9rem; color: var(--accent); margin-top: 0.35rem; font-style: italic; }
.vocab-def { font-size: 0.95rem; color: var(--text); margin-top: 0.5rem; }
.vocab-examples { margin-top: 0.5rem; }
.vocab-example {
    font-size: 0.85rem; color: var(--text-secondary);
    padding-left: 0.75rem;
    border-left: 2px solid var(--primary-light);
    margin-bottom: 0.375rem;
    font-style: italic;
}
.vocab-synonyms {
    display: flex; flex-wrap: wrap; gap: 0.375rem;
    margin-top: 0.5rem;
}

/* ── Free Speak / Buddy Speak Scene ────── */
.scene-card {
    background: var(--gradient-scene);
    border-radius: var(--radius-lg);
    padding: 2rem;
    color: white;
    margin-bottom: 1rem;
}
.scene-card.has-image {
    padding: 0;
    overflow: hidden;
}
.scene-card.has-image img {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
}
.scene-card .image-credit {
    font-size: 0.65rem;
    opacity: 0.6;
    padding: 0.25rem 0.75rem;
    text-align: right;
}
.scene-card .image-fallback {
    font-size: 1.3rem;
    line-height: 2;
    text-align: center;
    padding: 2rem 1rem;
}
.scene-title { font-weight: 600; opacity: 0.8; font-size: 0.85rem; margin-bottom: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; }
.scene-text { font-size: 1.05rem; line-height: 1.8; }

/* Buddy chat bubble */
.buddy-bubble {
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-lg);
    border-top-left-radius: 4px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    position: relative;
}
.buddy-bubble .buddy-avatar {
    font-size: 1.3rem;
    margin-right: 0.5rem;
}
.buddy-bubble .buddy-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}
.buddy-bubble .buddy-text {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.6;
}

/* Buddy narration (post-submission) */
.buddy-narration {
    background: linear-gradient(135deg, var(--success-bg) 0%, var(--green-bg) 100%);
    border: 1px solid var(--success-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1rem;
}
.buddy-narration .narr-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.buddy-narration .narr-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}
.buddy-narration .narr-text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    border-radius: 0.5rem;
    transition: background 0.4s ease, color 0.4s ease, padding 0.3s ease;
}
.buddy-narration .narr-text .karaoke-word {
    transition: color 0.15s ease;
}
.buddy-narration .narr-text .karaoke-word.is-current {
    color: var(--primary, #6366F1);
}
.buddy-narration .narr-text .karaoke-word.is-spoken {
    color: var(--text, #111);
}
.buddy-narration .tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--gradient-success);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.75rem;
}
/* When the attention-pulse animation temporarily replaces the green gradient with
   a light surface / primary-bg, text must still be legible. Using text-primary
   (near-black in light mode, near-white in dark mode) works on all backgrounds. */
.buddy-narration .tts-btn.tts-btn-attention { color: var(--text-primary); }
.buddy-narration .tts-btn:hover { filter: brightness(1.05) saturate(1.05); }
.buddy-narration .tts-btn.speaking { background: var(--gradient-success); color: white; border: none; opacity: 0.8; animation: buddy-pulse 1.5s ease infinite; }
.buddy-narration .tts-btn.tts-btn-attention { background: var(--gradient-success); color: white; border: none; animation: buddy-attention 1.3s ease infinite; }
@keyframes buddy-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
    50%      { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
}
@keyframes buddy-pulse {
    0%, 100% { opacity: 0.8; }
    50%      { opacity: 1; }
}

/* Drill 3 — Analysing speech skeleton */
.d3-analysing-card {
    text-align: center;
    padding: 1.5rem 1rem 1.2rem;
    background: var(--surface-2, #F3F4F6);
    border-radius: 1rem;
    margin-bottom: 0.75rem;
}
.d3-analysing-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border, #E5E7EB);
    border-top-color: var(--primary, #6366F1);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
    margin: 0 auto 0.85rem;
}
.d3-analysing-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}
.d3-analysing-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    transition: opacity 0.3s ease;
}
.d3-skel-row {
    background: var(--surface-2, #F3F4F6);
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Vocab reminder badges */
.vocab-reminder {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1rem;
}
.vocab-reminder .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 100%;
    margin-bottom: 0.125rem;
}
.vocab-reminder .vocab-badge {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.vocab-reminder .vocab-badge.used {
    background: var(--green-bg);
    border-color: var(--green-border);
    color: var(--text);
}

/* Hindi OK badge */
.hindi-ok-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-full);
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}

/* Hindi nudge cards */
.hindi-nudge {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.375rem;
    font-size: 0.85rem;
    color: var(--text);
}
.hindi-nudge .hindi-word { font-weight: 700; }
.hindi-nudge .english-word { font-weight: 600; color: var(--success); }

/* Analysis detail grid */
/* ── Feedback Bullets (encouraging drill results) ── */
.feedback-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}
.feedback-bullet {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.375rem;
    font-size: 0.88rem;
}
.fb-emoji { font-size: 1.15rem; flex-shrink: 0; }
.fb-text { flex: 1; }
.fb-score { font-size: 0.75rem; font-weight: 700; opacity: 0.6; }
.fb-excellent { background: var(--success-bg); color: var(--success-dark); }
.fb-good { background: var(--primary-bg); color: var(--primary); }
.fb-okay { background: var(--warning-bg); color: var(--warning); }
.fb-growing { background: var(--danger-bg); color: var(--danger); }
.fb-info { background: var(--surface); color: var(--text-secondary); }
.fb-trend { font-size: 0.7rem; font-weight: 600; margin-left: auto; white-space: nowrap; }
.fb-trend-up { color: #16a34a; }
.fb-trend-down { color: var(--warning); }
.fb-trend-same { color: var(--text-muted); opacity: 0.7; }

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.analysis-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    text-align: center;
}
.analysis-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}
.analysis-stat .stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.125rem;
}
.task-card {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.task-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.task-text { font-weight: 600; color: var(--text); }
.hints-section { margin-bottom: 1rem; }
.hints-toggle {
    font-size: 0.875rem; font-weight: 600; color: var(--primary);
    cursor: pointer; display: flex; align-items: center; gap: 0.375rem;
    margin-bottom: 0.5rem; background: none; border: none;
}
.hint-item {
    font-size: 0.85rem; color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 0.375rem;
}

/* ── Milestone / Quiz ──────────────────── */
.quiz-progress {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.quiz-progress-bar {
    flex: 1; height: 8px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}
.quiz-progress-text { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.question-number { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; }
.question-text { font-size: 1.05rem; font-weight: 500; margin-bottom: 1rem; line-height: 1.5; }
.question-type-badge { display: inline-block; margin-bottom: 0.5rem; }
.options-list { display: flex; flex-direction: column; gap: 0.5rem; }
.option-btn {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    text-align: left; width: 100%;
}
.option-btn:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.option-btn.selected { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.option-btn.correct { border-color: var(--success); background: var(--success-bg); color: var(--text); }
.option-btn.incorrect { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.option-letter {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--border-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 600; flex-shrink: 0;
}
.option-btn.selected .option-letter { background: var(--primary); color: white; }
.quiz-nav { display: flex; justify-content: space-between; margin-top: 1.5rem; }

/* ── Results Card ──────────────────────── */
.results-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
}
.results-score {
    font-size: 3rem; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.results-label { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1.5rem; }
.results-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; text-align: center; }
.results-item-value { font-size: 1.5rem; font-weight: 700; }
.results-item-label { font-size: 0.8rem; color: var(--text-secondary); }
.level-change {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-weight: 700; font-size: 1rem;
    margin-bottom: 1rem;
}
.level-change.promoted { background: var(--success-bg); color: var(--text); }
.level-change.maintained { background: var(--primary-bg); color: var(--primary); }
.level-change.demoted { background: var(--danger-bg); color: var(--danger); }

/* ── Milestone v3: Section Progress Dots ─── */
.ms-section-progress {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem 0 1.7rem;
    padding: 0.35rem 0.25rem 0;
}
.ms-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 84px;
}
.ms-dot {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.22s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}
.ms-dot.active {
    border-color: var(--primary);
    background: linear-gradient(180deg, var(--primary-bg), var(--surface));
    box-shadow: 0 7px 14px rgba(14, 116, 144, 0.2);
}
.ms-dot.done {
    border-color: var(--success);
    background: var(--success-bg);
    box-shadow: 0 7px 14px rgba(22, 163, 74, 0.18);
}
.ms-dot-index {
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--text-secondary);
    line-height: 1;
}
.ms-dot.active .ms-dot-index { color: var(--primary); }
.ms-dot.done .ms-dot-index { color: var(--success); }
.ms-step-label {
    margin-top: 0.45rem;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary);
    text-align: center;
    max-width: 84px;
}
.ms-dot.active + .ms-step-label { color: var(--primary); }
.ms-dot.done + .ms-step-label { color: var(--success); }
.ms-dot-line {
    width: 46px;
    height: 4px;
    border-radius: 999px;
    margin-top: 20px;
    background: var(--border-light);
    transition: background-color 0.22s ease;
}
.ms-dot-line.done {
    background: var(--success);
}

@media (max-width: 640px) {
    .ms-section-progress {
        gap: 0.3rem;
        margin-bottom: 1.3rem;
    }
    .ms-step { min-width: 72px; }
    .ms-dot {
        width: 38px;
        height: 38px;
    }
    .ms-step-label {
        font-size: 0.62rem;
        max-width: 72px;
    }
    .ms-dot-line {
        width: 24px;
        margin-top: 17px;
    }
}

/* ── Retell Card ─────────────────────── */
.retell-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.5rem;
}
.retell-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.75rem;
}
.retell-card-header h3 { margin: 0; font-size: 1.1rem; }
.retell-instructions {
    color: var(--text-secondary); font-size: 0.9rem;
    margin-bottom: 1rem; line-height: 1.5;
}
.retell-listen-row { text-align: center; }

/* ── 3-column Results Breakdown ────────── */
.results-breakdown-3 {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 1rem; margin-bottom: 1.5rem; text-align: center;
}
.results-item-weight {
    font-size: 0.7rem; color: var(--text-muted);
    font-weight: 600; margin-top: 0.15rem;
}

/* ── Milestone Deep Report ─────────────── */
.ms-result-root {
    max-width: 560px; margin: 0 auto;
    padding: 0 0 3rem;
}
.ms-result-hero {
    text-align: center; padding: 1.25rem 1.5rem 1rem;
}
.ms-result-celebrate { font-size: 2.5rem; margin-bottom: 0.4rem; }
.ms-result-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 0.2rem; }
.ms-result-week { font-size: 0.88rem; color: var(--text-secondary); font-weight: 600; }
.ms-result-stage-banner {
    display: inline-block; margin-top: 1rem;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-full);
    font-weight: 700; font-size: 0.95rem;
}
.ms-result-stage-banner.promoted { background: var(--success-bg); color: var(--text); }
.ms-result-stage-banner.demoted  { background: var(--danger-bg);  color: var(--danger); }

/* Coach card */
.ms-coach-card {
    display: flex; gap: 0.75rem; align-items: flex-start;
    background: var(--surface); border: 1.5px solid var(--primary);
    border-radius: var(--radius-lg); padding: 0.85rem 1rem;
    margin: 0 1rem 1rem;
}
.ms-coach-avatar { font-size: 1.5rem; flex-shrink: 0; }
.ms-coach-label {
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--primary); margin-bottom: 0.25rem;
}
.ms-coach-text { font-size: 0.87rem; line-height: 1.55; color: var(--text); }

/* Section wrapper */
.ms-result-section {
    margin: 0 1rem 1rem;
}
.ms-result-section-title {
    font-size: 0.68rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Trend buckets */
.ms-trend-bucket { margin-bottom: 1rem; }
.ms-trend-bucket-header {
    font-size: 0.82rem; font-weight: 700;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    display: inline-block; margin-bottom: 0.6rem;
}
.ms-trend-bucket-header.improved { background: var(--success-bg); color: var(--text); }
.ms-trend-bucket-header.steady   { background: var(--primary-bg); color: var(--primary); }
.ms-trend-bucket-header.focus    { background: rgba(249,115,22,0.12); color: #c2410c; }

/* Tag cards */
.ms-tag-card {
    display: flex; gap: 0.7rem; align-items: flex-start;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-lg);
    border-left: 4px solid transparent;
    margin-bottom: 0.4rem;
    background: var(--bg-secondary);
}
.ms-tag-card.ms-tag-improved  { border-color: var(--success); }
.ms-tag-card.ms-tag-steady    { border-color: var(--primary); }
.ms-tag-card.ms-tag-focus     { border-color: #f97316; }
.ms-tag-card-icon { font-size: 1.25rem; flex-shrink: 0; }
.ms-tag-card-name { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.15rem; }
.ms-tag-card-obs  { font-size: 0.8rem; color: var(--text); line-height: 1.45; }

/* Incorrect MCQ review */
.ms-mcq-review { display: flex; flex-direction: column; gap: 0.75rem; }
.ms-mcq-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    border-left: 4px solid var(--warning);
}
.ms-mcq-q  { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }
.ms-mcq-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.35rem; }
.ms-mcq-yours   { font-size: 0.82rem; color: var(--text-secondary); }
.ms-mcq-yours em { color: var(--text); text-decoration: line-through; font-style: normal; }
.ms-mcq-correct { font-size: 0.82rem; font-weight: 700; color: var(--success); }
.ms-mcq-exp { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; margin-top: 0.25rem; }
.ms-mcq-tag { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--primary); margin-top: 0.3rem; letter-spacing: 0.06em; }

/* Vocab */
.ms-vocab-row { display: flex; align-items: flex-start; gap: 0.6rem; flex-wrap: wrap; }
.ms-vocab-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.2rem 0.1rem; flex-shrink: 0; }
.ms-vocab-label.used    { color: var(--success); }
.ms-vocab-label.pending { color: var(--warning); }
.ms-vocab-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ms-vocab-chip {
    font-size: 0.8rem; padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full); font-weight: 600;
}
.ms-vocab-chip.used    { background: var(--success-bg); color: var(--text); }
.ms-vocab-chip.pending { background: rgba(234,179,8,0.15); color: #92400e; }
.ms-vocab-chip.sm      { font-size: 0.72rem; padding: 0.15rem 0.55rem; }

/* Next week focus */
.ms-next-focus {
    background: linear-gradient(135deg, var(--primary-bg), var(--surface));
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg); padding: 0.75rem 1rem;
    margin: 0 1rem 1rem;
}
.ms-next-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 0.35rem;
}
.ms-next-list li { font-size: 0.82rem; color: var(--text); line-height: 1.45; }
.ms-next-list li::before { content: '→ '; color: var(--primary); font-weight: 700; }

/* CTA row */
.ms-result-cta {
    display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
    padding: 0 1.25rem;
}
.ms-result-cta .btn { width: 100%; max-width: 360px; }

/* Milestone history cards in progress page */
.ms-hist-card {
    padding: 1rem 0.25rem 1rem;
    border-bottom: 1px solid var(--border-light);
}
.ms-hist-card:last-child { border-bottom: none; }
.ms-hist-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.ms-hist-week { font-size: 1rem; font-weight: 700; }
.ms-hist-badges { display: flex; gap: 0.35rem; }
.ms-hist-coach {
    font-size: 0.82rem; color: var(--text-secondary);
    font-style: italic; line-height: 1.5;
    margin-bottom: 0.5rem;
}
.ms-hist-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.ms-hist-chip {
    font-size: 0.72rem; font-weight: 600;
    padding: 0.2rem 0.6rem; border-radius: var(--radius-full);
}
.ms-hist-chip.improved { background: var(--success-bg); color: var(--text); }
.ms-hist-chip.steady   { background: var(--primary-bg); color: var(--primary); }
.ms-hist-chip.focus    { background: rgba(249,115,22,0.12); color: #c2410c; }
.ms-hist-vocab { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.4rem; }
.ms-hist-next { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.ms-hist-next-label { font-weight: 700; color: var(--primary); }

/* Full report expand/collapse in history */
.ms-hist-full-report {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-light);
}
.ms-hist-full-report .ms-coach-card { margin: 0.5rem 0; }
.ms-hist-full-report .ms-result-section { margin-bottom: 0.75rem; }
.ms-hist-full-report .ms-result-section-title { font-size: 0.82rem; }
.ms-hist-full-report .ms-tag-card { padding: 0.5rem; }
.ms-hist-full-report .ms-tag-card-obs { font-size: 0.78rem; }

/* Weekly cross-session trend summary */
.ms-wk-summary { margin-bottom: 1.25rem; }
.ms-wk-bucket {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-top: 0.6rem;
}
.ms-wk-up { border-left: 3px solid var(--success); }
.ms-wk-down { border-left: 3px solid var(--warning); }
.ms-wk-bucket-hdr {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}
.ms-wk-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}
.ms-wk-item:last-child { border-bottom: none; }
.ms-wk-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.ms-wk-tag-name { font-size: 0.9rem; font-weight: 600; }
.ms-wk-dim {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary, #2a2a3e);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}
.ms-wk-counts {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.ms-wk-dot {
    font-weight: 700;
    min-width: 1.1rem;
    text-align: center;
}
.ms-wk-dot.up { color: var(--success); }
.ms-wk-dot.down { color: var(--warning); }
.ms-wk-sep { color: var(--text-muted); margin: 0 1px; }
.ms-wk-arrow { font-size: 1rem; margin-left: 4px; font-weight: 700; }
.ms-wk-arrow.green { color: var(--success); }
.ms-wk-arrow.amber { color: var(--warning); }
.ms-wk-evidence {
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.ms-hist-toggle-btn {
    display: block;
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.4rem 0;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--primary);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
}
.ms-hist-toggle-btn:hover { background: var(--primary-bg); }


/* ── Progress Page ─────────────────────── */
.progress-bar-horizontal {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.progress-bar-label { font-size: 0.8rem; font-weight: 500; min-width: 120px; color: var(--text-secondary); }
.progress-bar-track {
    flex: 1; height: 10px;
    background: var(--border-light);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%; border-radius: var(--radius-full);
    background: var(--primary);
    transition: width 0.5s ease;
}
.progress-bar-value { font-size: 0.8rem; font-weight: 600; min-width: 40px; text-align: right; }

/* ── Weakness Tags ─────────────────────── */
.weakness-item {
    display: flex; flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-light);
}
.weakness-item:last-child { border-bottom: none; }
.weakness-tag { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.weakness-bar { width: 100%; height: 7px; background: var(--border-light); border-radius: var(--radius-full); overflow: hidden; }
.weakness-bar-fill { height: 100%; border-radius: var(--radius-full); background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width 0.6s ease; }

/* ── Recording UI ──────────────────────── */
/* Generic modal (centered, for non-recorder use) */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000; display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-backdrop {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.15);
}
.recorder-modal-content {
    position: relative; z-index: 1;
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 480px; width: 100%;
    height: 90vh;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}
/* Full-screen recorder on mobile */
@media (max-width: 640px) {
    .modal { padding: 0; }
    .recorder-modal-content {
        max-width: 100%; height: 100%; max-height: 100%;
        border-radius: 0;
    }
}

/* ── Recorder as bottom sheet (drill content stays visible) ── */
#recorder-modal {
    align-items: flex-end;          /* push content to bottom */
    padding: 0;
}
#recorder-modal .modal-backdrop {
    background: rgba(0,0,0,0.10);   /* light dim so text above is readable */
    backdrop-filter: none;
}
.recorder-modal-content {
    text-align: center;
    max-width: 100% !important;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    max-height: 45vh;               /* take at most 45% of screen */
    overflow-y: auto;
}
@media (min-width: 641px) {
    .recorder-modal-content {
        max-width: 480px !important;
        margin: 0 auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}
.recorder-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.recorder-body { padding: 1rem 1.5rem 1.25rem; }
.recorder-encourage {
    font-size: 0.85rem; color: var(--text-secondary);
    margin-bottom: 0.5rem;
    min-height: 1.2em;
}
.recorder-visualizer {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--primary-bg);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 0.75rem;
    transition: var(--transition);
}
.recorder-visualizer.recording {
    background: var(--accent-bg);
    animation: pulse-ring-accent 1.5s ease infinite;
}
.rec-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--primary);
    transition: var(--transition);
}
.recorder-visualizer.recording .rec-dot { background: var(--accent); animation: pulse-dot 1s ease infinite; }
.recorder-timer { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 0.5rem; color: var(--text); }
.recorder-controls { margin-bottom: 0.5rem; }
.btn-record {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--accent); color: white; border: none;
    font-size: 1.5rem;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(249, 112, 102, 0.35);
}
.btn-record.recording {
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
    animation: pulse-ring-danger 2s ease infinite;
}
.btn-record:hover { transform: scale(1.08); }
.btn-record:active { transform: scale(0.95); }
.recorder-status { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; font-weight: 500; }
.recorder-playback { margin-top: 0.75rem; }
.recorder-playback audio { width: 100%; margin-bottom: 0.75rem; border-radius: var(--radius-sm); height: 36px; }
.recorder-actions { display: flex; gap: 0.75rem; justify-content: center; }
.rec-icon { font-size: 1.4rem; }

/* ── Inline Recorder (replaces modal for drill pages) ── */
/* ── Sticky recording bar (mobile scroll) ── */
.sticky-rec-bar {
    position: fixed; left: 0; right: 0; z-index: 150;
    /* Sit above the bottom nav on mobile */
    bottom: calc(var(--bottom-nav-height, 64px) + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #1e1e2e 0%, #2d1b3d 100%);
    color: #fff; font-size: 0.9rem;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.25);
    animation: slide-up 0.25s ease;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sticky-rec-bar.hidden { display: none; }
.sticky-rec-left { display: flex; align-items: center; gap: 0.6rem; }
.sticky-rec-dot {
    width: 10px; height: 10px; border-radius: 50%; background: #f43f5e;
    box-shadow: 0 0 8px rgba(244,63,94,0.6);
    animation: pulse-dot 1s ease infinite;
}
@keyframes pulse-dot { 0%,100% { opacity: 1; box-shadow: 0 0 8px rgba(244,63,94,0.6); } 50% { opacity: 0.3; box-shadow: 0 0 2px rgba(244,63,94,0.2); } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sticky-rec-label { font-weight: 600; font-size: 0.85rem; }
.sticky-rec-time { font-family: 'Inter', monospace; font-variant-numeric: tabular-nums; opacity: 0.7; font-size: 0.85rem; }
.sticky-rec-btns { display: flex; gap: 0.4rem; }
.sticky-rec-btn {
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.1); color: #fff;
    padding: 0.35rem 0.7rem; border-radius: 0.5rem; font-size: 0.82rem;
    cursor: pointer; transition: background 0.15s;
}
.sticky-rec-btn:hover { background: rgba(255,255,255,0.22); }
.sticky-rec-done { background: #f43f5e; border-color: #f43f5e; font-weight: 600; }
.sticky-rec-done:hover { background: #e11d48; }
/* On desktop (no bottom nav), sit at the very bottom */
@media (min-width: 769px) {
    .sticky-rec-bar {
        bottom: 0; max-width: 600px; left: 50%; right: auto;
        transform: translateX(-50%); border-radius: 0.75rem 0.75rem 0 0;
    }
}
/* When bottom nav is hidden (e.g. analysis/entry test), drop bar to true bottom */
body:has(#bottom-nav.hidden) .sticky-rec-bar {
    bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Sticky TTS playback control bar ── */
.sticky-tts-bar {
    position: fixed; left: 0; right: 0; z-index: 10003;
    bottom: calc(var(--bottom-nav-height, 64px) + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #1a1a3e 0%, #2a1845 100%);
    color: #fff; font-size: 0.88rem;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.3);
    animation: slide-up 0.25s ease;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sticky-tts-bar.hidden { display: none; }
.sticky-tts-left { display: flex; align-items: center; gap: 0.5rem; }
.sticky-tts-icon { font-size: 1.1rem; animation: tts-pulse 1.2s ease infinite; }
@keyframes tts-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.sticky-tts-label { font-weight: 600; font-size: 0.82rem; }
.sticky-tts-label { margin-right: 0.55rem; }
.sticky-tts-btns { display: flex; gap: 0.4rem; }
.sticky-tts-btn {
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.15);
    color: #fff; padding: 0.3rem 0.75rem; border-radius: 0.5rem;
    font-size: 0.8rem; cursor: pointer; transition: background 0.15s;
    font-weight: 500;
}
.sticky-tts-btn:hover { background: rgba(255,255,255,0.25); }
.sticky-tts-btn:active { transform: scale(0.95); }
.sticky-tts-play { background: rgba(34,197,94,0.7); border-color: rgba(34,197,94,0.5); font-weight: 600; }
.sticky-tts-play:hover { background: rgba(34,197,94,0.92); }
.sticky-tts-restart { background: rgba(91,95,199,0.6); border-color: rgba(91,95,199,0.4); }
.sticky-tts-restart:hover { background: rgba(91,95,199,0.85); }
/* Entry test / placement test -- bottom nav hidden → drop to true bottom */
body:has(#bottom-nav.hidden) .sticky-tts-bar {
    bottom: env(safe-area-inset-bottom, 0px);
}
/* Tour active → drop to true bottom; push tour card up to avoid overlap */
body.tour-active .sticky-tts-bar {
    bottom: env(safe-area-inset-bottom, 0px);
}
body.tour-active .tour-card--bottom {
    bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 769px) {
    .sticky-tts-bar {
        bottom: 0; max-width: 600px; left: 50%; right: auto;
        transform: translateX(-50%); border-radius: 0.75rem 0.75rem 0 0;
    }
}

.inline-recorder {
    background: var(--surface);
    border: 2px solid var(--primary-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1rem;
    text-align: center;
    animation: fade-in 0.3s ease;
}
.inline-rec-status {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.inline-rec-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}
.inline-rec-row .recorder-timer {
    font-size: 1.5rem;
    margin-bottom: 0;
}
.inline-rec-row .recorder-visualizer {
    width: 40px;
    height: 40px;
}
.inline-rec-row .btn-record {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
}
.inline-rec-mid {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.75rem;
}
.inline-rec-mid .btn { min-width: 100px; }
.inline-rec-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.75rem;
}
.inline-recorder .recorder-playback {
    margin-top: 1rem;
}
.inline-recorder .recorder-playback audio {
    width: 100%;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-sm);
    height: 36px;
}

@keyframes pulse-ring-accent {
    0% { box-shadow: 0 0 0 0 rgba(249, 112, 102, 0.3); }
    70% { box-shadow: 0 0 0 24px rgba(249, 112, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(249, 112, 102, 0); }
}
@keyframes pulse-ring-danger {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.25); }
    70% { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ── Toast ─────────────────────────────── */
.toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    z-index: 2000; display: flex; flex-direction: column-reverse; gap: 0.5rem;
}
.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: slide-in-right 0.3s ease;
    max-width: 350px;
}
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
.toast.warning { background: var(--warning); color: #78350F; }

/* ── Loading ───────────────────────────── */
.loading-spinner {
    display: inline-block;
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-page {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 300px; gap: 1rem;
    color: var(--text-secondary);
}
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.skeleton-title { height: 1.5rem; width: 60%; margin-bottom: 0.75rem; }
.skeleton-card { height: 80px; margin-bottom: 0.75rem; border-radius: var(--radius); }

/* ── Empty State ───────────────────────── */
.empty-state {
    text-align: center; padding: 3rem 1.5rem;
    color: var(--text-secondary);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.7; }
.empty-title { font-weight: 600; font-size: 1.1rem; color: var(--text); margin-bottom: 0.375rem; }
.empty-desc { font-size: 0.9rem; max-width: 300px; margin: 0 auto; }

/* ── TTS Button ────────────────────────── */
.tts-btn {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.tts-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.tts-btn.speaking { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); animation: pulse-border 1s ease infinite; }
/* Attention pulse -- nudges user to tap Listen before recording */
.tts-btn-attention { border-color: var(--primary); color: var(--primary); animation: tts-attention 1.3s ease infinite; }
@keyframes tts-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.55); background: var(--surface); }
    50%       { box-shadow: 0 0 0 8px rgba(99,102,241,0); background: var(--primary-bg); }
}

/* ── Section Divider ───────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}
.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* ── Tab Navigation ────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; gap: 0; }
.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: var(--transition);
    background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Animations ────────────────────────── */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
    70% { box-shadow: 0 0 0 20px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
@keyframes pulse-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}
@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.3); }
    50% { box-shadow: 0 0 0 4px rgba(99,102,241,0.15); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner-xs {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(30,64,175,0.25); border-top-color: #1e40af;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes slide-in-right {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in 0.3s ease; }

/* ── Celebration Overlay ───────────────── */
/* ── Drill Tick Mark ──────────────────── */
.drill-tick {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--success);
    animation: tick-pop 0.4s ease;
}
@keyframes tick-pop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}
.drill-card.completed .drill-icon {
    background: var(--success-bg);
    border: 2px solid var(--success);
}
.status-done {
    color: var(--success);
    font-weight: 700;
    font-size: 0.8rem;
}
.status-start {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.8rem;
}

/* ── All Done Banner ─────────────────── */
.all-done-banner {
    background: linear-gradient(135deg, var(--success-bg), #ECFDF5);
    border: 1.5px solid var(--success);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--success-dark, #065F46);
    margin-top: 0.5rem;
    animation: fade-in 0.5s ease;
}
@media (prefers-color-scheme: dark) {
    .all-done-banner {
        background: linear-gradient(135deg, #0A2E20, #0F3D2A);
        border-color: #10B981;
        color: #6EE7B7;
    }
}
.all-done-icon { font-size: 1.1rem; }

/* ── Encouragement Overlay ───────────── */
.encouragement-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 950;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    animation: fade-in 0.25s ease;
    padding: 1.5rem;
}
.encouragement-card {
    background: var(--surface);
    border-radius: var(--radius-xl, 1.25rem);
    padding: 2rem 1.75rem;
    text-align: center;
    max-width: 340px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: enc-slide-up 0.4s ease;
}
@keyframes enc-slide-up {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.enc-emoji { font-size: 3.5rem; margin-bottom: 0.75rem; animation: bounce 0.8s ease; }
.enc-title {
    font-family: var(--font-heading);
    font-size: 1.5rem; font-weight: 800;
    color: var(--text); margin-bottom: 0.5rem;
}
.enc-msg { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 1.25rem; line-height: 1.5; }
.enc-progress {
    display: flex; align-items: center; justify-content: center;
    gap: 0.75rem; margin-bottom: 0.75rem;
}
.enc-dot {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700;
    background: var(--border-light, #f0f0f0);
    color: var(--text-muted);
    transition: all 0.3s ease;
}
.enc-dot.done {
    background: var(--success);
    color: white;
    animation: tick-pop 0.4s ease;
}
.enc-remaining {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 1.25rem;
}
.enc-continue { width: 100%; }

/* ── Celebration Overlay (enhanced) ──── */
.celebration-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 900;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: var(--surface);
    text-align: center; padding: 2rem;
    animation: fade-in 0.4s ease;
    overflow: hidden;
}
.celebration-content { position: relative; z-index: 2; }
.celebration-emoji { font-size: 4rem; margin-bottom: 1rem; animation: bounce 1s ease infinite; }
.celebration-title {
    font-family: var(--font-heading);
    font-size: 1.75rem; font-weight: 800;
    color: var(--text);
    margin-bottom: 0.5rem;
}
.celebration-sub { font-size: 1rem; color: var(--text-secondary); margin-bottom: 1.5rem; max-width: 300px; }
.celebration-streak-ring {
    background: var(--warning-bg);
    border: 2px solid var(--warning);
    border-radius: var(--radius-xl, 1.25rem);
    padding: 1rem 2rem;
    display: inline-block;
    margin-bottom: 1rem;
}
.celebration-streak {
    font-size: 2.5rem; font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.15rem;
}
.celebration-streak-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.celebration-reminder {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-bg);
    border-radius: var(--radius-full);
    display: inline-block;
}
.celebration-btn { min-width: 200px; }

/* On laptop/desktop: show as a centered modal card instead of full-screen */
@media (min-width: 640px) {
    .celebration-overlay {
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(6px);
        padding: 2rem;
    }
    .celebration-content {
        background: var(--surface);
        border-radius: var(--radius-xl, 1.25rem);
        padding: 2.5rem 3rem;
        max-width: 480px;
        width: 100%;
        box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
        animation: enc-slide-up 0.4s ease;
    }
    .celebration-sub { max-width: 100%; }
}

/* ── Confetti ────────────────────────── */
.confetti-container {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden; pointer-events: none; z-index: 1;
}
.confetti-piece {
    position: absolute;
    top: -10px;
    opacity: 0;
    animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    25% { opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Score Ring ────────────────────────── */
.score-ring {
    width: 70px; height: 70px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: 800;
    color: var(--primary);
    background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--border) 0);
    position: relative;
}
.score-ring::before {
    content: '';
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--surface);
    position: absolute;
}
.score-ring .ring-value { position: relative; z-index: 1; }

/* ── Responsive ────────────────────────── */

/* ── Tiny phones (iPhone SE, Galaxy A series ≤ 375px) ── */
@media (max-width: 375px) {
    .app-container { padding-left: 0.6rem; padding-right: 0.6rem; }
    .recorder-timer { font-size: 2rem; }
    .progress-bar-label { min-width: 80px; font-size: 0.72rem; }
    .drill-content-card { padding: 1.25rem; }
    h1 { font-size: 1.6rem; }
    .hero-headline { font-size: 2rem; }
    .btn-lg { padding: 0.75rem 1.25rem; font-size: 0.95rem; }
    /* Hero: fit everything on tiny phones */
    .hero-page { padding: env(safe-area-inset-top,0) 1rem env(safe-area-inset-bottom,0); }
    /* .hero-brand { margin-bottom: 1rem; } */
    .hero-brand-logo { height: 60px; width: auto; max-width: 210px; }
    .hero-brand-name { font-size: 1.25rem; }
    .hero-sub { font-size: 0.8rem; margin: 0.5rem 0 0.875rem; }
    .hero-features { gap: 0.375rem; margin-bottom: 1.25rem; max-width: 280px; }
    .hero-feature-card { padding: 0.625rem 0.375rem; gap: 0.25rem; }
    .hero-feature-icon { font-size: 1.25rem; }
    .hero-feature-label { font-size: 0.68rem; }
    .hero-cta { padding: 0.75rem 1.5rem; font-size: 0.95rem; }
}

/* ── Phone (portrait + landscape ≤ 640px) ── */
@media (max-width: 640px) {
    :root { --max-width: 100%; }
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.25rem; }
    .hero-headline { font-size: 2.2rem; }
    /* Hero: compact layout for phones */
    .hero-page { padding: env(safe-area-inset-top,0) 1.25rem env(safe-area-inset-bottom,0); }
    /* .hero-brand { margin-bottom: 1.5rem; } */
    .hero-brand-logo { height: 66px; width: auto; max-width: 240px; }
    .hero-brand-name { font-size: 3rem; }
    .hero-sub { font-size: 0.85rem; margin: 0.625rem 0 1.125rem; }
    .hero-features { gap: 0.5rem; margin-bottom: 1.5rem; }
    .hero-feature-card { padding: 0.75rem 0.5rem; }
    .hero-feature-icon { font-size: 1.4rem; }
    .hero-feature-label { font-size: 0.72rem; }
    .hero-cta { padding: 0.8rem 1.5rem; }
    .selector-grid { grid-template-columns: 1fr 1fr; }
    .selector-grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .results-breakdown { grid-template-columns: 1fr; }
    /* Safe-area aware padding on bottom */
    .app-container {
        padding: 0.75rem;
        padding-top: 72px;
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 0.75rem);
    }
    .nav-links { display: none; }
    #topnav-profile { display: none; }
    .dash-hero { padding: 1rem 1.1rem; }
    /* Toast above bottom nav + safe area */
    .toast-container {
        right: 0.75rem;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 0.5rem);
        left: 0.75rem;
    }
    .toast { max-width: 100%; }
    /* Wider drill cards on phone - less padding waste */
    .drill-card { padding: 1rem 0.875rem 1rem 0.875rem; gap: 0.75rem; }
    .drill-icon { width: 44px; height: 44px; font-size: 1.35rem; }
}

/* ── Tablet (641px -- 900px) ── */
@media (min-width: 641px) and (max-width: 900px) {
    :root { --max-width: 580px; }
    .hero-headline { font-size: 3.4rem; }
    .selector-grid { grid-template-columns: 1fr 1fr; }
    .selector-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    /* stat grid gets a bit more breathing room */
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
    h1 { font-size: 2.1rem; }
    /* No bottom nav on tablet -- hide it */
    .bottom-nav { display: none; }
    .app-container { padding-bottom: 2.5rem; }
}

/* ── Desktop (> 900px) ── */
@media (min-width: 901px) {
    :root { --max-width: 600px; }
    .bottom-nav { display: none; }
    .app-container { padding-bottom: 2.5rem; }
}

/* Catch-all for legacy "hide bottom-nav on desktop" */
@media (min-width: 641px) {
    .bottom-nav { display: none; }
}

/* ============================================
   GENERATING DRILLS ANIMATION
   ============================================ */

.generating-drills {
    text-align: center;
    padding: 2.5rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
}
.generating-drills .gen-icon {
    font-size: 3rem;
    animation: pulse 2s ease-in-out infinite;
}
.generating-drills .gen-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 1rem 0 0.5rem;
    color: var(--text-primary);
}
.generating-drills .gen-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-height: 1.4em;
    transition: opacity 0.3s;
}
.generating-drills .gen-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}
.generating-drills .gen-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotPulse 1.4s ease-in-out infinite;
}
.generating-drills .gen-dot:nth-child(2) { animation-delay: 0.2s; }
.generating-drills .gen-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================
   ADMIN PANEL
   ============================================ */

.admin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 640px) {
    .admin-grid { grid-template-columns: 1fr; }
}

.admin-detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.stat-warning {
    border-color: var(--warning, #F59E0B) !important;
    background: var(--warning-bg, #FFFBEB) !important;
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-table th {
    background: var(--surface-2, #F8F8F8);
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface-2, #FAFAFA); }

.admin-actions {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    border-radius: var(--radius-sm);
}

.badge-error { background: var(--danger-bg, #FEF2F2); color: var(--danger, #DC2626); }
.badge-info { background: rgba(37,99,235,0.12); color: #2563EB; }
.badge-default { background: var(--border-light, #f0f0f0); color: var(--text-secondary); }

/* ── Modal Overlay ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fade-in 0.2s ease;
}
.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    width: 90%;
}

/* ── Admin User Detail / Control Panel ── */
.admin-detail-card {
    background: var(--surface);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-lg, 0.75rem);
    padding: 1.25rem;
    margin-bottom: 1rem;
    overflow: hidden;
    max-width: 100%;
}
.admin-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
    font-size: 0.85rem;
}
@media (max-width: 600px) {
    .admin-detail-grid { grid-template-columns: 1fr; }
}
.admin-drills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}
@media (max-width: 700px) {
    .admin-drills-grid { grid-template-columns: 1fr; }
}
.drill-mini-card {
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-md, 0.5rem);
    padding: 0.75rem;
    background: var(--surface-1, #fafafa);
    min-width: 0;
    overflow: hidden;
}
.drill-mini-card.drill-error {
    border-color: var(--danger, #DC2626);
    background: var(--danger-bg, #fef2f2);
}
.drill-mini-card.drill-completed {
    border-color: var(--success, #16a34a);
    background: var(--success-bg, #f0fdf4);
}
.progress-timeline {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}
.timeline-day {
    min-width: 110px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-md, 0.5rem);
    padding: 0.625rem;
    text-align: center;
    background: var(--surface);
    flex-shrink: 0;
}
.timeline-day.day-completed {
    border-color: var(--success, #16a34a);
    background: var(--success-bg, #f0fdf4);
}
.timeline-day.day-error {
    border-color: var(--danger, #DC2626);
    background: var(--danger-bg, #fef2f2);
}
.admin-override-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
@media (max-width: 600px) {
    .admin-override-form { grid-template-columns: 1fr; }
}

/* ── Day Report & Analysis ─────────────── */
.drill-reports-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.drill-report-card {
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-md, 0.5rem);
    padding: 1rem;
    background: var(--surface);
}
.drill-report-card.drill-completed {
    border-color: var(--success, #16a34a);
    background: var(--success-bg);
}
.drill-report-card.drill-error {
    border-color: var(--danger, #DC2626);
    background: var(--danger-bg);
}
.drill-scores-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.score-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-2, #f5f5f5);
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    min-width: 65px;
}
.score-label {
    font-size: 0.65rem;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.score-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}
.error-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.375rem 0.5rem;
    background: var(--danger-bg);
    border-radius: 0.25rem;
    margin-bottom: 0.375rem;
}

/* ── Explain Scores button ── */
.explain-btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--primary, #5B5FC7);
    color: var(--primary, #5B5FC7);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.explain-btn:hover { background: var(--primary, #5B5FC7); color: #fff; }
.explain-btn:disabled { opacity: 0.5; cursor: wait; }

/* ── Explanation panel ── */
.explanation-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
}
.explanation-dimension {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border-radius: 4px;
}

/* ── Output sufficiency bar ── */
.sufficiency-bar-wrap { font-size: 0.8rem; }
.sufficiency-bar {
    height: 6px;
    background: var(--border-light, #e5e7eb);
    border-radius: 3px;
    overflow: hidden;
}
.sufficiency-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.sufficiency-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
}
.sufficiency-badge-bad { background: var(--danger-bg); color: var(--danger); }
.sufficiency-badge-warn { background: var(--warning-bg); color: var(--warning); }
.sufficiency-badge-ok { background: var(--success-bg); color: var(--success); }

/* Audio history date groups */
.audio-date-group .admin-table { font-size: 0.82rem; }
.audio-date-group .admin-table th { font-size: 0.72rem; padding: 0.35rem 0.5rem; }
.audio-date-group .admin-table td { padding: 0.35rem 0.5rem; }

/* ── Content moderation flags ── */
.flag-banner {
    background: var(--danger-bg);
    border: 2px solid var(--danger);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    color: var(--danger);
    font-size: 0.9rem;
    cursor: pointer;
    animation: flag-pulse 2s ease-in-out infinite;
}
.flag-banner:hover { background: var(--danger-bg); filter: brightness(1.1); }
@keyframes flag-pulse {
    0%, 100% { border-color: #fca5a5; }
    50% { border-color: #ef4444; }
}
.user-row-flagged {
    background: var(--danger-bg) !important;
    border-left: 3px solid #ef4444;
}
.user-row-flagged td { background: var(--danger-bg) !important; }
.badge-danger { background: var(--danger-bg); color: var(--danger); font-weight: 600; }

/* ── Admin Tabs ── */
.admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light, #e5e7eb);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}
.admin-tab {
    padding: 0.6rem 1.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--text-primary, #1a1a2e); }
.admin-tab.active {
    color: var(--primary, #5B5FC7);
    border-bottom-color: var(--primary, #5B5FC7);
    font-weight: 600;
}
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

/* ── Admin Filter Bar ── */
.admin-filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}
.admin-filter-bar select,
.admin-filter-bar input {
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    min-width: 120px;
}
.admin-filter-bar input[type="text"] { min-width: 200px; }

/* ── Admin Pagination ── */
.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    font-size: 0.82rem;
}
.admin-pagination button {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.admin-pagination button:hover { background: var(--surface-hover); }
.admin-pagination button:disabled { opacity: 0.4; cursor: default; }
.admin-pagination .page-info { color: var(--text-secondary, #6b7280); }

/* ── Collapsible sections ── */
.admin-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 0.25rem 0;
}
.admin-section-toggle h3 { margin: 0; }
.admin-section-toggle .chevron {
    font-size: 0.8rem;
    color: var(--text-muted, #9ca3af);
    transition: transform 0.2s;
}
.admin-section-toggle.collapsed .chevron { transform: rotate(-90deg); }
.admin-section-body.collapsed { display: none; }

/* ============================================
   GUIDED TOUR
   ============================================ */

/* Fullscreen overlay -- catches clicks, dims page */
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: auto;
    transition: background 0.3s ease;
}

/* Spotlight hole (box-shadow cutout) */
.tour-spotlight {
    position: fixed;
    z-index: 10001;
    border-radius: var(--radius, 14px);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Narration card */
.tour-card {
    position: fixed;
    z-index: 10002;
    background: var(--surface, #fff);
    border-radius: var(--radius-lg, 20px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    padding: 1.25rem 1.25rem 1rem;
    max-width: 400px;
    width: calc(100% - 2rem);
    left: 50%;
    transform: translateX(-50%);
    animation: tour-card-in 0.3s ease;
}
.tour-card--bottom { bottom: 1.5rem; }
.tour-card--top { top: 5rem; }
.tour-card--bottom-nav { bottom: calc(var(--bottom-nav-height, 60px) + 1rem); }
.tour-card--center {
    top: 50%;
    transform: translate(-50%, -50%);
    animation: tour-center-in 0.3s ease;
}
@keyframes tour-card-in {
    from { opacity: 0; transform: translateX(-50%) translateY(16px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes tour-center-in {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.tour-card-title {
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--text, #1a1a2e);
}
.tour-card-body {
    font-size: 0.88rem;
    color: var(--text-secondary, #52526c);
    line-height: 1.55;
    margin-bottom: 1rem;
}
.tour-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tour-left-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Progress dots */
.tour-dots { display: flex; gap: 5px; align-items: center; }
.tour-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--border, #e2e8f0);
    transition: all 0.25s ease;
}
.tour-dot.active {
    background: var(--primary, #5B5FC7);
    width: 20px;
    border-radius: 4px;
}

/* Buttons */
.tour-btn-next {
    padding: 0.5rem 1.25rem;
    background: var(--gradient-primary, linear-gradient(135deg, #5B5FC7, #8B5CF6));
    color: #fff;
    border: none;
    border-radius: var(--radius-full, 9999px);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.tour-btn-next:hover { filter: brightness(1.06); transform: translateY(-1px); }
.tour-btn-skip {
    background: none; border: none;
    color: var(--text-muted, #9494a8);
    font-size: 0.8rem; cursor: pointer;
}
.tour-btn-skip:hover { color: var(--text-secondary); }
.tour-btn-back {
    background: none; border: none;
    color: var(--text-muted, #9494a8);
    font-size: 0.85rem; cursor: pointer;
    padding: 0.5rem 0.75rem;
}
.tour-btn-back:hover { color: var(--text-secondary); }
.tour-mute-btn {
    background: none; border: none;
    font-size: 1rem; cursor: pointer;
    opacity: 0.5; transition: opacity 0.2s;
    padding: 0.25rem;
}
.tour-mute-btn:hover { opacity: 1; }
.tour-step-counter {
    font-size: 0.72rem;
    color: var(--text-muted, #9494a8);
    white-space: nowrap;
}
.tour-right-actions {
    display: flex; align-items: center; gap: 0.5rem;
}

/* ── Landing tour mockup screen ── */
.tour-mockup-container {
    position: fixed;
    z-index: 10001;
    left: 50%; top: 45%;
    transform: translate(-50%, -50%);
    width: min(360px, 88vw);
    max-height: 52vh;
    background: var(--surface, #fff);
    border-radius: var(--radius-xl, 28px);
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: tour-center-in 0.35s ease;
}
.tour-mockup-inner {
    padding: 1.25rem;
    text-align: center;
}
.tour-mock-header {
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-weight: 700; font-size: 1rem;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.6rem; text-align: left;
}
.tour-mock-label {
    font-weight: 600; font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #9494a8);
    margin-bottom: 0.4rem; text-align: left;
}
.tour-mock-drill {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.65rem 0.75rem;
    background: var(--bg, #fafaf7);
    border: 1px solid var(--border, #e8e8e0);
    border-radius: var(--radius-sm, 10px);
    margin-bottom: 0.4rem; font-weight: 500; font-size: 0.85rem;
}
.tour-mock-drill--locked { opacity: 0.45; }
.tour-mock-drill--active { border-left: 3px solid var(--primary, #5B5FC7); }
.tour-mock-arrow { color: var(--primary, #5B5FC7); font-weight: 700; }
.tour-mock-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem; margin-top: 0.6rem; text-align: center;
    font-weight: 700; font-size: 0.85rem;
}
.tour-mock-stats small {
    display: block; font-weight: 400; font-size: 0.65rem;
    color: var(--text-muted, #9494a8);
}
.tour-mock-step {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0; font-size: 0.85rem; text-align: left;
}
.tour-mock-num {
    width: 1.4rem; height: 1.4rem; border-radius: 50%;
    background: var(--primary, #5B5FC7); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}
.tour-mock-chip {
    display: inline-block; padding: 0.3rem 0.65rem;
    border-radius: var(--radius-full, 9999px);
    background: var(--bg, #fafaf7);
    border: 1px solid var(--border, #e8e8e0);
    font-size: 0.78rem; margin: 0.2rem;
}
.tour-mock-chip--active {
    background: var(--primary-bg, #eef0fb);
    border-color: var(--primary, #5B5FC7);
    color: var(--primary, #5B5FC7); font-weight: 600;
}
.tour-mock-input {
    width: 100%; padding: 0.55rem 0.75rem;
    border: 1px solid var(--border, #e8e8e0);
    border-radius: var(--radius-sm, 10px);
    margin-bottom: 0.4rem; font-size: 0.82rem;
    background: var(--bg, #fafaf7); color: var(--text-muted);
    text-align: left;
}
.tour-mock-btn {
    display: inline-block; padding: 0.55rem 1.5rem;
    background: var(--gradient-primary, linear-gradient(135deg, #5B5FC7, #8B5CF6));
    color: #fff; border-radius: var(--radius-full, 9999px);
    font-weight: 600; font-size: 0.85rem; margin-top: 0.5rem;
}
.tour-mock-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.tour-mock-title {
    font-family: var(--font-heading); font-weight: 700;
    font-size: 1rem; margin-bottom: 0.25rem;
}
.tour-mock-desc {
    font-size: 0.82rem; color: var(--text-secondary);
    line-height: 1.5;
}
.tour-cta-section { margin-top: 1rem; }
.tour-cta-section .tour-mock-btn { font-size: 1rem; padding: 0.75rem 2rem; cursor: pointer; }

/* "See it in Action" hero button */
.hero-demo-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.6rem 1.5rem;
    background: rgba(255,255,255,0.12);
    color: var(--primary, #5B5FC7);
    border: 1.5px solid var(--primary-light, #a5a8e6);
    border-radius: var(--radius-full, 9999px);
    font-weight: 600; font-size: 0.85rem;
    cursor: pointer; transition: all 0.15s ease;
    margin-top: 0.75rem;
}
.hero-demo-btn:hover {
    background: var(--primary-bg, #eef0fb);
    transform: translateY(-1px);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .tour-spotlight { box-shadow: 0 0 0 9999px rgba(0,0,0,0.72); }
    .tour-mockup-container { border: 1px solid var(--border, #333); }
    .tour-card { box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
}

/* Mobile */
@media (max-width: 640px) {
    .tour-card { max-width: calc(100% - 1.5rem); padding: 1rem; }
    .tour-card--bottom-nav { bottom: calc(var(--bottom-nav-height, 56px) + 0.5rem); }
    .tour-mockup-container { max-height: 48vh; }
    .tour-card-actions { flex-wrap: wrap; gap: 0.5rem; }
    .tour-right-actions { margin-left: auto; flex-shrink: 0; }
    .tour-btn-next { padding: 0.45rem 1rem; font-size: 0.82rem; white-space: nowrap; }
}

/* ──────────────────────────────────────────────
   Drill 1 Variants
   ────────────────────────────────────────────── */

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

/* Flash Read sentence card */
#flash-display-card {
    border: 2px solid var(--accent);
    transition: border-color 0.3s;
}

/* Cloze blank highlight */
.cloze-sentence ._blank {
    color: var(--warning);
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* Step badge variants */
.step-badge-3 {
    background: var(--border);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 1.6rem;
    height: 1.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 0.5rem;
}
