/* ============================================
   Pink Diary - CSS 样式
   清新粉色 | 可爱圆润 | 少女感
   ============================================ */

:root {
    --pink-50: #FFF0F3;
    --pink-100: #FFDEE9;
    --pink-200: #FFD1DC;
    --pink-300: #FFB7C5;
    --pink-400: #FF8FA3;
    --pink-500: #FF6B81;
    --pink-600: #FF4757;
    --pink-700: #E84151;
    --white: #FFFFFF;
    --white-90: rgba(255,255,255,0.9);
    --white-80: rgba(255,255,255,0.8);
    --white-70: rgba(255,255,255,0.7);
    --white-60: rgba(255,255,255,0.6);
    --text-primary: #4A3048;
    --text-secondary: #8E6F8A;
    --text-light: #B8A0B4;
    --shadow-sm: 0 2px 8px rgba(255, 107, 129, 0.12);
    --shadow-md: 0 4px 16px rgba(255, 107, 129, 0.15);
    --shadow-lg: 0 8px 32px rgba(255, 107, 129, 0.2);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --tab-height: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 8px);
}

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

body {
    font-family: 'Nunito', 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--pink-100) 0%, var(--pink-200) 50%, var(--pink-50) 100%);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* ========== 背景层 ========== */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.bg-layer.active {
    opacity: 0.25;
}

.bg-layer.bg-bg1 { background-image: url('../assets/bg1.jpg'); }
.bg-layer.bg-bg2 { background-image: url('../assets/bg2.jpg'); }
.bg-layer.bg-bg3 { background-image: url('../assets/bg3.jpg'); }

/* ========== 状态栏 ========== */
.status-bar {
    height: env(safe-area-inset-top, 20px);
    min-height: 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 16px 16px;
    position: relative;
    z-index: 5;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.main-content::-webkit-scrollbar { display: none; }

/* ========== 页面切换 ========== */
.page {
    display: none;
    animation: fadeSlideIn 0.35s ease;
}

.page.active {
    display: block;
}

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

/* ========== 页面头部 ========== */
.page-header {
    padding: 16px 4px 8px;
    text-align: center;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--pink-500), var(--pink-700));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* ========== 卡片 ========== */
.card {
    background: var(--white-90);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 197, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:active {
    transform: scale(0.985);
}

/* ========== 按钮 ========== */
.primary-btn {
    background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(255, 107, 129, 0.3);
    letter-spacing: 0.5px;
}

.primary-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(255, 107, 129, 0.2);
}

.secondary-btn {
    background: var(--white);
    color: var(--pink-500);
    border: 2px solid var(--pink-300);
    border-radius: var(--radius-md);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.secondary-btn:active {
    background: var(--pink-50);
    transform: scale(0.95);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
    color: white;
    border: none;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(255, 107, 129, 0.3);
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.text-btn {
    background: none;
    border: none;
    color: var(--pink-500);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
}

.file-btn {
    background: none;
    border: none;
    color: var(--pink-500);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
}

/* ========== 输入框通用 ========== */
input[type="text"],
input[type="number"],
textarea {
    font-family: inherit;
    border: 2px solid var(--pink-100);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--white);
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

input:focus, textarea:focus {
    border-color: var(--pink-400);
}

textarea {
    resize: none;
    height: 72px;
}

/* ========================================
   每日任务
   ======================================== */
.task-input-card {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-input-card input {
    flex: 1;
}

.progress-card {
    padding: 14px 16px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: var(--pink-100);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar.large {
    height: 14px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pink-300), var(--pink-500), var(--pink-600));
    border-radius: 99px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 任务项 */
.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--white-90);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 197, 0.2);
    animation: fadeSlideIn 0.3s ease;
}

.task-checkbox {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2.5px solid var(--pink-300);
    background: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.3s;
    position: relative;
}

.task-checkbox.done {
    background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
    border-color: var(--pink-500);
}

.task-checkbox.done::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-weight: 700;
}

.task-text {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s;
}

.task-text.done {
    text-decoration: line-through;
    color: var(--text-light);
}

.task-delete {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 71, 87, 0.1);
    color: var(--pink-600);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.task-item:hover .task-delete,
.task-item:active .task-delete {
    opacity: 1;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 14px;
}

.empty-state .empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

/* ========================================
   开心果记录
   ======================================== */
.happy-input-card textarea {
    margin-bottom: 12px;
}

.happy-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.happy-tags .tag {
    padding: 6px 14px;
    border-radius: 99px;
    background: var(--pink-50);
    border: 1.5px solid var(--pink-200);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.happy-tags .tag.selected {
    background: var(--pink-400);
    color: white;
    border-color: var(--pink-400);
    box-shadow: 0 2px 8px rgba(255, 107, 129, 0.3);
}

.happy-input-card .primary-btn {
    width: 100%;
}

/* 开心记录卡片 */
.happy-item {
    background: var(--white-90);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 197, 0.25);
    position: relative;
    overflow: hidden;
    animation: fadeSlideIn 0.3s ease;
}

.happy-item::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 60px;
    height: 60px;
    background: var(--pink-50);
    border-radius: 50%;
    opacity: 0.5;
}

.happy-item .happy-mood {
    font-size: 18px;
    margin-bottom: 6px;
}

.happy-item .happy-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    font-weight: 500;
}

.happy-item .happy-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 8px;
    text-align: right;
}

.happy-item .happy-delete {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 71, 87, 0.1);
    color: var(--pink-600);
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.happy-item:active .happy-delete {
    opacity: 1;
}

/* ========================================
   追星日常
   ======================================== */
.idol-card {
    display: flex;
    align-items: center;
    gap: 14px;
}

.idol-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background-size: cover;
    background-position: center;
    box-shadow: var(--shadow-md);
}

.idol-info h3 {
    font-size: 17px;
    font-weight: 700;
}

.idol-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.idol-info span {
    color: var(--pink-500);
    font-weight: 700;
}

.fan-input-card {
    display: flex;
    gap: 10px;
    align-items: center;
}

.fan-input-card input {
    flex: 1;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--pink-200);
}

.fan-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    background-size: cover;
    background-position: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s;
}

.gallery-item:active {
    transform: scale(0.95);
}

.fan-item {
    background: var(--white-90);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 197, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    animation: fadeSlideIn 0.3s ease;
}

.fan-item .fan-icon {
    font-size: 20px;
}

/* ========================================
   存钱进程
   ======================================== */
.saving-card {
    text-align: center;
    padding: 24px 16px;
}

.saving-amount {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
}

.saving-amount .currency {
    font-size: 24px;
    color: var(--pink-500);
}

.saving-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0 16px;
}

.saving-target {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.saving-actions {
    padding: 16px;
}

.quick-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.amount-chip {
    padding: 10px 4px;
    border-radius: var(--radius-md);
    border: 2px solid var(--pink-200);
    background: var(--white);
    color: var(--pink-500);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.amount-chip:active {
    background: var(--pink-400);
    color: white;
    border-color: var(--pink-400);
    transform: scale(0.93);
}

.custom-save {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.custom-save input {
    flex: 1;
}

.target-setting {
    display: flex;
    gap: 10px;
}

.target-setting input {
    flex: 1;
}

.saving-item {
    background: var(--white-90);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 197, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    animation: fadeSlideIn 0.3s ease;
}

.saving-item .amount-plus {
    color: var(--pink-500);
    font-weight: 700;
}

/* ========================================
   我的
   ======================================== */
.profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 16px;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pink-100), var(--pink-300));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: var(--shadow-md);
}

.profile-info h3 {
    font-size: 18px;
    font-weight: 700;
}

.profile-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stats-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-item {
    text-align: center;
    padding: 14px 8px;
    background: var(--pink-50);
    border-radius: var(--radius-md);
}

.stat-num {
    font-size: 24px;
    font-weight: 800;
    color: var(--pink-500);
    display: block;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 2px;
    display: block;
}

.settings-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 183, 197, 0.2);
    font-size: 14px;
    font-weight: 600;
}

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

.setting-item input[type="text"] {
    width: 140px;
    font-size: 13px;
    padding: 6px 10px;
    text-align: right;
}

/* ========== 全局背景切换小按钮 ========== */
.global-bg-btn {
    position: fixed;
    top: env(safe-area-inset-top, 20px);
    top: calc(env(safe-area-inset-top, 20px) + 6px);
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--white-80);
    backdrop-filter: blur(10px);
    border: 1.5px solid rgba(255, 183, 197, 0.3);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    opacity: 0.7;
}

.global-bg-btn:active {
    opacity: 1;
    transform: scale(0.9);
}

/* ========== 背景选择面板 ========== */
.bg-panel {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.bg-panel.show {
    opacity: 1;
    pointer-events: auto;
}

.bg-panel-content {
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 480px;
    padding: 20px 16px calc(var(--safe-bottom) + 16px);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.bg-panel.show .bg-panel-content {
    transform: translateY(0);
}

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

.bg-panel-header h3 {
    font-size: 17px;
    font-weight: 700;
}

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

.bg-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.bg-option {
    text-align: center;
    cursor: pointer;
}

.bg-preview {
    width: 100%;
    aspect-ratio: 9/16;
    border-radius: var(--radius-sm);
    background-size: cover;
    background-position: center;
    border: 2px solid transparent;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.bg-preview.no-bg {
    background: linear-gradient(135deg, var(--pink-100), var(--pink-200));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pink-400);
    font-size: 12px;
    font-weight: 700;
}

.bg-option.active .bg-preview {
    border-color: var(--pink-500);
    box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.2);
}

.bg-option span {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    display: block;
    margin-top: 6px;
}

/* ========== 底部导航栏 ========== */
.tab-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--white-90);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 183, 197, 0.2);
    padding: 6px 4px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    height: var(--tab-height);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 56px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-family: inherit;
    position: relative;
}

.tab-icon {
    font-size: 22px;
    transition: transform 0.2s;
}

.tab-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    transition: color 0.2s;
    white-space: nowrap;
}

.tab-item.active .tab-label {
    color: var(--pink-500);
}

.tab-item.active .tab-icon {
    transform: scale(1.15);
}

.tab-item.active::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--pink-400);
    border-radius: 99px;
}

/* 安全区 */
.safe-area {
    height: var(--safe-bottom);
    flex-shrink: 0;
    background: var(--white-90);
    backdrop-filter: blur(20px);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: var(--pink-500);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ========== 响应式微调 ========== */
@media (min-width: 480px) {
    #app {
        border-left: 1px solid rgba(255, 183, 197, 0.2);
        border-right: 1px solid rgba(255, 183, 197, 0.2);
    }
}
