/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --success-color: #10b981;
    --bg-gradient-start: #1e1b4b;
    --bg-gradient-end: #312e81;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    padding-bottom: 90px;
}

/* 背景装饰 */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
}

.bg-circle-1 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    top: -100px;
    right: -100px;
}

.bg-circle-2 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, #ec4899, #f43f5e);
    bottom: 20%;
    left: -80px;
}

.bg-circle-3 {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    top: 40%;
    right: -60px;
}

/* 毛玻璃卡片 */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--glass-shadow);
    position: relative;
    z-index: 1;
}

/* 主内容区域 */
.main-content {
    padding: 20px 16px;
    position: relative;
    z-index: 1;
}

/* 页面切换 */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* 今日打卡页面 */
.habit-card {
    text-align: center;
    padding: 40px 24px;
}

.habit-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.habit-name {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.habit-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 32px;
}

/* 打卡按钮 */
.check-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.check-button {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(10px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.check-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    border-radius: 50%;
}

.check-button:active {
    transform: scale(0.95);
}

.check-button.checked {
    background: linear-gradient(135deg, var(--success-color), #059669);
    border-color: rgba(255, 255, 255, 0.5);
    animation: checkPulse 0.5s ease;
}

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

.check-icon {
    font-size: 4rem;
    color: white;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.check-button.checked .check-icon {
    opacity: 1;
}

.check-status {
    margin-top: 20px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.check-button.checked + .check-status {
    color: var(--success-color);
}

/* 连续打卡信息 */
.streak-card {
    padding: 20px;
}

.streak-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.streak-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.streak-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-light);
    text-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
}

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

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

/* 最近7天 */
.recent-card h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.recent-days {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

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

.recent-day-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recent-day-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.recent-day-dot.checked {
    background: var(--success-color);
    border-color: var(--success-color);
}

.recent-day.today .recent-day-label {
    color: var(--primary-light);
    font-weight: 600;
}

/* 日历页面 */
.calendar-card {
    padding: 20px;
}

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

.nav-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.nav-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
}

.current-month {
    font-size: 1.1rem;
    font-weight: 600;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 12px;
}

.weekdays span {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px 0;
}

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

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
}

.calendar-day:hover {
    background: rgba(255, 255, 255, 0.15);
}

.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.5;
}

.calendar-day.today {
    background: rgba(99, 102, 241, 0.3);
    font-weight: 600;
}

.calendar-day.checked {
    background: var(--success-color);
    font-weight: 600;
}

.calendar-day.checked::after {
    content: '✓';
    position: absolute;
    font-size: 0.7rem;
    bottom: 2px;
}

/* 月度统计 */
.month-stats-card h3 {
    font-size: 1rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.month-progress {
    display: flex;
    align-items: center;
    gap: 24px;
}

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

.progress-ring svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progress-ring circle {
    fill: none;
    stroke-width: 8;
}

.progress-bg {
    stroke: rgba(255, 255, 255, 0.1);
}

.progress-bar {
    stroke: var(--success-color);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success-color);
}

.progress-info {
    flex: 1;
}

.progress-info p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-info strong {
    color: var(--text-primary);
}

/* 统计页面 */
.year-stats-card h3,
.chart-card h3,
.achievements-card h3 {
    font-size: 1rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

/* 年度热力图 */
.year-heatmap {
    display: grid;
    grid-template-columns: repeat(53, 1fr);
    gap: 3px;
    overflow-x: auto;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    min-width: 8px;
}

.heatmap-cell.checked {
    background: var(--success-color);
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

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

.legend-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-cell.level-0 { background: rgba(255, 255, 255, 0.05); }
.legend-cell.level-1 { background: rgba(16, 185, 129, 0.3); }
.legend-cell.level-2 { background: rgba(16, 185, 129, 0.5); }
.legend-cell.level-3 { background: rgba(16, 185, 129, 0.7); }
.legend-cell.level-4 { background: var(--success-color); }

/* 月度图表 */
.month-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 8px;
    height: 150px;
    padding: 10px 0;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(to top, var(--primary-color), var(--primary-light));
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    max-height: 100%;
    position: relative;
    transition: all 0.3s;
    opacity: 0.8;
}

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

.chart-bar-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* 成就列表 */
.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    transition: all 0.3s;
}

.achievement-item.unlocked {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.achievement-item.locked {
    opacity: 0.5;
}

.achievement-icon {
    font-size: 2rem;
    filter: grayscale(100%);
    transition: all 0.3s;
}

.achievement-item.unlocked .achievement-icon {
    filter: grayscale(0%);
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

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

.achievement-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.achievement-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: rgba(30, 27, 75, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item.active {
    color: var(--primary-light);
}

.nav-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.2s;
}

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

.nav-text {
    font-size: 0.7rem;
    font-weight: 500;
}

/* 打卡成功动画 */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.celebration.active {
    display: flex;
    opacity: 1;
}

.celebration-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--success-color);
    animation: celebrationPop 0.5s ease;
}

@keyframes celebrationPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* 触摸滑动提示 */
.swipe-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.swipe-hint.left {
    left: 0;
    border-radius: 0 20px 20px 0;
}

.swipe-hint.right {
    right: 0;
    border-radius: 20px 0 0 20px;
}

.swipe-hint.show {
    opacity: 1;
}

/* 响应式适配 */
@media (max-width: 360px) {
    html {
        font-size: 14px;
    }
    
    .glass-card {
        border-radius: 20px;
        padding: 20px;
    }
    
    .check-button {
        width: 120px;
        height: 120px;
    }
    
    .check-icon {
        font-size: 3rem;
    }
}

/* 适配刘海屏 */
@supports (padding-top: env(safe-area-inset-top)) {
    .main-content {
        padding-top: calc(20px + env(safe-area-inset-top));
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
