:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6a737d;
  --line: #e3e6ea;
  --accent: #3b5bdb;
  --accent-soft: #edf0fe;
  --code-bg: #f0f2f4;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.2px; }
.brand span { color: var(--accent); }
.doc-title { color: var(--muted); font-size: 13px; }

#layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w, 280px) 1fr var(--chat-w, 360px);
}
#layout.hide-sidebar { --sidebar-w: 0px; }
#layout.hide-chat { --chat-w: 0px; }
/* Pin each panel to its column so hiding one doesn't reflow the others into a 0px track. */
#sidebar { grid-column: 1; }
#center { grid-column: 2; }
#chat { grid-column: 3; }
#layout.hide-sidebar #sidebar, #layout.hide-chat #chat { display: none; }

#sidebar, #chat { background: var(--panel); overflow-y: auto; }
#sidebar { border-right: 1px solid var(--line); padding: 14px; }
#chat { border-left: 1px solid var(--line); display: flex; flex-direction: column; }

#center { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 8px 12px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.tab {
  padding: 8px 16px; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.content { flex: 1; overflow-y: auto; padding: 28px 40px; }

/* Graph tab (force-directed explorer) */
.graph-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.graph-bar strong { font-size: 17px; }
.graph-hint { font-size: 12px; }
.graph-open, .graph-reset {
  padding: 6px 12px; border: 1px solid var(--accent);
  background: var(--accent-soft); color: var(--accent); border-radius: 8px;
  font-weight: 600; cursor: pointer;
}
.graph-reset { margin-left: auto; border-color: var(--line); color: var(--muted); background: transparent; }
.graph-reset:hover { border-color: var(--accent); color: var(--accent); }
.graph-open:hover { background: var(--accent); color: #fff; }

.graph-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.graph-filter {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 12px; cursor: pointer;
}
.graph-filter i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.graph-filter.off { opacity: 0.4; text-decoration: line-through; }

/* community (theme) colour legend */
.graph-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; }
.graph-legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.graph-svg { width: 100%; height: auto; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfd; touch-action: none; }
.gnode { cursor: pointer; }
.gnode text.graph-label {
  font-size: 11.5px; fill: var(--ink); pointer-events: none;
  paint-order: stroke; stroke: #fbfcfd; stroke-width: 3px; stroke-linejoin: round;
}
.gnode:hover circle, .gnode:hover rect { stroke: var(--accent); }
/* keep a decluttered (hidden) label reachable: show it while hovering its node */
.gnode:hover text.graph-label { opacity: 1 !important; }
/* active/selected subgraph: dim the rest, emphasise the anchor */
.gnode.dim { opacity: 0.4; transition: opacity .15s ease; }
.gnode.dim:hover { opacity: 1; }
.gnode.selected text.graph-label { font-weight: 700; }

/* Tutorial "run" action buttons (rendered from run: links) */
.content a.run-action {
  display: inline-block; margin: 6px 0; padding: 7px 13px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 8px;
  font-weight: 600; text-decoration: none;
}
.content a.run-action:hover { background: var(--accent); color: #fff; }

#search {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; outline: none; background: var(--bg);
}
#search:focus { border-color: var(--accent); background: #fff; }

.search-results { margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.search-results .hit { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-results .hit:last-child { border-bottom: 0; }
.search-results .hit:hover { background: var(--accent-soft); }
.search-results .hit .t { font-weight: 600; font-size: 13px; }
.search-results .hit .s { color: var(--muted); font-size: 12px; }
.search-results .hit .x { color: var(--muted); font-size: 12px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.nav { margin-top: 8px; }
.nav ul { list-style: none; margin: 0; padding-left: 12px; }
.nav > ul { padding-left: 0; }
.nav a {
  display: block; padding: 3px 6px; color: var(--ink);
  text-decoration: none; border-radius: 6px; font-size: 13.5px;
}
.nav a:hover { background: var(--accent-soft); }
.nav a.active { background: var(--accent); color: #fff; }

.content h1 { font-size: 26px; margin: 0 0 14px; }
.content h2 { font-size: 20px; margin: 26px 0 10px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.content h3 { font-size: 16px; margin: 20px 0 8px; }
.content a { color: var(--accent); }
.content table { border-collapse: collapse; margin: 12px 0; font-size: 13.5px; }
.content th, .content td { border: 1px solid var(--line); padding: 5px 9px; }
.content th { background: var(--code-bg); }
.content code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.content pre { background: var(--code-bg); padding: 12px; border-radius: 8px; overflow-x: auto; }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.content img { max-width: 100%; }
.muted { color: var(--muted); }

.chat-head { padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 12px; border-radius: 10px; max-width: 92%; white-space: pre-wrap; font-size: 14px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg.agent { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg .tools { margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.msg .tools .tool { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.msg .tools .edit { color: #b5730a; }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form textarea {
  flex: 1; resize: none; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; outline: none;
}
.chat-form textarea:focus { border-color: var(--accent); }
.chat-form button {
  padding: 0 16px; border: 0; border-radius: 8px; background: var(--accent);
  color: #fff; font-weight: 600; cursor: pointer;
}
.chat-form button:disabled { opacity: .55; cursor: default; }

@media (max-width: 1100px) { #layout { --sidebar-w: 240px; --chat-w: 0px; } #chat { display: none; } }

/* -- project tab + header badge -- */
.project-badge {
  margin-left: 12px; padding: 3px 10px; border: 1px solid var(--line);
  border-radius: 999px; font-family: inherit; font-size: 12px; color: var(--muted); background: var(--bg);
  white-space: nowrap; cursor: pointer;
}
.project-badge:hover { color: var(--ink); border-color: var(--accent); }
.project-badge[hidden] { display: none; }
/* the project switcher (v0.120) */
.project-wrap { position: relative; }
.project-menu { position: absolute; top: calc(100% + 8px); left: 12px; z-index: 50; width: min(560px, 90vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18); font-size: 13px; }
.project-menu[hidden] { display: none; }
.pm-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }
.pm-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.pm-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left;
  font: inherit; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: var(--ink); cursor: pointer; }
.pm-row:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.pm-row:disabled { cursor: default; }
.pm-row.current { border-color: var(--accent); }
.pm-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pm-name { font-weight: 600; font-size: 13.5px; }
.pm-path { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.pm-open { display: flex; gap: 6px; margin: 10px 0 6px; }
.pm-open input { flex: 1; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--ink); }
.pm-remember { display: block; font-size: 12px; }
.pm-note { font-size: 12px; margin: 6px 0 0; }
.proj-changed { position: sticky; top: 0; z-index: 60; padding: 8px 16px; font-size: 13.5px;
  background: #fff4e6; color: #a35a00; border-bottom: 1px solid #f0c890; }
.proj-changed button { margin-left: 8px; }
.project-view { font-size: 14px; line-height: 1.5; }
.project-view h2 { margin: 4px 0 6px; }
.project-view h3 { margin: 18px 0 6px; font-size: 15px; }
.proj-list { margin: 0; padding-left: 18px; }
.proj-list li { margin: 3px 0; }
.proj-table { border-collapse: collapse; width: 100%; margin: 4px 0; }
.proj-table th, .proj-table td {
  text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.proj-table th { color: var(--muted); font-weight: 600; }
.proj-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pbadge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pbadge-up_to_date { background: #e6f4ea; color: #1e7e34; }
.pbadge-stale { background: #fff4e5; color: #b5730a; }
.pbadge-missing { background: #f1f3f5; color: var(--muted); }
.project-view h4 {
  margin: 12px 0 4px; font-size: 12px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.proj-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; align-items: start; }
.proj-kv { border-collapse: collapse; width: 100%; }
.proj-kv td { padding: 2px 10px 2px 0; font-size: 13px; vertical-align: top; }
.proj-kv td:first-child { color: var(--muted); white-space: nowrap; }
.proj-kv code { font-size: 12px; }
.ent-bars { display: flex; flex-direction: column; gap: 3px; max-width: 520px; margin: 2px 0; }
.ent-bar { display: grid; grid-template-columns: 165px 1fr 42px; align-items: center; gap: 8px; font-size: 12px; }
.ent-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ent-track { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; height: 12px; overflow: hidden; }
.ent-fill { display: block; height: 100%; background: var(--accent); }
.ent-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .proj-cols { grid-template-columns: 1fr; } }

/* community (theme) cards on the project tab */
.comm-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; max-width: 760px; }
.comm-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--bg); }
.comm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.comm-label { font-weight: 600; }
.comm-size { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.comm-summary { margin: 4px 0 0; font-size: 13px; line-height: 1.45; }

/* global search box (thematic question over the community summaries) */
.global-ask { margin: 10px 0 2px; max-width: 760px; }
.global-ask-row { display: flex; gap: 8px; }
.global-ask-row input {
  flex: 1; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: var(--bg); color: inherit;
}
.global-ask-row button {
  padding: 7px 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.global-ask-row button:disabled { opacity: .55; cursor: default; }
.global-hint { margin: 4px 0 0; font-size: 12px; }
.global-result { margin-top: 10px; }
.global-answer {
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 14px;
  background: var(--bg); font-size: 14px; line-height: 1.55;
}
.gc-list { margin-top: 4px; }
.gc-marker { color: var(--muted); font-variant-numeric: tabular-nums; }

/* -- evaluation tab -- */
.eval-view h3 { margin: 20px 0 6px; font-size: 15px; }
.eval-view h4 { margin: 14px 0 4px; font-size: 12px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; }
.eval-controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 12px 0 4px; }
.eval-controls label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.eval-controls label span { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; min-width: 14px; }
.eval-controls input[type="range"] { width: 120px; }
.eval-controls select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: #fff; color: var(--ink); }
.eval-table { border-collapse: collapse; margin: 6px 0 4px; min-width: 380px; }
.eval-table th, .eval-table td { text-align: left; padding: 6px 16px; border-bottom: 1px solid var(--line);
  font-size: 13.5px; font-variant-numeric: tabular-nums; }
.eval-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.eval-table td.ev-best { color: #1e7e34; font-weight: 700; }
.aq-judge { margin: 10px 0 2px; font-size: 13.5px; }
.aq-judge .ev-best { color: #1e7e34; font-weight: 700; }

/* Live A/B */
.eval-ab-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.eval-ab-controls input[type="text"] { flex: 1; min-width: 240px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; outline: none; background: var(--bg); }
.eval-ab-controls input[type="text"]:focus { border-color: var(--accent); background: #fff; }
.eval-ab-controls label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.ab-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-top: 8px; }
.ab-col { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: #fff; }
.ab-col h4 { margin: 0 0 8px; font-size: 14px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.ab-answer { font-size: 13.5px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.ab-answer > :first-child { margin-top: 0; } .ab-answer > :last-child { margin-bottom: 0; }
.ab-src { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.ab-src li { padding: 3px 0; }
.ab-page { color: var(--accent); text-decoration: none; } .ab-page:hover { text-decoration: underline; }
.ab-kind { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 999px;
  margin-right: 5px; vertical-align: middle; }
.ab-seed { background: var(--accent-soft); color: var(--accent); }
.ab-related { background: #fff0e6; color: #e8590c; }
.ab-cited { color: #1e7e34; font-size: 11.5px; font-weight: 600; }
@media (max-width: 720px) { .ab-cols { grid-template-columns: 1fr; } }

/* -- System / observability tab -- */
.m-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.m-head strong { font-size: 17px; }
.m-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.m-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; }
.m-card-h { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.m-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 2px 0; color: var(--muted); }
.m-row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.m-h3 { margin: 22px 0 6px; font-size: 15px; }
.m-h3 .muted { font-weight: 400; font-size: 12.5px; }
.m-bad { color: #c0392b; font-weight: 600; }
.m-details { margin-top: 10px; }
.m-scroll { overflow-x: auto; }
.m-scroll .m-table td.num, .m-scroll .m-table td.m-name { white-space: nowrap; }
.m-details summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
.m-table { border-collapse: collapse; width: 100%; }
.m-table th, .m-table td { text-align: left; padding: 5px 12px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-variant-numeric: tabular-nums; }
.m-table th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.m-table td.num { text-align: right; }
.m-table td.m-name { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; }
.m-kind { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.m-kind.chat { background: var(--accent-soft); color: var(--accent); }
.m-kind.embed { background: #e6f4ea; color: #1e7e34; }
.m-kind.http { background: #fff0e6; color: #e8590c; }

/* chat reply telemetry line */
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* -- Memory (Gedächtnis / Second Brain) tab -- */
.mem-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.mem-head strong { font-size: 17px; }
.mem-identity { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; margin-bottom: 10px; }
.mem-identity .mem-k { color: var(--accent); font-weight: 700; margin-right: 8px; }
.mem-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.mem-chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: 13px; color: var(--muted); }
.mem-chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mem-h3 { margin: 20px 0 8px; font-size: 15px; display: flex; align-items: center; gap: 12px; }
.mem-toggle { font-size: 12px; font-weight: 400; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }

.mem-recall { display: flex; gap: 8px; flex-wrap: wrap; }
.mem-recall input { flex: 1; min-width: 260px; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; outline: none; background: var(--bg); }
.mem-recall input:focus { border-color: var(--accent); background: #fff; }
.mem-recall button { padding: 8px 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.mem-recall button.secondary { background: #fff; color: var(--accent); }
.mem-out { margin-top: 10px; }
.mem-facts { display: flex; flex-direction: column; gap: 4px; }
.mem-fact { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.mem-fact.is-sup { opacity: .55; }
.mem-score { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; min-width: 42px; }
.mem-triple { flex: 1; }
.mem-src { color: var(--muted); font-size: 12px; }
.mem-badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.mem-badge.sup { background: #fbe9e7; color: #c0392b; }
.mem-badge.conf { background: #e6f4ea; color: #1e7e34; }
.mem-badge.ret { background: #f1e6fb; color: #7b3fb0; }
.mem-badge.plan { background: #e7f0fd; color: #2c5fb3; }
.mem-badge.mat { background: #fdf3e1; color: #9a6400; }
.mem-badge.fgt { background: #eeeeee; color: #666666; }
.mem-when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mem-when-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.mem-when-ctl label { display: inline-flex; align-items: center; gap: 6px; }
.mem-when-ctl input[type=date] { padding: 3px 8px; border: 1px solid var(--line); border-radius: 7px; font: inherit;
  font-size: 12.5px; background: var(--panel); color: var(--ink); }
.mem-when-ctl .linkish { border: none; background: none; color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; padding: 0; }
.mem-tl { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; background: var(--panel); }
.mem-tl-h { font-size: 13.5px; margin-bottom: 6px; }
.mem-tl-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 13px; }
.mem-tl-row.st-past, .mem-tl-row.st-retracted { opacity: .6; }
.mem-tl-row.st-retracted .mem-tl-obj { text-decoration: line-through; }
.mem-tl-mark { width: 14px; color: var(--accent); }
.mem-tl-when { min-width: 190px; font-variant-numeric: tabular-nums; color: var(--muted); }
.mem-tl-legend { font-size: 11.5px; margin-top: 2px; }
.mem-table td.m-when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mem-context { background: var(--code-bg); border-radius: 8px; padding: 12px 14px; font-size: 12.5px;
  white-space: pre-wrap; overflow-x: auto; margin: 4px 0 0; }
.mem-ctx-h { font-size: 12px; margin-bottom: 4px; }

.mem-themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mem-theme { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: #fff; }
.mem-theme-h { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.mem-theme-s { font-size: 13px; color: var(--muted); }

.mem-table { border-collapse: collapse; width: 100%; }
.mem-table th, .mem-table td { text-align: left; padding: 5px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mem-table th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.mem-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mem-table td.m-name { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.mem-table tr.sup { display: none; }
.mem-table.show-sup tr.sup { display: table-row; opacity: .6; }

/* -- Memory: facts browser, themes, fact detail (Direction K, M2-M3) ------ */
#mem-root .linkish { border: none; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.mem-click { cursor: pointer; }
.mem-click:hover { background: var(--accent-soft); }
.mf-ctl { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.mf-ctl input { flex: 1; min-width: 240px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13.5px; background: var(--panel); color: var(--ink); }
.mf-ctl select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px;
  background: var(--panel); color: var(--ink); }
.mf-chip { display: inline-flex; gap: 8px; align-items: center; background: var(--accent-soft); border-radius: 999px;
  padding: 3px 12px; font-size: 12.5px; margin-bottom: 8px; }
.mf-table tr.st-past td, .mf-table tr.st-retracted td, .mf-table tr.st-forgotten td { opacity: .6; }
.mf-table tr.st-retracted td:nth-child(3) { text-decoration: line-through; }
.mf-pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 10px 0 4px; font-size: 13px; }
.mf-pager button { padding: 4px 12px; border: 1px solid var(--accent); background: var(--panel); color: var(--accent);
  border-radius: 7px; cursor: pointer; font: inherit; }
.mf-pager button:disabled { opacity: .4; cursor: default; }
.mf-pager[hidden] { display: none; }
.mem-badge.kind { background: #fff4e6; color: #a35a00; }
/* Direction K, M6: the memory map */
.mf-views { display: inline-flex; margin-left: 12px; vertical-align: 2px; }
.mf-view { font: inherit; font-size: 12px; font-weight: 600; padding: 2px 11px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--panel); color: var(--accent); }
.mf-view:first-child { border-radius: 7px 0 0 7px; }
.mf-view:last-child { border-radius: 0 7px 7px 0; border-left: 0; }
.mf-view.active { background: var(--accent); color: #fff; }
.mf-svg { width: 100%; height: auto; display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; cursor: grab; touch-action: none; user-select: none; }
.mf-svg.dragging { cursor: grabbing; }
.mf-svg circle { vector-effect: non-scaling-stroke; }
.mf-svg .mp-ctx { fill: var(--muted); opacity: .22; }
.mf-svg .mp-on { opacity: .88; cursor: pointer; stroke-width: 1.2; }
.mf-svg .mp-on:hover { stroke: var(--ink); stroke-width: 1.5; opacity: 1; }
.mf-svg .sel { stroke: var(--ink); stroke-width: 2.5; opacity: 1; }
.mt-q { width: 100%; max-width: 360px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13px; margin-bottom: 8px; background: var(--panel); color: var(--ink); }
.mt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2px 18px; }
.mt-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 3px 0; font-size: 13px;
  border-bottom: 1px solid var(--line); }
.mt-row[hidden] { display: none; }
.mt-name { text-align: left; font-weight: 600; }
.mt-sum { flex-basis: 100%; color: var(--muted); font-size: 12.5px; padding: 2px 0 6px; }
.mem-detail { position: fixed; top: 56px; right: 0; bottom: 0; width: min(660px, 94vw); z-index: 40; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0, 0, 0, .12);
  padding: 16px 20px 24px; }
.mem-detail[hidden] { display: none; }
.md-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.md-title { font-size: 15px; line-height: 1.45; }
.md-close { font-size: 18px; }
.md-dl { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: 13px; margin: 0 0 6px; }
.md-dl dt { color: var(--muted); }
.md-dl dd { margin: 0; }
.mem-detail h4 { margin: 16px 0 6px; font-size: 13.5px; }
.md-link { font-size: 13px; padding: 3px 4px; border-radius: 6px; }
.md-note { font-size: 12px; margin-bottom: 6px; }
.md-ex { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 12.5px; }
.md-ex-h { font-size: 11.5px; margin-bottom: 4px; }
.md-turn { padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
.md-turn:not(.hit) { color: var(--muted); }
/* Direction K, M8: sessions in the browser */
.md-ex-open { font-size: 11.5px; margin-left: 6px; }
.md-back { display: block; margin: 0 0 6px; font-size: 12.5px; }
.sess-list { max-height: 360px; overflow-y: auto; }
.sess-table td { font-size: 13px; }
.sv-turns { margin: 6px 0; }
.sv-turn { border-left: 3px solid var(--line); padding: 3px 0 5px 10px; margin: 6px 0; }
.sv-turn.sv-user { border-left-color: var(--accent); }
.sv-turn.hit { background: var(--accent-soft); border-left-color: var(--accent); }
.sv-h { font-size: 11.5px; margin-bottom: 2px; }
.sv-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.sv-more { display: block; margin: 6px auto; font-size: 12px; }
.mb-svg { display: block; margin: 4px 0; }
.mb-svg text { fill: var(--ink); }
.mb-label { font-size: 11px; }
.mb-axis { font-size: 10.5px; fill: var(--muted) !important; }
.mb-row { cursor: pointer; }
.mb-bar.mb-current, .mb-key.mb-current { fill: var(--accent); background: var(--accent); }
.mb-bar.mb-past, .mb-key.mb-past { fill: #adb5bd; background: #adb5bd; }
.mb-bar.mb-future, .mb-key.mb-future { fill: #91a7ff; background: #91a7ff; }
.mb-bar.mb-forgotten, .mb-key.mb-forgotten { fill: #dee2e6; background: #dee2e6; }
.mb-bar.mb-retracted { fill: none; stroke: #7b3fb0; stroke-dasharray: 4 3; }
.mb-key.mb-retracted { border: 1px dashed #7b3fb0; }
.mb-sel .mb-bar { stroke: var(--ink); stroke-width: 2; }
.mb-sel .mb-label { font-weight: 700; }
.mb-now { stroke: var(--muted); stroke-dasharray: 2 3; }
.mb-legend { font-size: 11px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.mb-key { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-left: 6px; }

/* -- Memory: recall explained + hook preview (Direction K, M4) ------------ */
.mem-hit { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.mem-hit .mem-fact { border-bottom: 0; padding-bottom: 1px; }
.mem-hit.is-cut { opacity: .6; }
.mem-facts.is-displaced .mem-hit { opacity: .6; }
.mem-parts { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding-left: 50px;
  display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.mem-parts b { color: var(--ink); font-weight: 600; }
.mem-parts i { font-style: normal; }
.mp-f.is-one { opacity: .55; }
.mp-eq b { color: var(--accent); }
.mp-aid { color: var(--accent); }
.mp-rank { background: var(--code-bg); border-radius: 999px; padding: 0 6px; font-size: 10.5px; }
.mp-rank.swapped { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.mem-disp-h { margin-top: 10px; }
.mem-h4 { font-size: 13px; margin: 14px 0 4px; }
.mem-hdr { color: var(--muted); font-style: italic; }
.mem-banner { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 6px 10px;
  border-radius: 4px; font-size: 13px; margin-bottom: 8px; }
.mem-badge.in { background: #e6f4ea; color: #1e7e34; }
.mem-badge.cut { background: #eeeeee; color: #666666; }
.mem-badge.probe { background: #e7f0fd; color: #2c5fb3; }

/* -- Analyse tab: world-model coupling ------------------------------------ */
.an-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.an-head strong { font-size: 15px; }
.an-metrics { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 8px; }
.an-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.an-panel h3 { margin: 0 0 8px; font-size: 13px; }
.an-tbl { width: 100%; }
.an-tbl td, .an-tbl th { padding: 3px 6px; }
.an-tbl tr.an-dim { color: var(--muted); }
.an-note { font-size: 11.5px; margin: 8px 0 6px; }
.an-coh { font-size: 13px; border-top: 1px solid var(--line); padding-top: 8px; }
.an-headline { display: flex; flex-direction: column; }
.an-big { font-size: 44px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.an-headline p { font-size: 13px; margin: 6px 0 0; }
.an-maph { margin: 16px 0 6px; font-size: 13px; }
.an-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 6px; }
.an-toggles { display: flex; flex-wrap: wrap; gap: 12px; }
.an-tog { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; cursor: pointer; }
.an-tog input[disabled] { opacity: .4; }
.an-sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.an-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.an-leg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.an-map { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.an-svg { display: block; width: 100%; height: auto; }
.an-node { cursor: pointer; transition: r .1s; }
.an-node:hover { r: 7; stroke: var(--accent); stroke-width: 2; }
@media (max-width: 900px) { .an-metrics { grid-template-columns: 1fr; } }

/* -- Ask mode (chat pane) ------------------------------------------------- */
.chat-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.chat-mode { border: 0; background: var(--panel); color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 3px 12px; cursor: pointer; }
.chat-mode.active { background: var(--accent); color: #fff; }
.ask-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--bg); font-size: 12.5px; }
.ask-controls label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 500; }
.ask-controls label.disabled { opacity: .45; cursor: not-allowed; }
.ask-controls .ask-k input { width: 46px; }
.src-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.src-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 2px 8px; font-size: 11.5px; color: var(--ink); cursor: pointer; text-align: left; line-height: 1.5; }
.src-chip:hover { border-color: var(--accent); }
.src-chip.comm { cursor: default; }
.src-chip.comm.cited { border-color: var(--accent); background: var(--accent-soft); }
.src-badge { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--code-bg); border-radius: 6px; padding: 1px 5px; }
.src-chip.related .src-badge { color: #b5651d; background: #fff3e6; }
.msg.md { white-space: normal; }
.msg.md > :first-child { margin-top: 0; }
.msg.md > :last-child { margin-bottom: 0; }
.msg.md p { margin: 0 0 8px; }

/* -- Analyse sub-tabs (Kopplung / Lücken / Dynamik) ----------------------- */
.an-subtabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.an-subtab { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); padding: 6px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.an-subtab:hover { color: var(--ink); }
.an-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.gap-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.gap-panel h3 { margin: 0 0 8px; font-size: 13px; }
.gap-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 3px 0; font-size: 13px; }
.gap-metric { display: inline-block; min-width: 130px; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.gap-page { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 2px 8px; font: inherit; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.gap-page:hover { border-color: var(--accent); color: var(--accent); }
.temp-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--code-bg); margin: 4px 0 6px; }
.temp-seg.hot { background: #ff8787; }
.temp-seg.warm { background: #ffd43b; }
.temp-seg.cold { background: #adb5bd; }
.grow-bar { display: inline-block; height: 10px; border-radius: 5px; background: var(--accent); }
details.gap-panel summary { cursor: pointer; font-size: 13px; }
details.gap-panel[open] summary { margin-bottom: 8px; }

/* -- Analyse · Dynamik: memory over time (Direction K, M5) --------------- */
.ot-chart { width: 100%; height: auto; display: block; margin: 6px 0 2px; }
.ot-learn { fill: var(--accent); }
.ot-closed { fill: #e8a25c; }
.ot-retracted { fill: #9b6fd0; }
.ot-forgotten { fill: #adb5bd; }
.ot-cur { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.ot-zero { stroke: var(--line); }
.ot-tick { stroke: var(--muted); }
.ot-ax { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.ot-hit { fill: transparent; cursor: pointer; }
.ot-hit:hover { fill: rgba(127, 127, 127, .12); }
.ot-hit.sel { fill: rgba(59, 91, 219, .14); }
.ot-legend { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.ot-key { display: inline-block; width: 12px; height: 9px; border-radius: 2px; margin-left: 8px; }
.ot-key.ot-learn { background: var(--accent); }
.ot-key.ot-closed { background: #e8a25c; }
.ot-key.ot-retracted { background: #9b6fd0; }
.ot-key.ot-forgotten { background: #adb5bd; }
.ot-key.ot-line { height: 2px; background: var(--ink); }
#ot-period:not(:empty) { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.ot-period-h { display: flex; justify-content: space-between; align-items: baseline; }
.ot-list { max-height: 300px; overflow-y: auto; }
.ot-fact { font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ot-fact:hover { background: var(--accent-soft); }

/* -- Begriffe (entity/concept browser) ----------------------------------- */
.ent-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.ent-head strong { font-size: 15px; }
.ent-controls { display: flex; gap: 10px; margin-bottom: 12px; }
.ent-controls #ent-search { flex: 1; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; outline: none; background: var(--bg); }
.ent-controls #ent-search:focus { border-color: var(--accent); background: #fff; }
.ent-controls select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--panel); }
.ent-layout { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
.ent-list { max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.ent-card { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; cursor: pointer; font: inherit; }
.ent-card:hover { border-color: var(--accent); }
.ent-card.active { border-color: var(--accent); background: var(--accent-soft); }
.ent-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.ent-meta { font-size: 11.5px; color: var(--muted); }
.ent-type { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; }
.ent-detail { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-height: 200px; }
.ent-dhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ent-dhead h3 { margin: 0; font-size: 17px; }
.ent-detail h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ent-desc { margin: 8px 0; font-size: 13.5px; }
.ent-aliases { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.ent-alias { font-size: 11.5px; color: var(--muted); background: var(--code-bg); border-radius: 10px; padding: 1px 8px; }
.ent-pages { display: flex; flex-wrap: wrap; gap: 6px; }
.ent-rel { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 2px 8px; font: inherit; font-size: 12.5px; color: var(--accent); cursor: pointer; }
.ent-rel:hover { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 900px) { .ent-layout { grid-template-columns: 1fr; } }

/* -- source/book provenance filter (multi-source corpora) ----------------- */
.source-filter { width: 100%; margin: 8px 0 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; background: var(--panel); color: var(--ink); }
.source-filter:focus { border-color: var(--accent); outline: none; }
.search-results .hit .src { color: var(--accent); font-size: 11px; font-weight: 600; margin-top: 1px; }

/* -- theme toggle + search options --------------------------------------- */
.theme-toggle, .panel-toggle { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 4px 9px; font-size: 15px; line-height: 1; cursor: pointer; }
.theme-toggle { margin-left: 6px; }
.theme-toggle:hover, .panel-toggle:hover { border-color: var(--accent); }
#toggle-sidebar { margin-right: 6px; }
.panel-toggle.right { margin-left: auto; }   /* pushes the right-hand button group */
.search-opt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 6px 0 0; cursor: pointer; }

/* -- dark theme (opt-in via <html data-theme="dark">) -------------------- */
:root[data-theme="dark"] {
  --bg: #0f1216;
  --panel: #171b22;
  --ink: #e6e8ec;
  --muted: #97a0ac;
  --line: #2a303a;
  --accent: #6b8afd;
  --accent-soft: #1c2740;
  --code-bg: #1e232c;
}
:root[data-theme="dark"] .graph-svg { background: #12151b; }
:root[data-theme="dark"] .gnode text.graph-label { stroke: #12151b; }
:root[data-theme="dark"] #search:focus { background: var(--panel); }
:root[data-theme="dark"] .graph-filter { background: var(--panel); }
:root[data-theme="dark"] .src-chip.related .src-badge { color: #e0a060; background: #3a2a17; }
:root[data-theme="dark"] .mem-badge.sup { background: #3a1f1c; color: #f08a7e; }
:root[data-theme="dark"] .mem-badge.conf { background: #173323; color: #7fd49a; }
:root[data-theme="dark"] .mem-badge.ret { background: #2c1f3a; color: #c79bf0; }
:root[data-theme="dark"] .mem-badge.plan { background: #1a2a44; color: #8fb3f5; }
:root[data-theme="dark"] .mem-badge.mat { background: #3a2c14; color: #e8b86a; }
:root[data-theme="dark"] .mem-badge.fgt { background: #2a2a2a; color: #aaaaaa; }
:root[data-theme="dark"] .mem-badge.kind { background: #3a2a14; color: #f0b46a; }
:root[data-theme="dark"] .mem-badge.in { background: #173323; color: #7fd49a; }
:root[data-theme="dark"] .mem-badge.cut { background: #2a2a2a; color: #aaaaaa; }
:root[data-theme="dark"] .mem-badge.probe { background: #1a2a44; color: #8fb3f5; }
:root[data-theme="dark"] .proj-changed { background: #3a2a14; color: #f0b46a; border-color: #5a4220; }
:root[data-theme="dark"] .project-menu { box-shadow: 0 8px 28px rgba(0, 0, 0, .5); }

/* -- Analyse map controls (projection + community focus, U11) ------------- */
.an-mapctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 8px; font-size: 12.5px; }
.an-projtog { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.an-proj { border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 7px; cursor: pointer; }
.an-proj.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.an-focus-l { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.an-focus-l select { padding: 3px 8px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 12.5px; background: var(--panel); color: var(--ink); }

/* -- "Verwandte Seiten" panel (graph connectivity under a page) ----------- */
.related { margin-top: 32px; padding-top: 16px; border-top: 2px solid var(--line); }
.related-h { font-size: 15px; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.rel-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.rel-label { flex: 0 0 auto; min-width: 150px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.rel-link { border: 1px solid var(--line); background: var(--panel); color: var(--accent); border-radius: 8px; padding: 3px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.rel-link:hover { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 700px) { .rel-label { min-width: 100%; } }

/* -- #3 entity auto-links (first mention in the prose → Begriffe) --------- */
.content a.entity-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--accent); cursor: pointer; }
.content a.entity-link:hover { color: var(--accent); border-bottom-style: solid; }

/* -- #1 inline citation links ("Abschnitt 1.6" → the page it cites) ------- */
.content a.cite-link { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.content a.cite-link:hover { border-bottom-color: var(--accent); }

/* v0.110: the agent's memory writes awaiting approval */
.mem-staged { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin: 6px 0; }
.mem-staged-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mem-staged-h .muted { flex: 1; }
.mem-staged-add { color: var(--ok, #2e7d32); font-size: 0.92em; }
.mem-staged-del { color: var(--muted); text-decoration: line-through; font-size: 0.92em; }

/* Direction K, M7: the maintenance panel */
.mem-care { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 10px 0 4px; background: var(--panel); }
.mem-care > summary { cursor: pointer; font-size: 14px; }
.mem-care[open] > summary { margin-bottom: 4px; }
.care-list { max-height: 360px; overflow-y: auto; }
.care-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.care-row.is-queued { opacity: .6; }
.care-fact { flex: 1; cursor: pointer; }
.care-fact:hover { color: var(--accent); }
.care-act { display: flex; gap: 6px; white-space: nowrap; }
.care-btn { font-size: 12px; padding: 2px 9px; }
