/* Epione Care — Mobile-First Design System (v3 — Navy/Brand) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Colors — Epione Brand palette */
    --primary: #10069F;
    --primary-light: #E8E6FF;
    --primary-dark: #0A0470;
    --primary-cyan: #00C2FF;
    --primary-cyan-light: #E8F6FF;
    --primary-glow: rgba(16, 6, 159, 0.12);
    --bg: #F5F5F7;
    --surface: #ffffff;
    --text: #1D1D1F;
    --text-secondary: #6E6E73;
    --border: #E8E8ED;

    /* Posture colors */
    --correct: #34C759;
    --hunched: #FF3B30;
    --head-forward: #FF9F0A;
    --leaning: #FF9F0A;
    --elevated: #A78BFA;

    /* Grade colors — brand system */
    --grade-a: #34C759;
    --grade-b: #10069F;
    --grade-c: #FF9F0A;
    --grade-d: #FF3B30;
    --grade-f: #FF3B30;

    /* Spacing (8px base) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* Radius */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 980px;

    /* Shadows — brand system */
    --shadow-sm: 0 2px 12px rgba(0,0,0,0.06);
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.10);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.12);
    --shadow-ai: 0 0 40px rgba(0,194,255,0.20);
    --shadow-btn-ai: 0 4px 16px rgba(0,194,255,0.30);

    /* Bottom nav height */
    --nav-h: 64px;
    --topbar-h: 56px;

    /* HIG enhancements */
    --info: #00C2FF;
    --surface-glass: rgba(255,255,255,0.80);
    --backdrop-blur: 20px;
    --transition-default: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    --metric-large: 48px;
    --radius-2xl: 28px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

button, a, input, select, .card, .action-card, .nav-item {
    transition: all var(--transition-default);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    /* prevent content hidden behind fixed bars */
    padding-top: var(--topbar-h);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
    min-height: 100dvh;
}

/* =============================
   TOP BAR
   ============================= */
.topbar {
    background: var(--surface-glass);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    border-bottom: 0.5px solid rgba(0,0,0,0.08);
    padding: 0 var(--sp-4);
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: none;
}

.topbar-brand {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.topbar-brand-name {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 700;
    font-size: 18px;
    background: linear-gradient(135deg, #10069F 0%, #00C2FF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.topbar-tagline {
    font-size: 9px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding-left: 30px;
    line-height: 1;
}

.topbar-brand svg { width: 26px; height: 26px; }
.topbar-subtitle { font-size: 11px; color: var(--text-secondary); text-align: right; max-width: 140px; line-height: 1.3; }

/* Desktop inline tabs — hidden on mobile */
.desktop-tabs { display: none; }

.tab-btn {
    padding: var(--sp-2) var(--sp-4);
    border: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.15s;
    min-height: 44px;
}

.tab-btn:hover { background: var(--primary-light); color: var(--primary); }
.tab-btn.active { background: var(--primary); color: white; }

/* =============================
   BOTTOM NAVIGATION
   ============================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--surface-glass);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    border-top: 0.5px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: stretch;
    z-index: 100;
    box-shadow: none;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    color: #9CA3AF;
    cursor: pointer;
    transition: color 0.15s;
    padding: var(--sp-1) var(--sp-2);
    min-height: 44px;
}

.nav-item.active { color: var(--primary); }
.nav-item svg { transition: transform 0.15s; }
.nav-item.active svg { transform: scale(1.1); stroke: var(--primary); }

/* Camera action button — elevated center button */
.nav-item-camera { position: relative; }

.nav-camera-btn {
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, #10069F, #00C2FF);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-btn-ai);
    margin-top: -22px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.nav-item-camera.active .nav-camera-btn,
.nav-item-camera:active .nav-camera-btn {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0,194,255,0.20);
}

.nav-item-camera.active { color: var(--primary); }

/* =============================
   MAIN CONTENT
   ============================= */
.main {
    padding: var(--sp-4);
    max-width: 600px;
    margin: 0 auto;
}

.page { display: none; }
.page.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

/* =============================
   HOME PAGE
   ============================= */
.home-hero {
    padding: var(--sp-4) 0 var(--sp-5);
}

.home-greeting {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--sp-1);
    letter-spacing: -0.3px;
}

.home-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Action stack — vertical cards */
.action-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
}

.action-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    box-shadow: var(--shadow);
    border: 0.5px solid rgba(0,0,0,0.06);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-height: 72px;
    transition: transform 0.12s, box-shadow 0.12s;
    -webkit-user-select: none;
    user-select: none;
}

.action-card:active {
    transform: scale(0.97);
    box-shadow: var(--shadow);
}

.action-primary {
    background: linear-gradient(135deg, #10069F 0%, #00C2FF 100%);
    border-color: transparent;
    color: white;
    box-shadow: var(--shadow-btn-ai);
}

.action-primary .action-title { color: white; }
.action-primary .action-desc { color: rgba(255,255,255,0.75); }
.action-primary .action-arrow { color: rgba(255,255,255,0.7); }
.action-primary .action-icon { background: rgba(255,255,255,0.2); color: white; }

.action-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.action-icon-secondary {
    background: #f3f4f6;
    color: var(--text);
}

.action-body { flex: 1; }
.action-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.action-desc { font-size: 12px; color: var(--text-secondary); }
.action-arrow { color: var(--border); flex-shrink: 0; }

/* Section label */
.section-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    margin-bottom: var(--sp-3);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-10) var(--sp-6);
    color: var(--text-secondary);
    text-align: center;
    font-size: 14px;
}

.empty-state svg { opacity: 0.25; }

/* Home session list */
.session-list-item {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    margin-bottom: var(--sp-2);
    border: 0.5px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    transition: transform var(--transition-default);
}

.session-list-item:active {
    transform: scale(0.98);
}

.session-list-score {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.session-list-info { flex: 1; min-width: 0; }
.session-list-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-list-meta { font-size: 12px; color: var(--text-secondary); }

/* =============================
   CARDS
   ============================= */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
    border: none;
    margin-bottom: var(--sp-3);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: var(--sp-4);
    color: var(--text);
}

/* =============================
   FORM ELEMENTS
   ============================= */
.form-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--sp-5);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-3);
}

.form-section-header {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: var(--sp-4);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.form-step-badge {
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.form-group { margin-bottom: var(--sp-4); }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--sp-1);
}

.required { color: var(--hunched); }

.form-input {
    width: 100%;
    min-height: 48px;
    padding: var(--sp-3) var(--sp-4);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-select {
    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'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}

/* =============================
   UPLOAD ZONE
   ============================= */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: var(--sp-8) var(--sp-6);
    text-align: center;
    margin-bottom: var(--sp-4);
    transition: all 0.2s;
    cursor: pointer;
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* === Guide Card === */
.guide-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.guide-diagram {
    background: #f8f9fb;
    padding: var(--sp-4);
    border-bottom: 1px solid var(--border);
}

.guide-steps {
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.guide-step {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    font-size: 14px;
    line-height: 1.4;
}

.guide-num {
    width: 24px;
    height: 24px;
    min-width: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.guide-tips {
    padding: var(--sp-3) var(--sp-4);
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    font-size: 12px;
    color: #92400e;
}

.upload-zone .upload-icon { font-size: 44px; margin-bottom: var(--sp-3); opacity: 0.4; }
.upload-zone .upload-text { font-weight: 500; font-size: 14px; margin-bottom: var(--sp-1); }
.upload-zone .upload-hint { font-size: 12px; color: var(--text-secondary); }

/* Upload buttons */
.upload-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}

.btn-camera {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--sp-4);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 52px;
    transition: background 0.15s;
}

.btn-camera:active { background: var(--primary-dark); }

.btn-upload {
    background: var(--surface);
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: var(--sp-4);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 52px;
    transition: background 0.15s;
}

.btn-upload:active { background: var(--primary-light); }

/* =============================
   BUTTONS
   ============================= */
.btn {
    padding: var(--sp-3) var(--sp-5);
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 44px;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; border-radius: var(--radius-full); }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-light); color: var(--primary); border-radius: var(--radius-full); }
.btn-secondary:active { background: #D0CCFF; }
.btn-danger { background: #fef2f2; color: #dc2626; }
.btn-lg { padding: var(--sp-4) var(--sp-8); font-size: 16px; min-height: 52px; }
.btn-full { width: 100%; margin-top: var(--sp-4); }
.btn-icon { padding: var(--sp-2); border-radius: var(--radius-sm); min-height: unset; }

/* =============================
   PROGRESS BAR
   ============================= */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: var(--sp-4) 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s;
}

/* =============================
   SCORE CIRCLE
   ============================= */
.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--sp-4);
    border: 6px solid;
    animation: scoreReveal 0.5s ease;
}

@keyframes scoreReveal {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.score-circle .score-value { font-size: var(--metric-large); font-weight: 700; line-height: 1; }
.score-circle .score-label { font-size: 11px; color: var(--text-secondary); }

.score-a { border-color: var(--grade-a); }
.score-a .score-value { color: var(--grade-a); }
.score-b { border-color: var(--grade-b); }
.score-b .score-value { color: var(--grade-b); }
.score-c { border-color: var(--grade-c); }
.score-c .score-value { color: var(--grade-c); }
.score-d { border-color: var(--grade-d); }
.score-d .score-value { color: var(--grade-d); }
.score-f { border-color: var(--grade-f); }
.score-f .score-value { color: var(--grade-f); }

/* =============================
   METRICS
   ============================= */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.metric-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--sp-4);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    text-align: center;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.metric-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: var(--sp-1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =============================
   POSTURE BADGE
   ============================= */
.posture-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
}

.posture-badge.correct { background: #dcfce7; color: #166534; }
.posture-badge.hunched { background: #fef2f2; color: #991b1b; }
.posture-badge.head-forward { background: #fefce8; color: #854d0e; }
.posture-badge.leaning { background: #fff7ed; color: #9a3412; }

.posture-dot { width: 8px; height: 8px; border-radius: 50%; }
.posture-dot.correct { background: var(--correct); }
.posture-dot.hunched { background: var(--hunched); }
.posture-dot.head-forward { background: var(--head-forward); }
.posture-dot.leaning { background: var(--leaning); }

/* =============================
   A/B COMPARE
   ============================= */
.compare-slot { margin-bottom: var(--sp-4); }

.compare-slot-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--sp-2);
}

.compare-slot-epione .compare-slot-label { color: var(--primary); }
.compare-slot-regular .compare-slot-label { color: var(--hunched); }

.vs-badge {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-secondary);
    padding: var(--sp-2) 0 var(--sp-4);
}

/* =============================
   REPORTS PAGE
   ============================= */
.report-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    border: 0.5px solid rgba(0,0,0,0.06);
    box-shadow: var(--shadow-sm);
    min-height: 68px;
    margin-bottom: var(--sp-2);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
    transition: transform 0.12s;
}

.report-card:active { transform: scale(0.98); }

.report-card-score {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

.report-card-body { flex: 1; min-width: 0; }
.report-card-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-card-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.report-card-arrow { color: var(--border); flex-shrink: 0; }

/* Hidden table (kept for JS compat) */
.session-table { display: none; }

/* =============================
   RECOMMENDATION CARD
   ============================= */
.rec-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    margin-bottom: var(--sp-3);
    border-left: 4px solid var(--primary);
}

.rec-card.priority-1 { border-left-color: var(--hunched); }
.rec-card.priority-2 { border-left-color: var(--head-forward); }
.rec-card.priority-3 { border-left-color: var(--correct); }

.rec-title { font-weight: 600; margin-bottom: var(--sp-2); font-size: 14px; }
.rec-reason { font-size: 13px; color: var(--text-secondary); margin-bottom: var(--sp-2); }
.rec-action { font-size: 13px; }

/* =============================
   EXERCISE TOAST
   ============================= */
.exercise-toast {
    position: fixed;
    bottom: calc(var(--nav-h) + var(--sp-4));
    left: var(--sp-4);
    right: var(--sp-4);
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--sp-5);
    box-shadow: var(--shadow-xl);
    border: 0.5px solid rgba(0,0,0,0.06);
    z-index: 200;
    animation: slideUp 0.3s ease;
    display: none;
}

.exercise-toast.show { display: block; }
.exercise-toast .toast-title { font-weight: 600; margin-bottom: var(--sp-2); }
.exercise-toast .toast-steps { font-size: 13px; color: var(--text-secondary); padding-left: var(--sp-5); }
.exercise-toast .toast-steps li { margin-bottom: var(--sp-1); }

.toast-close {
    position: absolute;
    top: var(--sp-2);
    right: var(--sp-3);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 22px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

@keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* =============================
   SURVEY MODAL
   ============================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 300;
}

.modal-overlay.show {
    display: flex;
    animation: overlayFadeIn 0.25s ease;
}

.modal-overlay.show .modal {
    animation: sheetSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlayFadeIn {
    from { background: rgba(0,0,0,0); }
    to { background: rgba(0,0,0,0.4); }
}

@keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    padding: var(--sp-8) var(--sp-5) var(--sp-6);
    width: 100%;
    max-height: 85dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
}

.modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 5px;
    background: #D1D5DB;
    border-radius: var(--radius-full);
    margin: 0 auto var(--sp-5);
}

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: var(--sp-6); }

.survey-item { margin-bottom: var(--sp-5); }
.survey-label { font-weight: 500; margin-bottom: var(--sp-3); display: block; font-size: 14px; }

.pill-selector {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

.pill-btn {
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text);
}

.pill-btn:active { border-color: var(--primary); }
.pill-btn.selected { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 8px rgba(16,6,159,0.25); }

/* =============================
   GRID HELPERS
   ============================= */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

/* =============================
   UTILITY
   ============================= */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.hidden { display: none !important; }

/* Glassmorphism */
.glass {
    background: var(--surface-glass);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
}

/* iOS 18 vibrancy */
.surface-elevated {
    background: var(--surface);
    box-shadow: var(--shadow);
    border: 0.5px solid rgba(0,0,0,0.06);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* =============================
   DESKTOP ENHANCEMENTS
   (min-width: 640px = tablet+)
   ============================= */
@media (min-width: 640px) {
    :root {
        --nav-h: 68px;
    }

    .main { padding: var(--sp-6); }

    .home-greeting { font-size: 30px; }

    .action-stack {
        display: grid;
        grid-template-columns: 1fr;
    }

    .form-row-2 { grid-template-columns: 1fr 1fr; }

    .upload-buttons { grid-template-columns: 1fr 1fr; }

    .metrics-grid { grid-template-columns: repeat(3, 1fr); }

    .grid-2 { grid-template-columns: 1fr 1fr; }

    .modal {
        border-radius: var(--radius-2xl);
        max-width: 520px;
        align-self: center;
        padding: var(--sp-8);
    }

    .modal::before { display: none; }

    .modal-overlay { align-items: center; }

    .exercise-toast {
        left: auto;
        right: var(--sp-6);
        bottom: calc(var(--nav-h) + var(--sp-4));
        max-width: 380px;
    }
}

@media (min-width: 900px) {
    body {
        padding-top: var(--topbar-h);
        padding-bottom: 0;
    }

    /* On large screens, show top tabs instead of bottom nav */
    .bottom-nav { display: none; }

    .desktop-tabs {
        display: flex;
        gap: var(--sp-1);
    }

    .topbar-subtitle { display: none; }

    .main {
        padding: var(--sp-8) var(--sp-6);
        max-width: 1200px;
    }

    .metrics-grid { grid-template-columns: repeat(4, 1fr); }
    .grid-2 { grid-template-columns: 1fr 1fr; }

    .exercise-toast {
        bottom: var(--sp-6);
    }

    .action-stack {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .action-card {
        flex-direction: column;
        text-align: center;
        gap: var(--sp-3);
        padding: var(--sp-6);
    }

    .action-arrow { display: none; }
    .action-body { flex: unset; }
}

/* ==================== REAL-TIME TRACKING ==================== */

.tracking-video-container {
    position: relative;
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-lg);
}

.tracking-video-container video {
    width: 100%;
    display: block;
}

.tracking-video-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.tracking-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) 0;
    gap: var(--sp-3);
}

.tracking-timer {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
}

.btn-danger {
    background: #FF6B6B;
    color: #fff;
    border: none;
    padding: var(--sp-3) var(--sp-6);
    border-radius: var(--radius-full);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:active { background: #e55555; transform: scale(0.98); }

/* Tracking hero card */
.tracking-hero-card {
    text-align: center;
    padding: var(--sp-8) var(--sp-5);
}

.tracking-hero-emoji {
    font-size: 56px;
    margin-bottom: var(--sp-4);
}

.tracking-hero-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 var(--sp-2);
    letter-spacing: -0.2px;
}

.btn-start-big {
    padding: var(--sp-4) var(--sp-10);
    font-size: 17px;
    font-weight: 600;
    border-radius: var(--radius-full);
    min-height: 52px;
    border: none;
    color: #fff;
    background: linear-gradient(135deg, #10069F, #00C2FF);
    box-shadow: var(--shadow-btn-ai);
    cursor: pointer;
    transition: transform var(--transition-default), box-shadow var(--transition-default);
}
.btn-start-big:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(0,194,255,0.20); }

/* Camera guide card */
.tracking-guide-card {
    text-align: center;
    padding: var(--sp-6) var(--sp-5);
}

.tracking-guide-diagram {
    background: var(--primary-cyan-light);
    border-radius: var(--radius);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
    border: 1px solid rgba(0,194,255,0.20);
}

.tracking-guide-steps {
    text-align: left;
    margin-bottom: var(--sp-4);
}

.tracking-guide-step {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
    font-size: 14px;
}

.tracking-guide-num {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.tracking-guide-warning {
    background: #fef3c7;
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #92400e;
    margin-bottom: var(--sp-4);
}

details.card summary {
    list-style: none;
    cursor: pointer;
}

details.card summary::-webkit-details-marker {
    display: none;
}

details.card[open] summary {
    margin-bottom: var(--sp-3);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border);
}

.demo-card { cursor: pointer; }
.demo-card:active { transform: scale(0.98); }

.btn-switch-cam {
    background: rgba(255,255,255,0.9);
    color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 8px 16px;
    border-radius: 980px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    backdrop-filter: blur(8px);
}
.btn-switch-cam:active { background: var(--primary-light); transform: scale(0.95); }

.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.form-row .form-input { flex: 1; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* =============================
   LEAD CAPTURE GATE
   ============================= */
.lead-gate-card {
    animation: fadeInUp 0.3s ease;
}

.lead-icon-circle {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-3);
}

.lead-zalo-cta {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--primary-cyan-light);
    border-radius: var(--radius);
    border: 1px solid rgba(0,194,255,0.25);
    margin: var(--sp-4) 0;
    transition: background var(--transition-default);
    text-decoration: none;
    color: inherit;
}

.lead-zalo-cta:active {
    background: #C8EDFF;
}

.lead-zalo-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: #22c55e;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.lead-error {
    background: #fef2f2;
    color: #dc2626;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-top: var(--sp-3);
}

.lead-consent-label {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    cursor: pointer;
    margin-top: var(--sp-4);
}

.lead-consent-label input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Tip result cards */
.tip-result-card {
    padding: var(--sp-3);
    background: #fef3c7;
    border-radius: var(--radius-sm);
    margin-bottom: var(--sp-2);
    border-left: 3px solid var(--head-forward);
    font-size: 13px;
}

.tip-result-title { font-weight: 600; }
.tip-result-body { color: var(--text-secondary); margin-top: var(--sp-1); }

@keyframes fadeInUp {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* =============================
   FOCUS STYLES (Accessibility)
   ============================= */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* inputs already have box-shadow focus ring */
input:focus-visible,
select:focus-visible {
    outline: none;
}

/* =============================
   DESKTOP HOVER EFFECTS
   (pointer devices only)
   ============================= */
@media (hover: hover) {
    .action-card:hover {
        box-shadow: var(--shadow-lg);
        transform: translateY(-1px);
    }

    .report-card:hover {
        box-shadow: var(--shadow);
    }

    .session-list-item:hover {
        box-shadow: var(--shadow);
    }
}

/* =============================
   REDUCED MOTION SUPPORT
   ============================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =============================
   DARK MODE TOKENS
   (Phase 2 — tokens only, not active)
   ============================= */
@media (prefers-color-scheme: dark) {
    /* Uncomment when ready:
    :root {
        --bg: #111827;
        --surface: #1F2937;
        --text: #F3F4F6;
        --text-secondary: #9CA3AF;
        --border: #374151;
        --primary: #2FD9B7;
    }
    */
}

/* ===== Child Mode Styles ===== */
:root {
    --child-color: #00A86B;          /* Emerald green — distinct from adult navy */
    --child-color-light: #E6F7F1;
    --child-color-dark: #007A4D;
}

/* Child action card — Navy + Green gradient */
.action-child {
    background: linear-gradient(135deg, var(--child-color-dark) 0%, #00C2FF 100%);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 16px rgba(0, 168, 107, 0.28);
}
.action-child .action-title { color: white; }
.action-child .action-desc { color: rgba(255,255,255,0.75); }
.action-child .action-arrow { color: rgba(255,255,255,0.7); }
.action-icon-child {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Child form modal icon */
.child-icon-circle {
    background: var(--child-color-light);
}

/* Gender pill buttons inside child form */
.child-gender-pills {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.child-pill-btn {
    flex: 1;
    padding: 10px 0;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}
.child-pill-btn:active { border-color: var(--child-color); }
.child-pill-btn.selected {
    background: var(--child-color);
    color: white;
    border-color: var(--child-color);
    box-shadow: 0 2px 8px rgba(0,168,107,0.25);
}
