:root{color-scheme:light dark;--bg:#f3f4f0;--panel:#fff;--ink:#222923;--muted:#5b655d;--line:#d8ddd5;--accent:#225d49;--on:#fff;--soft:#e8efe8;--danger:#9d3528;font:15px/1.5 system-ui,sans-serif}
@media(prefers-color-scheme:dark){:root{--bg:#171c19;--panel:#222a24;--ink:#edf1e9;--muted:#bac6bc;--line:#404b42;--accent:#93cdb2;--on:#17271e;--soft:#303e33;--danger:#f2a79b}}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink)}[hidden]{display:none!important}button,input,select,textarea{font:inherit;color:inherit}button,input,select{min-height:42px}button{cursor:pointer;background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:8px 14px}button:hover:not(:disabled){border-color:var(--accent)}button:disabled{cursor:not-allowed;opacity:.6}a{color:var(--accent)}:focus-visible{outline:3px solid var(--accent);outline-offset:3px}.skip{position:absolute;left:8px;top:-80px;padding:10px;background:var(--panel);z-index:5}.skip:focus{top:8px}.top{display:flex;gap:20px;align-items:center;min-height:66px;border-bottom:1px solid var(--line);background:var(--panel);padding:12px max(20px,calc((100vw - 1160px)/2))}.brand{display:flex;gap:10px;align-items:center;text-decoration:none;color:var(--ink);white-space:nowrap;letter-spacing:-.02em}.brand-mark{display:grid;place-items:center;width:32px;height:32px;background:var(--accent);color:var(--on);border-radius:7px;font-family:Georgia,serif;font-size:23px}.local{margin-left:auto;color:var(--muted);font-size:12px}.quiet{font-size:13px}main{max-width:1160px;margin:auto;padding:36px 20px;min-height:75vh}footer{border-top:1px solid var(--line);max-width:1160px;margin:auto;padding:20px;color:var(--muted);font-size:12px}.hero{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:24px}.eyebrow{color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.12em}h1,h2,p{margin:0}h1{font:500 clamp(28px,4vw,44px)/1.1 Georgia,serif;letter-spacing:-.04em;margin:8px 0}h2{font-size:18px}p{color:var(--muted)}.primary{background:var(--accent);color:var(--on);border-color:var(--accent);font-weight:650}.toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;padding:14px 0}.toolbar input{flex:1 1 240px}.toolbar input,.toolbar select,.title-input{background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:9px 12px;min-width:0}.tabs{display:flex;gap:8px}.tabs button[aria-pressed=true]{background:var(--soft);font-weight:650}.library{border:1px solid var(--line);border-radius:10px;background:var(--panel);overflow:hidden}.doc{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--line)}.doc:last-child{border-bottom:0}.doc-main{min-width:0}.doc-main a,.doc-main strong{display:block;font-weight:650;overflow-wrap:anywhere;text-decoration:none;color:var(--ink)}.doc-main a:hover{text-decoration:underline}.doc-main small{display:block;color:var(--muted);margin-top:4px}.doc-actions{display:flex;gap:6px;flex-wrap:wrap}.doc-actions button{min-height:36px;font-size:13px}.empty{padding:48px 20px;text-align:center}.empty h2{margin-bottom:6px}.status{min-height:24px;margin:8px 0;color:var(--muted);overflow-wrap:anywhere}.status[data-error=true]{color:var(--danger)}.editor-top{display:flex;align-items:end;gap:12px;flex-wrap:wrap}.title-wrap{display:grid;gap:5px;flex:1 1 260px}.title-input{width:100%;font-size:22px;font-weight:600}.editor-actions{display:flex;gap:8px;flex-wrap:wrap}.editor-grid{display:grid;grid-template-columns:minmax(0,1fr) 245px;gap:20px;margin-top:16px}.paper{display:grid;gap:8px;background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:20px;min-width:0}.paper textarea{width:100%;resize:vertical;min-height:55vh;background:var(--panel);color:var(--ink);padding:14px;border:1px solid var(--line);border-radius:5px;font:15px/1.75 ui-monospace,monospace}.side{min-width:0;border:1px solid var(--line);border-radius:8px;background:var(--panel);padding:16px;align-self:start}.side p{font-size:13px;margin:8px 0}.side ol{padding-left:20px;overflow-wrap:anywhere}.side li{margin:8px 0}.side button{width:100%;margin-top:8px}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}@media(max-width:680px){.top{padding:12px 14px;gap:10px}.local{display:none}.quiet{margin-left:auto}main{padding:24px 14px}.hero{align-items:start;flex-direction:column}.doc{grid-template-columns:1fr;padding:14px}.editor-grid{grid-template-columns:1fr}.paper{padding:12px}.editor-actions{width:100%}.editor-actions button{flex:1}.doc-actions button{flex:1}}

/* Keep navigation and controls usable at narrow viewport widths and large text. */
.top{flex-wrap:wrap}.brand{max-width:100%;white-space:normal}.brand-mark{flex:none}.title-wrap,.editor-actions{min-width:0}.editor-actions button{max-width:100%;white-space:normal}.toolbar input{max-width:100%}.doc-actions{min-width:0}.doc-actions button{white-space:normal}.editor-top+ .status{min-height:24px}

/* O3 paper-like visual canvas; continuous document, not simulated pagination. */
.visual-mode,.visual-toolbar{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.visual-mode button[aria-pressed=true]{background:var(--soft);font-weight:650;border-color:var(--accent)}
.visual-note{font-size:13px;overflow-wrap:anywhere}
.visual-panel{display:grid;gap:12px;min-width:0}
.visual-toolbar{border-block:1px solid var(--line);padding:8px 0}
.visual-toolbar button{font-size:13px;padding:5px 10px;min-height:36px}
.visual-page-frame{background:var(--bg);padding:clamp(8px,2vw,24px);border:1px solid var(--line);border-radius:7px}
.visual-page{max-width:794px;margin:auto;min-height:65vh;padding:clamp(16px,5vw,56px);background:var(--panel);border:1px solid var(--line);box-shadow:0 2px 10px #0000000a;color:var(--ink);font:17px/1.7 Georgia,serif;overflow-wrap:anywhere;white-space:pre-wrap;outline-offset:2px}
.visual-page p,.visual-page div,.visual-page h1,.visual-page h2,.visual-page h3,.visual-page blockquote,.visual-page ul,.visual-page ol{margin:0 0 14px;color:inherit}
.visual-page h1{font:600 32px/1.25 Georgia,serif;letter-spacing:-.025em}.visual-page h2{font:600 26px/1.3 Georgia,serif}.visual-page h3{font:600 21px/1.4 Georgia,serif}
.visual-page ul,.visual-page ol{padding-inline-start:24px}.visual-page blockquote{border-inline-start:3px solid var(--accent);padding-inline-start:14px}
.visual-page code{font: .9em/1.5 ui-monospace,monospace;background:var(--soft);padding:2px 4px;border-radius:3px}
.visual-page[aria-invalid=true]{border-color:var(--danger)}
@media(max-width:680px){.visual-page-frame{padding:6px}.visual-page{padding:14px;font-size:16px}.visual-toolbar button{flex:1 1 auto}}

.visual-page.ProseMirror{outline-offset:2px;white-space:pre-wrap;min-width:0}.visual-page table{border-collapse:collapse;table-layout:fixed;width:100%;margin:12px 0}.visual-page td,.visual-page th{border:1px solid var(--line);padding:8px;vertical-align:top;min-width:0;overflow-wrap:anywhere}.visual-page th{background:var(--soft)}.visual-page td p,.visual-page th p{margin:0}.visual-page .selectedCell{background:var(--soft)}.visual-toolbar button[aria-pressed=true]{background:var(--soft);border-color:var(--accent)}.visual-page a{text-decoration:underline}.visual-page pre{white-space:pre-wrap;overflow-wrap:anywhere}.visual-page ul ul,.visual-page ol ol{margin-bottom:0}

/* Authoring controls remain accessible at narrow widths; paper layout is continuous. */
.office-ribbon{border:1px solid var(--line);border-radius:8px;background:var(--panel);padding:8px;display:grid;gap:8px;min-width:0}
.office-ribbon .visual-toolbar{border:0;padding:0}
.authoring-controls{display:flex;flex-wrap:wrap;gap:8px;align-items:end;border-top:1px solid var(--line);padding-top:8px;min-width:0}
.authoring-controls label{display:grid;gap:3px;font-size:12px;color:var(--muted);min-width:0;flex:1 1 95px}
.authoring-controls select{min-width:0;width:100%;padding:6px;background:var(--panel);border:1px solid var(--line);border-radius:5px;font-size:13px}
.visual-work{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;min-width:0}
.document-outline{border:1px solid var(--line);border-radius:7px;padding:10px;max-height:180px;overflow:auto}
.document-outline h2{font-size:14px;margin-bottom:5px}.document-outline p{font-size:12px}
.outline-heading{display:block;width:100%;text-align:left;border:0;min-height:28px;padding:4px 6px;overflow-wrap:anywhere;font-size:13px}
.outline-heading[data-level="2"]{padding-inline-start:18px}.outline-heading[data-level="3"]{padding-inline-start:30px}
.visual-page-frame{min-width:0;overflow:auto}.visual-page{width:100%;max-width:var(--office-page-width,210mm);padding:clamp(14px,4vw,var(--office-margin,20mm))}
.visual-page .tableWrapper{overflow-x:auto}.visual-page td,.visual-page th{min-width:3em}
@media print{
 body.office-printing{background:white!important;color:#202820!important}
 body.office-printing .top,body.office-printing footer,body.office-printing .skip,body.office-printing #app>a,body.office-printing #app>h1,body.office-printing .editor-top,body.office-printing .status,body.office-printing .side,body.office-printing .visual-mode,body.office-printing .visual-note,body.office-printing .paper>button,body.office-printing .office-ribbon,body.office-printing .document-outline,body.office-printing .visual-panel>button{display:none!important}
 body.office-printing main,body.office-printing #app,body.office-printing .editor-grid,body.office-printing .paper,body.office-printing .visual-panel,body.office-printing .visual-work,body.office-printing .visual-page-frame{display:block!important;margin:0!important;padding:0!important;border:0!important;background:white!important;max-width:none!important;min-height:0!important;overflow:visible!important}
 body.office-printing .visual-page{width:auto!important;max-width:none!important;min-height:0!important;padding:0!important;border:0!important;box-shadow:none!important;background:white!important;color:#202820!important;outline:0!important}
 body.office-printing .visual-page table{break-inside:auto}body.office-printing .visual-page tr{break-inside:avoid}body.office-printing .visual-page thead{display:table-header-group}body.office-printing .visual-page h1,body.office-printing .visual-page h2,body.office-printing .visual-page h3{break-after:avoid}
}

.account-panel{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;padding:8px 16px;border-bottom:1px solid var(--line);font-size:12px}.account-panel p{margin:0}.account-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.account-recovery{padding:12px;border:1px solid var(--line);border-radius:8px;margin-bottom:12px}.account-recovery button{margin:4px}.account-actions button{font-size:12px}.account-actions a{font-size:12px}@media print{body.office-printing .account-panel{display:none!important}}

.conflict-review{width:100%;max-width:100%;padding:8px;border:1px solid var(--line);border-radius:6px}.conflict-review summary{cursor:pointer;font-weight:600}.conflict-versions{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:8px}.conflict-versions section{min-width:0}.conflict-versions pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:220px;overflow:auto;font-size:12px}.conflict-review button{margin:4px}

.migration-panel{margin:12px 0;padding:12px;overflow-wrap:anywhere}.migration-panel summary{cursor:pointer;font-weight:600}.migration-panel input{max-width:100%;margin:4px}.migration-panel button{margin:4px}.migration-panel p{margin:8px 0}.migration-panel section{border-top:1px solid var(--line);margin-top:12px}

/* O5.1: native MathML, no external styles, scripts or fonts. */
.office-equation{cursor:pointer;border-radius:4px;max-width:100%;color:inherit}
.office-equation-inline{display:inline-block;vertical-align:middle;padding:0 .15em;max-width:100%;overflow-x:auto}
.office-equation-display{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:.7em;margin:.9em 0;padding:.45em .3em;break-inside:avoid}
.office-equation-display .office-equation-math{overflow-x:auto;text-align:center}
.office-equation-math math{font-size:1.05em;color:inherit}
.office-equation-number{font-variant-numeric:tabular-nums;white-space:nowrap}
.office-equation[data-equation-error]{outline:1px dashed currentColor;white-space:pre-wrap;overflow-wrap:anywhere}
.office-equation-dialog{max-width:min(640px,calc(100vw - 24px));width:100%;background:var(--panel);color:var(--ink);border:1px solid var(--line,#aaa);border-radius:10px;padding:20px}
.office-equation-dialog::backdrop{background:#0008}
.office-equation-dialog form{display:grid;gap:12px}
.office-equation-dialog textarea{display:block;width:100%;box-sizing:border-box;font:inherit;font-family:monospace;resize:vertical}
.office-equation-preview{min-height:2em;overflow:auto;padding:10px;border:1px solid var(--line,#aaa);text-align:center}
@media print{.office-equation-dialog{display:none!important}.office-equation.ProseMirror-selectednode{outline:none!important}.office-equation-display .office-equation-math{overflow:visible}}

/* O5.2 academic blocks retain editable rich bodies; captions are derived decorations. */
.office-academic-block{border-left:3px solid var(--accent);padding:.65rem 1rem;margin:1.2rem 0;background:var(--soft);border-radius:0 5px 5px 0;break-inside:avoid}
.office-academic-header{display:flex;gap:.7rem;align-items:baseline;flex-wrap:wrap;cursor:pointer;margin-bottom:.4rem;user-select:none}
.office-academic-caption{font-weight:700}
.office-academic-label{font:11px/1.4 monospace;color:var(--muted);overflow-wrap:anywhere}
.office-academic-body{min-height:1.5em}
.office-academic-body>p:first-child{margin-top:0}
.office-academic-block[data-academic-kind="proof"]{background:transparent;border-left-color:var(--line)}
.office-academic-block[data-academic-kind="proof"] .office-academic-body:after{content:"□";display:block;text-align:right}
.office-academic-reference{color:var(--accent);cursor:pointer;text-decoration:underline;text-underline-offset:2px}
.office-academic-reference[data-unresolved="true"]{color:var(--danger);text-decoration-style:dashed}
.office-academic-dialog input,.office-academic-dialog select{display:block;width:100%;max-width:100%;margin-top:.3rem}
@media print{.office-academic-block{background:transparent;color:#111;break-inside:avoid}.office-academic-label{display:none}.office-academic-reference{color:#111;text-decoration:none}.office-academic-reference[data-unresolved="true"]{text-decoration:underline}}

/* Document-local citations and a generated bibliography. */
.office-citation{font-weight:600;color:var(--accent);cursor:pointer}
.office-citation[data-unresolved="true"]{color:var(--danger);text-decoration:underline dashed}
.office-bibliography{margin:1.8rem 0;padding-top:1rem;border-top:1px solid var(--line)}
.office-bibliography h2{margin:.2rem 0 .6rem}
.office-bibliography li{margin:.4rem 0;overflow-wrap:anywhere}
.office-bibliography-info,.office-bibliography-empty{color:var(--muted);font-size:.85em}
.office-research-dialog{max-height:90vh;overflow:auto}
.office-research-dialog input,.office-research-dialog select,.office-research-dialog textarea{width:100%;max-width:100%}
.office-research-actions{display:flex;gap:.5rem;flex-wrap:wrap}
.office-research-fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:.5rem}
.office-research-fields label{min-width:0}
@media print{.office-bibliography-info,.office-bibliography-empty{display:none}.office-citation{color:#111}}
