/* 全局变量 */
:root {
    --bg-page: #f5f5f7;
    --bg-card: #ffffff;
    --color-primary: #007aff;
    --primary-light: rgba(0, 122, 255, 0.08);
    --primary-fill: rgba(0, 122, 255, 0.11);
    --text-main: #1d1d1f;
    --text-sub: #86868b;
    --border-line: #e6e6eb;
    --shadow-card: 0 2px 14px rgba(0,0,0,0.05);
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --font-main: -apple-system, BlinkMacSystemFont, PingFang SC, Microsoft YaHei, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}
body {
    font-family: var(--font-main);
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    padding: 0;
}

/* 页面容器基础 */
.page-container {
    max-width: 740px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}
@media(min-width:640px) {
    .page-container {
        padding: 32px 24px 50px;
    }
}

/* 头部区域 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-title {
    font-size: 24px;
    font-weight: 700;
}
.current-date-text {
    font-size: 14px;
    color: var(--text-sub);
}

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
@media(min-width:640px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    box-shadow: var(--shadow-card);
    position: relative;
}
.stat-tag {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 12px;
    color: var(--text-sub);
}
/* 数字容器统一底部对齐 */
.stat-number-wrap {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 56px; /* 固定高度，三张卡片数字区域等高 */
}
/* 大数字 */
.stat-number {
    font-size: 52px;
    font-weight: 700;
    line-height: 1;
    margin: 0;
}
/* 小字「次」强制下沉，和数字底边完全重合 */
.stat-unit {
    font-size: 16px;
    color: var(--text-sub);
    line-height: 1;
    margin-bottom: 8px; /* 精准向下偏移，匹配52号字底部 */
}
/* 另外两个卡片单独数字统一高度，对齐基准 */
.stat-card:nth-child(1) .stat-number,
.stat-card:nth-child(2) .stat-number {
    height: 56px;
    display: flex;
    align-items: flex-end;
}in-bottom: 6px;
}
.stat-desc {
    font-size: 13px;
    color: var(--text-sub);
}

/* 通用卡片容器 */
.chart-card, .calendar-card, .history-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.card-title {
    font-size: 18px;
    font-weight: 600;
}
.card-subtext {
    font-size: 13px;
    color: var(--text-sub);
}
.chart-wrap {
    height: 220px;
    width: 100%;
}

/* 日历样式 */
.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cal-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #efeff4;
    font-size: 16px;
    cursor: pointer;
}
.cal-title {
    font-size: 17px;
    font-weight: 600;
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}
.weekday-header {
    text-align: center;
    font-size: 12px;
    color: var(--text-sub);
    padding: 8px 0;
}
.calendar-day {
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 15px;
    cursor: pointer;
    position: relative;
}
.calendar-day.today {
    background: var(--primary-light);
    color: var(--color-primary);
    font-weight: 600;
}
.calendar-day.has-record {
    background: var(--primary-light);
}
.calendar-day.other-month {
    opacity: 0.3;
    cursor: default;
}
.calendar-day.future-day {
    opacity: 0.5;
    cursor: not-allowed;
}
.day-count {
    font-size: 10px;
    position: absolute;
    bottom: 3px;
    right: 4px;
    background: #fff;
    padding: 0 4px;
    border-radius: 3px;
    color: var(--color-primary);
}

/* ========== 重点：美化历史记录滚动条（解决下拉块丑陋问题） ========== */
.history-scroll {
    max-height: 300px;
    overflow-y: auto;
    /* Firefox 专用：细滚动条 + 配色 */
    scrollbar-width: thin;
    scrollbar-color: #d2d2d7 transparent;
}
/* Chrome / Edge / Safari 自定义滚动条 */
.history-scroll::-webkit-scrollbar {
    width: 5px; /* 滚动条宽度，做细 */
}
/* 滚动条轨道（背景） */
.history-scroll::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}
/* 滚动条滑块 */
.history-scroll::-webkit-scrollbar-thumb {
    background-color: #d2d2d7;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}
/* hover 加深颜色 */
.history-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #b0b0b8;
}

/* 历史记录列表项 */
.history-item {
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-line);
}
.history-item:last-child {
    border-bottom: none;
}
.empty-state {
    text-align: center;
    padding: 60px 0;
    color: var(--text-sub);
    font-size: 14px;
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 999;
    padding: 20px;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-box {
    background: #fff;
    width: 100%;
    max-width: 320px;
    border-radius: var(--radius-lg);
    padding: 30px 24px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.2, 1, 0.2, 1);
}
.modal-overlay.active .modal-box {
    transform: scale(1);
}
.modal-date {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}
.modal-count-text {
    font-size: 14px;
    color: var(--text-sub);
    margin-bottom: 24px;
}
.modal-btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ios-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}
.ios-btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.ios-btn-secondary {
    background: #efeff4;
    color: var(--color-primary);
}
.ios-btn-danger {
    background: #ff3b30;
    color: #fff;
}

/* 动画 */
.fade-up {
    opacity: 0;
    transform: translateY(16px);
    animation: fadeUp 0.45s ease forwards;
}
.fade-up:nth-child(2) { animation-delay: 0.06s; }
.fade-up:nth-child(3) { animation-delay: 0.12s; }
.fade-up:nth-child(4) { animation-delay: 0.18s; }
.fade-up:nth-child(5) { animation-delay: 0.24s; }
@keyframes fadeUp {
    to { opacity:1; transform: translateY(0); }
}
@keyframes pop {
    0% {transform:scale(1)}
    50% {transform:scale(1.06)}
    100% {transform:scale(1)}
}
.pop { animation: pop 0.25s ease; }
@keyframes countUp {
    0% {transform: translateY(0); opacity:1;}
    50% {transform: translateY(-8px); opacity:0.4;}
    100% {transform: translateY(0); opacity:1;}
}
.count-animation {
    animation: countUp 0.4s ease-out;
}