/* ============================================
   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;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;

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

    /* 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(180deg, #FAFAF7 0%, #F0EFE9 100%);
    --gradient-scene: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);

    /* 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;
}

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

        --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;

        --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(180deg, #121218 0%, #1A1A28 100%);
        --gradient-scene: linear-gradient(135deg, #0B1220 0%, #1E1B4B 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)); }
.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: 700; font-size: 1.1rem;
}
.brand-icon { font-size: 1.5rem; }
.brand-icon-img { width: 28px; height: 28px; border-radius: 6px; }
.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;
    -webkit-tap-highlight-color: transparent;
    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.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(--success-dark); }
.btn-outline {
    background: transparent; color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-bg); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.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; }
.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-sm);
    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 3px rgba(99,102,241,0.15);
}
.form-input::placeholder { color: var(--text-muted); }

/* ── 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: 600; font-size: 0.9rem; }
.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); }

/* ── 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: #B45309; }
.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); }

/* ── 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-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; font-weight: 500; }
.stat-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }

/* ── Welcome / Hero ────────────────────── */
.welcome-page {
    min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2rem;
    text-align: center;
    background: var(--gradient-page);
}
.welcome-logo { font-size: 4rem; margin-bottom: 1rem; animation: bounce 2s ease infinite; }
.welcome-logo-img { width: 96px; height: 96px; border-radius: 22px; margin: 0 auto 1rem; display: block; animation: bounce 2s ease infinite; }
.welcome-title {
    font-size: 2.5rem; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: 0.5rem;
}
.welcome-subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 2.5rem; max-width: 400px; }
.welcome-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; max-width: 500px; width: 100%; margin-bottom: 2rem; }
.welcome-card {
    padding: 2rem 1.5rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}
.welcome-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.welcome-card-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.welcome-card-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 0.375rem; }
.welcome-card-desc { font-size: 0.85rem; color: var(--text-secondary); }
.welcome-login { font-size: 0.9rem; color: var(--text-secondary); }
.welcome-login a { font-weight: 600; }

/* ── Page Header ───────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header-with-back { display: flex; align-items: center; gap: 0.75rem; }
.back-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 1.1rem;
    cursor: pointer; transition: var(--transition);
}
.back-btn:hover { background: var(--surface-hover); }
.page-title { font-size: 1.5rem; font-weight: 700; }
.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;
}
.dash-hero-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.dash-greeting { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.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;
}
.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;
}
.drill-passage {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-line;
}
.drill-passage .vocab-highlight {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-weight: 600;
}
.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;
}
.grammar-nudge em { font-style: italic; }

.drill-actions {
    display: flex; gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ── 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-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);
}
.buddy-narration .tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--gradient-success);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.75rem;
}
.buddy-narration .tts-btn:hover { filter: brightness(1.05) saturate(1.05); }

/* 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: #f0fdf4; color: #166534; }
.fb-good { background: #eff6ff; color: #1e40af; }
.fb-okay { background: #fefce8; color: #854d0e; }
.fb-growing { background: #fef2f2; color: #991b1b; }
.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: #b45309; }
.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: center; justify-content: center;
    gap: 0; margin: 1rem 0 1.5rem;
}
.ms-dot {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--border);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative; transition: all 0.3s;
}
.ms-dot.active { border-color: var(--primary); background: var(--primary-bg); }
.ms-dot.done { border-color: var(--success); background: var(--success-bg); }
.ms-dot-label {
    font-size: 0.55rem; font-weight: 700; text-transform: uppercase;
    color: var(--text-secondary); letter-spacing: 0.02em;
}
.ms-dot.active .ms-dot-label { color: var(--primary); }
.ms-dot.done .ms-dot-label { color: var(--success); }
.ms-dot-line { width: 32px; height: 2px; background: var(--border); }

/* ── 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;
}

/* ── 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) ── */
.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-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; }

/* ── 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); }
}
@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;
}
.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: linear-gradient(135deg, #FFF7ED, #FFFBEB);
    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; }

/* ── 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; }
    .welcome-title { font-size: 1.75rem; }
    .btn-lg { padding: 0.75rem 1.25rem; 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; }
    .welcome-title { font-size: 2rem; }
    .welcome-cards { grid-template-columns: 1fr; max-width: 320px; }
    .welcome-card { padding: 1.5rem 1.25rem; }
    .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; }
    .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; }
    /* Show 2-col welcome cards nicely on tablet */
    .welcome-cards { max-width: 520px; }
    .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; }
}

.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: #EFF6FF; color: #2563EB; }
.badge-default { background: var(--border-light, #f0f0f0); color: var(--text-secondary); }

/* ── Admin User Detail / Control Panel ── */
.admin-detail-card {
    background: white;
    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: white;
    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: white;
}
.drill-report-card.drill-completed {
    border-color: var(--success, #16a34a);
    background: #fafffe;
}
.drill-report-card.drill-error {
    border-color: var(--danger, #DC2626);
    background: #fffafa;
}
.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-primary, #1f2937);
}
.error-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.375rem 0.5rem;
    background: #fef2f2;
    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: #fafbfc;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
}
.explanation-dimension {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #fff;
    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: #fef2f2; color: #dc2626; }
.sufficiency-badge-warn { background: #fffbeb; color: #d97706; }
.sufficiency-badge-ok { background: #f0fdf4; color: #16a34a; }

/* 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: #fef2f2;
    border: 2px solid #fca5a5;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    color: #991b1b;
    font-size: 0.9rem;
    cursor: pointer;
    animation: flag-pulse 2s ease-in-out infinite;
}
.flag-banner:hover { background: #fee2e2; }
@keyframes flag-pulse {
    0%, 100% { border-color: #fca5a5; }
    50% { border-color: #ef4444; }
}
.user-row-flagged {
    background: #fef2f2 !important;
    border-left: 3px solid #ef4444;
}
.user-row-flagged td { background: #fef2f2 !important; }
.badge-danger { background: #fef2f2; color: #dc2626; font-weight: 600; }
