/* Gates Agents — interface styles.
   Palette: ink navy (structure), cool canvas, brass (evidence highlights), state colours that map to
   the four provenance elements in plan §5.2. Type: IBM Plex Sans for UI, Newsreader for analytic prose. */

:root {
  --ink: #15233b;
  --ink-2: #22324f;
  --ink-soft: #3b4a66;
  --canvas: #f3f5f8;
  --surface: #ffffff;
  --rule: #dde3ea;
  --rule-strong: #c7d0db;
  --text: #1b2433;
  --muted: #5d6a7e;
  --faint: #8794a7;

  --action: #1d4f8c;
  --action-hover: #163f71;
  --action-tint: #e8f0fa;

  --brass: #a87a1f;
  --brass-tint: #fbf3e2;

  --machine: #5e5aa0;     --machine-tint: #efeef9;
  --reviewed: #2b7a57;    --reviewed-tint: #e6f4ec;
  --approved: #1d4f8c;    --approved-tint: #e8f0fa;
  --pending: #a8620f;     --pending-tint: #fdf1e1;
  --conflict: #b0362c;    --conflict-tint: #fbeceb;

  --r-sm: 6px;
  --r-md: 10px;
  --shadow: 0 1px 2px rgba(21, 35, 59, .06), 0 1px 1px rgba(21, 35, 59, .03);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 14.5px; line-height: 1.5; color: var(--text);
  background: var(--canvas); font-variant-numeric: tabular-nums;
}
a { color: var(--action); text-decoration: none; }
.content svg, .topbar svg { width: 16px; height: 16px; vertical-align: -3px; flex: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; letter-spacing: -0.005em; }
p { margin: 0 0 .75em; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.serif { font-family: var(--serif); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--ink) 252px, transparent 252px); }
.sidebar {
  background: var(--ink); color: #c9d3e3; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 500; letter-spacing: .01em; }
.brand-sub { display: block; font-size: 11.5px; color: #8fa0bb; font-family: var(--sans); letter-spacing: 0; margin-top: -2px; }
.nav-group { margin-top: 14px; }
.nav-title { font-size: 12px; color: #8191ad; padding: 0 10px 6px; font-weight: 500; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: #d4dceb;
  font-size: 14px;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav a:hover { background: var(--ink-2); text-decoration: none; color: #fff; }
.nav a.active { background: #2a3d60; color: #fff; box-shadow: inset 3px 0 0 #d7b46a; }
.nav a .count {
  margin-left: auto; background: #d7b46a; color: var(--ink); font-size: 11.5px; font-weight: 600; border-radius: 999px;
  padding: 0 7px; line-height: 18px;
}
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #2a3a57; font-size: 12px; color: #8191ad; }
.mode-chip { display: inline-flex; align-items: center; gap: 6px; color: #c9d3e3; }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: #5cc29a; }
.mode-dot.mock { background: #d7b46a; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 32px; background: var(--surface);
  border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; max-width: 560px; position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search input[type=search] { padding-left: 34px; background: var(--canvas); border-color: transparent; }
.search input[type=search]:focus { background: #fff; border-color: var(--rule-strong); }
.user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
}
.user-meta { line-height: 1.2; font-size: 13px; }
.user-meta span { display: block; color: var(--muted); font-size: 12px; }
.menu-btn { display: none; }

.content { padding: 28px 32px 56px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 600; }
.page-head .lede { color: var(--muted); margin-top: 4px; max-width: 72ch; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }

/* ---------------------------------------------------------------- surfaces */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: var(--shadow); }
.panel-pad { padding: 20px 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--rule); }
.panel-head h2, .panel-head h3 { font-size: 15px; }
.panel-body { padding: 18px 20px; }
.stack > * + * { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.grid-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.section-title { font-size: 15px; margin: 0 0 10px; }
.divider { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }

/* figures row (dashboard) */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); margin-bottom: 22px; }
.figure { padding: 16px 20px; border-left: 1px solid var(--rule); }
.figure:first-child { border-left: 0; }
.figure .label { font-size: 13px; color: var(--muted); }
.figure .value { font-size: 26px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.figure .note { font-size: 12.5px; color: var(--muted); }
.figure .note.warn { color: var(--pending); }

/* ---------------------------------------------------------------- controls */
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=search],
input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm); padding: 8px 10px; line-height: 1.4;
}
textarea { resize: vertical; min-height: 84px; }
input:not([type=checkbox]):not([type=file]), select { height: 38px; }
select[multiple] { height: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--action-tint); }
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-soft); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); margin: 0; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--action); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; max-height: 260px; overflow: auto; padding: 4px 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 500; font-size: 14px;
  border-radius: var(--r-sm); border: 1px solid var(--rule-strong); background: #fff; color: var(--ink); padding: 7px 14px;
  cursor: pointer; white-space: nowrap; line-height: 1.35;
}
.btn:hover { background: var(--canvas); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--action); border-color: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-hover); }
.btn-danger { color: var(--conflict); border-color: #e3b8b4; }
.btn-danger:hover { background: var(--conflict-tint); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--action); padding-left: 8px; padding-right: 8px; }
.btn-quiet:hover { background: var(--action-tint); }
.btn-sm { font-size: 13px; padding: 4px 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--rule); }
.filters .f { min-width: 140px; flex: 1 1 150px; max-width: 230px; }
.filters .f label { font-size: 12px; margin-bottom: 3px; }
.filters .f.wide { flex: 2 1 240px; max-width: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); padding: 0 12px; }
.tabs a { padding: 11px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; font-size: 14px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .n { color: var(--faint); font-weight: 400; margin-left: 4px; }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--rule); background: #fafbfc; white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table .title-cell { font-weight: 500; color: var(--ink); }
.table .sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------- tags & states */
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; line-height: 1; padding: 4px 8px;
  border-radius: 999px; background: var(--canvas); color: var(--ink-soft); border: 1px solid var(--rule); white-space: nowrap;
}
.tag svg { width: 12px; height: 12px; }
.tag.machine { background: var(--machine-tint); color: var(--machine); border-color: #dcdaf0; }
.tag.reviewed { background: var(--reviewed-tint); color: var(--reviewed); border-color: #c8e6d5; }
.tag.approved { background: var(--approved-tint); color: var(--approved); border-color: #cddcf0; }
.tag.pending { background: var(--pending-tint); color: var(--pending); border-color: #f1d9b7; }
.tag.conflict { background: var(--conflict-tint); color: var(--conflict); border-color: #efc9c5; }
.tag.restricted { background: #f4ecf7; color: #7a3d8f; border-color: #e5d2ec; }
.tag.internal { background: #eef2f7; color: #3b4a66; }
.tag.legacy { background: #f1f1ee; color: #5f5e55; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.sev { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.sev.critical { background: #7d1a12; } .sev.high { background: var(--conflict); } .sev.medium { background: var(--pending); } .sev.low { background: var(--faint); }

/* ---------------------------------------------------------------- provenance trail (signature element)
   Four separate elements (plan §5.2): source provenance → machine processing → content review → institutional. */
.trail { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 4px 0 2px; }
.trail .step { position: relative; padding: 22px 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.3; }
.trail .step::before { content: ""; position: absolute; top: 7px; left: 0; right: 0; height: 2px; background: var(--rule); }
.trail .step:first-child::before { left: 6px; }
.trail .step:last-child::before { right: auto; width: 0; }
.trail .dot { position: absolute; top: 1px; left: 0; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--rule-strong); z-index: 1; }
.trail .step b { display: block; color: var(--ink-soft); font-weight: 500; font-size: 12.5px; }
.trail .step.done .dot { border-color: var(--reviewed); background: var(--reviewed); }
.trail .step.done::before { background: var(--reviewed); }
.trail .step.machine .dot { border-color: var(--machine); background: var(--machine); }
.trail .step.machine::before { background: linear-gradient(90deg, var(--machine), var(--rule) 70%); }
.trail .step.wait .dot { border-color: var(--pending); background: #fff; }
.trail .step.off .dot { border-style: dashed; }
.trail .step.off b { color: var(--faint); }

/* freshness meter */
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.fresh i { display: inline-block; width: 26px; height: 5px; border-radius: 3px; background: var(--rule); position: relative; overflow: hidden; }
.fresh i::after { content: ""; position: absolute; inset: 0; width: var(--f, 0%); background: var(--reviewed); }
.fresh.aging i::after { background: var(--pending); }
.fresh.stale i::after { background: var(--conflict); }

/* ---------------------------------------------------------------- topic list */
.topic-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.topic-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 10px; }
.topic-card:hover { border-color: var(--rule-strong); box-shadow: 0 4px 14px rgba(21, 35, 59, .06); }
.topic-card h3 { font-family: var(--serif); font-weight: 500; font-size: 19px; line-height: 1.25; }
.topic-card h3 a { color: var(--ink); }
.topic-card .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.topic-card .summary { font-family: var(--serif); font-size: 15px; line-height: 1.5; color: #2c3647; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.topic-card .empty { font-size: 13.5px; color: var(--faint); font-style: italic; }
.topic-card .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--rule); }
.dim-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.dim-head h2 { font-size: 16px; }
.dim-head:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- topic page */
.topic-title { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.15; letter-spacing: -0.01em; max-width: 30ch; }
.state { padding: 24px 26px; }
.state-summary { font-family: var(--serif); font-size: 18.5px; line-height: 1.6; color: #1f2938; max-width: 68ch; }
.state-label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); font-size: 13.5px; border: 1px solid; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice.machine { background: var(--machine-tint); border-color: #dcdaf0; color: #403d78; }
.notice.pending { background: var(--pending-tint); border-color: #f1d9b7; color: #7a4609; }
.notice.conflict { background: var(--conflict-tint); border-color: #efc9c5; color: #84261e; }
.notice.info { background: var(--action-tint); border-color: #cddcf0; color: #18406f; }

.devs { list-style: none; margin: 0; padding: 0; }
.dev { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--rule); }
.dev:first-child { border-top: 0; }
.dev .when { font-size: 12.5px; color: var(--muted); padding-top: 2px; }
.dev .what { font-size: 15px; color: var(--text); }
.cites { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
details.cite { display: inline-block; }
details.cite > summary {
  list-style: none; cursor: pointer; font-size: 12px; padding: 3px 8px; border-radius: 4px; background: var(--brass-tint);
  color: #7a5714; border: 1px solid #efdcb3; display: inline-flex; gap: 5px; align-items: center;
}
details.cite > summary::-webkit-details-marker { display: none; }
details.cite > summary svg { width: 12px; height: 12px; }
details.cite[open] { display: block; flex-basis: 100%; }
.quote {
  margin: 8px 0 4px; padding: 10px 14px; border-left: 3px solid var(--brass); background: #fffdf8; font-family: var(--serif);
  font-size: 15px; color: #3a3324; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.quote-meta { font-size: 12.5px; color: var(--muted); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13.5px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--text); text-align: right; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--rule); }
.timeline li { position: relative; padding: 0 0 16px 26px; font-size: 13.5px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--rule-strong); }
.timeline li.cur::before { border-color: var(--ink); background: var(--ink); }
.timeline li.pend::before { border-color: var(--pending); }
.timeline li.rej::before { border-color: var(--conflict); }
.timeline .v { font-weight: 600; color: var(--ink); }
.timeline .c { color: var(--muted); margin-top: 2px; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { padding: 10px 0; border-top: 1px solid var(--rule); font-size: 13.5px; }
.doc-list li:first-child { border-top: 0; padding-top: 0; }
.doc-list .t { color: var(--ink); font-weight: 500; }

/* ---------------------------------------------------------------- chat */
.chat { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 22px; height: calc(100vh - 150px); min-height: 520px; }
.chat-side { overflow: auto; }
.chat-side a { display: block; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-soft); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-side a:hover, .chat-side a.on { background: #e7ebf1; text-decoration: none; }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }
.msg { max-width: 760px; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 14px 14px 4px 14px; font-size: 14.5px; }
.msg.bot { align-self: flex-start; width: 100%; }
.msg.bot .body { font-size: 15px; line-height: 1.6; }
.msg.bot .body p { margin: 0 0 .7em; }
.msg.bot .body ul { margin: 0 0 .7em; padding-left: 20px; }
.msg.bot .body .synth { border-top: 1px dashed var(--rule-strong); padding-top: 8px; color: #3d4659; font-style: italic; }
.ref { display: inline-block; font-size: 11.5px; font-weight: 600; color: #7a5714; background: var(--brass-tint); border: 1px solid #efdcb3; padding: 0 5px; border-radius: 4px; margin: 0 1px; cursor: pointer; vertical-align: 1px; }
.sources { margin-top: 12px; display: grid; gap: 8px; }
.source { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: #fff; font-size: 13px; }
.source.flash { box-shadow: 0 0 0 3px var(--brass-tint); border-color: var(--brass); }
.source .k { font-weight: 600; color: #7a5714; }
.source .q { font-family: var(--serif); font-size: 14px; color: #3a3324; margin-top: 4px; }
.chat-form { border-top: 1px solid var(--rule); padding: 14px 18px; display: flex; gap: 10px; align-items: flex-end; background: #fff; border-radius: 0 0 var(--r-md) var(--r-md); }
.chat-form textarea { min-height: 46px; max-height: 160px; }
.chat-empty { margin: auto; text-align: center; max-width: 520px; color: var(--muted); }
.chat-empty h2 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin-bottom: 8px; }
.suggest { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.suggest button { text-align: left; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------------------------------------------------------------- misc */
.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { padding: 10px 14px; border-radius: var(--r-sm); font-size: 14px; border: 1px solid; word-break: break-word; }
.flash.success { background: var(--reviewed-tint); border-color: #c8e6d5; color: #1f5c41; }
.flash.error { background: var(--conflict-tint); border-color: #efc9c5; color: #84261e; }
.flash.warning { background: var(--pending-tint); border-color: #f1d9b7; color: #7a4609; }
.flash.info { background: var(--action-tint); border-color: #cddcf0; color: #18406f; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pre { white-space: pre-wrap; font-family: var(--serif); font-size: 15.5px; line-height: 1.65; color: #253041; max-height: 560px; overflow: auto; }
.diff-add { background: #e9f6ee; border-left: 3px solid var(--reviewed); padding: 6px 10px; margin: 6px 0; font-size: 14px; }
.diff-del { background: #fbeeed; border-left: 3px solid var(--conflict); padding: 6px 10px; margin: 6px 0; font-size: 14px; text-decoration: line-through; text-decoration-color: rgba(176, 54, 44, .4); }
.bar { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--action); }
.conf { font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--ink); color: #dfe6f1; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { color: #fff; font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1.1; max-width: 14ch; }
.login-art p { max-width: 46ch; color: #aebbd1; font-size: 15px; }
.login-art svg.grid { position: absolute; right: -80px; bottom: -80px; width: 560px; opacity: .5; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-form .box { width: 100%; max-width: 360px; }
.demo-users { font-size: 13px; color: var(--muted); margin-top: 22px; border-top: 1px solid var(--rule); padding-top: 14px; }
.demo-users code { font-size: 12.5px; color: var(--ink-soft); }
.digest-sec h4 { font-size: 14px; margin: 16px 0 8px; }
.digest-item { padding: 10px 0; border-top: 1px solid var(--rule); }
.digest-item:first-of-type { border-top: 0; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .grid-cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 18, 32, .45); }
  .menu-btn { display: inline-flex; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 10px 16px; }
  .user-meta { display: none; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-side { display: none; }
  .topic-list { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .dev { grid-template-columns: 1fr; gap: 4px; }
  .topic-title { font-size: 27px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.btn-col { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

ul.doc-list.panel-body { padding: 4px 20px 16px; }
ul.doc-list.panel-body li:first-child { padding-top: 12px; }
.btn-col .btn { white-space: normal; text-align: center; }

/* ---------------------------------------------------------------- chat answers (formatted + streaming) */
.msg.bot .body { font-size: 15px; line-height: 1.65; color: var(--text); max-width: 72ch; }
.msg.bot .body > :first-child { margin-top: 0; }
.msg.bot .body p { margin: 0 0 .8em; }
.msg.bot .body p:first-child strong:first-child { color: var(--ink); }
.msg.bot .body strong { font-weight: 600; color: var(--ink); }
.msg.bot .body h4 { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); margin: 1.2em 0 .45em; padding-bottom: 4px; border-bottom: 1px solid var(--rule); }
.msg.bot .body ul, .msg.bot .body ol { margin: 0 0 .9em; padding-left: 1.25em; }
.msg.bot .body li { margin: .35em 0; padding-left: .2em; }
.msg.bot .body li::marker { color: var(--faint); }
.msg.bot .body code { font-size: 13px; background: var(--canvas); padding: 1px 5px; border-radius: 4px; }
.msg.bot .body .synth { margin: 1em 0 .4em; padding: 10px 14px; background: var(--machine-tint); border-left: 3px solid var(--machine); border-radius: 0 var(--r-sm) var(--r-sm) 0; border-top: 0; font-size: 14.5px; font-style: normal; color: #36345e; }
.msg.bot .body .synth span { display: block; font-size: 12px; font-weight: 600; color: var(--machine); margin-bottom: 2px; }
.msg.bot .notice { margin-top: 10px; }
.msg.bot .status { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.msg.bot .status.quiet .typing { display: none; }
.caret { display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -2px; background: var(--action); border-radius: 1px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.sources-wrap { margin-top: 14px; }
.sources-wrap > summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-soft); margin-bottom: 8px; }
.bot-foot { margin-top: 10px; }

/* ---------------------------------------------------------------- policy tracker browser
   One colour per tag group (same hues as the tracker team's browser). */
.g1 { --g: #4553a6; --g-soft: #e9ebf8; }  /* Sector */
.g2 { --g: #6b4a9e; --g-soft: #efe9f8; }  /* Governance, regulation and authority */
.g3 { --g: #8f5d0a; --g-soft: #f8eeda; }  /* Economic transformation and innovation */
.g4 { --g: #0f6e6e; --g-soft: #dff1f0; }  /* Infrastructure, capability and evaluation */
.g5 { --g: #a83c62; --g-soft: #f9e6ed; }  /* Social equity and culture */
.g6 { --g: #3d7a2a; --g-soft: #e5f2df; }  /* Environment */
.g0 { --g: var(--ink-soft); --g-soft: var(--canvas); }
.flag-icon { display: inline-block; width: 1.6em; }

.browse { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 22px; align-items: start; }
.browse-filters { padding: 14px 14px 18px; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.browse-search input { width: 100%; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.seg a { padding: 3px 9px; border-radius: 999px; color: var(--ink-soft); border: 1px solid transparent; display: inline-flex; gap: 6px; align-items: center; }
.seg a:hover { background: var(--canvas); text-decoration: none; }
.seg a.on { background: var(--action-tint); color: var(--action); border-color: #cddcf0; font-weight: 500; }
.facet { border-top: 1px solid var(--rule); padding: 8px 0 4px; }
.facet > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); padding: 4px 2px; list-style: none; display: flex; justify-content: space-between; }
.facet > summary::after { content: "+"; color: var(--faint); font-weight: 400; }
.facet[open] > summary::after { content: "−"; }
.facet > summary::-webkit-details-marker { display: none; }
.facet ul { list-style: none; margin: 4px 0 4px; padding: 0; max-height: 280px; overflow: auto; }
.facet li a { display: flex; justify-content: space-between; gap: 10px; padding: 4px 8px; border-radius: var(--r-sm); color: var(--text); font-size: 13.5px; }
.facet li a:hover { background: var(--canvas); text-decoration: none; }
.facet li a.on { background: var(--action-tint); color: var(--action); font-weight: 500; }
.facet li a.any { font-style: italic; color: var(--muted); }
.tag-facet > summary { color: var(--g); }
.tag-facet li a.on { background: var(--g-soft); color: var(--g); }
.facet-title { font-size: 12.5px; color: var(--muted); font-weight: 500; margin: 16px 2px 2px; }
.count { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.results-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.results-head h2 { font-size: 18px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; }
.fchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; background: var(--action-tint); color: var(--action); border: 1px solid #cddcf0; }
.fchip[class*=" g"] { background: var(--g-soft); color: var(--g); border-color: transparent; }
.fchip:hover { text-decoration: none; filter: brightness(.97); }
.fchip-label { font-size: 11.5px; opacity: .75; }
.active-filters .clear { font-size: 13px; margin-left: 4px; }

.rcard { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 10px; }
.rcard h3 { font-family: var(--serif); font-weight: 500; font-size: 18px; line-height: 1.3; }
.rcard h3 a { color: var(--ink); }
.rmeta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.rmeta a { color: var(--ink-soft); }
.rmeta .brief { color: var(--brass); font-weight: 500; }
.rsyn { color: #3a4456; font-size: 14px; margin: 8px 0 0; max-width: 90ch; }
.tchips { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 0; }
.tchip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--g-soft); color: var(--g); }
.tchip:hover { text-decoration: none; filter: brightness(.96); }
.tchip.on { outline: 1.5px solid var(--g); }
.tchips .more { font-size: 12px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.tg-head { font-size: 12.5px; font-weight: 600; margin: 12px 0 2px; color: var(--g); }
.tg-head a { color: var(--g); }
.kv-wide { grid-template-columns: 190px 1fr; }

.tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.tiles a { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm); color: var(--text); font-size: 14px; }
.tiles a:hover { border-color: var(--action); text-decoration: none; }
.tgroups { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.tgroup { background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--g); border-radius: var(--r-md); padding: 14px 16px; }
.tgroup h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14.5px; margin-bottom: 8px; }
.tgroup h3 a { color: var(--g); }
.gcount { background: var(--g-soft); color: var(--g); font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; }
.tgroup ul { list-style: none; margin: 0; padding: 0; }
.tgroup li a { display: flex; justify-content: space-between; gap: 10px; padding: 4px 6px; border-radius: var(--r-sm); color: var(--text); font-size: 13.5px; }
.tgroup li a:hover { background: var(--g-soft); text-decoration: none; }

@media (max-width: 1000px) {
  .browse { grid-template-columns: 1fr; }
  .browse-filters { position: static; max-height: none; }
}

/* ---------------------------------------------------------------- agents on/off */
.off-pill { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 10.5px; line-height: 16px; background: #5a2a2a; color: #f3c9c4; vertical-align: 1px; }
.agent-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.agent-card { padding: 22px 24px; }
.agent-card.is-off { background: #fbfbfc; }
.agent-card.is-off h2 { color: var(--muted); }
.agent-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.agent-top h2 { font-size: 19px; }
.agent-state { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin: 14px 0 0; }
.switch { position: relative; width: 52px; height: 30px; border-radius: 999px; border: 0; background: var(--rule-strong); cursor: pointer; flex: none; transition: background .15s ease; }
.switch.on { background: var(--reviewed); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s ease; }
.switch.on .knob { transform: translateX(22px); }
@media (max-width: 860px) { .agent-cards { grid-template-columns: 1fr; } }
