/* 日记 · 控制台 —— 白色纸面 + 朱砂红
   better-ui 规范：外圆角 = 内圆角 + padding；阴影分层、边框分结构；
   图标 currentColor；hover 仅在 hover-capable 指针下；浮层 overscroll contain。 */

:root {
  --paper: #fdfcf9;
  --paper-warm: #faf7f1;
  --ink: #2b2622;
  --ink-soft: #5c554e;
  --ink-faint: #9a9187;
  --line: #e8e2d9;
  --line-strong: #ddd4c6;
  --cinnabar: #c0392b;
  --cinnabar-soft: #f7e8e5;
  --green: #2e7d4f;
  --radius-card: 18px;      /* 外圆角 */
  --radius-inner: 10px;     /* 内圆角 = 18 - 8 padding */
  --shadow-card: 0 1px 2px rgba(60, 48, 32, .05), 0 8px 24px rgba(60, 48, 32, .06);
  --shadow-lift: 0 2px 4px rgba(60, 48, 32, .06), 0 14px 34px rgba(60, 48, 32, .10);
  --serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper-warm);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }
img { outline: 1px solid oklch(0.1 0 0 / .1); }

/* ---------- 通用按钮 ---------- */
.btn-primary {
  background: var(--cinnabar); color: #fff; border: none;
  padding: 10px 22px; border-radius: var(--radius-inner);
  font-size: 15px; font-weight: 600; letter-spacing: .02em;
  box-shadow: 0 2px 8px rgba(192, 57, 43, .28);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn-primary:active { transform: scale(.97); }
.btn-ghost {
  background: var(--paper); color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  padding: 8px 14px; border-radius: var(--radius-inner); font-size: 14px;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.btn-small {
  background: var(--paper); color: var(--cinnabar);
  border: 1px solid var(--cinnabar);
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.btn-danger-ghost {
  background: transparent; color: var(--cinnabar);
  border: 1px solid transparent; padding: 8px 12px;
  border-radius: var(--radius-inner); font-size: 14px;
}
@media (hover: hover) {
  .btn-primary:hover { background: #a93226; box-shadow: 0 4px 14px rgba(192, 57, 43, .34); }
  .btn-ghost:hover { color: var(--ink); border-color: var(--ink-faint); }
  .btn-small:hover { background: var(--cinnabar-soft); }
  .btn-danger-ghost:hover { border-color: var(--cinnabar); }
}
.form-error { color: var(--cinnabar); font-size: 13px; margin-top: 8px; }
.form-ok { color: var(--green); font-size: 13px; margin-top: 8px; }
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 20px; margin-bottom: 18px;
}
.card-title {
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  margin-bottom: 14px; color: var(--ink);
}

/* ---------- 登录页 ---------- */
.login-view {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(ellipse at 50% -10%, #f3e9dc 0%, var(--paper-warm) 55%);
}
.login-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 24px; box-shadow: var(--shadow-lift);
  padding: 40px 36px; width: 100%; max-width: 380px; text-align: center;
  animation: rise .45s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-seal, .brand-seal {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cinnabar); color: #fff; font-family: var(--serif); font-weight: 700;
  border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.login-seal { width: 54px; height: 54px; font-size: 28px; margin-bottom: 16px; }
.login-title { font-family: var(--serif); font-size: 26px; letter-spacing: .06em; }
.login-sub { color: var(--ink-faint); font-size: 13px; margin: 6px 0 22px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-inner);
  background: var(--paper-warm); font-size: 15px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-card input:focus { border-color: var(--cinnabar); box-shadow: 0 0 0 3px var(--cinnabar-soft); }
.login-card .btn-primary { width: 100%; }

/* ---------- 应用外壳 ---------- */
.app-view { display: flex; min-height: 100dvh; }
.sidebar {
  width: 208px; flex-shrink: 0; background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 14px;
  position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand-seal { width: 34px; height: 34px; font-size: 18px; border-radius: 7px; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 16px; letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: none; background: transparent;
  border-radius: var(--radius-inner); color: var(--ink-soft);
  font-size: 14.5px; text-align: left; width: 100%;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item.active { background: var(--cinnabar-soft); color: var(--cinnabar); font-weight: 600; }
.nav-item.logout { color: var(--ink-faint); }
@media (hover: hover) {
  .nav-item:hover { background: var(--paper-warm); color: var(--ink); }
  .nav-item.active:hover { background: var(--cinnabar-soft); color: var(--cinnabar); }
}
.main { flex: 1; min-width: 0; padding: 30px 34px 60px; max-width: 960px; margin: 0 auto; width: 100%; }
.view { display: none; }
.view.active { display: block; animation: fadein .3s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.view-title { font-family: var(--serif); font-size: 26px; letter-spacing: .04em; }

/* ---------- 写作 ---------- */
.write-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.big-date { font-family: var(--serif); font-size: clamp(30px, 5vw, 42px); font-weight: 800; letter-spacing: .02em; line-height: 1.15; }
.write-date-sub { color: var(--ink-faint); font-size: 13.5px; margin-top: 4px; }
.write-head-actions { display: flex; gap: 10px; align-items: center; }
.date-input {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-inner);
  background: var(--paper); font-size: 14px;
}
.prompt-card { border-left: 3px solid var(--cinnabar); padding: 16px 20px; }
.prompt-label { font-size: 12px; letter-spacing: .18em; color: var(--cinnabar); font-weight: 700; margin-bottom: 6px; }
.prompt-question { font-family: var(--serif); font-size: 17px; margin-bottom: 10px; }
.editor-card { padding: 22px; }
.title-input {
  width: 100%; border: none; outline: none; background: transparent;
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  padding: 4px 2px 12px; border-bottom: 1px dashed var(--line-strong);
}
.title-input::placeholder { color: var(--ink-faint); font-weight: 400; }
.editor-toolbar { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--paper-warm); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg-btn {
  border: none; background: transparent; padding: 5px 16px; border-radius: 7px;
  font-size: 13.5px; color: var(--ink-soft); transition: background .15s ease, color .15s ease;
}
.seg-btn.active { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(60,48,32,.12); }
.word-count { font-size: 13px; color: var(--ink-faint); }
.draft-status { font-size: 12.5px; color: var(--ink-faint); margin-left: auto; }
.content-input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper-warm); padding: 16px; resize: vertical;
  font-size: 15.5px; line-height: 1.85; outline: none; min-height: 320px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.content-input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(192,57,43,.07); background: var(--paper); }
.md-preview {
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper-warm);
  padding: 18px 20px; min-height: 320px; line-height: 1.85; font-size: 15.5px;
  overscroll-behavior: contain; overflow-wrap: break-word;
}
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 { font-family: var(--serif); margin: .9em 0 .4em; line-height: 1.4; }
.md-preview h1 { font-size: 24px; } .md-preview h2 { font-size: 20px; } .md-preview h3 { font-size: 17px; }
.md-preview p { margin: .55em 0; }
.md-preview ul, .md-preview ol { margin: .55em 0 .55em 1.5em; }
.md-preview blockquote { border-left: 3px solid var(--cinnabar); padding: 2px 0 2px 14px; color: var(--ink-soft); margin: .7em 0; }
.md-preview code { font-family: var(--mono); font-size: .88em; background: #f0eadf; padding: 1px 6px; border-radius: 5px; }
.md-preview pre { background: #2b2622; color: #f3ede2; padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: .7em 0; overscroll-behavior: contain; }
.md-preview pre code { background: transparent; padding: 0; color: inherit; }
.md-preview hr { border: none; border-top: 1px solid var(--line-strong); margin: 1.1em 0; }
.md-preview a { color: var(--cinnabar); }
.editor-meta { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 18px; }
.meta-group { display: flex; flex-direction: column; gap: 8px; }
.meta-group.grow { flex: 1; min-width: 200px; }
.meta-label { font-size: 12px; letter-spacing: .14em; color: var(--ink-faint); font-weight: 600; }
.mood-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mood-btn {
  border: 1px solid var(--line-strong); background: var(--paper);
  padding: 6px 11px; border-radius: 999px; font-size: 13px; color: var(--ink-soft);
  transition: all .15s ease;
}
.mood-btn.selected { background: var(--cinnabar-soft); border-color: var(--cinnabar); color: var(--cinnabar); font-weight: 600; }
@media (hover: hover) { .mood-btn:hover { border-color: var(--ink-faint); } }
.tags-input {
  border: 1px solid var(--line-strong); border-radius: var(--radius-inner);
  padding: 8px 12px; font-size: 14px; background: var(--paper); outline: none; width: 100%;
}
.tags-input:focus { border-color: var(--cinnabar); }
.toggle-row { display: flex; gap: 6px; }
.toggle-btn {
  border: 1px solid var(--line-strong); background: var(--paper);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; color: var(--ink-soft);
  transition: all .15s ease;
}
.toggle-btn.on { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff; font-weight: 600; }
.editor-actions { display: flex; align-items: center; margin-top: 20px; }
.spacer { flex: 1; }
.otd-item { padding: 12px 4px; border-bottom: 1px dashed var(--line); cursor: pointer; }
.otd-item:last-child { border-bottom: none; }
.otd-date { font-size: 12.5px; color: var(--cinnabar); font-weight: 600; }
.otd-title { font-family: var(--serif); font-weight: 700; margin: 2px 0; }
.otd-preview { color: var(--ink-soft); font-size: 13.5px; }

/* ---------- 日历 ---------- */
.month-nav { display: flex; align-items: center; gap: 12px; }
.month-label { font-family: var(--serif); font-size: 17px; font-weight: 700; min-width: 110px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { text-align: center; font-size: 12.5px; color: var(--ink-faint); padding: 6px 0; font-weight: 600; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 15px; position: relative; border: 1px solid transparent;
  background: transparent; color: var(--ink); transition: background .15s ease, border-color .15s ease;
}
.cal-day.empty { visibility: hidden; }
.cal-day.today { border-color: var(--cinnabar); color: var(--cinnabar); font-weight: 700; }
.cal-day.has-entry { background: var(--paper-warm); font-weight: 600; }
.cal-day .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cinnabar); margin-top: 3px; }
.cal-day .dot.empty-dot { background: transparent; }
@media (hover: hover) { .cal-day:not(.empty):hover { background: var(--cinnabar-soft); } }

/* ---------- 列表 ---------- */
.list-total { color: var(--ink-faint); font-size: 13.5px; }
.list-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 16px; }
.search-input { flex: 1; min-width: 180px; }
.search-input, .tag-filter-input {
  border: 1px solid var(--line-strong); border-radius: var(--radius-inner);
  padding: 9px 13px; font-size: 14px; background: var(--paper-warm); outline: none;
}
.search-input:focus, .tag-filter-input:focus { border-color: var(--cinnabar); background: var(--paper); }
.check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-soft); cursor: pointer; }
.check-label input { accent-color: var(--cinnabar); width: 16px; height: 16px; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.entry-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 18px; cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
  display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%;
}
@media (hover: hover) { .entry-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); } }
.entry-card-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-faint); }
.entry-card-top .ec-date { font-weight: 700; color: var(--cinnabar); }
.entry-card-top .ec-marks { margin-left: auto; display: flex; gap: 5px; font-size: 13px; }
.entry-card-title { font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1.45; }
.entry-card-preview { color: var(--ink-soft); font-size: 13.5px; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entry-card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.tag-chip {
  background: var(--paper-warm); border: 1px solid var(--line); color: var(--ink-soft);
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
}
.list-more { text-align: center; margin-top: 18px; }
.empty-hint { color: var(--ink-faint); text-align: center; padding: 34px 0; font-size: 14px; grid-column: 1 / -1; }

/* ---------- 统计 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { margin-bottom: 0; padding: 18px 20px; }
.stat-num { font-family: var(--serif); font-size: 34px; font-weight: 800; line-height: 1.2; }
.stat-num.small { font-size: 19px; margin-top: 6px; overflow-wrap: anywhere; }
.stat-label { color: var(--ink-faint); font-size: 12.5px; letter-spacing: .08em; margin-top: 2px; }
.stat-sub { color: var(--ink-faint); font-size: 12.5px; margin-top: 8px; }
.heatmap-wrap { overflow-x: auto; overscroll-behavior: contain; padding-bottom: 4px; }
.heatmap { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; width: max-content; }
.hm-cell { width: 11px; height: 11px; border-radius: 3px; background: #efe9dd; display: inline-block; }
.hm-cell.lv0 { background: #efe9dd; } .hm-cell.lv1 { background: #f0c9c2; }
.hm-cell.lv2 { background: #e29a8f; } .hm-cell.lv3 { background: #d16a5c; } .hm-cell.lv4 { background: var(--cinnabar); }
.heatmap-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--ink-faint); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col .card { margin-bottom: 0; }
.mood-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13.5px; }
.mood-bar-row .mb-name { width: 56px; flex-shrink: 0; }
.mood-bar-row .mb-track { flex: 1; height: 10px; background: var(--paper-warm); border-radius: 5px; overflow: hidden; }
.mood-bar-row .mb-fill { height: 100%; background: var(--cinnabar); border-radius: 5px; transition: width .5s ease; }
.mood-bar-row .mb-count { width: 34px; text-align: right; color: var(--ink-faint); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.tag-cloud .tc-item { background: var(--paper-warm); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; color: var(--ink-soft); cursor: pointer; }
@media (hover: hover) { .tag-cloud .tc-item:hover { border-color: var(--cinnabar); color: var(--cinnabar); } }

/* ---------- 控制台 ---------- */
.console-updated { color: var(--ink-faint); font-size: 12.5px; }
.bar { height: 8px; background: var(--paper-warm); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.bar-fill { height: 100%; background: var(--cinnabar); border-radius: 4px; width: 0; transition: width .6s ease; }
.bar-fill.warn { background: #d98e2b; } .bar-fill.danger { background: #a93226; }
.service-row { display: flex; gap: 10px; flex-wrap: wrap; }
.service-badge {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 6px 14px; font-size: 13.5px; background: var(--paper-warm);
}
.service-badge .svc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.service-badge.on .svc-dot { background: var(--green); }
.service-badge.off .svc-dot { background: var(--cinnabar); }
.table-wrap { overflow-x: auto; overscroll-behavior: contain; }
.proc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.proc-table th, .proc-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.proc-table th { color: var(--ink-faint); font-weight: 600; font-size: 12.5px; letter-spacing: .05em; }
.proc-table td.num, .proc-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.log-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.log-tools select {
  border: 1px solid var(--line-strong); border-radius: var(--radius-inner);
  padding: 8px 10px; background: var(--paper); font-size: 14px;
}
.log-view {
  background: #2b2622; color: #e8e0d0; border-radius: 12px; padding: 16px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  max-height: 420px; overflow: auto; overscroll-behavior: contain;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- 设置 ---------- */
.settings-form { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.settings-form input {
  border: 1px solid var(--line-strong); border-radius: var(--radius-inner);
  padding: 10px 13px; font-size: 14.5px; background: var(--paper-warm); outline: none;
}
.settings-form input:focus { border-color: var(--cinnabar); background: var(--paper); }
.settings-form .btn-primary { align-self: flex-start; }
.data-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.file-label { display: inline-flex; align-items: center; cursor: pointer; }
.about-text { color: var(--ink-soft); font-size: 14px; line-height: 1.8; }

/* ---------- 字数目标进度 ---------- */
.goal-progress { margin-bottom: 16px; }
.goal-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; color: var(--ink-faint); letter-spacing: .06em; margin-bottom: 2px;
}
.goal-progress-num { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 600; }
.goal-progress .bar { margin-top: 4px; }

/* ---------- 天气/地点 ---------- */
.weather-select {
  border: 1px solid var(--line-strong); border-radius: var(--radius-inner);
  padding: 8px 10px; font-size: 14px; background: var(--paper); outline: none;
}
.weather-select:focus { border-color: var(--cinnabar); }

/* ---------- 图片 ---------- */
.editor-images { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 16px; }
.editor-images-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.image-thumb { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1; background: var(--paper-warm); }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.image-thumb .img-del {
  position: absolute; top: 5px; right: 5px; width: 24px; height: 24px;
  border: none; border-radius: 50%; background: rgba(43, 38, 34, .72); color: #fff;
  font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
@media (hover: hover) { .image-thumb .img-del:hover { background: var(--cinnabar); } }
.lightbox {
  position: fixed; inset: 0; background: rgba(30, 25, 20, .88); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  overscroll-behavior: contain; animation: fadein .2s ease both;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-lift); }
.lightbox-close {
  position: absolute; top: 18px; right: 18px; width: 38px; height: 38px;
  border: none; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 17px;
}
@media (hover: hover) { .lightbox-close:hover { background: rgba(255,255,255,.28); } }

/* ---------- 待办 ---------- */
.todo-add, .habit-add { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.todo-add .search-input, .habit-add .search-input { flex: 1; min-width: 180px; }
.todo-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px;
  border-bottom: 1px dashed var(--line); font-size: 15px;
}
.todo-item:last-child { border-bottom: none; }
.todo-item input[type="checkbox"] { accent-color: var(--cinnabar); width: 19px; height: 19px; flex-shrink: 0; cursor: pointer; }
.todo-text { flex: 1; overflow-wrap: anywhere; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--ink-faint); }
.todo-due { font-size: 12.5px; color: var(--ink-faint); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.todo-item.overdue .todo-due { color: var(--cinnabar); font-weight: 700; }
.todo-item.overdue .todo-text { color: var(--cinnabar); }
.todo-del { border: none; background: transparent; color: var(--ink-faint); font-size: 16px; padding: 4px 8px; flex-shrink: 0; }
@media (hover: hover) { .todo-del:hover { color: var(--cinnabar); } }

/* ---------- 打卡 ---------- */
.color-input {
  width: 46px; height: 40px; padding: 3px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-inner); background: var(--paper); cursor: pointer;
}
.habit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.habit-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.habit-card-top { display: flex; align-items: center; gap: 10px; }
.habit-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.habit-name { font-family: var(--serif); font-size: 17px; font-weight: 700; flex: 1; overflow-wrap: anywhere; }
.habit-streak { font-size: 14px; font-weight: 700; color: #d98e2b; flex-shrink: 0; }
.habit-dots { display: flex; gap: 7px; align-items: center; }
.habit-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--paper-warm); flex-shrink: 0; }
.habit-dot.on { border-color: transparent; }
.habit-dot.today { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink-faint); }
.habit-meta { font-size: 12.5px; color: var(--ink-faint); }
.habit-actions { display: flex; gap: 8px; margin-top: auto; }
.habit-checkin-btn { flex: 1; }
.habit-checkin-btn.done { background: var(--green); box-shadow: 0 2px 8px rgba(46, 125, 79, .3); }
@media (hover: hover) { .habit-checkin-btn.done:hover { background: #256b43; } }

/* ---------- 图表 ---------- */
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-title-row .card-title { margin-bottom: 0; }
.chart-canvas { width: 100%; display: block; }
.mood-trend-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-faint); margin-top: 8px; }
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; }
.chart-legend .lg-rx { color: var(--cinnabar); }
.chart-legend .lg-tx { color: #2e6da4; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fdf9f2; padding: 11px 22px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow-lift); z-index: 100;
  animation: toastin .25s ease both; max-width: calc(100vw - 32px); text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .app-view { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    flex-direction: row; align-items: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--line); z-index: 50;
    box-shadow: 0 -4px 20px rgba(60,48,32,.07);
  }
  .brand { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 2px; }
  .nav-item { flex-direction: column; gap: 3px; padding: 7px 6px; font-size: 11px; width: auto; text-align: center; }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.logout { flex-direction: column; gap: 3px; font-size: 11px; padding: 7px 6px; width: auto; }
  .main { padding: 22px 16px 110px; }
  .two-col { grid-template-columns: 1fr; }
  .editor-meta { flex-direction: column; gap: 14px; }
  .toast { bottom: 96px; }
}
