/* ============================================
   样式变量
   ============================================ */
:root {
    --bg: #F2F2F7;
    --surface: #FFFFFF;
    --primary: #007AFF;
    --primary-light: rgba(0, 122, 255, 0.08);
    --primary-tint: rgba(0, 122, 255, 0.12);
    --text: #1C1C1E;
    --text-secondary: #8E8E93;
    --separator: #E5E5EA;
    --record-bg: #E3F2FD;
    --overlay: rgba(0, 0, 0, 0.35);
    --radius-card: 16px;
    --radius-btn: 12px;
    --radius-day: 10px;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.07);
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display",
        "SF Pro Text", "Helvetica Neue", "PingFang SC",
        "Microsoft YaHei", sans-serif;
}

/* ============================================
   全局重置
   ============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-stack);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   页面容器
   ============================================ */
.page-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 32px;
}

@media (min-width: 640px) {
    .page-container {
        padding: 24px 24px 48px;
    }
}

/* ============================================
   卡片样式
   ============================================ */
.ios-card {
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

/* ============================================
   统计数字样式
   ============================================ */
.stat-number {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -1.5px;
    line-height: 1.1;
    color: var(--text);
    transition: transform 0.2s ease;
}

@media (min-width: 480px) {
    .stat-number {
        font-size: 48px;
    }
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 400;
}

/* ============================================
   导航按钮
   ============================================ */
.nav-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #E5E5EA;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.nav-btn:hover {
    background: #D1D1D6;
}

.nav-btn:active {
    background: #C7C7CC;
    transform: scale(0.9);
}

/* ============================================
   日历样式
   ============================================ */
.weekday-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    padding: 8px 0;
    user-select: none;
}

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

@media (min-width: 480px) {
    .calendar-grid {
        gap: 4px;
    }
}

.calendar-day {
    height: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-day);
    cursor: pointer;
    font-size: 15px;
    font-weight: 400;
    position: relative;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

@media (min-width: 480px) {
    .calendar-day {
        height: 48px;
        font-size: 16px;
    }
}

.calendar-day:active {
    transform: scale(0.92);
}

/* 今日样式 */
.calendar-day.today {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.calendar-day.today::after {
    content: "";
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
}

/* 有记录日期 */
.calendar-day.has-record:not(.today) {
    background: var(--record-bg);
    color: var(--text);
}

.calendar-day.today.has-record {
    background: var(--primary-tint);
}

/* 其他月份日期 */
.calendar-day.other-month {
    color: var(--text-secondary);
    opacity: 0.35;
    cursor: default;
}

/* 未来日期（禁止点击） */
.calendar-day.future-day {
    color: var(--text-secondary);
    opacity: 0.5;
    cursor: not-allowed;
}

.calendar-day.other-month:active,
.calendar-day.future-day:active {
    transform: none;
}

/* 日期数量徽章 */
.day-count {
    font-size: 9px;
    font-weight: 600;
    color: var(--primary);
    line-height: 1;
    margin-top: 1px;
    position: absolute;
    bottom: 3px;
}

.calendar-day.today .day-count {
    color: var(--primary);
}

.calendar-day.has-record:not(.today) .day-count .day-count {
    color: #4A90D9;
}

.calendar-day.today.has-record::after {
    display: none;
}

/* ============================================
   弹窗样式
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    padding: 20px;
}

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

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 28px 24px 22px;
    width: 100%;
    max-width: 280px;
    text-align: center;
    transform: scale(0.85);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.2s ease;
}

.modal-overlay.active .modal-box {
    transform: scale(1);
    opacity: 1;
}

/* 按钮样式 */
.ios-btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: var(--radius-btn);
    font-family: var(--font-stack);
    font-size: 17px;
    font-weight: 500;
    padding: 13px 20px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.ios-btn:active {
    transform: scale(0.97);
    opacity: 0.8;
}

.ios-btn-primary {
    background: var(--primary);
    color: #FFFFFF;
}

.ios-btn-primary:hover {
    background: #0066DD;
}

.ios-btn-secondary {
    background: #F2F2F7;
    color: var(--primary);
}

.ios-btn-secondary:hover {
    background: #E5E5EA;
}

.ios-btn-danger {
    background: #FF3B30;
    color: #FFFFFF;
}

.ios-btn-danger:hover {
    background: #FF2D20;
}

/* ============================================
   历史记录列表
   ============================================ */
.history-scroll {
    max-height: 320px;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.history-scroll::-webkit-scrollbar {
    display: none;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 0.5px solid var(--separator);
    transition: background 0.12s ease;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:active {
    background: #F2F2F7;
}

.empty-state {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 48px 20px;
    text-align: center;
    line-height: 1.7;
}

/* ============================================
   动画效果
   ============================================ */
.fade-up {
    opacity: 0;
    transform: translateY(18px);
    animation: fadeUp 0.5s 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.08); }
    100% { transform: scale(1); }
}

.pop {
    animation: pop 0.25s ease;
}

/* 刘海屏适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .page-container {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
}