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

:root {
    --pink: #ff6b9d;
    --pink-light: #ffe0ec;
    --pink-dark: #e8557e;
    --red: #ff4757;
    --red-light: #ffe0e5;
    --bg: #fdf6f9;
    --card: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --text-lighter: #b2bec3;
    --border: #f0e0e8;
    --shadow: 0 2px 12px rgba(255, 107, 157, 0.1);
    --radius: 14px;
    --radius-sm: 10px;
    --nav-height: 64px;
    --topbar-height: 52px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --gold: #f9ca24;
    --green: #2ed573;
    --blue: #70a1ff;
    --purple: #a29bfe;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ========== 页面切换 ========== */
.page { display: none; width: 100%; max-width: 480px; height: 100vh; height: 100dvh; flex-direction: column; background: var(--bg); position: relative; }
.page.active { display: flex; }

/* ========== 登录/注册页 ========== */
.login-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 28px; width: 100%; height: 100%;
}

.login-header { text-align: center; margin-bottom: 36px; }
.heart-icon { font-size: 56px; margin-bottom: 12px; animation: heartbeat 1.5s ease infinite; }
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
    60% { transform: scale(1); }
}

.login-header h1 {
    font-size: 26px; font-weight: 700;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.subtitle { color: var(--text-light); font-size: 14px; }

.login-form { width: 100%; max-width: 320px; }
.login-hint { text-align: center; color: var(--text-lighter); font-size: 12px; margin-top: 16px; line-height: 1.5; }

/* ========== 输入框 ========== */
.input-group { margin-bottom: 18px; }
.input-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--text-light); margin-bottom: 6px;
}

.input-group input, .input-group textarea {
    width: 100%; padding: 12px 14px; border: 2px solid var(--border);
    border-radius: var(--radius-sm); font-size: 15px; background: var(--card);
    color: var(--text); outline: none; transition: border-color 0.2s;
    -webkit-appearance: none; font-family: inherit;
}

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

.input-group textarea { resize: vertical; min-height: 80px; }
.input-group input[type="number"] { -moz-appearance: textfield; }
.input-group input[type="number"]::-webkit-inner-spin-button,
.input-group input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ========== 按钮 ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border: none; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: all 0.2s; font-family: inherit;
    -webkit-appearance: none; user-select: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
    background: linear-gradient(135deg, var(--pink), var(--pink-dark));
    color: #fff;
}

.btn-primary:hover { opacity: 0.9; }

.btn-block { width: 100%; }

.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 20px; }

.btn-outline {
    background: transparent; color: var(--pink);
    border: 2px solid var(--pink);
}

.btn-outline:active { background: var(--pink-light); }

.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-light); padding: 6px 12px; font-size: 13px; }

/* ========== 顶部栏 ========== */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px; height: var(--topbar-height);
    background: var(--card); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.greeting { font-size: 15px; font-weight: 600; color: var(--text); }
.partner-badge {
    font-size: 13px; color: var(--pink-dark);
    background: var(--pink-light); padding: 4px 12px;
    border-radius: 20px; font-weight: 500;
}

/* ========== 主体内容 ========== */
.main-content {
    flex: 1; overflow-y: auto; padding: 14px 14px 20px;
    padding-bottom: calc(var(--nav-height) + 20px + var(--safe-bottom));
    -webkit-overflow-scrolling: touch;
}

/* ========== Tab 切换 ========== */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== 卡片 ========== */
.card {
    background: var(--card); border-radius: var(--radius);
    padding: 18px; margin-bottom: 14px;
    box-shadow: var(--shadow);
}

/* ========== 统计卡片 ========== */
.stats-card { padding: 20px 14px; }

.stats-row {
    display: flex; align-items: center; justify-content: space-around;
}

.stat-item { text-align: center; flex: 1; }
.stat-num {
    font-size: 32px; font-weight: 800;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; line-height: 1.3;
}

.stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

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

/* ========== 对方次数卡片 ========== */
.partner-quota-card { background: linear-gradient(135deg, #fff5f8, #fdf0ff); border: 1px solid #ffe0ec; }
.partner-quota-header { text-align: center; font-size: 14px; color: var(--text); }
.partner-quota-header strong { color: var(--pink-dark); font-size: 18px; }

/* ========== 区域标题 ========== */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; margin-top: 4px;
}

.section-header h3 { font-size: 16px; font-weight: 600; }

/* ========== 次数列表 ========== */
.quota-list { display: flex; flex-direction: column; gap: 8px; }

.quota-item {
    background: var(--card); border-radius: var(--radius-sm);
    padding: 14px 16px; display: flex; align-items: center;
    justify-content: space-between; box-shadow: var(--shadow);
    transition: all 0.2s;
}

.quota-item.used { opacity: 0.55; background: #f8f8f8; }
.quota-item.expired { opacity: 0.45; background: #fef5f5; }

.quota-info { flex: 1; min-width: 0; }
.quota-tag {
    display: inline-block; font-size: 11px; padding: 2px 8px;
    border-radius: 10px; font-weight: 500; margin-bottom: 4px;
}

.quota-tag.available { background: #e8f8f0; color: var(--green); }
.quota-tag.used { background: #f0f0f0; color: #999; }
.quota-tag.expired { background: #fef0f0; color: #e88; }

.quota-time { font-size: 12px; color: var(--text-lighter); }
.quota-expire { font-size: 11px; color: var(--red); margin-top: 2px; }

.quota-action { flex-shrink: 0; margin-left: 12px; }
.quota-action .btn { padding: 8px 16px; font-size: 13px; border-radius: 20px; }

/* ========== 记录列表 ========== */
.record-filter {
    display: flex; gap: 6px; margin-bottom: 12px;
    overflow-x: auto; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.filter-btn {
    padding: 6px 14px; border: 1px solid var(--border);
    border-radius: 20px; font-size: 13px; background: var(--card);
    color: var(--text-light); cursor: pointer; white-space: nowrap;
    transition: all 0.2s; font-family: inherit;
    -webkit-appearance: none;
}

.filter-btn.active {
    background: var(--pink); color: #fff; border-color: var(--pink);
}

.record-list { display: flex; flex-direction: column; gap: 8px; }

.record-item {
    background: var(--card); border-radius: var(--radius-sm);
    padding: 14px 16px; box-shadow: var(--shadow);
}

.record-type {
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    font-weight: 600; display: inline-block; margin-bottom: 6px;
}

.record-type.use { background: #fff0f5; color: var(--pink-dark); }
.record-type.target { background: #f0f0ff; color: var(--purple); }
.record-type.add { background: #e8f8f0; color: var(--green); }

.record-content { font-size: 14px; line-height: 1.6; color: var(--text); }
.record-time { font-size: 12px; color: var(--text-lighter); margin-top: 6px; }

/* ========== Tab 切换按钮 ========== */
.tab-switch {
    display: flex; background: var(--card); border-radius: var(--radius-sm);
    padding: 3px; margin-bottom: 14px; box-shadow: var(--shadow);
}

.tab-switch-btn {
    flex: 1; padding: 10px; border: none; background: transparent;
    font-size: 14px; font-weight: 600; color: var(--text-light);
    cursor: pointer; border-radius: 8px; transition: all 0.2s;
    font-family: inherit; -webkit-appearance: none;
}

.tab-switch-btn.active {
    background: linear-gradient(135deg, var(--pink), var(--pink-dark));
    color: #fff;
}

.records-sub { display: none; }
.records-sub.active { display: block; }

/* ========== 请求列表 ========== */
.request-list { display: flex; flex-direction: column; gap: 8px; }

.request-item {
    background: var(--card); border-radius: var(--radius-sm);
    padding: 14px 16px; box-shadow: var(--shadow);
}

.request-info { margin-bottom: 10px; }
.request-info p { font-size: 14px; line-height: 1.6; }
.request-info .request-meta {
    font-size: 12px; color: var(--text-lighter); margin-top: 4px;
}

.request-actions { display: flex; gap: 8px; }

/* 状态标签 */
.badge {
    background: var(--red); color: #fff; font-size: 11px;
    padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

.status-tag {
    display: inline-block; font-size: 11px; padding: 2px 8px;
    border-radius: 10px; font-weight: 500;
}

.status-tag.pending { background: #fff8e1; color: #f9a825; }
.status-tag.agreed { background: #e8f5e9; color: #2e7d32; }
.status-tag.rejected { background: #fce4ec; color: #c62828; }

/* ========== 底部导航 ========== */
.bottom-nav {
    position: absolute; bottom: 0; left: 0; right: 0;
    display: flex; background: var(--card);
    border-top: 1px solid var(--border);
    height: var(--nav-height); padding-bottom: var(--safe-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.03);
}

.nav-btn {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border: none; background: transparent;
    cursor: pointer; transition: all 0.2s; position: relative;
    font-family: inherit; -webkit-appearance: none;
}

.nav-icon { font-size: 22px; transition: transform 0.2s; }
.nav-label { font-size: 11px; color: var(--text-lighter); margin-top: 2px; transition: color 0.2s; }

.nav-btn.active .nav-label { color: var(--pink-dark); font-weight: 600; }
.nav-btn.active .nav-icon { transform: scale(1.15); }

.nav-dot {
    position: absolute; top: 6px; right: 50%; margin-right: -14px;
    width: 8px; height: 8px; background: var(--red);
    border-radius: 50%;
}

/* ========== 弹窗 ========== */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45); z-index: 1000;
    align-items: center; justify-content: center; padding: 28px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--card); border-radius: var(--radius);
    width: 100%; max-width: 360px; max-height: 80vh;
    overflow-y: auto; animation: modalIn 0.25s ease;
}

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

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 12px;
}

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

.modal-close {
    width: 28px; height: 28px; border: none; background: var(--bg);
    border-radius: 50%; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-light); transition: all 0.2s;
}

.modal-close:active { background: var(--border); }

.modal-body { padding: 0 20px 20px; }
.modal-desc { font-size: 14px; color: var(--text-light); margin-bottom: 12px; }
.modal-hint { font-size: 12px; color: var(--text-lighter); margin: 10px 0; }

.char-count { text-align: right; font-size: 12px; color: var(--text-lighter); margin-top: -12px; margin-bottom: 12px; }

/* ========== Toast ========== */
.toast {
    position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
    padding: 10px 24px; border-radius: 24px; font-size: 14px;
    font-weight: 500; color: #fff; z-index: 9999;
    pointer-events: none; opacity: 0; transition: all 0.3s;
    white-space: nowrap; max-width: 90%;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(8px); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--blue); }

/* ========== 空状态 ========== */
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-lighter); font-size: 14px;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ========== 响应式微调 ========== */
@media (min-width: 480px) {
    .page { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
