/* 老徐工作台 · 简洁明亮风 */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #999;
  --border: #ececec;
  --primary: #ff7a1a;
  --primary-soft: #fff4ea;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar-h: 68px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hero {
  padding: 28px 20px 16px;
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px;
}
.hero-date { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.hero-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.hero-right { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.sync-badge {
  background: #f3f4f6; color: #666;
  padding: 4px 10px; border-radius: 12px; font-size: 11px;
  border: none; cursor: pointer;
}
.sync-badge.on { background: #dcfce7; color: #16a34a; }
.sync-badge.syncing { background: #fef3c7; color: #a16207; }
.sync-badge.err { background: #fee2e2; color: #dc2626; }
.sync-badge.off { background: #f3f4f6; color: #999; }
.inbox-btn {
  background: var(--primary-soft); color: var(--primary); border: none;
  padding: 10px 16px; border-radius: 24px; font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.inbox-btn .dot {
  width: 8px; height: 8px; background: var(--primary); border-radius: 50%;
  display: inline-block;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.3)} }

.page { padding: 8px 16px; }
.page.hidden { display: none; }

.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 4px 10px;
}
.section-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.2px; }
.muted { color: var(--muted); font-size: 13px; }

/* 板块布局 */
.category-block { margin-bottom: 8px; }
.cat-head h2 { font-size: 17px; }

.todo-list {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  margin-bottom: 16px;
}
.todo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.todo-item:last-of-type { border-bottom: none; }
.todo-item:active { background: #f8f8f8; }
.item-emoji { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; }
.item-title { flex: 1; min-width: 0; font-size: 15px; }
.todo-item.done .item-title { color: var(--muted); text-decoration: line-through; }
.todo-item.done .checkbox { background: var(--primary); border-color: var(--primary); }
.todo-item.done .checkbox::after { content: '✓'; font-size: 14px; color: #fff; }

.add-temp-btn {
  width: 100%; background: none; border: none; cursor: pointer;
  padding: 14px; color: var(--primary); font-size: 14px; font-weight: 500;
  border-top: 1px solid var(--border);
  transition: background 0.1s;
}
.add-temp-btn:active { background: var(--primary-soft); }
.add-temp-btn:only-child { border-top: none; }

/* 旧 .task-item 保留以免散错 */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
}
.task-item:active { transform: scale(0.98); }
.checkbox {
  width: 24px; height: 24px; border: 2px solid #ddd; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0; margin-top: 2px;
  transition: all 0.15s;
}
.task-item.done .checkbox {
  background: var(--primary); border-color: var(--primary);
}
.task-item.done .checkbox::after { content: '✓'; font-size: 14px; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 500; font-size: 16px; line-height: 1.4; }
.task-item.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-size: 12px; color: var(--muted);
  flex-wrap: wrap;
}
.tag {
  background: #f3f4f6; color: #555;
  padding: 2px 8px; border-radius: 6px; font-size: 12px;
}
.tag-ai { background: #e8f0ff; color: var(--info); }
.pri-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.pri-1 { background: var(--danger); }
.pri-2 { background: var(--warning); }
.pri-3 { background: #bbb; }

.habits-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.habit-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 10px; text-align: center;
  box-shadow: var(--shadow); cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
}
.habit-card:active { transform: scale(0.95); }
.habit-card.done {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.habit-emoji { font-size: 32px; line-height: 1; }
.habit-name { font-size: 14px; margin: 8px 0 4px; font-weight: 500; }
.habit-state { font-size: 11px; color: var(--muted); }
.habit-card.done .habit-state { color: var(--primary); font-weight: 600; }

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

.fab {
  position: fixed; right: 20px; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 28px; font-weight: 300;
  border: none; cursor: pointer;
  box-shadow: 0 6px 16px rgba(255,122,26,0.35);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.9); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--tabbar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tab-btn {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted);
  font-size: 12px;
}
.tab-btn .t-emoji { font-size: 22px; line-height: 1; }
.tab-btn.active { color: var(--primary); font-weight: 600; }

/* AI Inbox */
.inbox-list { display: flex; flex-direction: column; gap: 10px; }
.inbox-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.inbox-title { font-weight: 500; font-size: 15px; line-height: 1.4; margin-top: 6px; }
.inbox-note { font-size: 13px; color: #666; margin-top: 6px; line-height: 1.5; }
.inbox-src { font-size: 11px; color: var(--muted); margin-top: 4px; }
.inbox-actions { display: flex; gap: 10px; margin-top: 14px; }
.inbox-actions button { flex: 1; padding: 10px; border-radius: 10px; border: none; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-accept { background: var(--primary); color: #fff; }
.btn-dismiss { background: #f3f4f6; color: #555; }

/* Journal */
.quick-add {
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.quick-add textarea {
  width: 100%; border: none; outline: none; resize: none;
  font-size: 15px; font-family: inherit; min-height: 60px;
  background: #f8f8f8; padding: 12px; border-radius: 10px;
  box-sizing: border-box;
}
.quick-add-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; }
.type-tabs { display: flex; gap: 8px; }
.type-btn {
  padding: 6px 14px; border-radius: 20px; border: none;
  background: #f3f4f6; color: #666;
  font-size: 13px; cursor: pointer;
}
.type-btn.active { background: var(--primary); color: #fff; }

.journal-day {
  padding: 16px 4px 6px; color: var(--muted); font-size: 13px; font-weight: 500;
}
.journal-card {
  background: var(--surface); border-radius: var(--radius); padding: 10px 16px;
  box-shadow: var(--shadow); margin-bottom: 10px;
}
.journal-entry {
  padding: 12px 0; border-bottom: 1px solid var(--border);
  display: flex; gap: 12px; align-items: flex-start;
}
.journal-entry:last-child { border-bottom: none; }
.entry-icon { font-size: 18px; width: 28px; flex-shrink: 0; }
.entry-main { flex: 1; min-width: 0; }
.entry-title { font-size: 15px; line-height: 1.4; }
.entry-title.done { color: var(--muted); text-decoration: line-through; }
.entry-note { font-size: 13px; color: #666; margin-top: 4px; }
.entry-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-body {
  width: 100%; background: #fff; border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(32px + env(safe-area-inset-bottom));
  max-width: 500px;
}
.modal-body h3 { margin: 0 0 20px; font-size: 18px; }
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; outline: none; box-sizing: border-box;
}
.modal-body input:focus, .modal-body select:focus { border-color: var(--primary); }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; }
.pri-picker { display: flex; gap: 8px; }
.pri-btn { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-size: 14px; cursor: pointer; }
.pri-btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: 10px; border: none; font-size: 15px; font-weight: 500; cursor: pointer; }
.primary { background: var(--primary); color: #fff; }
.ghost { background: #f3f4f6; color: #333; }

/* 响应式:桌面居中限宽 */
@media (min-width: 640px) {
  body { max-width: 560px; margin: 0 auto; box-shadow: 0 0 30px rgba(0,0,0,0.05); background: var(--bg); min-height: 100vh; }
  .tabbar { max-width: 560px; margin: 0 auto; }
}
