:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #16202e;
  --ink-2: #5b6879;
  --ink-3: #93a0b1;
  --line: #e6ebf2;
  --brand: #2f6fed;
  --brand-soft: #e8f0ff;
  --danger: #e5484d;
  --ok: #0aa06e;
  --warn: #e0742a;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 22px; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

.icon-btn {
  border: 0; background: var(--bg); color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 10px; font-size: 18px; line-height: 1;
}

/* 今日概览条 */
.today-strip {
  display: flex; align-items: center; gap: 6px;
  margin: 10px 0 8px; padding: 8px 6px;
  background: linear-gradient(135deg, #f0f5ff, #f7f9ff);
  border-radius: var(--radius);
}
.ts-item { display: flex; flex-direction: column; align-items: center; min-width: 46px; }
.ts-num { font-size: 18px; font-weight: 800; color: var(--brand); line-height: 1.1; }
.ts-item.warn .ts-num { color: var(--warn); }
.ts-item.ok .ts-num { color: var(--ok); }
.ts-lbl { font-size: 10px; color: var(--ink-3); }
.ts-progress { flex: 1; display: flex; align-items: center; gap: 6px; padding-left: 4px; }
.ts-bar { flex: 1; height: 6px; border-radius: 99px; background: #e2e8f2; overflow: hidden; }
.ts-bar i { display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), #5b9dff); transition: width .3s; }

/* 快速添加 */
.quick-add { display: flex; gap: 8px; }
.quick-add input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); background: var(--bg);
  border-radius: 11px; padding: 9px 11px; font-size: 14px; color: var(--ink);
  outline: none;
}
.quick-add input:focus { border-color: var(--brand); background: #fff; }
.primary-btn {
  border: 0; border-radius: 11px; padding: 0 16px; height: 38px;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
}
.primary-btn:active { transform: scale(.97); }
.primary-btn.block { width: 100%; height: 44px; margin-top: 6px; font-size: 15px; }

/* 视图切换 */
.viewtabs { display: flex; gap: 6px; margin: 10px 0 8px; }
.vt {
  flex: 1; border: 0; border-radius: 9px; padding: 7px 0;
  background: var(--bg); color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.vt.active { background: var(--brand); color: #fff; }

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 6px; }
.ghost-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 9px; padding: 6px 10px; font-size: 13px;
}
.cur-label { flex: 1; text-align: center; font-weight: 700; font-size: 14px; }
.search-wrap { display: none; }
.search-wrap.show { display: block; }
.search-wrap input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 9px; font-size: 13px; outline: none;
}

/* 分类筛选 */
.filters { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); border-radius: 99px; padding: 4px 11px; font-size: 12px;
}
.fchip.active { color: #fff; border-color: transparent; }

/* ---------- 主区 ---------- */
main { padding: 10px 10px calc(84px + var(--safe-b)); }
.view { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

/* 月视图 */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.cal-head div { text-align: center; font-size: 11px; color: var(--ink-3); padding: 3px 0; }
.cal-head div.we { color: #c2708a; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cell {
  position: relative; min-height: 46px; background: var(--card);
  border-radius: 9px; padding: 3px 2px 2px; overflow: hidden;
}
.cell.out { opacity: .35; }
.cell.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cell.sel { background: var(--brand-soft); }
.cell .d { font-size: 12px; font-weight: 700; text-align: center; color: var(--ink-2); }
.cell.today .d { color: var(--brand); }
.cell .dots { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; margin-top: 3px; }
.cell .dot { width: 5px; height: 5px; border-radius: 99px; }
.cell .mini { font-size: 9px; color: var(--ink-3); text-align: center; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 周视图 */
.week-grid { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 2px; overflow-x: auto; }
.wg-head { font-size: 10px; text-align: center; color: var(--ink-3); padding: 4px 0; background: var(--card); border-radius: 8px; }
.wg-head b { display: block; font-size: 13px; color: var(--ink); }
.wg-head.today b { color: var(--brand); }
.wg-hour { font-size: 10px; color: var(--ink-3); text-align: right; padding-right: 4px; height: 34px; background: var(--bg); }
.wg-cell { height: 34px; background: var(--card); border-bottom: 1px solid #f0f3f8; position: relative; }
.wg-cell.today { background: #f7faff; }
.wg-ev {
  position: absolute; left: 1px; right: 1px; z-index: 2;
  border-radius: 5px; color: #fff; font-size: 9px; padding: 1px 3px;
  overflow: hidden; line-height: 1.25;
}

/* 日视图 / 清单 */
.day-sec { background: var(--card); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
.sec-title { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; font-weight: 600; }
.ev-row {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 0; border-bottom: 1px solid #f2f5f9;
}
.ev-row:last-child { border-bottom: 0; }
.ev-time { width: 44px; flex: 0 0 44px; font-size: 12px; color: var(--ink-2); font-weight: 700; padding-top: 1px; }
.ev-bar { width: 3px; align-self: stretch; border-radius: 99px; min-height: 30px; }
.ev-main { flex: 1; min-width: 0; }
.ev-title { font-size: 14px; font-weight: 600; word-break: break-word; }
.ev-title.done { text-decoration: line-through; color: var(--ink-3); font-weight: 400; }
.ev-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { border-radius: 4px; padding: 1px 5px; font-size: 10px; color: #fff; }
.tag.p2 { background: var(--danger); }
.tag.p1 { background: var(--warn); }
.ev-check {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 99px;
  border: 2px solid var(--line); background: #fff; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff;
}
.ev-check.on { background: var(--ok); border-color: var(--ok); }
.ev-overdue .ev-time { color: var(--danger); }

.empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 34px 0; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 16px; bottom: calc(18px + var(--safe-b)); z-index: 25;
  width: 52px; height: 52px; border-radius: 99px; border: 0;
  background: var(--brand); color: #fff; font-size: 26px; line-height: 1;
  box-shadow: 0 8px 22px rgba(47,111,237,.34);
}
.fab:active { transform: scale(.94); }

/* ---------- 弹层 ---------- */
.sheet-mask { position: fixed; inset: 0; background: rgba(15,22,33,.42); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--card); border-radius: 18px 18px 0 0;
  max-height: 90vh; display: flex; flex-direction: column;
  animation: up .22s cubic-bezier(.2,.9,.3,1);
}
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: #dde3ec; margin: 8px auto 2px; }
.sheet-head { display: flex; align-items: center; padding: 6px 12px 10px; border-bottom: 1px solid var(--line); }
.sheet-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.text-btn { border: 0; background: none; color: var(--brand); font-size: 14px; padding: 4px 6px; }
.text-btn.danger { color: var(--danger); }
.sheet-body { overflow-y: auto; padding: 12px 14px calc(20px + var(--safe-b)); }

.nlp-hint {
  background: var(--brand-soft); color: #1c4fbf; font-size: 12px;
  border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; line-height: 1.6;
}
.field { display: block; margin-bottom: 11px; }
.fl { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; font-size: 15px; color: var(--ink); background: #fff; outline: none;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 6px 12px; font-size: 13px; color: var(--ink-2); }
.chip.active { color: #fff; border-color: transparent; }

/* 菜单面板 */
.menu-panel {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--safe-b)); z-index: 41;
  width: min(92vw, 380px); background: var(--card); border-radius: 16px;
  box-shadow: 0 14px 40px rgba(15,22,33,.2); overflow: hidden;
  animation: up .2s ease;
}
.menu-item {
  display: block; width: 100%; text-align: left; border: 0; background: #fff;
  padding: 14px 16px; font-size: 14px; color: var(--ink);
  border-bottom: 1px solid var(--line); text-decoration: none; cursor: pointer;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item:active { background: var(--bg); }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + var(--safe-b)); z-index: 60;
  background: rgba(22,32,46,.92); color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 10px; max-width: 86vw; text-align: center;
}
