:root {
    --bg: #fafaf9;
    --ink: #1c1917;
    --muted: #78716c;
    --surface: #ffffff;
    --surface-soft: #fafaf9;
    --surface-border: #e7e5e4;
    --accent: #8b5cf6;
    --accent-2: #22c55e;
    --accent-3: #0ea5e9;
    --accent-purple: #a855f7;
    --shadow-soft: 0 20px 40px rgba(0, 0, 0, 0.06);
    --shadow-strong: 0 30px 60px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 40px 80px rgba(0, 0, 0, 0.12);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

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

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-weight: 400;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 20%, rgba(249, 115, 22, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 10%, rgba(168, 85, 247, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 50% 90%, rgba(34, 197, 94, 0.05) 0%, transparent 40%),
        linear-gradient(180deg, #fafaf9 0%, #f5f5f4 100%);
    min-height: 100vh;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
    font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
    letter-spacing: -0.025em;
    font-weight: 700;
    line-height: 1.2;
}

.app-shell {
    min-height: 100vh;
    padding: 28px 32px 64px;
    max-width: 1240px;
    margin: 0 auto;
}

.hidden {
    display: none;
}

.auth-view {
    min-height: calc(100vh - 140px);
    display: flex;
    align-items: center;
}

.auth-view .auth-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 32px;
    width: 100%;
}

.auth-hero {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%),
        linear-gradient(140deg, #fff5ed 0%, #ffedd5 45%, #fef3c7 100%);
    padding: 48px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(249, 115, 22, 0.1);
    display: grid;
    gap: 24px;
    backdrop-filter: blur(10px);
    animation: fadeInUp 0.6s ease-out;
}

.brand-mark,
.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.brand-name {
    font-size: 18px;
}

.brand-badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #8b5cf6;
    display: grid;
    place-items: center;
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.25);
}

.brand-core {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffe6d1;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6);
}

.auth-hero h1 {
    font-size: 48px;
    line-height: 1.1;
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 50%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.auth-hero .lead {
    font-size: 17px;
    line-height: 1.7;
    color: #57534e;
    font-weight: 500;
}

.hero-highlights {
    display: grid;
    gap: 12px;
}

.highlight-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.highlight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08);
    border-color: rgba(249, 115, 22, 0.2);
}

.highlight-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 700;
}

.highlight-card p {
    font-size: 13px;
    color: var(--muted);
}

.ghost-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    width: fit-content;
}

.auth-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    gap: 24px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    animation: fadeInUp 0.6s ease-out 0.2s backwards;
}

.auth-panel-header h2 {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #1c1917 0%, #57534e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-panel-header p {
    color: var(--muted);
    line-height: 1.6;
}

.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.oauth-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    width: 100%;
}

.oauth-note {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
}

label span {
    font-weight: 600;
    color: #554c44;
}

input,
select,
textarea {
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    background: linear-gradient(135deg, #fafaf9 0%, #ffffff 100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--ink);
}

input:hover,
select:hover,
textarea:hover {
    border-color: rgba(249, 115, 22, 0.3);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(249, 115, 22, 0.8);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1), 0 8px 20px rgba(249, 115, 22, 0.15);
    background: #ffffff;
    transform: translateY(-1px);
}

input::placeholder,
textarea::placeholder {
    color: #a8a29e;
}

button {
    font-family: inherit;
}

.primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 50%, #8b5cf6 100%);
    background-size: 200% 100%;
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 14px 28px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 24px rgba(249, 115, 22, 0.3);
    position: relative;
    overflow: hidden;
}

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

.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(249, 115, 22, 0.4);
    background-position: 100% 0;
}

.primary:hover::before {
    left: 100%;
}

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

.ghost {
    background: linear-gradient(135deg, #ffffff 0%, #fafaf9 100%);
    border: 2px solid rgba(0, 0, 0, 0.08);
    color: var(--ink);
    padding: 12px 20px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ghost:hover {
    border-color: rgba(249, 115, 22, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    background: #ffffff;
}

.ghost:active {
    transform: translateY(0);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.icon-btn .material-symbols-outlined {
    font-size: 18px;
}

.form-message {
    min-height: 20px;
    font-size: 14px;
    color: #b91c1c;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 18px 28px;
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    gap: 20px;
    position: sticky;
    top: 20px;
    z-index: 50;
    animation: fadeInUp 0.5s ease-out;
}

.app-nav {
    display: inline-flex;
    gap: 4px;
    background: linear-gradient(135deg, #f5f5f4 0%, #e7e5e4 100%);
    padding: 6px;
    border-radius: 999px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.nav-btn {
    border: none;
    background: transparent;
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600;
    color: #78716c;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.nav-btn:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.5);
}

.nav-btn.active {
    background: linear-gradient(135deg, #ffffff 0%, #fafaf9 100%);
    color: var(--ink);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
    border-radius: 999px;
}

.nav-icon {
    font-size: 18px;
}

.user-actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--muted);
}

.user-greeting {
    font-weight: 600;
}

.app-main {
    display: grid;
    gap: 24px;
    margin-top: 22px;
}

.panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: none;
    animation: fadeInUp 0.6s ease-out;
}

.panel.active {
    display: block;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.panel-header h2 {
    font-size: 28px;
}

.panel-subtitle {
    color: var(--muted);
    margin-top: 6px;
}

.panel-title {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 12px;
}

.panel-block {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
    padding: 20px;
    box-shadow: 0 14px 26px rgba(32, 24, 19, 0.06);
}

.profile-grid {
    display: grid;
}

.profile-grid .form-card {
    max-width: 420px;
}

.header-actions {
    display: inline-flex;
    gap: 10px;
}

.inline-controls {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    --accent-color: #8b5cf6;
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    display: grid;
    gap: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-color);
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-color) 70%, transparent);
    opacity: 0.9;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, var(--accent-color) 0%, transparent 60%);
    opacity: 0.03;
    pointer-events: none;
}

.stat-card.accent-green { --accent-color: #22c55e; }
.stat-card.accent-orange { --accent-color: #8b5cf6; }
.stat-card.accent-neutral { --accent-color: #f59e0b; }

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.stat-label {
    font-size: 13px;
    color: #78716c;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-color) 100%);
    color: #ffffff;
    font-size: 22px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.stat-card.accent-green .stat-icon {
    background: rgba(34, 197, 94, 0.14);
    color: #16a34a;
}
.stat-card.accent-orange .stat-icon {
    background: rgba(139, 92, 246, 0.14);
    color: #8b5cf6;
}
.stat-card.accent-neutral .stat-icon {
    background: rgba(245, 158, 11, 0.16);
    color: #d97706;
}

.stat-value {
    font-size: 36px;
    font-weight: 900;
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, var(--ink) 0%, #57534e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.stat-helper {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 600;
}

.activity-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-xl);
    padding: 28px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.activity-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.analytics-activity {
    margin-bottom: 22px;
}

.activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.activity-header h3 {
    font-size: 20px;
    font-weight: 800;
}

.activity-header p {
    color: var(--muted);
    font-size: 13px;
}

.activity-select {
    border: 1px solid var(--surface-border);
    background: #fff;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #5e534a;
}

.heatmap-block {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
}

.heatmap-weekdays {
    display: grid;
    grid-template-rows: repeat(7, 12px);
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    padding-top: 22px;
}

.heatmap-weekdays span:empty {
    visibility: hidden;
}

.heatmap-body {
    display: grid;
    gap: 8px;
    overflow-x: auto;
}

.heatmap-months {
    display: grid;
    grid-auto-flow: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.heatmap {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 12px;
    grid-template-rows: repeat(7, 12px);
    gap: 6px;
    padding-bottom: 6px;
}

.heatmap-cell {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: #e7e5e4;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.heatmap-cell:hover {
    transform: scale(1.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.heatmap-cell.level-0 { background: #e7e5e4; }
.heatmap-cell.level-1 {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(34, 197, 94, 0.4));
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.3);
}
.heatmap-cell.level-2 {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.5), rgba(34, 197, 94, 0.6));
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.4);
}
.heatmap-cell.level-3 {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.75), rgba(34, 197, 94, 0.85));
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.5);
}
.heatmap-cell.level-4 {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.heatmap-cell.empty { background: transparent; }

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
    padding-left: 40px;
}

.heatmap-scale {
    display: flex;
    gap: 6px;
}

.habit-list,
.record-list {
    display: grid;
    gap: 16px;
}

.habit-item,
.record-item {
    display: grid;
    grid-template-columns: auto minmax(0, 2fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    padding: 22px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.habit-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.1);
    border-color: rgba(249, 115, 22, 0.2);
}

.habit-item.is-complete {
    border-color: rgba(34, 197, 94, 0.5);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, rgba(255, 255, 255, 0.95) 100%);
    box-shadow: 0 8px 32px rgba(34, 197, 94, 0.15);
}

.habit-item::after {
    content: "";
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    transform: skewX(-20deg);
    opacity: 0;
}

.habit-item.animate-complete {
    animation: habit-pop 0.35s ease;
}

.habit-item.animate-complete::after {
    animation: habit-sweep 0.6s ease;
}

.habit-item.animate-undo {
    animation: habit-undo 0.3s ease;
}

.habit-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15) 0%, rgba(249, 115, 22, 0.08) 100%);
    color: var(--accent);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15), inset 0 0 0 1px rgba(249, 115, 22, 0.2);
    font-size: 24px;
    transition: all 0.3s ease;
}

.habit-item:hover .habit-icon {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.25), inset 0 0 0 1px rgba(249, 115, 22, 0.3);
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.habit-meta {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.2) 100%);
    color: #15803d;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15), inset 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.badge.pending {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15) 0%, rgba(249, 115, 22, 0.2) 100%);
    color: #7c3aed;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.15), inset 0 0 0 1px rgba(249, 115, 22, 0.2);
}

.habit-actions {
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

.toggle-btn {
    border: none;
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
    position: relative;
    overflow: hidden;
}

.toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(249, 115, 22, 0.4);
}

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

.toggle-btn.complete {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f4 100%);
    color: #15803d;
    border: 2px solid rgba(34, 197, 94, 0.3);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.15);
}

.toggle-btn.complete:hover {
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.25);
}

.toggle-btn:disabled {
    opacity: 0.7;
    cursor: progress;
}

.toggle-btn.btn-bounce {
    animation: btn-bounce 0.3s ease;
}

@keyframes habit-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.015); }
    100% { transform: scale(1); }
}

@keyframes habit-sweep {
    0% { opacity: 0; transform: translateX(0) skewX(-20deg); }
    40% { opacity: 0.6; }
    100% { opacity: 0; transform: translateX(240%) skewX(-20deg); }
}

@keyframes habit-undo {
    0% { transform: scale(1); }
    50% { transform: scale(0.995); }
    100% { transform: scale(1); }
}

@keyframes btn-bounce {
    0% { transform: scale(1); }
    50% { transform: scale(0.96); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .habit-item,
    .toggle-btn {
        animation: none !important;
        transition: none !important;
    }
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.progress-track {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.2);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 100%);
}

.progress-text {
    font-size: 12px;
    color: var(--muted);
    min-width: 48px;
    text-align: right;
}

.card {
    background: var(--surface-soft);
    border: 1px dashed var(--surface-border);
    border-radius: var(--radius-md);
    padding: 16px;
    color: var(--muted);
}

.form-card {
    display: grid;
    gap: 18px;
}

.form-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
}

.form-actions {
    display: flex;
    gap: 10px;
}

.color-field {
    display: grid;
    gap: 8px;
}

.color-chip {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.2), 0 8px 18px rgba(249, 115, 22, 0.2);
}

.color-label {
    font-size: 12px;
    color: var(--muted);
}

.icon-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    gap: 10px;
}

.icon-option {
    border: 1px solid var(--surface-border);
    background: var(--surface);
    border-radius: 12px;
    padding: 10px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    color: var(--icon-color, var(--muted));
}

.icon-option.active {
    border-color: var(--icon-color, var(--accent));
    background: rgba(249, 115, 22, 0.08);
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.18);
}

.weekday-picker {
    display: grid;
    gap: 10px;
}

.weekday-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.weekday-grid label {
    background: var(--surface-soft);
    border-radius: 10px;
    padding: 8px;
    text-align: center;
    font-size: 12px;
    cursor: pointer;
}

.analytics-head {
    margin-bottom: 18px;
}

.analytics-head h2 {
    font-size: 32px;
}

.analytics-head .panel-subtitle {
    font-size: 15px;
}

.analytics-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.analytics-stat {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    border: 1px solid var(--surface-border);
    box-shadow: 0 12px 22px rgba(32, 24, 19, 0.06);
    display: grid;
    gap: 6px;
}

.analytics-stat .stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
}

.analytics-stat.tone-green {
    border-color: rgba(34, 197, 94, 0.35);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), #fff);
}

.analytics-stat.tone-orange {
    border-color: rgba(249, 115, 22, 0.35);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.06), #fff);
}

.analytics-stat.tone-neutral {
    border-color: var(--surface-border);
}

.analytics-stat.tone-green .stat-icon {
    background: rgba(34, 197, 94, 0.16);
    color: #22c55e;
}

.analytics-stat.tone-orange .stat-icon {
    background: rgba(249, 115, 22, 0.16);
    color: #8b5cf6;
}

.analytics-stat.tone-neutral .stat-icon {
    background: rgba(148, 163, 184, 0.2);
    color: #6b7280;
}

.analytics-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 22px;
}

.analytics-grid.two-up {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.analytics-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    border: 1px solid var(--surface-border);
    box-shadow: 0 14px 24px rgba(32, 24, 19, 0.06);
    display: grid;
    gap: 12px;
}

.analytics-card.wide {
    padding: 22px;
}

.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.analytics-card h3 {
    font-size: 18px;
    font-weight: 600;
}

.analytics-card p {
    color: var(--muted);
    font-size: 13px;
}

.analytics-header h3 {
    font-size: 18px;
}

.analytics-header p {
    color: var(--muted);
    font-size: 13px;
}

.trend-value {
    display: grid;
    text-align: right;
    gap: 2px;
}

.trend-value span {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}

.trend-value small {
    color: var(--muted);
    font-size: 12px;
}

.trend-chart {
    height: 180px;
    background:
        linear-gradient(180deg, rgba(249, 115, 22, 0.08), rgba(249, 115, 22, 0.02)),
        repeating-linear-gradient(0deg, rgba(124, 111, 98, 0.15) 0, rgba(124, 111, 98, 0.15) 1px, transparent 1px, transparent 32px);
    border-radius: 18px;
    padding: 12px;
}

.trend-chart-wrap {
    display: grid;
    gap: 8px;
}

.trend-axis {
    display: grid;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
}

.trend-axis span {
    text-align: center;
}

.trend-svg {
    width: 100%;
    height: 100%;
}

.bar-chart {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    align-items: end;
    gap: 14px;
    height: 160px;
    padding-top: 10px;
}

.bar-column {
    display: grid;
    align-items: end;
    gap: 8px;
    height: 100%;
    justify-items: center;
}

.bar-fill {
    background: #d8d2cb;
    border-radius: 999px 999px 8px 8px;
    width: 100%;
    min-height: 6px;
}

.bar-fill.accent {
    background: linear-gradient(180deg, #8b5cf6 0%, #a78bfa 100%);
}

.bar-label {
    font-size: 12px;
    text-align: center;
    color: var(--muted);
}

.monthly-chart {
    height: 180px;
    display: grid;
    align-items: end;
    background:
        repeating-linear-gradient(0deg, rgba(124, 111, 98, 0.14) 0, rgba(124, 111, 98, 0.14) 1px, transparent 1px, transparent 32px);
    border-radius: 18px;
    padding: 12px;
}

.monthly-bars {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    align-items: end;
    gap: 16px;
    height: 150px;
}

.monthly-column {
    display: grid;
    align-items: end;
    gap: 8px;
    justify-items: center;
    height: 100%;
}

.monthly-bar {
    width: 100%;
    border-radius: 12px 12px 6px 6px;
    background: #8b5cf6;
    min-height: 10px;
    box-shadow: 0 10px 18px rgba(249, 115, 22, 0.2);
}

.streak-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.streak-card {
    background: #fff7ed;
    border-radius: 16px;
    padding: 14px 12px;
    border: 1px solid #f3e7db;
    text-align: center;
    display: grid;
    gap: 6px;
    justify-items: center;
}

.streak-card:nth-child(2) {
    background: #fff6e6;
}

.streak-card:nth-child(3) {
    background: #ecfdf5;
}

.streak-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(249, 115, 22, 0.16);
    color: #8b5cf6;
}

.streak-card:nth-child(2) .streak-icon {
    background: rgba(245, 158, 11, 0.18);
    color: #f59e0b;
}

.streak-card:nth-child(3) .streak-icon {
    background: rgba(16, 185, 129, 0.16);
    color: #10b981;
}

.streak-card strong {
    font-size: 20px;
    color: var(--ink);
}

.donut-wrapper {
    display: grid;
    gap: 12px;
    justify-items: center;
}

.donut {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    margin: 0 auto;
    background: #e7e0d8;
    position: relative;
}

.donut::after {
    content: "";
    position: absolute;
    inset: 26px;
    background: #fff;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px var(--surface-border);
}

.donut-legend {
    display: grid;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    width: 100%;
}

.donut-legend span {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    align-items: center;
    gap: 8px;
}

.donut-legend strong {
    font-weight: 600;
    color: var(--ink);
}

.donut-legend em {
    font-style: normal;
    color: var(--muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.ranking-list {
    display: grid;
    gap: 16px;
}

.ranking-item {
    display: grid;
    grid-template-columns: 40px 1fr 60px;
    gap: 12px;
    align-items: center;
}

.ranking-rank {
    font-weight: 600;
    color: var(--muted);
}

.ranking-info {
    display: grid;
    gap: 8px;
}

.ranking-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.ranking-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.ranking-bar {
    height: 8px;
    background: #eee6dd;
    border-radius: 999px;
    overflow: hidden;
}

.ranking-bar span {
    display: block;
    height: 100%;
    background: #8b5cf6;
    border-radius: 999px;
}

.ranking-value {
    font-weight: 600;
    color: var(--muted);
    text-align: right;
}

.streaks-card {
    gap: 16px;
}

.best-habit-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--surface-border);
    background: #fff7ed;
}

.best-habit-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 20px;
}

.best-habit-title {
    font-weight: 600;
}

.best-habit-subtitle {
    font-size: 13px;
    color: var(--muted);
}

.empty {
    color: var(--muted);
    font-size: 13px;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 20;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    animation: fadeIn 0.3s ease;
}

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

.modal-card {
    position: relative;
    width: min(720px, 94vw);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 36px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 1;
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-close {
    border: none;
    background: rgba(0, 0, 0, 0.06);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--ink);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent);
    transform: rotate(90deg);
}

.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: linear-gradient(135deg, #1c1917 0%, #292524 100%);
    color: #fff;
    padding: 16px 28px;
    border-radius: 999px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    font-weight: 600;
    font-size: 15px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6, #a78bfa, #22c55e);
    border-radius: 999px 999px 0 0;
}

/* Calendar View Styles */
.calendar-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 32px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.3) 100%);
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.legend-color {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.calendar-container {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.weekday {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    min-height: 400px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    position: relative;
    font-weight: 600;
    font-size: 15px;
}

.calendar-day:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 10;
}

.calendar-day.other-month {
    opacity: 0.3;
    pointer-events: none;
}

.calendar-day.today {
    border-color: var(--accent);
    font-weight: 800;
}

.calendar-day.level-none {
    background: linear-gradient(135deg, #e7e5e4, #d6d3d1);
    color: #78716c;
}

.calendar-day.level-0 {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.25));
    color: #dc2626;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.2);
}

.calendar-day.level-1 {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(249, 115, 22, 0.25));
    color: #7c3aed;
    box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.2);
}

.calendar-day.level-2 {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.25));
    color: #d97706;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.2);
}

.calendar-day.level-3 {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.25));
    color: #16a34a;
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.calendar-day.level-4 {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
    font-weight: 800;
}

.calendar-day-percent {
    font-size: 10px;
    font-weight: 700;
    margin-top: 2px;
    opacity: 0.8;
}

.calendar-details {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.05);
    animation: fadeInUp 0.4s ease-out;
}

.calendar-details.hidden {
    display: none;
}

.details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.details-header h3 {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, #1c1917 0%, #57534e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#details-content {
    display: grid;
    gap: 12px;
}

.detail-habit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.6) 100%);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.detail-habit-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-habit-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.detail-habit-text h4 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-habit-text p {
    font-size: 12px;
    color: var(--muted);
}

.calendar-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.8);
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 24px;
}

.calendar-toggle-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
    color: #8b5cf6;
    transform: scale(1.05);
}

.calendar-toggle-btn.completed {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    border-color: #8b5cf6;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.calendar-toggle-btn.completed:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    transform: scale(1.05);
}

@media (max-width: 1024px) {
    .auth-view .auth-grid {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 24px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .calendar-grid {
        gap: 4px;
    }

    .calendar-day {
        font-size: 13px;
    }
}

@media (max-width: 720px) {
    .app-nav {
        flex-wrap: wrap;
    }

    .habit-item,
    .record-item {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .two-col {
        grid-template-columns: 1fr;
    }

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