/* ============================================================
   今日待办 · 样式
   移动端优先，单列居中，兼容刘海屏安全区
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #151b2d;
  --muted: #6d7791;
  --line: #e7ebf5;
  --accent: #4557d6;
  --accent-deep: #3545bb;
  --accent-soft: #eceffe;
  --ok: #0e9f6e;
  --danger: #d94a4a;

  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-sm: 0 1px 2px rgba(21, 27, 45, .05), 0 6px 18px rgba(21, 27, 45, .05);
  --shadow-md: 0 10px 30px rgba(21, 27, 45, .09);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 60% at 50% 0%, #ffffff 0%, rgba(255,255,255,0) 60%),
    linear-gradient(170deg, #f7f9fd 0%, #eef1fa 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 视图切换 ---------- */
.view { display: none; }
.view.is-active { display: block; }

/* ---------- 通用控件 ---------- */
input, button, textarea { font-family: inherit; font-size: 16px; }

.btn {
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  transition: transform .12s var(--ease), background-color .18s, opacity .18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(69, 87, 214, .28);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #4f61e0 0%, #3a4bc6 100%); }

.btn-block { width: 100%; height: 50px; }

.btn-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .18s, border-color .18s, background-color .18s;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover { color: var(--danger); border-color: #f3cccc; background: #fff7f7; }

.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 8px;
  transition: color .18s;
}
.link-btn:hover { color: var(--danger); }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.form-error {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger);
}

/* ---------- 登录页 ---------- */
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: max(48px, calc(env(safe-area-inset-top) + 40px)) 20px
           calc(32px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.brand { text-align: center; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(150deg, #5b6cec 0%, #3a49c4 100%);
  box-shadow: 0 10px 24px rgba(69, 87, 214, .32);
}

.brand-title {
  margin: 0;
  font-size: 26px;
  letter-spacing: .5px;
  font-weight: 700;
}

.brand-sub {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.auth-card { padding: 22px 20px 20px; box-shadow: var(--shadow-md); }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: #f2f4fa;
  border-radius: 12px;
}

.seg-btn {
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s, box-shadow .2s;
}
.seg-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(21, 27, 45, .1);
}

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfcfe;
  color: var(--text);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background-color .18s;
}
.field input::placeholder { color: #a8b0c4; }
.field input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(69, 87, 214, .13);
}

#auth-submit { margin-top: 6px; }

.auth-hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.local-note {
  margin: 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: #97a0b8;
  padding: 0 12px;
}

/* ---------- 主界面 ---------- */
.app-shell {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px
           calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 2px;
}

.greeting {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .3px;
}

.today {
  margin: 5px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .2px;
}

.account-box { display: flex; align-items: center; gap: 8px; }

.account-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

/* 统计卡 */
.stat-card {
  padding: 18px 18px 16px;
  background: linear-gradient(140deg, #4d5fdb 0%, #35429f 100%);
  box-shadow: 0 12px 26px rgba(53, 66, 159, .25);
  color: #fff;
}

.stat-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.stat-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, .72);
}

.stat-value {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-unit { font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, .78); }

.stat-ratio {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, .78);
  font-variant-numeric: tabular-nums;
}

.progress {
  height: 7px;
  margin-top: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #ffffff;
  transition: width .38s var(--ease);
}

/* 输入区 */
.composer { padding: 12px; }

.composer-row { display: flex; gap: 10px; align-items: center; }

.composer-input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: #f5f7fc;
  color: var(--text);
  outline: none;
  transition: border-color .18s, background-color .18s, box-shadow .18s;
}
.composer-input::placeholder { color: #a3abc0; }
.composer-input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(69, 87, 214, .12);
}
.composer-input.is-invalid {
  border-color: var(--danger);
  background: #fffafa;
  animation: shake .3s var(--ease);
}

.btn-add {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  color: #fff;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 0;
}

.tabs { display: flex; gap: 6px; }

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .18s, color .18s, border-color .18s;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--surface);
  color: var(--accent);
  border-color: #dfe4f7;
  box-shadow: 0 1px 3px rgba(21, 27, 45, .06);
}

/* 列表 */
.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 12px 14px 14px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s, opacity .25s, transform .25s var(--ease);
  animation: item-in .28s var(--ease) both;
}

@keyframes item-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.todo-item.is-entering { animation: item-in .28s var(--ease) both; }

.todo-item.is-removing {
  opacity: 0;
  transform: translateX(28px) scale(.97);
}

.todo-item:hover { border-color: #e2e7f6; }

/* 勾选框 */
.check {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid #cfd6e8;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: border-color .18s, background-color .18s, transform .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.check:active { transform: scale(.9); }
.check::after {
  content: "";
  width: 5px;
  height: 10px;
  margin-top: -2px;
  border-right: 2.4px solid #fff;
  border-bottom: 2.4px solid #fff;
  transform: rotate(42deg) scale(0);
  transition: transform .18s var(--ease);
}
.check:hover { border-color: var(--accent); }

.todo-item.is-done .check {
  background: var(--ok);
  border-color: var(--ok);
}
.todo-item.is-done .check::after { transform: rotate(42deg) scale(1); }

.todo-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 3px 0 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
  font-size: 15.5px;
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
}

.todo-item.is-done .todo-text {
  color: #98a1b6;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.todo-item.is-done { background: #fbfcfe; }

.del-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #98a2b6;
  cursor: pointer;
  transition: color .18s, background-color .18s;
  -webkit-tap-highlight-color: transparent;
}
.del-btn:hover { color: var(--danger); background: #fdf2f2; }

/* 空状态 */
.empty {
  text-align: center;
  padding: 30px 20px 22px;
  animation: item-in .3s var(--ease) both;
}
.empty-title { margin: 12px 0 0; font-size: 15px; font-weight: 600; }
.empty-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.app-footer {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  font-size: 12px;
  color: #a3aabd;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .18s, transform .12s;
}
.footer-link:hover { background: #e3e7fd; }
.footer-link:active { transform: scale(.97); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 40px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(21, 27, 45, .92);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 22px rgba(21, 27, 45, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(21, 27, 45, .38);
  opacity: 0;
  transition: opacity .2s var(--ease);
  z-index: 40;
}
.modal-mask[hidden] { display: none; }
.modal-mask.is-visible { opacity: 1; }

.modal-card {
  width: 100%;
  max-width: 360px;
  padding: 24px 22px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(21, 27, 45, .22);
  transform: translateY(8px) scale(.98);
  transition: transform .22s var(--ease);
}
.modal-mask.is-visible .modal-card { transform: none; }

.modal-title { margin: 0 0 10px; font-size: 17px; font-weight: 700; }
.modal-text { margin: 0 0 20px; font-size: 14px; line-height: 1.65; color: var(--muted); }
.modal-text strong { color: var(--accent); font-size: 16px; }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; height: 44px; font-size: 15px; }

.btn-ghost { background: #f2f4fa; color: var(--text); }
.btn-ghost:hover { background: #e9edf7; }

/* ---------- 桌面端微调 ---------- */
@media (min-width: 560px) {
  .app-shell { padding-top: 40px; gap: 16px; }
  .today { font-size: 24px; }
}

/* ---------- 无障碍 / 动效偏好 ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ============================================================
   天气卡
   ============================================================ */
.weather-card { padding: 0; overflow: hidden; }

.w-main {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.w-icon { font-size: 27px; line-height: 1; flex: 0 0 auto; }

.w-temp {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.w-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.w-text {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.w-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.w-city {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 10px;
  border-radius: 999px;
}

.w-advice {
  margin: 0;
  padding: 0 16px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}
.w-advice[hidden] { display: none; }

.w-days {
  border-top: 1px solid var(--line);
  padding: 6px 8px 10px;
}
.w-days[hidden] { display: none; }

.w-day {
  display: grid;
  grid-template-columns: 42px 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-size: 13px;
  border-radius: 10px;
}
.w-day + .w-day { border-top: 1px dashed #eef1f8; }

.wd-name { color: var(--muted); font-size: 12px; }
.wd-icon { font-size: 15px; }
.wd-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-range { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ============================================================
   统计补充行
   ============================================================ */
.stat-extra {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, .8);
}
.stat-sep { opacity: .5; }

/* ============================================================
   日历
   ============================================================ */
.calendar-card { padding: 14px 14px 12px; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-title { font-size: 14px; font-weight: 700; }
.cal-nav { display: flex; gap: 6px; }

.cal-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .18s, border-color .18s;
}
.cal-btn:hover { color: var(--accent); border-color: #dfe4f7; }

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.cal-week span { text-align: center; font-size: 11px; color: var(--muted); }

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

.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: #f6f8fd;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .16s, color .16s;
}
.cal-day.is-blank { background: transparent; cursor: default; }
.cal-day.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }
.cal-day.is-selected { background: var(--accent); color: #fff; }

.cal-day.has-task::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-day.is-selected.has-task::after { background: #fff; }
.cal-day.is-busy::after { width: 11px; border-radius: 999px; }

.cal-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.cal-detail-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cal-empty { margin: 0; font-size: 12.5px; color: #a3aabd; }

.cal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-item { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.cal-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.is-done .cal-text { color: #a3aabd; text-decoration: line-through; }
.cal-item.is-done .cal-dot { background: #c9d0e0; }

/* ============================================================
   专注计时
   ============================================================ */
.focus-card { max-width: 322px; text-align: center; }
.focus-mode-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 4px; }

.focus-ring {
  position: relative;
  width: 178px;
  height: 178px;
  margin: 6px auto 2px;
}
.focus-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.focus-track { fill: none; stroke: #eef1f8; stroke-width: 8; }
.focus-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset .3s linear;
}
.focus-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.focus-task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 14px;
  font-size: 13px;
}
.focus-task-row > span { color: var(--muted); flex: 0 0 auto; }
.focus-task-row select {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--text);
  font-size: 13px;
}

.focus-actions { display: flex; gap: 10px; }
.focus-actions .btn { flex: 1; height: 44px; font-size: 15px; }

.focus-modes { display: flex; gap: 6px; margin-top: 12px; }
.focus-mode {
  flex: 1;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.focus-mode.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #d6dcfa;
}

.focus-count { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.focus-close {
  margin-top: 8px;
  padding: 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

/* 城市选择 */
.city-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.city-item {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .16s, color .16s, border-color .16s;
}
.city-item.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 「自动定位」占满一行 */
.city-item.city-auto { grid-column: span 3; }

.footer-actions { display: flex; gap: 8px; }
