:root {
  --accent: #4f6ef7;
  --accent-dark: #3a56d6;
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #8a91a6;
  --ok: #2fbf71;
  --line: #eceef4;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.dim { color: var(--muted); font-size: 0.8rem; }
.err { color: #e5484d; margin-top: 8px; }

/* 登录 */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 340px; background: var(--card); border-radius: var(--radius);
  padding: 32px 26px; box-shadow: 0 10px 30px rgba(28,35,51,.08);
}
.login-card h1 { font-size: 1.4rem; text-align: center; margin-bottom: 6px; }
.login-card p { text-align: center; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 1rem; margin-bottom: 12px;
}
.login-card button {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 1rem; cursor: pointer;
}
.login-card button:active { background: var(--accent-dark); }

/* 主布局 */
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: 40px; }
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.15rem; }
.tabs { display: flex; gap: 6px; }
.tabs button {
  background: transparent; border: 0; color: var(--muted); font-size: 0.95rem;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.tabs button.active { background: #e7ecff; color: var(--accent); font-weight: 600; }
.logout { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 0.85rem; }

#content { padding: 16px 18px; }

/* 进度头部 */
.progress-head {
  display: flex; gap: 16px; align-items: center; margin-bottom: 18px;
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 4px 14px rgba(28,35,51,.04);
}
.stat-num { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-lbl { font-size: 0.8rem; color: var(--muted); text-align: center; }
.grow { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.prow { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }

.bar { flex: 1; background: var(--line); border-radius: 999px; height: 14px; position: relative; overflow: hidden; }
.bar-in { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; color: #555; font-weight: 600;
}

/* 任务卡 */
.task-list, .cards { display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex; gap: 12px; align-items: flex-start; background: var(--card);
  border-radius: var(--radius); padding: 14px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(28,35,51,.04); transition: opacity .2s;
}
.check {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #c7cdea; display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: #fff; margin-top: 2px;
}
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task.done { opacity: .72; }
.task-body { flex: 1; }
.task-title { font-weight: 600; font-size: 0.98rem; margin-bottom: 4px; }
.task-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag {
  background: #eef2ff; color: var(--accent); font-size: 0.72rem;
  padding: 2px 8px; border-radius: 999px;
}

/* 周 / 全部 */
.sec-title { font-size: 1rem; margin: 4px 0 12px; color: var(--muted); }
.weeks, .day-groups { display: flex; flex-direction: column; gap: 12px; }
.week-card, .day-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 4px 14px rgba(28,35,51,.04);
}
.week-head, .day-head { font-weight: 600; margin-bottom: 12px; }
.week-head { font-size: 1rem; }
.day-head { font-size: 0.9rem; color: var(--muted); }
.week-card .bar { margin-bottom: 4px; }

.empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: 0.95rem; }
.empty.tiny { padding: 8px 0; font-size: 0.85rem; }

/* AI 对话 */
.chat-log {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 46vh; overflow-y: auto; padding: 4px 2px 12px;
}
.msg {
  max-width: 84%; padding: 10px 13px; border-radius: var(--radius);
  font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant {
  align-self: flex-start; background: var(--card);
  border: 1px solid var(--line); border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(28,35,51,.04);
}
.chat-empty {
  align-self: flex-start; text-align: left; padding: 6px 0;
  max-width: 92%; font-size: 0.88rem; line-height: 1.6;
}
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.chat-input-row textarea {
  flex: 1; resize: none; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 0.98rem; font-family: inherit;
  max-height: 120px; background: var(--card);
}
.chat-input-row textarea:focus { outline: 2px solid #e7ecff; border-color: var(--accent); }
.chat-input-row button {
  padding: 11px 16px; border: 0; border-radius: 12px; background: var(--accent);
  color: #fff; font-size: 0.95rem; cursor: pointer; flex-shrink: 0;
}
.chat-input-row button:disabled { opacity: .5; cursor: not-allowed; }
.chat-input-row button:active { background: var(--accent-dark); }
.chat-input-row button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* 每日记录时间线 */
.note-groups { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 4px 14px rgba(28,35,51,.04);
}
.note-date { font-weight: 600; font-size: 0.9rem; color: var(--muted); margin-bottom: 10px; }
.note-list { display: flex; flex-direction: column; gap: 8px; }
.note-item {
  font-size: 0.95rem; line-height: 1.55; padding: 8px 10px 8px 14px;
  border-left: 3px solid var(--accent); background: #f7f8fd; border-radius: 6px;
}
