/* AnkR web app — shared styles. Tokens lifted verbatim from
   platform/docs/AnkR Server Architecture.html so the Hub feels like the same
   product the deck pitched, not a bolted-on admin panel. */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink: #1E3A4F; --ink-2: #3D4F5F; --ink-3: #6B7B8D; --ink-4: #8A96A3;
  --blue: #2B6B8A; --blue-lt: #4A8EA3; --sky: #7EC8D9;
  --green: #2B8A7A; --green-lt: #6BCB9E; --green-dk: #3A8F6E;
  --paper: #FAFAF7; --sand: #F4F1EC; --sand-2: #E8E4DD; --mist: #E8F0EE;
  --surface: #FFFFFF;
  --border: #E0DAD1; --border-lt: #EDE8E1; --border-cool: #D3E2E3;
  --brick: #B4503C; --brick-dim: rgba(180,80,60,.08);
  --shadow: 0 12px 34px rgba(30,58,79,.10);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

.brand { font-family: 'DM Serif Display', serif; letter-spacing: .01em; }

/* --- shell: top bar + two-pane layout ------------------------------- */
.shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 28px; padding: 0 22px; height: 56px;
  background: var(--ink); color: var(--paper); flex: none;
}
.topbar .brand { font-size: 20px; color: #fff; margin-right: 6px; }
.topbar .brand em { color: var(--green-lt); font-style: normal; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: rgba(255,255,255,.72); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 8px; transition: background .15s, color .15s;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar nav a.active { background: var(--green-dk); color: #fff; }
.topbar .who { font-size: 13px; color: rgba(255,255,255,.75); display:flex; align-items:center; gap:10px; }
.topbar .who button {
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff;
  border-radius: 7px; padding: 5px 11px; font-size: 12.5px; cursor: pointer;
}
.topbar .who button:hover { background: rgba(255,255,255,.12); }

.body2 { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 300px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 10px;
}
.main { flex: 1; overflow-y: auto; padding: 30px 44px; }

.searchbox { display: flex; gap: 8px; margin-bottom: 16px; padding: 0 6px; }
.searchbox input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; font-family: inherit; background: var(--sand);
}
.searchbox button {
  background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 9px 14px;
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.searchbox button:hover { background: var(--blue-lt); }

.sec-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3);
  font-weight: 700; margin: 18px 12px 6px;
}
.sec-title:first-child { margin-top: 6px; }
.navlist { list-style: none; margin: 0; padding: 0; }
.navlist li a, .tree-file, .tree-dir > .tl {
  display: block; padding: 6px 12px; border-radius: 7px; color: var(--ink-2);
  text-decoration: none; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.navlist li a:hover, .tree-file:hover, .tree-dir > .tl:hover { background: var(--mist); }
.navlist li a.current, .tree-file.current { background: var(--green); color: #fff; }
.tree-dir { margin-left: 0; }
.tree-dir > ul { margin-left: 14px; padding-left: 8px; border-left: 1px dashed var(--border); }
.tree-dir > .tl { font-weight: 600; color: var(--ink); }
.tree-dir > .tl::before { content: '▸ '; color: var(--ink-4); }
.tree-dir.open > .tl::before { content: '▾ '; }
.tree-dir > ul { display: none; }
.tree-dir.open > ul { display: block; }

.stagepill { display:inline-block; font-size:11px; font-weight:700; padding:2px 8px; border-radius:999px; text-transform:uppercase; letter-spacing:.03em; }
.stagepill.proposal-sent { background: var(--mist); color: var(--blue); }
.stagepill.won { background: rgba(43,138,122,.15); color: var(--green-dk); }
.stagepill.lost { background: var(--brick-dim); color: var(--brick); }
.stagepill.qualified, .stagepill.identified, .stagepill.negotiation, .stagepill.dormant { background: var(--sand-2); color: var(--ink-3); }

.card { background: var(--surface); border: 1px solid var(--border-lt); border-radius: var(--radius); padding: 22px 26px; margin-bottom: 20px; box-shadow: var(--shadow); }
h1.page-title { font-family:'DM Serif Display',serif; font-size: 30px; margin: 0 0 4px; }
.subtle { color: var(--ink-3); font-size: 13.5px; }

table.fieldtable { border-collapse: collapse; width: 100%; margin: 10px 0 4px; }
table.fieldtable td { padding: 7px 10px; border-bottom: 1px solid var(--border-lt); font-size: 14px; vertical-align: top; }
table.fieldtable td.k { color: var(--ink-3); width: 190px; font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
table.fieldtable td.v { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; }

.prose { line-height: 1.65; font-size: 15px; }
.prose h1 { font-family:'DM Serif Display',serif; font-size: 24px; }
.prose h2 { font-size: 18px; margin-top: 26px; color: var(--ink); border-bottom: 1px solid var(--border-lt); padding-bottom: 6px;}
.prose h3 { font-size: 15.5px; color: var(--ink-2); }
.prose code { background: var(--sand); padding: .1em .35em; border-radius: 4px; font-size: 13px; }
.prose pre { background: var(--ink); color: var(--mist); padding: 14px 16px; border-radius: 8px; overflow-x: auto; }
.prose pre code { background: none; color: inherit; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.prose table th, .prose table td { border: 1px solid var(--border); padding: 6px 10px; font-size: 13.5px; text-align: left; }
.prose table th { background: var(--sand); }
.prose blockquote { border-left: 3px solid var(--green); margin: 0; padding: 4px 16px; color: var(--ink-2); background: var(--mist); border-radius: 0 8px 8px 0; }

.doclist { width: 100%; border-collapse: collapse; margin-top: 8px; }
.doclist th { text-align:left; font-size: 11px; text-transform: uppercase; letter-spacing:.04em; color: var(--ink-3); padding: 6px 10px; border-bottom: 2px solid var(--border); }
.doclist td { padding: 9px 10px; border-bottom: 1px solid var(--border-lt); font-size: 13.5px; vertical-align: top; }
.doclist code { font-size: 11.5px; color: var(--ink-3); }
.btn { display:inline-block; background: var(--blue); color:#fff; text-decoration:none; padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight:600; }
.btn:hover { background: var(--blue-lt); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--ink-2); }

.artifact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 10px; }
.artifact-tile { border: 1px solid var(--border-lt); border-radius: 10px; padding: 16px; background: var(--surface); text-decoration: none; color: var(--ink); transition: box-shadow .15s, transform .15s; }
.artifact-tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.artifact-tile .name { font-weight: 600; font-size: 13.5px; }
.artifact-tile .meta { color: var(--ink-3); font-size: 11.5px; margin-top: 6px; }

.searchresults .result { border-bottom: 1px solid var(--border-lt); padding: 12px 0; cursor: pointer; }
.searchresults .result:hover { background: var(--mist); }
.searchresults .loc { font-family:'JetBrains Mono',monospace; font-size: 12px; color: var(--blue); }
.searchresults .score { color: var(--ink-4); font-size: 11px; margin-left: 8px; }
.searchresults .snippet { font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }

.empty { color: var(--ink-4); font-style: italic; padding: 20px 0; }
.error-banner { background: var(--brick-dim); color: var(--brick); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; }

/* --- login --- */
.loginwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--ink), var(--blue) 130%); }
.loginbox { background: var(--surface); border-radius: 16px; padding: 40px 40px 34px; width: 340px; box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.loginbox .brand { font-size: 30px; margin-bottom: 4px; color: var(--ink); }
.loginbox .brand em { color: var(--green); font-style: normal; }
.loginbox .tag { color: var(--ink-3); font-size: 13px; margin-bottom: 26px; }
.loginbox label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display:block; margin-bottom: 5px; }
.loginbox input { width: 100%; padding: 10px 12px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.loginbox button { width: 100%; padding: 11px; background: var(--green); color: #fff; border: none; border-radius: 8px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.loginbox button:hover { background: var(--green-dk); }
.loginbox .err { color: var(--brick); font-size: 13px; margin-bottom: 12px; min-height: 1em; }
.loginbox .ok, .card .ok { color: var(--green-dk); font-size: 13px; margin-bottom: 12px; min-height: 1em; }
.card .err { color: var(--brick); font-size: 13px; margin-bottom: 12px; min-height: 1em; }
.card label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display:block; margin-bottom: 5px; }
.card form input { width: 100%; padding: 10px 12px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.card form button { padding: 10px 18px; background: var(--green); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.card form button:hover { background: var(--green-dk); }

/* --- history --- */
.commitrow { padding: 11px 14px; border-bottom: 1px solid var(--border-lt); cursor: pointer; }
.commitrow:hover { background: var(--mist); }
.commitrow.active { background: var(--green); color: #fff; }
.commitrow.active .subtle, .commitrow.active .hash { color: rgba(255,255,255,.85); }
.commitrow .subject { font-weight: 600; font-size: 13.5px; }
.commitrow .hash { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--ink-4); }
.difftext { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; background: var(--ink); color: var(--mist); border-radius: 10px; padding: 16px 18px; overflow-x: auto; }
.difftext .add { background: rgba(43,138,122,.35); display: block; }
.difftext .del { background: rgba(180,80,60,.35); display: block; }
.difftext .hunk { color: var(--sky); display: block; }
.difftext .meta { color: var(--ink-4); display: block; }

/* --- terminal --- */
.termwrap { flex: 1; display: flex; flex-direction: column; background: #10181f; }
.termhead { padding: 8px 16px; color: var(--ink-4); font-size: 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
#term { flex: 1; padding: 8px; }

/* Moved out of terminal.html's inline <style> (Finding C1, whole-branch
   review 2026-09-07) so the app's CSP can drop 'unsafe-inline' from
   style-src without breaking the terminal page's full-height layout.
   Applied via class="term-page" on <html> — html.term-page alone (without
   also sizing body) would compute the child's 100% against an auto-height
   ancestor and collapse to 0. */
html.term-page, html.term-page body { height: 100%; }
html.term-page .shell { height: 100vh; }

/* --- chat: the primary front door (architecture deck slide 3) ------------ */
.chatwrap { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.chatwrap.chat-gate { align-items: center; justify-content: center; padding: 40px; }
.connect-card { max-width: 460px; text-align: center; }
.connect-card .btn { margin-top: 6px; }
.connect-card .connect-again { margin-left: 10px; }

.chatlog { flex: 1; overflow-y: auto; padding: 26px 18%; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) { .chatlog { padding: 20px 6%; } }

.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-assistant { justify-content: flex-start; }
.msg .bubble {
  max-width: 78%; padding: 12px 16px; border-radius: 14px; font-size: 14.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.msg-user .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg-assistant .bubble { background: var(--surface); border: 1px solid var(--border-lt); box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.msg-assistant .bubble.prose { white-space: normal; }
.msg-assistant .bubble.prose :first-child { margin-top: 0; }
.msg-assistant .bubble.prose :last-child { margin-bottom: 0; }
.msg-assistant .bubble.streaming::after { content: '▍'; opacity: .6; animation: chatcaret 1s step-start infinite; }
@keyframes chatcaret { 50% { opacity: 0; } }

.msg-status { justify-content: flex-start; }
.msg-status { color: var(--ink-3); font-size: 12.5px; font-style: italic; padding: 2px 4px; }

.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 14px 18%; flex: none; }
@media (max-width: 900px) { .composer { padding: 12px 6%; } }
.composer textarea {
  width: 100%; resize: vertical; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14.5px; font-family: inherit; background: var(--sand);
}
.composer textarea:disabled { opacity: .6; }
.composer-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.composer-btns button { padding: 8px 18px; border-radius: 8px; font-size: 13.5px; font-weight: 600; border: none; cursor: pointer; }
.composer-btns .btn { background: var(--green); color: #fff; }
.composer-btns .btn:hover { background: var(--green-dk); }
.composer-btns .btn:disabled { opacity: .5; cursor: default; }
.composer-btns .btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--ink-2); }

/* --- footer: names the running version, links to the changelog ---------- */
.appfooter {
  position: fixed; right: 14px; bottom: 10px; z-index: 5;
  font-size: 11.5px; color: var(--ink-4); background: var(--surface);
  border: 1px solid var(--border-lt); border-radius: 999px; padding: 3px 12px;
  box-shadow: var(--shadow); font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.appfooter a { color: var(--ink-3); text-decoration: none; }
.appfooter a:hover { color: var(--blue); text-decoration: underline; }
