/* 手机优先。一套控件走到底：按钮只有三种、芯片只有一种、面板只有一种。
   所有可点的东西不小于 40px。 */
:root {
  --bg: #fdf8f9;
  --card: #ffffff;
  --ink: #322a2d;
  --ink-2: #6f6166;
  --ink-3: #a3949a;
  --line: #f0e6e9;
  --line-2: #e6d9de;
  --accent: #e0698a;
  --accent-weak: #fdeef2;
  --new: #2f8f6a;
  --paper: #3f7fbf;
  --quiz: #8a63c9;
  --drill: #c9803a;
  --recite: #b8763f;
  --review: #3f9f9f;
  --lost: #9a8f92;
  --custom: #6f7fa8;
  --danger: #c0392b;
  --r: 16px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(120, 80, 95, .06), 0 6px 16px -12px rgba(120, 80, 95, .25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { padding-bottom: 78px; }
body.sheet-open { overflow: hidden; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 14px; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  background: rgba(255, 246, 248, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
#topbar .brand { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
#topbar .term { margin-left: auto; font-size: 12px; color: var(--ink-3); }
#syncDot { width: 8px; height: 8px; border-radius: 50%; background: #d8ccd0; flex: none; transition: background .2s; }
#syncDot.on { background: var(--new); }
#syncDot.err { background: var(--danger); }
#syncDot.busy { background: var(--drill); }

/* ---------- 底部标签 ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
#tabs button {
  flex: 0 1 180px; padding: 11px 4px 13px;
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--ink-3);
  transition: color .15s;
}
#tabs button.active { color: var(--accent); font-weight: 600; }
.badge {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 4px;
  background: var(--accent); color: #fff; border-radius: 9px;
  font-size: 11px; line-height: 17px; font-weight: 600;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--r);
  padding: 14px 16px; margin: 10px 0; box-shadow: var(--shadow);
}
.section-title { margin: 20px 2px 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.mini-empty { color: var(--ink-3); font-size: 14px; padding: 2px 0; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--ink-3); font-size: 15px; }
.hint { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

/* ---------- 控件 ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  font: inherit; font-size: 14.5px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f0d7d3; }
.btn.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

input[type="text"], input[type="date"], input[type="time"], textarea, select {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 10px 12px; font: inherit; font-size: 15px; color: var(--ink);
  background: #fff; transition: border-color .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #c6b8bd; }
textarea { resize: vertical; min-height: 66px; line-height: 1.5; }
input[type="checkbox"] { width: 21px; height: 21px; accent-color: var(--accent); flex: none; margin: 2px 0 0; }

/* ---------- 日期头 ---------- */
.dayhead { display: flex; align-items: center; gap: 10px; margin: 18px 0 4px; }
.dayhead .d { font-size: 21px; font-weight: 700; letter-spacing: .3px; }
.dayhead .w { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.dayhead .nav { margin-left: auto; display: flex; gap: 6px; }
.dayhead .nav button {
  width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: #fff; font-size: 17px; color: var(--ink-2); cursor: pointer;
}
.dayhead .nav button:active { background: var(--accent-weak); }

/* ---------- 今天的时间线 ---------- */
.timeline { margin-top: 12px; }
.tl-item { position: relative; }
.card.period, .card.todo-card { position: relative; padding-right: 52px; }
.card.period .head, .card.todo-card .head { display: flex; align-items: baseline; gap: 8px; }
.card .name { font-size: 16px; font-weight: 650; }
.card .time { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.card .subject {
  margin-left: auto; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-weak);
}
.card .subject.other { color: var(--paper); background: #eaf1f9; }
.card.period.meeting { background: #faf8f9; box-shadow: none; padding: 12px 16px; }
.card.period.meeting .name { font-weight: 500; color: var(--ink-2); font-size: 14px; }

.check {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--line-2); background: #fff;
  color: #fff; font-size: 15px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, transform .1s;
}
.check:active { transform: scale(.9); }
.card.is-done .check { background: var(--accent); border-color: var(--accent); }
.card.is-done { background: #fdfbfc; }
.card.is-done .head .name { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
/* 勾上就折叠：正文收起来，只剩标题那行 */
.card.is-done .body { display: none; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill {
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: #f3f0f2; color: var(--ink-2);
}
.pill.t-new { background: #e7f4ee; color: var(--new); }
.pill.t-paper { background: #e9f1fa; color: var(--paper); }
.pill.t-quiz { background: #f1ebfb; color: var(--quiz); }
.pill.t-drill { background: #fdf1e4; color: var(--drill); }
.pill.t-recite { background: #fdf0e8; color: var(--recite); }
.pill.t-review { background: #e6f5f5; color: var(--review); }
.pill.t-lost { background: #f2f0f1; color: var(--lost); }
.pill.t-custom { background: #eef0f7; color: var(--custom); }

.note { margin-top: 9px; font-size: 14.5px; color: var(--ink-2); white-space: pre-wrap; }
ul.plain { list-style: none; margin: 10px 0 0; padding: 0; }
ul.plain li { display: flex; gap: 7px; padding: 3px 0; font-size: 14.5px; color: var(--ink-2); }
ul.plain li .mark { color: var(--accent); font-size: 12px; line-height: 1.6; }
ul.plain li.done { color: var(--ink-3); text-decoration: line-through; }

.hw-block { margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--line); }
.hw-label { display: inline-block; margin-bottom: 4px; font-size: 11px; font-weight: 600; color: var(--drill); }
.hw-item { font-size: 14.5px; color: var(--ink-2); padding: 1px 0; }

/* ---------- 本周 ---------- */
.weeknav { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; }
.weeknav .t { font-size: 18px; font-weight: 700; }
.weeknav .r { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.weeknav .nav { margin-left: auto; display: flex; gap: 6px; }
.weeknav .nav button {
  height: 38px; min-width: 38px; padding: 0 10px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: #fff; font: inherit; font-size: 15px; color: var(--ink-2); cursor: pointer;
}
.weeknav .nav .todaybtn { font-size: 13px; color: var(--accent); border-color: var(--accent-weak); background: var(--accent-weak); font-weight: 600; }

.budget { padding: 0; overflow: hidden; }
.budget-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left;
}
.budget-head .verdict { font-size: 15px; font-weight: 650; }
.budget-head .verdict.tight { color: var(--accent); }
.budget-head .verdict.ok { color: var(--new); }
.budget-head .chev { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }
.budget-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.budget-body .plan { margin: 12px 0 8px; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.budget-body .nums { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.budget-body .nums b { color: var(--ink); }
.budget-body .adj { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.budget-body .adj button {
  width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; cursor: pointer; line-height: 1; color: var(--ink-2);
}

.weekscroll {
  margin: 4px -14px 0; padding: 12px 14px 4px;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.weekrow { display: flex; gap: 10px; }
.daycol { flex: 0 0 152px; scroll-snap-align: start; }
.daycol.today .dayhead-col .wd { color: var(--accent); }
.dayhead-col { display: flex; align-items: center; gap: 6px; padding: 0 2px 8px; }
.dayhead-col .wd { font-size: 13px; font-weight: 650; }
.dayhead-col .dd { font-size: 12px; color: var(--ink-3); }
.dayhead-col .nowtag {
  margin-left: auto; padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-weak);
}

.pcell {
  display: block; width: 100%; margin-bottom: 8px; padding: 10px 11px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
  font: inherit; text-align: left; cursor: pointer;
  transition: transform .08s, border-color .15s;
}
.pcell:active { transform: scale(.98); }
.pcell .pt { display: block; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pcell .pn { display: block; margin-top: 1px; font-size: 14.5px; font-weight: 600; }
.pcell .ptag { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #f3f0f2; color: var(--ink-2); }
.pcell .ptag.other { background: #eef0f4; color: var(--ink-3); }
.pcell .pnote { display: block; margin-top: 6px; font-size: 12.5px; color: var(--ink-2);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pcell .pmini { display: block; margin-top: 5px; font-size: 11.5px; color: var(--ink-3); }
.pcell.meeting { background: #faf8f9; border-style: dashed; cursor: default; }
.pcell.meeting .pn { font-weight: 500; color: var(--ink-2); font-size: 13.5px; }
.pcell.meeting .ptag { background: #eef0f4; color: var(--ink-3); }
.pcell.t-new .ptag { background: #e7f4ee; color: var(--new); }
.pcell.t-paper .ptag { background: #e9f1fa; color: var(--paper); }
.pcell.t-quiz .ptag { background: #f1ebfb; color: var(--quiz); }
.pcell.t-drill .ptag { background: #fdf1e4; color: var(--drill); }
.pcell.t-recite .ptag { background: #fdf0e8; color: var(--recite); }
.pcell.t-review .ptag { background: #e6f5f5; color: var(--review); }
.pcell.t-lost .ptag { background: #f2f0f1; color: var(--lost); }
.pcell.t-custom .ptag { background: #eef0f7; color: var(--custom); }
.pcell.is-done { opacity: .55; }
.pcell.is-done .pn { text-decoration: line-through; }

/* ---------- 列表行（待办 / 面板里的小列表） ---------- */
.rows { margin-top: 2px; }
.row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-text { flex: 1; font-size: 15px; line-height: 1.5; min-width: 0; }
.row-text.done { color: var(--ink-3); text-decoration: line-through; }
.row-del {
  flex: none; border: 0; background: none; color: #cdbfc4; font-size: 18px;
  line-height: 1; padding: 2px 4px; cursor: pointer;
}
.row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); margin: 8px 7px 0; flex: none; }
.row .from { margin-left: 6px; font-size: 11.5px; color: var(--ink-3); }
.row .rownote { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.row-add { display: flex; gap: 8px; margin-top: 10px; }
.row-add .btn { flex: none; }
.date-head { padding: 12px 0 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.date-head:first-child { padding-top: 2px; }
.nowtag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-weak); }

.collapse-head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 0; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink-2);
  text-align: left; cursor: pointer;
}
.collapse-head .chev { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }
.card.hw-card { padding: 14px 16px; }
.card.hw-card .hw-count { margin-left: 8px; font-size: 12px; color: var(--ink-3); }
.hw-detail { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.hw-group + .hw-group { margin-top: 10px; }
.hw-where { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 2px; }
.hw-card .hw-item { font-size: 14.5px; color: var(--ink-2); padding: 2px 0; }

/* ---------- 我的 ---------- */
.row-line { display: flex; align-items: center; padding: 7px 0; font-size: 14px; color: var(--ink-2); }
.row-line b { margin-left: auto; color: var(--ink); }
.setting-row { margin-top: 12px; }
.setting-row label { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- 浮动加号 ---------- */
.fab {
  position: fixed; right: max(18px, calc(50% - 320px + 18px)); bottom: calc(74px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff; font-size: 27px; line-height: 1;
  box-shadow: 0 6px 18px -6px rgba(224, 105, 138, .7);
  cursor: pointer; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.fab:active { transform: scale(.92); }

/* ---------- 底部面板 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(50, 42, 45, .35);
  opacity: 0; transition: opacity .2s;
}
.sheet-wrap.show .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0;
  transform: translateY(100%); transition: transform .24s cubic-bezier(.22, .8, .3, 1);
  box-shadow: 0 -8px 32px -12px rgba(80, 40, 55, .35);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-wrap.show .sheet { transform: translateY(0); }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 9px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 16px 10px; flex: none; }
.sheet-title { font-size: 16px; font-weight: 700; }
.sheet-close {
  margin-left: auto; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: #f1eaec; color: var(--ink-2); font-size: 14px; cursor: pointer;
}
.sheet-body { padding: 2px 16px 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px 16px 16px; flex: none; border-top: 1px solid var(--line); background: var(--bg); }
@media (min-width: 560px) {
  .sheet { left: 50%; transform: translate(-50%, 100%); width: 520px; border-radius: 22px 22px 0 0; }
  .sheet-wrap.show .sheet { transform: translate(-50%, 0); }
}

.panel-sec { margin-bottom: 18px; }
.panel-sec.two { display: flex; gap: 10px; }
.panel-sec.two > div { flex: 1; }
.panel-label { margin-bottom: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  font: inherit; font-size: 13.5px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.chip:active { transform: scale(.96); }
.chip.on { color: #fff; border-color: transparent; font-weight: 600; background: var(--ink-2); }
.chip.on.t-new { background: var(--new); }
.chip.on.t-paper { background: var(--paper); }
.chip.on.t-quiz { background: var(--quiz); }
.chip.on.t-drill { background: var(--drill); }
.chip.on.t-recite { background: var(--recite); }
.chip.on.t-review { background: var(--review); }
.chip.on.t-lost { background: var(--lost); }
.chip.on.t-custom { background: var(--custom); }
.chip-add { border-style: dashed; color: var(--accent); border-color: #f2d3dc; background: var(--accent-weak); }
.newtype { display: flex; gap: 8px; margin-top: 10px; }
.newtype[hidden] { display: none; }

/* ---------- 提示条 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(8px);
  max-width: 84vw; padding: 10px 16px; border-radius: 999px;
  background: rgba(50, 42, 45, .94); color: #fff; font-size: 14px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 700px) {
  body { font-size: 15px; }
  .wrap { max-width: 720px; }
}
