:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --text: #1f2328;
  --text-muted: #6a737d;
  --link: #0969da;
  --border: #d8dee4;
  --code-bg: #f6f8fa;
  --mark-bg: #fff3a3;
  --callout-note: #086ddd;
  --callout-warning: #ec7500;
  --callout-danger: #e93147;
  --callout-success: #08b94e;
  --callout-info: #00b7e4;
  --callout-question: #ec7500;
  --callout-tip: #00bfbc;
  --callout-quote: #9e9e9e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --bg-soft: #1e2128;
    --text: #dadde2;
    --text-muted: #8b949e;
    --link: #539bf5;
    --border: #343a46;
    --code-bg: #22262e;
    --mark-bg: #7a6400;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.7;
  font-size: 16px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.site-title {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
}
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px 0 40px;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- index tree ---------- */
.index-heading { font-size: 24px; }
.note-count { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.tree { font-size: 15px; }
.tree-folder > summary {
  cursor: pointer;
  padding: 4px 0;
  font-weight: 600;
  list-style: none;
}
.tree-folder > summary::-webkit-details-marker { display: none; }
.tree-children { margin-left: 20px; border-left: 1px solid var(--border); padding-left: 12px; }
.tree-note { padding: 3px 0; }
.tree-note .lock { font-size: 13px; }

/* ---------- note page ---------- */
.note-title { margin: 0 0 4px; font-size: 30px; line-height: 1.3; }
.note-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

.markdown-body h1, .markdown-body h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.markdown-body img {
  max-width: 100%;
  border-radius: 6px;
}
.markdown-body blockquote {
  margin: 0;
  padding: 2px 16px;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.markdown-body table {
  border-collapse: collapse;
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 13px;
}
.markdown-body th { background: var(--bg-soft); }
.markdown-body code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.markdown-body pre {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
}
.markdown-body pre code { background: none; padding: 0; font-size: 0.88em; }
.markdown-body mark { background: var(--mark-bg); color: inherit; border-radius: 3px; padding: 0 2px; }
.markdown-body .math-display { overflow-x: auto; padding: 4px 0; }
.task-list-item { list-style: none; margin-left: -20px; }
.task-list-item input { margin-right: 6px; }

/* ---------- callouts ---------- */
.callout {
  border: none !important;
  border-radius: 8px;
  padding: 12px 16px !important;
  margin: 16px 0;
  background: color-mix(in srgb, var(--callout-color, var(--callout-note)) 10%, var(--bg));
  color: var(--text);
  border-left: 4px solid var(--callout-color, var(--callout-note)) !important;
}
.callout .callout-title {
  font-weight: 700;
  color: var(--callout-color, var(--callout-note));
  margin-bottom: 4px;
}
.callout p { margin: 6px 0; }
.callout-warning, .callout-caution, .callout-attention { --callout-color: var(--callout-warning); }
.callout-danger, .callout-error, .callout-bug, .callout-failure { --callout-color: var(--callout-danger); }
.callout-success, .callout-check, .callout-done { --callout-color: var(--callout-success); }
.callout-info, .callout-abstract, .callout-summary { --callout-color: var(--callout-info); }
.callout-question, .callout-help, .callout-faq { --callout-color: var(--callout-question); }
.callout-tip, .callout-hint, .callout-important { --callout-color: var(--callout-tip); }
.callout-quote, .callout-cite { --callout-color: var(--callout-quote); }

/* ---------- decrypt box ---------- */
.decrypt-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  margin: 40px 0;
}
.decrypt-box form { display: flex; gap: 10px; justify-content: center; }
.decrypt-box input {
  font-size: 15px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: min(260px, 60vw);
}
.decrypt-box button {
  font-size: 15px;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  background: var(--link);
  color: #fff;
  cursor: pointer;
}
.decrypt-box button:hover { filter: brightness(1.1); }
.decrypt-error { color: var(--callout-danger); font-size: 14px; }

.attachment-error { outline: 2px dashed var(--callout-danger); }

.unresolved-link {
  color: var(--text-muted);
  border-bottom: 1px dashed var(--border);
  cursor: default;
}

.backlinks {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.backlinks h2 { font-size: 15px; color: var(--text-muted); font-weight: 600; }
.backlinks ul { margin: 8px 0 0; padding-left: 20px; }
.backlinks li { padding: 2px 0; }

.error-page { text-align: center; padding: 60px 0; }
.error-page h1 { font-size: 64px; margin-bottom: 0; }

/* ---------- mobile ---------- */
@media (max-width: 600px) {
  body { font-size: 15px; }
  .container { padding: 18px 14px 48px; }
  .site-header { padding: 12px 14px; }
  .note-title { font-size: 23px; }
  .markdown-body h1 { font-size: 21px; }
  .markdown-body h2 { font-size: 18px; }
  .markdown-body pre { padding: 10px 12px; border-radius: 6px; }
  .markdown-body th, .markdown-body td { padding: 5px 8px; font-size: 14px; }
  .tree-children { margin-left: 8px; padding-left: 8px; }
  .tree-note, .tree-folder > summary { padding: 7px 0; } /* larger touch targets */
  .decrypt-box { padding: 18px 14px; }
  .decrypt-box form { flex-wrap: wrap; }
  .decrypt-box input { width: 100%; font-size: 16px; } /* 16px 避免 iOS 聚焦时自动放大 */
  .decrypt-box button { width: 100%; padding: 11px 20px; }
  .callout { padding: 10px 12px !important; }
}

/* iOS momentum scrolling for wide content */
.markdown-body pre, .markdown-body table, .markdown-body .math-display {
  -webkit-overflow-scrolling: touch;
}
