/* Word++ THD — giao diện quen thuộc kiểu Word */
:root {
  --brand: #1a5aa6;
  --brand-dark: #123f7a;
  --brand-soft: #e8f0fb;
  --accent: #0e8f7e;
  --bg: #e9ebee;
  --panel: #ffffff;
  --ribbon: #f8f9fb;
  --line: #d9dde3;
  --line-2: #e7eaee;
  --text: #1f2328;
  --muted: #6a7380;
  --hover: #e6ecf5;
  --on: #cfdcf0;
  --ok: #138a52;
  --warn: #b7791f;
  --bad: #c0362c;
  --radius: 6px;
  --ui: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --doc: "Times New Roman", "Liberation Serif", "Noto Serif", serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--ui); font-size: 13.5px; color: var(--text); background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
code { background: #f1f3f5; padding: 1px 5px; border-radius: 4px; }

body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------- Đang tải ---------- */
#loading { position: fixed; inset: 0; background: #fff; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Thanh tiêu đề ---------- */
#titlebar { height: 40px; background: var(--brand); color: #fff; display: flex; align-items: center; padding: 0 8px; gap: 8px; flex-shrink: 0; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 2px; min-width: 200px; }
.tb-right { justify-content: flex-end; }
.tb-center { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; justify-content: center; gap: 6px; }
.logo { display: flex; margin-right: 6px; }
.logo img { border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.qa { background: transparent; border: 0; color: #fff; width: 32px; height: 32px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.qa:hover { background: rgba(255,255,255,.15); }
#doc-title { font-weight: 600; cursor: text; padding: 2px 6px; border-radius: 4px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
#doc-title:hover { background: rgba(255,255,255,.15); }
.tb-center .sep { opacity: .6; }
#app-name { opacity: .85; }
.save-state { font-size: 12px; opacity: .9; margin-left: 10px; display: inline-flex; align-items: center; gap: 4px; }
.save-state.error { color: #ffd1cc; font-weight: 600; }
#user-box { background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 16px; padding: 4px 12px; display: flex; gap: 8px; align-items: center; }
#user-box:hover { background: rgba(255,255,255,.22); }
#user-exp { font-size: 11.5px; opacity: .85; }

/* ---------- Thẻ (tab) ---------- */
#tabs { background: var(--brand); display: flex; padding: 0 6px; gap: 2px; flex-shrink: 0; overflow-x: auto; scrollbar-width: none; }
.tab { background: transparent; border: 0; color: #fff; padding: 7px 14px 8px; border-radius: 6px 6px 0 0; white-space: nowrap; font-size: 13px; opacity: .92; }
.tab:hover { background: rgba(255,255,255,.14); }
.tab.on { background: var(--ribbon); color: var(--brand-dark); font-weight: 600; opacity: 1; }
.tab.file { background: var(--brand-dark); font-weight: 600; margin-right: 4px; }
.tab.file:hover { background: #0c2f5c; }
.tab.accent:not(.on)::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #7fd3c6; margin-left: 6px; vertical-align: 2px; }

/* ---------- Ribbon ---------- */
#ribbon { background: var(--ribbon); border-bottom: 1px solid var(--line); display: flex; align-items: stretch; padding: 4px 6px 0; min-height: 96px; flex-shrink: 0; overflow-x: auto; overflow-y: hidden; }
.rb-group { display: flex; flex-direction: column; padding: 0 8px; border-right: 1px solid var(--line-2); flex-shrink: 0; }
.rb-items { flex: 1; display: flex; align-items: flex-start; gap: 2px; }
.rb-label { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0 4px; white-space: nowrap; }
.rb-col { display: flex; flex-direction: column; gap: 1px; }
.rb-row { display: flex; align-items: center; gap: 1px; margin-bottom: 3px; }
.rb-big { background: transparent; border: 1px solid transparent; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 6px 4px; min-width: 52px; max-width: 86px; color: var(--text); }
.rb-big span { font-size: 11.5px; line-height: 1.2; text-align: center; }
.rb-big svg { color: var(--brand-dark); }
.rb-btn { background: transparent; border: 1px solid transparent; border-radius: 4px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 5px; min-height: 26px; color: var(--text); white-space: nowrap; }
.rb-btn span { font-size: 12.5px; }
.rb-big:hover, .rb-btn:hover { background: var(--hover); border-color: #c9d6ea; }
.rb-big.on, .rb-btn.on, .rb-btn.active { background: var(--on); border-color: #9fb8de; }
.rb-sel select, .rb-input { height: 26px; border: 1px solid #c4cad3; border-radius: 4px; background: #fff; padding: 0 4px; width: 100%; font-size: 12.5px; }
.rb-sel { margin-right: 3px; }
#ribbon select, #ribbon input { padding-top: 0 !important; padding-bottom: 0 !important; }
.rb-note { font-size: 11.5px; color: var(--muted); padding: 6px 2px; max-width: 130px; }
.color-btn.hl svg { border-bottom: 3px solid #ffe600; }
.color-btn.fc svg { border-bottom: 3px solid #c00000; }
.styles-gallery { display: flex; gap: 3px; padding-top: 2px; }
.style-tile { width: 70px; height: 58px; border: 1px solid var(--line); background: #fff; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.style-tile:hover { border-color: #8fb0dd; }
.style-tile.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.style-tile span { font-family: var(--doc); font-size: 15px; }
.style-tile small { font-size: 10.5px; color: var(--muted); }
.st-h1 span { font-weight: 700; font-size: 17px; color: var(--brand-dark); }
.st-h2 span { font-weight: 700; color: var(--brand-dark); }
.st-h3 span { font-style: italic; font-weight: 700; }
.st-q span { font-style: italic; color: #555; }
.lang-pick { display: grid; gap: 3px; padding-top: 2px; }
.lang-pick label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.lang-pick label span { width: 40px; color: var(--muted); }
.lang-pick select { height: 25px; border: 1px solid #c4cad3; border-radius: 4px; width: 210px; background: #fff; font-size: 12.5px; }
.lang-pick .dim { opacity: .5; }
.rb-engine { font-size: 11.5px; display: grid; gap: 3px; padding: 4px 2px; min-width: 150px; }
.eng-row { display: flex; align-items: center; gap: 6px; }

/* ---------- Thông báo trên cùng ---------- */
.banner { padding: 7px 14px; display: flex; align-items: center; gap: 10px; font-size: 13px; flex-shrink: 0; }
.banner.warn { background: #fff6e0; color: #6b4b00; border-bottom: 1px solid #f0d58c; }
.banner.bad { background: #fde8e6; color: #7a1e16; border-bottom: 1px solid #f2b5ae; }

/* ---------- Vùng làm việc ---------- */
#workspace { flex: 1; display: flex; min-height: 0; }
#canvas { flex: 1; overflow: auto; position: relative; padding: 18px 24px 60px; }
#page-wrap { display: flex; justify-content: center; min-width: min-content; }
#page { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 6px 18px rgba(0,0,0,.06); position: relative; padding: var(--mt) var(--mr) var(--mb) var(--ml); margin: 0 auto; transition: width .2s; }
#page-header, #page-footer { position: absolute; left: var(--ml); right: var(--mr); font-family: var(--doc); font-size: 11pt; color: #9aa1aa; text-align: center; pointer-events: none; }
#page-header { top: calc(var(--mt) / 2 - 8px); }
#page-footer { bottom: calc(var(--mb) / 2 - 8px); }
#page-marks { position: absolute; inset: 0; pointer-events: none; }
.pg-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #b9c3d0; }
.pg-line span { position: absolute; right: 6px; top: -9px; background: #fff; color: #8a95a3; font-size: 10.5px; padding: 0 4px; }
.pg-num { position: absolute; height: 18px; line-height: 18px; font: 11pt/18px var(--doc); color: #6b7684; white-space: nowrap; pointer-events: none; }
.pg-num.c { left: 50%; transform: translateX(-50%); }
.pg-num.l { left: var(--ml); }
.pg-num.r { right: var(--mr); }
/* số trang ở các ranh giới giữa hai trang: đặt ngay bên ngoài mép tờ giấy (không đè lên chữ); ở trang đầu/trang cuối đặt đúng vị trí trong lề */
.pg-num:not(.edge) { font-size: 10pt; transform: none; left: 100%; right: auto; margin-left: 8px; }
.pg-num.l:not(.edge) { left: auto; right: 100%; margin-left: 0; margin-right: 8px; }
@media (max-width: 900px) { .pg-num:not(.edge) { left: auto !important; right: 4px !important; margin: 0 !important; background: #fff; padding: 0 6px; border-radius: 9px; box-shadow: 0 0 0 1px #dde3ea; } }
#ruler { position: sticky; top: -18px; z-index: 5; display: flex; justify-content: center; margin: -18px -24px 12px; background: var(--bg); }
.ruler-in { height: 20px; background: #fff; position: relative; border-bottom: 1px solid var(--line); font-size: 9.5px; color: var(--muted); }
.r-margin { position: absolute; top: 0; bottom: 0; left: 0; background: #dfe4ea; }
.r-margin.right { left: auto; right: 0; }
.rt { position: absolute; top: 4px; transform: translateX(-50%); }
.rt::after { content: ""; position: absolute; left: 50%; top: 12px; height: 4px; border-left: 1px solid #999; }

/* ---------- Nội dung văn bản ---------- */
.ProseMirror { font-family: var(--doc); font-size: 14pt; line-height: 1.15; outline: none; min-height: 200px; position: relative; color: #000; word-wrap: break-word; white-space: pre-wrap; tab-size: 4; }
.ProseMirror p { margin: 0 0 6pt; }
.ProseMirror h1 { font-size: 16pt; font-weight: 700; margin: 12pt 0 6pt; }
.ProseMirror h2 { font-size: 14pt; font-weight: 700; margin: 10pt 0 6pt; }
.ProseMirror h3 { font-size: 14pt; font-weight: 700; font-style: italic; margin: 8pt 0 6pt; }
.ProseMirror h4 { font-size: 14pt; font-style: italic; margin: 6pt 0; }
.ProseMirror ul, .ProseMirror ol { margin: 0 0 6pt; padding-left: 1.27cm; }
.ProseMirror li p { margin: 0 0 3pt; }
.ProseMirror blockquote { margin: 6pt 0 6pt 1cm; padding-left: 10px; border-left: 3px solid #c7cfda; color: #333; font-style: italic; }
.ProseMirror hr { border: 0; border-top: 1px solid #000; margin: 10pt 0; }
.ProseMirror a { color: #0b57d0; text-decoration: underline; }
.ProseMirror mark { padding: 0 1px; }
.ProseMirror img { max-width: 100%; height: auto; display: block; }
.ProseMirror img[data-align="center"] { margin: 0 auto; }
.ProseMirror img[data-align="right"] { margin-left: auto; }
.ProseMirror img.ProseMirror-selectednode { outline: 2px solid var(--brand); }
.ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: #a0a7b1; float: left; height: 0; pointer-events: none; }
.ProseMirror table { border-collapse: collapse; width: 100%; margin: 4pt 0 8pt; table-layout: fixed; }
.ProseMirror td, .ProseMirror th { border: 1px solid #000; padding: 2pt 5pt; vertical-align: top; position: relative; }
.ProseMirror th { background: #f2f4f7; font-weight: 700; }
.ProseMirror td p, .ProseMirror th p { margin: 0; }
.ProseMirror table.no-border td, .ProseMirror table.no-border th { border: 1px dashed #d9dde3; }
.ProseMirror .selectedCell::after { content: ""; position: absolute; inset: 0; background: rgba(26,90,166,.14); pointer-events: none; }
.ProseMirror .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: 0; width: 4px; background: #7aa7e0; pointer-events: none; }
.ProseMirror.resize-cursor { cursor: col-resize; }
.ProseMirror td[data-formula]::before { content: "ƒ"; position: absolute; left: 1px; top: -1px; font-size: 9px; color: var(--accent); font-family: var(--ui); }
.tableWrapper { overflow-x: auto; }
.page-break { position: relative; height: 16px; margin: 0 calc(-1 * var(--mr)) 0 calc(-1 * var(--ml)); }
.page-break::after { content: "Ngắt trang"; position: absolute; left: 0; right: 0; bottom: 0; border-bottom: 2px dotted #9fb0c5; color: #8a95a3; font: 10.5px var(--ui); text-align: center; line-height: 16px; }
.page-break.ProseMirror-selectednode::after { border-color: var(--brand); color: var(--brand); }
.comment-mark { background: #fff2b3; border-bottom: 2px solid #f0c419; }
.find-hit { background: #fff07a; }
.find-hit.current { background: #ff9e3d; }
.read-hl { background: #cfe7ff; }
body.show-marks .ProseMirror p::after, body.show-marks .ProseMirror h1::after, body.show-marks .ProseMirror h2::after, body.show-marks .ProseMirror h3::after { content: "¶"; color: #9fb0c5; margin-left: 2px; }
body.painter-on .ProseMirror { cursor: copy; }
.toc { border: 1px dashed #c3ccd8; padding: 6px 10px; margin: 6pt 0; user-select: none; }
.toc-title { text-align: center; font-weight: 700; margin-bottom: 4pt; }
.toc-row { display: flex; align-items: baseline; gap: 4px; cursor: pointer; }
.toc-row:hover .toc-text { color: var(--brand); }
.toc-row.l2 { padding-left: 0.75cm; } .toc-row.l3 { padding-left: 1.5cm; }
.toc-dots { flex: 1; border-bottom: 1px dotted #666; transform: translateY(-4px); }
.toc-empty { color: var(--muted); font-family: var(--ui); font-size: 12px; text-align: center; }

/* ---------- Song ngữ ---------- */
.bi-line { font-family: var(--doc); color: #3b5d86; font-size: 0.82em; line-height: 1.3; margin: -3pt 0 7pt; user-select: none; cursor: default; white-space: normal; text-indent: 0; font-weight: 400; font-style: normal; text-align: left; }
.bi-inter { padding-left: 2px; border-left: 2px solid #dbe6f5; padding-left: 8px; }
li .bi-line, td .bi-line { margin-top: 0; }
.bi-lang + .bi-lang { margin-top: 2px; }
.bi-tag { display: inline-block; font: 600 9.5px var(--ui); color: #fff; background: #7f97b8; border-radius: 3px; padding: 0 4px; margin-right: 5px; vertical-align: 1px; }
.bi-s { cursor: pointer; border-radius: 3px; transition: background .1s; }
.bi-s:hover { background: #e3edfa; }
.bi-s.st-approved { color: #22507f; }
.bi-s.st-edited { color: #22507f; text-decoration: underline dotted #6a8fbd; }
.bi-s.st-approved::after { content: "✓"; font-size: 9px; color: var(--ok); vertical-align: super; margin-left: 1px; }
.bi-s.pending { color: #a3b1c2; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.bi-s.outdated { background: #fff4d1; color: #7a5a00; }
.bi-s.outdated::before { content: "●"; color: #e3a008; font-size: 9px; margin-right: 3px; vertical-align: 1px; }
.bi-s.warn { text-decoration: underline wavy #d6453a; text-underline-offset: 3px; }
.bi-s.unsup, .bi-s.err { color: #b04d43; font-style: italic; }
.bi-s.rev { color: #5f6b7a; font-style: italic; }
.bi-s.reading { background: #cfe7ff; }
#page.cols .ProseMirror { width: calc(50% - 12px); }
#page.cols .bi-col { position: absolute; left: calc(100% + 24px); width: 100%; margin: 0; font-size: 0.92em; color: #24456d; border-left: 2px solid #dbe6f5; padding-left: 10px; }
#page.cols::before { content: ""; position: absolute; top: var(--mt); bottom: var(--mb); left: 50%; border-left: 1px solid #edf0f4; }
.hover-tip { position: fixed; z-index: 60; background: #fff; border: 1px solid #c9d6ea; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 8px 12px; max-width: 620px; font-size: 15px; margin: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aa5b2; vertical-align: 1px; }
.dot.approved { background: var(--ok); } .dot.edited { background: #3d7bd6; } .dot.auto { background: #9aa5b2; } .dot.outdated { background: #e3a008; } .dot.off { background: #c9ced6; }

/* ---------- Ngăn bên ---------- */
#nav, #side { width: 280px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
#side { border-right: 0; border-left: 1px solid var(--line); width: 320px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.side-body, .nav-list { overflow: auto; padding: 10px; flex: 1; }
.nav-it { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 5px 8px; border-radius: 4px; font-size: 13px; }
.nav-it:hover { background: var(--hover); }
.nav-it.l1 { font-weight: 600; } .nav-it.l2 { padding-left: 20px; } .nav-it.l3 { padding-left: 32px; font-size: 12.5px; }
.cmt { border: 1px solid var(--line); border-left: 3px solid #f0c419; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; background: #fffdf3; }
.cmt.resolved { opacity: .55; border-left-color: #9aa5b2; background: #fafafa; }
.cmt-head { display: flex; justify-content: space-between; gap: 8px; }
.cmt-quote { font-size: 12px; color: var(--muted); margin: 4px 0; font-style: italic; }
.cmt-reply { font-size: 12.5px; border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 4px; }
.cmt-acts { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- Thanh trạng thái ---------- */
#statusbar { height: 26px; background: #f3f4f6; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 12px; font-size: 12px; color: #444; flex-shrink: 0; }
.st-btn { background: transparent; border: 0; padding: 2px 6px; border-radius: 4px; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.st-btn:hover { background: var(--hover); }
.zoom { display: flex; align-items: center; gap: 4px; }
.zoom input { width: 110px; }
#zoom-val { width: 40px; text-align: right; }

/* ---------- Nút, ô nhập chung ---------- */
.btn { background: #fff; border: 1px solid #c4cad3; border-radius: var(--radius); padding: 6px 14px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.btn:hover { background: #f3f6fa; border-color: #a9b4c2; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #e7b3ad; }
.btn.danger:hover { background: #fdeeec; }
.btn.sm { padding: 3px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: transparent; border: 0; border-radius: 4px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.link-btn { background: none; border: 0; color: var(--brand); padding: 0; font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { border: 1px solid #c4cad3; border-radius: var(--radius); padding: 6px 9px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9cff0; border-color: var(--brand); }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; margin: 0; }
.chk, .radio { display: flex; align-items: center; gap: 7px; margin: 6px 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 10px; }
.chip { display: inline-block; background: var(--brand-soft); color: var(--brand-dark); border: 0; border-radius: 12px; padding: 2px 10px; margin: 2px; font-size: 12.5px; }
button.chip:hover { background: var(--on); }
.badge { display: inline-block; border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
.badge.ok { background: #e2f5ea; color: var(--ok); } .badge.bad { background: #fde8e6; color: var(--bad); } .badge.warn { background: #fff4d1; color: #8a6200; }
.ok-box { background: #e9f7ef; border: 1px solid #b9e3c9; color: #0f5a37; padding: 10px 12px; border-radius: 6px; }
.warn-box { background: #fff6e0; border: 1px solid #f0d58c; color: #6b4b00; padding: 10px 12px; border-radius: 6px; }
.kbd { font-size: 11px; color: var(--muted); margin-left: auto; }
table.kv { border-collapse: collapse; margin-bottom: 12px; }
table.kv td { padding: 5px 14px 5px 0; vertical-align: top; }
table.kv td:first-child { color: var(--muted); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-weight: 600; background: #f3f5f8; padding: 7px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
table.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.scroll { overflow: auto; }

/* ---------- Hộp thoại ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow: auto; }
.modal { background: #fff; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; max-height: 88vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.modal-title { font-weight: 600; font-size: 15px; }
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line-2); }
#toasts { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #1f2933; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: min(620px, 92vw); font-size: 13px; transition: opacity .3s, transform .3s; }
.toast.ok { background: #13643e; } .toast.warn { background: #8a5a00; } .toast.err { background: #a8291f; }
.toast.out { opacity: 0; transform: translateY(6px); }
.popover { position: fixed; z-index: 300; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.16); padding: 8px; max-width: min(460px, 94vw); }
.menu-pop { padding: 4px; min-width: 210px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 6px 10px; border-radius: 5px; text-align: left; font-size: 13px; }
.menu-item:hover:not(:disabled) { background: var(--hover); }
.menu-item:disabled { opacity: .45; }
.mi-ic { width: 16px; display: inline-flex; color: var(--brand-dark); }
.mi-hint { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.menu-sep { height: 1px; background: var(--line-2); margin: 4px 2px; }
.color-grid { display: grid; grid-template-columns: repeat(7, 24px); gap: 4px; }
.color-grid .sw { width: 24px; height: 24px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); }
.color-grid .sw:hover { transform: scale(1.12); }
.color-grid .sw-none, .color-grid .sw-custom { grid-column: span 7; font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.sym-grid { display: grid; grid-template-columns: repeat(10, 30px); gap: 3px; }
.sym { height: 30px; border: 1px solid var(--line-2); background: #fff; border-radius: 4px; font-size: 16px; font-family: var(--doc); }
.sym:hover { background: var(--hover); }
.tbl-pick { width: 254px; }
.tp-grid { display: grid; grid-template-columns: repeat(10, 22px); gap: 3px; }
.tp-cell { width: 22px; height: 18px; border: 1px solid #c4cad3; background: #fff; }
.tp-cell.on { background: #cfe0f6; border-color: var(--brand); }
.tp-label { margin: 6px 0; text-align: center; }

/* ---------- Thẻ câu, thẻ từ điển, dịch đoạn chọn ---------- */
.sent-pop { width: 420px; }
.sm-src { font-family: var(--doc); font-size: 15px; color: #333; padding-bottom: 6px; border-bottom: 1px solid var(--line-2); }
.sm-tgt { font-family: var(--doc); font-size: 16px; color: #173d6b; padding: 8px 0; }
.sm-warn { background: #fdeceb; color: #8b241c; border-radius: 5px; padding: 5px 8px; margin: 4px 0; font-size: 12.5px; }
.sm-status { font-size: 12px; color: var(--muted); margin: 4px 0 8px; display: flex; align-items: center; gap: 6px; }
.sm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.sm-btn { display: flex; align-items: center; gap: 7px; background: #f6f8fb; border: 1px solid transparent; border-radius: 5px; padding: 6px 8px; font-size: 12.5px; text-align: left; }
.sm-btn:hover:not(:disabled) { background: var(--hover); border-color: #c9d6ea; }
.sm-btn:disabled { opacity: .45; }
.sm-btn svg { color: var(--brand-dark); flex-shrink: 0; }
.sm-edit .row { gap: 6px; margin-top: 6px; }
.sm-back, .sm-alt { background: #f3f6fa; border-radius: 5px; padding: 6px 8px; margin: 6px 0; font-size: 13px; }
.sm-alt-t { font-family: var(--doc); font-size: 15px; margin-bottom: 6px; }
.dict-pop { width: 400px; max-height: 70vh; overflow: auto; }
.dc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.dc-word { font-family: var(--doc); font-size: 22px; font-weight: 700; color: #173d6b; }
.dc-sub { font-size: 12px; color: var(--muted); }
.dc-quick { margin: 8px 0; padding: 7px 9px; background: var(--brand-soft); border-radius: 6px; }
.dc-q-label { color: var(--muted); font-size: 12px; }
.dc-sec { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 10px 0 4px; }
.dc-pos { font-style: italic; color: var(--accent); font-size: 12.5px; margin-top: 4px; }
.dc-entry ol { margin: 2px 0 6px; padding-left: 20px; }
.dc-entry li { margin-bottom: 4px; }
.dc-entry .g .orig { color: var(--muted); font-size: 11.5px; }
.dc-entry .ex { color: #4c5866; font-style: italic; font-size: 12.5px; }
.dc-ex { padding: 4px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.dc-ctx-src mark { background: #fff07a; }
.dc-ctx-t { font-size: 13px; margin-top: 2px; }
.dc-foot { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.sel-bubble { position: fixed; z-index: 150; display: flex; background: #1f2933; border-radius: 8px; padding: 3px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.sel-bubble button { background: transparent; border: 0; color: #fff; padding: 5px 9px; border-radius: 5px; display: flex; align-items: center; gap: 5px; font-size: 12.5px; }
.sel-bubble button:hover { background: rgba(255,255,255,.14); }
.tr-popover { width: 440px; }
.tr-out { font-family: var(--doc); font-size: 15px; background: #f6f8fb; border-radius: 6px; padding: 8px 10px; margin: 8px 0; white-space: pre-wrap; max-height: 300px; overflow: auto; }
.dictation-tip { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 6px 16px; box-shadow: 0 6px 18px rgba(0,0,0,.12); z-index: 150; }

/* ---------- Bảng tìm kiếm nổi ---------- */
.float-panel { position: fixed; top: 160px; right: 24px; z-index: 120; width: 330px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 10px 12px; }
.fp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.fp-head .fp-x { margin-left: auto; }
.fp-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.fp-row input:not([type=checkbox]) { flex: 1; }
.fp-btns { flex-wrap: wrap; }

/* ---------- Tệp (backstage) ---------- */
#backstage { position: fixed; inset: 0; z-index: 180; display: flex; background: #fff; }
.bs-nav { width: 230px; background: var(--brand); color: #fff; display: flex; flex-direction: column; padding: 8px 0; overflow: auto; }
.bs-nav button { background: transparent; border: 0; color: #fff; text-align: left; padding: 10px 20px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.bs-nav button:hover { background: rgba(255,255,255,.12); }
.bs-nav button.on { background: rgba(255,255,255,.22); font-weight: 600; }
.bs-nav .kbd { color: rgba(255,255,255,.7); }
.bs-back { margin-bottom: 8px; }
.bs-sep { height: 1px; background: rgba(255,255,255,.2); margin: 6px 16px; }
.bs-main { flex: 1; overflow: auto; padding: 28px 40px; }
.bs-main h2 { font-weight: 600; margin: 0 0 16px; font-size: 24px; color: var(--brand-dark); }
.bs-main h3 { font-weight: 600; margin: 22px 0 10px; font-size: 15px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tpl { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.tpl:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(26,90,166,.12); }
.tpl-thumb { height: 120px; border: 1px solid var(--line-2); border-radius: 4px; background: repeating-linear-gradient(#fff 0 12px, #f1f3f6 12px 13px); display: flex; align-items: center; justify-content: center; color: var(--brand); }
.doc-list { margin-top: 10px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 6px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.doc-row:hover { background: var(--hover); }
.doc-row.cur { background: var(--brand-soft); }
.dr-ic { color: var(--brand); }
.dr-main { flex: 1; min-width: 0; }
.dr-title { font-weight: 600; }
.dr-snip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-meta { text-align: right; white-space: nowrap; }
.exp-opts { margin-bottom: 18px; }
.exp-btns { display: flex; gap: 14px; flex-wrap: wrap; }
.big-btn { width: 210px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; }
.big-btn:hover { border-color: var(--brand); background: var(--brand-soft); }
.big-btn svg { color: var(--brand); }
.big-btn span { color: var(--muted); font-size: 12.5px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.plan { border: 2px solid var(--line); border-radius: 10px; background: #fff; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.plan:hover { border-color: #93b4e0; }
.plan.on { border-color: var(--brand); background: var(--brand-soft); }
.plan .price { font-size: 20px; font-weight: 700; color: var(--brand-dark); }
.qr-wrap { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.qr-wrap img { border: 1px solid var(--line); border-radius: 8px; }
.qr-info { display: grid; gap: 6px; flex: 1; min-width: 200px; }
.qr-info .code { font-size: 16px; color: var(--bad); letter-spacing: .05em; }

/* ---------- Màn hình phủ (sổ văn bản, từ vựng) ---------- */
.overlay { position: fixed; inset: 0; z-index: 170; background: #fff; display: flex; flex-direction: column; }
.ov-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--ribbon); }
.ov-head > b { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--brand-dark); margin-right: 10px; }
.ov-head .ov-x { margin-left: auto; }
.ov-body { flex: 1; overflow: auto; padding: 0 16px 20px; }
.seg { display: inline-flex; border: 1px solid #c4cad3; border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; }
.seg button.on { background: var(--brand); color: #fff; }
table.reg td.ty { max-width: 420px; }
table.reg tr.late td { background: #fff4f2; }
table.reg tbody tr:hover td { background: var(--hover); cursor: pointer; }
.reg-sum { padding: 8px 0; }
.vocab-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; padding-top: 14px; }
.voc { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.voc-w { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.voc-m { margin: 4px 0; }
.voc-f { display: flex; justify-content: space-between; margin-top: 6px; }
.flash { text-align: center; padding: 10px 0; }
.fl-word { font-family: var(--doc); font-size: 32px; font-weight: 700; color: var(--brand-dark); margin: 10px 0; }
.fl-sent { margin-bottom: 10px; }
.fl-ans { font-size: 17px; margin: 12px 0; padding: 10px; background: var(--brand-soft); border-radius: 8px; }
.issues { padding-left: 18px; }
.issues li { margin-bottom: 6px; }
.issues li.bad { color: #8b241c; }
.issues li.note { color: #6b4b00; }
.q-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.q-stats span { background: #f3f5f8; border-radius: 6px; padding: 6px 10px; }
.q-stats span.bad { background: #fde8e6; color: #8b241c; }
.steps { padding-left: 18px; }
.steps li { margin-bottom: 10px; }
.fields { margin-top: 6px; }
.preview-doc { font-family: var(--doc); font-size: 14pt; border: 1px solid var(--line); padding: 20px 28px; max-height: 64vh; overflow: auto; }
.preview-doc table { border-collapse: collapse; width: 100%; }
.preview-doc td { vertical-align: top; }
.diff-view { font-family: var(--doc); font-size: 15px; line-height: 1.5; max-height: 64vh; overflow: auto; border: 1px solid var(--line); padding: 14px; white-space: normal; }
ins { background: #d6f5df; color: #0b5a2c; text-decoration: none; }
del { background: #fbdcd9; color: #8b241c; }
.ver { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.ver-acts { display: flex; gap: 6px; }

/* ---------- Chế độ đọc tập trung ---------- */
body.focus-mode #titlebar, body.focus-mode #tabs, body.focus-mode #ribbon, body.focus-mode #statusbar, body.focus-mode #banner { display: none !important; }
body.focus-mode #canvas { background: #f6f3ec; }
body.focus-mode .ProseMirror { font-size: 16pt; line-height: 1.6; }

/* ---------- Màn hình nhỏ (điện thoại) ---------- */
@media (max-width: 820px) {
  .tb-left { min-width: 0; } .tb-right { min-width: 0; }
  #app-name, .tb-center .sep, #user-exp { display: none; }
  #ribbon { min-height: 84px; }
  #canvas { padding: 8px 4px 40px; }
  #page { padding: 14mm 10mm; width: 100% !important; }
  #page.cols .ProseMirror { width: 100%; }
  #page.cols .bi-col { position: static; width: auto; border: 0; padding: 0; }
  .zoom input { width: 70px; }
  #st-engine { display: none; }
  .bs-nav { width: 64px; }
  .bs-nav button { font-size: 0; padding: 12px; justify-content: center; }
  .bs-nav button svg { width: 22px; height: 22px; }
  .bs-main { padding: 18px; }
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .sent-pop, .dict-pop, .tr-popover { width: 94vw; }
}
@media print { body * { visibility: hidden; } }
@media (max-width: 520px) { #st-words, #st-engine { display: none; } #statusbar { gap: 8px; } .zoom input { width: 56px; } }
