/* ========== Apple Design System ========== */
:root {
  --bg-primary: #F2F2F7;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F2F2F7;
  --bg-elevated: #FFFFFF;
  --text-primary: #1C1C1E;
  --text-secondary: #3C3C43;
  --text-tertiary: #8E8E93;
  --text-quaternary: #AEAEB2;
  --separator: rgba(60, 60, 67, 0.12);
  --fill-primary: rgba(120, 120, 128, 0.2);
  --fill-secondary: rgba(120, 120, 128, 0.16);
  --fill-tertiary: rgba(120, 120, 128, 0.12);
  --accent: #007AFF;
  --accent-hover: #0056CC;
  --accent-light: rgba(0, 122, 255, 0.1);
  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;
  --yellow: #FFCC00;
  --purple: #AF52DE;
  --pink: #FF2D55;
  --teal: #5AC8FA;
  --indigo: #5856D6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --bg-elevated: #1C1C1E;
    --text-primary: #FFFFFF;
    --text-secondary: rgba(235,235,245,0.6);
    --text-tertiary: rgba(235,235,245,0.4);
    --text-quaternary: rgba(235,235,245,0.28);
    --separator: rgba(84, 84, 88, 0.65);
    --fill-primary: rgba(120, 120, 128, 0.36);
    --fill-secondary: rgba(120, 120, 128, 0.32);
    --fill-tertiary: rgba(120, 120, 128, 0.24);
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-light: rgba(10, 132, 255, 0.15);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
    --green: #30D158;
    --red: #FF453A;
    --orange: #FF9F0A;
    --yellow: #FFD60A;
  }
}

/* ========== Reset & Base ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', 'Noto Sans CJK SC', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.47;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

/* ========== Navigation ========== */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}

.nav-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 8px;
}

.nav-icon { font-size: 20px; }

.nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.nav-version {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 10px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.nav-tab.active {
  background: var(--accent);
  color: #fff;
}

.nav-tab:not(.active):active {
  background: var(--fill-tertiary);
}

.tab-icon { font-size: 14px; }

/* ========== Container ========== */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}

/* ========== Tab Content ========== */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active { display: block; }

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

/* ========== Cards ========== */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: -0.2px;
}

/* ========== Header Card ========== */
.header-card {
  padding: 24px 20px;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
}

.ai-header-card {
  display: flex;
  align-items: center;
}

.ai-header-card .date-display {
  flex: 1;
  margin-bottom: 0;
}

.date-display {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.date-emoji {
  font-size: 44px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.1));
}

.date-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.date-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 500;
}

.core-task {
  background: var(--fill-tertiary);
  border-radius: var(--radius-md);
  padding: 16px;
}

.core-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.core-input-wrap { position: relative; }

.core-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  letter-spacing: -0.3px;
}

.core-input::placeholder {
  color: var(--text-quaternary);
  font-weight: 400;
}

/* ========== AI Brief / Analysis Cards ========== */
.ai-brief-card, .ai-analysis-card {
  background: linear-gradient(135deg, rgba(88,86,214,0.08), rgba(175,82,222,0.08));
  border: 1px solid rgba(88,86,214,0.15);
}

.ai-brief-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.ai-brief-icon { font-size: 20px; }

.ai-brief-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--indigo);
  flex: 1;
}

.btn-sm-icon {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--fill-tertiary);
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-sm-icon:active {
  transform: scale(0.9);
  background: var(--fill-secondary);
}

.ai-brief-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-brief-content .brief-highlight {
  color: var(--indigo);
  font-weight: 600;
}

/* ========== Self-Optimization Card ========== */
.evo-card {
  background: linear-gradient(135deg, rgba(52,199,89,0.06), rgba(90,200,250,0.06));
  border: 1px solid rgba(52,199,89,0.15);
}

.evo-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.evo-icon { font-size: 20px; }

.evo-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.evo-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(52,199,89,0.15);
  color: var(--green);
}

.evo-badge.active { background: rgba(255,149,0,0.15); color: var(--orange); }
.evo-badge.idle { background: var(--fill-tertiary); color: var(--text-tertiary); }

.evo-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.evo-stat {
  text-align: center;
  padding: 12px 8px;
  background: var(--fill-tertiary);
  border-radius: var(--radius-sm);
}

.evo-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.evo-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  font-weight: 500;
}

.evo-log {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.6;
  max-height: 60px;
  overflow-y: auto;
}

.evo-log:empty::before {
  content: '数据积累中，开始记录后将自动学习优化...';
  opacity: 0.6;
}

.evo-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.evo-timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--separator);
}

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

.evo-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-top: 6px;
  flex-shrink: 0;
}

.evo-timeline-date {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.evo-timeline-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ========== Time Blocks ========== */
.time-blocks { padding: 8px 0; }

.time-block {
  padding: 16px 0;
  border-bottom: 0.5px solid var(--separator);
}

.time-block:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.block-icon { font-size: 20px; }

.block-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.block-time {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ========== Task Items ========== */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--fill-tertiary);
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
  animation: taskIn 0.3s ease;
}

@keyframes taskIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.task-item.completed { opacity: 0.5; }
.task-item.completed .task-text { text-decoration: line-through; }

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-quaternary);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: transparent;
}

.task-check.checked {
  background: var(--green);
  border-color: var(--green);
}

.task-check.checked::after {
  content: '✓';
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.red-dot { background: var(--red); }
.yellow-dot { background: var(--orange); }
.green-dot { background: var(--green); }

.task-text {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.task-delete {
  opacity: 0;
  border: none;
  background: none;
  color: var(--red);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  transition: opacity 0.2s;
}

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

.add-task-btn {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--text-quaternary);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-task-btn:active {
  background: var(--fill-tertiary);
  color: var(--accent);
  border-color: var(--accent);
}

/* ========== AI Section ========== */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.section-icon { font-size: 20px; }
.section-header h2 { font-size: 17px; font-weight: 600; }

.section-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  font-weight: 400;
}

.ai-ideas {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-idea-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--fill-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.ai-idea-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  min-width: 18px;
}

.ai-idea-type {
  font-size: 11px;
  font-weight: 600;
  color: var(--purple);
  background: rgba(175, 82, 222, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.ai-idea-content {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

/* ========== Quote & Checkin ========== */
.quote-box {
  font-style: italic;
  font-size: 15px;
  color: var(--text-secondary);
  padding: 16px;
  background: var(--fill-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  line-height: 1.5;
  position: relative;
  border-left: 3px solid var(--accent);
}

.quote-box::before {
  content: '"';
  font-size: 40px;
  color: var(--accent);
  position: absolute;
  top: -4px;
  left: 12px;
  font-family: Georgia, serif;
  line-height: 1;
  opacity: 0.3;
}

.checkin-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.checkin-grid { display: flex; gap: 10px; }

.checkin-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--fill-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkin-item:active { background: var(--fill-secondary); }

.checkin-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.checkin-label { font-size: 14px; font-weight: 500; }
.checkin-item input:checked + .checkin-label { color: var(--accent); }

/* ========== Action Bar ========== */
.action-bar {
  display: flex;
  gap: 10px;
  padding: 16px 0;
}

/* ========== Buttons ========== */
.btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  letter-spacing: -0.2px;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:active { background: var(--accent-hover); }

.btn-secondary {
  background: var(--fill-secondary);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--separator);
}

.btn-danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}

.btn-block { width: 100%; }

/* ========== Review Section ========== */
.review-header {
  background: linear-gradient(135deg, #1C1C1E 0%, #2C2C2E 100%);
}

@media (prefers-color-scheme: light) {
  .review-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
  }
  .review-header .date-sub { color: rgba(255,255,255,0.7); }
}

.eval-stars {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.star {
  font-size: 32px;
  color: var(--text-quaternary);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 4px;
}

.star.active {
  color: var(--orange);
  transform: scale(1.1);
}

.review-textarea,
.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--fill-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: background 0.2s;
}

.review-textarea:focus,
.form-input:focus { background: var(--fill-secondary); }

.form-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--fill-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238E8E93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.input-with-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-toggle .form-input { flex: 1; }

.btn-toggle-vis {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--fill-tertiary);
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.slider-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}

.tomorrow-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goodnight-card {
  text-align: center;
  padding: 32px 20px;
  margin-bottom: 12px;
}

.goodnight-text {
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========== AI Coding Tab ========== */
.type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.type-btn {
  padding: 12px;
  border: 1px solid var(--separator);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.type-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.prompt-display {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.ai-idea-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.ai-idea-card {
  background: var(--fill-tertiary);
  border-radius: var(--radius-md);
  padding: 16px;
  border-left: 4px solid;
}

.ai-idea-card:nth-child(1) { border-color: var(--accent); }
.ai-idea-card:nth-child(2) { border-color: var(--purple); }
.ai-idea-card:nth-child(3) { border-color: var(--teal); }

.ai-idea-card .idea-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-idea-card .idea-title {
  font-size: 16px;
  font-weight: 600;
}

.ai-idea-card .idea-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========== AI Chat ========== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--fill-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.quick-btn:active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.quick-icon { font-size: 24px; }

.chat-area {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 400px;
  max-height: 55vh;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

.chat-welcome-icon { font-size: 56px; margin-bottom: 16px; }

.chat-welcome p {
  font-size: 15px;
  margin-bottom: 8px;
}

.chat-welcome-hint {
  font-size: 13px;
  color: var(--text-quaternary);
}

.chat-msg {
  margin-bottom: 16px;
  animation: msgIn 0.3s ease;
}

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

.chat-msg-user {
  display: flex;
  justify-content: flex-end;
}

.chat-msg-user .chat-bubble {
  background: var(--accent);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.5;
}

.chat-msg-ai {
  display: flex;
  gap: 10px;
}

.chat-msg-ai .chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-msg-ai .chat-bubble {
  background: var(--fill-tertiary);
  border-radius: 18px 18px 18px 4px;
  max-width: 85%;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg-ai .chat-bubble code {
  background: var(--fill-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', Menlo, monospace;
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingDot 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.chat-input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 0.5px solid var(--separator);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
}

.chat-input-wrap {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input {
  flex: 1;
  border: none;
  background: var(--fill-tertiary);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
}

.chat-input::placeholder { color: var(--text-quaternary); }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.chat-send-btn:active {
  transform: scale(0.9);
  background: var(--accent-hover);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== History Tab ========== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 500;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.history-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:active { transform: scale(0.98); }

.history-date {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.history-preview {
  font-size: 13px;
  color: var(--text-tertiary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--orange);
}

.data-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.danger-zone {
  padding-top: 16px;
  border-top: 0.5px solid var(--separator);
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 680px;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  overflow-y: auto;
}

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

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

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

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--fill-tertiary);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.priority-selector { display: flex; gap: 8px; }

.priority-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--separator);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.priority-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.priority-btn.red.active { border-color: var(--red); background: rgba(255,59,48,0.08); }
.priority-btn.yellow.active { border-color: var(--orange); background: rgba(255,149,0,0.08); }
.priority-btn.green.active { border-color: var(--green); background: rgba(52,199,89,0.08); }

/* ========== Settings ========== */
.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--separator);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--separator);
  font-size: 15px;
  font-weight: 500;
}

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

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--fill-primary);
  border-radius: 28px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
  background: var(--green);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* ========== Detail Modal ========== */
.modal-detail .modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.detail-tasks {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-task {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 14px;
}

.detail-task-done { color: var(--green); }
.detail-task-pending { color: var(--text-secondary); }

/* ========== Loading ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: rgba(255,255,255,0.8);
  font-size: 15px;
  font-weight: 500;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-xl);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(20px);
}

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

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--fill-primary);
  border-radius: 3px;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

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

.empty-state p { font-size: 15px; }

/* ========== Focus Mode Banner ========== */
.focus-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: linear-gradient(135deg, var(--accent), var(--indigo));
  color: #fff;
  transform: translateY(-100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.focus-banner.visible { transform: translateY(0); }

.focus-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.focus-icon { font-size: 18px; }
.focus-text { flex: 1; }
.focus-progress {
  font-size: 12px;
  background: rgba(255,255,255,0.2);
  padding: 3px 10px;
  border-radius: 10px;
}

.focus-dismiss {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== AI Badge ========== */
.nav-ai-badge {
  font-size: 14px;
  animation: aiPulse 2s infinite;
}

@keyframes aiPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== AI Generate Card ========== */
.ai-gen-card {
  background: linear-gradient(135deg, rgba(0,122,255,0.06), rgba(175,82,222,0.06));
  border: 1px solid rgba(0,122,255,0.15);
  padding: 16px;
}

.ai-gen-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-gen-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.ai-gen-icon { font-size: 24px; }

.ai-gen-title {
  font-size: 15px;
  font-weight: 600;
}

.ai-gen-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--indigo));
  color: #fff;
  white-space: nowrap;
}

.btn-accent:active { opacity: 0.8; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ========== Block Progress ========== */
.block-progress {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 8px;
}

/* ========== Habits Tab ========== */
.stats-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Heatmap */
.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.heatmap-legend-colors {
  display: flex;
  gap: 3px;
}

.heatmap-cell {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

.heatmap-cell.level-0 { background: var(--fill-tertiary); }
.heatmap-cell.level-1 { background: rgba(52,199,89,0.2); }
.heatmap-cell.level-2 { background: rgba(52,199,89,0.4); }
.heatmap-cell.level-3 { background: rgba(52,199,89,0.65); }
.heatmap-cell.level-4 { background: var(--green); }

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 4px;
}

.heatmap-grid .hm-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  transition: transform 0.2s;
}

.heatmap-grid .hm-cell:hover { transform: scale(1.3); }

.heatmap-grid .hm-cell.empty { background: var(--fill-tertiary); opacity: 0.3; }
.heatmap-grid .hm-cell.l0 { background: var(--fill-tertiary); }
.heatmap-grid .hm-cell.l1 { background: rgba(52,199,89,0.2); }
.heatmap-grid .hm-cell.l2 { background: rgba(52,199,89,0.4); }
.heatmap-grid .hm-cell.l3 { background: rgba(52,199,89,0.65); }
.heatmap-grid .hm-cell.l4 { background: var(--green); }

.heatmap-habits-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.heatmap-habit-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: center;
}

/* Trend Chart */
.habit-trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 8px 0;
}

.trend-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.trend-bar {
  width: 100%;
  max-width: 28px;
  border-radius: 4px 4px 0 0;
  transition: height 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  min-height: 2px;
}

.trend-bar.cg { background: linear-gradient(to top, var(--red), var(--orange)); }
.trend-bar.paipai { background: linear-gradient(to top, var(--accent), var(--teal)); }
.trend-bar.meditate { background: linear-gradient(to top, var(--purple), var(--pink)); }

.trend-label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Weekly Chart in History */
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding: 8px 0;
}

.trend-chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.trend-chart-fill {
  width: 100%;
  max-width: 40px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(to top, var(--accent), var(--teal));
  transition: height 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  min-height: 2px;
  position: relative;
}

.trend-chart-fill .bar-value {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.trend-chart-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ========== 4-col Quick Actions ========== */
.quick-actions {
  grid-template-columns: repeat(4, 1fr);
}

/* ========== Responsive ========== */
@media (min-width: 768px) {
  .container { padding: 24px 24px 100px; }
  .card { padding: 24px; }
  .chat-input-bar { padding: 10px 24px; }
}
