:root {
  --bg: #f7f6f3;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e5e3dd;
  --accent: #0f7b6c;
  --accent-soft: #e3f1ef;
  --mark: #ffe9a8;
  --danger: #c0392b;
  --radius: 12px;
  --nav-h: 52px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1d2025;
    --text: #e6e4df;
    --muted: #9aa0a6;
    --line: #2c3036;
    --accent: #4fb3a5;
    --accent-soft: #1d3330;
    --mark: #5c4a12;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }

/* ---------- 导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 4px;
  height: var(--nav-h);
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.nav .brand { font-weight: 700; margin-right: 12px; color: var(--text); font-size: 17px; }
.nav a.tab {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 15px;
}
.nav a.tab.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav .spacer { flex: 1; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 9px; font-size: 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
input[type=text], input[type=password], input[type=date], input[type=url], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); color: var(--text); font-size: 15px; outline: none;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
.row { display: flex; gap: 8px; align-items: center; }
.muted { color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; margin-right: 4px;
}
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%);
  background: rgba(20,20,20,.88); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 14px; z-index: 200; opacity: 0; transition: opacity .25s; pointer-events: none;
  max-width: 86vw;
}
#toast.show { opacity: 1; }

/* ---------- 文章卡片 ---------- */
.art-card { cursor: pointer; }
.art-card h3 { margin: 0 0 6px; font-size: 17px; line-height: 1.45; }
.art-card .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.art-card .excerpt { color: var(--muted); font-size: 14px; margin: 6px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.gray { background: var(--line); color: var(--muted); }

/* ---------- 阅读页 ---------- */
.reader { max-width: 720px; margin: 0 auto; padding: 20px 18px 120px; }
.reader h1.title { font-size: 26px; line-height: 1.35; margin: 8px 0 10px; }
.reader .meta { color: var(--muted); font-size: 14px; margin-bottom: 20px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.reader .warning { background: #fff3cd; color: #7a5c00; padding: 10px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 16px; }
@media (prefers-color-scheme: dark) { .reader .warning { background: #3d3418; color: #e8cf7a; } }
#content { font-family: Georgia, "Songti SC", "Noto Serif CJK SC", serif; font-size: 18px; line-height: 1.85; }
#content p, #content li { margin: 0 0 1.1em; }
#content h2 { font-size: 22px; margin: 1.6em 0 .6em; font-family: inherit; }
#content h3 { font-size: 19px; margin: 1.4em 0 .5em; }
#content blockquote {
  margin: 1.2em 0; padding: 2px 18px; border-left: 3px solid var(--accent);
  color: var(--muted); font-style: italic;
}
#content pre {
  background: rgba(127,127,127,.1); border: 1px solid var(--line); border-radius: 9px;
  padding: 14px; overflow-x: auto; font-size: 13.5px; line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: rgba(127,127,127,.12); padding: 1px 5px; border-radius: 4px; }
#content pre code { background: none; padding: 0; }
#content figure { margin: 1.4em 0; text-align: center; }
#content img { max-width: 100%; height: auto; border-radius: 8px; }
#content figcaption { color: var(--muted); font-size: 13px; margin-top: 6px; font-family: -apple-system, sans-serif; }
#content a.embed {
  display: block; border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px;
  font-family: -apple-system, sans-serif; font-size: 14px; margin: 1em 0;
}
#content .trans {
  display: block; margin-top: 6px; padding-left: 10px;
  border-left: 2px solid var(--accent); color: var(--muted);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px; line-height: 1.75;
}
#content h2 .trans, #content h3 .trans { font-size: .85em; }
#content mark {
  background: var(--mark); color: inherit; padding: 1px 0; border-radius: 2px; cursor: pointer;
}
#content .has-note { border-left: 3px solid var(--mark); padding-left: 12px; }

/* 选中文字后的底部操作条 */
#selbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  display: none; gap: 8px; z-index: 120;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
#selbar.show { display: flex; }

/* 笔记区 */
.note-item { border-top: 1px solid var(--line); padding: 12px 0; }
.note-item:first-child { border-top: none; }
.note-quote {
  border-left: 3px solid var(--mark); padding: 2px 10px; color: var(--muted);
  font-size: 14px; margin-bottom: 6px; background: rgba(127,127,127,.06); border-radius: 0 6px 6px 0;
}
.note-body { font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.note-body.md { white-space: normal; }
.note-body.md h2 { font-size: 17px; margin: .9em 0 .35em; }
.note-body.md h3 { font-size: 15.5px; margin: .8em 0 .3em; }
.note-body.md ul { padding-left: 20px; margin: .3em 0; }
.note-body.md blockquote { border-left: 3px solid var(--line); margin: .5em 0; padding: 0 10px; color: var(--muted); }
.note-foot { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.note-foot .muted { flex: 1; }
.kind-ai { color: #8e6ccf; font-size: 12px; }

/* 弹窗 */
#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 150;
  display: none; align-items: flex-end; justify-content: center;
}
#overlay.show { display: flex; }
.sheet {
  background: var(--card); border-radius: 16px 16px 0 0; width: 100%; max-width: 760px;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  #overlay { align-items: center; }
  .sheet { border-radius: 16px; }
}

/* 笔记时间线 */
.day-head { font-weight: 700; margin: 20px 4px 8px; font-size: 15px; display: flex; align-items: baseline; gap: 8px; }

/* ---------- 移动端底部导航 ---------- */
.bottomnav { display: none; }
@media (max-width: 640px) {
  .nav .tab { display: none; }
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; background: var(--card); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a {
    flex: 1; text-align: center; padding: 7px 0 6px; color: var(--muted); font-size: 11px;
  }
  .bottomnav a .ico { display: block; font-size: 20px; line-height: 1.2; }
  .bottomnav a.active { color: var(--accent); }
}
