/* LibStack — one stylesheet, no framework. Light and dark follow the system. */
:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e2e0d9;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --err-bg: #fdecec;
  --err-ink: #8a1c1c;
  --ok-bg: #e8f5e9;
  --ok-ink: #1b5e20;
  --radius: 6px;
  --max: 72rem;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --panel: #1d2024;
    --ink: #e6e3dc;
    --muted: #9aa0a6;
    --line: #2d3136;
    --accent: #f59e0b;
    --accent-ink: #1a1a1a;
    --err-bg: #3b1d1d;
    --err-ink: #f7c2c2;
    --ok-bg: #1d3b22;
    --ok-ink: #c2f0c8;
  }
}

* { box-sizing: border-box; }
html { font: 16px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }

/* header */
.top {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.top .brand { font-weight: 700; color: var(--ink); letter-spacing: .02em; }
.top nav { display: flex; gap: 1rem; }
.top nav a { color: var(--ink); opacity: .85; }
.top .who { margin-left: auto; display: flex; align-items: center; gap: .9rem; font-size: .92rem; }
.top .who .org { font-weight: 600; }
.top .who .name { color: var(--muted); }
.top form { margin: 0; }
.top select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); }

main { max-width: var(--max); margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.narrow { max-width: 24rem; margin: 3rem auto; }

/* forms */
label { display: block; margin: .75rem 0; font-size: .92rem; color: var(--muted); }
label input { display: block; width: 100%; margin-top: .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit; padding: .45rem .9rem; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button.link { background: none; border: none; color: var(--accent); padding: .25rem .4rem; }
button.link:hover { text-decoration: underline; }
form.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0 0 1rem; }
form.inline input[type="text"] { flex: 1 1 16rem; }

/* notices */
.notice { padding: .55rem .8rem; border-radius: var(--radius); margin: .5rem 0 1rem; }
.notice.err { background: var(--err-bg); color: var(--err-ink); }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }
.muted { color: var(--muted); }
.tag { font-size: .75rem; padding: .05rem .4rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

/* collections */
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.cards li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .95rem; display: flex; flex-direction: column; gap: .2rem; }
.cards li > a { font-weight: 600; font-size: 1.05rem; }
.cards .blurb { margin: .25rem 0 0; font-size: .9rem; color: var(--muted); }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: .5rem; }
.title-row { display: flex; align-items: baseline; gap: .75rem; }
.title-row h1 { margin: 0 0 .5rem; }

/* lists and tables */
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.list th, table.list td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.list tr:last-child td { border-bottom: none; }

/* rendered markdown */
.prose { line-height: 1.6; }
.prose pre { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; overflow-x: auto; }
.prose code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
.prose img { max-width: 100%; }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--line); padding: .3rem .6rem; }
.prose blockquote { margin: 1rem 0; padding: .25rem 1rem; border-left: 3px solid var(--line); color: var(--muted); }

/* editor (CodeMirror mounts into [data-editor]; the textarea underneath stays for no-JS) */
.editor-head { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.editor-head input[name="title"] { flex: 1 1 20rem; font-size: 1.2rem; font-weight: 600; }
[data-editor] { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-height: 24rem; }
[data-editor] .cm-editor { min-height: 24rem; font-size: .95rem; }
[data-editor] .cm-editor.cm-focused { outline: 2px solid var(--accent); outline-offset: 1px; }
[data-editor] .cm-scroller { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; line-height: 1.5; }
[data-editor] .cm-gutters { background: transparent; border-right: 1px solid var(--line); color: var(--muted); }
textarea[name="markdown"] { width: 100%; min-height: 24rem; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.editor-foot { display: flex; gap: .75rem; align-items: center; margin-top: .6rem; flex-wrap: wrap; }
.editor-foot input[name="summary"] { flex: 1 1 16rem; }
#save-status.err { color: var(--err-ink); }

/* links styled as buttons, danger buttons, search hits, diffs */
a.btn { display: inline-block; padding: .35rem .8rem; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-size: .92rem; }
a.btn:hover { text-decoration: none; filter: brightness(1.05); }
button.danger { color: var(--err-ink); }
.tags { margin: .25rem 0 1rem; }
.backlinks ul { padding-left: 1.2rem; }
.hits { list-style: none; padding: 0; margin: 0; }
.hits li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.hits li > a { font-weight: 600; }
.hits .excerpt { margin: .2rem 0 0; color: var(--muted); font-size: .92rem; }
.hits mark { background: transparent; color: var(--ink); font-weight: 600; }
td.actions { white-space: nowrap; }
pre.diff { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; overflow-x: auto; font-size: .88rem; line-height: 1.4; }
pre.diff .del { color: var(--err-ink); background: var(--err-bg); display: block; }
pre.diff .ins { color: var(--ok-ink); background: var(--ok-bg); display: block; }
pre.diff .ctx { color: var(--muted); display: block; }

/* htmx */
.htmx-request { opacity: .6; transition: opacity .15s; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* attachments, comments, account (0023–0025) */
.attachments ul { padding-left: 1.2rem; }
.attachments li { margin: .2rem 0; }
.comments .thread { border-top: 1px solid var(--line); padding: .75rem 0; }
.comments .replies { margin-left: 1.5rem; padding-left: .75rem; border-left: 2px solid var(--line); }
.comment { margin: .4rem 0; }
.comment header { font-size: .85rem; }
.comment .prose { margin: .2rem 0 .4rem; }
.comment .prose p { margin: .25rem 0; }
.comment-form { display: flex; flex-direction: column; gap: .4rem; max-width: 40rem; margin: .5rem 0 .75rem; }
.comment-form textarea { min-height: 4rem; }
.comment-form button { align-self: flex-start; }
form.stack { display: flex; flex-direction: column; gap: .5rem; max-width: 32rem; margin: .75rem 0 1.5rem; }
form.stack h3 { margin: .5rem 0 0; font-size: 1rem; }
form.stack button { align-self: flex-start; }
form.stack label { margin: .25rem 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .8rem; }
legend { font-size: .85rem; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: .3rem; margin: .15rem 1rem .15rem 0; color: var(--ink); }
label.check input { width: auto; margin: 0; }
pre.token { margin: .5rem 0 0; padding: .5rem .7rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; user-select: all; }
.top .who a.name { color: var(--muted); }
label.upload { display: inline; margin: 0; cursor: pointer; color: var(--accent); font-size: .92rem; }

@media (max-width: 40rem) {
  .top { gap: .6rem; }
  .top .who { margin-left: 0; width: 100%; }
}

/* domains: tags, vault, vendors, audit, proposals, org */
.cloud { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: baseline; }
.cloud .count { color: var(--muted); font-size: .8rem; }
.secret { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.secret code { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .1rem .4rem; }
.secret .mask { letter-spacing: .15em; color: var(--muted); }
form.stack { display: grid; gap: .5rem; max-width: 36rem; margin: 0 0 1.5rem; }
form.stack label { margin: 0; }
form.stack select, form.stack textarea { width: 100%; font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); }
form.stack .row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
table.list td.detail { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .8rem; color: var(--muted); max-width: 28rem; overflow-wrap: anywhere; }
.proposal { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: .8rem .95rem; margin: 0 0 1rem; }
.proposal .meta { color: var(--muted); font-size: .9rem; }
.once { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
