:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #202322;
  --muted: #626763;
  --subtle: #f5f6f5;
  --line: #e5e7e5;
  --control: #c6cbc7;
  --green: #214a35;
  --error: #9e302c;
  --warning: #805821;
  --radius: 6px;
  --font: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #b8beb9 transparent; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; outline-offset: 3px; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; color: var(--muted); background: var(--subtle); }
a { color: inherit; text-decoration: none; text-underline-offset: 4px; }
:focus-visible { outline: 2px solid var(--green); }
::selection { color: var(--ink); background: #dce8df; }
input, textarea { caret-color: var(--green); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.4; }
h1 span { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 8px; letter-spacing: 0; }
h2 { font-size: 18px; font-weight: 600; }
h3, h4 { font-size: 16px; font-weight: 600; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 16px; padding: 8px 16px; background: var(--paper); z-index: 100; }

/* Three destinations share one top bar: at 1440px, 2 × 160px + 1120px = 1440px. */
.app-header { border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1200px; padding: 0 40px; margin: auto; display: flex; align-items: center; gap: 24px; min-height: 72px; }
.brand { font-size: 16px; font-weight: 600; white-space: nowrap; }
.header-inner nav { display: flex; align-self: stretch; gap: 28px; }
.nav-item { display: flex; align-items: center; position: relative; color: var(--muted); white-space: nowrap; }
.nav-item:hover, .nav-item.active { color: var(--ink); }
.nav-item.active::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--ink); }
.account-button { margin-left: auto; min-height: 36px; padding: 6px 0 6px 12px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.account-button:hover { color: var(--ink); }
.workspace { max-width: 1200px; margin: auto; padding: 0 40px; }
.view { padding: 48px 0; min-width: 0; }
.view-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 36px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid transparent; font-weight: 500; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.primary { background: var(--ink); color: #fff; }
.primary:hover:not(:disabled) { background: #414642; }
.primary:disabled { border-color: var(--line); }
.secondary { border-color: var(--control); background: var(--paper); }
.secondary:hover:not(:disabled), .subtle:hover:not(:disabled) { background: var(--subtle); }
.subtle { color: var(--muted); padding-left: 10px; padding-right: 10px; }
.ui-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#notice { margin-top: 24px; padding: 12px 16px; color: var(--warning); background: #faf6ee; border-radius: var(--radius); overflow-wrap: anywhere; }

.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 20px; }
.search-form { display: flex; align-items: center; gap: 10px; width: 360px; max-width: 65%; }
.search-form > svg { color: var(--muted); }
.search-form input { width: 100%; min-width: 0; border: 0; background: transparent; padding: 8px 0; }
.search-form .button { font-size: 12px; }
.toolbar-detail { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.document-area { border-top: 1px solid var(--line); }
.upload-area { margin-bottom: 24px; padding: 20px; background: var(--subtle); border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.upload-area p { color: var(--muted); font-size: 12px; max-width: 380px; }
.upload-controls { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-picker { display: flex; align-items: center; position: relative; border: 1px solid var(--control); border-radius: var(--radius); min-height: 36px; padding: 6px 12px; background: var(--paper); max-width: 280px; overflow: hidden; cursor: pointer; }
.file-picker span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-picker:focus-within { outline: 2px solid var(--green); outline-offset: 3px; }
.empty-state { padding: 64px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 300px; gap: 12px; }
.empty-state h2 { font-size: 18px; font-weight: 500; }
.empty-state .button { margin-top: 8px; }
.table-scroll { overflow-x: auto; }
.document-table { border-collapse: collapse; width: 100%; table-layout: fixed; text-align: left; }
.document-table th { color: var(--muted); font-weight: 400; font-size: 12px; padding: 16px 12px; }
.document-table td { padding: 20px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.document-table th:first-child, .document-table td:first-child { padding-left: 0; width: 42%; }
.document-table th:nth-child(2) { width: 15%; }
.document-table th:nth-child(3) { width: 25%; }
.document-table th:last-child, .document-table td:last-child { padding-right: 0; text-align: right; width: 18%; }
.doc-name-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.doc-name-wrap > div { min-width: 0; }
.doc-name { display: block; overflow-wrap: anywhere; font-size: 14px; font-weight: 500; }
.file-icon { flex: none; font-size: 12px; color: var(--muted); }
.doc-subtitle { color: var(--muted); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.doc-category { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.document-select { width: 16px; height: 16px; flex: none; margin: 0; accent-color: var(--ink); }
.doc-states { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.badge { font-size: 12px; color: var(--muted); white-space: nowrap; }
.badge.warning { color: var(--warning); }
.doc-issues { color: var(--warning); font-size: 12px; line-height: 1.6; margin-top: 6px; overflow-wrap: anywhere; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; white-space: nowrap; }
.text-action { font-size: 12px; padding: 8px 0; color: var(--ink); }
.text-action:hover { text-decoration: underline; text-underline-offset: 4px; }
.action-menu > summary { cursor: pointer; list-style: none; padding: 6px; min-width: 32px; border-radius: var(--radius); text-align: center; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > summary, .action-menu > summary:hover { background: var(--subtle); }
.action-menu-list { position: fixed; z-index: 30; display: flex; flex-direction: column; padding: 6px; width: 164px; max-height: calc(100dvh - 24px); overflow: auto; background: var(--paper); border-radius: var(--radius); box-shadow: 0 6px 32px #20232225; }
.action-menu-list button { text-align: left; padding: 9px 12px; font-size: 12px; border-radius: 4px; }
.action-menu-list button:hover { background: var(--subtle); }
.action-menu-list .danger { color: var(--error); }

.knowledge-status { color: var(--muted); font-size: 12px; margin: -12px 0 24px; }
.wiki-build-controls { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; max-width: 100%; }
.wiki-model-control { min-width: 0; }
.wiki-model-control select { width: 100%; max-width: 220px; text-overflow: ellipsis; }
.wiki-build-controls > button { flex: none; }
.wiki-model-notice { margin-top: -12px; margin-bottom: 20px; }
.wiki-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.wiki-toolbar > .button { font-size: 12px; }
.tabs { display: flex; gap: 24px; }
.tabs button { min-height: 48px; padding: 8px 0; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }
.wiki-layout { display: grid; grid-template-columns: 240px minmax(0,1fr); min-height: 460px; }
.wiki-browser { border-right: 1px solid var(--line); padding: 24px 20px 24px 0; min-width: 0; }
.wiki-browser-heading { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.wiki-browser-heading small { font-size: inherit; }
.wiki-search { margin: 16px 0; }
.wiki-search input { width: 100%; padding: 8px 10px; background: var(--subtle); border: 1px solid transparent; border-radius: var(--radius); font-size: 12px; }
.wiki-list { display: flex; flex-direction: column; gap: 4px; max-height: 65vh; overflow-y: auto; }
.wiki-list-empty { font-size: 12px; color: var(--muted); padding: 8px 0; }
.wiki-list-item { padding: 14px 12px; border-radius: var(--radius); text-align: left; width: 100%; flex: none; }
.wiki-list-item:hover { background: #fafbfa; }
.wiki-list-item.active { background: var(--subtle); }
.wiki-list-item strong { font-size: 14px; font-weight: 500; display: block; overflow-wrap: anywhere; }
.wiki-list-item .badge, .wiki-list-item small { display: inline-block; margin-top: 8px; margin-right: 8px; font-size: 12px; color: var(--muted); }
.wiki-reader { min-width: 0; padding: 32px 0 32px 40px; overflow-wrap: anywhere; }
.wiki-reader > .empty-state { min-height: 320px; }
.wiki-reader h2 { font-size: 24px; line-height: 1.5; font-weight: 500; }
.wiki-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12px; margin: 12px 0 24px; }
.wiki-summary { font-size: 14px; line-height: 1.9; color: var(--muted); margin-bottom: 28px; max-width: 75ch; }
.wiki-content { font-size: 14px; line-height: 1.9; max-width: 75ch; }
.wiki-content h2 { font-size: 18px; margin: 32px 0 12px; }
.wiki-content h3, .wiki-content h4 { font-size: 16px; margin: 28px 0 12px; }
.wiki-content p { margin: 12px 0; white-space: pre-wrap; }
.wiki-content ul, .wiki-content ol { padding-left: 24px; margin: 12px 0; }
.wiki-content li { margin: 6px 0; }
.wiki-content blockquote { margin: 16px 0; padding-left: 16px; border-left: 1px solid var(--control); color: var(--muted); white-space: pre-wrap; }
.wiki-content pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.8 ui-monospace, monospace; background: var(--subtle); padding: 16px; border-radius: var(--radius); }
.markdown-table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: normal; font-variant-numeric: tabular-nums; }
.markdown-table th, .markdown-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-wrap: normal; }
.markdown-table th { font-weight: 500; color: var(--muted); }
.markdown-table th:first-child, .markdown-table td:first-child { padding-left: 0; }
.markdown-table th:last-child, .markdown-table td:last-child { padding-right: 0; }
.wiki-content .table-scroll, .message-body .table-scroll { margin: 16px 0; }
.wiki-sources { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 24px; }
.wiki-sources h3 { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 12px; }
.source { font-size: 12px; margin-top: 12px; overflow-wrap: anywhere; }
.source a, .source button { padding: 0; text-align: left; color: var(--green); line-height: 1.8; font-size: 12px; }
.source a:hover, .source button:hover { text-decoration: underline; }
.source-kind { color: var(--muted); margin-right: 6px; }
.source summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 4px 0; }
.source pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; font: 12px/1.8 var(--font); color: var(--muted); margin: 8px 0; padding: 12px; background: var(--subtle); border-radius: var(--radius); }
.stale-warning { background: #faf6ee; color: var(--warning); font-size: 12px; padding: 12px 16px; margin-bottom: 24px; border-radius: var(--radius); }
.graph-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; }
.graph-toolbar > label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
select { border: 1px solid var(--control); border-radius: var(--radius); min-height: 36px; padding: 5px 28px 5px 10px; background-color: var(--paper); font-size: 12px; max-width: 100%; }
.graph-legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; }
.graph-legend span { display: flex; align-items: center; gap: 6px; }
.graph-legend i { width: 8px; height: 8px; display: inline-block; border: 1px solid #9da59f; border-radius: 2px; }
.category-dot { background: #f4f4f3; }
.document-dot { background: #fff; }
.graph-legend .wiki-dot { background: #edf2ef; border-color: #547561; }
.zoom-controls { display: flex; }
.zoom-controls button { min-width: 36px; min-height: 36px; padding: 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; border-radius: var(--radius); }
.zoom-controls button:hover { background: var(--subtle); }
.graph-canvas { overflow: auto; min-height: 320px; max-height: 560px; background: #fafbfa; display: flex; align-items: flex-start; justify-content: flex-start; border-radius: var(--radius); }
.graph-canvas svg { width: 100%; height: 100%; min-width: 500px; display: block; flex: none; }
.graph-canvas > .empty-state { width: 100%; height: 100%; }
.graph-node { cursor: pointer; }
.graph-node:hover rect, .graph-node:focus-visible rect { stroke: var(--green); stroke-width: 2; }
.graph-node text { pointer-events: none; font: 12px var(--font); }
.graph-footer { padding-top: 12px; color: var(--muted); font-size: 12px; }

.chat-view { max-width: 800px; margin: auto; padding-bottom: 24px; }
.chat-view .view-heading { margin-bottom: 24px; }
.conversation { display: flex; flex-direction: column; min-height: 0; height: calc(100dvh - 212px); }
.chat-messages { flex: 1; min-height: 160px; overflow-y: auto; padding: 12px 8px 24px 0; scroll-behavior: smooth; }
.chat-empty { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 32px 24px; }
.chat-empty h2 { font-size: 18px; font-weight: 500; }
.chat-empty p { max-width: 380px; color: var(--muted); }
.message { margin-bottom: 32px; overflow-wrap: anywhere; }
.message-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.message-body { font-size: 14px; line-height: 1.9; white-space: pre-wrap; }
.message-body p + p { margin-top: 12px; }
.message-body ul, .message-body ol { padding-left: 24px; margin: 12px 0; white-space: normal; }
.message-body h2, .message-body h3, .message-body h4 { font-size: 16px; margin: 20px 0 12px; }
.message-body blockquote { margin: 16px 0; padding-left: 16px; border-left: 1px solid var(--control); color: var(--muted); }
.message-body pre { font: 12px/1.8 ui-monospace, monospace; padding: 16px; background: var(--subtle); white-space: pre-wrap; }
.message.user { display: flex; flex-direction: column; align-items: flex-end; padding-left: 40px; }
.message.user .message-body { background: var(--subtle); padding: 12px 16px; border-radius: var(--radius); }
.message.error .message-body { color: var(--error); }
.message.loading .message-body { color: var(--muted); }
.message-sources { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.message-sources:empty { display: none; }
.message-sources-title { color: var(--muted); font-size: 12px; }
.chat-status { min-height: 24px; padding-bottom: 6px; font-size: 12px; color: var(--muted); }
.composer { border: 1px solid var(--control); border-radius: var(--radius); padding: 16px; background: var(--paper); }
.composer:focus-within { border-color: var(--ink); }
.composer textarea { border: 0; outline: none; resize: vertical; width: 100%; min-height: 56px; max-height: 160px; padding: 0; font-size: 14px; line-height: 1.8; background: transparent; }
.composer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 12px; }
.composer-options { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.scope-control, .model-control { min-width: 0; max-width: 100%; }
.scope-control select, .model-control select { border-color: transparent; padding-left: 0; color: var(--muted); }
.model-control select { max-width: 220px; width: 100%; text-overflow: ellipsis; }
.composer-bottom > button { flex: none; }
.model-notice { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; padding-bottom: 8px; color: var(--muted); font-size: 12px; }
.chat-disclaimer { font-size: 12px; text-align: center; color: var(--muted); margin-top: 12px; }

dialog { border: 0; border-radius: 12px; padding: 32px; width: 400px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); color: var(--ink); background: var(--paper); box-shadow: 0 16px 64px #20232230; }
dialog::backdrop { background: #20232266; }
dialog h2 { font-size: 18px; line-height: 1.5; overflow-wrap: anywhere; }
dialog form { margin-top: 24px; }
dialog label { display: block; margin-top: 16px; font-size: 12px; color: var(--muted); }
dialog input { width: 100%; display: block; padding: 10px 12px; border: 1px solid var(--control); border-radius: var(--radius); margin-top: 8px; font-size: 14px; background: var(--paper); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.error-text { color: var(--error); font-size: 12px; margin: 16px 0; overflow-wrap: anywhere; }
.error-text:empty { display: none; }
.preview { width: 900px; }
#parsedText { padding: 20px; max-height: 60vh; overflow: auto; background: var(--subtle); white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.9 var(--font); border-radius: var(--radius); margin-top: 24px; }
#filePreview { width: 100%; height: 64vh; border: 0; margin-top: 24px; }

@media (max-width: 1000px) {
  .header-inner { gap: 20px; padding: 0 28px; }
  .workspace { padding: 0 28px; }
  .view { padding-top: 36px; }
  .header-inner nav { gap: 24px; }
  .wiki-layout { grid-template-columns: 200px minmax(0,1fr); }
  .wiki-reader { padding-left: 28px; }
  .upload-area { align-items: flex-start; flex-direction: column; gap: 16px; }
  .conversation { height: calc(100dvh - 200px); }
}
@media (max-width: 640px) {
  .header-inner { padding: 0 20px; min-height: 108px; flex-wrap: wrap; gap: 0; align-content: start; }
  .brand { min-height: 56px; display: flex; align-items: center; }
  .account-button { min-height: 44px; }
  .header-inner nav { order: 3; width: 100%; min-height: 52px; justify-content: space-between; gap: 20px; }
  .nav-item { min-height: 48px; min-width: 44px; font-size: 14px; }
  .workspace { padding: 0 20px; }
  .view { padding-top: 28px; padding-bottom: 24px; }
  .view-heading { gap: 12px; margin-bottom: 24px; }
  h1 { font-size: 24px; }
  .button { min-height: 44px; min-width: 44px; padding: 10px 12px; }
  .view-heading > .button { font-size: 12px; }
  .section-toolbar { gap: 16px; padding-bottom: 12px; align-items: center; }
  .search-form { max-width: 74%; gap: 8px; }
  .search-form input { font-size: 14px; min-height: 44px; }
  .search-form .button { padding: 8px; }
  .toolbar-detail { font-size: 12px; }
  .upload-area { padding: 16px; }
  .upload-controls { width: 100%; }
  .file-picker { flex: 1; min-height: 44px; font-size: 12px; }
  .upload-controls button { font-size: 12px; }
  .empty-state { min-height: 280px; padding: 48px 12px; }
  .document-table, .document-table tbody { display: block; }
  .document-table thead { display: none; }
  .document-table tr.doc { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 12px; padding: 20px 0; border-bottom: 1px solid var(--line); }
  .document-table td { display: block; padding: 0; border: 0; }
  .document-table td:first-child { width: auto; grid-column: 1 / -1; }
  .document-table td:nth-child(2) { grid-column: 1; }
  .document-table td:nth-child(3) { grid-column: 1; grid-row: 3; }
  .document-table td:last-child { width: auto; grid-column: 2; grid-row: 2 / 4; align-self: center; }
  .document-select { width: 20px; height: 20px; }
  .file-icon { display: none; }
  .row-actions { gap: 8px; }
  .text-action { min-height: 44px; }
  .action-menu > summary { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  .action-menu-list button { min-height: 44px; font-size: 14px; }
  .wiki-toolbar { gap: 8px; }
  .tabs { gap: 20px; }
  .wiki-toolbar > .button { padding: 8px 0 8px 8px; }
  .wiki-layout { display: block; min-height: 0; }
  .wiki-browser { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px 0; }
  .wiki-browser-heading { display: none; }
  .wiki-search { margin: 0 0 12px; }
  .wiki-search input { min-height: 44px; font-size: 14px; }
  .wiki-list { max-height: 200px; }
  .wiki-list-item { padding: 12px; }
  .wiki-list-item .badge, .wiki-list-item small { margin-top: 4px; }
  .wiki-reader { padding: 24px 0; }
  .wiki-reader > .empty-state { min-height: 200px; }
  .wiki-reader h2 { font-size: 18px; }
  .knowledge-status { margin: -8px 0 20px; }
  .wiki-heading { flex-wrap: wrap; gap: 12px; }
  .wiki-build-controls { width: 100%; }
  .wiki-model-control { flex: 1; }
  .wiki-model-control select { max-width: none; }
  .graph-toolbar { flex-wrap: wrap; gap: 12px; }
  .graph-legend { order: 3; width: 100%; gap: 20px; }
  select, .zoom-controls button { min-height: 44px; }
  .zoom-controls button { min-width: 44px; }
  .graph-canvas { min-height: 300px; max-height: 420px; }
  .graph-canvas svg { min-width: 500px; }
  .chat-view { padding-top: 24px; }
  .chat-view .view-heading { margin-bottom: 12px; }
  .conversation { height: calc(100dvh - 220px); min-height: 360px; }
  .chat-empty { padding: 24px 12px; }
  .message.user { padding-left: 24px; }
  .composer { padding: 12px; }
  .composer textarea { font-size: 16px; min-height: 48px; }
  .composer-bottom { margin-top: 8px; gap: 8px; align-items: flex-end; }
  .composer .button { min-width: 64px; }
  .chat-disclaimer { margin-top: 8px; }
  dialog { padding: 24px; }
  dialog input { font-size: 16px; }
  #parsedText { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Library scope stays beside the brand; excerpts open where they are cited. */
.library-control select { background: var(--paper); border: 1px solid var(--control); border-radius: var(--radius); min-height: 36px; padding: 4px 28px 4px 12px; }
button.doc-name { padding: 0; text-align: left; }
button.doc-name:hover { text-decoration: underline; text-underline-offset: 4px; }
.inline-citation { color: var(--green); font-size: .85em; font-weight: 600; padding: 2px 5px; border-radius: 3px; vertical-align: baseline; }
.inline-citation:hover, .inline-citation[aria-expanded=true] { background: #eaf0ec; }
.citation-detail { margin: 12px 0 20px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--subtle); font-size: 13px; font-weight: 400; overflow-wrap: anywhere; }
.citation-detail .citation-title { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.citation-detail blockquote { margin: 0; padding: 0; border: 0; white-space: pre-wrap; max-height: 28vh; overflow-y: auto; }
.citation-actions { display: flex; gap: 20px; margin: 4px 0 12px; }
.citation-status { color: var(--error); margin-bottom: 12px; }
.book-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.book-tools span, .book-job small { color: var(--muted); font-size: 13px; }
.book-job { padding: 16px 0; border-top: 1px solid var(--line); }
.book-job p { margin: 8px 0; }
.book-job progress { display: block; width: 100%; height: 6px; margin: 12px 0; accent-color: var(--ink); }
.book-job small { display: block; margin-bottom: 12px; }
.message-sources > summary { cursor: pointer; width: fit-content; }
#wordPreview { margin-top: 24px; max-height: 64vh; overflow: auto; padding: 8px 20px 24px; line-height: 1.9; overflow-wrap: anywhere; }
#wordPreview p { margin: 12px 0; white-space: pre-wrap; }
#wordPreview h2, #wordPreview h3 { margin: 20px 0 12px; }
#wordPreview img { display: block; max-width: 100%; height: auto; margin: 20px auto; }
@media (max-width: 640px) {
  .library-control { margin-left: 16px; }
  .library-control select { min-height: 44px; padding: 4px 8px; }
  #wordPreview { padding: 4px 0 16px; }
  .inline-citation { min-width: 32px; min-height: 32px; }
}
