:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f27;
  --muted: #6b7280;
  --faint: #9aa1ad;
  --line: #e4e7ec;
  --accent: #2f6fed;
  --accent-soft: #e8f0ff;
  --danger: #d93838;
  --ok: #1f9d55;
  --warn: #d98a0b;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --title-font: "Funnel Sans", "Alibaba PuHuiTi 3.0 Heavy", "Alibaba PuHuiTi 3.0", "HarmonyOS Sans SC", "PingFang SC", var(--font);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #171a21; --text: #e6e8ec; --muted: #9aa1ad; --faint: #6b7280;
    --line: #262a33; --accent: #6b9cff; --accent-soft: #1b2740;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); }
.wrap { max-width: none; margin: 0 auto; padding: 0 20px; }

/* ─── chrome ─────────────────────────────────────────────── */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; align-items: center; gap: 18px; height: 48px; }
.brand { font-family: var(--title-font); font-weight: 700; font-size: 18px; line-height: 24px; }
.ver { margin-left: -10px; font-size: 12px; line-height: 18px; color: var(--faint); white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 5px 10px; border-radius: 7px; font-size: 13.5px; line-height: 18px; color: var(--muted); white-space: nowrap; }
.nav a.on { color: var(--text); background: var(--bg); }
.bar-end { margin-left: auto; }

/* ─── controls: one size per row, primary differs by colour only ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 28px; padding: 0 10px; font: 12.5px/1 var(--font); color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.wide { width: 100%; height: 34px; font-size: 13.5px; }
.btn.add { height: 30px; padding: 0 12px; font-size: 13px; border-style: dashed; border-radius: 8px; }
.btn.add::before {
  content: ""; width: 11px; height: 11px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M6 1.5v9M1.5 6h9' stroke='black' stroke-width='1.2' stroke-linecap='round'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M6 1.5v9M1.5 6h9' stroke='black' stroke-width='1.2' stroke-linecap='round'/></svg>") center / contain no-repeat;
}
.input {
  width: 100%; height: 34px; padding: 0 10px; font: 13.5px/1.5 var(--font); color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.row { display: flex; align-items: center; gap: 8px; }
.row form { display: contents; }
.inline-form { margin-bottom: 12px; }
.inline-form .input { max-width: 280px; }
.inline-form .btn { height: 34px; font-size: 13.5px; }

/* ─── headings ───────────────────────────────────────────── */
.h1 { font-family: var(--title-font); font-weight: 700; font-size: 20px; line-height: 28px; margin: 0; }
.h { font-family: var(--title-font); font-weight: 700; font-size: 16px; line-height: 22px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.count { font: 12px/18px var(--font); color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.group { font-family: var(--title-font); font-weight: 700; font-size: 14px; line-height: 20px; color: var(--muted); margin: 18px 0 6px; }
.group:first-of-type { margin-top: 4px; }

/* ─── page list ──────────────────────────────────────────── */
.sec { margin-top: 22px; }
.pages { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.page { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-top: 1px solid var(--line); }
.page:first-child { border-top: 0; }
.page-main { min-width: 0; flex: 1; }
.page-title { display: block; font-weight: 600; font-size: 14.5px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-title:hover { color: var(--accent); }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 12px; line-height: 18px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px; font-size: 12px; line-height: 18px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; flex-shrink: 0; }
.chip.ver { background: var(--bg); color: var(--muted); border: 1px solid var(--line); height: 18px; line-height: 16px; font-variant-numeric: tabular-nums; }
a.chip.ver:hover, a.chip.talk:hover { border-color: var(--muted); color: var(--text); }
.chip.talk { background: #fff4e0; color: #9a5b00; border: 1px solid #f0d9a8; height: 18px; line-height: 16px; }
@media (prefers-color-scheme: dark) { .chip.talk { background: #332a14; color: #f0c674; border-color: #4d3f1c; } }
.meta .note { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.key { font-size: 12px; color: var(--muted); }
.page-side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.left { font-size: 12.5px; line-height: 18px; white-space: nowrap; }
.page.live .left { color: var(--ok); }
.page.archived .left { color: var(--warn); }
.actions { display: flex; align-items: center; gap: 6px; }
.actions form { display: contents; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.empty p { margin: 0 0 8px; }
.empty code { display: inline-block; font-size: 12.5px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }
.empty.small { padding: 18px 0; margin: 0; }
/* comments on the detail page */
.page.comment .page-main { display: block; }
.page.comment.done { opacity: .55; }
.quote { margin: 0 0 4px; padding: 2px 10px; border-left: 3px solid var(--line); color: var(--muted); font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cbody { margin: 0; font-size: 14px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.page.comment .meta { margin-top: 4px; }
/* wide screens: one line per page, title then meta, actions at the far right */
@media (min-width: 1200px) {
  .page:not(.comment) .page-main { display: flex; align-items: center; gap: 12px; }
  .page:not(.comment) .page-title { flex: 0 1 auto; max-width: 56ch; }
  .page:not(.comment) .meta { margin-top: 0; flex: 1; min-width: 0; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
}

/* ─── source ─────────────────────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 8px; }
.src {
  margin: 12px 0 0; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  font: 12.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 70vh; overflow: auto;
}

/* ─── login ──────────────────────────────────────────────── */
.login { max-width: 320px; margin: 14vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login .h1 { text-align: center; font-size: 26px; line-height: 32px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.err { color: var(--danger); font-size: 12.5px; margin: 0; text-align: center; }

/* ─── admin ──────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; margin: 18px 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 12px; font-size: 13.5px; line-height: 20px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.search { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search .input { max-width: 320px; }
.search .btn { height: 34px; font-size: 13.5px; }
.hint { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.seg { display: flex; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg a { padding: 0 10px; height: 24px; font-size: 12.5px; line-height: 24px; color: var(--muted); border-radius: 6px; white-space: nowrap; }
.seg a.on { background: var(--bg); color: var(--text); }

.qa-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; padding: 14px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.qa { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 0 14px; }
.qa summary { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 0; cursor: pointer; list-style: none; }
.qa summary::-webkit-details-marker { display: none; }
.qa-q { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; line-height: 20px; }
.qa-tags { display: flex; gap: 4px; flex-shrink: 0; }
.qa summary time { font-size: 12px; line-height: 18px; color: var(--faint); white-space: nowrap; }
.qa > form { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.qa > .row { padding: 0 0 14px; }

.log ul { margin: 0; padding-left: 18px; }
.log li { margin: 3px 0; }

.tokens { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.token { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.token:first-child { border-top: 0; }
.token.off { opacity: .55; }
.tk-name { font-weight: 600; min-width: 120px; }
.tk-meta { flex: 1; font-size: 12.5px; line-height: 18px; color: var(--muted); }
.tk-meta code { font-size: 12px; }
/* accent-bordered card: the two corners on the coloured edge stay square */
.token-new { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; }
.token-new p { margin: 0; font-size: 13px; }
.token-new code { font-size: 12.5px; word-break: break-all; }

.settings { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 22px 0 0; font-size: 13px; max-width: 360px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ─── markdown editor (growth-ledger MarkdownEditor, 1:1) ─── */
.md-editor { display: flex; flex-direction: column; gap: 6px; container-type: inline-size; }
.md-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.md-tool {
  min-width: 30px; min-height: 30px; padding: 4px 8px; cursor: pointer;
  font-size: 12.5px; line-height: 1; white-space: nowrap; font-family: inherit;
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 6px;
}
.md-tool:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }
.md-hint { margin-left: auto; font-size: 11.5px; color: var(--faint); }
/* 左写右预览。两栏等宽，盒模型必须一致，否则同样写 100% 也会差出 padding 与边框的宽度 */
.md-panes { display: grid; grid-template-columns: 1fr; gap: 10px; }
.md-panes.split { grid-template-columns: 1fr 1fr; }
.md-panes > * { box-sizing: border-box; min-width: 0; }
.md-input { resize: vertical; min-height: 120px; font-size: 13.5px; line-height: 1.7; font-family: inherit; }
.md-preview {
  overflow-y: auto; padding: 6px 10px; min-height: 120px;
  border: 1px dashed var(--line); border-radius: 8px;
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
/* 编辑器自己不到 520px 宽就上写下预览——看的是容器宽度，不是屏幕宽度 */
@container (max-width: 520px) {
  .md-panes.split { grid-template-columns: 1fr; }
}
.md-body { font-size: 13.5px; line-height: 1.7; max-width: 70ch; overflow-wrap: anywhere; }
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body pre { margin: 0.6em 0; }
.md-body h1 { font-size: 1.35em; }
.md-body h2 { font-size: 1.2em; }
.md-body h3 { font-size: 1.08em; }
.md-body h4, .md-body h5, .md-body h6 { font-size: 1em; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { margin: 1em 0 0.4em; font-weight: 600; }
.md-body a { color: var(--accent); }
.md-body ul, .md-body ol { padding-left: 1.4em; }
.md-body li { margin: 0.2em 0; }
.md-body blockquote { border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); padding-left: 10px; color: color-mix(in srgb, var(--text) 70%, transparent); }
.md-body code { font-family: var(--mono); font-size: 0.9em; background: color-mix(in srgb, var(--text) 9%, transparent); border-radius: 4px; padding: 1px 5px; }
.md-body pre { padding: 10px 12px; overflow-x: auto; border-radius: 8px; background: color-mix(in srgb, var(--text) 7%, transparent); border: 1px solid var(--line); }
.md-body pre code { background: transparent; padding: 0; font-size: 0.86em; }
.md-body img { max-width: 100%; height: auto; border-radius: 8px; margin: 4px 0; display: block; }
.md-body hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }

/* ─── phone: fewer decorations, same information ─────────── */
@media (max-width: 640px) {
  .bar { gap: 12px; }
  .page { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-side { justify-content: space-between; }
  .meta .size, .meta .views { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .src { max-height: none; }
  .tk-name { min-width: 0; }
  .token { flex-wrap: wrap; }
  .hint { white-space: normal; }
}
