:root {
  --bg: #FFF9F0;
  --card: #FFFFFF;
  --primary: #FF9A76;
  --success: #4CD964;
  --danger: #FF3B30;
  --text: #2C2C2E;
  --light: #8E8E93;
  --border: #F0F0F0;
  --progress-bg: #E9E9EF;
  --input-bg: #F9F9F9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1C1E;
    --card: #2C2C2E;
    --text: #FFFFFF;
    --light: #8E8E93;
    --border: #3A3A3C;
    --progress-bg: #3A3A3C;
    --input-bg: #2C2C2E;
  }
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 80px;
  transition: background .3s, color .3s;
}
.page { padding: 20px; max-width: 480px; margin: 0 auto; }
.greeting { font-size: 28px; font-weight: 700; }
.date-display { color: var(--light); font-size: 15px; margin: 4px 0 20px; }
.card {
  background: var(--card);
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.card-title { font-size: 14px; color: var(--light); margin-bottom: 8px; }
.progress-bar { height: 8px; background: var(--progress-bg); border-radius: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 8px; transition: width .3s; }
.progress-text { font-size: 24px; font-weight: 700; margin-top: 8px; }
.progress-text span { color: var(--primary); }
.habit-item {
  display: flex;
  align-items: center;
  background: var(--card);
  border-radius: 24px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  cursor: pointer;
  transition: transform .15s, opacity .2s;
}
.habit-item:active { transform: scale(.98); }
.habit-item.completed { opacity: .7; }
.habit-icon { font-size: 28px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--progress-bg); border-radius: 14px; margin-right: 12px; }
.habit-info { flex: 1; }
.habit-name { font-size: 16px; font-weight: 600; }
.habit-target { font-size: 13px; color: var(--light); margin-top: 2px; }
.habit-action { margin-left: auto; }
.checkin-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--primary);
  color: white;
  border: none; border-radius: 32px;
  font-size: 15px; font-weight: 500;
  cursor: pointer;
  transition: transform .15s;
}
.checkin-btn:active { transform: scale(.95); }
.completed-badge { font-size: 24px; }
.fab {
  position: fixed; right: 20px; bottom: 90px;
  width: 56px; height: 56px;
  background: var(--primary); color: white;
  border: none; border-radius: 50%;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(255,154,118,.4);
  cursor: pointer;
  transition: transform .15s;
  z-index: 100;
}
.fab:active { transform: scale(.9); }
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 1000;
}
.tab-bar-inner { display: flex; justify-content: space-around; max-width: 480px; margin: 0 auto; }
.tab-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 16px;
  color: var(--light);
  text-decoration: none;
  font-size: 12px;
  border-radius: 12px;
  transition: background .2s, color .2s;
}
.tab-item.active { color: var(--primary); }
.tab-icon { width: 24px; height: 24px; margin-bottom: 2px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--light); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-text { font-size: 16px; margin-bottom: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 48px; padding: 0 24px;
  border: none; border-radius: 32px;
  font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-block { width: 100%; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; color: var(--text); }
.form-input {
  width: 100%; height: 48px; padding: 0 16px;
  background: var(--input-bg);
  border: 2px solid transparent;
  border-radius: 16px;
  font-size: 16px; color: var(--text);
  transition: border-color .2s;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E8E93' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.icon-option { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--input-bg); border: 2px solid transparent; border-radius: 12px; cursor: pointer; transition: border-color .2s, transform .15s; }
.icon-option:hover { transform: scale(1.05); }
.icon-option.selected { border-color: var(--primary); background: rgba(255,154,118,.15); }
.color-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.color-option { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: border-color .2s, transform .15s; }
.color-option:hover { transform: scale(1.1); }
.color-option.selected { border-color: var(--text); }
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 5000; opacity: 0; visibility: hidden;
  transition: opacity .3s, visibility .3s;
}
.modal.show { opacity: 1; visibility: visible; }
.modal-content {
  background: var(--card); width: 100%; max-width: 480px;
  border-radius: 28px 28px 0 0; padding: 24px;
  max-height: 85vh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s;
}
.modal.show .modal-content { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 20px; }
.modal-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; text-align: center; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  padding: 12px 24px;
  background: var(--text); color: var(--card);
  border-radius: 12px;
  font-size: 15px;
  opacity: 0; visibility: hidden;
  transition: opacity .3s, transform .3s, visibility .3s;
  z-index: 10000;
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.back-header { display: flex; align-items: center; padding: 16px 20px; background: var(--bg); position: sticky; top: 0; z-index: 10; }
.back-btn { display: flex; align-items: center; gap: 4px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 500; }
.back-title { flex: 1; text-align: center; font-size: 18px; font-weight: 600; margin-right: 40px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { background: var(--card); border-radius: 24px; padding: 20px; text-align: center; }
.stat-icon { width: 32px; height: 32px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-label { font-size: 14px; color: var(--light); margin-top: 4px; }
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 16px; background: var(--card); border-radius: 24px; }
.heatmap-day { aspect-ratio: 1; border-radius: 6px; background: var(--progress-bg); }
.heatmap-legend { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 12px; font-size: 12px; color: var(--light); }
.legend-box { width: 14px; height: 14px; border-radius: 3px; }
.setting-item { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); }
.setting-label { font-weight: 500; }
.setting-desc { font-size: 13px; color: var(--light); margin-top: 2px; }
.copy-btn { padding: 8px 16px; background: var(--primary); color: white; border: none; border-radius: 12px; font-size: 14px; cursor: pointer; }
.tutorial-content { background: var(--input-bg); border-radius: 16px; padding: 16px; font-size: 14px; color: var(--light); }
.tutorial-content p { margin-bottom: 10px; }
.tutorial-content strong { color: var(--text); }
.error-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; text-align: center; }
.error-icon { font-size: 64px; margin-bottom: 16px; }
.error-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.error-message { color: var(--light); margin-bottom: 20px; }
.time-btns { display: flex; gap: 8px; margin-bottom: 20px; }
.time-btn { flex: 1; padding: 10px; background: var(--progress-bg); border: 2px solid transparent; border-radius: 12px; font-size: 14px; cursor: pointer; transition: border-color .2s; }
.time-btn.active { border-color: var(--primary); background: rgba(255,154,118,.1); }
.collapse-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; cursor: pointer; }
.collapse-content { max-height: 0; overflow: hidden; transition: max-height .3s; }
.collapse.open .collapse-content { max-height: 500px; }
.collapse-arrow { transition: transform .3s; }
.collapse.open .collapse-arrow { transform: rotate(180deg); }
