* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #f5f5f5;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --accent: #f5a623;
    --accent-bg: #fdf6ec;
    --ring-bg: #e8e8e8;
    --ring-track: #d0d0d0;
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--gray-900);
    overflow: hidden;
    position: fixed;
    width: 100%;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* ===== 页面容器 ===== */
.page-container {
    display: flex;
    width: 200%;
    height: calc(100dvh - 24px - var(--safe-bottom));
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    padding-top: var(--safe-top);
}

.page-container.swiping {
    transition: none;
}

.page {
    width: 50%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 20px 50px;
    -webkit-overflow-scrolling: touch;
}

.page::-webkit-scrollbar { display: none; }
.page { scrollbar-width: none; }

/* ===== 顶部栏 ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 4px 12px;
}

.top-left, .top-right {
    width: 40px;
    display: flex;
}

.top-right { justify-content: flex-end; }

.top-center h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:active { background: var(--gray-100); }

/* ===== 日期 ===== */
.date-display {
    text-align: center;
    font-size: 13px;
    color: var(--gray-400);
    padding: 4px 0 16px;
}

/* ===== 圆环 ===== */
.ring-wrapper {
    display: flex;
    justify-content: center;
    padding: 0 10px;
    margin-bottom: 20px;
}

.ring-outer {
    position: relative;
    width: 260px;
    height: 260px;
}

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

.ring-bg {
    fill: none;
    stroke: var(--ring-bg);
    stroke-width: 10;
}

.ring-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 722.57;
    stroke-dashoffset: 722.57;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.ring-count {
    font-size: 72px;
    font-weight: 200;
    color: var(--gray-900);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: transform 0.15s ease;
}

.ring-count.bump { transform: scale(1.08); }

.ring-unit {
    font-size: 16px;
    color: var(--gray-400);
    font-weight: 400;
}

/* ===== 记录按钮 ===== */
.record-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto 24px;
    padding: 12px 32px;
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: 30px;
    font-size: 15px;
    font-weight: 500;
    color: var(--gray-800);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: all 0.2s;
}

.record-btn:active {
    transform: scale(0.96);
    background: var(--gray-50);
}

/* ===== 操作按钮 ===== */
.action-grid {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 28px;
}

.action-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1.5px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.action-btn:active {
    transform: scale(0.9);
    background: var(--gray-50);
}

/* ===== 底部统计 ===== */
.bottom-stats {
    background: linear-gradient(135deg, #fdf0d5 0%, #fce8c3 100%);
    border-radius: 16px;
    padding: 20px 16px 16px;
    margin: 0 0 16px;
    position: relative;
    overflow: hidden;
}

.bottom-stats::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
}

.bottom-stats::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
}

.stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-val {
    font-size: 22px;
    font-weight: 600;
    color: var(--gray-900);
}

.stat-desc {
    font-size: 12px;
    color: var(--gray-600);
}

.stat-divider {
    width: 1px;
    height: 32px;
    background: rgba(0,0,0,0.08);
}

.stats-note {
    text-align: center;
    font-size: 12px;
    color: var(--gray-500);
    position: relative;
    z-index: 1;
}

/* ===== 滑动提示 ===== */
.swipe-hint {
    text-align: center;
    color: var(--gray-300);
    font-size: 12px;
    padding: 12px 0;
}

/* ===== 页面指示器 ===== */
.page-indicator {
    position: fixed;
    bottom: calc(10px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gray-300);
    transition: all 0.3s ease;
}

.dot.active {
    background: var(--gray-700);
    width: 20px;
    border-radius: 3px;
}

/* ===== 趋势页 ===== */
.tab-bar {
    display: flex;
    background: var(--gray-100);
    border-radius: 10px;
    padding: 3px;
    margin: 0 20px 16px;
}

.tab {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.25s;
}

.tab.active {
    background: var(--white);
    color: var(--gray-900);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.date-range {
    text-align: center;
    font-size: 13px;
    color: var(--gray-400);
    margin-bottom: 20px;
}

.chart-area {
    background: var(--white);
    border-radius: 16px;
    padding: 20px 12px 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

#trendChart {
    width: 100%;
    height: 200px;
}

/* ===== 趋势统计卡片 ===== */
.trend-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.trend-card {
    background: var(--white);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.trend-val {
    font-size: 28px;
    font-weight: 300;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

.trend-desc {
    font-size: 12px;
    color: var(--gray-400);
}

.trend-note {
    text-align: center;
    font-size: 13px;
    color: var(--gray-400);
    padding: 8px 0 16px;
}

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

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

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 16px;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    overflow-y: auto;
    max-height: 55vh;
}

.modal-body::-webkit-scrollbar { display: none; }

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 15px;
}

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

.history-item .h-time {
    color: var(--gray-700);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.history-item .h-del {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item .h-del:active { background: var(--gray-100); color: #ef4444; }

.history-empty {
    text-align: center;
    color: var(--gray-300);
    padding: 40px 0;
    font-size: 14px;
}

/* ===== 设置 ===== */
.settings-body { padding: 4px 0; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    font-size: 15px;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 16px;
}

.setting-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid var(--gray-200);
    background: var(--white);
    font-size: 18px;
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.setting-btn:active { background: var(--gray-50); }

.setting-val {
    font-size: 20px;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: calc(60px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--gray-800);
    color: var(--white);
    padding: 10px 22px;
    border-radius: 22px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
