:root {
  --bg: #fafaf9; --fg: #1c1917; --muted: #78716c; --line: #e7e5e4; --card: #fff;
  --accent: #2563eb; --accent-bg: #eff6ff; --danger: #b91c1c; --mark: #fef08a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #18181b; --fg: #e4e4e7; --muted: #a1a1aa; --line: #3f3f46; --card: #232327;
    --accent: #60a5fa; --accent-bg: #1e293b; --danger: #f87171; --mark: #854d0e; }
  .EasyMDEContainer .CodeMirror, .editor-toolbar, .editor-preview, .editor-preview-side { background: var(--card); color: var(--fg); border-color: var(--line); }
  .CodeMirror-cursor { border-color: var(--fg); }
  .editor-toolbar button { color: var(--fg); }
  .editor-toolbar button:hover, .editor-toolbar button.active { background: var(--line); }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--fg); }
.searchbox { flex: 1; max-width: 520px; }
.searchbox input, .bigsearch input { width: 100%; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); font-size: 14px; }
.top nav { display: flex; gap: 1rem; align-items: center; margin-left: auto; }
.user { color: var(--muted); font-size: 13px; }
.wrap { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 50px); }
.sidebar { border-right: 1px solid var(--line); padding: .8rem .6rem; overflow: auto; max-height: calc(100vh - 50px); position: sticky; top: 50px; font-size: 14px; }
main { padding: 1.2rem 2rem 3rem; max-width: 980px; min-width: 0; }
@media (max-width: 800px) { .wrap { grid-template-columns: 1fr; } .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); } }
.tree { list-style: none; margin: 0; padding-left: .8rem; }
.sidebar > .tree { padding-left: 0; }
.tree li { margin: 1px 0; }
.tree summary { cursor: pointer; font-weight: 500; }
.tree .doc a { display: block; padding: 1px 4px; border-radius: 4px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree .doc.active a { background: var(--accent-bg); color: var(--accent); }
.count { color: var(--muted); font-size: 12px; font-weight: 400; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.flash { background: var(--accent-bg); border: 1px solid var(--accent); padding: .5rem .8rem; border-radius: 6px; margin-bottom: 1rem; }
.error { background: #fef2f2; color: #7f1d1d; border: 1px solid var(--danger); padding: .5rem .8rem; border-radius: 6px; margin-bottom: 1rem; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tag { display: inline-block; background: var(--accent-bg); color: var(--accent); border-radius: 999px; padding: 0 .6rem; margin: 0 .3rem .3rem 0; font-size: 12.5px; }
.tagcloud .tag { font-size: 14px; }
.meta { margin: .3rem 0 .8rem; font-size: 13px; }
.summary { color: var(--muted); font-size: 1.05rem; margin-top: -.4rem; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs span + span::before { content: " / "; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0 1.2rem; align-items: center; }
.btn { display: inline-block; padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font-size: 13.5px; cursor: pointer; font-family: inherit; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
form.inline { display: inline; margin: 0; }
.hit { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.hit h3 { margin: 0; font-size: 1.05rem; }
.hit .path { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.hit .summary { font-size: 14px; margin: .2rem 0; }
.snippet { margin: .2rem 0 .4rem; font-size: 14px; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }
.bigsearch { margin-bottom: 1rem; }
.editor label { display: block; margin-bottom: .8rem; font-weight: 500; font-size: 14px; }
.editor input { display: block; width: 100%; margin-top: .25rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; font-weight: 400; }
.editor input[readonly] { color: var(--muted); }
.editor textarea { width: 100%; font-family: var(--mono); }
.editor-toolbar button { width: auto !important; padding: 0 .5rem; font-size: 13px; font-weight: 600; }
.markdown { overflow-wrap: break-word; }
.markdown pre { background: var(--card); border: 1px solid var(--line); padding: .8rem; border-radius: 6px; overflow-x: auto; }
.markdown code { font-family: var(--mono); font-size: 13.5px; }
.markdown :not(pre) > code { background: var(--card); border: 1px solid var(--line); padding: 0 .3rem; border-radius: 4px; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: .3rem .6rem; }
.markdown blockquote { border-left: 3px solid var(--line); margin-left: 0; padding-left: 1rem; color: var(--muted); }
.markdown img { max-width: 100%; }
.newtoken { border: 1px solid var(--accent); background: var(--accent-bg); border-radius: 6px; padding: .2rem 1rem; margin-bottom: 1.2rem; }
.newtoken pre { background: var(--card); border: 1px solid var(--line); padding: .6rem; border-radius: 6px; overflow-x: auto; user-select: all; }
.tokenform { max-width: 420px; }
.wrap.single { grid-template-columns: 1fr; }
.wrap.single main { margin: 0 auto; width: 100%; }
.narrow { max-width: 420px; }
.hint { font-size: 13px; margin: -.4rem 0 .8rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .3rem 0; }
.inline-form input, .inline-form select, .editor select { padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; }
.editor label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.editor label.check input { display: inline; width: auto; margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.danger-text { color: var(--danger); }
.actions-cell { display: flex; flex-direction: column; gap: .3rem; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 1rem; padding: .5rem .8rem; }
legend { font-weight: 500; font-size: 14px; padding: 0 .3rem; }
.consent ul { padding-left: 1.2rem; font-size: 14px; }
.narrow-wide { max-width: 560px; }
