:root {
  --bg: #faf8f5;
  --panel: #ffffff;
  --ink: #1c1a17;
  --ink-2: #6b645c;
  --ink-3: #9c948a;
  --line: #e8e2da;
  --accent: #d9603c;
  --accent-soft: #fbe9e3;
  --ok: #4a8c5c;
  --shadow: 0 1px 2px rgb(28 26 23 / 5%), 0 8px 24px rgb(28 26 23 / 4%);
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --panel: #1d1a16;
    --ink: #f0ece5;
    --ink-2: #a79e92;
    --ink-3: #6f675d;
    --line: #2c2822;
    --accent: #e8795a;
    --accent-soft: #33201a;
    --ok: #6fb384;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 20%);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

/* 顶栏 */
.bar {
  position: sticky; top: 0; z-index: 9;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px calc(12px) 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; letter-spacing: .02em; font-size: 15px; white-space: nowrap; }
.nav {
  display: flex; gap: 4px;
  overflow-x: auto; scrollbar-width: none;
  margin-left: auto;
  min-width: 0;      /* flex 子项默认 min-width:auto，不写这个永远不会收缩，item 会被裁掉 */
  flex: 1;
  justify-content: flex-end;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 5px 11px; border-radius: 999px; text-decoration: none;
  color: var(--ink-2); font-size: 13px; white-space: nowrap;
}
.nav a.on { background: var(--ink); color: var(--bg); }
.nav a:active { background: var(--line); }

main { padding: 18px 16px; max-width: 860px; margin: 0 auto; }

h2 {
  font-size: 12px; font-weight: 600; letter-spacing: .1em;
  color: var(--ink-3); text-transform: uppercase;
  margin: 26px 0 10px;
}
h2:first-child { margin-top: 4px; }

/* 统计 */
.grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 650; tracking-tight; letter-spacing: -.02em; }
.stat .k { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.stat.hero { grid-column: span 2; background: var(--ink); color: var(--bg); border-color: transparent; }
.stat.hero .k { color: color-mix(in srgb, var(--bg) 65%, transparent); }
@media (max-width: 619px) { .stat.hero { grid-column: span 2; } }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); padding: 12px 14px; text-decoration: none; color: inherit;
}
.row:active { background: var(--bg); }
.row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.row .meta { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.pill.s { background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.empty { color: var(--ink-3); font-size: 13px; padding: 18px 4px; }

/* 筛选 */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  font-size: 13px; padding: 6px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  font-family: inherit;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.search {
  width: 100%; padding: 11px 14px; border-radius: var(--r); font: inherit;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  margin-bottom: 12px;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* 登录 */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.card {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 30px 26px; box-shadow: var(--shadow);
}
.card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
.card p.sub { margin: 0 0 24px; color: var(--ink-3); font-size: 13px; }
.card label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.card input {
  width: 100%; padding: 11px 13px; margin-bottom: 14px; font: inherit;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink);
}
.card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.btn {
  width: 100%; padding: 12px; font: inherit; font-weight: 600;
  border: none; border-radius: 9px; background: var(--ink); color: var(--bg);
  cursor: pointer;
}
.btn:active { opacity: .85; }
.btn[disabled] { opacity: .45; }
.err { color: var(--accent); font-size: 13px; min-height: 20px; margin: -6px 0 10px; }

/* 入库页 */
.card2 {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow);
}
.card2 .search { margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--ink-3); margin: 12px 0 0; line-height: 1.7; }
.pill.ok  { background: #e6f4ea; color: var(--ok); }
.pill.bad { background: #fdecea; color: #c0392b; }
.pill.run { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .pill.ok  { background: #1b2f22; color: #7fc79a; }
  .pill.bad { background: #33201c; color: #e8836f; }
}
.job {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 13px 14px;
}
.job:last-child { border-bottom: 0; }
.job-top { display: flex; align-items: center; gap: 9px; }
.job-url {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; color: var(--ink-2);
}
.job-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.dl {
  display: inline-block; margin-top: 9px; padding: 7px 14px; border-radius: 8px;
  background: var(--ink); color: var(--bg); text-decoration: none;
  font-size: 13px; font-weight: 600;
}
.dl:active { opacity: .8; }
#jobs { display: block; }

.btnrow { display: flex; gap: 10px; }
.btnrow .btn { flex: 1; }
.btn.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:active { background: var(--bg); }

/* 月历 */
.calhead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.calhead #title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.calhead .chip { padding: 6px 16px; font-size: 16px; }
.cal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
}
.caleek {
  display: grid; grid-template-columns: repeat(7, 1fr);
  font-size: 11px; color: var(--ink-3); text-align: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calcell {
  min-height: 58px; padding: 5px 4px; cursor: pointer;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative;
}
.calcell:nth-child(7n) { border-right: 0; }
.calcell.void { background: var(--bg); cursor: default; }
.calcell:active { background: var(--bg); }
.calnum { font-size: 13px; color: var(--ink); line-height: 18px; }
.calcell.today .calnum {
  background: var(--ink); color: var(--bg);
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
}
.calcell.sel { background: var(--accent-soft); }
.calcell.has .calnum { font-weight: 650; }
.caldot {
  font-size: 9px; min-width: 13px; height: 13px; border-radius: 7px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  padding: 0 3px; line-height: 1;
}
.calpreview {
  font-size: 9px; color: var(--ink-3); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 手机端折叠菜单 */
.menubtn { display: none; }
.menubtn span {
  display: block; width: 16px; height: 1.6px; margin: 3.4px 0;
  background: currentColor; border-radius: 2px;
  transition: transform .18s var(--ds-ease, ease), opacity .18s ease;
}
@media (max-width: 520px) {
  .bar { gap: 10px; }
  .menubtn {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
    width: 36px; height: 36px; margin-left: auto; flex: none;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--panel); color: var(--ink); cursor: pointer; padding: 0;
  }
  .menubtn.active span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
  .menubtn.active span:nth-child(2) { opacity: 0; }
  .menubtn.active span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

  .nav {
    position: absolute; top: calc(100% - 4px); right: 12px;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 2px; min-width: 150px; padding: 6px;
    margin-left: 0; overflow: visible;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow);
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 14px; border-radius: 8px; font-size: 14px; text-align: left; }
  .nav a.on { background: var(--ink); color: var(--bg); }
}

/* 退出：弱化处理，别跟导航抢注意力 */
.nav a.logout { opacity: .5; }
.nav a.logout:active { opacity: .3; }
@media (min-width: 521px) {
  .nav a.logout { margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--line); border-radius: 0; }
}
@media (max-width: 520px) {
  .nav a.logout { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); border-radius: 0; }
}

/* 品牌区：logo + 文字 */
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo {
  width: 26px; height: 26px; flex: none; display: block;
  border-radius: 7px;            /* 方形红底收个圆角，像 App 图标 */
}
.brand span { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }

/* 登录页 */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 50% 8%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 62%);
}
.card.login {
  text-align: center;
  padding: 34px 26px 26px;
  border-radius: 20px;
  max-width: 330px;
}
.login-logo {
  width: 64px; height: 64px; display: block; margin: 0 auto 18px;
  border-radius: 16px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 22%, transparent);
}
.card.login h1 { font-size: 21px; margin: 0 0 6px; text-align: center; letter-spacing: -.01em; }
.card.login .sub { margin: 0 0 24px; text-align: center; }
.card.login input {
  text-align: left; margin-bottom: 11px; padding: 12px 14px;
  border-radius: 10px;
}
.card.login .err { margin: 4px 0 10px; }
.card.login .btn { padding: 13px; border-radius: 10px; font-size: 15px; }
/* 登录页是全屏一屏，不需要底栏留白 */
body:has(.login-wrap) { padding-bottom: 0; }

/* 单篇阅读 */
.notehead { margin-bottom: 20px; }
.notetitle { font-size: 21px; font-weight: 700; letter-spacing: -.01em; line-height: 1.4; margin-bottom: 10px; }
.notetags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.notemeta { display: flex; flex-direction: column; gap: 3px; }
.metarow { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; }
.metak { flex: none; width: 34px; color: var(--ink-3); }
.metav { color: var(--ink-2); word-break: break-all; }
.metav a { color: var(--accent); text-decoration: none; }
.notefoot { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); }
.backlink { font-size: 13px; color: var(--ink-2); text-decoration: none; }

.md { font-size: 15px; line-height: 1.78; color: var(--ink); word-wrap: break-word; }
.md h1 { font-size: 20px; margin: 26px 0 10px; letter-spacing: -.01em; }
.md h2 {
  font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none;
  margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.md h3 { font-size: 15px; margin: 20px 0 8px; color: var(--ink); }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin-bottom: 4px; }
.md a { color: var(--accent); }
.md strong { font-weight: 700; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md blockquote {
  margin: 0 0 14px; padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent); color: var(--ink-2);
}
.md code {
  font-family: var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12.5px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px;
}
.md pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 13px 15px; overflow-x: auto; margin: 0 0 14px;
}
.md pre code { border: 0; background: none; padding: 0; font-size: 12.5px; }
.md table {
  width: 100%; border-collapse: collapse; margin: 0 0 16px;
  font-size: 13px; display: block; overflow-x: auto; white-space: nowrap;
}
.md th, .md td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.md th { background: var(--bg); font-weight: 600; }
.md img { max-width: 100%; height: auto; border-radius: 8px; }
.md details {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 14px; margin: 0 0 14px;
}
.md summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.md details[open] summary { margin-bottom: 10px; }

/* 编辑 / 阅读操作栏 */
.kbtop { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.kbtop .search { margin-bottom: 0; }
.editbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.efile {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; color: var(--ink-3);
}
.btn.tiny { width: auto; padding: 8px 15px; font-size: 13px; flex: none; }
.btn.tiny.danger { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.actions { display: flex; gap: 8px; margin-top: 14px; }
textarea#ta {
  width: 100%; display: block; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.75;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); color: var(--ink);
  margin-bottom: 10px;
}
textarea#ta:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* 回收站 */
.trashsum { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.trashbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.trashbar .chips { margin-bottom: 0; flex: 1; }
.btn.tiny.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }

/* 回收站条目 */
.trashitem {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.trashitem:last-child { border-bottom: 0; }
.trashitem .tit { flex: 1; min-width: 0; }
.trashitem .tname {
  font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trashitem .tmeta { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

/* 知识库：行内快捷操作 + 选择模式 */
.row .t { text-decoration: none; color: inherit; }

.cbx { display: none; flex: none; width: 20px; height: 20px; }
.cbx .tick {
  display: grid; place-items: center; width: 20px; height: 20px;
  border: 1.5px solid var(--line); border-radius: 6px;
  font-size: 12px; color: transparent; line-height: 1;
}
.list.selecting .cbx { display: block; }
.row.picked { background: var(--accent-soft); }
.row.picked .cbx .tick {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.acts { display: none; gap: 6px; flex: none; }
.iact {
  font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.iact.danger { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
/* 只有真正有指针悬停能力的设备才用 hover 显示 */
@media (hover: hover) and (min-width: 521px) {
  .row .acts { display: flex; opacity: 0; transition: opacity .12s; }
  .row:hover .acts { opacity: 1; }
  .list.selecting .acts { display: none; }
}

/* 选择模式底栏 */
.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgb(0 0 0 / 8%);
}
.selinfo { font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.selacts { display: flex; gap: 7px; flex-wrap: wrap; }
.sact {
  font: inherit; font-size: 13px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer;
}
.sact.danger { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.sact[disabled] { opacity: .35; }
body.hassel { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }

/* 目录选择弹层 */
.modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgb(0 0 0 / 35%);
  display: grid; place-items: center; padding: 22px;
}
.modal[hidden] { display: none; }
.modalbox {
  width: 100%; max-width: 360px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow);
}
.mtitle { font-size: 15px; font-weight: 650; margin-bottom: 14px; }
.modalbox .search { margin-bottom: 14px; }
.modalbox .btnrow { display: flex; gap: 8px; }
.modalbox .btnrow .btn { flex: 1; }

/* 日历：完成状态 */
.calcell.alldone .caldot { background: #4a8c5c; }
.calcell.somedone .caldot { background: color-mix(in srgb, #4a8c5c 55%, var(--accent)); }
.calcell.alldone .calpreview { color: var(--ok); }
.calcell.alldone::after {
  content: ''; position: absolute; top: 5px; right: 5px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
}

.todow {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel); padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.todow:last-child { border-bottom: 0; }
.tcheck {
  flex: none; width: 22px; height: 22px; border-radius: 50%; padding: 0;
  border: 1.5px solid var(--line); background: transparent;
  color: transparent; font-size: 12px; line-height: 1; cursor: pointer;
}
.todow.done .tcheck { background: var(--ok); border-color: var(--ok); color: #fff; }
.ttitle { flex: 1; min-width: 0; font-size: 14px; }
.todow.done .ttitle { color: var(--ink-3); text-decoration: line-through; }
.tdel {
  flex: none; width: 26px; height: 26px; border-radius: 50%; padding: 0;
  border: 0; background: transparent; color: var(--ink-3); font-size: 17px;
  cursor: pointer; line-height: 1;
}
.tdel:active { color: var(--accent); }

/* 知识库顶部：按钮多了让它换行，别把搜索框压没 */
.kbtop { flex-wrap: wrap; }
.kbtop .search { flex: 1 1 150px; }
/* chips 里的链接式按钮（回收站）跟按钮长得一样 */
a.chip { text-decoration: none; display: inline-flex; align-items: center; }

/* 首页分区标题 + 本月待办 */
.h2row { display: flex; align-items: baseline; justify-content: space-between; }
.h2link { font-size: 12.5px; color: var(--accent); text-decoration: none; letter-spacing: 0; text-transform: none; }
.listsum {
  font-size: 11.5px; color: var(--ink-3);
  padding: 8px 14px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.tdate {
  flex: none; font-size: 11.5px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; min-width: 34px;
}
.todow .ttitle { cursor: text; }
.todow .ttitle[contenteditable="true"] {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

/* 大按钮宫格 */
.dock {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 22px;
}
@media (min-width: 620px) { .dock { grid-template-columns: repeat(6, 1fr); } }
.dockitem {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 16px 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink);
  transition: transform .12s ease, background .12s ease;
}
.dockitem:active { transform: scale(.97); background: var(--bg); }
.dockicon { width: 26px; height: 26px; color: var(--accent); flex: none; }
.docklabel { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
