#library-view.file-open>.library-sidebar{display:none}#library-view.file-open.file-sidebar-open>.library-sidebar{display:flex}
#library-view.file-open>.library-main{padding:0;overflow:hidden;height:100%}
#file-viewer{display:flex;flex-direction:column;height:100%;min-height:0}
#file-document{flex:1;min-height:0;min-width:0;display:flex;flex-direction:column}
#file-document>.document-heading{height:60px;min-height:60px;display:grid;grid-template-columns:minmax(140px,1fr) auto minmax(100px,1fr);gap:12px;padding:10px 20px;border-bottom:1px solid var(--line);flex-wrap:nowrap}
.document-heading-title,.document-heading-actions{display:flex;align-items:center;gap:12px;min-width:0}.document-heading-actions{justify-content:flex-end}
#file-viewer .document-heading h1{font-size:16px;font-weight:600;line-height:24px;letter-spacing:0;margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#file-viewer .document-heading .icon-button{width:32px;height:32px;padding:6px;flex:none;color:var(--muted)}
#file-formatbar{display:flex;align-items:center;gap:4px}#file-formatbar button{width:34px;height:32px;padding:4px;border-radius:6px;font-size:14px;background:transparent;color:var(--muted)}#file-formatbar button:first-child,#file-formatbar button:nth-child(2){font-size:18px}#file-formatbar button:hover,#file-formatbar button[aria-pressed=true]{background:var(--soft);color:var(--text)}.format-divider{height:20px;width:1px;background:var(--line);margin:0 5px}
/* List buttons use authored aria-hidden SVG glyphs (data-icon); B/I stay strong, H1-H3 stay small. */
#file-formatbar svg{width:20px;height:20px}
#file-formatbar [data-file-format^=h]{font-size:13px;font-weight:600}
.document-scroll{flex:1;min-height:0;overflow:auto;scrollbar-width:thin}.document-body{max-width:784px;margin:auto;padding:80px 32px 60px}
/* The 720px content column is centered in the scroll area. Light mode uses white paper,
   and dark mode shares the header background. Code blocks and table headers have their own tint. */
.document-scroll{--document-background:light-dark(var(--surface),var(--bg));background:var(--document-background);--soft:color-mix(in srgb,var(--document-background),var(--text) 5%)}
#file-viewer #preview{border:0;padding:0;white-space:normal;background:transparent;border-radius:0}
#file-preamble{font-style:italic;font-size:16px;line-height:24px;border-left:3px solid var(--line);padding:0 0 0 16px;margin:0 0 52px}
/* Document typography (rich editor and read-only Markdown), scoped to the viewer.
   Explicit values shield it from the global p line-height, generic .markdown list margins
   and the .library-main h1 title rule. */
#file-viewer .markdown{font-size:16px;line-height:26px;overflow-wrap:anywhere}
#file-viewer .markdown p{margin:0 0 16px;line-height:inherit}
#file-viewer .markdown :is(h1,h2,h3){font-weight:600;letter-spacing:0;overflow-wrap:anywhere}
#file-viewer .markdown h1{font-size:28px;line-height:36px;letter-spacing:-.2px;margin:32px 0 12px}
#file-viewer .markdown h2{font-size:22px;line-height:30px;margin:28px 0 10px}
#file-viewer .markdown h3{font-size:18px;line-height:26px;margin:24px 0 8px}
#file-viewer .markdown>:first-child{margin-top:0}
#file-viewer .markdown>:last-child{margin-bottom:0}
/* Tight lists keep the steady 26px prose rhythm; separate paragraphs stay visibly separate. */
#file-viewer .markdown :is(ul,ol){padding-left:26px;margin:0 0 16px}
#file-viewer .markdown li{margin:0}
#file-viewer .markdown li>p{margin:0}
#file-viewer .markdown li>p+p{margin-top:8px}
#file-viewer .markdown li>:is(ul,ol){margin:0}
/* Loose lists: editor lists without data-tight, or rendered items wrapped in paragraphs. */
#file-viewer .markdown :is(ul,ol):not([data-tight])>li+li:has(>p){margin-top:8px}
.rich-document{outline:0;min-height:45vh;cursor:text}.rich-document pre{white-space:pre-wrap}.rich-document pre code{font-size:13px}.rich-document .editor-image{display:inline-block;border:1px dashed var(--line);border-radius:4px;padding:2px 8px;color:var(--muted);font-size:13px}.rich-document [data-align=left]{text-align:left}.rich-document [data-align=center]{text-align:center}.rich-document [data-align=right]{text-align:right}
#file-viewer .document-status{display:flex;align-items:baseline;justify-content:flex-end;gap:16px;padding:4px 20px;min-height:28px;font-size:11px;color:var(--muted);border-top:1px solid var(--line)}#file-status{margin:0}#file-version{font-size:11px}
#file-viewer #file-editor{border:0;border-radius:0;min-height:55vh;padding:0;outline:0;resize:vertical}
#file-menu-dialog .more-actions+.more-actions{border-top:1px solid var(--line);padding-top:6px;margin-top:6px}
@media(max-width:1000px){#file-document>.document-heading{grid-template-columns:minmax(100px,1fr) auto;gap:4px}#file-formatbar{grid-row:2;grid-column:1/3;justify-content:center}#file-document>.document-heading:has(#file-formatbar:not([hidden])){height:98px;min-height:98px}.document-heading-actions{grid-row:1;grid-column:2}.document-heading-title{gap:4px}#library-view.file-open.file-sidebar-open>.library-sidebar{width:200px}.document-body{padding-top:48px}}
@media(max-width:700px){#file-document>.document-heading{padding:8px 12px}.document-body{padding:32px 20px 48px}#file-viewer .document-heading h1{order:0;flex-basis:auto}#file-formatbar{gap:2px}#file-formatbar button{width:32px}#file-preamble{font-size:14px;line-height:22px;margin-bottom:32px}#file-viewer .document-status{padding:4px 12px;justify-content:space-between;gap:8px}#file-status{font-size:11px}#library-view.file-open.file-sidebar-open>.library-sidebar{width:100%}.document-heading-actions{gap:4px}.document-scroll{overscroll-behavior:contain}}
@media(max-width:700px){
  #file-viewer .markdown{font-size:15px;line-height:24px}
  #file-viewer .markdown h1{font-size:24px;line-height:32px}
  #file-viewer .markdown h2{font-size:20px;line-height:28px}
  #file-viewer .markdown h3{font-size:17px;line-height:24px}
}
/* Side-by-side document chat. The live Main chat column (360px by default, after the rail) sits on
   the leading side; the document keeps the remaining width with its own header and scroll. The
   column clamps to the pane, so a narrower window needs no script. Only .with-chat changes layout,
   and the full viewer above is untouched. */
#file-viewer.with-chat{display:grid;grid-template-columns:clamp(280px,var(--file-chat-width,360px),calc(100% - 360px)) minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
#file-viewer.with-chat>#file-document{grid-column:2;grid-row:1;container:file-document/inline-size}
#file-chat{grid-column:1;grid-row:1;display:flex;flex-direction:column;min-width:0;min-height:0;border-right:1px solid var(--line);background:var(--bg)}
.file-chat-heading{flex:none;height:60px;display:flex;flex-direction:column;justify-content:center;gap:2px;padding:0 16px;border-bottom:1px solid var(--line)}
.file-chat-heading h2{margin:0;font-size:16px;font-weight:600;line-height:22px;letter-spacing:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#file-chat-context{display:flex;gap:4px;margin:0;min-width:0;font-size:12px;line-height:16px;color:var(--muted);white-space:nowrap}
#file-chat-context>span{flex:none}
#file-chat-context>#file-chat-file{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;color:var(--text)}
#file-chat #chat-view{min-width:0;width:100%}
#file-chat #chat-scroll{padding:12px 16px 20px;overscroll-behavior:contain}
/* The separator straddles the column edge without taking width, so the document starts where the column ends. */
#file-chat-resize{grid-column:1;grid-row:1;justify-self:end;position:relative;z-index:3;width:12px;margin-right:-6px;cursor:col-resize;touch-action:none;outline:0}
#file-chat-resize::after{content:'';position:absolute;top:0;bottom:0;left:5px;width:2px;border-radius:1px}
#file-chat-resize:hover::after,.resizing-chat #file-chat-resize::after{background:color-mix(in srgb,var(--accent) 45%,transparent)}
#file-chat-resize:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;border-radius:6px}
#file-chat-resize:focus-visible::after{background:var(--accent)}
#file-viewer.resizing-chat{cursor:col-resize;user-select:none}
/* A narrow document pane wraps its header (formatting on a second row) and keeps every control. */
@container file-document (max-width:720px){
  #file-viewer.with-chat .document-heading{grid-template-columns:minmax(0,1fr) auto;gap:4px 8px;padding:10px 16px}
  #file-viewer.with-chat .document-heading:has(#file-formatbar:not([hidden])){height:auto;min-height:98px}
  #file-viewer.with-chat #file-formatbar{grid-row:2;grid-column:1/3;justify-content:center;flex-wrap:wrap}
  #file-viewer.with-chat .document-heading-actions{grid-row:1;grid-column:2;gap:4px}
  #file-viewer.with-chat .document-heading-title{gap:4px}
  #file-viewer.with-chat .document-body{padding:48px 24px}
}
@container file-document (max-width:480px){
  #file-viewer.with-chat .document-heading{padding:8px 12px}
  #file-viewer.with-chat .document-body{padding:32px 16px 40px}
}
/* Wide card-opened split (file-editor.js syncFileChatHeader, never at ≤700px): the real chat header
   floats over the origin conversation, whose history scrolls beneath it. The title/context row stays
   as the pane's accessible name and description, visually hidden. Only the header's controls take
   pointer events. The picker and status panel it opens stay inside the measured conversation column
   (--file-chat-column), so the document never shifts or loses width. */
#chat-header-name{display:none}
#file-chat.origin-overlay{position:relative}
#file-chat.origin-overlay>.file-chat-heading{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0}
#file-chat.origin-overlay #chat-scroll{padding-top:72px;scroll-padding-top:72px}
#file-chat>#chat-header{position:absolute;z-index:2;top:0;left:0;right:0;height:72px;display:flex;align-items:flex-start;justify-content:flex-start;gap:6px;padding:10px 12px 0;pointer-events:none;background:linear-gradient(var(--bg) 55%,transparent)}
#file-chat>#chat-header button{pointer-events:auto}
#file-chat>#chat-header #title{display:none}
#file-chat>#chat-header .chat-title-pill{display:flex}
#file-chat>#chat-header :is(#chat-back,#sidebar-toggle){width:36px;height:36px;padding:0;display:inline-grid;place-items:center;border-radius:50%;background:var(--surface);box-shadow:var(--shadow);color:var(--text)}
#file-chat>#chat-header :is(#chat-back,#sidebar-toggle) svg{width:20px;height:20px}
#file-chat>#chat-header #chat-back svg{transform:rotate(90deg)}
#file-chat>#chat-header:not(.side-chat) #chat-back{display:none}
#file-chat>#chat-header #activity-toggle{position:absolute;top:8px;left:50%;transform:translateX(-50%);width:36px;height:36px;font-size:24px}
#file-chat>#chat-header #chat-header-name{display:block;position:absolute;top:46px;left:50%;transform:translateX(-50%);max-width:calc(50% - 32px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:14px;color:var(--muted)}
#shell:has(#file-chat.origin-overlay){--origin-column:var(--file-chat-column,410px)}
#shell.page-mode.show-sidebar:has(#file-chat.origin-overlay)>#sidebar{display:flex;position:absolute;z-index:6;top:72px;bottom:0;left:72px;width:min(310px,var(--origin-column));background:var(--bg);box-shadow:12px 0 40px #0002}
#shell:has(#file-chat.origin-overlay)>#activity-panel{position:absolute;z-index:6;top:0;bottom:0;left:72px;right:auto;width:var(--origin-column);border-left:0;border-right:1px solid var(--line);background:var(--bg);box-shadow:var(--shadow)}
/* Compact fallback: chat above the document, each with its own scroll; no separator to drag. */
@media(max-width:700px){
  #file-viewer.with-chat{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,45fr) minmax(0,55fr)}
  #file-viewer.with-chat>#file-document{grid-column:1;grid-row:2}
  #file-chat{border-right:0;border-bottom:1px solid var(--line)}
  .file-chat-heading{height:48px;padding:0 12px}
  #file-chat #chat-scroll{padding:8px 12px 12px}
  #file-chat-resize{display:none!important}
}
