:root {
  --paper: #f6f1e7;
  --paper-2: #efe7d8;
  --card: #fbf8f2;
  --ink: #2b2622;
  --ink-2: #5d544b;
  --muted: #8a7f72;
  --line: #ddd2bf;
  --red: #b23a2b;
  --red-soft: #f3e1da;
  --gold: #a7843f;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  --side: 290px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1916; --paper-2: #24211d; --card: #22201c;
    --ink: #e9e1d3; --ink-2: #c4b9a8; --muted: #8f8577; --line: #3a352e;
    --red: #e06a55; --red-soft: #3a2420; --gold: #c9a45c;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.85 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* 侧栏 */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); overflow-y: auto;
  background: var(--paper-2); border-right: 1px solid var(--line);
  padding: 22px 18px 30px; font-size: 14px; line-height: 1.6;
}
.brand { display: flex; gap: 12px; align-items: center; color: var(--ink); margin-bottom: 18px; }
.brand:hover { text-decoration: none; }
.brand b { display: block; font: 700 21px/1.2 var(--serif); letter-spacing: .12em; }
.brand small { color: var(--muted); font-size: 12px; letter-spacing: .05em; }
.seal {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  background: var(--red); color: var(--paper); border-radius: 6px;
  font: 700 26px/1 var(--serif); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.progress { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.progress .bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--red); transition: width .4s; }
.progress .stats { margin-top: 8px; color: var(--ink-2); font-size: 13px; }
.progress b { color: var(--red); }
.nav-group { margin: 18px 0 6px; color: var(--muted); font-size: 12px; letter-spacing: .15em; }
nav ul { list-style: none; margin: 0; padding: 0; }
nav li a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--ink-2); }
nav li a:hover { background: var(--card); text-decoration: none; color: var(--ink); }
nav li.active > a { background: var(--card); color: var(--red); font-weight: 600; box-shadow: inset 3px 0 0 var(--red); }
nav .toc { margin: 4px 0 8px 12px; border-left: 1px solid var(--line); }
nav .toc a { padding: 2px 10px; font-size: 13px; color: var(--muted); }
.backup { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.backup button {
  font: inherit; font-size: 13px; margin-right: 8px; padding: 4px 12px; cursor: pointer;
  background: transparent; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px;
}
.backup button:hover { border-color: var(--red); color: var(--red); }
.backup p { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.menu-btn { display: none; }

/* 正文 */
main { margin-left: var(--side); padding: 0 48px 60px; max-width: calc(var(--side) + 900px); }
.today {
  position: sticky; top: 0; z-index: 5; margin: 0 -48px; padding: 12px 48px;
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink-2);
}
.today b { color: var(--red); }
.today .ok, .today .todo { margin-left: 12px; font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.today .ok { background: var(--red); color: var(--paper); }
.today .todo { border: 1px dashed var(--red); color: var(--red); }
article { padding-top: 28px; }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.4; position: relative; }
h1 { font-size: 32px; letter-spacing: .04em; margin: 8px 0 24px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
h2 {
  font-size: 24px; margin: 56px 0 18px; padding: 10px 0 10px 16px;
  border-left: 4px solid var(--red); background: linear-gradient(90deg, var(--red-soft), transparent 70%);
}
h2.is-today::after {
  content: "今日"; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  font: 600 12px/1 var(--sans); color: var(--paper); background: var(--red); padding: 5px 10px; border-radius: 999px;
}
h3 { font-size: 19px; margin: 32px 0 10px; color: var(--ink); }
h3::before { content: "◆"; color: var(--gold); font-size: 11px; margin-right: 8px; vertical-align: 3px; }
h4 { font-size: 16px; margin: 24px 0 8px; }
.anchor { margin-left: 8px; color: var(--muted); opacity: 0; font-weight: 400; font-size: .8em; }
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: .6; }
hr { border: 0; height: 1px; background: var(--line); margin: 40px 0; }
p, ul, ol { margin: 10px 0; }
ul, ol { padding-left: 1.5em; }
strong { color: var(--ink); }
blockquote {
  margin: 16px 0; padding: 10px 18px; background: var(--card);
  border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; color: var(--ink-2);
}
blockquote p { margin: 6px 0; }
code { font: 14px var(--mono); background: var(--paper-2); padding: 1px 6px; border-radius: 4px; }
pre {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 18px; overflow-x: auto; line-height: 1.6;
}
pre code { background: none; padding: 0; font-size: 14px; }
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.6; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--paper-2); font-family: var(--serif); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--red-soft); }
.wl { border-bottom: 1px dotted var(--red); }
.wl:hover { text-decoration: none; border-bottom-style: solid; }
.wl-missing { color: var(--muted); }

/* 勾选框 */
li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.4em; }
input[type=checkbox] {
  appearance: none; width: 18px; height: 18px; margin: 0 8px 0 0; vertical-align: -3px; cursor: pointer;
  border: 1.5px solid var(--muted); border-radius: 4px; background: var(--card); position: relative; transition: .15s;
}
input[type=checkbox]:hover { border-color: var(--red); }
input[type=checkbox]:checked { background: var(--red); border-color: var(--red); }
input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid var(--paper); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
li:has(> input:checked) { color: var(--muted); }
.dayrow { padding: 4px 8px; border-radius: 6px; }
.dayrow.is-today { background: var(--red-soft); box-shadow: inset 3px 0 0 var(--red); }

/* 打卡卡片 */
.checkcard {
  position: relative; margin: 28px 0 8px; padding: 6px 22px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  border-top: 3px solid var(--gold);
}
.checkcard.is-today { border-top-color: var(--red); box-shadow: 0 6px 24px -12px rgba(178,58,43,.45); }
.checkcard h4 { margin-top: 14px; }
.checkcard ul { padding-left: 1.4em; }
.checkcard .stamp {
  position: absolute; right: 22px; top: 18px; padding: 6px 12px;
  font: 700 18px/1 var(--serif); letter-spacing: .2em; color: var(--red);
  border: 2.5px solid var(--red); border-radius: 6px; transform: rotate(-12deg) scale(1.3);
  opacity: 0; transition: .35s cubic-bezier(.2,1.6,.4,1); pointer-events: none;
}
.checkcard.done .stamp { opacity: .85; transform: rotate(-12deg) scale(1); }

footer { margin-top: 60px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 20; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .menu-btn {
    display: block; position: fixed; right: 14px; bottom: 18px; z-index: 30;
    width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--red); color: var(--paper); font-size: 20px; box-shadow: 0 6px 18px rgba(0,0,0,.25);
  }
  main { margin-left: 0; padding: 0 18px 80px; }
  .today { margin: 0 -18px; padding: 10px 18px; }
  h1 { font-size: 26px; }
  h2 { font-size: 21px; }
  h2.is-today::after { position: static; display: inline-block; transform: none; margin-left: 10px; vertical-align: 3px; }
  .checkcard { padding: 4px 14px 12px; }
}
@media print {
  .sidebar, .menu-btn, .today { display: none; }
  main { margin: 0; }
}
@media (max-width: 900px) { th, td { min-width: 5.5em; } }
