:root {
  --ink: #202124;
  --muted: #5f6368;
  --accent: #1a73e8;
  --accent-dark: #1558b0;
  --soft: #e8f0fe;
  --line: #e5e7eb;
  --bg: #f5f6f8;
  --white: #fff;
  --danger: #a43c3c;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang HK", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--white);
  font-size: 14px;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 23px; line-height: 1.4; font-weight: 600; letter-spacing: -.3px; }
h2 { font-size: 18px; line-height: 1.4; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
small { font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.primary, .secondary, .ghost { border-radius: 20px; padding: 9px 16px; border: 1px solid transparent; font-weight: 500; }
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.secondary { background: white; border-color: var(--line); color: var(--ink); }
.secondary:hover:not(:disabled) { background: var(--soft); }
.ghost { background: transparent; color: var(--accent); padding: 5px 9px; }
.compact { padding: 6px 10px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 7px; font-size: 18px; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 12px; background: var(--bg); color: var(--muted); padding: 3px 9px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.warn { background: #fff3d7; color: #876415; }
.pill.error { background: #fce9e9; color: var(--danger); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.error { color: var(--danger); font-size: 13px; }
.fine-print { font-size: 12px; color: var(--muted); }
.eyebrow { font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 500; }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }
.panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-head p { margin-bottom: 0; font-size: 13px; }
.section-head h1 { margin-bottom: 4px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.divider { border-top: 1px solid var(--line); margin: 20px 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink); }
input, textarea, select { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--ink); background: white; min-width: 0; width: 100%; }
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #87919e; }
form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full { grid-column: 1 / -1; }
.checkbox { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.notice { margin: 12px 24px 0; padding: 10px 14px; border: 1px solid #c9d8e3; background: #edf3f7; color: var(--accent); border-radius: 4px; }
.notice.error { background: #fff0ef; color: var(--danger); border-color: #ebcece; }
.brand-mark { width: 32px; height: 32px; background: var(--soft); color: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex: 0 0 auto; }
.login-screen { min-height: 100dvh; display: grid; grid-template-columns: 1fr 380px; align-items: center; max-width: 1050px; margin: auto; padding: 64px; gap: 100px; }
.login-story { padding: 28px 0; }
.login-story .brand-mark { margin-bottom: 32px; width: 44px; height: 44px; font-size: 18px; }
.login-story .client-name { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.login-story h1 { font-size: 34px; line-height: 1.35; margin-bottom: 16px; }
.login-story > p:last-child { color: var(--muted); font-size: 15px; }
.login-card { background: white; padding: 32px; border-radius: 20px; border: 1px solid var(--line); }
.login-card h2 { font-size: 22px; margin: 0; }
.login-card p { margin: 0; }
.login-card .primary { margin-top: 5px; }
.login-card-top { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.app { display: flex; min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 224px; background: var(--bg); padding: 26px 14px 18px; display: flex; flex-direction: column; z-index: 5; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); padding: 0 5px; margin-bottom: 30px; }
.brand:hover { text-decoration: none; }
.brand strong { font-size: 15px; font-weight: 600; }
.brand small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--muted); border-radius: 24px; padding: 12px 16px; text-align: left; font-size: 13px; font-weight: 500; }
.nav-item .nav-icon { width: 20px; height: 20px; flex: none; }
.nav-item.active { background: var(--soft); color: var(--accent); }
.nav-item:hover { background: #e9ecef; }
.nav-item:disabled { opacity: .35; }
.side-bottom { margin-top: auto; padding: 20px 4px 0; }
.user-line { border-top: 1px solid var(--line); padding-top: 16px; display: flex; align-items: center; gap: 8px; }
.avatar { height: 30px; width: 30px; border-radius: 50%; background: var(--soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; flex: 0 0 auto; }
.user-line strong { font-size: 12px; overflow-wrap: anywhere; }
.user-line small { display: block; color: var(--muted); font-size: 11px; }
.user-line button { margin-left: auto; }
.main { margin-left: 224px; flex: 1; min-width: 0; }
.topbar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 12px 30px; background: white; gap: 16px; }
.breadcrumb { font-size: 14px; min-width: 0; }
.breadcrumb strong { font-weight: 500; color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 16px 30px 28px; max-width: 1450px; margin: auto; }
.content:has(.chat-layout) { max-width: none; }

/* The answer and the original document share one reading workspace. */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(380px, .9fr); gap: 28px; align-items: start; }
.chat-layout-centered { grid-template-columns: minmax(0, 1fr); max-width: 860px; margin: 0 auto; }
.content[data-page="chat"] > .section-head h1 { display: none; }
.content[data-page="chat"] > .section-head { justify-content: flex-end; margin-bottom: 4px; }
.chat-panel { padding: 0; border: 0; border-radius: 0; display: flex; flex-direction: column; height: calc(100dvh - 182px); min-height: 490px; overflow: hidden; }
.conversation { padding: 24px 16px 24px; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.conversation:has(.chat-welcome) { display: flex; align-items: center; }
.chat-welcome { padding: 20px 10px; width: 100%; max-width: 620px; margin: auto; }
.chat-welcome h2 { font-size: clamp(28px, 3vw, 38px); font-weight: 500; letter-spacing: -.8px; margin-bottom: 12px; }
.chat-welcome p { font-size: 14px; color: var(--muted); max-width: 420px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-top: 30px; }
.suggestions button { background: var(--bg); color: var(--ink); border: 1px solid transparent; border-radius: 16px; padding: 14px 16px; font-size: 13px; line-height: 1.5; text-align: left; flex: 1 1 160px; }
.suggestions button:hover { background: #eceff3; border-color: var(--line); }
.message { margin: 0 auto 30px; max-width: 760px; }
.message-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.message-label .dot { width: 5px; height: 5px; }
.message-label .chat-answer-status { padding: 0; font-size: 11px; }
.reader-heading .reader-graph-status { padding: 0; margin-left: auto; font-size: 11px; white-space: nowrap; }
.message.user { display: flex; flex-direction: column; align-items: flex-end; }
.message.user .message-body { background: var(--bg); border-radius: 20px 20px 4px 20px; padding: 11px 14px; max-width: 88%; white-space: pre-wrap; }
.message.assistant .message-body { line-height: 1.85; white-space: pre-wrap; font-size: 15px; overflow-wrap: anywhere; }
.answer-block { margin-bottom: 14px; }
.cite-button { font-size: 12px; color: var(--accent); background: var(--soft); padding: 1px 5px; margin: 0 3px; border: 1px solid #cbd8e2; border-radius: 3px; vertical-align: baseline; white-space: nowrap; }
.cite-button:hover, .cite-button.active { background: #dce8f1; border-color: var(--accent); }
.message-foot { margin-top: 10px; font-size: 12px; color: var(--muted); }
.composer { flex: 0 0 auto; padding: 10px 8px 0; background: white; gap: 0; }
.composer-inner { display: flex; align-items: flex-end; border: 1px solid transparent; border-radius: 24px; padding: 16px; gap: 12px; background: var(--bg); }
.composer-inner:focus-within { border-color: var(--accent); outline: 1px solid var(--accent); }
.composer textarea { border: 0; resize: none; min-height: 52px; max-height: 150px; padding: 4px; box-shadow: none; font-size: 15px; background: transparent; }
.composer textarea:focus-visible { outline: none; }
.composer .primary { padding: 10px 16px; flex: 0 0 auto; border-radius: 22px; }
.composer .fine-print { margin: 9px 8px 0; font-size: 11px; }
.chat-context { min-width: 0; gap: 14px; }
.reader-panel, .reader-graph-panel { padding: 16px; border-radius: 16px; }
.reader-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.reader-heading h2 { font-size: 15px; margin: 0; flex: 0 0 auto; }
.reader-document { margin: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-pages { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; }
.reader-page { flex-shrink: 0; white-space: nowrap; border: 1px solid var(--line); background: white; color: var(--muted); border-radius: 3px; padding: 4px 8px; font-size: 12px; text-align: left; max-width: 100%; }
.reader-page:hover { background: var(--soft); }
.reader-page.active { border-color: var(--accent); color: var(--accent); background: var(--soft); }
.reader-location { font-size: 12px; color: var(--muted); margin: 0 0 8px; overflow-wrap: anywhere; }
.reader-content { height: clamp(300px, calc(100dvh - 600px), 430px); overflow: auto; overscroll-behavior: contain; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; }
.reader-content > .empty { padding: 32px 18px; text-align: left; }
.reader-content .original-page { margin: 0; }
.reader-content .original-page-stage { border: 0; border-radius: 0; }
.reader-content .original-page-status, .reader-content .original-page-actions { margin: 0 !important; padding: 8px 10px; background: white; border-top: 1px solid var(--line); font-size: 12px; }
.reader-content .original-page-actions { gap: 10px; }
.reader-content .original-page-actions .secondary { padding: 4px 7px; }
.reader-empty { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.reader-graph { min-width: 0; }
.chat-related-graph { min-width: 0; white-space: normal; }
.chat-page-graph { width: 100%; height: auto; display: block; background: white; }
.chat-page-graph text { font-family: inherit; font-size: 14px; fill: var(--ink); }
.chat-page-graph .chat-graph-column { font-size: 12px; fill: var(--muted); }
.chat-graph-line { stroke: #ccd5dd; stroke-width: 1.3; fill: none; }
.chat-graph-page, .chat-graph-topic { cursor: pointer; }
.chat-graph-page rect, .chat-graph-topic rect { rx: 4px; fill: white; stroke: #d2dae2; stroke-width: 1; }
.chat-graph-page.cited rect { fill: #edf3f8; stroke: #7f9bb1; }
.chat-graph-page.related rect { fill: #f5f6f8; stroke: #c6cfd8; }
.chat-graph-topic rect { fill: white; }
.chat-graph-page:hover rect, .chat-graph-topic:hover rect, .chat-graph-page.selected rect, .chat-graph-topic.selected rect { stroke: var(--accent); stroke-width: 2; }
.chat-graph-line.selected { stroke: var(--accent); stroke-width: 2; }
.chat-graph-page:focus-visible, .chat-graph-topic:focus-visible { outline: none; }
.chat-graph-page:focus-visible rect, .chat-graph-topic:focus-visible rect { stroke: var(--accent-dark); stroke-width: 3; }
.chat-graph-details { border-top: 1px solid var(--line); padding-top: 9px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.chat-graph-details:empty { display: none; }
.chat-graph-details strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 5px; font-weight: 500; }
.chat-graph-details button { margin: 0 5px 4px 0; }

/* Administration and document tools retain their existing layouts. */
.reference { margin-top: 10px; border: 1px solid var(--line); border-radius: 4px; background: white; overflow: hidden; }
.reference summary { cursor: pointer; padding: 10px 12px; list-style: none; display: flex; align-items: center; gap: 9px; font-size: 12px; }
.reference summary:before { content: '›'; color: var(--accent); }
.reference[open] summary:before { content: '⌄'; }
.reference-body { padding: 0 13px 13px; font-size: 13px; }
.reference blockquote { margin: 8px 0 10px; padding: 10px 12px; border-left: 2px solid #a3b8c8; background: var(--bg); white-space: pre-wrap; line-height: 1.8; }
.reference-title { white-space: normal; }
.document-card, .model-card, .server-card { padding: 20px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: white; min-width: 0; }
.document-card h3, .server-card h3 { margin: 0; font-size: 14px; }
.document-card .doc-meta { font-size: 12px; color: var(--muted); margin: 13px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { padding: 10px 14px; border: 0; background: transparent; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.result-summary { display: flex; gap: 12px; align-items: center; margin: 0 0 18px; font-size: 12px; color: var(--muted); }
.entity-list { display: flex; flex-wrap: wrap; gap: 8px; }
.entity { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 7px 10px; font-size: 12px; }
.entity small { display: block; font-size: 11px; color: var(--muted); }
.relation { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.relation:last-child { border-bottom: 0; }
.relation-path { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.relation-path strong { background: var(--soft); padding: 3px 8px; border-radius: 3px; color: var(--accent); font-weight: 500; }
.relation p { margin: 7px 0 0; color: var(--muted); }
.model-card h3 { margin-bottom: 7px; }
.model-details { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.model-details code { display: block; color: var(--ink); padding: 7px 0; font-size: 12px; }
.output { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 13px; margin-top: 13px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 350px; overflow: auto; }
.server-card p { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin: 7px 0 12px; }
.tools-list { margin-top: 15px; }
.tool-item { border-top: 1px solid var(--line); padding: 10px 0; }
.tool-item strong { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }
.tool-item p { font-size: 12px; margin: 3px 0; color: var(--muted); }
.trace { border-left: 2px solid #c2cfd9; padding-left: 14px; margin: 16px 0; }
.trace-step { margin-bottom: 15px; }
.trace-step h4 { margin: 0; font-size: 12px; color: var(--accent); }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td select { width: auto; font-size: 12px; padding: 5px 8px; }
.role-profiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 12px 0 28px; }
.role-profile h3 { margin-bottom: 7px; }
.role-profile p { font-size: 13px; margin: 0; }
.access-role-checks { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 4px; }
.access-role-checks label { white-space: nowrap; }
.document-access-panel { margin-top: 24px; }
.modal { position: fixed; inset: 0; background: #23304470; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 30px; }
.modal-card { background: white; border-radius: 6px; width: min(1100px, 95vw); max-height: 90dvh; overflow: auto; box-shadow: 0 20px 70px #23304420; padding: 25px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h2 { margin: 0; }
.pdf-frame { width: 100%; height: 68dvh; border: 1px solid var(--line); border-radius: 4px; }
.markdown-preview { white-space: pre-wrap; font: 12px/1.8 ui-monospace, SFMono-Regular, monospace; background: var(--bg); padding: 20px; border-radius: 4px; max-height: 65dvh; overflow: auto; }
.busy { color: var(--muted); font-size: 13px; padding: 10px 0; }
.busy:before { content: ''; display: inline-block; width: 12px; height: 12px; border: 2px solid #cbd8e2; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Full graph inspection is separate from the compact page relationship reader. */
.graph-visualization { min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 22px; background: white; padding: 15px; }
.graph-visualization .panel-head { margin-bottom: 8px; }
.graph-visualization > p { font-size: 12px; margin-bottom: 6px; }
.knowledge-graph { width: 100%; height: auto; display: block; min-width: 540px; background: white; }
.graph-canvas { overflow-x: auto; min-width: 0; max-width: 100%; }
.graph-edge, .graph-node { cursor: pointer; }
.graph-edge-hit { stroke: transparent; stroke-width: 14; fill: none; }
.graph-edge-line { stroke: #b5c6d3; stroke-width: 1.7; fill: none; pointer-events: none; }
.graph-edge:hover .graph-edge-line, .graph-edge.selected .graph-edge-line { stroke: var(--accent); stroke-width: 3; }
.graph-node circle { fill: var(--soft); stroke: #96adbf; stroke-width: 1.5; }
.graph-node:hover circle, .graph-node.selected circle { fill: var(--accent); stroke: var(--accent); }
.graph-node-glyph { fill: var(--accent); font-size: 12px; text-anchor: middle; pointer-events: none; }
.graph-node:hover .graph-node-glyph, .graph-node.selected .graph-node-glyph { fill: white; }
.graph-node-label { fill: var(--ink); font-size: 11px; pointer-events: bounding-box; font-weight: 500; }
.graph-edge:focus, .graph-node:focus { outline: none; }
.graph-edge:focus .graph-edge-line { stroke: var(--accent-dark); stroke-width: 4; }
.graph-node:focus circle { stroke: var(--accent-dark); stroke-width: 4; }
.graph-selection { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 13px; }
.graph-selection > p { margin-bottom: 8px; font-size: 12px; }
.graph-selection h3 { font-size: 13px; overflow-wrap: anywhere; }
.graph-description { white-space: pre-wrap; line-height: 1.8; }
.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; }
.locale-control { display: inline-flex; margin: 0; align-items: center; }
.locale-control select { width: auto; max-width: 176px; padding: 6px 26px 6px 9px; font-size: 12px; margin: 0; border-radius: 4px; }
.mobile-logout { display: none; }

/* Image and normalized highlight coordinates remain in the same sized stage. */
.original-page { min-width: 0; margin: 12px 0; }
.original-page-status { margin: 8px 0 !important; white-space: normal; }
.original-page-stage { position: relative; width: 100%; background: white; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.original-page-image { display: block; width: 100%; height: auto; }
.original-page-highlights { position: absolute; inset: 0; pointer-events: none; }
.source-highlight { position: absolute; background: rgba(255, 205, 51, .30); border: 1px solid rgba(183, 124, 0, .7); mix-blend-mode: multiply; }
.original-page-actions { flex-wrap: wrap; gap: 9px; margin-top: 10px; }
.original-page-actions a { white-space: normal; }
.reference-body .original-page { max-width: 850px; }
.graph-node.graph-seed-page circle { fill: #e4eef7; stroke: #6589a6; stroke-width: 2.2; }
.graph-node.graph-seed-page .graph-node-glyph { fill: var(--accent); }
.graph-node.graph-related-page circle { fill: #f5f6f8; stroke: #aab7c3; stroke-width: 2; }
.pill.graph-seed-tag { background: #e4eef7; color: var(--accent); }
.pill.graph-related-tag { background: #f0f2f5; color: var(--muted); }
.graph-page-legend { flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.graph-node.graph-seed-page.selected circle, .graph-node.graph-related-page.selected circle { fill: var(--accent); stroke: var(--accent); }
.graph-node.graph-seed-page.selected .graph-node-glyph, .graph-node.graph-related-page.selected .graph-node-glyph { fill: white; }

@media (max-width: 1200px) {
  .content { padding: 20px; }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-panel { height: 620px; min-height: 0; }
  .chat-context { display: flex; }
  .reader-content { height: 430px; }
  .reader-graph .chat-page-graph { max-height: 310px; }
  .login-screen { padding: 45px; gap: 50px; }
}
@media (max-width: 700px) {
  .app { display: block; }
  .sidebar { position: relative; width: auto; inset: auto; padding: 14px 16px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 0 13px; padding: 0; }
  .brand-mark { width: 30px; height: 30px; }
  .brand strong { font-size: 14px; }
  .brand small { display: none; }
  .side-bottom { display: none; }
  nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 7px 9px; font-size: 12px; }
  .nav-item .nav-icon { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .top-actions { gap: 7px; flex-wrap: wrap; }
  .locale-control select { max-width: 158px; }
  .mobile-logout { display: block; }
  .content { padding: 18px 14px; }
  .section-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .section-head h1 { font-size: 22px; }
  .section-head .row { gap: 7px; }
  .grid.two, .grid.three, .form-grid, .role-profiles { grid-template-columns: minmax(0, 1fr); }
  .full { grid-column: auto; }
  .chat-layout { gap: 14px; }
  .chat-panel { height: 560px; }
  .conversation { padding: 20px 17px 12px; }
  .chat-welcome { padding: 10px 0; }
  .chat-welcome h2 { font-size: 21px; }
  .composer { padding: 12px; }
  .composer-inner { gap: 7px; }
  .composer .primary { padding: 8px 10px; }
  .chat-context { display: flex; width: 100%; }
  .panel { padding: 16px; }
  .chat-panel { padding: 0; }
  .reader-panel, .reader-graph-panel { padding: 12px; }
  .reader-heading { flex-wrap: wrap; gap: 3px 10px; }
  .reader-document { max-width: 100%; }
  .reader-content { height: 410px; }
  .chat-page-graph text { font-size: 18px; }
  .chat-page-graph .chat-graph-column { font-size: 16px; }
  .notice { margin: 12px 14px 0; }
  .login-screen { display: block; padding: 28px 20px; max-width: 460px; }
  .login-story { padding: 12px 0; }
  .login-story .brand-mark { margin-bottom: 20px; }
  .login-story h1 { font-size: 29px; }
  .login-card { padding: 24px; margin-top: 18px; }
  .modal { padding: 10px; }
  .modal-card { padding: 18px; }
  .original-page-actions { gap: 7px; }
  .original-page-actions a, .original-page-actions button { font-size: 12px; padding: 6px 8px; }
  .reference-body { padding: 12px; }
}
@media (max-width: 420px) {
  .top-actions { width: 100%; justify-content: flex-end; }
  .reader-content { height: 360px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* Model configuration and the executable question-answering workflow. */
.model-add{margin-top:20px}.workflow-layout{display:grid;grid-template-columns:minmax(0,2.3fr) minmax(320px,1fr);gap:20px;align-items:start}.workflow-editor h2{margin-top:0}.workflow-editor textarea{font-family:inherit;font-size:13px;line-height:1.55}.workflow-canvas{overflow:auto;max-width:100%;margin:18px -4px;padding:0;border:1px solid var(--line);border-radius:6px;background-color:#f9fbfc;background-image:radial-gradient(#d9e1e7 1px,transparent 1px);background-size:20px 20px;overscroll-behavior:contain}.workflow-stage{position:relative;isolation:isolate}.workflow-lines{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none}.workflow-lines marker path{fill:var(--accent)}.workflow-edge{fill:none;stroke:var(--accent);stroke-width:1.7}.workflow-edge.inactive{stroke:#a5b1bd;stroke-dasharray:5 4}.workflow-node{position:absolute;display:flex;flex-direction:column;gap:4px;text-align:left;white-space:normal;width:174px;height:94px;padding:13px 11px;border:1px solid #bdcbd5;background:#fff;border-radius:8px;cursor:grab;touch-action:none;user-select:none;box-shadow:0 2px 4px #23304408}.workflow-node strong{font-size:13px;line-height:1.25;max-width:146px}.workflow-node.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.workflow-node.inactive{border-style:dashed;background:#f4f6f8}.workflow-node.dragging{cursor:grabbing;z-index:2}.workflow-node .fine-print,.workflow-node-state{font-size:11px;line-height:1.3;color:var(--muted)}.workflow-grip{position:absolute;right:8px;top:7px;color:#8497a7;letter-spacing:-2px}.workflow-connections>.row{align-items:flex-end;flex-wrap:wrap}.workflow-connections label{flex:1;min-width:170px;margin:0}.workflow-connections label select{margin-top:5px}.workflow-edge-list{margin-top:14px;display:grid;gap:6px}.workflow-connection{min-height:36px;border-bottom:1px solid #edf1f4;font-size:12px}.workflow-presets{margin-top:14px}.workflow-presets button{font-size:11px}.workflow-execution,.workflow-disabled-note{background:var(--soft);padding:10px;border-radius:5px;line-height:1.5}.workflow-editor>.primary{margin-top:14px}.workflow-editor>.checkbox{gap:9px;flex-wrap:wrap}.workflow-editor>.checkbox .pill{margin-left:auto}
@media(max-width:1400px){.workflow-layout{grid-template-columns:1fr}.workflow-editor textarea{min-height:240px}}@media(max-width:700px){.workflow-layout{gap:14px}.workflow-connections label{min-width:0;flex-basis:100%}}

.workflow-node-host{position:absolute;width:174px;height:94px}.workflow-node-host>.workflow-node{left:0;top:0}.workflow-port{position:absolute;top:39px;width:16px;height:16px;min-width:0;padding:0;border:2px solid var(--accent);border-radius:50%;background:#fff;z-index:3;touch-action:none}.workflow-port-input{left:-8px}.workflow-port-output{right:-8px;background:var(--accent);cursor:crosshair}.workflow-port-input.candidate{background:#ccebdc;border-color:#257453;box-shadow:0 0 0 4px #25745320}.workflow-edge-preview{stroke-dasharray:5 4}

.chat-agent-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:0 0 14px}.chat-agent-row label{min-width:220px;max-width:340px;margin:0}.chat-agent-row label>span{font-size:11px;color:var(--muted)}.chat-agent-row label select{margin-top:0;border:0;background:var(--bg);border-radius:20px;padding:8px 12px}.chat-agent-row p{margin:0}.agent-builder-toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:15px}.agent-list{display:flex;gap:8px;overflow:auto;margin-bottom:20px;padding-bottom:5px}.agent-list-item{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-width:180px;text-align:left;padding:12px;border:1px solid var(--line);background:#fff;border-radius:6px}.agent-list-item.active{border-color:var(--accent);background:var(--soft)}.agent-metadata{margin-bottom:20px}.agent-metadata>.checkbox{align-self:center}.agent-metadata>.ghost{justify-self:start;align-self:center}.workflow-palette{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-top:12px}.workflow-palette strong{font-size:12px;margin-right:4px}.workflow-palette button{font-size:11px;padding:6px 9px}@media(max-width:700px){.chat-agent-row label{min-width:0;flex-basis:100%;max-width:none}.agent-list-item{min-width:160px}}

/* Document upload and page review. */
.document-upload{margin-bottom:16px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px 16px;align-items:end}.document-upload>label{grid-column:1}.document-upload>.fine-print{grid-column:1;margin:0}.document-upload>.primary{grid-column:2;grid-row:1/3}.document-review-card{border:1px solid var(--line);border-radius:var(--radius);padding:14px}.document-review-card.active{border-color:var(--accent)}.document-card .row>h3,.document-review-card .row>strong,.document-review-toolbar>div:first-child{min-width:0;flex:1;overflow-wrap:anywhere}.document-review-toolbar h3{overflow-wrap:anywhere}.document-review-card .doc-meta{margin:7px 0}.document-review-card progress{width:100%;height:8px;accent-color:var(--accent)}.document-review-card .fine-print{margin:8px 0 0}.document-review-toolbar{margin:22px 0 16px;padding-top:16px;border-top:1px solid var(--line)}.document-review-toolbar h3{margin:0}.document-review-toolbar .fine-print{margin:4px 0 0}.document-review-layout{display:grid;grid-template-columns:140px minmax(0,1fr);gap:18px;align-items:start}.document-review-pages{max-height:740px;overflow:auto;border:1px solid var(--line);border-radius:4px}.document-review-page-row{display:flex;align-items:center;gap:8px;border-bottom:1px solid var(--line);padding:8px}.document-review-page-row:last-child{border-bottom:0}.document-review-page-row.active{background:var(--soft)}.document-review-page-row>input{width:auto;flex:none}.document-review-page{border:0;background:transparent;display:flex;flex-direction:column;align-items:flex-start;text-align:left;padding:0;min-width:0}.document-review-page small{color:var(--muted);font-size:10px;line-height:1.3}.document-review-workspace{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:18px;min-width:0}.document-review-source,.document-review-markdown{min-width:0}.document-review-source>img{display:block;width:100%;height:auto;border:1px solid var(--line)}.document-review-markdown textarea{min-height:540px;font:12px/1.6 ui-monospace,SFMono-Regular,Consolas,monospace;margin:10px 0 6px}.document-review-markdown>.checkbox{margin-top:12px}.document-review-markdown>.row{margin-top:12px}.document-markdown-preview{border:1px solid var(--line);padding:16px;margin:10px 0 6px;min-height:540px;max-height:700px;overflow:auto;overflow-wrap:anywhere}.document-review-uncertainties{padding:9px;background:#fff3d7;color:#876415}
@media(max-width:1100px){.document-review-layout{grid-template-columns:110px minmax(0,1fr);gap:12px}.document-review-workspace{grid-template-columns:minmax(0,1fr)}.document-review-source>img{max-height:620px;object-fit:contain}.document-review-markdown textarea{min-height:400px}}@media(max-width:700px){.document-upload{display:flex;align-items:stretch}.document-upload>.primary{align-self:flex-start}.document-review-layout{grid-template-columns:minmax(0,1fr)}.document-review-pages{max-height:180px}.document-review-toolbar{align-items:flex-start}.document-review-toolbar>.row{gap:7px}.document-review-toolbar button{white-space:normal}}

/* Markdown is shared by streamed answers and the document review preview. */
.markdown-content { white-space: normal; overflow-wrap: anywhere; }
.message.assistant .markdown-content { white-space: normal; }
.markdown-content > :first-child { margin-top: 0; }
.markdown-content > :last-child { margin-bottom: 0; }
.markdown-content p { margin: 0 0 14px; }
.markdown-content h1, .markdown-content h2, .markdown-content h3, .markdown-content h4, .markdown-content h5, .markdown-content h6 { margin: 22px 0 10px; line-height: 1.4; font-weight: 600; }
.markdown-content h1 { font-size: 22px; }
.markdown-content h2 { font-size: 19px; }
.markdown-content h3 { font-size: 16px; }
.markdown-content h4, .markdown-content h5, .markdown-content h6 { font-size: 14px; }
.markdown-content ul, .markdown-content ol { margin: 0 0 14px; padding-left: 24px; }
.markdown-content li { margin: 4px 0; }
.markdown-content li > p { margin-bottom: 7px; }
.markdown-content blockquote { margin: 14px 0; padding: 2px 14px; border-left: 3px solid #bdc8d3; color: var(--muted); }
.markdown-content code { background: var(--soft); border-radius: 3px; padding: 2px 4px; font: .9em/1.6 ui-monospace, SFMono-Regular, monospace; }
.markdown-content pre { margin: 14px 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; overflow-x: auto; white-space: pre; }
.markdown-content pre code { background: none; padding: 0; font-size: 12px; }
.markdown-content table { display: block; width: max-content; max-width: 100%; margin: 14px 0; overflow-x: auto; border-collapse: collapse; font-size: 13px; }
.markdown-content th, .markdown-content td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.markdown-content th { background: var(--bg); font-weight: 600; }
.markdown-content a { color: var(--accent); text-underline-offset: 3px; }
.markdown-content hr { margin: 20px 0; border: 0; border-top: 1px solid var(--line); }
.chat-citations { margin-left: 3px; }
