/* ============================================
   Habit Tracker - Custom Styles
   Dark + Light theme with glassmorphism design
   ============================================ */

/* ── CSS Variables (Dark - Default) ───────── */
:root {
    --bg-primary: #0f0a1e;
    --bg-secondary: #1a1333;
    --bg-card: rgba(30, 22, 56, 0.7);
    --bg-card-hover: rgba(40, 30, 70, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-active: rgba(99, 102, 241, 0.4);

    --text-primary: #f1f0f5;
    --text-secondary: #9a93b8;
    --text-muted: #645e80;

    --accent-indigo: #6366f1;
    --accent-violet: #8b5cf6;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;

    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-success: linear-gradient(135deg, #22c55e, #10b981);
    --gradient-card: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.05));

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(99,102,241,0.3);

    --nav-height: 72px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Light Theme Override ─────────────────── */
[data-theme="light"] {
    --bg-primary: #f5f3ff;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(99, 102, 241, 0.04);
    --border-glass: rgba(99, 102, 241, 0.12);
    --border-active: rgba(99, 102, 241, 0.3);

    --text-primary: #1e1b4b;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 16px rgba(99,102,241,0.15);
}

[data-theme="light"] body::before {
    background: radial-gradient(circle, rgba(99,102,241,0.06) 0%, transparent 70%);
}

[data-theme="light"] body::after {
    background: radial-gradient(circle, rgba(139,92,246,0.04) 0%, transparent 70%);
}

[data-theme="light"] .bottom-nav {
    background: rgba(255,255,255,0.92);
    border-top-color: rgba(99,102,241,0.1);
}

[data-theme="light"] .modal {
    background: #ffffff;
    border-color: rgba(99,102,241,0.1);
}

[data-theme="light"] .modal-handle {
    background: #d1d5db;
}

[data-theme="light"] .login-screen {
    background: var(--bg-primary);
}

[data-theme="light"] .app-header {
    background: linear-gradient(180deg, var(--bg-primary) 60%, transparent);
}

[data-theme="light"] select.form-input option {
    background: #ffffff;
    color: #1e1b4b;
}

[data-theme="light"] .user-dropdown {
    background: #ffffff;
    border-color: rgba(99,102,241,0.1);
}

/* ── Base Reset & Typography ───────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Background Ambient Glow ───────────────── */
body::before {
    content: '';
    position: fixed;
    top: -30%;
    left: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    right: -20%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(139,92,246,0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── App Container ─────────────────────────── */
#app {
    position: relative;
    z-index: 1;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    min-height: 100vh;
    min-height: 100dvh;
}

@media (min-width: 768px) {
    #app {
        max-width: 640px;
        padding: 0 24px;
        padding-bottom: calc(var(--nav-height) + 24px);
    }
}

@media (min-width: 1024px) {
    #app {
        max-width: 800px;
    }
}

/* ── Header ────────────────────────────────── */
.app-header {
    padding: 20px 0 8px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(180deg, var(--bg-primary) 60%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header .date-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Glass Cards ───────────────────────────── */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

/* ── Habit Card ────────────────────────────── */
.habit-card {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
    animation: slideUp 0.4s ease-out both;
}

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

.habit-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.habit-card:hover .habit-icon {
    transform: scale(1.1);
}

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

.habit-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.habit-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Custom Checkbox ───────────────────────── */
.habit-checkbox {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.habit-checkbox.checked {
    border-color: transparent;
    background: var(--gradient-success);
    animation: checkPulse 0.4s ease;
}

.habit-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 1rem;
    font-weight: 700;
    animation: checkmarkPop 0.3s ease 0.1s both;
}

.habit-card.completed .habit-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ── Progress Ring ─────────────────────────── */
.progress-ring-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    margin-bottom: 16px;
}

.progress-ring {
    position: relative;
    width: 100px;
    height: 100px;
}

.progress-ring svg {
    transform: rotate(-90deg);
}

.progress-ring .ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.06);
    stroke-width: 8;
}

.progress-ring .ring-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.progress-percent {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-stats {
    text-align: left;
}

.progress-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.progress-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Bottom Navigation ─────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    padding-bottom: var(--safe-bottom);
    background: rgba(15, 10, 30, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    max-width: 480px;
    padding: 0 16px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 18px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-muted);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.nav-item.active {
    color: var(--accent-indigo);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 0 0 4px 4px;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.nav-item span {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── FAB (Floating Action Button) ──────────── */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    border: none;
    color: white;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 90;
    -webkit-tap-highlight-color: transparent;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99,102,241,0.5);
}

.fab:active {
    transform: scale(0.95);
}

/* ── Modal ─────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px 20px;
    padding-bottom: calc(24px + var(--safe-bottom));
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 768px) {
    .modal-overlay {
        align-items: center;
    }
    .modal {
        border-radius: var(--radius-xl);
        max-width: 500px;
        max-height: 85vh;
        padding-bottom: 24px;
    }
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--text-muted);
    border-radius: var(--radius-full);
    margin: 0 auto 16px;
}

@media (min-width: 768px) {
    .modal-handle {
        display: none;
    }
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* ── Form Inputs ───────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

select.form-input {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239a93b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 6.646a.5.5 0 0 1 .708 0L8 9.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select.form-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Frequency Day Picker ──────────────────── */
.day-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.day-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.day-btn.selected {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

/* ── Icon & Color Picker ───────────────────── */
.picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.picker-item {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    background: var(--bg-glass);
}

.picker-item.selected {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.3);
    transform: scale(1.1);
}

.color-item {
    border-radius: var(--radius-full);
}

/* ── Buttons ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.btn-primary:hover {
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transform: translateY(-1px);
}

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

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover {
    background: rgba(239,68,68,0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

/* ── Manage Habit Items ────────────────────── */
.manage-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    animation: slideUp 0.4s ease-out both;
}

.manage-item .habit-icon {
    width: 40px;
    height: 40px;
}

.manage-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.manage-actions button {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-glass);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.manage-actions button:hover {
    background: rgba(99,102,241,0.15);
    color: var(--accent-indigo);
}

.manage-actions button.delete-btn:hover {
    background: rgba(239,68,68,0.15);
    color: var(--accent-red);
}

/* ── Streaks ───────────────────────────────── */
.streaks-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.streak-card {
    padding: 14px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    animation: slideUp 0.4s ease-out both;
}

.streak-icon {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.streak-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.streak-values {
    display: flex;
    gap: 12px;
}

.streak-current .streak-num {
    font-size: 1.6rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.streak-max .streak-num {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-muted);
    line-height: 1;
}

.streak-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* ── Charts ────────────────────────────────── */
.chart-section {
    margin-bottom: 24px;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 16px;
    position: relative;
}

.chart-container canvas {
    max-height: 220px;
}

/* ── Section Titles ────────────────────────── */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title .title-icon {
    font-size: 1.1rem;
}

/* ── Heatmap ───────────────────────────────── */
.heatmap-container {
    overflow-x: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
}

.heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 14px);
    grid-auto-flow: column;
    gap: 3px;
    width: max-content;
    min-width: 100%;
}

.heatmap-cell {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: rgba(255,255,255,0.04);
    transition: all 0.2s ease;
}

.heatmap-cell:hover {
    outline: 1px solid var(--accent-indigo);
    transform: scale(1.4);
    z-index: 1;
}

.heatmap-cell[data-level="1"] { background: rgba(99,102,241,0.2); }
.heatmap-cell[data-level="2"] { background: rgba(99,102,241,0.4); }
.heatmap-cell[data-level="3"] { background: rgba(99,102,241,0.6); }
.heatmap-cell[data-level="4"] { background: rgba(99,102,241,0.85); }

.heatmap-months {
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
    margin-top: 8px;
}

.heatmap-months span {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.6rem;
    color: var(--text-muted);
}

.heatmap-legend .heatmap-cell {
    width: 12px;
    height: 12px;
}

/* ── Year Selector ─────────────────────────── */
.year-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.year-selector button {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.year-selector button:hover {
    background: var(--accent-indigo);
    color: white;
}

.year-selector .year-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── View Transitions ──────────────────────── */
.view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: block;
}

/* ── Empty States ──────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    animation: fadeIn 0.5s ease;
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state .empty-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ── Toast Notifications ───────────────────── */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
    width: calc(100% - 32px);
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    animation: toastIn 0.4s ease-out;
    box-shadow: var(--shadow-lg);
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }

/* ── Skeleton Loader ───────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.06) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ── Animations ────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

@keyframes checkPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

@keyframes checkmarkPop {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Frequency Badge ───────────────────────── */
.freq-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ── Tooltip ───────────────────────────────── */
.heatmap-tooltip {
    position: fixed;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 400;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.heatmap-tooltip.visible {
    opacity: 1;
}

/* ── Date Navigation ───────────────────────── */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.date-nav button {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-nav button:hover {
    background: var(--accent-indigo);
    color: white;
    border-color: transparent;
}

.date-nav .current-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 160px;
    text-align: center;
}

.date-nav .today-btn {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto;
}

/* ── Login Screen ──────────────────────────── */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-primary);
}

.login-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
    animation: fadeIn 0.6s ease;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    border-radius: var(--radius-xl);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    font-weight: 800;
    box-shadow: var(--shadow-glow);
}

.login-title {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.login-error {
    color: var(--accent-red);
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 20px;
    margin-bottom: 8px;
    text-align: center;
}

.login-card .form-group {
    text-align: left;
}

.login-card .btn-primary {
    margin-top: 8px;
}

/* ── User Menu (Header) ───────────────────── */
.user-menu {
    position: relative;
}

.user-avatar {
    background: var(--gradient-primary);
    border: none;
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-avatar:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

/* ── User Dropdown ─────────────────────────── */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 60;
    overflow: hidden;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-glass);
}

.dropdown-username {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dropdown-role {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-glass);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.dropdown-logout {
    color: var(--accent-red);
}

.dropdown-logout:hover {
    background: rgba(239,68,68,0.1);
    color: var(--accent-red);
}

/* ── Theme Toggle ─────────────────────────── */
.theme-toggle {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: var(--radius-full);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    transform: rotate(20deg);
    box-shadow: var(--shadow-glow);
}

/* ── Notification Settings (Dropdown) ─────── */
.dropdown-section {
    padding: 10px 16px;
}

.dropdown-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.notif-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

input:checked + .toggle-slider {
    background: var(--gradient-primary);
    border-color: var(--accent-indigo);
}

input:checked + .toggle-slider::after {
    left: 18px;
    background: white;
}

.notif-time-input {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.75rem;
    padding: 4px 8px;
    width: 80px;
    text-align: center;
}

.notif-time-input::-webkit-calendar-picker-indicator {
    filter: invert(0.5);
}

[data-theme="light"] .notif-time-input::-webkit-calendar-picker-indicator {
    filter: none;
}

/* ── Reorder Arrows ───────────────────────── */
.reorder-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-right: 6px;
}

.reorder-btn {
    background: none;
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-size: 0.55rem;
    line-height: 1;
    padding: 4px 5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.reorder-btn:hover:not(.disabled) {
    background: var(--bg-glass);
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
}

.reorder-btn.disabled {
    opacity: 0.2;
    cursor: default;
}

/* ── Habit Card - Main + Note ─────────────── */
.habit-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 0;
    width: 100%;
}

.habit-note-preview {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.habit-note-bar {
    display: flex;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-glass);
}

.note-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 0;
    transition: color 0.2s ease;
}

.note-btn:hover {
    color: var(--accent-indigo);
}

/* ── Export Bar ────────────────────────────── */
.export-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.export-btn {
    font-size: 0.8rem !important;
    padding: 8px 16px !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: var(--radius-full) !important;
    transition: all 0.2s ease;
}

.export-btn:hover {
    border-color: var(--accent-indigo) !important;
    box-shadow: var(--shadow-glow);
}

/* ── PWA Install Prompt ───────────────────── */
.install-prompt {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px + var(--safe-bottom));
    left: 16px;
    right: 16px;
    z-index: 40;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-active);
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
    .install-prompt {
        width: 360px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
    }
}

.install-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.install-icon {
    font-size: 2rem;
    line-height: indulgence;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.install-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.install-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.install-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.install-actions button {
    flex: 1;
    padding: 8px !important;
    font-size: 0.85rem !important;
}
