/* Mobile scroll and touch optimizations */
html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Prevent iOS auto-zoom and mobile UX issues */
input, textarea, select, button {
    font-size: 16px !important;
    -webkit-appearance: none;
    border-radius: 0;
}

/* Additional mobile stability */
input:focus, textarea:focus, select:focus {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Category Dividers */
.category-divider {
    height: 1px;
    background-color: rgba(0, 0, 0, 0.05);
    margin: 12px 0;
    width: 100%;
}

/* Grid layout dividers using box-shadow for better visual separation */
.category-option {
    position: relative;
}

.category-option::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 8px;
    right: 8px;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.08);
    opacity: 0.6;
}

/* Remove divider from last items in each row */
.category-option:nth-last-child(-n+2)::after {
    display: none;
}

/* Edit Habit Modal - Mobile Optimized */
.edit-habit-modal {
    position: absolute !important;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    max-height: 60vh;
    overflow-y: auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    max-width: 300px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.edit-habit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
}

/* CSS Custom Properties - Updated with Custom Brand Colors */
:root {
    /* Brand Colors - HabitIQ */
    --habitiq-blue: #2563EB;
    --habitiq-blue-dark: #1D4ED8;
    --habitiq-blue-light: #60A5FA;
    --background-light: #F8FAFC;
    --gray-muted: #CBD5E1;
    --green-accent: #10B981;
    --green-accent-light: #34D399;
    --yellow-highlight: #FACC15;
    --yellow-highlight-light: #FDE047;
    
    /* Supporting Colors */
    --secondary-gray: #64748B;
    --tertiary-gray: #94A3B8;
    --quaternary-gray: #E2E8F0;
    --quinary-gray: #F1F5F9;
    --senary-gray: #F8FAFC;
    --background-primary: #FFFFFF;
    --background-secondary: #F8FAFC;
    --background-tertiary: #FFFFFF;
    --background-gradient: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    --card-background: rgba(255, 255, 255, 0.95);
    --card-background-hover: rgba(255, 255, 255, 1);
    --label-primary: #0F172A;
    --label-secondary: #334155;
    --label-tertiary: #64748B;
    --separator: #E2E8F0;
    --green: #10B981;
    --red: #EF4444;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --font-size-large: 28px;
    --font-size-title: 20px;
    --font-size-body: 17px;
    --font-size-caption: 15px;
    --font-size-small: 13px;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;
    
    /* Enhanced Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-card-hover: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    background-color: var(--background-light);
    color: var(--label-primary);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--background-light);
}

/* Enhanced Header with Date Navigation */
.app-header {
    background: linear-gradient(135deg, #FEF3E2 0%, #EEF2FF 30%, #DBEAFE 70%, #F0F9FF 100%);
    padding: 4px 0;
    margin: 0;
    min-height: auto;
    border-bottom: 1px solid var(--quaternary-gray);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0px;
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #FF9F0A 0%, var(--habitiq-blue) 50%, var(--green-accent) 100%);
    opacity: 0.8;
}

/* Top Bar with Profile and Streak */
.top-bar {
    width: 100%;
    position: relative;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
}

.profile-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.profile-icon svg {
    width: 28px;
    height: 28px;
    fill: rgba(0, 0, 0, 0.6);
}

.profile-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Home Profile Image */
.home-profile-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.home-profile-placeholder {
    font-size: 18px;
    color: white;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-default-icon {
    width: 28px;
    height: 28px;
    opacity: 0.8;
}

.profile-icon:hover {
    transform: scale(1.05);
    border-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.center-logo-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

.app-logo {
    width: 180px;
    height: auto;
    margin: 0;
    padding: 0;
    display: block;
}

/* Responsive logo sizing */
@media (max-width: 480px) {
    .app-logo {
        width: 140px;
    }
}

@media (min-width: 768px) {
    .app-logo {
        width: 200px;
    }
}

.date-navigation {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.date-nav-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    color: var(--habitiq-blue);
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

.date-nav-btn:hover {
    background: white;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.date-nav-btn:active {
    transform: scale(0.95);
}

.date-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.date-display-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 0;
    padding: 0 16px 8px 16px;
}

.date-display {
    font-size: 22px;
    color: var(--label-primary);
    font-weight: 600;
    margin: 0;
    padding: 0;
    line-height: 1.0;
    transition: all 0.3s ease;
}

.date-subtitle {
    font-size: 16px;
    color: var(--label-secondary);
    font-weight: 500;
    margin: 0;
    margin-top: 2px;
    padding: 0;
    line-height: 1.0;
    transition: all 0.3s ease;
}

/* Streak Badge */
.streak-badge {
    background: linear-gradient(135deg, #60A5FA 0%, #3B82F6 100%);
    color: white;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    min-width: 60px;
    justify-content: center;
}

.streak-pop {
    animation: streakPop 0.25s ease-out;
}

@keyframes streakPop {
    from { 
        transform: scale(0.92); 
        opacity: 0.8; 
    }
    to { 
        transform: scale(1); 
        opacity: 1; 
    }
}

@keyframes streakCelebration {
    0% { 
        transform: scale(1); 
        filter: brightness(1);
    }
    20% { 
        transform: scale(1.3); 
        filter: brightness(1.5) saturate(1.5);
    }
    40% { 
        transform: scale(1.1); 
        filter: brightness(1.2);
    }
    60% { 
        transform: scale(1.2); 
        filter: brightness(1.4);
    }
    80% { 
        transform: scale(1.05); 
        filter: brightness(1.1);
    }
    100% { 
        transform: scale(1); 
        filter: brightness(1);
    }
}

.streak-celebration {
    animation: streakCelebration 1.5s ease-out;
}

@keyframes confettiBurst {
    0% {
        opacity: 1;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(360deg);
    }
}

.confetti {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 12px;
    pointer-events: none;
    animation: confettiBurst 1.2s ease-out forwards;
}

/* Streak Reset Alert */
.streak-reset-alert {
    position: absolute;
    top: 68px;
    right: 16px;
    background-color: rgba(239, 68, 68, 0.1);
    color: #DC2626;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    white-space: nowrap;
    z-index: 9;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease-out;
}

.streak-reset-alert.show {
    opacity: 1;
    transform: translateY(0);
}

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

/* Weekly Report Modal */
.weekly-report-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-out;
}

.weekly-report-modal.show {
    opacity: 1;
    visibility: visible;
}

.weekly-report-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin: 20px;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease-out;
}

.weekly-report-modal.show .weekly-report-content {
    transform: scale(1) translateY(0);
}

.weekly-report-header {
    text-align: center;
    margin-bottom: 20px;
}

.weekly-report-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--habitiq-blue);
    margin: 0 0 8px 0;
}

.weekly-report-subtitle {
    font-size: 14px;
    color: #6B7280;
    margin: 0;
}

.weekly-report-stats {
    margin: 20px 0;
}

.weekly-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #F3F4F6;
}

.weekly-stat:last-child {
    border-bottom: none;
}

.weekly-stat-label {
    font-size: 15px;
    color: #374151;
    font-weight: 500;
}

.weekly-stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--habitiq-blue);
}

.weekly-report-close {
    width: 100%;
    background: var(--habitiq-blue);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.weekly-report-close:hover {
    background: #1D4ED8;
}

@media (max-width: 480px) {
    .weekly-report-content {
        margin: 16px;
        padding: 20px;
    }
}

/* Historical Data Styles */
.no-data-message {
    text-align: center;
    color: var(--label-secondary);
    font-style: italic;
    padding: var(--spacing-lg);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--border-radius-sm);
    margin: var(--spacing-sm) 0;
}

.historical-category {
    margin-bottom: var(--spacing-lg);
}

.historical-category-title {
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--quaternary-gray);
}

.historical-habit-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
}

.historical-habit-status {
    font-size: 16px;
}

.historical-habit-name {
    font-size: var(--font-size-caption);
    color: var(--label-primary);
}

.historical-reflection-item {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--border-radius-sm);
}

.historical-reflection-question {
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-xs);
}

.historical-reflection-answer {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    line-height: 1.4;
}

.historical-todo-list {
    margin-bottom: var(--spacing-md);
}

.historical-list-title {
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-sm);
}

.historical-task-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
}

.historical-task-status {
    font-size: 16px;
}

.historical-task-text {
    font-size: var(--font-size-caption);
    color: var(--label-primary);
}

/* Main Content */
.main-content {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Weekly Pills Styles */
.weekly-pills-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--background-light);
    margin: 0 calc(-1 * var(--spacing-md));
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--quaternary-gray);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.weekly-pills {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-xs);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: var(--spacing-xs) 0;
    width: 100%;
}

.weekly-pills::-webkit-scrollbar {
    display: none;
}

.day-pill {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-xs);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    max-width: 60px;
    user-select: none;
    -webkit-user-select: none;
    background: white;
    border: 2px solid var(--quaternary-gray);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.day-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.day-pill:active {
    transform: translateY(0);
}

.day-pill.today {
    border-color: var(--habitiq-blue);
    border-width: 3px;
    background: rgba(37, 99, 235, 0.05);
}

.day-pill.today .day-letter {
    color: var(--habitiq-blue);
    font-weight: 700;
}

.day-pill.today .day-number {
    color: var(--habitiq-blue);
    font-weight: 700;
}

.day-letter {
    font-size: 11px;
    font-weight: 600;
    color: var(--label-secondary);
    margin-bottom: 2px;
    text-transform: uppercase;
}

.day-number {
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: 4px;
}

.day-progress-text {
    font-size: 9px;
    font-weight: 500;
    color: var(--label-secondary);
    text-align: center;
    line-height: 1.1;
    margin-bottom: 4px;
    min-height: 18px;
    display: flex;
    align-items: center;
}

.day-progress-bar {
    width: 100%;
    height: 3px;
    background: var(--quaternary-gray);
    border-radius: 2px;
    overflow: hidden;
}

.day-progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.day-progress-fill.completed {
    background: #22c55e;
    width: 100%;
}

.day-progress-fill.in-progress {
    background: var(--habitiq-blue);
}

.day-progress-fill.incomplete {
    background: #ef4444;
}

.day-progress-fill.no-data {
    background: var(--quaternary-gray);
    width: 0%;
}

/* Active pill styling for navigation */
.day-pill.active {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    border: 3px solid var(--habitiq-blue);
    background: rgba(37, 99, 235, 0.1);
}

.day-pill.active .day-letter,
.day-pill.active .day-number {
    color: var(--habitiq-blue);
    font-weight: 700;
}

/* Past Day Editor Modal */
.past-day-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.past-day-modal {
    background: white;
    border-radius: var(--border-radius-lg);
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.past-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
    border-bottom: 1px solid var(--quaternary-gray);
}

.past-day-header h3 {
    margin: 0;
    font-size: var(--font-size-body);
    font-weight: 600;
    color: var(--label-primary);
}

.past-day-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--label-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.past-day-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.past-day-content {
    padding: var(--spacing-md);
}

.past-day-subtitle {
    margin: 0 0 var(--spacing-md) 0;
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
}

.past-habits-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.past-habit-item {
    display: flex;
    align-items: center;
}

.past-habit-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    flex: 1;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s ease;
}

.past-habit-label:hover {
    background: rgba(0, 0, 0, 0.05);
}

.past-habit-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--habitiq-blue);
}

.past-habit-text {
    font-size: var(--font-size-caption);
    color: var(--label-primary);
}

.past-day-footer {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
    border-top: 1px solid var(--quaternary-gray);
}

.past-day-cancel,
.past-day-save {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-caption);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.past-day-cancel {
    background: rgba(174, 174, 178, 0.15);
    color: var(--label-primary);
    border: 1px solid rgba(174, 174, 178, 0.3);
}

.past-day-cancel:hover {
    background: rgba(174, 174, 178, 0.25);
}

.past-day-save {
    background: var(--habitiq-blue);
    color: white;
    border: 1px solid var(--habitiq-blue);
}

.past-day-save:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* Enhanced Section Cards with Brand Colors */
.section-card {
    background-color: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 12px;
    border: 1px solid var(--quaternary-gray);
    transition: all 0.3s ease;
}

.section-card:hover {
    background: var(--card-background-hover);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

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

/* Select All Button */
.select-all-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(174, 174, 178, 0.15);
    color: var(--label-primary);
    border: 1px solid rgba(174, 174, 178, 0.3);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-caption);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.select-all-btn:hover {
    background: rgba(174, 174, 178, 0.25);
    border-color: rgba(174, 174, 178, 0.5);
    transform: translateY(-1px);
}

.select-all-btn:active {
    transform: translateY(0);
    background: rgba(174, 174, 178, 0.3);
}

.section-title {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
}

/* Category Selector */
.category-selector {
    margin-bottom: var(--spacing-lg);
}

.category-label {
    display: block;
    font-size: var(--font-size-body);
    font-weight: 500;
    color: var(--label-primary);
    margin-bottom: var(--spacing-md);
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-sm);
}

.category-option {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(242, 242, 247, 0.9) 100%);
    border-radius: var(--border-radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    position: relative;
}

.category-option:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(229, 229, 234, 0.95) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.category-option.selected {
    background-color: var(--habitiq-blue);
    border-color: var(--habitiq-blue);
    color: white;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}

.category-checkbox {
    display: none;
}

.category-name {
    font-size: var(--font-size-caption);
    font-weight: 500;
    color: var(--label-primary);
}

/* Habits Container */
.habits-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    transition: all 0.3s ease;
}

.category-group {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(242, 242, 247, 0.8) 100%);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(198, 198, 200, 0.2);
    animation: slideIn 0.5s ease-out;
}

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

@keyframes habitFadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.category-group-title {
    font-size: var(--font-size-body);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-md);
}

.habits-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.habit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(198, 198, 200, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 56px;
    position: relative;
    overflow: hidden;
}

.habit-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 122, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.habit-item:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.habit-item:hover::before {
    left: 100%;
}

.habit-text-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
    margin-right: auto;
    padding-right: var(--spacing-sm);
}

.habit-name {
    font-size: var(--font-size-body);
    color: var(--label-primary);
    font-weight: 500;
    line-height: 1.3;
}

.habit-goal {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    font-weight: 400;
    margin-top: 2px;
}

/* Enhanced iOS-style Toggle Switch */
.toggle-switch {
    position: relative;
    display: flex;
    align-items: center;
    width: 52px;
    height: 32px;
    background: linear-gradient(135deg, var(--tertiary-gray) 0%, var(--quaternary-gray) 100%);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.toggle-switch.checked {
    background: linear-gradient(135deg, var(--green-accent) 0%, var(--green-accent-light) 100%);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 2px;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-50%);
}

.toggle-switch.checked::before {
    transform: translateY(-50%) translateX(20px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toggle-switch:hover::before {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.toggle-switch.checked:hover::before {
    transform: translateY(-50%) translateX(20px) scale(1.05);
}

.toggle-switch:active::before {
    transform: translateY(-50%) scale(0.95);
}

.toggle-switch.checked:active::before {
    transform: translateY(-50%) translateX(20px) scale(0.95);
}

/* Reflection Form */
.reflection-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
    padding: var(--spacing-sm) 0;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-lg);
}

.input-label {
    font-size: var(--font-size-title);
    font-weight: 700;
    color: var(--label-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.input-label .emoji {
    font-size: 1.2em;
}

.reflection-input {
    font-family: var(--font-family);
    font-size: var(--font-size-body);
    padding: var(--spacing-sm) 0;
    border: none;
    border-bottom: 1px solid rgba(198, 198, 200, 0.3);
    border-radius: 0;
    background: transparent;
    color: var(--label-primary);
    resize: none;
    min-height: 60px;
    transition: border-bottom-color 0.3s ease;
    outline: none;
    width: 100%;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
    touch-action: manipulation;
    -webkit-touch-callout: default;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.reflection-input:focus {
    border-bottom-color: var(--habitiq-blue);
    background: transparent;
}

.reflection-input::placeholder {
    color: var(--label-tertiary);
    font-style: italic;
}

/* Enhanced Save Button */
.save-btn {
    background: linear-gradient(135deg, var(--habitiq-blue) 0%, var(--habitiq-blue-light) 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-size-body);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
    position: relative;
    overflow: hidden;
}

.save-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.save-btn:hover {
    background: linear-gradient(135deg, var(--habitiq-blue-dark) 0%, var(--habitiq-blue) 100%);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
    transform: translateY(-2px);
}

.save-btn:hover::before {
    left: 100%;
}

.save-btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* Toast Notification */
.toast {
    position: fixed;
    left: 50%;
    background: linear-gradient(135deg, rgba(29, 29, 31, 0.95) 0%, rgba(60, 60, 67, 0.9) 100%);
    backdrop-filter: blur(20px);
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-xl);
    font-size: var(--font-size-caption);
    font-weight: 500;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    max-width: calc(100% - 2 * var(--spacing-md));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-bottom {
    bottom: var(--spacing-lg);
    transform: translateX(-50%) translateY(100px);
}

.toast-top {
    top: var(--spacing-lg);
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95) 0%, rgba(52, 211, 153, 0.9) 100%);
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
}

.toast.show {
    opacity: 1;
    animation: toastBounce 0.4s ease-out;
}

.toast-bottom.show {
    transform: translateX(-50%) translateY(0) scale(1);
}

.toast-top.show {
    transform: translateX(-50%) translateY(0) scale(1);
}

@keyframes toastBounce {
    0% {
        transform: translateX(-50%) translateY(100px) scale(0.9);
    }
    50% {
        transform: translateX(-50%) translateY(-5px) scale(1.02);
    }
    100% {
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* Responsive Design */
@media (max-width: 375px) {
    .main-content {
        padding: var(--spacing-sm);
    }
    
    .section-card {
        padding: var(--spacing-md);
    }
    
    .category-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 768px) {
    .app-container {
        max-width: 480px;
    }
    
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Enhanced Animation for habit completion */
@keyframes checkmarkAnimation {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulseSuccess {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.habit-item.completed {
    animation: checkmarkAnimation 0.4s ease;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(52, 211, 153, 0.05) 100%);
    border-color: rgba(16, 185, 129, 0.3);
}

.habit-item.completed .toggle-switch {
    animation: pulseSuccess 1s ease-out;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: var(--spacing-lg);
    max-width: 400px;
    width: calc(100% - 2 * var(--spacing-md));
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    margin-bottom: var(--spacing-lg);
}

.modal-title {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-sm);
}

.modal-subtitle {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.form-label {
    font-size: var(--font-size-caption);
    font-weight: 500;
    color: var(--label-primary);
}

.form-input {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    font-size: var(--font-size-body);
    padding: var(--spacing-md);
    border: 1px solid var(--quaternary-gray);
    border-radius: var(--border-radius-sm);
    background: var(--background-light);
    color: var(--label-primary);
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--habitiq-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.habits-input-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.habit-input-group {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.habit-input {
    flex: 1;
}

.remove-habit-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--quaternary-gray);
    background: white;
    color: var(--secondary-gray);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-habit-btn:hover {
    background: var(--red);
    color: white;
    border-color: var(--red);
}

.add-habit-btn {
    background: none;
    border: 1px dashed var(--habitiq-blue);
    color: var(--habitiq-blue);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-caption);
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.add-habit-btn:hover {
    background: rgba(37, 99, 235, 0.05);
}

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.modal-btn {
    flex: 1;
    padding: var(--spacing-md);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-body);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

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

.modal-btn-primary:hover {
    background: var(--habitiq-blue-dark);
}

.modal-btn-secondary {
    background: var(--quaternary-gray);
    color: var(--label-secondary);
}

.modal-btn-secondary:hover {
    background: var(--tertiary-gray);
}

/* Custom Category Display */
.custom-category {
    position: relative;
}



/* Edit Categories Button */
.edit-categories-btn {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #374151;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    margin-top: var(--spacing-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    font-weight: 600;
    font-size: var(--font-size-body);
    border: 2px solid #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.edit-categories-btn:hover {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.edit-categories-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.edit-categories-btn.editing {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.edit-categories-btn.editing .edit-categories-text {
    display: none;
}

.edit-categories-btn.editing::after {
    content: 'Done Editing';
}

/* Category editing mode styles */
.category-grid.editing .category-option {
    animation: wiggle 0.3s ease-in-out infinite;
    position: relative;
}

@keyframes wiggle {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-1.5deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(1.5deg); }
    100% { transform: rotate(0deg); }
}

.category-option .delete-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    z-index: 10;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.category-grid.editing .category-option .delete-badge {
    display: flex;
}

.category-option .category-name-input {
    display: none;
    font-size: var(--font-size-caption);
    padding: 2px 4px;
    border: 1px solid var(--habitiq-blue);
    border-radius: 4px;
    background: white;
    width: calc(100% - 8px);
}

.category-grid.editing .category-option.edit-name .category-name {
    display: none;
}

.category-grid.editing .category-option.edit-name .category-name-input {
    display: block;
}

/* Add Category Bar */
.add-category-bar {
    background: linear-gradient(135deg, var(--habitiq-blue) 0%, var(--habitiq-blue-dark) 100%);
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    margin-top: var(--spacing-sm);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    font-weight: 600;
    font-size: var(--font-size-body);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.add-category-bar:hover {
    background: linear-gradient(135deg, var(--habitiq-blue-dark) 0%, var(--habitiq-blue) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.add-category-bar:active {
    transform: translateY(0);
}

/* Inline Category Form */
.inline-category-form {
    margin-top: var(--spacing-md);
    background: white;
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    border: 2px solid var(--habitiq-blue);
    animation: slideDown 0.3s ease-out;
}

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

.inline-form-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.inline-category-input {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    font-size: var(--font-size-body);
    font-weight: 600;
    padding: var(--spacing-md);
    border: 2px solid var(--habitiq-blue);
    border-radius: var(--border-radius-sm);
    background: var(--background-light);
    color: var(--label-primary);
    transition: all 0.3s ease;
}

.inline-category-input:focus {
    outline: none;
    border-color: var(--habitiq-blue-dark);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.inline-habits-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.inline-habit-input {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    font-size: var(--font-size-caption);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--quaternary-gray);
    border-radius: var(--border-radius-sm);
    background: white;
    color: var(--label-primary);
    transition: all 0.3s ease;
}

.inline-habit-input:focus {
    outline: none;
    border-color: var(--habitiq-blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.inline-form-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.inline-btn {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-caption);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

.inline-btn-cancel {
    background: var(--quaternary-gray);
    color: var(--label-secondary);
}

.inline-btn-cancel:hover {
    background: var(--tertiary-gray);
}

.inline-btn-save {
    background: var(--habitiq-blue);
    color: white;
}

.inline-btn-save:hover {
    background: var(--habitiq-blue-dark);
}

/* Add Habit Button */
.add-habit-bar {
    background: linear-gradient(135deg, var(--habitiq-blue) 0%, var(--habitiq-blue-dark) 100%);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    margin-top: var(--spacing-sm);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    font-weight: 500;
    font-size: var(--font-size-caption);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.2);
    border: none;
    width: 100%;
}

.add-habit-bar:hover {
    background: linear-gradient(135deg, var(--habitiq-blue-dark) 0%, var(--habitiq-blue) 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Consolidated habit text area styles moved to line 1183 */

/* Habit Item Editing */
.habit-item.editing .habit-name {
    display: none;
}

.habit-item.editing .habit-edit-input {
    display: block;
}

.habit-edit-input {
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    font-size: var(--font-size-body);
    font-weight: 500;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--habitiq-blue);
    border-radius: var(--border-radius-xs);
    background: white;
    color: var(--label-primary);
    flex: 1;
    margin-right: var(--spacing-sm);
}

.habit-actions {
    display: flex;
    gap: var(--spacing-xs);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.habit-item:hover .habit-actions {
    opacity: 1;
}

.habit-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.habit-edit-btn {
    background: rgba(37, 99, 235, 0.1);
    color: var(--habitiq-blue);
}

.habit-edit-btn:hover {
    background: var(--habitiq-blue);
    color: white;
}

.habit-delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

.habit-delete-btn:hover {
    background: var(--red);
    color: white;
}

/* Edit Reflections Bar */
.edit-reflections-bar {
    background: linear-gradient(135deg, var(--habitiq-blue) 0%, var(--habitiq-blue-dark) 100%);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    margin-top: var(--spacing-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    font-weight: 500;
    font-size: var(--font-size-caption);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.2);
}

.edit-reflections-bar:hover {
    background: linear-gradient(135deg, var(--habitiq-blue-dark) 0%, var(--habitiq-blue) 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Inline Reflection Editor */
.inline-reflection-editor {
    margin-top: var(--spacing-md);
    background: white;
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    border: 2px solid var(--habitiq-blue);
    animation: slideDown 0.3s ease-out;
}

.reflection-editor-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.editor-title {
    font-size: var(--font-size-body);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 var(--spacing-sm) 0;
}

.reflection-questions-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.question-edit-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--background-light);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--quaternary-gray);
}

.question-emoji {
    font-size: var(--font-size-body);
    min-width: 24px;
}

.question-input {
    flex: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    font-size: var(--font-size-caption);
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--quaternary-gray);
    border-radius: var(--border-radius-xs);
    background: white;
    color: var(--label-primary);
}

.question-input:focus {
    outline: none;
    border-color: var(--habitiq-blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.question-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.question-delete-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.question-delete-btn:hover {
    background: var(--red);
    color: white;
}

.add-question-section {
    margin-top: var(--spacing-sm);
}

.add-question-btn {
    background: rgba(37, 99, 235, 0.1);
    color: var(--habitiq-blue);
    border: 1px dashed var(--habitiq-blue);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-caption);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.add-question-btn:hover {
    background: var(--habitiq-blue);
    color: white;
    border-color: var(--habitiq-blue);
}

.editor-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--quaternary-gray);
}

/* Swipe Gesture Components */
.swipe-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 10px;
    background: white;
    touch-action: pan-y;
    user-select: none;
}

.swipe-actions {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 8px;
    background-color: #F8FAFC;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1;
    border-radius: 0 12px 12px 0;
    overflow: hidden;
    visibility: visible;
}

.swipe-actions.revealed {
    transform: translateX(0);
    visibility: visible;
}

.swipe-content {
    position: relative;
    background: white;
    padding: 14px;
    transition: transform 0.3s ease;
    z-index: 2;
    border-radius: 12px;
    cursor: pointer;
}

.swipe-content.swiped {
    transform: translateX(-140px);
}

.swipe-action-btn {
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    min-width: 70px;
    min-height: 44px; /* iOS minimum tap target */
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.swipe-edit-btn {
    background-color: #2563EB; /* Bronto Blue */
}

.swipe-edit-btn:hover {
    background-color: #1D4ED8;
    transform: scale(1.05);
}

.swipe-edit-btn:active {
    transform: scale(0.95);
    background-color: #1E40AF;
}

.swipe-delete-btn {
    background-color: #EF4444; /* Soft red */
}

.swipe-delete-btn:hover {
    background-color: #DC2626;
    transform: scale(1.05);
}

.swipe-delete-btn:active {
    transform: scale(0.95);
    background-color: #B91C1C;
}

/* Touch/Mouse interaction improvements */
.swipe-container.dragging .swipe-content {
    transition: none;
}

.swipe-container.dragging .swipe-actions {
    transition: none;
}

/* Habit item modifications for swipe */
.habit-item-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    position: relative;
    z-index: 2;
    min-height: 52px;
    width: 100%;
    padding: 0;
}

.habit-item .habit-actions {
    display: none; /* Hide old hover actions, use swipe instead */
}

/* Reflection question swipe modifications */
.reflection-question-item {
    border: 1px solid var(--quaternary-gray);
}

.reflection-question-content {
    background: white;
    position: relative;
    z-index: 2;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Habit item specific swipe content - horizontal layout for habit items only */
.habit-item-content .swipe-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
}

/* Animation for smooth reveals */
@keyframes swipeReveal {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes swipeContentSlide {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-140px);
    }
}

/* Improved touch targets */
.swipe-action-btn {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* iOS-style haptic feedback visual cues */
.swipe-container.haptic-light {
    animation: hapticPulse 0.1s ease-out;
}

@keyframes hapticPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Enhanced Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-primary: #1C1C1E;
        --background-secondary: #000000;
        --background-tertiary: #2C2C2E;
        --background-gradient: linear-gradient(135deg, #000000 0%, #1C1C1E 100%);
        --card-background: rgba(28, 28, 30, 0.8);
        --card-background-hover: rgba(28, 28, 30, 0.95);
        --label-primary: #FFFFFF;
        --label-secondary: #EBEBF5;
        --label-tertiary: #EBEBF599;
        --separator: #38383A;
        --senary-gray: #1C1C1E;
        --quinary-gray: #2C2C2E;
        --quaternary-gray: #3A3A3C;
        --tertiary-gray: #48484A;
        --secondary-gray: #636366;
    }
    
    .app-header {
        background: rgba(28, 28, 30, 0.85);
        border-bottom: 1px solid rgba(56, 56, 58, 0.5);
    }
    
    .reflection-input {
        background: rgba(28, 28, 30, 0.7);
        border: 1px solid rgba(56, 56, 58, 0.3);
    }
    
    .reflection-input:focus {
        background: rgba(28, 28, 30, 0.95);
    }
    
    .habit-item {
        background: rgba(28, 28, 30, 0.6);
        border: 1px solid rgba(56, 56, 58, 0.2);
    }
    
    .habit-item:hover {
        background: rgba(28, 28, 30, 0.8);
    }
    
    .category-option {
        background: linear-gradient(135deg, rgba(28, 28, 30, 0.8) 0%, rgba(44, 44, 46, 0.9) 100%);
    }
    
    .category-group {
        background: linear-gradient(135deg, rgba(28, 28, 30, 0.6) 0%, rgba(44, 44, 46, 0.8) 100%);
        border: 1px solid rgba(56, 56, 58, 0.3);
    }
}

/* Multiple To-Do Lists Styles */
.todo-lists-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.todo-list-container {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.3);
    overflow: hidden;
    transition: all 0.3s ease;
}

.todo-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.05) 100%);
    border-bottom: 1px solid rgba(198, 198, 200, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.todo-list-header:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(37, 99, 235, 0.08) 100%);
}

.list-title-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
}

.list-collapse-icon {
    font-size: 12px;
    color: var(--habitiq-blue);
    transition: transform 0.3s ease;
    width: 12px;
    text-align: center;
}

.todo-list-header.collapsed .list-collapse-icon {
    transform: rotate(0deg);
}

.list-title {
    font-size: var(--font-size-body);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0;
}

.list-count {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    font-weight: 500;
}

.delete-list-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.delete-list-btn:hover {
    background: var(--red);
    color: white;
    opacity: 1;
    transform: scale(1.1);
}

.todo-list-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

.todo-list-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.todo-items-container {
    padding: 0 var(--spacing-md);
}

.add-task-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(37, 99, 235, 0.02) 100%);
    color: var(--habitiq-blue);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: var(--font-size-caption);
    margin: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    border: 1px dashed rgba(37, 99, 235, 0.3);
}

.add-task-bar:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.05) 100%);
    border-color: rgba(37, 99, 235, 0.5);
    transform: translateY(-1px);
}

.add-list-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--habitiq-blue) 0%, var(--habitiq-blue-light) 100%);
    color: white;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

.add-list-bar:hover {
    background: linear-gradient(135deg, var(--habitiq-blue-dark) 0%, var(--habitiq-blue) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
}

/* Legacy To-Do List Styles */
.todo-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.todo-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.3);
    transition: all 0.3s ease;
}

.todo-item:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.todo-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--habitiq-blue);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    position: relative;
}

.todo-checkbox:checked {
    background: var(--habitiq-blue);
}

.todo-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Remove old styling - now handled by input[type="checkbox"] */

.todo-text {
    flex: 1;
    font-size: var(--font-size-body);
    color: var(--label-primary);
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: var(--label-tertiary);
}

.add-todo-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--habitiq-blue) 0%, var(--habitiq-blue-light) 100%);
    color: white;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: var(--spacing-sm);
    font-weight: 500;
}

.add-todo-bar:hover {
    background: linear-gradient(135deg, var(--habitiq-blue-dark) 0%, var(--habitiq-blue) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.3);
}

/* Weekly Summary Styles */
.weekly-summary-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    border: 1px solid rgba(198, 198, 200, 0.3);
}

.weekly-summary-title {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-lg);
}

.habit-chart {
    background: white;
    border: 2px solid var(--label-primary);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.habit-row {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-md);
    height: 40px;
}

.habit-row:last-child {
    margin-bottom: 0;
}

.habit-label {
    width: 100px;
    font-size: 16px;
    font-weight: 500;
    color: var(--label-primary);
    text-align: right;
    margin-right: var(--spacing-md);
    flex-shrink: 0;
}

.habit-bar-container {
    flex: 1;
    height: 30px;
    background: #f0f0f0;
    border-radius: 2px;
    position: relative;
    margin-right: var(--spacing-md);
}

.habit-bar {
    height: 100%;
    background: var(--habitiq-blue);
    border-radius: 2px;
    transition: width 0.5s ease;
    position: relative;
}

.habit-score {
    font-size: 16px;
    font-weight: 600;
    color: var(--label-primary);
    width: 30px;
    text-align: left;
    flex-shrink: 0;
}

.weekly-summary-stats {
    display: flex;
    justify-content: space-between;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--label-primary);
}

.weekly-summary-stats .stat-item {
    flex: 1;
}

.weekly-summary-stats .stat-emoji {
    margin-right: var(--spacing-xs);
}

.weekly-summary-stats .stat-item {
    margin-bottom: var(--spacing-sm);
}

/* Page Navigation */
.page {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Bottom Tab Bar */
.bottom-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: var(--spacing-xs) 0;
    height: 80px;
    z-index: 100;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
}

.tab-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    min-width: 60px;
    position: relative;
}

/* Add divider lines between tab buttons */
.tab-button:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    bottom: 25%;
    width: 1px;
    background-color: rgba(0, 0, 0, 0.25);
    opacity: 0.8;
}

.tab-button:hover {
    background: rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.tab-button.active {
    color: #2563EB;
}

.tab-button.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: #2563EB;
    border-radius: 2px;
}

.tab-icon {
    font-size: 24px;
    margin-bottom: 2px;
    filter: grayscale(0.5);
    transition: filter 0.2s ease;
}

.tab-button.active .tab-icon {
    filter: grayscale(0);
}

.tab-label {
    font-size: 11px;
    font-weight: 500;
    color: #64748B;
    transition: color 0.2s ease;
}

.tab-button.active .tab-label {
    color: #2563EB;
    font-weight: 600;
}

/* Main content spacing for bottom tab bar */
.main-content {
    padding-bottom: 100px; /* Space for bottom tab bar */
}

/* Simple Tab Bar */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    background-color: #fff;
    border-top: 1px solid #ccc;
    padding: 10px 0;
    z-index: 1000;
}

.tab-bar button {
    flex-grow: 1;
    background: none;
    border: none;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    padding: 8px;
    position: relative;
}

/* Add divider lines between tabs */
.tab-bar button:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background-color: rgba(0, 0, 0, 0.2);
    opacity: 0.8;
}

.tab-bar button.active {
    font-weight: bold;
    color: #2563EB;
}

/* Confirmation Modal */
.confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-lg);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.confirmation-modal.show {
    opacity: 1;
    visibility: visible;
}

.confirmation-modal-content {
    background: white;
    border-radius: 14px;
    padding: var(--spacing-lg);
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.confirmation-modal.show .confirmation-modal-content {
    transform: scale(1);
}

.confirmation-modal-title {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.3;
}

.confirmation-modal-message {
    font-size: var(--font-size-body);
    color: var(--label-secondary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.4;
}

.confirmation-modal-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.confirmation-btn {
    flex: 1;
    padding: 12px var(--spacing-md);
    border: none;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-body);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.confirmation-btn-cancel {
    background: var(--fill-quaternary);
    color: var(--label-primary);
}

.confirmation-btn-cancel:hover {
    background: var(--fill-tertiary);
}

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

.confirmation-btn-primary:hover {
    background: var(--blue-600);
    transform: translateY(-1px);
}

.confirmation-btn-destructive {
    background: #ff3b30;
    color: white;
}

.confirmation-btn-destructive:hover {
    background: #e60012;
    transform: translateY(-1px);
}

/* Calendar specific styling for tab view */
.calendar-header {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.calendar-header h3 {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: var(--spacing-sm);
    padding: 0 var(--spacing-sm);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: var(--spacing-sm);
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin: 0 auto var(--spacing-sm);
    padding: 12px;
    box-sizing: border-box;
}

.calendar-weekday {
    text-align: center;
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-secondary);
    padding: var(--spacing-xs);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 36px;
}

.chart-axis {
    display: flex;
    justify-content: space-between;
    margin-top: var(--spacing-sm);
    padding: 0 100px 0 114px;
    font-size: 14px;
    color: var(--label-secondary);
}

.chart-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        to right,
        transparent,
        transparent calc(100% / 7 - 1px),
        rgba(0, 0, 0, 0.1) calc(100% / 7),
        rgba(0, 0, 0, 0.1) calc(100% / 7)
    );
    pointer-events: none;
}

/* Calendar Styles - iOS Responsive Grid */
.calendar-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    border: 1px solid rgba(198, 198, 200, 0.3);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    color: var(--label-primary);
}

.calendar-nav {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.calendar-nav:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--habitiq-blue);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin: 0 auto var(--spacing-md);
    padding: 8px;
    box-sizing: border-box;
    min-height: 200px;
}

.calendar-day-header {
    text-align: center;
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-secondary);
    padding: var(--spacing-xs);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 28px;
}

.calendar-day {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 28px;
    border-radius: 4px;
    background-color: white;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    color: var(--label-primary);
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.calendar-day:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

.calendar-day.today {
    background-color: #2563eb;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.calendar-day.completed {
    background-color: #22c55e !important;
    color: white;
    font-weight: 600;
}

.calendar-day.incomplete {
    background-color: #ef4444 !important;
    color: white;
    font-weight: 600;
}

.calendar-day.today {
    background-color: #2563eb !important;
    color: white !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
}

.calendar-day.other-month {
    color: var(--label-quaternary);
    opacity: 0.3;
}

.monthly-completion {
    text-align: center;
    font-size: var(--font-size-body);
    color: var(--label-primary);
    font-weight: 500;
}

.monthly-stats {
    text-align: center;
    padding: var(--spacing-md);
}

/* Weekly Insights Styles */
.insights-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.insights-category {
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
}

.insights-title {
    font-size: var(--font-size-body);
    font-weight: 700;
    color: var(--label-primary);
    margin: 0 0 var(--spacing-sm) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.insights-stats {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.stat-item {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    line-height: 1.4;
    padding: var(--spacing-xs) 0;
}

.stat-item strong {
    color: var(--label-primary);
    font-weight: 600;
}

.insights-placeholder {
    background: rgba(37, 99, 235, 0.05);
    border: 1px dashed rgba(37, 99, 235, 0.3);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    text-align: center;
    margin-top: var(--spacing-sm);
}

.placeholder-text {
    font-size: var(--font-size-caption);
    color: var(--label-tertiary);
    font-style: italic;
    margin: 0;
}

/* AI Insights Availability Message */
.ai-insights-availability {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
}

.ai-insights-availability p {
    font-size: var(--font-size-body);
    color: var(--label-secondary);
    line-height: 1.5;
    margin: 0;
    font-weight: 500;
}

.insights-no-data {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.no-data-message h3 {
    font-size: var(--font-size-body);
    font-weight: 600;
    color: var(--label-secondary);
    margin: 0 0 var(--spacing-sm) 0;
}

.no-data-message p {
    font-size: var(--font-size-caption);
    color: var(--label-tertiary);
    line-height: 1.5;
    margin: 0;
}

/* Today's Recap Section Styles */
.today-recap-section {
    margin-bottom: var(--spacing-lg);
}

.today-recap-container {
    padding: var(--spacing-md);
}

.today-recap-no-data {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.today-recap-no-data .no-data-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.today-recap-no-data h3 {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 var(--spacing-sm) 0;
}

.today-recap-no-data p {
    font-size: var(--font-size-body);
    color: var(--label-secondary);
    line-height: 1.5;
    margin: 0;
}

.today-recap-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.recap-overview {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.recap-stats {
    display: flex;
    gap: var(--spacing-lg);
    justify-content: center;
}

.recap-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(198, 198, 200, 0.3);
    min-width: 80px;
}

.recap-stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--habitiq-blue);
    line-height: 1;
    margin-bottom: 4px;
}

.recap-stat-label {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.recap-motivation {
    text-align: center;
    padding: var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-size: var(--font-size-body);
    font-weight: 600;
    line-height: 1.4;
}

.recap-motivation.all-completed {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.3));
    color: rgba(21, 128, 61, 1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.recap-motivation.partial-completed {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.2), rgba(251, 146, 60, 0.3));
    color: rgba(194, 65, 12, 1);
    border: 1px solid rgba(251, 146, 60, 0.3);
}

.recap-habits {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.recap-habits-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.recap-section-title {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0;
}

.recap-habits-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.habit-item {
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
    font-size: var(--font-size-body);
    line-height: 1.4;
}

.habit-item.completed-habit {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
    color: rgba(21, 128, 61, 1);
}

.habit-item.missed-habit {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: rgba(153, 27, 27, 1);
}

.habit-item.no-habits {
    font-style: italic;
    color: var(--label-tertiary);
    text-align: center;
}

/* Today's Recap Chart Section */
.recap-chart-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.weekly-progress-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 120px;
    padding: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
    gap: var(--spacing-xs);
}

.chart-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    max-width: 40px;
}

.chart-bar {
    width: 100%;
    max-height: 80px;
    background: linear-gradient(to top, var(--habitiq-blue), var(--habitiq-blue-light));
    border-radius: 6px 6px 0 0;
    transition: all 0.3s ease;
    min-height: 4px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.chart-bar-fill {
    width: 100%;
    height: 100%;
    border-radius: 6px 6px 0 0;
    transition: all 0.3s ease;
}

.chart-bar-fill {
    background: linear-gradient(to top, var(--habitiq-blue), var(--habitiq-blue-light));
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.chart-bar-container:hover .chart-bar {
    transform: scale(1.05);
}

.chart-bar-container:hover .chart-bar-fill {
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

.chart-bar-label {
    margin-top: var(--spacing-xs);
    text-align: center;
    font-size: var(--font-size-caption);
    position: relative;
    z-index: 1;
}

.chart-day {
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: 2px;
}

.chart-progress {
    font-size: 10px;
    color: var(--label-secondary);
    font-weight: 500;
}

/* Profile Page Styles */
.profile-section {
    margin-bottom: var(--spacing-lg);
}

.profile-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    padding: var(--spacing-md);
}

.profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.profile-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    background: var(--fill-quaternary);
    border: 2px solid var(--separator-opaque);
}

.profile-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar-placeholder svg {
    width: 60px;
    height: 60px;
}

.profile-change-photo-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--habitiq-blue);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-body);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.profile-change-photo-btn:hover {
    background: var(--habitiq-blue-dark);
}

.profile-change-photo-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.profile-label {
    font-size: var(--font-size-body);
    font-weight: 500;
    color: var(--label-primary);
}

.profile-input {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--separator-opaque);
    border-radius: var(--border-radius-sm);
    font-size: 16px; /* Prevent zoom on iOS */
    background: var(--fill-secondary);
    color: var(--label-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-input:focus {
    outline: none;
    border-color: var(--habitiq-blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.profile-input-readonly {
    background: var(--fill-tertiary);
    color: var(--label-secondary);
    cursor: default;
}

.profile-input-readonly:focus {
    border-color: var(--separator-opaque);
    box-shadow: none;
}

.profile-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.profile-btn {
    flex: 1;
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-body);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

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

.profile-btn-primary:hover:not(:disabled) {
    background: var(--habitiq-blue-dark);
    transform: translateY(-1px);
}

.profile-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.profile-btn-secondary {
    background: var(--fill-tertiary);
    color: var(--label-primary);
    border: 1px solid var(--separator-opaque);
}

.profile-btn-secondary:hover:not(:disabled) {
    background: var(--fill-quaternary);
    transform: translateY(-1px);
}

.profile-btn-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.8);
}

.profile-toast {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    text-align: center;
    font-size: var(--font-size-body);
    margin-top: var(--spacing-md);
}

.profile-toast.success {
    background: rgba(34, 197, 94, 0.1);
    color: rgba(21, 128, 61, 1);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.profile-toast.error {
    background: rgba(239, 68, 68, 0.1);
    color: rgba(153, 27, 27, 1);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Profile Auth Required Styles */
.profile-auth-required {
    text-align: center;
    padding: var(--spacing-xl);
    background: var(--fill-secondary);
    border-radius: var(--border-radius-md);
    margin: var(--spacing-lg) 0;
}

.auth-required-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.profile-auth-required h3 {
    font-size: var(--font-size-h3);
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: var(--spacing-sm);
}

.profile-auth-required p {
    color: var(--label-secondary);
    margin-bottom: var(--spacing-lg);
}

/* Profile version footer */
.profile-footer {
    text-align: center;
    padding: var(--spacing-lg) 0;
    border-top: 1px solid var(--separator-opaque);
    margin-top: var(--spacing-lg);
}

.profile-version {
    color: var(--label-secondary);
    font-size: var(--font-size-caption);
}

/* Fix auto-scroll issue on mobile when keyboard opens */
/* The scrollable content wrapper that holds the profile screen */
.app-scroll,
.profile-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scroll-padding-top: 80px; /* height of any fixed/sticky header */
  overscroll-behavior: contain;
}

/* Use dynamic viewport height so keyboard resize doesn't jump */
.page,
.profile-screen {
  min-height: 100dvh;
}

/* Prevent input focus from causing page scroll on mobile */
.profile-input:focus {
  scroll-margin-top: 80px;
  scroll-behavior: smooth;
}

/* Additional mobile Safari keyboard fixes */
@supports (-webkit-touch-callout: none) {
  .profile-scroll {
    position: relative;
    overflow-anchor: none;
  }
  
  /* Prevent iOS Safari from scrolling to input on focus */
  .profile-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Weekly Insights Styles */
.wi-card { 
    padding: 16px; 
    border-radius: 16px; 
    background: #fff; 
    box-shadow: 0 6px 24px rgba(0,0,0,0.06); 
    margin-bottom: var(--spacing-lg);
}
.wi-chart { 
    height: 160px; 
    display: flex; 
    align-items: flex-end; 
    gap: 12px; 
    padding: 16px; 
    border-radius: 16px; 
    background: #f7f9ff; 
}
.wi-bar {
    width: 28px;
    border-radius: 12px;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 6px 16px rgba(37,99,235,0.25);
    transition: height 200ms ease;
    /* Important: NO flex: 1 - height is set inline per bar */
}
.wi-bar.is-today { 
    outline: 2px solid rgba(37,99,235,0.35); 
    outline-offset: 4px; 
}
.wi-day { 
    text-align: center; 
    font-size: 12px; 
    color: #667085; 
    margin-top: 8px; 
}
.wi-col { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}
.wi-summary { 
    padding: 12px 2px 0; 
}
.wi-line { 
    margin: 4px 0; 
    font-size: 14px; 
    color: #111827; 
}
.wi-main { 
    font-weight: 600; 
}
.wi-sub { 
    color: #6b7280; 
}

.weekly-insights-summary-container {
    padding: var(--spacing-md);
}

.weekly-summary-no-data {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.weekly-summary-no-data .no-data-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.weekly-summary-no-data h3 {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 var(--spacing-sm) 0;
}

.weekly-summary-no-data p {
    font-size: var(--font-size-body);
    color: var(--label-secondary);
    line-height: 1.5;
    margin: 0;
}

.weekly-summary-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.summary-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.summary-stat-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(198, 198, 200, 0.3);
}

.summary-stat-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.summary-stat-content {
    flex: 1;
    min-width: 0;
}

.summary-stat-number {
    font-size: var(--font-size-title);
    font-weight: 700;
    color: var(--habitiq-blue);
    line-height: 1.2;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-stat-label {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    font-weight: 500;
    line-height: 1.2;
}

.weekly-insights {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.insights-section-title {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0;
}

.insights-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
}

.insight-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.insight-text {
    font-size: var(--font-size-body);
    color: var(--label-primary);
    line-height: 1.5;
    flex: 1;
}

/* Section subtitle styles */
.section-subtitle {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    margin: 4px 0 0 0;
    font-weight: 500;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .recap-stats {
        gap: var(--spacing-md);
    }
    
    .recap-stat {
        min-width: 70px;
        padding: var(--spacing-sm);
    }
    
    .recap-stat-number {
        font-size: 24px;
    }
    
    .summary-stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .summary-stat-card {
        padding: var(--spacing-sm);
    }
    
    .summary-stat-number {
        font-size: var(--font-size-body);
    }
}

/* Weekly Progress Chart Styles */
.weekly-progress-chart {
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
    margin-bottom: var(--spacing-md);
}

.chart-container {
    position: relative;
    height: 200px;
    margin-bottom: var(--spacing-md);
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 160px;
    padding: 0 var(--spacing-sm);
    position: relative;
}

.chart-bar {
    flex: 1;
    margin: 0 2px;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    position: relative;
    min-height: 8px;
}

/* Dynamic bar colors based on completion */
.chart-bar[data-percentage="0"] {
    background: rgba(37, 99, 235, 0.2);
}

.chart-bar[data-percentage="1"], 
.chart-bar[data-percentage="2"], 
.chart-bar[data-percentage="3"] {
    background: linear-gradient(to top, rgba(37, 99, 235, 0.3), rgba(37, 99, 235, 0.4));
}

.chart-bar[data-percentage="4"], 
.chart-bar[data-percentage="5"], 
.chart-bar[data-percentage="6"] {
    background: linear-gradient(to top, rgba(37, 99, 235, 0.5), rgba(37, 99, 235, 0.6));
}

.chart-bar[data-percentage="7"], 
.chart-bar[data-percentage="8"] {
    background: linear-gradient(to top, var(--habitiq-blue), rgba(37, 99, 235, 0.9));
}

.chart-bar[data-percentage="9"], 
.chart-bar[data-percentage="10"] {
    background: linear-gradient(to top, var(--habitiq-blue), #1d4ed8);
}

.chart-bar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.chart-bar-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-secondary);
    text-align: center;
}

.chart-bar-value {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--label-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chart-bar:hover .chart-bar-value {
    opacity: 1;
}

.chart-grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.chart-grid-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(198, 198, 200, 0.3);
}

.weekly-progress-summary {
    text-align: center;
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
}

.progress-summary-main {
    font-size: var(--font-size-body);
    color: var(--label-primary);
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.progress-summary-trend {
    font-size: var(--font-size-caption);
    color: var(--label-secondary);
    font-style: italic;
}

.trend-positive {
    color: #22c55e;
}

.trend-negative {
    color: #ef4444;
}

.trend-neutral {
    color: var(--label-tertiary);
}
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-md);
    margin-top: var(--spacing-md);
    font-weight: 600;
    color: var(--label-primary);
    font-size: 16px;
}

.monthly-stats::before {
    content: '✓ ';
    color: #22c55e;
    font-weight: bold;
}

/* Sign In Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile keyboard support */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-start;
        padding: 10px;
        min-height: 100vh;
        box-sizing: border-box;
    }
    
    .modal-overlay.keyboard-open {
        padding-top: 5px;
        padding-bottom: 5px;
        align-items: flex-start;
    }
}

.sign-in-modal {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

/* Mobile adjustments for keyboard */
@media (max-width: 768px) {
    .sign-in-modal {
        width: 95%;
        max-height: none;
        min-height: auto;
        margin: 10px 0;
    }
    
    .modal-overlay.keyboard-open .sign-in-modal {
        margin: 5px 0;
        max-height: calc(100vh - 10px);
        overflow-y: auto;
        transform: scale(1) translateY(0);
    }
}

.modal-overlay.active .sign-in-modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, var(--habitiq-blue) 100%);
    color: white;
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: white;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: white;
    font-weight: 600;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-content {
    padding: 24px;
    background: white;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile modal content adjustments */
@media (max-width: 768px) {
    .modal-content {
        padding: 16px;
        max-height: none;
    }
    
    .modal-overlay.keyboard-open .modal-content {
        max-height: calc(80vh - 60px);
        overflow-y: auto;
        padding: 12px;
    }
}

.modal-message {
    font-size: 16px;
    color: var(--label-secondary);
    margin: 0 0 24px 0;
    line-height: 1.5;
    text-align: center;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, var(--habitiq-blue) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--habitiq-blue);
    border: 2px solid var(--habitiq-blue);
    border-radius: 12px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--habitiq-blue);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.2);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Authentication form styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--habitiq-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Enhanced mobile input focus styling */
@media (max-width: 768px) {
    .form-group input.input-focused {
        transform: translateZ(0);
        position: relative;
        z-index: 10;
    }
    
    .modal-overlay.keyboard-open .form-group input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .modal-overlay.keyboard-open .form-group {
        margin-bottom: 12px; /* Reduced spacing when keyboard is open */
    }
}

.auth-error {
    background: #FEE2E2;
    border: 1px solid #FECACA;
    color: #DC2626;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.auth-success {
    background: #DCFCE7;
    border: 1px solid #BBF7D0;
    color: #16A34A;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.form-help {
    color: #666;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.forgot-password-link {
    color: #2563EB;
    text-decoration: none;
    font-size: 14px;
    margin-top: 8px;
    display: inline-block;
}

.forgot-password-link:hover {
    text-decoration: underline;
}

.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 8px;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Profile Modal Styles - Refined Version */
#userProfileView {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Top Bar with Gradient */
.profile-header-gradient {
    background: linear-gradient(135deg, var(--habitiq-blue) 0%, #1e40af 100%);
    padding: 32px 24px 24px;
    text-align: center;
    border-radius: 16px 16px 0 0;
    margin: -24px -24px 0 -24px;
    position: relative;
}

.profile-title {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.profile-welcome {
    margin: 0 0 24px 0;
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Profile Picture in Header */
.profile-header-gradient .profile-picture-section {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.profile-picture-container {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.profile-picture-container:hover {
    transform: translateY(-2px);
}

.profile-picture {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    position: relative;
    background: var(--background-primary);
}

.profile-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-picture svg {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.profile-picture-overlay {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: var(--habitiq-blue);
    color: white;
    border: 3px solid white;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transition: all 0.3s ease;
    pointer-events: none;
}

.profile-picture-container:hover .profile-picture-overlay {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

/* Scrollable Content Area */
.profile-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--background-primary);
}

/* Profile Sections */
.profile-section {
    margin-bottom: 32px;
}

.profile-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--label-primary);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--quaternary-gray);
}

.profile-field {
    margin-bottom: 20px;
    padding: 16px 0;
    border-bottom: 1px solid var(--quaternary-gray);
}

.profile-field:last-child {
    border-bottom: none;
}

.profile-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--label-secondary);
    margin-bottom: 8px;
    display: block;
}

.profile-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    min-height: 36px; /* Prevent layout shift */
}

.profile-edit-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 36px; /* Reserve space to prevent layout shift */
}

.profile-value {
    font-size: 16px;
    font-weight: 500;
    color: var(--label-primary);
    flex: 1;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.profile-value-optional {
    color: var(--label-secondary);
    font-style: italic;
}

.profile-input {
    font-size: 16px;
    font-weight: 500;
    color: var(--label-primary);
    padding: 12px 16px;
    background: var(--background-secondary);
    border: 2px solid var(--quaternary-gray);
    border-radius: 8px;
    flex: 1;
    transition: all 0.2s ease;
}

.profile-input:focus {
    outline: none;
    border-color: var(--habitiq-blue);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.profile-edit-btn {
    background: var(--background-secondary);
    border: 2px solid var(--quaternary-gray);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--label-secondary);
}

.profile-edit-btn:hover {
    border-color: var(--habitiq-blue);
    color: var(--habitiq-blue);
    background: rgba(37, 99, 235, 0.05);
}

.profile-edit-btn:active {
    transform: scale(0.95);
}

.profile-save-btn,
.profile-cancel-btn {
    background: var(--background-secondary);
    border: 2px solid var(--quaternary-gray);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--label-secondary);
}

.profile-save-btn {
    border-color: var(--habitiq-blue);
    color: var(--habitiq-blue);
    background: rgba(37, 99, 235, 0.05);
}

.profile-save-btn:hover {
    background: var(--habitiq-blue);
    color: white;
}

.profile-cancel-btn {
    border-color: var(--red);
    color: var(--red);
    background: rgba(239, 68, 68, 0.05);
}

.profile-cancel-btn:hover {
    background: var(--red);
    color: white;
}

.profile-save-btn:active,
.profile-cancel-btn:active {
    transform: scale(0.95);
}

/* Settings Section */
.profile-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--quaternary-gray);
    transition: background-color 0.15s ease;
    border-radius: 0;
    position: relative;
    z-index: 1;
}

.profile-setting:last-child {
    border-bottom: none;
}

.profile-setting:hover {
    background-color: rgba(0, 0, 0, 0.015);
    border-radius: 8px;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--label-primary);
}

.setting-description {
    font-size: 14px;
    color: var(--label-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 34px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    will-change: background-color, box-shadow;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    will-change: transform;
}

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

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

.toggle-slider:hover {
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.08);
}

/* Prevent flash on focus/active states */
.toggle-switch input:focus + .toggle-slider,
.toggle-switch input:active + .toggle-slider {
    outline: none;
    box-shadow: none;
}

/* Ensure smooth transitions without browser repaints */
.toggle-switch {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.toggle-switch *,
.toggle-switch *:before,
.toggle-switch *:after {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
}
}

/* Action Buttons */
.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
    padding: 0;
}

.btn-sign-out {
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
}

.btn-sign-out:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-sign-out:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
}

.btn-delete-account {
    background: transparent;
    color: #dc2626;
    border: 2px solid #dc2626;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-delete-account:hover {
    background: #dc2626;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-delete-account:active {
    transform: translateY(0);
}

/* Footer */
.profile-footer {
    text-align: center;
    padding: 24px 0 0;
    border-top: 1px solid var(--quaternary-gray);
    margin-top: 24px;
}

.profile-version {
    font-size: 14px;
    color: var(--label-secondary);
    margin: 0;
    line-height: 1.4;
}

/* Delete Account Modal */
.delete-account-modal {
    background: white;
    border-radius: 12px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(220, 38, 38, 0.3);
    border: 2px solid rgba(220, 38, 38, 0.1);
}

.delete-warning {
    padding: 0 4px;
}

.delete-warning p {
    margin: 0 0 16px 0;
    line-height: 1.5;
    color: var(--label-primary);
}

.delete-warning p:first-child {
    font-size: 16px;
    color: #dc2626;
    font-weight: 600;
}

.delete-list {
    margin: 16px 0;
    padding-left: 20px;
    color: var(--label-secondary);
}

.delete-list li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.delete-account-actions {
    gap: 12px;
    margin-top: 24px;
}

.btn-delete-confirm {
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    min-width: 160px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-delete-confirm:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.btn-delete-confirm:active {
    transform: translateY(0);
}

.btn-delete-confirm:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.profile-info {
    margin: 20px 0;
    padding: 16px 0;
    border-top: 1px solid #eee;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.profile-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.profile-value {
    font-size: 14px;
    color: #333;
    font-weight: 600;
}

/* Authenticated profile icon styling */
.profile-icon.authenticated {
    background: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(0, 0, 0, 0.15);
}

/* Checkbox styling for email opt-in */
.checkbox-group {
    margin: 16px 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    position: relative;
    padding-left: 28px;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 2px;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.checkbox-label:hover input ~ .checkmark {
    border-color: #2563EB;
}

.checkbox-label input:checked ~ .checkmark {
    background-color: #2563EB;
    border-color: #2563EB;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-label input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-label .checkmark:after {
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.btn-spinner {
    display: inline-block;
    margin-left: 8px;
}

.user-profile {
    text-align: center;
    padding: 20px 0;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 16px;
    border: 3px solid #D1FAE5;
}

.user-profile h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 4px 0;
}

.user-status {
    font-size: 14px;
    color: var(--label-secondary);
    margin: 0;
}

/* Profile icon authenticated state */
.profile-icon.authenticated {
    background: transparent !important;
    border: 2px solid rgba(0, 0, 0, 0.15) !important;
}

.profile-icon.authenticated::before {
    background: white !important;
    filter: none !important;
}

/* Mobile responsive modal */
@media (max-width: 480px) {
    .sign-in-modal {
        width: 95%;
        margin: 20px;
    }
    
    .modal-header {
        padding: 20px 20px 18px 20px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-title {
        font-size: 20px;
    }
    
    .modal-message {
        font-size: 15px;
    }
    
    .btn-primary, .btn-secondary {
        padding: 14px 20px;
        font-size: 15px;
    }
}

/* Image Cropper Modal Styles */
.cropper-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cropper-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.cropper-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    width: 500px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.cropper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #E5E7EB;
}

.cropper-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.cropper-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6B7280;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.cropper-close-btn:hover {
    color: #374151;
}

.cropper-container {
    padding: 20px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 400px;
    background: #f8f9fa;
    touch-action: none;
    overflow: hidden;
}

/* Easy Crop Container */
.easy-crop-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 350px;
    touch-action: none;
    overflow: hidden;
    border-radius: 8px;
}

.cropper-instructions {
    padding: 12px 24px;
    text-align: center;
    background: #F3F4F6;
    border-bottom: 1px solid #E5E7EB;
}

.cropper-instructions p {
    margin: 0;
    font-size: 14px;
    color: #6B7280;
    font-style: italic;
    line-height: 1.4;
}

.cropper-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-top: 1px solid #E5E7EB;
}

.cropper-preview-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cropper-preview-section span {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

.cropper-live-preview {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--habitiq-blue);
    overflow: hidden;
    background: #f0f0f0;
    position: relative;
}

.cropper-live-preview canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.cropper-buttons {
    display: flex;
    gap: 12px;
}

.cropper-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cropper-btn-cancel {
    background: #F3F4F6;
    color: #374151;
}

.cropper-btn-cancel:hover {
    background: #E5E7EB;
}

.cropper-btn-save {
    background: var(--habitiq-blue);
    color: white;
}

.cropper-btn-save:hover {
    background: var(--habitiq-blue-dark);
}

/* Mobile responsive cropper */
@media (max-width: 640px) {
    .cropper-modal-content {
        width: 95vw;
        height: 95vh;
    }
    
    .cropper-container {
        padding: 16px;
        min-height: 300px;
    }
    
    .easy-crop-container {
        min-height: 250px;
    }
    
    .cropper-header {
        padding: 16px 20px;
    }
    
    .cropper-controls {
        padding: 16px 20px;
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .cropper-preview-section {
        justify-content: center;
    }
    
    .cropper-buttons {
        justify-content: center;
    }
}

/* Smart Feedback Section Styles */
.smart-feedback-section {
    margin-top: var(--spacing-lg);
}

.smart-feedback-container {
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.3);
}

.smart-feedback-title {
    font-size: var(--font-size-title);
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 var(--spacing-md) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.smart-feedback-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(37, 99, 235, 0.3);
    border-top: 3px solid var(--habitiq-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.smart-feedback-loading p {
    font-size: var(--font-size-body);
    color: var(--label-secondary);
    margin: 0;
}

.smart-feedback-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.smart-feedback-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.8);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(198, 198, 200, 0.2);
}

.smart-feedback-icon {
    font-size: 16px;
    color: var(--habitiq-blue);
    flex-shrink: 0;
    margin-top: 2px;
    font-weight: 600;
}

.smart-feedback-text {
    font-size: var(--font-size-body);
    color: var(--label-primary);
    line-height: 1.5;
    flex: 1;
}

.smart-feedback-no-data {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.smart-feedback-no-data p {
    font-size: var(--font-size-body);
    color: var(--label-secondary);
    line-height: 1.5;
    margin: 0 0 var(--spacing-sm) 0;
}

.smart-feedback-suggestion {
    font-style: italic;
    color: var(--label-tertiary) !important;
    font-size: var(--font-size-caption) !important;
}

.smart-feedback-error {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.smart-feedback-error p {
    font-size: var(--font-size-body);
    color: #ef4444;
    line-height: 1.5;
    margin: 0;
}

/* Dark mode support for Smart Feedback */
@media (prefers-color-scheme: dark) {
    .smart-feedback-container {
        background: rgba(28, 28, 30, 0.8);
        border-color: rgba(56, 56, 58, 0.3);
    }
    
    .smart-feedback-item {
        background: rgba(28, 28, 30, 0.6);
        border-color: rgba(56, 56, 58, 0.2);
    }
    
    .loading-spinner {
        border-color: rgba(37, 99, 235, 0.3);
        border-top-color: var(--habitiq-blue);
    }
}

/* ---- DAILY (Today's Recap) ---- */
.di-card { padding: 12px; border-radius: 16px; background: #fff; }
.di-chart { 
    height: 100px; 
    display: flex; 
    align-items: flex-end; 
    justify-content: center;
    gap: 10px; 
    padding: 12px; 
    border-radius: 12px; 
    background: #f7f9ff; 
}
.di-col { display: flex; flex-direction: column; align-items: center; }
.di-bar {
  width: 24px; border-radius: 10px;
  background: linear-gradient(180deg,#3b82f6 0%,#2563eb 100%);
  box-shadow: 0 6px 16px rgba(37,99,235,.22);
  transition: height .2s ease;
}
.di-day {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

/* ---- WEEKLY INSIGHTS (AI-Powered) ---- */
.wi-card { 
    padding: 16px; 
    border-radius: 16px; 
    background: #fff; 
    margin-bottom: 16px;
}

.wi-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wi-chart { 
    height: 120px; 
    display: flex; 
    align-items: flex-end; 
    justify-content: center;
    gap: 12px; 
    padding: 16px 12px 12px 12px; 
    margin-bottom: 16px;
}

.wi-col { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}

.wi-bar { 
    width: 32px; 
    border-radius: 8px;
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    transition: all .2s ease;
    min-height: 8px;
}

.wi-bar.is-today {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 12px;
}

.wi-day {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

/* AI Insights Content */
.weekly-insights-container {
    margin-top: 0;
}

/* Weekly Insights Widget - Bar Chart */
.weekly-insights-widget {
    padding: 20px;
}

.weekly-bars-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 120px;
    margin-bottom: 20px;
    padding: 0 10px;
}

.weekly-bar-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 100%;
    margin: 0 2px;
}

.weekly-bar {
    width: 100%;
    max-width: 30px;
    background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    position: relative;
}

.weekly-bar.today {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.weekly-summary-text {
    text-align: center;
    font-size: 14px;
    line-height: 1.6;
}

.summary-main {
    color: var(--label-primary);
    margin-bottom: 8px;
}

.summary-main strong {
    font-weight: 600;
    color: #2563eb;
}

.summary-trend {
    color: var(--label-secondary);
    font-size: 13px;
}

.trend-symbol {
    font-weight: 600;
    margin-right: 4px;
    font-size: 16px;
}

/* Weekly Insights Countdown */
.insights-countdown {
    padding: 30px 20px;
    text-align: center;
}

.countdown-message h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 20px 0;
}

.countdown-days {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}

.days-number {
    font-size: 48px;
    font-weight: 700;
    color: #2563eb;
    line-height: 1;
}

.days-label {
    font-size: 16px;
    color: var(--label-secondary);
    margin-top: 8px;
}

.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    margin: 20px auto;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    color: var(--label-secondary);
    margin-top: 10px;
}

/* Weekly Insights Report - Matching Design */
.weekly-insights-report {
    padding: 25px;
    background: white;
    border-radius: 16px;
}

.report-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.brain-icon {
    font-size: 28px;
}

.report-title h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--label-primary);
    margin: 0;
}

/* Consistency Section */
.consistency-section {
    margin-bottom: 30px;
}

.consistency-section h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 15px 0;
}

.consistency-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    color: var(--label-primary);
}

.stat-icon {
    font-size: 20px;
    width: 28px;
    flex-shrink: 0;
}

.stat-text {
    flex: 1;
}

/* Habits Section */
.habits-section,
.growth-section {
    margin-bottom: 30px;
}

.habits-section h4,
.growth-section h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 15px 0;
}

.habits-list,
.growth-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.habit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: var(--label-primary);
    padding: 8px 0;
}

.growth-row {
    display: block;
    font-size: 16px;
    color: var(--label-primary);
    padding: 8px 0;
}

.growth-row > span:not(.habit-tip) {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.habit-emoji {
    font-size: 20px;
    width: 28px;
    flex-shrink: 0;
}

.habit-name {
    flex: 1;
    font-weight: 500;
    color: var(--label-primary);
}

.habit-percent {
    color: var(--label-secondary);
    margin-left: auto;
    font-weight: 500;
    white-space: nowrap;
}

.habit-tip {
    font-size: 13px;
    color: var(--label-tertiary);
    font-style: italic;
    margin-top: 4px;
    margin-left: 56px;
    display: block;
    line-height: 1.4;
}

.no-habits {
    font-size: 15px;
    color: var(--label-secondary);
    font-style: italic;
}

/* Weekly Chart Section */
.weekly-chart-section {
    margin: 30px 0;
    padding: 20px 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.weekly-chart-section .weekly-bars-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 120px;
    gap: 8px;
}

.weekly-bar-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.weekly-bar-column .weekly-bar {
    width: 100%;
    max-width: 30px;
    background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
}

.weekly-bar-column .weekly-bar.today {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.weekly-bar-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--label-secondary);
    text-align: center;
}

/* Insights Countdown Styles */
.insights-countdown {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 16px;
    margin: 20px 0;
}

.countdown-icon {
    font-size: 48px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.countdown-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--label-primary);
    margin: 0 0 20px 0;
}

.countdown-days {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.days-number {
    font-size: 48px;
    font-weight: 700;
    color: #2563eb;
    line-height: 1;
}

.days-label {
    font-size: 18px;
    font-weight: 500;
    color: var(--label-secondary);
}

.countdown-number {
    font-size: 20px;
    font-weight: 600;
    color: #2563eb;
    margin: 15px 0;
}

.countdown-phrase {
    font-size: 18px;
    font-weight: 600;
    color: var(--label-primary);
    margin: 15px 0;
}

.countdown-message {
    font-size: 16px;
    color: var(--label-secondary);
    line-height: 1.5;
    max-width: 400px;
    margin: 0 auto;
}

.countdown-info {
    font-size: 14px;
    color: var(--label-tertiary);
    margin-top: 15px;
    line-height: 1.5;
}

.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 4px;
    margin: 20px auto;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    color: var(--label-secondary);
    margin: 10px 0;
}

/* Tips Section */
.tips-section {
    margin-top: 30px;
    padding: 20px;
    background: #f0f9ff;
    border-radius: 12px;
}

.tips-section h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--label-primary);
    margin: 0 0 15px 0;
}

.tips-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tip-item {
    font-size: 15px;
    color: var(--label-primary);
    line-height: 1.5;
    padding-left: 5px;
}

.ai-insights-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    color: #6b7280;
    font-size: 14px;
}

.ai-insights-loading .loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-insights-content {
    /* No extra styling needed - content comes pre-formatted from AI */
}

.ai-insights-error {
    padding: 12px;
    background: #fef2f2;
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
    border: 1px solid #fecaca;
}

/* Weekly Insights Text Styling */
.wi-insight-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
}

.wi-insight-line .emoji {
    flex-shrink: 0;
    font-size: 16px;
}

.wi-insight-line .text {
    color: #374151;
    font-weight: 500;
}

.wi-insight-line.main .text {
    font-weight: 600;
    color: #1f2937;
}

/* ===== PROFILE SLIDE-OUT PANEL ===== */
.pf-drawer{position:fixed;inset:0;z-index:60;display:none}
.pf-drawer[aria-hidden="false"]{display:block}
.pf-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.35);backdrop-filter:saturate(120%) blur(2px)}
.pf-panel{position:absolute;right:0;top:0;height:100dvh;width:min(92vw,420px);background:#fff;border-left:1px solid #eef1f5;box-shadow:-12px 0 40px rgba(0,0,0,.08);display:flex;flex-direction:column}
.pf-header{display:flex;justify-content:space-between;align-items:center;padding:16px 18px;border-bottom:1px solid #eef1f5}
.pf-body{padding:16px 18px;overflow:auto;-webkit-overflow-scrolling:touch}
.pf-footer{padding:12px 18px;border-top:1px solid #eef1f5;display:flex;gap:8px}
.pf-avatar{width:88px;height:88px;border-radius:999px;object-fit:cover;border:2px solid #e6ebf5}
.pf-avatar-wrap{display:flex;align-items:center;gap:12px;margin-bottom:12px}
.pf-row{display:flex;align-items:center;gap:10px}
.pf-name-section{margin-bottom:20px}
.pf-input{width:100%;padding:12px;border:1px solid #d1d5db;border-radius:8px;font-size:16px;background:white;margin-bottom:12px;box-sizing:border-box}
.pf-input:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,0.1)}
.pf-name-buttons{display:flex;flex-direction:column;gap:8px;align-items:flex-start}
.pf-save-btn{background:#2563eb;color:white;padding:8px 24px;border:none;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer;transition:background 200ms}
.pf-save-btn:hover{background:#1d4ed8}
.pf-cancel-btn{background:#f3f4f6;color:#374151;padding:8px 24px;border:none;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer;transition:background 200ms}
.pf-cancel-btn:hover{background:#e5e7eb}

/* CRITICAL: Ensure buttons in edit mode are full width and stacked vertically */
.pf-name.is-editing .pf-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100% !important;
}

.pf-name.is-editing .pf-actions button {
    width: 100% !important;
    text-align: center !important;
    display: block !important;
}

/* PROFILE MODAL: Fix Save/Cancel buttons to display inline */
.profile-edit-buttons {
    display: inline-flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    margin-left: auto;
}

.profile-edit-buttons .profile-save-btn,
.profile-edit-buttons .profile-cancel-btn {
    width: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms;
    background: transparent;
    border: none;
}

.profile-edit-buttons .profile-save-btn {
    color: #22c55e !important;
}

.profile-edit-buttons .profile-cancel-btn {
    color: #ef4444 !important;
}

.profile-edit-buttons button svg {
    width: 20px;
    height: 20px;
}

/* Additional focus behavior improvements */
.pf-input:focus {
    transform: translateZ(0);
    position: relative;
    z-index: 10;
}

/* Profile drawer button styles */
.pf-btn {
    background: #f3f4f6;
    color: #374151;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 200ms ease;
    text-align: center;
}

.pf-btn:hover {
    background: #e5e7eb;
}

.pf-btn.pf-primary {
    background: #2563eb;
    color: white;
}

.pf-btn.pf-primary:hover {
    background: #1d4ed8;
}

.pf-btn.pf-ghost {
    background: transparent;
    color: #dc2626;
    border: 1px solid #dc2626;
}

.pf-btn.pf-ghost:hover {
    background: #dc2626;
    color: white;
}

.pf-link {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
    padding: 0;
}

.pf-link:hover {
    color: #1d4ed8;
}

.pf-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pf-meta {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.pf-meta > div {
    padding: 4px 0;
    font-size: 14px;
    color: #6b7280;
}

.pf-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 200ms;
}

.pf-close:hover {
    background: #f3f4f6;
}

/* Enhanced availability messages */
.ai-insights-availability {
    text-align: center;
    padding: 32px 24px;
    color: #374151;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin: 20px 0;
}

.ai-insights-availability h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 16px 0;
}

.ai-insights-availability ul {
    text-align: left;
    margin: 16px 0;
    padding-left: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.ai-insights-availability li {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.5;
}

.ai-insights-availability p {
    margin: 12px 0;
    font-size: 14px;
    line-height: 1.5;
}

.ai-insights-availability .days-progress {
    background: #2563eb;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    display: inline-block;
    margin-top: 16px;
}

/* no horizontal scroll anywhere in drawer */
.pf-panel      { overflow: hidden; }
.pf-body       { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.pf-name       { display: grid; gap: 8px; }
.pf-actions    { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
/* edit state toggles */
.pf-name.is-editing #pf-name-view   { display: none; }
.pf-name.is-editing #pf-name-input  { display: block; }
.pf-name.is-editing .pf-actions     { display: grid; }
.pf-name.is-editing #pf-edit-name   { display: none; }
.pf-link { color:#2563eb; background:none; border:0; padding:6px 0; text-align:left; }
.pf-input{ width:100%; }
.pf-btn{padding:10px 12px;border-radius:10px;border:1px solid #e6ebf5;background:#f8fafc}
.pf-primary{background:#2563eb;color:#fff;border-color:#2563eb}
.pf-ghost{background:#fff}
.pf-link{background:transparent;border:none;color:#2563eb;padding:6px 8px}
.pf-meta{margin-top:12px;color:#6b7280;font-size:14px}
.pf-close{background:transparent;border:none;font-size:18px;line-height:1;padding:6px 8px}
