﻿:root {
  --primary: #FF6B8A;
  --primary-light: #FF8FA8;
  --secondary: #A78BFA;
  --accent: #34D399;
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --danger: #EF4444;
  --warning: #F59E0B;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
  --nav-height: 56px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --bg: #0D1117;
  --surface: #161B22;
  --text: #F0F6FC;
  --text-secondary: #8B949E;
  --border: #30363D;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5;
  overflow: hidden; height: 100vh; width: 100vw;
}

.page { display: none; height: 100vh; width: 100vw; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page.active { display: flex; flex-direction: column; }

.login-container { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; }
.login-header { text-align: center; margin-bottom: 48px; }
.login-header h1 { font-size: 32px; color: var(--primary); margin-bottom: 8px; }
.login-header p { color: var(--text-secondary); font-size: 14px; }
.login-form { width: 100%; max-width: 320px; }
.input-group { margin-bottom: 16px; }
.input-group input { width: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 16px; background: var(--surface); color: var(--text); outline: none; transition: border-color 0.2s; }
.input-group input:focus { border-color: var(--primary); }
.btn { width: 100%; padding: 14px; border: none; border-radius: var(--radius); font-size: 16px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary); color: white; }
.login-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-secondary); }
.login-switch a { color: var(--primary); text-decoration: none; font-weight: 500; }

#page-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tab-page { display: none; }
.tab-page.active { display: flex; flex-direction: column; height: 100%; }

.page-header { height: var(--header-height); display: flex; align-items: center; justify-content: center; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.page-header h2 { font-size: 18px; font-weight: 600; }

.bottom-nav { height: var(--nav-height); display: flex; background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom); }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border: none; background: none; cursor: pointer; color: var(--text-secondary); transition: color 0.2s; padding: 6px 0; }
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; margin-bottom: 2px; }
.nav-label { font-size: 11px; }

.home-content { padding: 16px; }
.greeting-card { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.date-display { font-size: 14px; opacity: 0.9; margin-bottom: 4px; }
.greeting-text { font-size: 22px; font-weight: 600; }
.section { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.section h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; color: var(--text-secondary); }

.list-empty { color: var(--text-secondary); font-size: 14px; text-align: center; padding: 20px 0; }
.list-item { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 12px; }
.list-item.completed { opacity: 0.5; }
.list-item.completed .item-title { text-decoration: line-through; }
.item-check { width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; margin-top: 2px; font-size: 13px; color: white; }
.item-check.checked { background: var(--accent); border-color: var(--accent); }
.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 500; word-break: break-word; }
.item-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.item-meta.overdue { color: var(--danger); font-weight: 500; }

.sub-tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); }
.sub-tab { flex: 1; padding: 12px; border: none; background: none; font-size: 14px; font-weight: 500; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; }
.sub-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.sub-page { display: none; flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.sub-page.active { display: block; }

.category-bar { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; margin-bottom: 8px; }
.category-bar::-webkit-scrollbar { display: none; }
.category-chip { padding: 6px 14px; border-radius: 20px; font-size: 13px; white-space: nowrap; background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); cursor: pointer; flex-shrink: 0; transition: all 0.2s; }
.category-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.fab-btn { position: fixed; bottom: calc(var(--nav-height) + 16px); right: 20px; width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--primary); color: white; font-size: 28px; cursor: pointer; box-shadow: 0 4px 12px rgba(255,107,138,0.4); transition: transform 0.2s; z-index: 20; }
.fab-btn:active { transform: scale(0.9); }

.calendar-container { padding: 8px 0; }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.calendar-header h4 { font-size: 16px; font-weight: 600; }
.calendar-nav { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); padding: 4px 12px; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 14px; cursor: pointer; transition: all 0.15s; border: none; background: none; color: var(--text); }
.calendar-day.today { font-weight: 700; border: 2px solid var(--primary); }
.calendar-day.period { background: var(--primary); color: white; }
.calendar-day.ovulation { background: var(--warning); color: white; }
.calendar-day.predicted { background: var(--secondary); color: white; }
.calendar-day.other-month { color: var(--text-secondary); opacity: 0.3; }

.prediction-card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-top: 12px; box-shadow: var(--shadow); }
.prediction-card h4 { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.prediction-card p { font-size: 15px; font-weight: 500; }

.profile-content { padding: 16px; }
.profile-info { text-align: center; padding: 24px 0; }
.avatar { font-size: 56px; margin-bottom: 12px; }
.nickname { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.reg-date { font-size: 13px; color: var(--text-secondary); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; }
.stat-item { background: var(--surface); border-radius: var(--radius); padding: 14px 8px; text-align: center; box-shadow: var(--shadow); }
.stat-num { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.settings-list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.setting-item:last-child { border-bottom: none; }
.setting-item:active { background: var(--bg); }
.arrow { color: var(--text-secondary); }
.setting-value { color: var(--text-secondary); font-size: 14px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); border-radius: 16px 16px 0 0; width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; padding: 20px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-secondary); padding: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 15px; background: var(--bg); color: var(--text); outline: none; }
.form-group textarea { min-height: 120px; resize: vertical; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--primary); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.mood-selector { display: flex; gap: 12px; justify-content: center; }
.mood-option { font-size: 28px; cursor: pointer; padding: 8px; border-radius: 50%; transition: all 0.2s; border: 2px solid transparent; }
.mood-option.selected { border-color: var(--primary); background: rgba(255,107,138,0.1); }
.btn-modal { width: 100%; padding: 14px; border: none; border-radius: var(--radius); font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn-cancel { background: var(--bg); color: var(--text); }
.btn-delete { background: var(--danger); color: white; }

.diary-card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.diary-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.diary-date { font-size: 12px; color: var(--text-secondary); }
.diary-mood { font-size: 20px; }
.diary-preview { font-size: 14px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.quote-card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); border-left: 3px solid var(--secondary); }
.quote-content { font-size: 15px; font-style: italic; margin-bottom: 8px; line-height: 1.6; }
.quote-meta { font-size: 12px; color: var(--text-secondary); }

.toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 20px; border-radius: 20px; font-size: 14px; z-index: 200; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.show { opacity: 1; }

.loading { text-align: center; padding: 20px; color: var(--text-secondary); font-size: 14px; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.overdue-border { border-left: 3px solid var(--danger); }
.overdue-tag { color: var(--danger); font-size: 11px; font-weight: 500; }

.anniv-card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.anniv-card.important { border-left: 3px solid var(--warning); }
.anniv-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.anniv-date { font-size: 13px; color: var(--text-secondary); }
.anniv-countdown { font-size: 20px; font-weight: 700; color: var(--primary); margin-top: 6px; }
.anniv-countdown.past { color: var(--secondary); }

.badge-important { background: #FEF3C7; color: #D97706; }
.badge-birthday { background: #FCE7F3; color: #DB2777; }
.badge-festival { background: #DBEAFE; color: #2563EB; }
.badge-anniversary { background: #D1FAE5; color: #059669; }

@media (min-width: 768px) { .modal { border-radius: 16px; margin: auto; max-height: 80vh; } .modal-overlay { align-items: center; } }
