/* Palette and visual language based on https://www.opus.com/css/tokens.css.
   Use locally available typefaces; no third-party requests from the workspace. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elevated: #f3f3f1;
  --bg-section: #f6f6f4;
  --bg-card: #fbfbfa;
  --fg: #0e0e10;
  --fg-secondary: #45464a;
  --fg-muted: #8a8a86;
  --muted: #696a67;
  --border: #e7e5e0;
  --border-strong: #d8d6d0;
  --brand: #2162df;
  --brand-hover: #194ebe;
  --primary: #0426cd;
  --primary-hover: #062aad;
  --accent-soft: #eef0fb;
  --accent-warm: #f4d35e;
  --person: #2dd4bf;
  --email: #6684ab;
  --meeting: #2162df;
  --client: #a78bfa;
  --graph-edge: #d8d6d0;
  --graph-member-edge: #c8bce4;
  --font-body: "PP Neue Montreal", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "PP Neue Montreal Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { opacity: .5; cursor: wait; }
button, a, input, textarea, select { outline-offset: 4px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }
input, textarea, select { color: var(--fg); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
::selection { background: #dce6ff; color: var(--fg); }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-weight: 500; letter-spacing: -.025em; }
h1 { font-size: clamp(34px, 3vw, 46px); line-height: 1.06; margin-bottom: 17px; }
h2 { font-size: 16px; margin-bottom: 6px; }
h3 { font-size: 15px; }
p { line-height: 1.6; }
.heading-muted { color: var(--fg-muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.6; }
.eyebrow {
  font: 500 10px/1.5 var(--font-mono);
  letter-spacing: .09em;
  margin-bottom: 16px;
  color: var(--brand);
}

/* White surfaces and fine rails keep the workspace close to the reference. */
.workspace { display: grid; grid-template-columns: 60px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 60px; min-height: 0; background: var(--bg-card); border-right: 1px solid var(--border);
  padding: 12px 8px; display: flex; flex-direction: column; gap: 8px; overflow: auto;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--fg); font-size: 13px;
  font-weight: 400; letter-spacing: -.015em; line-height: 1.3;
}
.brand:hover { color: var(--fg); }
.brand-logo { display: block; width: 140px; height: auto; flex-shrink: 0; }
.nav-caption, .nav-label, .sidebar-note { display: none; }
.nav-item { border: 1px solid transparent; background: none; color: var(--fg-secondary); width: 100%; height: 40px; border-radius: 6px; padding: 6px; }
.nav-item > span:first-child { font-size: 21px; }
.nav-item:hover { background: var(--bg-elevated); }
.nav-item.active { color: var(--primary); background: var(--accent-soft); border-color: #dfe5f7; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-right: 7px; }
.sidebar-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; justify-content: center; }
.sidebar-bottom > .avatar, .sidebar-bottom > div { display: none; }
.icon-button { background: none; border: none; border-radius: 4px; font-size: 22px; padding: 4px 7px; color: inherit; }
.icon-button:hover { background: var(--bg-elevated); }
.sidebar-bottom .icon-button { font-size: 19px; }
.main { min-height: 0; min-width: 0; padding: 0 12px 6px; display: flex; flex-direction: column; }
.topbar { grid-column: 1 / -1; min-height: 46px; padding-inline: 12px; display: flex; align-items: center; gap: 16px; color: var(--muted); }
.topbar h1 { font-size: 13px; line-height: 1.3; letter-spacing: -.015em; margin: 0; white-space: nowrap; color: var(--fg); }
#refresh { font-size: 22px; padding: 0 8px; }
#global-error { margin: 0 0 6px; padding: 6px 10px; max-height: 90px; overflow: auto; flex-shrink: 0; }
.workspace-status { display: flex; flex-wrap: wrap; gap: 3px 16px; padding-top: 5px; font-size: 10px; line-height: 1.5; color: var(--muted); flex-shrink: 0; }
#discovery-status { margin-left: auto; }
.primary, .secondary { border-radius: 4px; padding: 11px 15px; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 30px; }
.primary { background: var(--primary); color: var(--bg); border: 1px solid var(--primary); }
.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.secondary { background: #efefef; border: 1px solid var(--border-strong); white-space: nowrap; }
.secondary:hover { background: #e2e2e2; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-left: auto; }
.stat { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.stat strong { font-size: 13px; font-weight: 500; color: var(--fg); font-variant-numeric: tabular-nums; }
.stat small { font-size: 11px; color: var(--muted); }

/* Relationship map */
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(350px, 31%); grid-template-rows: minmax(0, 1fr); gap: 10px; flex: 1; min-height: 0; }
.graph-card, .detail-card { min-width: 0; border: 1px solid var(--border); background: var(--bg); border-radius: 10px; overflow: hidden; }
.graph-card { display: flex; flex-direction: column; min-height: 0; }
.graph-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 7px 10px; flex-shrink: 0; }
#graph-count { font-size: 11px; }
#ask-timeline { margin-left: auto; }
.legend { display: flex; gap: 12px; font-size: 10px; color: var(--fg-secondary); }
.legend span { white-space: nowrap; }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.node-type-filters { gap: 4px; flex-wrap: wrap; }
.node-type-filters button { background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; font-size: 10px; white-space: nowrap; }
.node-type-filters button:hover { background: var(--accent-soft); }
.node-type-filters button[aria-pressed="false"] { color: var(--muted); background: transparent; text-decoration: line-through; }
.node-type-filters button[aria-pressed="false"] i { opacity: .3; }
.node-type-filters button:disabled { cursor: default; }
.client-color { background: var(--client); }
.person-color { background: var(--person); }
.meeting-color { background: var(--meeting); }
.filters { display: flex; margin: 0 10px 6px; gap: 8px; align-items: center; }
.scope-filter { flex: 0 1 220px; min-width: 150px; }
.scope-filter select { width: 100%; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; background: var(--bg-card); }
.search-label { display: flex; align-items: center; gap: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px; padding-left: 10px; flex: 1; min-width: 0; }
.search-label:focus-within { border-color: var(--brand); }
.search-label input { border: 0; background: none; min-width: 0; width: 100%; padding: 8px 5px; font-size: 12px; }
.search-label span { font-size: 21px; color: var(--muted); }
.text-button { border: none; border-radius: 4px; background: none; font-size: 11px; color: var(--brand); padding: 6px; }
.text-button:hover { background: var(--accent-soft); }
.date-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 0 10px 8px; }
.date-filters label { font-size: 10px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.date-filters input { min-width: 0; max-width: 123px; font-size: 11px; padding: 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--fg-secondary); }
.date-filters > span { font: 9px/1.6 var(--font-mono); }
#timeline-sort-label { margin-left: auto; }
#timeline-sort { font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 5px; background: var(--bg); }
.graph-stage { flex: 1; min-height: 0; position: relative; background-color: var(--bg-card); background-image: radial-gradient(#d8d6d0 .7px, transparent .7px); background-size: 20px 20px; border-block: 1px solid var(--border); }
.graph-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.graph-stage svg:active { cursor: grabbing; }
.graph-node { cursor: pointer; }
.node-label { font-size: 11px; fill: var(--fg-secondary); paint-order: stroke; stroke: var(--bg-card); stroke-width: 4px; stroke-linejoin: round; }
.graph-node:hover .node-label, .graph-node.selected .node-label { fill: var(--fg); font-weight: 700; }
.graph-node:focus { outline: none; }
.graph-node:focus-visible .node-body, .graph-node.selected .node-body { stroke: var(--primary); stroke-width: 3; }
.graph-node:hover .node-halo, .graph-node.selected .node-halo { opacity: .3; }
.graph-node circle { transition: stroke-width .15s, opacity .15s; }
.graph-empty { position: absolute; top: 38%; left: 12%; right: 12%; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.map-controls { position: absolute; left: 16px; bottom: 18px; display: flex; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 5px; overflow: hidden; box-shadow: 0 2px 4px #0e0e1005; }
.map-controls button { background: transparent; border: 0; border-right: 1px solid var(--border); font-size: 19px; width: 34px; height: 34px; }
.map-controls button:hover { background: var(--bg-elevated); }
.map-controls button:last-child { border: 0; }
.map-controls button:focus-visible { outline-offset: -3px; }
.map-hint { position: absolute; bottom: 29px; right: 18px; color: var(--muted); font-size: 10px; pointer-events: none; }
.graph-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px; flex-shrink: 0; font: 9px/1.5 var(--font-mono); color: var(--muted); }
.graph-footer .status-dot { width: 5px; height: 5px; }

/* Questions, citations and source material */
.detail-card { display: flex; flex-direction: column; min-height: 0; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 14px; flex-shrink: 0; }
.panel-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 14px 0; font-size: 12px; color: var(--muted); }
.panel-tabs button:hover { color: var(--fg); }
.panel-tabs button.active { border-bottom-color: var(--brand); color: var(--brand); font-weight: 500; }
.ask-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.chat-history { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.ask-intro { padding: 20px 16px 8px; }
.spark { background: var(--accent-soft); border: 1px solid #dfe5f7; width: 40px; height: 40px; border-radius: 8px; font-size: 27px; display: grid; place-items: center; margin-bottom: 23px; color: var(--primary); }
.ask-intro h2 { font-size: 21px; line-height: 1.15; }
.ask-intro p { font-size: 12px; color: var(--muted); margin-top: 12px; }
.suggestions { padding: 0 16px 12px; display: flex; flex-direction: column; gap: 9px; }
.suggestions button { border: 1px solid var(--border); background: var(--bg-card); border-radius: 6px; text-align: left; font-size: 12px; line-height: 1.5; padding: 9px 11px; color: var(--fg-secondary); }
.suggestions button:hover { background: var(--accent-soft); border-color: #c6d4f3; color: var(--primary); }
.ask-form { flex-shrink: 0; padding: 12px 14px 10px; border-top: 1px solid var(--border); background: var(--bg); }
.ask-form > label { font-size: 11px; color: var(--muted); margin-right: 9px; }
.ask-form select { font-size: 11px; border: 1px solid var(--border-strong); background: var(--bg); border-radius: 4px; max-width: calc(100% - 85px); padding: 6px; }
.question-box { margin-top: 9px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--bg-card); padding: 11px 12px; }
.question-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px var(--accent-soft); }
.question-box textarea { width: 100%; resize: vertical; border: 0; background: none; font-size: 12px; line-height: 1.6; min-height: 44px; max-height: 160px; }
.question-box textarea:focus { outline: none; }
.question-box > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.checkbox { font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.checkbox input { accent-color: var(--primary); width: 13px; }
.send-button { background: var(--primary); color: var(--bg); border: 0; width: 31px; height: 31px; border-radius: 4px; font-size: 20px; }
.send-button:hover { background: var(--primary-hover); }
.ask-form > p { margin: 7px 0 0; font-size: 10px; line-height: 1.6; }
.answers { padding: 12px 16px; overflow-wrap: anywhere; }
.question-display { padding: 13px; background: var(--accent-soft); border: 1px solid #dfe5f7; border-radius: 6px; font-size: 13px; line-height: 1.5; margin-bottom: 17px; }
.answer-claim { font-size: 13px; line-height: 1.75; margin-bottom: 19px; }
.citation { display: block; width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 12px; text-align: left; background: var(--bg-card); margin: 9px 0; font-size: 11px; color: var(--fg-secondary); line-height: 1.6; }
.citation:hover { background: var(--accent-soft); border-color: #c6d4f3; }
.citation strong { display: block; font-size: 12px; color: var(--brand); }
.citation blockquote { margin: 8px 0 0; padding-left: 10px; border-left: 2px solid var(--brand); color: var(--fg-secondary); white-space: pre-wrap; max-height: 180px; overflow: auto; }
.coverage { font-size: 11px; color: var(--muted); padding: 12px 0 20px; line-height: 1.7; }
.notice { padding: 12px 16px; background: #fff9e5; border: 1px solid #e9d896; border-radius: 6px; font-size: 12px; line-height: 1.5; margin: 15px 0; color: #705514; }
.error { color: #ae352a; font-size: 12px; line-height: 1.6; }
.notice.error { background: #fff3f1; border-color: #f1cec8; }
.inspect-panel { flex: 1; min-height: 0; padding: 18px; overflow: auto; overscroll-behavior: contain; overflow-wrap: anywhere; }
.empty-inspector { text-align: center; margin: 70px 15px; color: var(--muted); }
.empty-inspector > span { font-size: 40px; font-weight: 400; display: block; margin-bottom: 23px; color: var(--brand); }
.empty-inspector p { font-size: 13px; }
.node-badge { display: inline-flex; padding: 6px 9px; border-radius: 4px; background: var(--accent-soft); color: var(--primary); font: 10px/1.5 var(--font-mono); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 17px; }
.inspect-panel h2 { font-size: 25px; line-height: 1.2; color: var(--fg); }
.detail-time { font-size: 12px; line-height: 1.7; color: var(--muted); }
.detail-tabs { display: flex; flex-wrap: wrap; gap: 16px; border-bottom: 1px solid var(--border); margin: 20px 0; }
.detail-tabs button { border: 0; border-bottom: 2px solid transparent; background: none; padding: 11px 0; font-size: 12px; color: var(--muted); }
.detail-tabs button.active { border-bottom-color: var(--brand); color: var(--brand); }
.transcript-turn { padding: 14px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 12px; }
.transcript-turn.highlight { background: #fcf3cf; box-shadow: inset 3px 0 var(--accent-warm); border-radius: 4px; padding: 14px 12px; }
.turn-heading { font: 10px/1.7 var(--font-mono); color: var(--brand); display: flex; flex-wrap: wrap; gap: 7px; justify-content: space-between; }
.transcript-turn p { font-size: 13px; color: var(--fg-secondary); line-height: 1.8; white-space: pre-wrap; margin: 8px 0 0; }
.metadata { font: 11px/1.8 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-section); border: 1px solid var(--border); padding: 13px; border-radius: 6px; }
.note-text { white-space: pre-wrap; font-size: 13px; line-height: 1.8; }
.related-node { display: block; width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--border); padding: 12px; border-radius: 5px; margin: 8px 0; font-size: 12px; line-height: 1.7; }
.related-node:hover { background: var(--bg-section); border-color: var(--border-strong); }
.related-node small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.inspector-search { width: 100%; border: 1px solid var(--border-strong); padding: 10px; border-radius: 4px; font-size: 12px; margin-bottom: 8px; background: var(--bg-card); }
.company-source { display: block; font-size: 12px; line-height: 1.7; margin: 8px 0; overflow-wrap: anywhere; }
.loading { padding: 24px; font-size: 13px; color: var(--muted); }
.source-type { font: 10px/1.5 var(--font-mono); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Sign-in and client management use the same surfaces and controls. */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 40px 24px;
  background-color: var(--bg-section);
  background-image: linear-gradient(90deg, transparent calc(50% - 281px), var(--border) calc(50% - 281px), var(--border) calc(50% - 280px), transparent calc(50% - 280px), transparent calc(50% + 280px), var(--border) calc(50% + 280px), var(--border) calc(50% + 281px), transparent calc(50% + 281px));
}
.login-card { width: 100%; max-width: 480px; background: var(--bg); border: 1px solid var(--border); border-top: 3px solid var(--primary); border-radius: 10px; padding: 40px; }
.login-card .brand { margin-bottom: 37px; }
.login-card h1 { font-size: 43px; margin-bottom: 20px; }
.login-card > .muted { font-size: 14px; }
.login-card label { display: block; font-size: 12px; margin: 30px 0 10px; }
.login-card input { display: block; width: 100%; border: 1px solid var(--border-strong); border-radius: 4px; padding: 13px; background: var(--bg-card); margin-bottom: 13px; }
.login-card .primary { width: 100%; justify-content: space-between; padding: 13px 15px; }
.login-card > .small { margin: 24px 0 0; font-size: 11px; }
dialog { border: 1px solid var(--border); border-radius: 14px; max-width: 790px; width: calc(100% - 40px); padding: 32px; color: var(--fg); background: var(--bg); max-height: 90vh; box-shadow: 0 24px 80px #0e0e1026; }
dialog::backdrop { background: #0e0e1080; backdrop-filter: blur(4px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-heading h2 { font-size: 29px; }
.dialog-heading .eyebrow { margin-bottom: 10px; }
dialog > .muted { font-size: 13px; }
.client-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 30px; margin-top: 26px; }
.client-layout form label { display: block; font-size: 12px; margin: 0 0 8px; }
.client-layout form input, .client-layout textarea { width: 100%; border: 1px solid var(--border-strong); padding: 11px; border-radius: 4px; font-size: 13px; margin-bottom: 18px; background: var(--bg-card); }
.client-layout textarea { resize: vertical; margin-bottom: 0; }
.client-layout form input[readonly] { color: var(--muted); background: var(--bg-elevated); }
.client-layout .primary { width: 100%; }
#client-list { margin-top: 15px; }
.mobile-actions { display: none; gap: 10px; white-space: nowrap; }
.client-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.client-actions button { font-size: 11px; padding: 10px; }
.domain-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.domain-tag { padding: 3px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--primary); font: 10px/1.5 var(--font-mono); overflow-wrap: anywhere; }
.merge-controls, .merge-source-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.merge-controls > label, .merge-source-field legend { display: block; font-size: 13px; font-weight: 500; margin-bottom: 10px; }
.merge-controls > select { width: 100%; padding: 12px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--bg-card); font-size: 13px; }
.merge-controls > p { margin: 9px 0 24px; }
.merge-sources { max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.merge-source { display: flex; align-items: flex-start; gap: 12px; padding: 13px; border-bottom: 1px solid var(--border); cursor: pointer; }
.merge-source:last-child { border-bottom: 0; }
.merge-source:has(input:checked) { background: var(--accent-soft); }
.merge-source input { accent-color: var(--primary); margin-top: 3px; flex-shrink: 0; }
.merge-source > span { min-width: 0; }
.merge-source strong { display: block; font-size: 13px; font-weight: 500; }
.merge-source small { display: block; color: var(--muted); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.merge-preview { margin-top: 24px; padding: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow-wrap: anywhere; }
.merge-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-block: 16px; border-block: 1px solid var(--border); margin: 16px 0; }
.merge-summary strong { display: block; font-size: 24px; font-weight: 500; }
.merge-summary span { font: 10px/1.5 var(--font-mono); color: var(--muted); }
.merge-preview details, .merge-history { margin: 14px 0; font-size: 12px; }
.merge-preview summary, .merge-history summary { cursor: pointer; color: var(--brand); line-height: 1.6; }
.merge-preview ul { max-height: 190px; overflow: auto; padding-left: 20px; line-height: 1.8; }
.merge-preview > p:last-child { margin-bottom: 0; }
.merge-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding-top: 12px; }
.merge-actions .primary { max-width: 100%; overflow-wrap: anywhere; }
#merge-dialog { max-width: 720px; }
#client-status { color: var(--brand); }

@media (max-width: 1150px) {
  .content-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .map-hint, #identity-status { display: none; }
  .scope-filter { flex-basis: 170px; }
  #graph-count { margin-left: auto; }
}
@media (max-width: 850px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding-inline: 8px; }
  .mobile-actions { display: flex; gap: 2px; }
  .topbar { gap: 6px; flex-wrap: wrap; padding: 6px 8px; }
  .stats { gap: 4px 10px; }
  .content-grid { grid-template-columns: minmax(0, 1fr) 310px; gap: 8px; }
  .filters { flex-wrap: wrap; }
  .scope-filter { flex-basis: 100%; }
  .graph-heading { gap: 5px; }
  #graph-count { margin-left: 0; }
  .date-filters { gap: 6px; }
  .date-filters label { gap: 3px; }
  .date-filters input { max-width: 119px; }
  .legend { gap: 8px; font-size: 9px; }
  .workspace-status { font-size: 9px; }
}
@media (max-width: 680px) {
  .workspace { grid-template-rows: auto auto; height: auto; min-height: 100dvh; overflow: visible; }
  .content-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; flex: none; }
  .graph-card { height: 66vh; height: 66dvh; min-height: 380px; }
  .detail-card { height: 70vh; height: 70dvh; min-height: 400px; }
  .stats { order: 3; flex-basis: 100%; margin: 0; }
  .topbar h1 { margin-right: auto; }
  .scope-filter { flex: 0 1 175px; }
  .filters { flex-wrap: nowrap; }
  .search-label input { font-size: 11px; }
  .graph-heading { gap: 10px; }
  .graph-footer { flex-wrap: wrap; }
  .workspace-status { padding-bottom: 6px; }
  #discovery-status { margin-left: 0; }
  .client-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .client-layout > div { max-height: 160px; overflow: auto; }
  dialog { padding: 22px; }
  .login-screen { padding: 24px 16px; background-image: none; }
  .login-card { padding: 30px 24px; }
  .login-card h1 { font-size: 37px; }
}
@media (max-width: 380px) {
  .brand { gap: 8px; font-size: 12px; }
  .brand-logo { width: 112px; }
  .scope-filter { flex-basis: 145px; min-width: 120px; }
  .stat small { font-size: 10px; }
  .date-filters > span { display: none; }
  .login-card h1 { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  button, .graph-node circle { transition: none; }
}

.email-color { background: var(--email); }
.email-headers { margin: 16px 0; padding: 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; overflow-wrap: anywhere; }
.email-headers p { margin: 5px 0; }

/* Compact map/timeline switch and chronological source navigation. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.view-switch { display: flex; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-section); }
.view-switch button { border: 0; background: none; border-radius: 4px; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.view-switch button[aria-pressed="true"] { background: var(--bg); color: var(--primary); box-shadow: 0 1px 3px #0e0e1015; }
.timeline-panel { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; border-block: 1px solid var(--border); padding: 16px 20px; background: var(--bg-card); }
#timeline-note { margin-bottom: 12px; }
.timeline-day h3 { font: 11px/1.5 var(--font-mono); color: var(--muted); margin: 0 0 10px; }
.timeline-day ol { list-style: none; margin: 0 0 24px 6px; padding: 0 0 0 17px; border-left: 1px solid var(--border-strong); }
.timeline-day li { position: relative; padding-bottom: 9px; }
.timeline-day li::before { content: ''; position: absolute; left: -21px; top: 18px; height: 7px; width: 7px; border-radius: 50%; background: var(--meeting); box-shadow: 0 0 0 4px var(--bg-card); }
.timeline-day li.email::before { background: var(--email); }
.timeline-event { display: block; width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; text-align: left; }
.timeline-event:hover { background: var(--accent-soft); border-color: #c6d4f3; }
.timeline-event[aria-current="true"] { border-color: var(--brand); box-shadow: inset 3px 0 var(--brand); }
.timeline-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 9px; margin-bottom: 5px; font: 10px/1.5 var(--font-mono); color: var(--muted); }
.event-kind { color: var(--brand); }
.email .event-kind { color: var(--email); }
.timeline-event strong { font-size: 14px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.timeline-event small { display: block; color: var(--muted); font-size: 11px; line-height: 1.6; margin-top: 4px; overflow-wrap: anywhere; }
.timeline-empty { padding: 30px 10px; text-align: center; color: var(--muted); font-size: 13px; }

/* Database explorer: tables and SQL share a scrollable result grid. */
.database-page { flex: 1; min-height: 0; display: grid; grid-template-columns: 235px minmax(0, 1fr); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.database-tables { min-width: 0; overflow: auto; background: var(--bg-card); border-right: 1px solid var(--border); padding: 14px; }
.database-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.database-heading h2 { margin: 0; }
#db-table-search { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
.database-tables > p { margin: 9px 0; font-size: 10px; }
#db-table-list button { width: 100%; display: block; padding: 10px 8px; margin-top: 4px; border: 1px solid transparent; border-radius: 5px; background: none; text-align: left; overflow-wrap: anywhere; font: 11px/1.5 var(--font-mono); }
#db-table-list button[aria-current="true"] { color: var(--primary); background: var(--accent-soft); border-color: #dfe5f7; }
#db-table-list button:hover { background: var(--bg-elevated); }
#db-table-list small { display: block; font: 10px/1.6 var(--font-body); color: var(--muted); }
.database-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.database-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
#db-table-name { overflow-wrap: anywhere; }
.database-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
.database-controls label, .database-pagination label { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.database-page select, .database-filter input { border: 1px solid var(--border); padding: 7px; border-radius: 4px; font-size: 12px; background: var(--bg); min-width: 0; max-width: 240px; }
.database-page .primary, .database-page .secondary { padding: 7px 11px; font-size: 12px; }
#db-columns { position: relative; font-size: 12px; }
#db-columns summary { padding: 7px; cursor: pointer; }
#db-column-list { position: absolute; z-index: 5; left: 0; top: 100%; width: min(350px, 65vw); max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: var(--bg); box-shadow: 0 8px 24px #0e0e101f; }
#db-column-list label { display: flex; gap: 6px; padding: 5px; font-size: 11px; }
#db-column-list small { margin-left: auto; }
.database-filter { display: flex; gap: 7px; margin: 0 12px 8px; }
.database-filter input { flex: 1; max-width: none; }
.database-filter select { max-width: 200px; }
#db-filters { max-height: 190px; overflow: auto; }
.database-query { padding: 12px; border-bottom: 1px solid var(--border); }
.database-query > label { display: block; font-size: 12px; margin-bottom: 7px; }
#db-sql { width: 100%; min-height: 90px; max-height: 30vh; resize: vertical; padding: 12px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--bg-card); font: 12px/1.6 var(--font-mono); tab-size: 2; }
.database-query-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.database-query-actions .small { font-size: 10px; }
.database-results { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--border); }
.database-results table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.database-results th { position: sticky; top: 0; z-index: 1; background: var(--bg-section); text-align: left; font-weight: 500; padding: 8px; white-space: nowrap; border-bottom: 1px solid var(--border-strong); }
.database-results td { padding: 0; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); max-width: 320px; height: 36px; }
.database-results td button, .database-results th button { display: block; width: 100%; border: 0; background: none; text-align: left; font-size: 12px; }
.database-results td button { padding: 8px; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 35px; }
.database-results td button:hover { background: var(--accent-soft); }
.database-null { color: var(--muted); font-style: italic; }
.database-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 11px; }
#db-row-count { margin-right: auto; }
.database-empty { text-align: center; color: var(--muted); padding: 30px 15px; font-size: 13px; }
#db-error { margin: 8px 12px; padding: 8px 10px; }
#db-loading { padding: 8px 12px; margin: 0; }
#db-cell-dialog { width: min(900px, calc(100% - 30px)); }
#mcp-dialog { width: min(650px, calc(100% - 30px)); }
#mcp-dialog > label, #mcp-dialog summary { font-size: 13px; }
.mcp-url-row { display: flex; gap: 8px; margin: 8px 0 20px; }
#mcp-url { min-width: 0; flex: 1; border: 1px solid var(--border); border-radius: 4px; padding: 8px; font: 11px var(--font-mono); }
.mcp-settings { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; font-size: 12px; }
.mcp-settings dt { color: var(--muted); }
.mcp-settings dd { margin: 0; overflow-wrap: anywhere; }
#mcp-dialog li { font-size: 12px; line-height: 1.8; }
@media (max-width: 950px) { .database-page { grid-template-columns: 190px minmax(0, 1fr); } .database-filter { flex-wrap: wrap; } }
@media (max-width: 680px) {
  .database-page { grid-template-columns: minmax(0, 1fr); grid-template-rows: 185px minmax(0, 1fr); height: calc(100dvh - 110px); min-height: 550px; flex: none; }
  .database-tables { border-right: 0; border-bottom: 1px solid var(--border); padding: 10px; }
  #db-table-list { display: flex; gap: 5px; }
  #db-table-list button { width: auto; flex-shrink: 0; }
  .database-tables > p { display: none; }
  .database-heading { margin-bottom: 7px; }
  .database-toolbar { gap: 6px; }
  .database-controls { gap: 5px; }
  .database-pagination { gap: 5px; }
  #db-row-count { flex-basis: 100%; }
}
