/* Word processor styles (the command chrome lives in shared/chrome.css, shared parts in shared/kit.css). */
#doc-main { flex: 1; min-height: 0; display: flex; position: relative; }
#doc-canvas { flex: 1; min-width: 0; overflow: auto; position: relative; background: var(--desk); }
#doc-zoom { position: relative; margin: 20px auto 48px; }
#doc-pages { position: absolute; inset: 0; }
.doc-page { position: absolute; left: 0; background: #fff; box-shadow: 0 1px 3px rgba(60, 64, 67, .18), 0 0 0 1px rgba(60, 64, 67, .06); }
.doc-hf { position: absolute; color: #3c4043; overflow: hidden; cursor: default; }
.doc-hf:empty { display: none; }
.doc-hf.foot { display: flex; flex-direction: column; justify-content: flex-end; }
.doc-hf:hover { outline: 1px dashed #9aa0a6; outline-offset: 4px; }
#doc-column { position: absolute; z-index: 1; }

/* the document itself; paragraph styles are generated into #doc-style-css */
.doc-flow { white-space: pre-wrap; overflow-wrap: break-word; tab-size: 48px; -moz-tab-size: 48px; }
.doc-flow p, .doc-flow h1, .doc-flow h2, .doc-flow h3, .doc-flow h4, .doc-flow h5, .doc-flow h6, .doc-flow li { margin: 0; }
.doc-flow ul, .doc-flow ol { margin: 0; padding-left: 48px; }
.doc-flow li { padding-left: 0; }
/* nested numbering like Word/Docs: 1. → a. → i. (an explicit list-style-type wins) */
.doc-flow ol ol { list-style-type: lower-alpha; }
.doc-flow ol ol ol { list-style-type: lower-roman; }
.doc-flow ol ol ol ol { list-style-type: decimal; }
.doc-flow a { color: #1155cc; text-decoration: underline; }
.doc-flow img { max-width: 100%; height: auto; vertical-align: bottom; }
.doc-flow table { border-collapse: collapse; table-layout: fixed; max-width: 100%; margin: 4px 0; }
.doc-flow table[data-align="center"] { margin-left: auto; margin-right: auto; }
.doc-flow table[data-align="right"] { margin-left: auto; }
.doc-flow td, .doc-flow th { padding: 5px 7px; vertical-align: top; min-width: 16px; overflow-wrap: anywhere; }
.doc-flow table[data-borders="1"] td, .doc-flow table[data-borders="1"] th, .doc-flow table:not([data-borders]) td { border: 1px solid var(--tb-color, #000); }
.doc-flow table[data-borders="0"] td { border: 1px dashed #dadce0; }
.doc-flow hr { border: 0; border-top: 1px solid #5f6368; margin: 8px 0; }
.doc-flow hr.page-break { border: 0; height: 0; margin: 0; }
.doc-flow .toc { margin: 6px 0; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: default; }
.doc-flow .toc a { color: inherit; text-decoration: none; }
.doc-flow .toc a:hover { color: #1155cc; text-decoration: underline; }
.doc-flow .field { display: inline; background: #f1f3f4; border-radius: 2px; }
.doc-hf .field { background: none; }
.doc-flow .cmt { background: rgba(251, 188, 4, .28); border-bottom: 2px solid rgba(249, 171, 0, .7); cursor: pointer; }
.doc-flow .cmt.active { background: rgba(251, 188, 4, .55); }
#doc-body { outline: none; min-height: 1.2em; counter-reset: fn; caret-color: #000; }
#doc-body .fn-ref { color: #1155cc; cursor: pointer; font-size: .72em; vertical-align: super; line-height: 0; padding: 0 1px; }
#doc-body .fn-ref::after { counter-increment: fn; content: counter(fn); }
#doc-body .pg-push, #doc-notes .pg-push { padding-top: var(--push) !important; }
#doc-body tr.pg-push { padding-top: 0 !important; }
#doc-body tr.pg-push > td, #doc-body tr.pg-push > th { padding-top: calc(5px + var(--push)) !important; }
#doc-notes { margin-top: 24px; font-size: 9pt; cursor: pointer; }
#doc-notes .notes-sep { width: 160px; border-top: 1px solid #5f6368; margin-bottom: 6px; }
#doc-notes .notes-list { padding-left: 20px; }
#doc-notes li { font-size: 9pt; }
#doc-notes li p { font-size: 9pt; line-height: 1.3; margin: 0; }
#doc-notes li:hover { background: var(--bg); }
::highlight(find-hits) { background-color: #fde293; }
::highlight(find-current) { background-color: #f9ab00; color: #000; }

/* image resize box */
#img-box { position: absolute; z-index: 3; border: 1px solid var(--sel); pointer-events: none; }
#img-box .img-handle { position: absolute; right: -5px; bottom: -5px; width: 8px; height: 8px; background: #fff; border: 1.3px solid var(--sel); border-radius: 2px; cursor: nwse-resize; pointer-events: auto; }
#img-box .img-size { position: absolute; left: 0; top: calc(100% + 6px); background: #3c4043; color: #fff; font: 11px Arial; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }

/* link chip */
#link-chip { position: absolute; z-index: 5; display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--pop-shadow); border-radius: var(--radius); padding: 4px 4px 4px 8px; font-size: 12.5px; max-width: 440px; }
#link-chip a { font-family: var(--mono); font-size: 12px; color: var(--accent-strong); text-decoration: none; margin-right: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#link-chip a:hover { text-decoration: underline; }
#link-chip > .material-symbols-outlined { font-size: 18px; color: var(--muted); }

/* the outline (left panel) and comments (right panel) */
#outline, #comments-panel { display: flex; flex-direction: column; min-height: 0; }
.panel-list { flex: 1; min-height: 0; overflow: auto; padding: 6px 8px 14px; display: flex; flex-direction: column; gap: 2px; }
.outline-item { text-align: left; border: 0; background: none; border-radius: 16px; padding: 6px 10px; cursor: pointer; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-item:hover { background: var(--hover); }
.outline-item.lvl0 { font-weight: 500; }
.outline-item.lvl2 { padding-left: 22px; }
.outline-item.lvl3 { padding-left: 34px; }
.outline-item.lvl4, .outline-item.lvl5, .outline-item.lvl6 { padding-left: 46px; color: var(--muted); }
.cmt-card { background: var(--surface); border-radius: 8px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(60, 64, 67, .2); margin-bottom: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; border-left: 3px solid transparent; }
.cmt-card.active { border-left-color: #f9ab00; box-shadow: 0 2px 6px rgba(60, 64, 67, .25); }
.cmt-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.cmt-quote { font-size: 12px; color: var(--muted); border-left: 2px solid #f9ab00; padding-left: 6px; }
.cmt-text { font-size: 13px; white-space: pre-wrap; line-height: 1.45; }
.cmt-actions { display: flex; gap: 4px; margin-left: -6px; }

/* dialogs & popovers specific to documents */
.mini-editor { min-height: 72px; max-height: 220px; overflow: auto; border: 1px solid var(--line-strong); border-radius: 4px; padding: 8px 10px; outline: none; background: var(--surface); }
.mini-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.hf-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.hf-tools .btn { padding: 4px 10px; font-size: 13px; }
.margin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; }
.char-btn { height: 36px; border: 1px solid var(--line-soft); background: var(--surface); border-radius: 4px; font-size: 18px; cursor: pointer; }
.char-btn:hover { background: #e8f0fe; border-color: #aecbfa; }
.grid-pick { display: flex; flex-direction: column; gap: 6px; }
.grid-pick-cells { display: grid; grid-template-columns: repeat(10, 18px); gap: 2px; }
.gp { width: 18px; height: 18px; border: 1px solid var(--line-strong); background: var(--surface); padding: 0; border-radius: 2px; cursor: pointer; }
.gp.on { background: var(--sel-soft); border-color: var(--sel); }
.grid-pick-label { font-size: 12px; color: var(--muted); text-align: center; }
/* bar controls: the paragraph style picker shows the current style */
.cmd-style { width: 124px; }
.grid-pick > .link-btn { align-self: center; padding: 2px 6px; }
.stats td:last-child { text-align: right; font-variant-numeric: tabular-nums; }


#print-pages { display: none; }
@media print {
  /* the editor builds #print-pages (one sheet per page, as on screen) on beforeprint; @page has no margin */
  html:has(body.printing), body.printing { margin: 0 !important; padding: 0 !important; background: #fff !important; height: auto !important; overflow: visible !important; display: block !important; }
  body.printing > *:not(#print-pages) { display: none !important; }
  #print-pages { display: block; }
  /* fallback when a browser prints without a beforeprint event: just the text, without the page chrome */
  body:not(.printing) #cmd-header, body:not(.printing) #cmd-left, body:not(.printing) .cmd-mega, body:not(.printing) .cmd-files, body:not(.printing) .cmd-side, body:not(.printing) #doc-pages, body:not(.printing) .toast { display: none !important; }
  body:not(.printing), body:not(.printing) #app, body:not(.printing) #workspace, body:not(.printing) #main, body:not(.printing) #doc-main, body:not(.printing) #doc-canvas { height: auto !important; overflow: visible !important; display: block !important; background: #fff !important; }
  body:not(.printing) #doc-zoom { zoom: 1 !important; margin: 0 !important; height: auto !important; }
  body:not(.printing) #doc-column { position: static !important; }
  body:not(.printing) .pg-push { padding-top: 0 !important; }
  .print-sheet { position: relative; overflow: hidden; break-after: page; background: #fff; }
  .print-sheet:last-child { break-after: auto; }
  .print-sheet .doc-page { box-shadow: none; }
  .print-window { position: absolute; left: 0; right: 0; overflow: hidden; }
  .print-window #doc-column { z-index: 1; }
  .doc-flow table[data-borders="0"] td { border: 0; }
  .doc-flow .cmt { background: none; border: 0; }
}

#link-chip .btn { height: 26px; padding: 0 9px; font-size: 12px; }
