/* Office Word Editor — SharePoint / Word-for-the-web look. Light + dark themes. */
:root {
  --blue: #185ABD;
  --blue-dark: #124A98;
  --blue-darker: #0F3E80;
  --blue-soft: #B4D0F3;
  --blue-soft-2: #EBF3FC;
  --bg: #ffffff;
  --bg-2: #f5f6f7;
  --bg-3: #eceef0;
  --text: #242424;
  --text-2: #616161;
  --line: #e1e1e1;
  --line-2: #d1d1d1;
  --chat-bg: #ffffff;
  --bubble-user: #E8F1FB;
  --bubble-user-line: #D2E3F5;
  --bubble-user-text: #16324E;
  --bubble-ai: #f0f1f3;
  --bubble-ai-line: #e6e7e9;
  --accent-link: #0F6CBD;
  --danger: #A4262C;
  --danger-bg: #FDF3F4;
  --danger-line: #F1BBC0;
  --warn-bg: #FFF4CE;
  --warn-line: #F0E6B3;
  --chip-bg: #F7F6FE;
  --chip-line: #D6D3F1;
  --chip-text: #40397E;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  --shadow-page: 0 2px 8px rgba(0, 0, 0, 0.22);
  color-scheme: light;
}
[data-theme="dark"] {
  --blue: #2268c9;
  --blue-dark: #3577d4;
  --blue-darker: #185ABD;
  --blue-soft: #2c517e;
  --blue-soft-2: #1c2c42;
  --bg: #1d1f21;
  --bg-2: #26282b;
  --bg-3: #2e3134;
  --text: #e8e8e8;
  --text-2: #a5a5a5;
  --line: #3a3d40;
  --line-2: #46494d;
  --chat-bg: #202225;
  --bubble-user: #1c2c42;
  --bubble-user-line: #2c517e;
  --bubble-user-text: #cfe1f5;
  --bubble-ai: #2b2d30;
  --bubble-ai-line: #37393c;
  --accent-link: #6cb2f0;
  --danger: #ff6b7a;
  --danger-bg: #3a2225;
  --danger-line: #5c3338;
  --warn-bg: #3a3320;
  --warn-line: #5c522f;
  --chip-bg: #26243a;
  --chip-line: #3f3b63;
  --chip-text: #b8b1ea;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  --shadow-page: 0 2px 12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.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;
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg-3);
  display: flex; flex-direction: column; overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
svg { fill: currentColor; }

/* ---------- Suite bar (Word blue in both themes) ---------- */
.suitebar {
  height: 48px; background: var(--blue); color: #fff;
  display: flex; align-items: center; gap: 10px; padding: 0 12px 0 0; flex: none;
}
[data-theme="dark"] .suitebar { background: #17457e; }
.waffle {
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  color: #fff; background: transparent; border: 0; cursor: pointer;
}
.waffle:hover { background: rgba(255,255,255,.12); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.brand-ic { flex: none; }
.docmeta { display: flex; align-items: baseline; gap: 10px; margin-left: 18px; min-width: 0; }
#docTitle {
  font-size: 14px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
  outline: none; white-space: nowrap; overflow: hidden; max-width: 320px;
}
#docTitle:hover, #docTitle:focus { background: rgba(255,255,255,.16); }
.docstate { font-size: 12px; opacity: .82; white-space: nowrap; }

/* top-right actions — same design as Excel Editor */
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.credits { font-size: 12px; background: rgba(255,255,255,.16); border-radius: 10px; padding: 3px 9px; font-family: ui-monospace, Menlo, monospace; }
.topup { color: #fff; font-size: 12px; text-decoration: underline; }
.top-icon-btn, .top-ghost-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.top-icon-btn { padding: 4px 8px; }
.top-icon-btn:hover, .top-ghost-btn:hover { background: rgba(255,255,255,.14); }
.top-signin-btn {
  background: #fff; color: var(--blue-darker); border: none; border-radius: 4px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
[data-theme="dark"] .top-signin-btn { color: #0F3E80; }
.top-signin-btn:hover { background: #eef3fa; }
.chat-toggle.active { background: rgba(255,255,255,.22); }
#themeBtn::before { content: "\2600"; font-size: 14px; }
[data-theme="dark"] #themeBtn::before { content: "\263E"; }
#helpBtn { font-weight: 700; }

/* ---------- Ribbon ---------- */
.ribbon { background: var(--bg); border-bottom: 1px solid var(--line-2); flex: none; }
.rtabs { display: flex; align-items: center; padding: 0 8px; }
.rtab {
  background: transparent; border: 0; padding: 9px 14px 7px; font-size: 14px;
  color: var(--text); cursor: pointer; border-bottom: 2.5px solid transparent;
}
.rtab:hover { color: var(--blue-dark); }
.rtab.active { color: var(--blue-dark); font-weight: 600; border-bottom-color: var(--blue-dark); }
.rtab-file { color: var(--blue-dark); font-weight: 600; }
.rtabs-spacer { flex: 1; }
.rev-cluster { display: flex; align-items: center; gap: 4px; margin-right: 6px; }
.rev-cluster .rlbl { margin-right: 4px; font-size: 12.5px; white-space: nowrap; }
.rev-cluster .rinput { width: 120px; height: 24px; }
.rev-cluster .rbtn { height: 26px; }
.rev-cluster .rbtn-lbl span { font-size: 12.5px; white-space: nowrap; }
.rev-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
@media (max-width: 1360px) { .rev-count { display: none; } }
@media (max-width: 1180px) { .rlbl-author { display: none; } }
.rbar {
  display: flex; align-items: center; gap: 4px; padding: 5px 12px 7px;
  border-top: 1px solid var(--line); flex-wrap: wrap;
}
.rgroup { display: flex; align-items: center; gap: 2px; }
.rsep { width: 1px; height: 26px; background: var(--line); margin: 0 8px; }
.rbtn {
  min-width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--text); cursor: pointer; padding: 0 5px; gap: 6px;
}
.rbtn:hover { background: var(--bg-2); border-color: var(--line); }
.rbtn.on { background: var(--blue-soft-2); border-color: var(--blue-soft); color: var(--blue-dark); }
.rbtn-lbl span { font-size: 13px; }
.rlbl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin-right: 12px; }
.rsel {
  height: 28px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--bg);
  font-size: 13px; padding: 0 4px; color: var(--text);
}
.rsel-font { width: 130px; }
.rsel-size { width: 54px; }
.tbtn span { font-size: 14px; }
.g-b { font-weight: 700; }
.g-i { font-style: italic; font-family: Georgia, serif; }
.g-u { text-decoration: underline; }
.g-s { text-decoration: line-through; font-size: 13px; }
.g-hl { background: #FFFF00; padding: 0 2px; font-size: 12px; border-radius: 2px; color: #242424; }
.g-fc { color: #C00000; font-weight: 700; border-bottom: 3px solid #C00000; line-height: 1; }
.g-cf { font-weight: 600; }
.g-cfx { font-size: 10px; margin-left: -2px; color: #C00000; }

.stylechip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 4px; margin: 0 2px;
  padding: 3px 10px; cursor: pointer; font-size: 12.5px; line-height: 1.5; color: var(--text);
}
.stylechip:hover { background: var(--bg-2); border-color: var(--line-2); }
.stylechip.on { background: var(--blue-soft-2); border-color: var(--blue-soft); }
.st-Title { font-family: "Calibri Light", Calibri, sans-serif; font-size: 14px; }
.st-Heading1 { color: #2F5496; font-family: "Calibri Light", Calibri, sans-serif; font-weight: 600; }
.st-Heading2 { color: #2F5496; font-family: "Calibri Light", Calibri, sans-serif; }
.st-Heading3 { color: #1F3763; font-family: "Calibri Light", Calibri, sans-serif; }
[data-theme="dark"] .st-Heading1, [data-theme="dark"] .st-Heading2 { color: #8fb3e8; }
[data-theme="dark"] .st-Heading3 { color: #7fa3d8; }
.st-Quote { font-style: italic; color: var(--text-2); }

/* dropdowns */
.dropwrap { position: relative; }
.drop {
  position: absolute; top: 34px; left: 0; z-index: 60; background: var(--bg);
  border: 1px solid var(--line-2); border-radius: 6px; box-shadow: var(--shadow);
  padding: 8px;
}
.drop-colors { display: grid; grid-template-columns: repeat(5, 24px); gap: 6px; }
.drop-colors button {
  width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--line-2); cursor: pointer; padding: 0;
}
.drop-colors button:hover { outline: 2px solid var(--blue); }
.drop-colors .noneopt { grid-column: 1 / -1; width: auto; height: 26px; font-size: 12px; background: var(--bg); color: var(--text); }
.drop-table { display: flex; flex-direction: column; gap: 8px; width: 190px; }
.drop-table label { font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text); }
.drop-table input[type="number"] { width: 64px; height: 26px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 6px; background: var(--bg); color: var(--text); }
.drop-primary {
  background: var(--blue); color: #fff; border: 0; border-radius: 4px; height: 30px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.drop-primary:hover { background: var(--blue-dark); }

/* ---------- File menu ---------- */
.filemenu {
  position: fixed; top: 84px; left: 10px; z-index: 100; background: var(--bg); width: 280px;
  border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow);
  padding: 6px;
}
.fm-item {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  padding: 10px 12px; font-size: 13.5px; border-radius: 5px; cursor: pointer; color: var(--text);
  text-decoration: none;
}
.fm-item:hover { background: var(--bg-2); }
.fm-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.fm-note { font-size: 11.5px; color: var(--text-2); padding: 8px 12px 10px; line-height: 1.5; }

/* ---------- Main / canvas ---------- */
.main { flex: 1; display: flex; min-height: 0; }
.canvas-wrap { flex: 1; overflow: auto; padding: 28px 20px 60px; position: relative; }
.dropveil {
  position: absolute; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center;
  background: rgba(24,90,189,.10); border: 2.5px dashed var(--blue); margin: 10px;
  border-radius: 10px; font-size: 18px; color: var(--blue); font-weight: 600; pointer-events: none;
}
[data-theme="dark"] .dropveil { color: #8fb3e8; }
.dropveil.show { display: flex; }

/* start screen — same structure as Excel Editor's empty state */
.empty {
  position: absolute; inset: 0; z-index: 20; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-3); padding: 16px 0;
}
.drop-card {
  max-width: 540px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 36px 40px;
  text-align: center; margin: 20px;
}
.drop-logo { margin-bottom: 10px; }
.drop-card h2 { margin: 8px 0 10px; font-size: 21px; color: var(--text); }
.drop-card p { color: var(--text-2); line-height: 1.5; margin: 0 0 18px; }
.drop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
button.primary {
  background: var(--blue); border: 1px solid var(--blue); color: #fff;
  border-radius: 5px; padding: 7px 16px; font-size: 13.5px; font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--blue-dark); }
button.ghost {
  background: transparent; border: 1px solid var(--line-2); color: var(--text);
  border-radius: 5px; padding: 7px 14px; font-size: 13.5px;
}
button.ghost:hover { background: var(--bg-2); }
button.primary.big, button.ghost.big { padding: 9px 18px; font-size: 14px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.tut-link { color: var(--blue-dark); font-weight: 600; }
[data-theme="dark"] .tut-link { color: #8fb3e8; }
.feature-strip { display: flex; gap: 16px; max-width: 940px; margin: 8px 20px; flex-wrap: wrap; justify-content: center; }
.feature { flex: 1 1 230px; max-width: 290px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 13px 16px; }
.feature h3 { margin: 0 0 6px; font-size: 13.5px; color: var(--blue-dark); }
[data-theme="dark"] .feature h3 { color: #8fb3e8; }
.feature p { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }

/* review controls */
.rinput {
  height: 26px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--bg);
  color: var(--text); font-size: 12.5px; padding: 0 8px; width: 150px;
}
.chk-lbl input { accent-color: var(--blue); }
.rev-count { font-size: 12px; color: var(--text-2); margin-left: 10px; }

/* scoped-edit highlight: stays visible while typing in the chat */
.page .scope-hl {
  background: rgba(24, 90, 189, .07);
  box-shadow: inset 3px 0 0 var(--blue);
  border-radius: 2px;
}
[data-theme="dark"] .page .scope-hl { background: rgba(24, 90, 189, .12); }

/* comments: anchor highlight + panel */
.page .cmt-hl { background: #FFE8A6; border-bottom: 2px solid #E8B33C; cursor: pointer; }
[data-theme="dark"] .page .cmt-hl { background: #6b5a22; border-bottom-color: #a8842e; }
.cmt-flash { outline: 2px solid #E8A33D; transition: outline .2s; }
.cmt-badge {
  background: var(--blue); color: #fff; border-radius: 9px; font-size: 10.5px;
  min-width: 16px; padding: 1px 4px; text-align: center; font-weight: 700;
}
.cmt-badge:empty { display: none; }
.cmt-panel {
  position: absolute; top: 14px; right: 18px; z-index: 36; width: 300px; max-height: 75%;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.cmt-panel-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13.5px; color: var(--text);
}
.cmt-panel-head span { flex: 1; }
.cmt-panel-head button {
  background: transparent; border: 1px solid var(--line-2); color: var(--text);
  border-radius: 4px; font-size: 12px; padding: 3px 9px; cursor: pointer;
}
.cmt-panel-head button:hover { background: var(--bg-2); }
.cmt-empty { padding: 16px 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.cmt-list { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.cmt-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
.cmt-card.cmt-reply { margin-left: 20px; }
.cmt-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.cmt-author { font-weight: 600; font-size: 12.5px; color: var(--text); }
.cmt-date { font-size: 11px; color: var(--text-2); }
.cmt-text { font-size: 12.5px; color: var(--text); white-space: pre-wrap; line-height: 1.45; }
.cmt-lost { font-size: 11px; color: var(--danger); margin-top: 4px; }
.cmt-acts { display: flex; gap: 4px; margin-top: 7px; }
.cmt-acts button {
  background: transparent; border: 0; color: var(--accent-link); font-size: 11.5px;
  cursor: pointer; padding: 2px 4px;
}
.cmt-acts button:hover { text-decoration: underline; }

/* tracked-changes markup (Word Online style) */
.page .rev-ins { text-decoration: underline; }
.page .rev-del { text-decoration: line-through; }
.page .rev-c0 { color: #C00000; }
.page .rev-c1 { color: #2E74B5; }
.page .rev-c2 { color: #547B37; }
.page .rev-c3 { color: #7030A0; }
.page .rev-c4 { color: #BF8F00; }
.page .rev-c5 { color: #C55A11; }
.page > .has-rev { position: relative; }
.page > .has-rev::before {
  content: ""; position: absolute; left: -46px; top: 2px; bottom: 2px; width: 2.5px;
  background: #C00000; border-radius: 2px;
}
.page tr.rev-row-ins { outline: 1px dashed #C00000; }
.page .imgblock.rev-del img, .page .pagebreak.rev-del { opacity: .4; outline: 2px dashed #C00000; }
.page .imgblock.rev-ins img { outline: 2px dashed #2E74B5; }
body.no-markup .rev-del { display: none; }
body.no-markup .page tr.rev-row-del { display: none; }
body.no-markup .page .imgblock.rev-ins img { outline: none; }
body.no-markup .page .rev-ins { text-decoration: inherit; color: inherit; }
body.no-markup .page > .has-rev::before { display: none; }
body.no-markup .page tr.rev-row-ins { outline: none; }

/* the document page is paper: white in both themes */
.page {
  width: 816px; min-height: 1056px; margin: 0 auto; background: #fff;
  box-shadow: var(--shadow-page); outline: none;
  padding: 96px; /* set by JS for margins */
  font-family: Calibri, "Segoe UI", sans-serif; font-size: 14.67px; /* 11pt */
  line-height: 1.25; color: #000;
}
.page.landscape { width: 1056px; min-height: 816px; }
.page.a4 { width: 794px; min-height: 1123px; }
.page.a4.landscape { width: 1123px; min-height: 794px; }

/* document content */
.page .p { margin: 0 0 10.7px; white-space: pre-wrap; word-wrap: break-word; min-height: 1em; }
.page .s-Title { font-family: "Calibri Light", Calibri, sans-serif; font-size: 37.3px; line-height: 1.1; margin-bottom: 5px; color: #000; }
.page .s-Heading1 { font-family: "Calibri Light", Calibri, sans-serif; font-size: 21.3px; color: #2F5496; margin: 16px 0 5px; }
.page .s-Heading2 { font-family: "Calibri Light", Calibri, sans-serif; font-size: 17.3px; color: #2F5496; margin: 13px 0 5px; }
.page .s-Heading3 { font-family: "Calibri Light", Calibri, sans-serif; font-size: 16px; color: #1F3763; margin: 11px 0 5px; }
.page .s-Quote { font-style: italic; color: #595959; margin: 11px 43px; }
.page ul, .page ol { margin: 0 0 10.7px; padding-left: 48px; }
.page ul ul, .page ol ol, .page ul ol, .page ol ul { margin-bottom: 0; }
.page li { white-space: pre-wrap; }
.page a { color: #0563C1; text-decoration: underline; }
.page table.doctbl { border-collapse: collapse; margin: 0 0 10.7px; width: 100%; table-layout: fixed; }
.page table.doctbl td, .page table.doctbl th {
  border: 1px solid #666; padding: 2px 8px; vertical-align: top; word-wrap: break-word;
}
.page table.doctbl .p:last-child { margin-bottom: 0; }
.page .imgblock { margin: 0 0 10.7px; text-align: center; }
.page .imgblock img { max-width: 100%; height: auto; }
.page .pagebreak {
  border: 0; border-top: 1.5px dashed #B5B5B5; margin: 22px -40px; position: relative; text-align: center;
}
.page .pagebreak::after {
  content: "Page break"; position: relative; top: -10px; background: #fff; color: #949494;
  font-size: 10.5px; font-family: "Segoe UI", sans-serif; padding: 0 10px;
}

/* ---------- Chat panel ---------- */
.chat {
  width: 372px; flex: none; background: var(--chat-bg); border-left: 1px solid var(--line-2);
  display: flex; flex-direction: column; min-height: 0; position: relative;
}
.chat.hidden { display: none; }
.chat-resizer {
  position: absolute; left: -4px; top: 0; bottom: 0; width: 8px;
  cursor: col-resize; z-index: 30;
}
.chat-resizer:hover, body.resizing .chat-resizer { background: rgba(24,90,189,.28); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing .page { pointer-events: none; }
.chat-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.chat-title { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14.5px; color: var(--text); }
.spark { color: #7F5AF8; }
[data-theme="dark"] .spark { color: #a68bfc; }
.chat-model {
  margin-left: auto; max-width: 168px; height: 28px; border: 1px solid var(--line-2);
  border-radius: 4px; font-size: 12.5px; background: var(--bg); color: var(--text);
}
.chat-x { background: transparent; border: 0; cursor: pointer; color: var(--text-2); padding: 6px; border-radius: 4px; }
.chat-x:hover { background: var(--bg-2); }
.chat-auth {
  background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); font-size: 12.5px;
  padding: 9px 12px; display: flex; align-items: center; gap: 10px; color: var(--text);
}
.chat-auth button {
  margin-left: auto; background: var(--blue); border: 0; color: #fff; padding: 5px 12px;
  border-radius: 4px; font-size: 12.5px; font-weight: 600; cursor: pointer; flex: none;
}
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.chat-welcome { text-align: center; padding: 26px 10px 10px; color: var(--text-2); }
.chat-welcome h3 { margin: 10px 0 6px; font-size: 15.5px; color: var(--text); }
.chat-welcome p { font-size: 13px; margin: 0 0 14px; line-height: 1.5; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip {
  border: 1px solid var(--chip-line); background: var(--chip-bg); color: var(--chip-text); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; cursor: pointer; text-align: left; line-height: 1.4;
}
.chip:hover { filter: brightness(.97); }
[data-theme="dark"] .chip:hover { filter: brightness(1.15); }
.chat-tutorial-link { display: inline-block; margin-top: 14px; font-size: 12.5px; color: var(--accent-link); }
.msg { max-width: 92%; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg-user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-text); border: 1px solid var(--bubble-user-line); }
.msg-ai { align-self: flex-start; background: var(--bubble-ai); border: 1px solid var(--bubble-ai-line); color: var(--text); }
.msg-ai.thinking { color: var(--text-2); font-style: italic; }
.msg-err { align-self: flex-start; background: var(--danger-bg); border: 1px solid var(--danger-line); color: var(--danger); }
.msg-note { align-self: flex-start; font-size: 11.5px; color: var(--text-2); padding: 0 4px; }
.msg-note a { color: var(--accent-link); }
.msg-doc {
  align-self: flex-start; display: flex; gap: 7px; align-items: center;
  font-size: 12px; color: var(--blue-dark); background: var(--blue-soft-2); border: 1px solid var(--blue-soft);
  border-radius: 8px; padding: 6px 10px;
}
[data-theme="dark"] .msg-doc { color: #8fb3e8; }
.chat-foot { border-top: 1px solid var(--line); padding: 8px 12px 10px; }
.chat-scope {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text);
  background: var(--blue-soft-2); border: 1px solid var(--blue-soft); border-radius: 6px;
  padding: 5px 9px; margin-bottom: 7px;
}
.scope-check { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-weight: 600; }
.scope-check input { accent-color: var(--blue); }
.scope-info {
  color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.chat-meter { font-size: 11.5px; color: var(--text-2); min-height: 16px; padding: 0 2px 4px; }
.chat-meter .warn { color: var(--danger); font-weight: 600; }
.chat-meter a { color: var(--accent-link); }
.chat-inputrow { display: flex; gap: 8px; align-items: flex-end; }
.chat-inputrow textarea {
  flex: 1; resize: none; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px;
  font-family: inherit; font-size: 13.5px; line-height: 1.45; max-height: 130px; outline: none;
  background: var(--bg); color: var(--text);
}
.chat-inputrow textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.chat-inputrow button {
  width: 38px; height: 38px; border-radius: 8px; border: 0; background: var(--blue); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none;
}
.chat-inputrow button:hover { background: var(--blue-dark); }
.chat-inputrow button:disabled { background: var(--line-2); cursor: default; }
.chat-hint { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-2); padding: 6px 2px 0; }

/* ---------- Status bar ---------- */
.statusbar {
  height: 26px; background: var(--bg-2); color: var(--text); font-size: 12px;
  display: flex; align-items: center; gap: 18px; padding: 0 12px; flex: none;
  border-top: 1px solid var(--line);
}
.sb-spacer { flex: 1; }
.sb-note a, .sb-link { color: var(--accent-link); text-decoration: none; }
.sb-note a:hover, .sb-link:hover { text-decoration: underline; }
.sb-zoom {
  height: 20px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--bg);
  font-size: 11.5px; color: var(--text);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: #242424; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: var(--shadow); max-width: 70vw;
}
[data-theme="dark"] .toast { background: #3a3d40; }

@media (max-width: 1180px) {
  .chat { width: 320px; }
  .rsel-font { width: 104px; }
}

/* ---------- Print: just the document page ---------- */
@media print {
  body { overflow: visible; background: #fff; }
  .suitebar, .ribbon, .statusbar, .chat, .filemenu, .toast, .dropveil, .empty { display: none !important; }
  .main { display: block; }
  .canvas-wrap { overflow: visible; padding: 0; }
  .page, .page.a4, .page.landscape {
    width: auto; min-height: 0; margin: 0; box-shadow: none; zoom: 1 !important;
  }
  .page .pagebreak { border: 0; margin: 0; break-after: page; }
  .page .pagebreak::after { content: none; }
}
