/**
 * Reseeda — Design System v2.0
 * iOS-Modern, Earth-Toned Premium Design
 * 
 * Features:
 * - Glassmorphic navigation bars
 * - Translucent layered cards
 * - SF-inspired typography & spacing
 * - Smooth haptic-feel micro-interactions
 * - Earthy sage/olive/terracotta palette
 */

/* ======================================================
   DESIGN TOKENS
   ====================================================== */

:root {
    /* Brand Colors — Earthy Modern */
    --color-primary: #4A6741;
    --color-primary-light: #5C7A52;
    --color-primary-dark: #3A5534;
    --color-secondary: #9BB88A;
    --color-secondary-light: #B5CEAA;
    --color-secondary-dark: #7FA06E;
    --color-accent: #C67D4E;
    --color-accent-light: #D49670;
    --color-accent-dark: #A86638;
    --color-reward: #E5A84B;
    --color-reward-light: #EDBD6F;
    --color-reward-dark: #CC923A;
    --color-bg: #F8F6F3;
    --color-bg-warm: #F2EFEA;
    --color-bg-card: rgba(255, 255, 255, 0.82);
    --color-bg-card-solid: #FFFFFF;
    --color-dark: #1A1A1A;
    --color-dark-lighter: #2D3B28;

    /* Neutrals — iOS-style warm grays */
    --color-gray-50: #FAFAF9;
    --color-gray-100: #F5F4F2;
    --color-gray-200: #E8E6E3;
    --color-gray-300: #D4D1CC;
    --color-gray-400: #A8A29E;
    --color-gray-500: #78716C;
    --color-gray-600: #57534E;
    --color-gray-700: #3C3836;
    --color-gray-800: #292524;
    --color-gray-900: #1C1917;

    /* Semantic Colors */
    --color-success: #34C759;
    --color-success-bg: rgba(52, 199, 89, 0.1);
    --color-warning: #FF9F0A;
    --color-warning-bg: rgba(255, 159, 10, 0.1);
    --color-error: #FF3B30;
    --color-error-bg: rgba(255, 59, 48, 0.08);
    --color-info: #007AFF;
    --color-info-bg: rgba(0, 122, 255, 0.08);

    /* Typography — SF-style */
    --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
    --font-mono: 'SF Mono', ui-monospace, monospace;

    /* Type Scale */
    --text-xs: 0.6875rem;    /* 11px */
    --text-sm: 0.8125rem;    /* 13px */
    --text-base: 0.9375rem;  /* 15px */
    --text-lg: 1.0625rem;    /* 17px */
    --text-xl: 1.25rem;      /* 20px */
    --text-2xl: 1.5rem;      /* 24px */
    --text-3xl: 1.75rem;     /* 28px */
    --text-4xl: 2.125rem;    /* 34px */
    --text-5xl: 2.75rem;     /* 44px */

    /* Line Heights */
    --leading-tight: 1.15;
    --leading-snug: 1.3;
    --leading-normal: 1.47;
    --leading-relaxed: 1.6;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Spacing — iOS 8pt grid */
    --space-0: 0;
    --space-1: 0.25rem;  /* 4px */
    --space-2: 0.5rem;   /* 8px */
    --space-3: 0.75rem;  /* 12px */
    --space-4: 1rem;     /* 16px */
    --space-5: 1.25rem;  /* 20px */
    --space-6: 1.5rem;   /* 24px */
    --space-8: 2rem;     /* 32px */
    --space-10: 2.5rem;  /* 40px */
    --space-12: 3rem;    /* 48px */
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Border Radius — iOS rounded rectangle */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 28px;
    --radius-full: 9999px;

    /* Shadows — layered iOS-style */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.06);
    --shadow-glow-primary: 0 0 24px rgba(74, 103, 65, 0.2);
    --shadow-glow-accent: 0 0 24px rgba(198, 125, 78, 0.2);
    --shadow-glow-reward: 0 0 24px rgba(229, 168, 75, 0.2);

    /* Transitions — iOS springs */
    --transition-fast: 180ms cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-base: 280ms cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-slow: 400ms cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Z-Index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-popover: 600;
    --z-toast: 700;

    /* Layout */
    --nav-height: 56px;
    --bottom-nav-height: 84px;
    --sidebar-width: 260px;
    --content-max-width: 680px;
    --content-padding: var(--space-4);
}


/* ======================================================
   RESET & BASE
   ====================================================== */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-gray-800);
    background-color: var(--color-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    letter-spacing: -0.01em;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

img, video, svg { display: block; max-width: 100%; height: auto; }

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-dark); }

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

input, textarea, select { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

::selection {
    background: rgba(155, 184, 138, 0.35);
    color: var(--color-dark);
}


/* ======================================================
   TYPOGRAPHY — iOS-inspired
   ====================================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-dark);
    line-height: var(--leading-tight);
    font-weight: var(--font-bold);
    letter-spacing: -0.025em;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); font-weight: var(--font-semibold); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-muted { color: var(--color-gray-500); }
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-reward { color: var(--color-reward); }
.text-success { color: var(--color-success); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-heading { font-family: var(--font-heading); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }


/* ======================================================
   LAYOUT
   ====================================================== */

.container {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 var(--content-padding);
}

.page-content {
    padding-top: calc(var(--nav-height) + var(--space-3));
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-6));
    min-height: 100vh;
}

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 600px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }


/* ======================================================
   TOP NAVIGATION — Frosted Glass
   ====================================================== */

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(74, 103, 65, 0.88);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    z-index: var(--z-fixed);
    border-bottom: 0.5px solid rgba(255,255,255,0.15);
}

.top-nav .logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: white;
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    letter-spacing: -0.02em;
    text-decoration: none;
}

.top-nav .nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.top-nav .nav-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.9);
    background: rgba(255, 255, 255, 0.12);
    transition: all var(--transition-fast);
    font-size: 1.1rem;
}

.top-nav .nav-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

.top-nav .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    border: 2px solid rgba(255,255,255,0.35);
    object-fit: cover;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.top-nav .user-avatar:hover {
    border-color: rgba(255,255,255,0.7);
    transform: scale(1.05);
}

.top-nav .xp-mini {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: white;
}

.top-nav .xp-mini .level-badge {
    background: rgba(255,255,255,0.2);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
}


/* ======================================================
   BOTTOM NAVIGATION — iOS Tab Bar
   ====================================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    z-index: var(--z-fixed);
    border-top: 0.5px solid rgba(0,0,0,0.08);
    padding-top: 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 12px;
    color: var(--color-gray-400);
    font-size: 10px;
    font-weight: var(--font-medium);
    text-decoration: none;
    transition: color var(--transition-fast);
    letter-spacing: 0.01em;
}

.bottom-nav .nav-item .nav-icon {
    font-size: 1.4rem;
    transition: transform var(--transition-bounce);
}

.bottom-nav .nav-item:hover,
.bottom-nav .nav-item.active {
    color: var(--color-primary);
}

.bottom-nav .nav-item.active .nav-icon {
    transform: scale(1.1);
}


/* ======================================================
   CARDS — iOS Grouped Style
   ====================================================== */

.card {
    background: var(--color-bg-card);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    border: 0.5px solid rgba(0,0,0,0.06);
    transition: all var(--transition-base);
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.card-header h3 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
}

.card-body {
    color: var(--color-gray-600);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.card-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 0.5px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stat cards */
.stat-card {
    background: var(--color-bg-card);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    border: 0.5px solid rgba(0,0,0,0.06);
    text-align: center;
    transition: all var(--transition-base);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: var(--space-2); }

.stat-card .stat-value {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-dark);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: var(--font-medium);
}


/* ======================================================
   BUTTONS — iOS Rounded
   ====================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.7rem 1.25rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    letter-spacing: -0.01em;
}

.btn:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-accent {
    background: var(--color-accent);
    color: white;
}

.btn-accent:hover {
    background: var(--color-accent-dark);
}

.btn-reward {
    background: var(--color-reward);
    color: var(--color-dark);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-gray-200);
}

.btn-outline:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--color-gray-600);
}

.btn-ghost:hover {
    background: var(--color-gray-100);
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.9rem 1.75rem;
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}

.btn-block { width: 100%; }

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn:disabled, .btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}


/* ======================================================
   FORM ELEMENTS — iOS Style
   ====================================================== */

.form-group { margin-bottom: var(--space-4); }

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-gray-700);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: var(--text-base);
    color: var(--color-gray-800);
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(74, 103, 65, 0.1);
}

.form-input::placeholder { color: var(--color-gray-400); }
.form-input.error { border-color: var(--color-error); }
.form-textarea { min-height: 100px; resize: vertical; }

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.5rem;
}


/* ======================================================
   XP & GAMIFICATION
   ====================================================== */

.xp-bar {
    width: 100%;
    height: 8px;
    background: var(--color-gray-100);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-reward-dark), var(--color-reward));
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.xp-bar-fill::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: shimmer 2.5s infinite;
}

@keyframes shimmer { to { left: 100%; } }

.xp-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: var(--text-xs);
}

.xp-bar-label .level {
    font-weight: var(--font-bold);
    color: var(--color-reward-dark);
}

.xp-bar-label .xp { color: var(--color-gray-400); }

/* Level Badge */
.level-badge-large {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-reward-dark), var(--color-reward-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: white;
    box-shadow: 0 4px 16px rgba(229, 168, 75, 0.35);
}

/* Streak */
@keyframes flicker {
    0% { transform: scale(1) rotate(-2deg); }
    50% { transform: scale(1.08) rotate(2deg); }
    100% { transform: scale(1.03) rotate(-1deg); }
}

/* Badge Grid */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: var(--space-3);
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-gray-50);
    transition: all var(--transition-base);
}

.badge-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.badge-item .badge-icon { font-size: 1.75rem; }
.badge-item .badge-name {
    font-size: 10px;
    font-weight: var(--font-medium);
    color: var(--color-gray-600);
    text-align: center;
    line-height: 1.2;
}

.badge-item.locked { opacity: 0.25; filter: grayscale(1); }
.badge-item.locked:hover { opacity: 0.35; transform: none; box-shadow: none; }


/* ======================================================
   TAGS — Pill Style
   ====================================================== */

.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px 10px;
    font-size: 11px;
    font-weight: var(--font-semibold);
    border-radius: var(--radius-full);
    letter-spacing: 0.01em;
}

.tag-primary { background: rgba(74, 103, 65, 0.1); color: var(--color-primary); }
.tag-secondary { background: rgba(155, 184, 138, 0.2); color: var(--color-secondary-dark); }
.tag-accent { background: rgba(198, 125, 78, 0.1); color: var(--color-accent); }
.tag-reward { background: rgba(229, 168, 75, 0.12); color: var(--color-reward-dark); }


/* ======================================================
   TOAST NOTIFICATIONS — iOS-style
   ====================================================== */

.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + var(--space-3));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: var(--z-toast);
    pointer-events: none;
    width: calc(100% - 2rem);
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: auto;
    border: 0.5px solid rgba(0,0,0,0.06);
}

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-error); }
.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.info { border-left: 3px solid var(--color-info); }
.toast-removing { animation: toastOut 0.25s ease-in forwards; }

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

.toast .toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast .toast-message { font-size: var(--text-sm); color: var(--color-gray-700); flex: 1; }
.toast .toast-close {
    color: var(--color-gray-400);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
}


/* ======================================================
   XP / LEVEL-UP ANIMATIONS
   ====================================================== */

.xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--color-reward);
    text-shadow: 0 2px 12px rgba(229, 168, 75, 0.5);
    z-index: var(--z-toast);
    pointer-events: none;
    animation: xpPop 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes xpPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    40% { transform: translate(-50%, -50%) scale(1); }
    70% { opacity: 1; transform: translate(-50%, -80%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -120%) scale(0.8); }
}

.level-up-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.level-up-content {
    text-align: center;
    color: white;
    animation: levelUpBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes levelUpBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.level-up-content .level-up-icon { font-size: 4.5rem; margin-bottom: var(--space-4); }
.level-up-content h2 { color: var(--color-reward); font-size: var(--text-4xl); margin-bottom: var(--space-2); }
.level-up-content p { font-size: var(--text-lg); opacity: 0.8; }


/* ======================================================
   MODALS — iOS Sheet
   ====================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    animation: fadeIn 0.2s;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 2rem);
    max-width: 480px;
    max-height: 90vh;
    background: white;
    border-radius: var(--radius-xl);
    z-index: var(--z-modal);
    overflow: hidden;
    animation: modalIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalIn {
    from { transform: translate(-50%, -45%) scale(0.95); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 0.5px solid var(--color-gray-200);
}

.modal-body { padding: var(--space-5); overflow-y: auto; max-height: calc(90vh - 130px); }
.modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    padding: var(--space-3) var(--space-5);
    border-top: 0.5px solid var(--color-gray-200);
}


/* ======================================================
   EMPTY STATES
   ====================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
}

.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: var(--space-3); opacity: 0.5; }
.empty-state h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.empty-state p {
    color: var(--color-gray-500);
    font-size: var(--text-sm);
    margin-bottom: var(--space-6);
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}


/* ======================================================
   LOADING STATES
   ====================================================== */

.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--color-gray-200);
    border-top-color: var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 0.65s linear infinite;
}

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

.skeleton {
    background: linear-gradient(90deg, var(--color-gray-100) 25%, var(--color-gray-50) 50%, var(--color-gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card { height: 140px; border-radius: var(--radius-lg); }


/* ======================================================
   UTILITIES
   ====================================================== */

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.shadow { box-shadow: var(--shadow-md); }
.hidden { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); border: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-gray-300); border-radius: var(--radius-full); }


/* ======================================================
   LANDING PAGE
   ====================================================== */

.landing-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    position: relative;
    overflow: hidden;
    padding: var(--space-8) var(--space-4);
}

.landing-hero::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -25%;
    width: 70%;
    height: 70%;
    background: radial-gradient(circle, rgba(155, 184, 138, 0.12) 0%, transparent 70%);
    border-radius: 50%;
}

.landing-hero::after {
    content: '';
    position: absolute;
    bottom: -25%;
    left: -15%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(229, 168, 75, 0.06) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-content {
    max-width: 580px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.hero-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.hero-brand .logo-mark {
    font-size: 3rem;
    animation: sway 4s ease-in-out infinite;
}

@keyframes sway {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: rotate(4deg); }
}

.hero-brand h1 {
    font-size: var(--text-5xl);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-tagline {
    font-size: var(--text-lg);
    color: var(--color-gray-600);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-8);
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.hero-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-10);
}

.hero-actions .btn {
    padding: 0.85rem 2rem;
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}

.hero-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    text-align: center;
}

@media (max-width: 640px) {
    .hero-features { grid-template-columns: 1fr; }
    .hero-brand h1 { font-size: var(--text-4xl); }
}

.hero-feature { padding: var(--space-3); }
.hero-feature .feature-icon { font-size: 2rem; margin-bottom: var(--space-2); }
.hero-feature h3 { font-size: var(--text-base); margin-bottom: var(--space-1); }
.hero-feature p { font-size: var(--text-xs); color: var(--color-gray-500); line-height: var(--leading-relaxed); }


/* ======================================================
   AUTH FORMS
   ====================================================== */

.auth-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.auth-card {
    width: 100%;
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
}

.auth-card .auth-header { text-align: center; margin-bottom: var(--space-6); }
.auth-card .auth-header .logo-mark { font-size: 2.5rem; display: block; margin-bottom: var(--space-3); }
.auth-card .auth-header h2 { font-size: var(--text-2xl); margin-bottom: 4px; }
.auth-card .auth-header p { color: var(--color-gray-500); font-size: var(--text-sm); }
.auth-card .auth-footer { text-align: center; margin-top: var(--space-5); font-size: var(--text-sm); color: var(--color-gray-500); }
.auth-card .auth-footer a { color: var(--color-primary); font-weight: var(--font-semibold); }


/* ======================================================
   DASHBOARD SPECIFIC
   ====================================================== */

.dashboard-greeting {
    margin-bottom: var(--space-4);
}

.dashboard-greeting h1 {
    font-size: var(--text-3xl);
    margin-bottom: 2px;
}

.dashboard-greeting p {
    color: var(--color-gray-500);
    font-size: var(--text-sm);
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

@media (max-width: 600px) {
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Quick action cards */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}

@media (max-width: 600px) {
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--color-gray-700);
    border: 0.5px solid rgba(0,0,0,0.06);
    transition: all var(--transition-base);
}

.quick-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--color-primary);
}

.quick-action .action-icon {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-action .action-label {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}


/* ======================================================
   DESKTOP SIDEBAR — Frosted Glass
   ====================================================== */

.desktop-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .desktop-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        bottom: 0;
        width: var(--sidebar-width);
        background: rgba(255, 255, 255, 0.72);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-right: 0.5px solid rgba(0,0,0,0.08);
        z-index: var(--z-sticky);
        padding: var(--space-4) var(--space-3);
        overflow-y: auto;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .desktop-sidebar.collapsed {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    /* Toggle button — sits on the sidebar edge */
    .sidebar-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: calc(var(--nav-height) + 14px);
        left: calc(var(--sidebar-width) - 14px);
        width: 28px;
        height: 28px;
        background: white;
        border: 0.5px solid rgba(0,0,0,0.12);
        border-radius: 50%;
        box-shadow: 0 1px 4px rgba(0,0,0,0.12);
        cursor: pointer;
        z-index: calc(var(--z-sticky) + 1);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        color: var(--color-gray-500);
        font-size: 14px;
        line-height: 1;
    }

    .sidebar-toggle-btn:hover {
        background: var(--color-gray-50);
        color: var(--color-primary);
        border-color: var(--color-primary);
    }

    .sidebar-toggle-btn.collapsed {
        left: 6px;
    }

    .sidebar-toggle-btn .toggle-icon {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: inline-block;
    }

    .sidebar-toggle-btn.collapsed .toggle-icon {
        transform: rotate(180deg);
    }

    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-nav-bottom {
        margin-top: auto;
    }

    .sidebar-divider {
        height: 0.5px;
        background: rgba(0,0,0,0.08);
        margin: var(--space-3) var(--space-2);
        flex-shrink: 0;
    }

    .sidebar-item {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: 10px 14px;
        border-radius: var(--radius-md);
        color: var(--color-gray-600);
        text-decoration: none;
        font-size: var(--text-sm);
        font-weight: var(--font-medium);
        transition: all var(--transition-fast);
        letter-spacing: -0.01em;
    }

    .sidebar-item:hover {
        background: rgba(74, 103, 65, 0.06);
        color: var(--color-gray-800);
    }

    .sidebar-item.active {
        background: rgba(74, 103, 65, 0.1);
        color: var(--color-primary);
        font-weight: var(--font-semibold);
    }

    .sidebar-icon {
        font-size: 1.25rem;
        width: 28px;
        text-align: center;
        flex-shrink: 0;
    }

    .sidebar-label {
        white-space: nowrap;
    }

    .sidebar-more-toggle.has-active {
        color: var(--color-primary);
        font-weight: var(--font-semibold);
    }

    .sidebar-sub-item {
        padding-left: 24px;
        font-size: var(--text-xs);
        color: var(--color-gray-500);
    }

    .sidebar-sub-item .sidebar-icon {
        font-size: 1.05rem;
    }
}


/* ======================================================
   RESPONSIVE
   ====================================================== */

@media (max-width: 480px) {
    :root { --content-padding: var(--space-3); }
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    .auth-card { padding: var(--space-6); }
}

@media (min-width: 1024px) {
    .bottom-nav { display: none; }

    .page-content {
        margin-left: var(--sidebar-width);
        padding-bottom: var(--space-8);
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .page-content.sidebar-collapsed {
        margin-left: 0;
    }

    /* Use available desktop space */
    .page-content .container {
        max-width: 960px;
    }
}

/* Print */
@media print {
    .top-nav, .bottom-nav, .desktop-sidebar, .toast-container { display: none !important; }
    body { background: white; }
    .page-content { margin-left: 0; }
}

/* Welcome overlay animation */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* More Menu Drawer */
.more-menu-item:hover, .more-menu-item:active {
    background: var(--color-gray-50);
}
#more-menu-drawer {
    padding-bottom: env(safe-area-inset-bottom, 0);
}


/* ======================================================
   TOGGLE SWITCH — iOS Style
   ====================================================== */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--color-gray-300);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}


/* ======================================================
   VIEW TOGGLE — Segmented Control
   ====================================================== */

.view-toggle {
    display: flex;
    background: var(--color-gray-100);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
}

.view-btn {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-gray-500);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.view-btn.active {
    background: white;
    color: var(--color-primary);
    font-weight: var(--font-semibold);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.view-btn:hover:not(.active) {
    color: var(--color-gray-700);
}


/* ======================================================
   STAT CARDS
   ====================================================== */

.stat-card {
    text-align: center;
    padding: var(--space-3);
    background: var(--color-gray-50);
    border-radius: var(--radius-md);
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: var(--space-1);
}

.stat-card .stat-value {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-gray-800);
}

.stat-card .stat-label {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
    margin-top: 2px;
}
