:root {
  --bg: #0c0f11;
  --panel: #14191c;
  --panel-2: #1a2126;
  --line: #242d33;
  --text: #e9eff2;
  --muted: #87979f;
  --accent: #35c8dc;
  --accent-soft: rgba(53, 200, 220, 0.13);
  --warn: #e2b85c;
  --ok: #6fd08c;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* 整页禁掉「双击放大」，但保留两指捏合放大 */
html { touch-action: manipulation; }

/* 手机双击不放大：按钮、筛选、锁屏都不吃双击手势 */
button, .chip, input, select, textarea { touch-action: manipulation; }

/* 上锁时只露锁屏，页面骨架整个不显示 */
body.locked .shell { display: none; }

body.locked { touch-action: manipulation; }

#lock {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 28px 18px calc(28px + env(safe-area-inset-bottom));
}

body.locked #lock { display: flex; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(53, 200, 220, 0.10), transparent 62%),
    radial-gradient(900px 460px at 92% 4%, rgba(53, 200, 220, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }

.live {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  margin-top: 4px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.live.on {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(53, 200, 220, 0.55);
  animation: pulse 2.4s ease-out infinite;
}

.live.off { background: var(--warn); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53, 200, 220, 0.5); }
  70% { box-shadow: 0 0 0 9px rgba(53, 200, 220, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 200, 220, 0); }
}

.brand-text { min-width: 0; }

h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

#today {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.stamp {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  padding-top: 4px;
  white-space: nowrap;
}

/* ---------- 概览 ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px 12px;
}

.stat b {
  display: block;
  font-size: 27px;
  font-weight: 600;
  line-height: 1.15;
  font-family: "Cascadia Mono", Consolas, monospace;
  letter-spacing: -0.5px;
}

.stat span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.stat.accent b { color: var(--accent); }

/* ---------- 按人筛选 ---------- */

.people {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  margin-bottom: 4px;
  scrollbar-width: none;
}

.people::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.chip i {
  font-style: normal;
  font-size: 11.5px;
  opacity: 0.72;
  margin-left: 3px;
}

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

.chip.on {
  background: var(--accent-soft);
  border-color: rgba(53, 200, 220, 0.45);
  color: var(--accent);
}

/* ---------- 视图切换 ---------- */

.views {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.views .spacer { flex: 1; }

.seg {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  line-height: 1;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

.seg button.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.seg.small button { padding: 6px 10px; font-size: 12.5px; }

/* ---------- 日程 ---------- */

.day { margin-bottom: 16px; }

/* 前天及更早：顶部折叠，默认收起 */
.fold-earlier {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.018);
  overflow: hidden;
}

.fold-earlier > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.fold-earlier > summary::-webkit-details-marker { display: none; }

.fold-earlier > summary::before {
  content: "▸";
  margin-right: 6px;
  font-size: 10px;
  opacity: 0.6;
  transition: transform 0.16s ease;
}

.fold-earlier[open] > summary::before { transform: rotate(90deg); }

.fold-earlier > summary > span:first-child { flex: 1; }

/* 展开后和正常日程一样：一天一组，行里只留时间 */
.fold-body {
  padding: 12px 14px 4px;
  border-top: 1px solid var(--line);
}

.fold-earlier .day { margin-bottom: 14px; }
.fold-earlier .day:last-child { margin-bottom: 2px; }
.fold-earlier .items {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 8px;
  font-size: 12px;
  color: var(--muted);
}

.day-head b {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}

.day-head.today b { color: var(--accent); }

.items {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.sched {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  column-gap: 10px;
  row-gap: 3px;
  align-items: baseline;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}

.sched:last-child { border-bottom: 0; }

.sched-time {
  grid-row: 1;
  grid-column: 1;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
}

.sched-title {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
  font-size: 14.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* 右边的「完成 / 逾期完成」 */
.sched-state {
  grid-row: 1;
  grid-column: 3;
  align-self: start;
  color: var(--ok);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.sched-meta {
  grid-row: 2;
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.sched-owner {
  color: #b6c4ca;
  background: rgba(255, 255, 255, 0.045);
  border-radius: 5px;
  padding: 1px 6px;
}

/* 已完成：变淡、打勾，垫在当天最后 */
/* 已完成：只把内容变淡，右边绿字保持醒目 */
.sched.done .sched-time,
.sched.done .sched-title,
.sched.done .sched-meta { opacity: 0.55; }
.sched.done .sched-title { color: var(--muted); }

.sched-check {
  margin-left: 6px;
  color: var(--ok);
  font-size: 13px;
}

.sched-doneat {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.85;
}

.sched-project {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 项目卡片 ---------- */

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

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card.is-archived { opacity: 0.55; }

.card-head { padding: 15px 16px 13px; }

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: anywhere;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.tag {
  font-size: 11.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}

.tag.type { color: var(--accent); border-color: rgba(53, 200, 220, 0.28); }
.tag.due { color: var(--warn); border-color: rgba(226, 184, 92, 0.28); }

.count {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  padding-top: 3px;
}

.progress {
  display: block;
  width: 100%;
  height: 3px;
  margin-top: 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  appearance: none;
  -webkit-appearance: none;
}

.progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.07); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; opacity: 0.85; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* ---------- 任务行 ---------- */

.tasks { border-top: 1px solid var(--line); }

.task {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 3px 12px;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}

.task:last-child { border-bottom: 0; }

.task-title {
  flex: 1 1 190px;
  font-size: 14.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  min-width: 0;
}

.task-meta {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  white-space: nowrap;
}

.task-meta .who {
  font-family: inherit;
  color: #b6c4ca;
  background: rgba(255, 255, 255, 0.045);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
}

.task-meta .when.is-today { color: var(--accent); }

.empty {
  padding: 13px 16px;
  color: var(--muted);
  font-size: 13.5px;
  border-top: 1px solid var(--line);
}

/* ---------- 已完成 ---------- */

.done {
  border-top: 1px solid var(--line);
}

.done summary {
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
}

.done summary::-webkit-details-marker { display: none; }
.done summary::after { content: "▾"; opacity: 0.6; }
.done[open] summary::after { content: "▴"; }

.done ul { margin: 0; padding: 0 16px 12px; list-style: none; }

.done li {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
  text-decoration: line-through;
  text-decoration-color: rgba(135, 151, 159, 0.4);
  word-break: break-word;
}

/* ---------- 其他状态 ---------- */

.loading, .error, .noresult {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.error { color: var(--warn); }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

#hint { font-family: "Cascadia Mono", Consolas, monospace; }

@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat b { font-size: 23px; }
  h1 { font-size: 19px; }
}

@media (min-width: 700px) {
  .shell { padding-top: 32px; }
  h1 { font-size: 23px; }
}
