/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
    /* Palette */
    --indigo:      #4f46e5;
    --indigo-dark: #4338ca;
    --violet:      #7c3aed;
    --indigo-pale: #eef2ff;
    --green:       #059669;
    --green-light: #d1fae5;
    --amber:       #f59e0b;
    --amber-light: #fef3c7;
    --red:         #dc2626;
    --gray-50:     #f9fafb;
    --gray-100:    #f3f4f6;
    --gray-200:    #e5e7eb;
    --gray-300:    #d1d5db;
    --gray-400:    #9ca3af;
    --gray-500:    #6b7280;
    --gray-600:    #4b5563;
    --gray-700:    #374151;
    --gray-800:    #1f2937;
    --gray-900:    #111827;
    --radius:      12px;
    --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);

    /* Theme tokens — game (default) */
    --t-header-bg:       linear-gradient(135deg, #4338ca 0%, #7c3aed 100%);
    --t-header-text:     #ffffff;
    --t-header-border:   none;
    --t-auth-bg:         linear-gradient(150deg, #e0e7ff 0%, #f3e8ff 100%);
    --t-body-bg:         #f3f4f6;
    --t-logo-color:      #3730a3;
    --t-daily-card-bg:   linear-gradient(180deg, #fafbff 0%, #fff 60%);
    --t-primary:         #4f46e5;
    --t-primary-dark:    #4338ca;
    --t-select-bg:       rgba(255,255,255,.18);
    --t-select-color:    #ffffff;
    --t-select-border:   rgba(255,255,255,.3);
    --t-logout-color:    rgba(255,255,255,.8);
    --t-logout-border:   rgba(255,255,255,.35);
    --t-logout-hover-bg: rgba(255,255,255,.15);
}

/* ── Bright theme ──────────────────────────────────────────────────────────── */
body.theme-bright {
    --t-header-bg:       linear-gradient(135deg, #0891b2 0%, #7c3aed 100%);
    --t-auth-bg:         linear-gradient(150deg, #cffafe 0%, #fef9c3 100%);
    --t-body-bg:         #fff7ed;
    --t-logo-color:      #164e63;
    --t-daily-card-bg:   linear-gradient(180deg, #ecfeff 0%, #fff 60%);
    --t-primary:         #0891b2;
    --t-primary-dark:    #0e7490;
    --indigo:            #0891b2;
    --indigo-dark:       #0e7490;
    --violet:            #7c3aed;
    --indigo-pale:       #cffafe;
}

/* ── Classic theme ─────────────────────────────────────────────────────────── */
body.theme-classic {
    --t-header-bg:       #ffffff;
    --t-header-text:     #374151;
    --t-header-border:   1px solid #e5e7eb;
    --t-auth-bg:         #f9fafb;
    --t-body-bg:         #f9fafb;
    --t-logo-color:      #4f46e5;
    --t-daily-card-bg:   #ffffff;
    --t-primary:         #4f46e5;
    --t-primary-dark:    #4338ca;
    --t-select-bg:       #eef2ff;
    --t-select-color:    #4f46e5;
    --t-select-border:   #c7d2fe;
    --t-logout-color:    #4f46e5;
    --t-logout-border:   #4f46e5;
    --t-logout-hover-bg: #eef2ff;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--t-body-bg);
    color: var(--gray-900);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;   /* prevent elastic bounce on iOS/Android */
}

/* ── Auth view ────────────────────────────────────────────────────────────── */
#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.25rem 1rem;
    background: var(--t-auth-bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .2rem;
}

.logo-flame {
    font-size: 2rem;
    line-height: 1;
}

.logo {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--t-logo-color);
    letter-spacing: -0.5px;
}

.auth-hero {
    text-align: center;
    margin-bottom: .9rem;
}

.auth-hero .auth-logo {
    justify-content: center;
    margin-bottom: .35rem;
}

.tagline {
    color: var(--gray-500);
    margin: 0;
    font-size: .9rem;
    line-height: 1.45;
    max-width: 22rem;
    margin-inline: auto;
}

/* ── Auth value props — the 30-second "what & why" ────────────────────────── */
.auth-value-props {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .7rem;
    margin: 0 0 1.1rem;
    padding: .85rem .9rem;
    background: linear-gradient(180deg, rgba(255,255,255,.55) 0%, rgba(255,255,255,.25) 100%);
    border: 1px solid rgba(79,70,229,.1);
    border-radius: var(--radius);
}

.auth-value {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
}

.auth-value-icon {
    font-size: 1.25rem;
    line-height: 1.35;
    flex-shrink: 0;
    width: 1.6rem;
    text-align: center;
}

.auth-value-rickie {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--indigo-pale);
    margin-top: -.1rem;
}

.auth-value-text {
    font-size: .84rem;
    line-height: 1.45;
    color: var(--gray-600);
}

.auth-value-text b {
    color: var(--gray-900);
    font-weight: 700;
}

.rickie-mission-intro {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .85rem;
    font-size: .82rem;
    color: var(--gray-600);
}

/* Small helper text under a field (e.g. password requirements) */
.field-hint {
    font-size: .75rem;
    color: var(--gray-500);
    margin: -.35rem 0 .1rem;
    line-height: 1.4;
}

/* Quiet trust reassurance at the foot of the auth card */
.auth-trust-line {
    text-align: center;
    font-size: .72rem;
    color: var(--gray-400);
    margin: .9rem 0 0;
    line-height: 1.4;
}

/* ── Auth guest divider & button ──────────────────────────────────────────── */
.auth-guest-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0 .75rem;
    color: var(--gray-400);
    font-size: .8rem;
}

.auth-guest-divider::before,
.auth-guest-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.btn-guest {
    width: 100%;
    padding: .7rem;
    background: none;
    color: var(--gray-500);
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-guest:hover {
    background: var(--gray-50);
    color: var(--gray-700);
    border-color: var(--gray-400);
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.guest-mode-banner {
    background: var(--indigo-pale);
    color: var(--indigo-dark);
    border-radius: var(--radius);
    padding: .6rem 1rem;
    margin: 0 0 1rem;
    font-size: .82rem;
    text-align: center;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1.5rem;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: .5rem .85rem;
    cursor: pointer;
    font-size: .95rem;
    color: var(--gray-500);
    transition: color .15s;
}

.tab.active {
    color: var(--indigo);
    border-bottom-color: var(--indigo);
    font-weight: 700;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: .75rem; }

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: .7rem .85rem;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
}

input:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.input-row { display: flex; gap: .5rem; }
.input-row input { flex: 1; min-width: 0; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
    background: var(--indigo);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .7rem 1.25rem;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, transform .1s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover  { background: var(--indigo-dark); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { background: #a5b4fc; cursor: default; transform: none; }

.btn-full { width: 100%; padding: .8rem; font-size: 1rem; }

.btn-logout {
    background: none;
    color: var(--t-logout-color);
    border: 1.5px solid var(--t-logout-border);
    border-radius: 8px;
    padding: .4rem .85rem;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-logout:hover {
    background: var(--t-logout-hover-bg);
}

.btn-done {
    background: var(--green-light);
    color: #065f46;
    border: none;
    border-radius: 8px;
    padding: .55rem 1rem;
    font-size: .9rem;
    font-weight: 700;
    cursor: default;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Site header ──────────────────────────────────────────────────────────── */
.site-header {
    background: var(--t-header-bg);
    color: var(--t-header-text);
    border-bottom: var(--t-header-border);
    padding: .85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 10;
    padding-top: calc(.85rem + env(safe-area-inset-top, 0px));
}

.header-logo {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.header-flame { font-size: 1.3rem; line-height: 1; }

.header-brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--t-header-text);
    letter-spacing: -0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-shrink: 0;
}

/* ── Skill level select ───────────────────────────────────────────────────── */
.skill-select {
    -webkit-appearance: none;
    appearance: none;
    background: var(--t-select-bg);
    color: var(--t-select-color);
    border: 1.5px solid var(--t-select-border);
    border-radius: 20px;
    padding: .35rem .85rem;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
}

/* Keyboard focus was only a faint opacity change — give the difficulty/Rickie
   selects a real, visible ring (keyboard users only, via :focus-visible). */
.skill-select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .45);
    border-color: var(--indigo);
}

.skill-select option { background: #3730a3; color: #fff; }

/* ── Settings menu (gear → dropdown that holds difficulty/Rickie/theme/logout) ── */
.header-right { position: relative; }

.settings-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--t-select-bg);
    color: var(--t-select-color);
    border: 1.5px solid var(--t-select-border);
    font-size: 1.05rem;
    cursor: pointer;
    transition: background .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.settings-toggle:hover  { background: var(--t-logout-hover-bg); }
.settings-toggle:active { transform: scale(.92); }
.settings-toggle.active { background: var(--t-logout-hover-bg); }
.settings-toggle-icon { line-height: 1; }

.settings-menu {
    position: absolute;
    top: calc(100% + .55rem);
    right: 0;
    width: 250px;
    max-width: calc(100vw - 1.5rem);
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: .9rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: .7rem;
    animation: settings-menu-in .16s ease;
}

@keyframes settings-menu-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .settings-menu { animation: none; }
}

.settings-menu-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--gray-400);
    margin: 0;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.settings-label {
    font-size: .88rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* Selects live in a white panel now — override the header's white-on-gradient look. */
.settings-menu .skill-select {
    background: var(--gray-100);
    color: var(--gray-900);
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    padding: .35rem .6rem;
}
.settings-menu .skill-select option { background: #fff; color: var(--gray-900); }

/* Theme toggle: consistent light styling inside the panel regardless of active theme. */
.settings-menu .theme-toggle { background: var(--gray-100); }
.settings-menu .theme-btn:hover  { background: var(--gray-200); }
.settings-menu .theme-btn.active { background: var(--indigo-pale); opacity: 1; }

.settings-divider {
    height: 1px;
    background: var(--gray-200);
    margin: .05rem 0;
}

.settings-logout {
    width: 100%;
    color: var(--gray-600);
    border-color: var(--gray-300);
}
.settings-logout:hover { background: var(--gray-50); color: var(--gray-800); }

/* Forget-our-conversations: a quiet, low-emphasis control (memory is per-account
   and rarely used) that reveals its destructive nature only on hover/focus. */
.btn-forget-coach {
    min-height: 44px;
    padding: .35rem .7rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-100);
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-forget-coach:hover,
.btn-forget-coach:focus-visible {
    background: #fdecec;
    color: #b42318;
    border-color: #f3b4ae;
}
.btn-forget-coach:disabled { opacity: .6; cursor: default; }

/* ── Dashboard container ──────────────────────────────────────────────────── */
.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ── Daily 5 card ─────────────────────────────────────────────────────────── */
.daily-card {
    background: var(--t-daily-card-bg);
    border: 1.5px solid var(--gray-200);
    padding: 1.25rem 1.25rem 1rem;
    /* Soft, on-brand elevation — the mission is the centre of the app, so it
       sits a touch above everything else on the page. */
    box-shadow: 0 6px 20px rgba(67, 56, 202, .07), 0 1px 3px rgba(0, 0, 0, .05);
}

.daily-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.daily-mission-meta {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-top: .1rem;
    flex-wrap: wrap;
}

.daily-mission-date {
    font-size: .75rem;
    color: var(--gray-500);
    font-weight: 500;
}

.daily-streak-badge {
    font-size: .75rem;
    font-weight: 700;
    color: var(--amber);
}

.daily-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.daily-count-badge {
    background: var(--indigo);
    color: #fff;
    border-radius: 20px;
    padding: .25rem .7rem;
    font-size: .82rem;
    font-weight: 700;
    min-width: 2.8rem;
    text-align: center;
    transition: background .3s;
}

.daily-count-badge.badge-complete {
    background: var(--green);
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.daily-progress-track {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.daily-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--indigo) 0%, var(--violet) 100%);
    border-radius: 4px;
    transition: width .45s cubic-bezier(.4,0,.2,1);
}

.daily-progress-fill.complete {
    background: linear-gradient(90deg, var(--green) 0%, #10b981 100%);
    box-shadow: 0 0 10px rgba(16, 185, 129, .45);
}

/* ── Rise Again ceremony ──────────────────────────────────────────────────── */
.rise-again-ceremony {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
}

.rise-again-avatar {
    width: 48px;
    height: 48px;
    margin: 0 auto .5rem;
    display: block;
}

.rise-again-emoji {
    font-size: 2.2rem;
    margin: 0 0 .6rem;
    line-height: 1;
}

.rise-again-title {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--t-primary);
    margin: 0 0 .75rem;
}

.rise-again-body {
    font-size: .9rem;
    color: var(--t-secondary);
    line-height: 1.6;
    margin: 0 0 .15rem;
}

.rise-again-btn {
    margin-top: 1.5rem;
    min-width: 9rem;
}

/* ── Complete banner ──────────────────────────────────────────────────────── */
.daily-complete-banner {
    display: flex;
    align-items: center;
    gap: .85rem;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1.5px solid #6ee7b7;
    border-radius: 10px;
    padding: .9rem 1rem;
    margin-bottom: .85rem;
}

.complete-emoji { font-size: 1.8rem; line-height: 1; flex-shrink: 0; }

.complete-title {
    font-weight: 700;
    font-size: .95rem;
    color: #065f46;
}

.complete-sub {
    font-size: .8rem;
    color: #047857;
    margin-top: .1rem;
}

.rickie-handoff-line {
    font-size: .85rem;
    color: var(--gray-600);
    margin: 0 0 .85rem;
}

/* ── Guest complete banner ────────────────────────────────────────────────── */
.guest-complete-banner {
    flex-direction: column;
    align-items: stretch;
}

.guest-banner-top {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.guest-banner-desc {
    font-size: .82rem;
    color: #047857;
    margin-top: .5rem;
    line-height: 1.5;
}

.guest-banner-actions {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
    flex-wrap: wrap;
}

.guest-banner-actions .btn-primary {
    flex: 1;
    min-width: 110px;
    padding: .6rem .85rem;
    font-size: .9rem;
}

.btn-guest-login {
    flex: 1;
    min-width: 110px;
    padding: .6rem .85rem;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    background: none;
    border: 1.5px solid #6ee7b7;
    border-radius: 8px;
    color: #065f46;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-guest-login:hover {
    background: rgba(16,185,129,.1);
}

/* ── Today's Insight card ─────────────────────────────────────────────────── */
.insight-card {
    background: var(--indigo-pale);
    border-radius: 10px;
    border-left: 3px solid var(--t-primary);
    padding: .85rem 1rem;
    margin-bottom: .85rem;
}

.insight-category {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--t-primary);
    margin-bottom: .4rem;
}

.insight-text {
    font-size: .9rem;
    line-height: 1.55;
    color: var(--gray-700);
}

/* ── Brain Boost teaser / reveal ──────────────────────────────────────────── */
.insight-teaser-top {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .65rem;
}

.rickie-avatar-sm {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--indigo-pale);
}

.insight-teaser-text {
    font-size: .9rem;
    line-height: 1.55;
    color: var(--gray-700);
    margin: 0;
}

.insight-reveal-btn {
    background: var(--t-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .65rem 1rem;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .15s, transform .1s;
}
.insight-reveal-btn:hover  { opacity: .85; }
.insight-reveal-btn:active { transform: scale(.97); }

/* ── Insight tell-more link ───────────────────────────────────────────────── */
.insight-tell-more {
    background: none;
    border: none;
    font-size: .8rem;
    color: var(--t-primary);
    cursor: pointer;
    padding: .4rem 0 0;
    display: block;
    text-align: right;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

.insight-tell-more:hover { opacity: .75; }

/* ── Brain Boost question (multiple choice) ───────────────────────────────── */
.bb-question-wrap {
    margin-bottom: .85rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--gray-200);
}

.bb-question-text {
    font-size: .92rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 .65rem;
    line-height: 1.45;
}

.bb-options {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.bb-option-btn {
    width: 100%;
    min-height: 44px;
    text-align: left;
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    padding: .6rem .85rem;
    font-size: .87rem;
    color: var(--gray-700);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s, background .15s;
}

.bb-option-btn:hover:not(:disabled) { border-color: var(--t-primary); }
.bb-option-btn:active:not(:disabled) { transform: scale(.99); }
.bb-option-btn:disabled { cursor: default; opacity: .7; }

.bb-option-correct {
    border-color: var(--green) !important;
    background: var(--green-light) !important;
    color: #065f46 !important;
    font-weight: 700;
    opacity: 1 !important;
}

.bb-option-incorrect {
    border-color: var(--amber) !important;
    background: var(--amber-light) !important;
    color: #92400e !important;
    font-weight: 700;
    opacity: 1 !important;
}

.bb-feedback {
    margin: .65rem 0 0;
    font-size: .85rem;
    font-weight: 700;
}

.bb-feedback-correct   { color: #065f46; }
.bb-feedback-incorrect { color: #92400e; }

.bb-explanation {
    font-size: .85rem;
    line-height: 1.55;
    color: var(--gray-700);
    margin: .4rem 0 0;
}

.bb-points-note {
    font-size: .75rem;
    font-weight: 600;
    color: var(--gray-500);
    margin: .5rem 0 0;
}

/* ── Coach panel ──────────────────────────────────────────────────────────── */
.coach-panel {
    margin-bottom: .85rem;
}

.coach-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .6rem;
}

.coach-header-left {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.coach-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--indigo-pale);
}

.coach-title {
    font-weight: 700;
    font-size: .95rem;
    color: var(--t-primary);
}

.coach-mood-badge {
    font-size: .85rem;
    line-height: 1;
}

.coach-close {
    background: none;
    border: none;
    font-size: .82rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.coach-close:hover { color: var(--gray-700); }

.coach-thread {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: .65rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    scroll-behavior: smooth;
}

.coach-msg {
    font-size: .88rem;
    line-height: 1.55;
    padding: .6rem .8rem;
    border-radius: 10px;
    max-width: 90%;
    word-break: break-word;
}

.coach-msg-line {
    margin: 0 0 .45rem;
}

.coach-msg-line:last-child {
    margin-bottom: 0;
}

.coach-msg-coach {
    background: var(--indigo-pale);
    color: var(--gray-700);
    align-self: flex-start;
}

.coach-msg-user {
    background: var(--gray-100);
    color: var(--gray-700);
    align-self: flex-end;
}

.coach-input-row {
    display: flex;
    gap: .5rem;
}

.coach-input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    padding: .55rem .75rem;
    font-size: .9rem;
    background: var(--bg-card);
    color: var(--t-main);
    transition: border-color .15s, box-shadow .15s;
}

.coach-input:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.coach-send {
    padding: .55rem .9rem;
    font-size: .88rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Ask about StreakFit footer link ──────────────────────────────────────── */
.coach-ask-btn {
    background: none;
    border: none;
    font-size: .78rem;
    color: var(--gray-500);
    cursor: pointer;
    /* 44px tap target without changing the link's visual weight */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 .25rem;
    -webkit-tap-highlight-color: transparent;
}

.coach-ask-btn:hover { color: var(--t-primary); }
.coach-ask-btn:focus-visible {
    outline: 2px solid var(--indigo);
    outline-offset: 2px;
    border-radius: 8px;
}

/* ── Daily exercise rows ──────────────────────────────────────────────────── */
.daily-exercise-row {
    min-height: 48px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 .75rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--gray-100);
    min-height: 52px;
}

.daily-exercise-row:last-child { border-bottom: none; }

/* Completed rows: stay readable — accomplished, not erased */
.daily-exercise-done {
    background: #f0fdf4;
    border-radius: 6px;
    padding-left: .5rem;
    padding-right: .5rem;
    margin-left: -.5rem;
    margin-right: -.5rem;
}
.daily-exercise-done .daily-exercise-name { color: var(--gray-500); }

.daily-exercise-info { flex: 1; min-width: 0; }

.daily-exercise-name {
    font-size: .95rem;
    font-weight: 600;
    color: var(--gray-900);
}

.daily-exercise-meta {
    font-size: .78rem;
    color: var(--gray-500);
    display: block;
    margin-top: .1rem;
}

/* How-to / tips — quiet chips, not dated underlined links */
.btn-how-to,
.btn-coach-link {
    border: none;
    border-radius: 999px;
    padding: .26rem .72rem;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    /* 44px tap target — fits within the 52px exercise row */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    transition: background .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn-how-to:focus-visible,
.btn-coach-link:focus-visible {
    outline: 2px solid var(--indigo);
    outline-offset: 2px;
}

/* Pre-completion teaser (Insight + Brain Boost discoverability) — quiet. */
.next-up-teaser {
    text-align: center;
    color: var(--gray-500);
    font-size: .8rem;
    margin: .9rem 0 .1rem;
}
.next-up-teaser p { margin: 0; }

.btn-how-to {
    background: var(--indigo-pale);
    color: var(--indigo-dark);
}
.btn-how-to:hover { background: #e0e7ff; }

.btn-coach-link {
    background: var(--gray-100);
    color: var(--gray-600);
}
.btn-coach-link:hover { background: var(--gray-200); color: var(--gray-800); }

.exercise-link-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem .4rem;
    margin-top: .4rem;
}

/* Expandable instructions panel — wraps to full width via flex-wrap on parent */
.exercise-instructions {
    width: 100%;
    padding: .5rem 0 .25rem;
    font-size: .82rem;
    line-height: 1.55;
    color: var(--gray-600);
    border-top: 1px solid var(--gray-100);
    margin-top: .35rem;
}

.exercise-illustration {
    display: block;
    width: 80px;
    height: 80px;
    object-fit: contain;
    float: right;
    margin: 0 0 .25rem .75rem;
    border-radius: 8px;
    background: var(--gray-50, #f9fafb);
}

/* Category pills — each category gets its own colour */
.daily-category-pill {
    font-size: .7rem;
    font-weight: 600;
    border-radius: 4px;
    padding: .2rem .45rem;
    white-space: nowrap;
    text-transform: capitalize;
    flex-shrink: 0;
}

.pill-upper-body    { background: #dbeafe; color: #1d4ed8; }
.pill-lower-body    { background: #dcfce7; color: #166534; }
.pill-core          { background: #ffedd5; color: #c2410c; }
.pill-mobility      { background: #f3e8ff; color: #6d28d9; }
.pill-conditioning  { background: #fee2e2; color: #b91c1c; }

/* Mark Done button */
.btn-daily-complete {
    background: var(--indigo);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .65rem 1rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}

.btn-daily-complete:hover    { background: var(--indigo-dark); }
.btn-daily-complete:active   { transform: scale(.95); }
.btn-daily-complete:disabled { background: #a5b4fc; cursor: default; transform: none; }

.btn-daily-done {
    background: var(--green-light);
    color: #065f46;
    border: none;
    border-radius: 8px;
    padding: .65rem 1rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 800;
    cursor: default;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Daily footer ─────────────────────────────────────────────────────────── */
.daily-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .75rem;
    flex-wrap: wrap;
    gap: .4rem;
}

.daily-progress-text {
    font-size: .82rem;
    color: var(--gray-500);
}

/* Streak helper text — below progress bar, visible while mission is incomplete */
.daily-streak-helper {
    font-size: .78rem;
    color: var(--gray-500);
    margin-bottom: .75rem;
    font-style: italic;
}

/* ── Stats row — current streak · best streak · total missions ───────────── */
.daily-stats-row {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .85rem;
    flex-wrap: wrap;
}

.daily-stat {
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-600);
}

.daily-stat-sep {
    font-size: .78rem;
    color: var(--gray-400);
}

/* ── Rickie's Journey card ────────────────────────────────────────────────── */
.journey-card {
    text-align: left;
}

.journey-header {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin-bottom: 1.1rem;
}

.journey-avatar {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--indigo-pale);
    animation: journey-avatar-bob 4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .journey-avatar {
        animation: none;
    }
}

@keyframes journey-avatar-bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-4px) rotate(-2deg); }
}

.journey-header-text {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.journey-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 0;
}

.journey-level-line {
    display: flex;
    align-items: baseline;
    gap: .4rem;
    margin: 0;
    flex-wrap: wrap;
}

.journey-level {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--t-primary);
}

.journey-level-title {
    font-size: .85rem;
    font-weight: 600;
    color: var(--gray-500);
}

.journey-xp-track {
    height: 10px;
    background: var(--gray-200);
    border-radius: 5px;
    margin-bottom: .5rem;
    overflow: hidden;
}

.journey-xp-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--indigo) 0%, var(--violet) 100%);
    border-radius: 5px;
    transition: width .45s cubic-bezier(.4,0,.2,1);
}

.journey-xp-caption {
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-500);
    margin: 0 0 1rem;
}

.journey-acorns-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: 1rem;
}

.journey-acorns-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.journey-acorns-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--gray-900);
}

.journey-acorns-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-500);
    letter-spacing: .02em;
}

.journey-message {
    font-size: .88rem;
    font-style: italic;
    color: var(--gray-700);
    margin: 0 0 1.1rem;
    line-height: 1.5;
}

.journey-memory-book-btn {
    width: 100%;
    padding: .65rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--indigo-pale);
    background: var(--indigo-pale);
    color: var(--t-primary);
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}

.journey-memory-book-btn:hover {
    background: #e0e0fc;
}

/* ── Teams section ────────────────────────────────────────────────────────── */
.teams-section {
    padding: 1rem 0 .25rem;
}

.teams-header {
    margin-bottom: .85rem;
}

.teams-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-700);
    margin: 0 0 .15rem;
}

.teams-subtitle {
    font-size: .78rem;
    color: var(--gray-500);
    margin: 0;
}

.team-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    margin-bottom: .7rem;
    border-left: 4px solid var(--indigo-pale);
}

.team-rickie-card {
    border-left-color: var(--amber);
}

.team-rickie-card-tappable {
    cursor: pointer;
    transition: box-shadow .15s;
}
.team-rickie-card-tappable:hover,
.team-rickie-card-tappable:focus-visible {
    box-shadow: var(--shadow-md);
    outline: none;
}

.team-card-header {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: .6rem;
}

.team-card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.team-rickie-line {
    font-size: .8rem;
    font-style: italic;
    color: var(--gray-500);
    margin: .15rem 0 0;
}

.team-card-meta {
    font-size: .8rem;
    color: var(--gray-500);
    margin: 0;
}

.team-card-stats {
    font-size: .85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 .7rem;
}

.team-card-open-btn {
    padding: .5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: var(--gray-100);
    color: var(--gray-400);
    font-size: .82rem;
    font-weight: 700;
    cursor: not-allowed;
}

.team-empty-card {
    text-align: center;
}

.team-empty-card .team-card-title {
    margin-bottom: .3rem;
}

.team-empty-card .team-card-meta {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.team-empty-btn-row {
    display: flex;
    gap: .6rem;
    justify-content: center;
}

.team-empty-btn-row .team-card-open-btn {
    flex: 1;
    max-width: 160px;
}

/* ── Team Onboarding (R2.7) ───────────────────────────────────────────────── */
.team-inline-form {
    margin-top: .7rem;
}

.team-created-success {
    border-left-color: var(--green);
    text-align: center;
}

.team-invite-code {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--gray-900);
    background: var(--green-light);
    border-radius: 8px;
    padding: .5rem;
    margin: .5rem 0 .8rem;
}

.team-guest-card {
    text-align: center;
}

.team-guest-card .team-card-title {
    font-weight: 600;
    color: var(--gray-500);
    margin: 0;
}

.team-card-open-btn-active {
    background: var(--indigo);
    border-color: var(--indigo);
    color: #fff;
    cursor: pointer;
}
.team-card-open-btn-active:hover { opacity: .9; }

/* ── Team Panel (R2.5 Team Chat MVP) ─────────────────────────────────────── */
.team-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.52);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
    overscroll-behavior: contain;
}
.team-panel-overlay.open { display: flex; }

@media (min-width: 540px) {
    .team-panel-overlay { align-items: center; padding: 1.5rem; }
    .team-panel { border-radius: var(--radius); }
}

.team-panel {
    background: var(--t-card-bg, #fff);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 88dvh;
    overflow-y: auto;
    padding: 1.4rem 1.1rem 1.1rem;
    position: relative;
    box-shadow: 0 -4px 24px rgba(0,0,0,.18);
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
}

.team-panel-close {
    position: absolute;
    top: .85rem;
    right: .85rem;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: 4px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.team-panel-close:hover { color: var(--gray-700); background: var(--gray-100); }

.team-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 1.5rem .2rem 0;
}

.team-panel-meta {
    font-size: .8rem;
    color: var(--gray-500);
    margin: 0 0 .3rem;
}

.team-panel-stats {
    font-size: .85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 .9rem;
}

/* ── Team Panel Info: roster, invite, leave (Operation: No Dead Ends) ────── */
.team-panel-info {
    border-top: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
    padding: .8rem 0;
    margin-bottom: .8rem;
}

.team-panel-info-loading {
    font-size: .82rem;
    color: var(--gray-500);
    text-align: center;
    margin: 0;
}

.team-panel-info-section {
    margin-bottom: .8rem;
}
.team-panel-info-section:last-child {
    margin-bottom: 0;
}

.team-panel-section-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin: 0 0 .4rem;
}

.team-roster {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.team-roster-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    font-size: .85rem;
}

.team-roster-name {
    color: var(--gray-700);
    word-break: break-word;
}

.team-roster-remove-btn {
    background: none;
    border: 1px solid var(--gray-200);
    color: var(--gray-500);
    border-radius: 6px;
    padding: .25rem .6rem;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.team-roster-remove-btn:hover { background: var(--gray-100); }
.team-roster-remove-btn-confirm {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}
.team-roster-remove-btn-confirm:hover { background: var(--red); opacity: .9; }

.team-panel-invite-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.team-invite-code-inline {
    font-size: .95rem;
    padding: .3rem .6rem;
    margin: 0;
}

.team-panel-leave-row {
    display: flex;
    justify-content: center;
}

.team-panel-thread {
    flex: 1;
    min-height: 160px;
    max-height: 340px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: .8rem;
    scroll-behavior: smooth;
}

.team-msg {
    font-size: .88rem;
    line-height: 1.5;
    padding: .5rem .75rem;
    border-radius: 10px;
    max-width: 85%;
    word-break: break-word;
}

.team-msg-sender {
    font-size: .72rem;
    font-weight: 700;
    color: var(--gray-500);
    margin: 0 0 .15rem;
}

.team-msg-body {
    margin: 0;
    color: var(--gray-700);
}

.team-msg-other {
    background: var(--gray-100);
    align-self: flex-start;
}

.team-msg-self {
    background: var(--indigo-pale);
    align-self: flex-end;
}

.team-msg-rickie {
    background: #fff;
    border: 1px solid var(--amber);
    align-self: flex-start;
}

.team-msg-rickie .team-msg-sender {
    color: var(--amber);
}

.team-panel-empty {
    text-align: center;
    font-size: .85rem;
    color: var(--gray-500);
    margin: auto;
}

.team-msg-send-error {
    text-align: center;
    font-size: .78rem;
    color: var(--red, #dc2626);
    margin: 0;
}

.team-panel-reaction-row {
    display: flex;
    gap: .4rem;
    margin-bottom: .6rem;
    flex-wrap: wrap;
}

.team-panel-reaction-btn {
    background: var(--gray-100);
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    line-height: 1;
    padding: .4rem .55rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.team-panel-reaction-btn:hover { background: var(--gray-200); }

.team-panel-input-row {
    display: flex;
    gap: .5rem;
}

.team-panel-input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    padding: .55rem .75rem;
    font-size: .9rem;
    background: var(--bg-card);
    color: var(--t-main);
    transition: border-color .15s, box-shadow .15s;
}

.team-panel-input:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.team-panel-send {
    padding: .55rem .9rem;
    font-size: .88rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.teams-error-state {
    text-align: center;
    padding: .5rem 0 1rem;
}

.teams-retry-btn {
    margin-top: .5rem;
    padding: .5rem 1.2rem;
    font-size: .82rem;
    width: auto;
}

/* ── Install card ─────────────────────────────────────────────────────────── */
.install-card {
    text-align: center;
}

.install-card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 .85rem;
}

.install-card-instructions {
    font-size: .85rem;
    color: var(--gray-700);
    line-height: 1.45;
    margin: .75rem 0 0;
}

/* ── Side Quests section ──────────────────────────────────────────────────── */
.side-quests-section {
    padding: 1rem 0 .25rem;
}

.side-quests-header {
    margin-bottom: .85rem;
}

.side-quests-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-700);
    margin: 0 0 .15rem;
}

.side-quests-subtitle {
    font-size: .78rem;
    color: var(--gray-500);
    margin: 0;
}

.side-quests-form {
    margin-top: .85rem;
    padding-top: .85rem;
    border-top: 1px solid var(--gray-100);
}

/* ── Challenge cards ──────────────────────────────────────────────────────── */
.challenge-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    margin-bottom: .7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .85rem;
    border-left: 4px solid transparent;
    transition: border-color .2s, box-shadow .2s;
}

.challenge-card:hover        { box-shadow: var(--shadow-md); }
.challenge-card.has-streak   { border-left-color: var(--amber); }
.challenge-card.at-risk      { border-left-color: var(--red); }
.challenge-card.done-today   { border-left-color: var(--green); }

.challenge-info { flex: 1; min-width: 0; }

.challenge-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.streak-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    flex-wrap: wrap;
    font-size: .82rem;
    color: var(--gray-500);
}

.streak-current {
    font-weight: 800;
    font-size: .95rem;
    color: var(--amber);
}

/* ── Celebration: confetti, badge pop, progress glow ──────────────────────── */
.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 300;
    overflow: hidden;
}

.confetti-piece {
    position: fixed;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    will-change: transform, opacity;
    opacity: 0;
    animation: confetti-burst var(--dur, 1.2s) cubic-bezier(.2, .7, .35, 1) forwards;
}

@keyframes confetti-burst {
    0%   { transform: translate(-50%, -50%) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) rotate(var(--rot)); opacity: 0; }
}

@keyframes badge-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}
.badge-pop { animation: badge-pop .5s cubic-bezier(.34, 1.56, .64, 1); }

@media (prefers-reduced-motion: reduce) {
    .confetti-piece { display: none; }
    .badge-pop { animation: none; }
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes completePulse {
    0%   { background-color: transparent; }
    30%  { background-color: #dcfce7; }
    100% { background-color: transparent; }
}

.completing {
    animation: completePulse .55s ease forwards;
    border-radius: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Loading state ────────────────────────────────────────────────────────── */
.state-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 0;
    color: var(--gray-400);
    font-size: .875rem;
    gap: .5rem;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--indigo);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2.25rem 1rem;
}

.empty-icon { font-size: 2.5rem; margin-bottom: .6rem; }

.empty-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: .25rem;
}

.empty-sub {
    font-size: .825rem;
    color: var(--gray-400);
    line-height: 1.5;
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.error {
    color: var(--red);
    font-size: .85rem;
    min-height: 1.2rem;
}

.muted { color: var(--gray-500); font-size: .875rem; }

/* ── Theme toggle buttons ─────────────────────────────────────────────────── */
.theme-toggle {
    display: flex;
    gap: .2rem;
    background: rgba(0,0,0,.12);
    border-radius: 20px;
    padding: .15rem .25rem;
}

.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    padding: .15rem .3rem;
    border-radius: 16px;
    line-height: 1.4;
    transition: background .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
    opacity: .65;
}

.theme-btn:hover  { opacity: 1; background: rgba(255,255,255,.2); }
.theme-btn:active { transform: scale(.9); }
.theme-btn.active { opacity: 1; background: rgba(255,255,255,.3); }

body.theme-classic .theme-toggle { background: rgba(79,70,229,.1); }
body.theme-classic .theme-btn:hover  { background: rgba(79,70,229,.15); }
body.theme-classic .theme-btn.active { background: rgba(79,70,229,.2); }

/* ── PWA standalone adjustments ──────────────────────────────────────────── */
@media (display-mode: standalone) {
    body { background: var(--t-body-bg); }
}

/* ── Mobile responsive ────────────────────────────────────────────────────── */
@media (max-width: 400px) {
    .card { padding: 1.1rem; }
    .daily-card { padding: 1rem 1rem .85rem; }
    .container { padding: 1rem .85rem 2rem; gap: 1rem; }
    .site-header { padding: .7rem 1rem; }
    .header-brand { font-size: 1.1rem; }
    .challenge-card { padding: .9rem 1rem; }
    .journey-avatar { width: 56px; height: 56px; }
    .journey-header { gap: .7rem; }
    .journey-title { font-size: .95rem; }
}

/* header-right wraps instead of squeezing on narrow phones */
@media (max-width: 480px) {
    .header-right { flex-wrap: wrap; flex-shrink: 1; min-width: 0; justify-content: flex-end; gap: .4rem; row-gap: .4rem; }
    .skill-select { padding: .3rem .6rem; font-size: .75rem; }
}


/* ── Retention prompts (install + notification ask) ───────────────────────── */
#retention-prompts {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin-bottom: .25rem;
}

.retention-banner {
    position: relative;
    background: var(--t-card-bg, #fff);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .9rem 2.5rem .9rem 1rem;
    box-shadow: var(--shadow);
}

.retention-text {
    font-size: .88rem;
    color: var(--gray-700);
    margin: 0 0 .6rem;
    line-height: 1.4;
}

.retention-btn-row {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.retention-btn {
    padding: .45rem 1rem;
    border-radius: 8px;
    border: none;
    background: var(--indigo-dark, #4338ca);
    color: #fff;
    font-size: .83rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .15s;
}
.retention-btn:hover { opacity: .85; }

.retention-btn-ghost {
    background: transparent;
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
}
.retention-btn-ghost:hover { background: var(--gray-100); opacity: 1; }

/* ── Exercise Coach Modal ─────────────────────────────────────────────────── */
.ex-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.52);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
    overscroll-behavior: contain;
}
.ex-modal-overlay.open { display: flex; }

@media (min-width: 540px) {
    .ex-modal-overlay { align-items: center; padding: 1.5rem; }
    .ex-modal { border-radius: var(--radius); }
}

.ex-modal {
    background: var(--t-card-bg, #fff);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 88dvh;
    overflow-y: auto;
    padding: 1.4rem 1.25rem 2.5rem;
    position: relative;
    box-shadow: 0 -4px 24px rgba(0,0,0,.18);
    overscroll-behavior: contain;
}

.ex-modal-close {
    position: absolute;
    top: .85rem;
    right: .85rem;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: 4px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.ex-modal-close:hover { color: var(--gray-700); background: var(--gray-100); }

.ex-modal-img {
    display: block;
    width: 220px;
    height: 220px;
    object-fit: contain;
    margin: 0 auto .85rem;
    border-radius: 12px;
    background: var(--gray-50, #f9fafb);
}

.ex-modal-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-900);
    text-align: center;
    margin: 0 0 .5rem;
    padding-right: 1.5rem;
}

.ex-modal-text {
    font-size: .875rem;
    line-height: 1.6;
    color: var(--gray-700);
    margin: 0;
}

.ex-modal-section { margin-bottom: 1rem; }

.ex-modal-section-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin: 0 0 .5rem;
}

.ex-modal-list {
    margin: 0;
    padding-left: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.ex-modal-list li {
    font-size: .875rem;
    line-height: 1.5;
    color: var(--gray-700);
}

.ex-modal-tip {
    font-size: .875rem;
    line-height: 1.6;
    color: var(--gray-700);
    background: var(--indigo-pale, #eef2ff);
    border-radius: 8px;
    padding: .7rem .9rem;
    margin: 0;
}

/* ── Rickie's Reaction (completion toast) ─────────────────────────────────── */
.rickie-reaction {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: min(360px, calc(100vw - 2rem));
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: .9rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    z-index: 150;
    pointer-events: none;
    animation: rickie-reaction-in .35s cubic-bezier(.4,0,.2,1);
}

.rickie-reaction.leaving {
    animation: rickie-reaction-out .3s ease-in forwards;
}

/* Level-up gets a soft violet halo so the toast reads as a bigger moment. */
.rickie-reaction.celebrate {
    box-shadow: var(--shadow-md), 0 0 0 1.5px rgba(124, 58, 237, .35), 0 8px 24px rgba(124, 58, 237, .18);
}

@keyframes rickie-reaction-in {
    from { opacity: 0; transform: translateX(-50%) translateY(16px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes rickie-reaction-out {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to   { opacity: 0; transform: translateX(-50%) translateY(16px); }
}

@media (prefers-reduced-motion: reduce) {
    .rickie-reaction { animation: none; }
    .rickie-reaction.leaving { animation: none; }
}

.rickie-reaction-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--indigo-pale);
    flex-shrink: 0;
}

.rickie-reaction-body {
    min-width: 0;
    flex: 1;
}

.rickie-reaction-line {
    font-size: .95rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    line-height: 1.35;
}

.rickie-reaction-progress {
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-500);
    margin: .35rem 0 0;
}

.rickie-reaction-levelup {
    font-size: .8rem;
    font-weight: 700;
    color: var(--t-primary);
    margin: .35rem 0 0;
}

@media (max-width: 400px) {
    .rickie-reaction { padding: .8rem .9rem; gap: .6rem; }
    .rickie-reaction-avatar { width: 34px; height: 34px; }
}

/* ── Rickie's Memory Book ──────────────────────────────────────────────────── */
.mb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.52);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
    overscroll-behavior: contain;
}
.mb-overlay.open { display: flex; }

@media (min-width: 540px) {
    .mb-overlay { align-items: center; padding: 1.5rem; }
    .mb-book { border-radius: var(--radius); }
}

.mb-book {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #fffaf0 0%, #ffffff 45%);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.5rem 1.5rem 1.25rem;
    box-shadow: var(--shadow-md);
}

.mb-close {
    position: absolute;
    top: .9rem;
    right: .9rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    color: var(--gray-500);
    font-size: .9rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mb-header {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-bottom: 1.1rem;
    padding-right: 2rem;
}

.mb-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--amber-light);
    flex-shrink: 0;
}

.mb-header-text {
    min-width: 0;
}

.mb-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 0 0 .2rem;
}

.mb-subtitle {
    font-size: .82rem;
    color: var(--gray-500);
    margin: 0;
}

.mb-page-title {
    font-size: .95rem;
    font-weight: 700;
    color: #b45309;
    margin: 0 0 .9rem;
    padding-bottom: .6rem;
    border-bottom: 1px dashed var(--gray-200);
}

.mb-page-content {
    min-height: 140px;
    margin-bottom: 1.1rem;
}

.mb-empty {
    font-size: .9rem;
    color: var(--gray-500);
    font-style: italic;
    line-height: 1.6;
    margin: 1.5rem 0;
}

.mb-memory-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .7rem;
}

.mb-memory-item {
    font-size: .9rem;
    color: var(--gray-700);
    line-height: 1.5;
    padding-left: 1.1rem;
    position: relative;
}

.mb-memory-item::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--amber);
}

.mb-day-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin: 1rem 0 .5rem;
}
.mb-day-label:first-child {
    margin-top: 0;
}

.mb-journey-line {
    font-size: .95rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 .3rem;
}

.mb-journey-sub {
    font-size: .85rem;
    color: var(--gray-500);
    margin: 0 0 .9rem;
}

.mb-milestone-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.mb-milestone-item {
    font-size: .88rem;
    color: var(--gray-400);
    line-height: 1.5;
    padding: .55rem .7rem;
    border-radius: 8px;
    background: var(--gray-50);
}

.mb-milestone-item.unlocked {
    color: var(--gray-900);
    background: var(--amber-light);
    font-weight: 600;
}

.mb-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: .9rem;
    border-top: 1px solid var(--gray-100);
}

.mb-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--gray-200);
    background: #fff;
    color: var(--t-primary);
    font-size: 1.1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mb-nav-btn:disabled {
    color: var(--gray-300, #d1d5db);
    cursor: not-allowed;
    border-color: var(--gray-100);
}

.mb-dots {
    display: flex;
    gap: .4rem;
}

.mb-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-200);
}

.mb-dot.active {
    background: var(--amber);
}

@media (max-width: 400px) {
    .mb-book { padding: 1.2rem 1.1rem 1rem; max-height: 92vh; }
    .mb-avatar { width: 48px; height: 48px; }
}


/* ── Phone-width corrections (must stay last) ─────────────────────────────────
   These blocks intentionally live at the end of the file. Several of the base
   rules they override (.mb-close, .mb-nav-btn) are defined hundreds of lines
   below where a "mobile responsive" section would naturally sit, and a media
   query adds no specificity — so an earlier override silently loses to the
   later base rule. Appending is what makes these actually take effect.
   Everything here is scoped to <=539.98px, the complement of this stylesheet's
   `min-width: 540px` desktop breakpoint, so no desktop rendering changes. */

/* Today's Mission rows on phones.
   The row is [info | pill | button] on one flex line. The pill (78px) and button
   (86px) are flex-shrink:0, so on a 390px screen .daily-exercise-info was left
   with ~141px — not enough for "How to do this" and "Exercise Tips" side by
   side, so the two chips stacked into a lopsided 162px-tall column beside a
   vertically-centred pill and button, and the reps line wrapped mid-phrase.
   Giving info its own full-width line lets the chips sit inline and the reps
   line fit, then the pill and button share the line below — pill left, button
   right. Measured at 390px: row height 185px -> 169px, so the mission also gets
   shorter, not taller.
   Bounded by 539.98px because 540px is where this stylesheet's `min-width: 540px`
   desktop rules take over and the single-line layout has room again. */
@media (max-width: 539.98px) {
    .daily-exercise-row  { justify-content: space-between; row-gap: .5rem; }
    .daily-exercise-info { flex: 1 1 100%; }
}

/* Tap targets: 44px is this stylesheet's established minimum (see .btn-how-to,
   .btn-daily-complete et al). A mobile-width audit of the logged-in dashboard
   found seven interactive controls still below it — the header settings gear at
   38x38, Memory Book at 38px tall, both team empty-state buttons at 33px, Add
   to Home Screen at 39px, and the notification prompt's Yes / Not now pair at
   31px (those two only render once the mission is complete, which is why they
   needed a second pass to catch). Each is raised here rather than by editing
   the base rules, so the desktop look is unchanged. */
@media (max-width: 539.98px) {
    .settings-toggle          { width: 44px; height: 44px; }
    .journey-memory-book-btn  { min-height: 44px; }
    .team-card-open-btn       { min-height: 44px; }
    .install-card-btn         { min-height: 44px; }
    .retention-btn            { min-height: 44px; }

    /* Settings panel: the difficulty and Rickie-mode selects were 27px tall,
       the three theme buttons 28x25, and Log Out 30px. The panel is 250px wide,
       so three 44px theme buttons still fit its ~221px content box. */
    .skill-select             { min-height: 44px; }
    .settings-menu .theme-btn { min-width: 44px; min-height: 44px;
                                display: inline-flex; align-items: center; justify-content: center; }
    .settings-logout          { min-height: 44px; }

    /* Dialog dismiss and paging controls: the exercise modal's ✕ was 26x24 and
       is the only way to dismiss it; Memory Book's ✕ was 32px and its page
       arrows 36px. The title clearances below are widened in step so a long
       exercise name cannot run underneath the now-larger ✕. */
    .ex-modal-close  { min-width: 44px; min-height: 44px;
                       display: inline-flex; align-items: center; justify-content: center; }
    .ex-modal-name   { padding-right: 2.75rem; }
    .mb-close        { width: 44px; height: 44px; }
    .mb-header       { padding-right: 2.75rem; }
    .mb-nav-btn      { width: 44px; height: 44px; }

    /* The Log In / Register tabs were 35px tall — on the first screen a new
       user ever touches, which makes them the highest-traffic undersized
       target in the app. Centred so the label stays put as the box grows. */
    .tab { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}
