:root { --bg:#fff; --fg:#1b1b1f; --muted:#6b7280; --accent:#2563eb; --line:#e5e7eb; --code:#f3f4f6; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#16161a; --fg:#e8e8ea; --muted:#9ca3af; --accent:#7aa2f7; --line:#2a2a31; --code:#1f1f25; }
}
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--fg);
  font:16px/1.6 -apple-system, "Segoe UI", Roboto, sans-serif; }
header { display:flex; gap:1rem; align-items:center; padding:.75rem 1.25rem;
  border-bottom:1px solid var(--line); position:sticky; top:0; background:var(--bg); }
.brand { font-weight:600; text-decoration:none; color:var(--fg); }
header form { flex:1; }
header input { width:100%; max-width:28rem; padding:.4rem .6rem;
  border:1px solid var(--line); border-radius:6px; background:var(--bg); color:var(--fg); }
a { color:var(--accent); }
.meta { color:var(--muted); font-size:.875rem; display:flex; gap:.75rem; flex-wrap:wrap; }
.meta .path { font-family:ui-monospace, monospace; }
.muted { color:var(--muted); }
.snippet { color:var(--muted); margin:.25rem 0 0; }
.hits { list-style:none; padding:0; }
.hits li { padding:.6rem 0; border-bottom:1px solid var(--line); }
aside { margin-top:3rem; padding-top:1rem; border-top:1px solid var(--line); }
pre, code { background:var(--code); border-radius:4px; }
pre { padding:.75rem; overflow-x:auto; }
code { padding:.1rem .3rem; font-size:.9em; }
table { border-collapse:collapse; width:100%; display:block; overflow-x:auto; }
th, td { border:1px solid var(--line); padding:.4rem .6rem; text-align:left; }
img { max-width:100%; height:auto; }
#graph { width:100%; height:70vh; border:1px solid var(--line); border-radius:8px; }

/* header identity */
.whoami { color:var(--muted); font-size:.85em; }
.signout { font-size:.85em; }

/* login page */
.login-body { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.login-card { width:100%; max-width:22rem; padding:2rem; border:1px solid var(--line);
  border-radius:10px; background:var(--bg); }
.login-card h1 { margin:0 0 .25rem; font-size:1.25rem; }
.login-card label { display:block; margin:.9rem 0 .25rem; font-size:.85em; color:var(--muted); }
.login-card input { width:100%; padding:.5rem .6rem; border:1px solid var(--line);
  border-radius:6px; background:var(--bg); color:var(--fg); }
.login-card button { width:100%; margin-top:1.25rem; padding:.55rem; border:0;
  border-radius:6px; background:var(--accent); color:#fff; font-weight:600; cursor:pointer; }
.login-card button:disabled { opacity:.6; cursor:default; }
.login-error { color:var(--text-error, #dc2626); font-size:.875em; margin-top:.75rem; }

/* full-page graph: no sidebar, no reading column */
body.graph-page .sidebar { display: none; }
body.graph-page main { max-width: none; padding: 0; }
body.graph-page .graph-hint { margin: 0; padding: .4rem 1rem; font-size: .8em;
  border-bottom: 1px solid var(--line); }
body.graph-page #graph { width: 100%; height: calc(100vh - 6.2rem);
  border: 0; border-radius: 0; display: block; }

/* collapsible folder groups */
details.folder { border-bottom: 1px solid var(--line); }
details.folder > summary { cursor: pointer; padding: .45rem .5rem; font-weight: 600;
  font-size: .9em; list-style: none; display: flex; align-items: center; gap: .4rem; }
details.folder > summary::-webkit-details-marker { display: none; }
details.folder > summary::before { content: "\25B8"; color: var(--muted);
  transition: transform .12s ease; display: inline-block; }
details.folder[open] > summary::before { transform: rotate(90deg); }
details.folder > summary:hover { color: var(--accent); }
.folder-count { color: var(--muted); font-weight: 400; font-size: .8em; }
details.folder ul { margin: 0 0 .4rem; padding-left: 1.35rem; list-style: none; }
details.folder li { padding: .12rem 0; }
details.folder li a { display: block; padding: .18rem .4rem; border-radius: 4px;
  text-decoration: none; font-size: .9em; color: var(--fg); }
details.folder li a:hover { background: var(--code); }
details.folder li.active a { background: var(--accent); color: #fff; font-weight: 600; }

/* two-panel layout: navigation left, document right */
.layout { display: flex; align-items: stretch;
  height: calc(100vh - 3.4rem);   /* viewport minus the sticky header */ }
.sidebar { flex: 0 0 clamp(17rem, 22%, 28rem); overflow-y: auto;
  border-right: 1px solid var(--line); padding: .5rem 0 2rem; }
.layout > main { flex: 1 1 auto; overflow-y: auto;
  max-width: 52rem; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }
.recent { list-style: none; padding: 0; }
.recent li { padding: .3rem 0; display: flex; gap: .6rem; align-items: baseline; }
.recent li .muted { font-size: .8em; }

/* narrow screens: stack, and let the nav collapse out of the way */
@media (max-width: 720px) {
  .layout { display: block; height: auto; }
  .sidebar { flex: none; width: auto; border-right: 0;
    border-bottom: 1px solid var(--line); max-height: 40vh; }
  .layout > main { max-width: none; padding: 1rem; }
}

/* root-level notes (README) pinned above the folder list */
.rootlinks { list-style: none; margin: 0 0 .35rem; padding: 0 .5rem .35rem;
  border-bottom: 1px solid var(--line); }
.rootlinks li a { display: block; padding: .3rem .4rem; border-radius: 4px;
  text-decoration: none; color: var(--fg); font-weight: 600; font-size: .9em; }
.rootlinks li a:hover { background: var(--code); }
.rootlinks li.active a { background: var(--accent); color: #fff; }

/* vault chat */
.chat-log { display: flex; flex-direction: column; gap: .75rem; margin: 1.25rem 0; }
.chat-msg { padding: .6rem .8rem; border-radius: 8px; white-space: pre-wrap; line-height: 1.55; }
.chat-you { background: var(--code); align-self: flex-end; max-width: 80%; }
.chat-einstein { border: 1px solid var(--line); }
.chat-pending { color: var(--muted); font-style: italic; }
.chat-cites { margin-top: .6rem; padding-top: .5rem; border-top: 1px solid var(--line);
  font-size: .85em; color: var(--muted); }
.chat-form { display: flex; gap: .5rem; position: sticky; bottom: 0;
  background: var(--bg); padding: .75rem 0; }
.chat-form input { flex: 1; padding: .55rem .7rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--fg); }
.chat-form button { padding: .55rem 1.1rem; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.chat-form button:disabled { opacity: .6; cursor: default; }
