:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --text: #1d1c1a;
  --muted: #6b6862;
  --line: #e4e1db;
  --accent: #2f5fd0;
  --accent-soft: #e8eefb;
  --draft: #a15c00;
  --draft-soft: #fdf1df;
  --ok: #2a7a3b;
  --danger: #b3261e;
  --code: #f3f1ed;
  --add: #e6f4ea;
  --del: #fbe9e7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --panel: #1f1e1d;
    --text: #e8e6e1;
    --muted: #9b978f;
    --line: #34322f;
    --accent: #8aa9f0;
    --accent-soft: #232c40;
    --draft: #f0b35a;
    --draft-soft: #3a2c17;
    --ok: #7cc58a;
    --danger: #f2867c;
    --code: #262523;
    --add: #1d3324;
    --del: #3d2220;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, textarea.body { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--code); padding: 1px 4px; border-radius: 4px; }
pre { background: var(--code); padding: 12px; border-radius: 6px; overflow-x: auto; }
pre code { background: none; padding: 0; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 8px; }
h3 { font-size: 15px; }

.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.top nav { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
.top nav a { color: var(--muted); }
.top nav a.on, .top nav a:hover { color: var(--text); text-decoration: none; }
.top form.search input { width: 220px; }
main { max-width: 980px; margin: 0 auto; padding: 24px 20px 64px; }

input[type=text], input[type=password], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
}
textarea.body { width: 100%; min-height: 420px; line-height: 1.5; }
label { display: block; font-weight: 600; margin: 14px 0 4px; }
label small, .hint { font-weight: 400; color: var(--muted); }
.field input[type=text], .field select { width: 100%; }
button, .button {
  font: inherit; font-size: 14px; cursor: pointer; display: inline-block;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 5px 12px; border-radius: 6px;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); }
button.danger { color: var(--danger); }
button:hover, .button:hover { text-decoration: none; filter: brightness(0.97); }
form.inline { display: inline-flex; gap: 6px; align-items: center; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.badge {
  display: inline-block; font-size: 12px; line-height: 1; padding: 3px 7px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); vertical-align: 1px;
}
.badge.draft { background: var(--draft-soft); color: var(--draft); }
.badge.type { background: var(--code); color: var(--muted); }
.error { background: var(--del); color: var(--danger); padding: 8px 12px; border-radius: 6px; }
.notice { background: var(--accent-soft); padding: 12px 14px; border-radius: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }

ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li { padding: 7px 0; border-bottom: 1px solid var(--line); }
ul.list li:last-child { border-bottom: none; }
.desc { color: var(--muted); }

/* tree */
.tree, .tree ul { list-style: none; margin: 0; padding-left: 0; }
.tree ul { padding-left: 18px; border-left: 1px solid var(--line); margin-left: 6px; }
.tree li { padding: 2px 0; }
.tree details > summary { cursor: pointer; list-style: none; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary::before { content: "▸"; color: var(--muted); display: inline-block; width: 14px; }
.tree details[open] > summary::before { content: "▾"; }
.tree .leaf::before { content: ""; display: inline-block; width: 14px; }
.tree .implicit { color: var(--muted); font-style: italic; }

.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.meta { color: var(--muted); font-size: 13px; margin: 6px 0 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.lede { font-size: 16px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; margin: 10px 0 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; align-items: center; }
.prose { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 22px; }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--line); padding: 4px 8px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  .top { gap: 8px 14px; }
  .top nav { flex: 1 1 auto; min-width: 0; }
  .top form.search { flex: 1 1 100%; }
  .top form.search input { width: 100%; }
  main { padding: 18px 16px 48px; }
}

.diff { white-space: pre-wrap; }
.diff .add { background: var(--add); display: block; }
.diff .del { background: var(--del); display: block; }

.log-day { margin-top: 22px; }
.log-entry summary { cursor: pointer; }
.log-entry .body { margin: 6px 0 10px 18px; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 13px; color: var(--muted); font-weight: 600; }
.copy { position: relative; }
.login { max-width: 340px; margin: 80px auto; }
.login input { width: 100%; }
