/* calendar-app — 移动优先，自动深色模式 */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1c2430;
  --text-2: #6b7686;
  --line: #e4e8ee;
  --accent: #4a90d9;
  --accent-text: #ffffff;
  --danger: #d9534f;
  --chip-text: #ffffff;
  --today: #eaf3fd;
  --holiday: #d9534f;
  --shadow: 0 1px 4px rgba(16, 32, 56, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151c;
    --panel: #1a222c;
    --text: #e6ebf2;
    --text-2: #8a94a3;
    --line: #2a3441;
    --accent: #4a90d9;
    --today: #22303f;
    --shadow: 0 1px 4px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100dvh; overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--text-2); font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; }
.icon-btn {
  background: transparent; border: none; color: var(--text);
  font-size: 24px; line-height: 1; padding: 6px 10px; border-radius: 8px;
}

/* 登录 */
.login {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); border-radius: 18px;
  padding: 36px 28px; box-shadow: var(--shadow); text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { font-size: 44px; }
.login-sub { margin: 0; color: var(--text-2); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; margin: 0; }

/* 主界面 */
#view-main { padding-bottom: 70px; }
.tab-page { padding: 12px 12px 0; max-width: 760px; margin: 0 auto; }
.cal-header { display: flex; align-items: center; gap: 6px; padding: 4px 0 10px; }
.cal-header h1 { flex: 1; font-variant-numeric: tabular-nums; cursor: pointer; }
.page-header { padding: 8px 0 12px; }
.wknd { color: var(--holiday); }
.week-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; color: var(--text-2); font-size: 12px; padding: 2px 0 6px;
}

/* 月网格 */
#month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--panel); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.cell {
  min-height: 64px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 4px 4px 2px; overflow: hidden; position: relative; cursor: pointer;
}
.cell:nth-child(7n) { border-right: none; }
.cell .d {
  font-size: 13px; text-align: center; width: 22px; height: 22px; line-height: 22px;
  border-radius: 50%; margin: 0 auto 3px; color: var(--text);
}
.cell.wknd .d { color: var(--holiday); }
.cell.today .d { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cell.dim { background: color-mix(in srgb, var(--panel) 55%, var(--bg)); }
.cell.dim .d { color: var(--text-2); }
.cell .d.holiday { color: var(--holiday); font-weight: 600; }
.chip {
  font-size: 11px; line-height: 1.25; border-radius: 5px; padding: 1px 5px 1px 6px;
  margin: 2px 0; color: var(--chip-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.cont::before { content: "…"; opacity: .8; }
.more { font-size: 10px; color: var(--text-2); padding-left: 6px; }
.legend {
  display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 10px 4px 4px;
  font-size: 12px; color: var(--text-2);
}
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.item {
  background: var(--panel); border-radius: 12px; padding: 12px 14px;
  box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
}
.item .bar { width: 4px; border-radius: 2px; align-self: stretch; flex: none; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t.done { text-decoration: line-through; color: var(--text-2); }
.item .meta { font-size: 12px; color: var(--text-2); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.item .note { font-size: 13px; color: var(--text-2); margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.item .ops { display: flex; flex-direction: column; gap: 6px; flex: none; }
.item .ops .btn { padding: 5px 10px; font-size: 12px; }
.empty { text-align: center; color: var(--text-2); padding: 40px 0; font-size: 14px; }

/* 搜索 */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input { flex: 1; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--line);
  display: flex; z-index: 30;
}
.tab {
  flex: 1; background: none; border: none; color: var(--text-2);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tab .t-ico { font-size: 20px; }
.tab.active { color: var(--accent); font-weight: 600; }

/* 抽屉与模态 */
.sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.sheet-panel, .modal-panel {
  position: fixed; z-index: 41; background: var(--panel);
  left: 0; right: 0; bottom: 0; max-height: 86dvh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.modal-panel { max-width: 560px; margin: 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; color: var(--text); font-size: 17px; }

/* 分类胶囊 */
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip {
  border: 1.5px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.cat-chip.sel { border-color: var(--accent); background: var(--today); font-weight: 600; }
.cat-chip .dot { width: 10px; height: 10px; border-radius: 50%; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.row label.chk { flex: none; flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.row label.chk input { width: auto; }
.grow { flex: 1; }

/* 设置 */
.settings { display: flex; flex-direction: column; gap: 14px; padding-bottom: 16px; }
.card { background: var(--panel); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.card input { margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--text-2); margin: 0; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.cat-row input[type=color] { width: 34px; height: 30px; padding: 2px; border-radius: 8px; flex: none; }
.cat-row .name { flex: 1; font-size: 14px; }
.cat-row .count { font-size: 12px; color: var(--text-2); }
.cat-row input[type=checkbox] { width: auto; }

/* Toast */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 26, 34, .92); color: #fff; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; z-index: 60; max-width: 80vw;
}
