/* Markdown Studio — estilos. */
:root {
  color-scheme: light dark;
  --bg: #f3f6fb; --panel: #ffffff; --text: #182033; --muted: #62708a;
  --line: #d8dfeb; --accent: #265de8; --accent-soft: #eaf0ff; --code: #f4f6fa;
  --shadow: 0 10px 30px rgba(31, 50, 84, .08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11151d; --panel: #191f2b; --text: #e7ecf7; --muted: #a5b1c7;
    --line: #303a4e; --accent: #87a7ff; --accent-soft: #243252; --code: #10151f;
    --shadow: 0 10px 30px rgba(0, 0, 0, .24); }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
header { padding: 26px max(20px, calc((100vw - 1440px) / 2)); background: var(--panel);
  border-bottom: 1px solid var(--line); }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 6px; }
.subtitle { margin: 0; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
button, input { font: inherit; }
button { border: 1px solid var(--line); color: var(--text); background: var(--panel); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: white; border-color: var(--accent); font-weight: 650; }
button:disabled { cursor: default; opacity: .55; }
#file-search, #document-search { min-width: 190px; max-width: 330px; padding: 8px 10px; border: 1px solid var(--line);
  color: var(--text); background: var(--bg); border-radius: 8px; }
#folder-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: none; min-height: calc(100vh - 156px); margin: 0 auto; padding: 22px 20px; }
#drop-zone { margin-bottom: 18px; border: 2px dashed var(--line); border-radius: 12px; padding: 16px 18px;
  color: var(--muted); text-align: center; transition: .15s ease; }
#drop-zone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.layout { display: grid; grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); gap: 18px; }
.files, .reader { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.files { min-height: 600px; overflow: hidden; }
.files-head { padding: 15px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.files-head strong { font-size: 14px; }
#file-count { color: var(--muted); font-size: 13px; }
#file-list { max-height: calc(100vh - 285px); min-height: 250px; overflow: auto; padding: 7px; }
.file-entry { display: block; width: 100%; margin: 0; padding: 9px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text); text-align: left; overflow-wrap: anywhere; }
.file-entry:hover, .file-entry.active { background: var(--accent-soft); color: var(--text); }
.file-entry .path { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.empty-list { color: var(--muted); padding: 15px 10px; font-size: 14px; }
.reader { min-width: 0; min-height: calc(100vh - 255px); overflow: hidden; }
.reader-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); }
#document-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#document-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.reader-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#search-count { min-width: 76px; color: var(--muted); font-size: 13px; text-align: center; }
#copy, #previous-hit, #next-hit, #fullscreen { flex: 0 0 auto; }
#viewer { height: calc(100vh - 330px); min-height: 600px; padding: clamp(20px, 4vw, 52px); overflow: auto; }
.placeholder { max-width: 600px; margin: 90px auto; text-align: center; color: var(--muted); }
.placeholder strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }
.markdown { max-width: 1000px; margin: 0 auto; overflow-wrap: anywhere; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { color: var(--text); line-height: 1.25; margin: 1.6em 0 .55em; }
.markdown h1 { font-size: 2em; border-bottom: 1px solid var(--line); padding-bottom: .3em; margin-top: 0; }
.markdown h2 { font-size: 1.55em; border-bottom: 1px solid var(--line); padding-bottom: .25em; }
.markdown h3 { font-size: 1.25em; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote { margin: .8em 0; }
.markdown li + li { margin-top: .25em; }
.markdown a { color: var(--accent); }
.markdown blockquote { margin-left: 0; padding: .1em 1em; border-left: 4px solid var(--accent); color: var(--muted); }
.markdown code { padding: .16em .35em; border-radius: 5px; background: var(--code); font: .88em ui-monospace, SFMono-Regular, Consolas, monospace; }
.markdown pre { overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--code); }
.markdown pre code { padding: 0; background: transparent; }
.markdown .table-wrap { max-width: 100%; margin: 1em 0; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.markdown table { width: max-content; min-width: 100%; border-collapse: collapse; margin: 0; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.markdown th { background: var(--code); }
.markdown img { max-width: 100%; height: auto; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 1.7em 0; }
mark.term-hit { background: #ffe168; color: #202020; border-radius: 2px; padding: 0 1px; }
mark.term-hit.current { background: #ff9d2e; outline: 2px solid #d56d00; }
.reader:fullscreen { width: 100vw; height: 100vh; border: 0; border-radius: 0; background: var(--panel); }
.reader:fullscreen #viewer { height: calc(100vh - 76px); max-width: 1800px; margin: 0 auto; }
.notice { margin: 0 0 15px; padding: 9px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--muted); font-size: 13px; }
.hidden { display: none; }
@media (max-width: 760px) {
  header { padding: 20px; } main { padding: 14px; }
  .layout { grid-template-columns: 1fr; }
  .files { min-height: auto; } #file-list { max-height: 220px; min-height: 100px; }
  #viewer { min-height: 440px; padding: 24px 18px; }
}
/* Camada visual do Markdown Studio */
:root { --bg: #f6f7fb; --panel: #ffffff; --text: #1b2333; --muted: #69758b; --line: #e2e6ef;
  --accent: #3457d5; --accent-soft: #eef2ff; --code: #f7f8fc; --shadow: 0 14px 38px rgba(22, 35, 62, .07); }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --bg: #10131a; --panel: #171c26; --text: #eaf0fb; --muted: #9aa7bc;
  --line: #293243; --accent: #91aaff; --accent-soft: #222f4f; --code: #111722; --shadow: 0 18px 40px rgba(0, 0, 0, .25); }
body { background: radial-gradient(circle at 3% 0%, rgba(90, 115, 215, .11), transparent 25rem), var(--bg); letter-spacing: .002em; }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; padding: 14px clamp(16px, 3vw, 44px); background: color-mix(in srgb, var(--panel) 91%, transparent);
  backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.topbar-main, .commandbar { max-width: 1800px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand, .topbar-actions, .commandbar, .command-group, .reader-actions, .search-box { display: flex; align-items: center; }
.brand { gap: 11px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #4168ee, #263da1); border-radius: 11px; box-shadow: 0 6px 16px rgba(44, 76, 190, .27); }
.brand-mark svg { width: 22px; height: 22px; }
.product-tag { display: block; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .12em; line-height: 1; }
.topbar h1 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.025em; }
.topbar-actions { gap: 10px; }
.status-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2fac70; box-shadow: 0 0 0 3px color-mix(in srgb, #2fac70 16%, transparent); }
.status-chip[data-state="busy"] .status-dot { background: #d99019; box-shadow: 0 0 0 3px color-mix(in srgb, #d99019 18%, transparent); animation: pulse-status 1.2s ease-in-out infinite; }
.status-chip[data-state="error"] .status-dot { background: #d14b5a; box-shadow: 0 0 0 3px color-mix(in srgb, #d14b5a 16%, transparent); }
@keyframes pulse-status { 50% { opacity: .42; transform: scale(.8); } }
.icon-button, .mini-button { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.icon-button svg, .button-icon, .drop-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.commandbar { justify-content: flex-start; margin-top: 13px; flex-wrap: wrap; }
.command-group { gap: 8px; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 35px; padding: 7px 11px; border-radius: 8px; font-size: 13px; font-weight: 650; transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
button:hover:not(:disabled) { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 52%, var(--line)); box-shadow: 0 3px 10px rgba(40, 56, 94, .08); }
button.primary { background: linear-gradient(135deg, #4169e8, #304bc0); box-shadow: 0 5px 13px rgba(47, 75, 192, .2); }
.search-box { flex: 1 1 215px; max-width: 340px; gap: 7px; padding: 0 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent); }
#file-search, #document-search { min-width: 0; width: 100%; max-width: none; padding: 7px 0; border: 0; outline: 0; background: transparent; }
.folder-context { display: flex; align-items: center; gap: 7px; max-width: min(430px, 100%); padding: 7px 10px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
#folder-label { min-width: 0; }
.app-main { min-height: calc(100vh - 132px); padding: 18px clamp(16px, 3vw, 44px) 28px; }
#drop-zone { display: flex; align-items: center; justify-content: center; gap: 11px; max-width: 1800px; margin: 0 auto 16px; padding: 10px 14px; border: 1px dashed color-mix(in srgb, var(--accent) 38%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--panel) 72%, transparent); text-align: left; font-size: 13px; }
#drop-zone strong { color: var(--text); } #drop-zone span { color: var(--muted); }
.workspace { max-width: 1800px; margin: 0 auto; grid-template-columns: minmax(260px, 310px) minmax(0, 1fr); gap: 16px; }
.files, .reader { border-color: var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.files { display: flex; flex-direction: column; height: calc(100vh - 215px); min-height: 550px; }
.files-head { padding: 16px; } .panel-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.files-head strong { display: block; margin-top: 2px; color: var(--text); font-size: 15px; }
#file-count { align-self: center; padding: 3px 7px; color: var(--accent); background: var(--accent-soft); border-radius: 99px; font-size: 11px; font-weight: 750; }
#file-list { flex: 1; min-height: 160px; max-height: none; padding: 8px; }
.file-entry { position: relative; padding: 10px 10px 10px 34px; font-size: 13px; line-height: 1.28; }
.file-entry::before { content: ""; position: absolute; left: 12px; top: 12px; width: 12px; height: 15px; border: 1.5px solid var(--muted); border-radius: 2px; opacity: .85; }
.file-entry.active { box-shadow: inset 3px 0 0 var(--accent); } .file-entry.active::before { border-color: var(--accent); }
.file-entry .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-panel { flex: 0 1 210px; min-height: 92px; border-top: 1px solid var(--line); overflow: hidden; }
.outline-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 15px 7px; }
#outline { max-height: 160px; overflow: auto; padding: 0 8px 10px; }
.outline-empty { margin: 4px 7px; color: var(--muted); font-size: 12px; }
.outline-entry { display: block; width: 100%; min-height: 27px; padding: 4px 7px; overflow: hidden; color: var(--muted); border: 0; border-radius: 5px; background: transparent; text-align: left; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 550; }
.outline-entry:hover { color: var(--text); background: var(--accent-soft); box-shadow: none; transform: none; }
.outline-entry.level-2 { padding-left: 17px; } .outline-entry.level-3 { padding-left: 27px; }
.reader { display: flex; flex-direction: column; min-height: 0; height: calc(100vh - 215px); }
.reader-head { flex: 0 0 auto; padding: 12px 16px; }
.document-identity { min-width: 170px; overflow: hidden; }
#document-path { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
#document-name { margin-top: 1px; font-size: 15px; letter-spacing: -.012em; }
#document-meta { font-size: 11px; }
.reader-actions { gap: 6px; }
.document-search-box { flex: 1 1 190px; max-width: 280px; } #search-count { min-width: 68px; font-size: 11px; }
.reader-actions .mini-button { width: 31px; height: 31px; min-height: 31px; font-size: 15px; }
.reader-actions #copy, .reader-actions #fullscreen { min-height: 31px; padding: 5px 9px; }
#viewer { flex: 1; height: auto; min-height: 0; padding: clamp(25px, 4vw, 64px); background: color-mix(in srgb, var(--panel) 90%, var(--bg)); }
.welcome { max-width: 600px; margin: max(6vh, 36px) auto; text-align: center; }
.welcome-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 15px; color: var(--accent); background: var(--accent-soft); border-radius: 17px; }
.welcome-icon svg { width: 29px; height: 29px; } .welcome h2 { margin: 0; font-size: 22px; letter-spacing: -.035em; } .welcome p { margin: 8px auto 0; color: var(--muted); }
.welcome-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 25px; text-align: left; }
.welcome-step { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.welcome-step b { display: block; margin-bottom: 3px; color: var(--accent); font-size: 11px; } .welcome-step span { color: var(--muted); font-size: 12px; }
.markdown { max-width: 940px; font-size: 16px; line-height: 1.72; } .markdown h1 { font-size: 2.15em; letter-spacing: -.04em; } .markdown h2 { margin-top: 2em; font-size: 1.55em; letter-spacing: -.025em; }
.markdown h3 { margin-top: 1.6em; } .markdown p, .markdown ul, .markdown ol { margin: 1em 0; } .markdown blockquote { padding: .35em 1.1em; background: color-mix(in srgb, var(--accent-soft) 50%, transparent); border-radius: 0 8px 8px 0; }
.markdown pre { padding: 16px 18px; box-shadow: inset 0 0 0 1px var(--line); } .markdown th { font-weight: 750; } .markdown th, .markdown td { padding: 9px 12px; }
.reader:fullscreen { display: flex; } .reader:fullscreen #viewer { height: auto; max-width: none; width: 100%; margin: 0; }
.reader:fullscreen .markdown { max-width: 1040px; }
.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; }
@media (max-width: 900px) { .workspace { grid-template-columns: 245px minmax(0, 1fr); } .reader-head { align-items: flex-start; flex-direction: column; } .reader-actions { width: 100%; } .document-search-box { max-width: none; } }
@media (max-width: 700px) { .topbar { position: static; } .topbar-main { align-items: flex-start; } .status-chip { display: none; } .commandbar { align-items: stretch; } .folder-context { width: 100%; max-width: none; } .workspace { grid-template-columns: 1fr; } .files, .reader { height: auto; min-height: auto; } #file-list { max-height: 260px; } #viewer { min-height: 620px; } .welcome-steps { grid-template-columns: 1fr; } .reader-actions #copy { display: none; } }

/* Ribbon compacto: ações acima, leitura logo abaixo. */
.topbar { padding: 0 clamp(12px, 2vw, 34px); }
.ribbon { display: flex; align-items: center; gap: 12px; min-height: 58px; max-width: 1800px; margin: 0 auto; }
.ribbon .brand { flex: 0 0 auto; gap: 8px; }
.ribbon .brand-mark { width: 31px; height: 31px; border-radius: 9px; box-shadow: none; }
.ribbon .brand-mark svg { width: 18px; height: 18px; }
.ribbon h1 { margin: 0; font-size: 14px; letter-spacing: -.015em; }
.ribbon .product-tag { margin-top: 1px; font-size: 8px; letter-spacing: .1em; }
.ribbon .folder-context { flex: 1 1 160px; min-width: 80px; max-width: none; padding: 0; border: 0; background: transparent; font-size: 12px; }
.ribbon-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; min-width: 0; }
button.ribbon-action { width: 32px; min-width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 7px; }
button.ribbon-action svg { width: 17px; height: 17px; }
button.ribbon-action.primary { box-shadow: none; }
button.ribbon-action.done { color: #fff; border-color: #2fac70; background: #2fac70; }
.ribbon-divider { width: 1px; height: 20px; margin: 0 2px; background: var(--line); }
.ribbon-search { display: flex; align-items: center; width: 128px; height: 32px; gap: 5px; padding: 0 8px; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.ribbon-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.ribbon-search .button-icon { width: 15px; height: 15px; }
.ribbon-search #file-search, .ribbon-search #document-search { width: 100%; height: 100%; min-width: 0; padding: 0; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; line-height: 1.2; }
.document-ribbon-search { width: 174px; }
.ribbon-search-count { min-width: 54px; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.1; text-align: center; white-space: nowrap; }
.ribbon .status-chip { width: 13px; height: 20px; min-width: 13px; padding: 0; overflow: hidden; border: 0; border-radius: 0; background: transparent; font-size: 0; }
.ribbon .status-dot { margin: auto; }
.app-main { min-height: calc(100vh - 58px); padding: 7px clamp(12px, 2vw, 34px) 10px; }
#drop-zone { height: 29px; margin: 0 auto 7px; padding: 4px 10px; border-radius: 7px; font-size: 11px; }
#drop-zone .drop-icon { width: 14px; height: 14px; } #drop-zone strong { font-size: 11px; }
.workspace { gap: 10px; }
.files, .reader { height: calc(100vh - 111px); min-height: 440px; border-radius: 9px; }
.files { min-height: 440px; }
.files-head { padding: 10px 12px; } .files-head strong { font-size: 13px; }
.outline-head { padding: 8px 12px 5px; }
.reader-head { display: flex; align-items: center; min-height: 40px; padding: 6px 14px; }
.document-identity { display: flex; align-items: baseline; gap: 9px; width: 100%; min-width: 0; }
#document-path { flex: 0 1 170px; min-width: 0; }
#document-name { flex: 0 1 auto; min-width: 0; margin: 0; font-size: 13px; }
#document-meta { overflow: hidden; margin: 0; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
#viewer { padding: clamp(20px, 3vw, 46px); }
.markdown { max-width: 960px; }
@media (max-width: 1320px) { .ribbon .folder-context { display: none; } .ribbon { justify-content: space-between; } }
@media (max-width: 980px) { .file-filter { display: none; } .workspace { grid-template-columns: 230px minmax(0, 1fr); } .optional-action { display: none; } }
@media (max-width: 700px) { .ribbon { min-height: 52px; gap: 6px; } .ribbon .brand-mark { width: 29px; height: 29px; } .ribbon .product-tag { display: none; } .ribbon h1 { font-size: 13px; } .document-ribbon-search { width: min(30vw, 156px); } .ribbon-search-count, .ribbon-divider { display: none; } .ribbon-actions { gap: 4px; } button.ribbon-action { width: 30px; min-width: 30px; height: 30px; min-height: 30px; } .app-main { min-height: calc(100vh - 52px); padding: 5px 8px 8px; } #drop-zone { margin-bottom: 5px; } #drop-zone span { display: none; } .workspace { grid-template-columns: 1fr; } .files, .reader { height: auto; min-height: auto; } .reader-head { min-height: 38px; } .document-identity { gap: 6px; } #document-meta { display: none; } #viewer { min-height: 580px; padding: 20px 16px; } }
.tools-menu { position: relative; }
.tools-menu > summary { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: var(--panel); list-style: none; cursor: pointer; }
.tools-menu > summary::-webkit-details-marker { display: none; }
.tools-menu[open] > summary { color: var(--accent); background: var(--accent-soft); }
.tools-popover { position: absolute; top: calc(100% + 9px); right: 0; z-index: 30; width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.tools-popover button { display: flex; justify-content: flex-start; width: 100%; padding: 9px 10px; border: 0; background: transparent; text-align: left; font-size: 12px; }
.tools-popover button:hover:not(:disabled) { background: var(--accent-soft); box-shadow: none; transform: none; }
.tools-popover small { display: block; margin: 4px 10px 6px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.table-tools { display: flex; align-items: center; gap: 5px; padding: 5px 8px; border-bottom: 1px solid var(--line); background: var(--code); }
.table-tools .table-label { flex: 1; color: var(--muted); font-size: 11px; font-weight: 700; }
.table-tools button { min-height: 24px; padding: 2px 7px; font-size: 10px; }
.markdown .table-wrap { background: var(--panel); }
.markdown .katex[data-selectable-formula] { cursor: pointer; border-radius: 3px; }
.markdown .katex[data-selectable-formula]:hover, .markdown .katex[data-selectable-formula]:focus-visible, .markdown .katex.selected-formula { outline: 2px solid var(--accent); outline-offset: 3px; }
.formula-panel { position: fixed; right: clamp(12px, 2vw, 32px); bottom: 18px; z-index: 40; width: min(430px, calc(100vw - 24px)); padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 18px 48px rgba(20, 30, 55, .24); }
.formula-panel[hidden] { display: none; }
.formula-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.formula-panel-head strong { font-size: 13px; }
.formula-panel-head button { min-height: 25px; padding: 1px 7px; }
.formula-panel textarea { display: block; width: 100%; min-height: 68px; margin: 9px 0; padding: 8px; border: 1px solid var(--line); border-radius: 7px; outline-color: var(--accent); color: var(--text); background: var(--code); font: 12px/1.4 ui-monospace, Consolas, monospace; resize: vertical; }
.formula-panel-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.formula-panel p { margin: 9px 0 0; color: var(--muted); font-size: 11px; }
@page { size: A4; margin: 17mm; }
@media print {
  :root, :root[data-theme="dark"] { color-scheme: light; --bg: #fff; --panel: #fff; --text: #111; --muted: #444; --line: #ccc; --code: #f5f5f5; --accent: #233fa0; --accent-soft: #eef1fb; }
  html, body, .app-shell, .app-main, .workspace, .reader, #viewer { display: block !important; width: 100% !important; height: auto !important; min-height: 0 !important; max-height: none !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: #fff !important; }
  .topbar, #drop-zone, .files, .reader-head, .table-tools, .formula-panel { display: none !important; }
  .markdown { max-width: none; color: #111; font-size: 10.5pt; line-height: 1.5; }
  .markdown h1, .markdown h2, .markdown h3, .markdown h4 { break-after: avoid; }
  .markdown pre, .markdown blockquote, .markdown img, .markdown tr, .markdown .katex-display { break-inside: avoid; }
  .markdown .table-wrap { overflow: visible; border: 0; }
  .markdown table { width: 100%; min-width: 0; max-width: 100%; table-layout: auto; }
  .markdown th, .markdown td { overflow-wrap: anywhere; }
  .markdown thead { display: table-header-group; }
  .markdown a { color: #233fa0; }
  mark.term-hit, mark.term-hit.current { color: inherit; background: transparent; outline: 0; }
}
@media (max-width: 500px) { .ribbon #previous-hit, .ribbon #next-hit, .ribbon .status-chip { display: none; } .document-ribbon-search { width: min(37vw, 150px); } }
@media (max-width: 400px) { .ribbon .brand h1 { display: none; } .ribbon .brand { gap: 0; } }

/* ===== Identidade Plano Certo ===== */
:root { --brand-navy: #102c41; --brand-blue: #24516d; --brand-orange: #ef9b57; --brand-orange-dark: #a84c16;
  --bg: #f3f6f7; --panel: #ffffff; --text: #172e40; --muted: #5d6f7c; --line: #dce3e7; --accent: #1f5f8b; --accent-soft: #e8f1f6; --code: #f5f8f9;
  --shadow: 0 14px 36px rgba(16, 44, 65, .07); --hl-yellow: rgba(255, 207, 51, .42); --hl-green: rgba(64, 192, 110, .3); --hl-blue: rgba(70, 150, 235, .28); --hl-pink: rgba(240, 90, 150, .26); --hl-orange: rgba(239, 155, 87, .42); }
:root[data-theme="dark"] { --bg: #0c171f; --panel: #12212c; --text: #e5edf2; --muted: #9bb0bd; --line: #25394a; --accent: #7db8de; --accent-soft: #19313f; --code: #0e1b24;
  --shadow: 0 18px 40px rgba(0, 0, 0, .3); --hl-yellow: rgba(255, 207, 51, .3); --hl-green: rgba(64, 192, 110, .28); --hl-blue: rgba(70, 150, 235, .3); --hl-pink: rgba(240, 90, 150, .3); --hl-orange: rgba(239, 155, 87, .34); }
body { background: radial-gradient(circle at 3% 0%, rgba(36, 81, 109, .1), transparent 26rem), var(--bg); }
.brand-mark, .ribbon .brand-mark { background: linear-gradient(150deg, var(--brand-blue), var(--brand-navy)); box-shadow: inset 0 -3px 0 var(--brand-orange); }
button.primary { color: #fff; background: linear-gradient(135deg, var(--brand-blue), var(--brand-navy)); border-color: var(--brand-navy); box-shadow: 0 5px 13px rgba(16, 44, 65, .2); }
:root[data-theme="dark"] button.primary { color: var(--brand-navy); background: linear-gradient(135deg, #f6b47c, var(--brand-orange)); border-color: var(--brand-orange); }
a.product-tag { color: var(--brand-orange-dark); text-decoration: none; text-transform: uppercase; }
a.product-tag:hover { text-decoration: underline; }
:root[data-theme="dark"] a.product-tag { color: var(--brand-orange); }
.logo-dark { display: none; } :root[data-theme="dark"] .logo-light { display: none; } :root[data-theme="dark"] .logo-dark { display: inline-block; }
.markdown { font-feature-settings: "kern", "liga"; }
.markdown h1, .markdown h2 { color: var(--brand-navy); } :root[data-theme="dark"] .markdown h1, :root[data-theme="dark"] .markdown h2 { color: var(--text); }
.markdown h2 { border-bottom-color: color-mix(in srgb, var(--brand-orange) 45%, var(--line)); }
.markdown blockquote { border-left-color: var(--brand-orange); }
.tools-popover { width: 250px; }
.tools-popover a { display: flex; width: 100%; padding: 9px 10px; border-radius: 8px; color: var(--text); font-size: 12px; font-weight: 650; text-decoration: none; }
.tools-popover a:hover { background: var(--accent-soft); }
.tools-popover hr { margin: 5px 4px; border: 0; border-top: 1px solid var(--line); }
.edited-chip { display: inline-block; margin-left: 6px; padding: 1px 6px; color: var(--brand-orange-dark); background: color-mix(in srgb, var(--brand-orange) 16%, transparent); border-radius: 99px; font-size: 10px; font-weight: 750; }

/* ===== Tabelas: cabem na largura da página ===== */
.markdown .table-wrap { overflow: hidden; background: var(--panel); box-shadow: 0 1px 0 rgba(16, 44, 65, .03); }
.markdown .table-scroll { overflow-x: auto; }
.markdown table { width: 100%; min-width: 0; table-layout: auto; font-variant-numeric: tabular-nums; }
.markdown th, .markdown td { overflow-wrap: break-word; hyphens: auto; border-color: var(--line); }
.markdown td.nowrap { white-space: nowrap; }
.markdown .table-wrap.tight th, .markdown .table-wrap.tight td { overflow-wrap: anywhere; white-space: normal; }
.markdown .table-wrap.stacked thead { display: none; }
.markdown .table-wrap.stacked table, .markdown .table-wrap.stacked tbody, .markdown .table-wrap.stacked tr { display: block; width: 100%; font-size: .95em; }
.markdown .table-wrap.stacked tr { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.markdown .table-wrap.stacked tr:last-child { border-bottom: 0; }
.markdown .table-wrap.stacked tbody tr:nth-child(even) { background: color-mix(in srgb, var(--code) 70%, transparent); }
.markdown .table-wrap.stacked tbody tr td, .markdown .table-wrap.stacked tbody tr:hover td { display: grid; grid-template-columns: minmax(82px, 36%) minmax(0, 1fr); gap: 10px; padding: 3px 0; background: transparent; border: 0; text-align: left !important; white-space: normal; }
.markdown .table-wrap.stacked td::before { content: attr(data-label); color: var(--muted); font-size: .88em; font-weight: 700; }
.markdown thead th { color: var(--brand-navy); background: color-mix(in srgb, var(--accent-soft) 75%, var(--panel)); border-bottom: 2px solid color-mix(in srgb, var(--brand-blue) 40%, var(--line)); vertical-align: bottom; }
:root[data-theme="dark"] .markdown thead th { color: var(--text); }
.markdown tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--code) 70%, transparent); }
.markdown tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.markdown td.num { text-align: right; overflow-wrap: normal; white-space: nowrap; }
.markdown .table-wrap.cols-m table { font-size: .92em; }
.markdown .table-wrap.cols-l table { font-size: .84em; } .markdown .table-wrap.cols-l th, .markdown .table-wrap.cols-l td { padding: 7px 8px; }
.markdown .table-wrap.cols-xl table { font-size: .77em; } .markdown .table-wrap.cols-xl th, .markdown .table-wrap.cols-xl td { padding: 5px 6px; }
.markdown .table-wrap.scroll-mode table { width: max-content; min-width: 100%; }
.markdown .table-wrap.scroll-mode th, .markdown .table-wrap.scroll-mode td { overflow-wrap: normal; hyphens: manual; max-width: 36em; }
.table-tools { flex-wrap: wrap; }
.table-tools button, .diagram-tools button { gap: 4px; }
.table-tools svg, .diagram-tools svg { width: 13px; height: 13px; }

/* ===== Diagramas Mermaid ===== */
.markdown .diagram { margin: 1.4em 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.diagram-tools { display: flex; align-items: center; gap: 5px; padding: 5px 8px; border-bottom: 1px solid var(--line); background: var(--code); }
.diagram-tools .table-label { flex: 1; color: var(--muted); font-size: 11px; font-weight: 700; }
.diagram-tools button { min-height: 24px; padding: 2px 7px; font-size: 10px; }
.diagram-canvas { padding: 18px; overflow: auto; text-align: center; line-height: 1.3; }
.diagram-canvas svg { max-width: 100%; max-height: min(72vh, 760px); height: auto; }
.diagram-source { display: none; }
.diagram-loading { color: var(--muted); font-size: 12px; }
.diagram-error { margin: 0; padding: 10px 12px; color: #b42335; background: color-mix(in srgb, #d14b5a 9%, transparent); border-radius: 7px; font-size: 12px; text-align: left; white-space: pre-wrap; }
:root[data-theme="dark"] .diagram-error { color: #ff9aa6; }

/* ===== Diálogos ===== */
dialog.ms-dialog { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; overflow: hidden; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 30px 80px rgba(8, 20, 30, .35); }
dialog.ms-dialog[open] { display: flex; flex-direction: column; }
dialog.ms-dialog::backdrop { background: rgba(8, 18, 26, .5); backdrop-filter: blur(2px); }
dialog.ms-dialog form { display: flex; flex-direction: column; min-height: 0; flex: 1; margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 16px; letter-spacing: -.015em; }
.dialog-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.dialog-close { width: 32px; min-width: 32px; padding: 0; font-size: 18px; }
.dialog-body { flex: 1; min-height: 0; padding: 16px 18px; overflow: auto; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--code); }
.dialog-foot .foot-note { margin-right: auto; color: var(--muted); font-size: 11px; }
.field-label { display: block; margin: 0 0 7px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.field-group + .field-group { margin-top: 16px; }
.ms-dialog select { min-height: 33px; padding: 5px 8px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 13px; }
.excel-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch i { width: 15px; height: 15px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatch:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.inline-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand-blue); flex: 0 0 auto; }
.check small { display: block; color: var(--muted); font-size: 11px; }
.excel-preview { margin-top: 16px; overflow: hidden; border: 1px solid #d5dde3; border-radius: 7px; background: #fff; color: #1f2933; font: 11px Calibri, Arial, sans-serif; }
.excel-preview .xp-title { padding: 7px 9px 2px; font-size: 13px; font-weight: 700; }
.excel-preview .xp-sub { padding: 0 9px 6px; color: #5d6f7c; font-style: italic; font-size: 10px; }
.excel-preview table { width: 100%; border-collapse: collapse; }
.excel-preview th, .excel-preview td { padding: 4px 7px; border: 1px solid #d5dde3; text-align: left; }
.excel-preview td:last-child, .excel-preview th:last-child { text-align: right; }
.excel-preview tfoot td { font-weight: 700; border-top: 2px solid currentColor; }
.excel-preview .xp-credit { padding: 5px 9px; color: #7b8a95; font-size: 9px; font-style: italic; }
dialog.diagram-dialog { width: min(1240px, calc(100vw - 24px)); height: min(800px, calc(100vh - 24px)); }
.diagram-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 18px; border-bottom: 1px solid var(--line); }
.diagram-toolbar button { min-height: 29px; padding: 4px 9px; font-size: 12px; }
.diagram-toolbar .spacer { flex: 1; }
.diagram-editor { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.45fr); }
.diagram-editor textarea { width: 100%; height: 100%; margin: 0; padding: 14px 16px; resize: none; color: var(--text); background: var(--code); border: 0; border-right: 1px solid var(--line); outline: 0; font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 4; }
.diagram-preview { min-width: 0; overflow: auto; padding: 18px; display: grid; place-items: center; background: var(--panel); }
.diagram-preview svg { max-width: 100%; height: auto; }
#diagram-status { color: var(--muted); font-size: 11px; }
#diagram-status[data-state="error"] { color: #c23345; } :root[data-theme="dark"] #diagram-status[data-state="error"] { color: #ff9aa6; }
.help-chip { color: var(--muted); font-size: 11px; }
.help-chip a { color: var(--accent); }

/* ===== Anotações ===== */
mark.annot { color: inherit; padding: 0 1px; border-radius: 2px; cursor: pointer; -webkit-box-decoration-break: clone; box-decoration-break: clone; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
mark.annot[data-color="yellow"] { background: var(--hl-yellow); } mark.annot[data-color="green"] { background: var(--hl-green); }
mark.annot[data-color="blue"] { background: var(--hl-blue); } mark.annot[data-color="pink"] { background: var(--hl-pink); } mark.annot[data-color="orange"] { background: var(--hl-orange); }
mark.annot.has-note { border-bottom: 2px solid color-mix(in srgb, var(--brand-navy) 55%, transparent); }
:root[data-theme="dark"] mark.annot.has-note { border-bottom-color: color-mix(in srgb, #fff 55%, transparent); }
mark.annot.flash { animation: annot-flash 1.2s ease 2; }
@keyframes annot-flash { 50% { box-shadow: 0 0 0 3px var(--brand-orange); } }
.annot-badge { display: inline-grid; place-items: center; min-width: 15px; height: 15px; margin-left: 2px; padding: 0 3px; color: #fff; background: var(--brand-navy); border-radius: 99px; font-size: 9px; font-weight: 800; line-height: 1; vertical-align: super; cursor: pointer; user-select: none; }
:root[data-theme="dark"] .annot-badge { color: var(--brand-navy); background: var(--brand-orange); }
.selection-toolbar { position: fixed; z-index: 55; display: flex; align-items: center; gap: 4px; padding: 5px 6px; color: #fff; background: var(--brand-navy); border: 1px solid rgba(255, 255, 255, .12); border-radius: 10px; box-shadow: 0 12px 30px rgba(8, 20, 30, .3); }
.selection-toolbar[hidden], .annot-popover[hidden] { display: none; }
.color-dot { width: 22px; min-width: 22px; height: 22px; min-height: 22px; padding: 0; border: 2px solid rgba(255, 255, 255, .85); border-radius: 50%; }
.color-dot[data-color="yellow"] { background: #ffd23f; } .color-dot[data-color="green"] { background: #4cc77a; } .color-dot[data-color="blue"] { background: #5aa2ee; } .color-dot[data-color="pink"] { background: #f06ba0; } .color-dot[data-color="orange"] { background: var(--brand-orange); }
.color-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.selection-toolbar .sep { width: 1px; height: 18px; margin: 0 2px; background: rgba(255, 255, 255, .25); }
.selection-toolbar button.text-button { min-height: 26px; padding: 3px 8px; color: #fff; background: transparent; border-color: transparent; font-size: 12px; }
.selection-toolbar button.text-button:hover { background: rgba(255, 255, 255, .12); border-color: transparent; box-shadow: none; }
.annot-popover { position: fixed; z-index: 56; width: min(330px, calc(100vw - 16px)); padding: 12px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 50px rgba(8, 20, 30, .28); }
.annot-pop-head { display: flex; align-items: center; gap: 8px; }
.annot-pop-head .panel-label { flex: 1; }
#annot-date { color: var(--muted); font-size: 11px; }
#annot-close { width: 26px; min-width: 26px; height: 26px; min-height: 26px; padding: 0; }
#annot-quote { max-height: 76px; margin: 8px 0; padding: 4px 9px; overflow: auto; color: var(--muted); border-left: 3px solid var(--brand-orange); font-size: 12px; line-height: 1.45; }
#annot-note { display: block; width: 100%; min-height: 82px; padding: 8px 9px; color: var(--text); background: var(--code); border: 1px solid var(--line); border-radius: 8px; outline-color: var(--accent); font: 13px/1.45 inherit; font-family: inherit; resize: vertical; }
.annot-pop-actions { display: flex; align-items: center; gap: 6px; margin-top: 9px; }
.annot-colors { display: flex; gap: 5px; margin-right: auto; }
.annot-colors .color-dot { border-color: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.annot-pop-actions button:not(.color-dot) { min-height: 30px; padding: 4px 10px; font-size: 12px; }
button.danger { color: #b42335; } :root[data-theme="dark"] button.danger { color: #ff9aa6; }
.outline-panel { display: flex; flex-direction: column; flex: 0 1 250px; min-height: 120px; }
.side-tabs { display: flex; gap: 3px; padding: 8px 10px 6px; }
.side-tab { flex: 1; min-height: 27px; padding: 3px 8px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; font-size: 11px; font-weight: 750; }
.side-tab:hover:not(:disabled) { color: var(--text); transform: none; box-shadow: none; }
.side-tab[aria-selected="true"] { color: var(--text); background: var(--accent-soft); }
.tab-count { min-width: 17px; padding: 1px 5px; color: var(--accent); background: var(--panel); border-radius: 99px; font-size: 10px; }
#outline, #annotation-list { flex: 1; min-height: 0; max-height: 190px; overflow: auto; padding: 0 8px 8px; }
#annotations-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#annotations-panel[hidden], #outline[hidden] { display: none; }
.annot-entry { display: block; width: 100%; min-height: 0; margin: 0 0 4px; padding: 6px 8px; color: var(--text); background: transparent; border: 0; border-left: 3px solid var(--hl-yellow); border-radius: 5px; text-align: left; font-size: 12px; font-weight: 500; line-height: 1.35; }
.annot-entry:hover:not(:disabled) { background: var(--accent-soft); transform: none; box-shadow: none; }
.annot-entry[data-color="green"] { border-left-color: #4cc77a; } .annot-entry[data-color="blue"] { border-left-color: #5aa2ee; } .annot-entry[data-color="pink"] { border-left-color: #f06ba0; } .annot-entry[data-color="orange"] { border-left-color: var(--brand-orange); } .annot-entry[data-color="yellow"] { border-left-color: #ffd23f; }
.annot-entry .annot-quote { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.annot-entry .annot-note { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.annot-entry.orphan { opacity: .6; } .annot-entry small { display: block; color: #b42335; font-size: 10px; }
.annotation-actions { display: flex; gap: 6px; padding: 0 10px 8px; }
.annotation-actions button { flex: 1; min-height: 27px; padding: 3px 6px; font-size: 11px; }

/* ===== Plano Certo (divulgação discreta) ===== */
.promo-card { position: relative; flex: 0 0 auto; margin: 0 8px 8px; padding: 11px 12px 10px; border: 1px solid color-mix(in srgb, var(--brand-orange) 38%, var(--line)); border-radius: 10px; background: linear-gradient(155deg, color-mix(in srgb, var(--brand-orange) 10%, var(--panel)), var(--panel) 70%); font-size: 12px; }
.promo-card[hidden] { display: none; }
.promo-kicker { display: flex; align-items: center; gap: 6px; color: var(--brand-orange-dark); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
:root[data-theme="dark"] .promo-kicker { color: var(--brand-orange); }
.promo-kicker img { width: 17px; height: 12px; }
.promo-card strong { display: block; margin: 5px 18px 2px 0; color: var(--text); font-size: 13px; line-height: 1.25; }
.promo-card p { margin: 0; color: var(--muted); line-height: 1.4; }
.promo-actions { display: flex; gap: 6px; margin-top: 9px; }
.promo-actions a { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 7px; font-size: 11px; font-weight: 750; text-decoration: none; }
.promo-primary { color: #fff; background: var(--brand-navy); }
:root[data-theme="dark"] .promo-primary { color: var(--brand-navy); background: var(--brand-orange); }
.promo-secondary { color: var(--accent); border: 1px solid var(--line); background: var(--panel); }
.promo-actions a:hover { filter: brightness(1.08); }
.promo-close { position: absolute; top: 5px; right: 5px; width: 22px; min-width: 22px; height: 22px; min-height: 22px; padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 15px; }
.promo-close:hover:not(:disabled) { color: var(--text); transform: none; box-shadow: none; }
@media (max-height: 760px) { .promo-card p { display: none; } }
.doc-footer-promo { display: flex; align-items: center; gap: 12px; max-width: 960px; margin: 3.2em auto 0; padding-top: 16px; color: var(--muted); border-top: 1px dashed var(--line); font-size: 12px; line-height: 1.45; }
.doc-footer-promo img { width: 28px; height: 20px; flex: 0 0 auto; }
.doc-footer-promo a { color: var(--accent); font-weight: 700; }
.welcome { max-width: 760px; }
.welcome-actions { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; margin-top: 20px; }
.welcome-actions button { min-height: 38px; padding: 8px 15px; }
.welcome-steps { grid-template-columns: repeat(4, 1fr); }
.welcome-step b { color: var(--brand-orange-dark); } :root[data-theme="dark"] .welcome-step b { color: var(--brand-orange); }
.welcome-step strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 13px; }
.welcome-sponsor { display: flex; align-items: center; gap: 13px; margin-top: 22px; padding: 13px 15px; text-align: left; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); font-size: 12.5px; color: var(--muted); }
.welcome-sponsor img { width: 42px; height: 30px; flex: 0 0 auto; }
.welcome-sponsor strong { color: var(--text); }
.welcome-sponsor a { color: var(--accent); font-weight: 700; white-space: nowrap; }
.privacy-note { margin-top: 14px; color: var(--muted); font-size: 11.5px; }
@media (max-width: 760px) { .welcome-steps { grid-template-columns: 1fr 1fr; } .excel-grid { grid-template-columns: 1fr; } .diagram-editor { grid-template-columns: 1fr; grid-template-rows: minmax(0, 45%) minmax(0, 55%); } .diagram-editor textarea { border-right: 0; border-bottom: 1px solid var(--line); } .welcome-sponsor { flex-direction: column; text-align: center; } }

/* ===== Avisos ===== */
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 70; max-width: min(460px, calc(100vw - 32px)); padding: 9px 14px; color: #fff; background: var(--brand-navy); border-radius: 9px; box-shadow: 0 12px 30px rgba(8, 20, 30, .3); font-size: 13px; font-weight: 600; opacity: 0; transform: translate(-50%, 10px); transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-state="error"] { background: #b42335; }
.toast[hidden] { display: none; }
.consent { position: fixed; left: 16px; bottom: 16px; z-index: 65; max-width: 430px; padding: 14px 15px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 48px rgba(8, 20, 30, .22); font-size: 12.5px; }
.consent p { margin: 0 0 10px; color: var(--muted); line-height: 1.5; } .consent strong { color: var(--text); } .consent a { color: var(--accent); }
.consent-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 520px) { .consent { left: 8px; right: 8px; bottom: 8px; max-width: none; } }

@media print {
  .diagram-tools, .promo-card, .doc-footer-promo, .consent, .toast, .selection-toolbar, .annot-popover, .annot-badge, dialog { display: none !important; }
  .markdown .table-wrap.scroll-mode table { width: 100%; }
  .markdown .table-scroll { overflow: visible; }
  .markdown thead th { color: #102c41; background: #e8f1f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .markdown .diagram { border: 0; break-inside: avoid; }
  mark.annot.has-note { border-bottom: 0; }
}

/* ===== Barra lateral em abas: Explorador / Sumário / Anotações, com uma única rolagem ===== */
.files.sidebar { display: flex; flex-direction: column; overflow: hidden; }
.sidebar .side-tabs { flex: 0 0 auto; display: flex; gap: 3px; padding: 8px; border-bottom: 1px solid var(--line); }
.sidebar .side-tab { flex: 1 1 0; min-width: 0; min-height: 30px; gap: 5px; padding: 4px 6px; font-size: 11.5px; white-space: nowrap; }
.sidebar .side-tab .tab-count { flex: 0 0 auto; }
.side-panels { position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.side-panel[hidden] { display: none !important; }
.sidebar #file-list, .sidebar #outline, .sidebar #annotation-list { flex: none; max-height: none; min-height: 0; padding: 8px; overflow: visible; }
.sidebar #annotations-panel { display: block; }
.sidebar .annotation-actions { position: sticky; top: 0; z-index: 1; padding: 8px 8px 7px; background: var(--panel); border-bottom: 1px solid var(--line); }
.folder-summary { display: flex; align-items: center; gap: 6px; margin: 8px 10px 0; padding: 6px 9px; overflow: hidden; color: var(--muted); background: var(--bg); border-radius: 7px; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.folder-summary[hidden] { display: none; }
.folder-summary svg { width: 13px; height: 13px; flex: 0 0 auto; }
.folder-summary span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { .files.sidebar { height: auto; min-height: 0; } .side-panels { max-height: 330px; } }

/* ===== Visual x Markdown (texto puro) ===== */
.reader-head { gap: 10px; }
.view-switch { flex: 0 0 auto; display: inline-flex; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.view-switch button { min-height: 26px; gap: 5px; padding: 2px 10px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; font-size: 11.5px; }
.view-switch button:hover:not(:disabled) { color: var(--text); transform: none; box-shadow: none; }
.view-switch button[aria-pressed="true"] { color: var(--text); background: var(--panel); box-shadow: 0 1px 3px rgba(16, 44, 65, .14); }
.view-switch svg { width: 14px; height: 14px; }
.md-source { max-width: 1120px; margin: 0 auto; overflow: hidden; color: var(--text); background: var(--code); border: 1px solid var(--line); border-radius: 10px; font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }
.md-source[hidden], .markdown[hidden] { display: none; }
.source-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 6px 10px; color: var(--muted); background: var(--panel); border-bottom: 1px solid var(--line); font: 600 11px system-ui, "Segoe UI", sans-serif; }
.source-bar .grow { flex: 1; }
.source-bar button { min-height: 25px; padding: 2px 9px; font-size: 11px; }
.source-lines { padding: 10px 0; overflow-x: auto; }
.src-line { display: grid; grid-template-columns: 4.4em minmax(0, 1fr); min-height: 1.65em; }
.src-line:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.src-line .ln { margin-right: 1em; padding-right: 1em; color: color-mix(in srgb, var(--muted) 70%, transparent); border-right: 1px solid var(--line); text-align: right; user-select: none; -webkit-user-select: none; }
.src-line .tx { padding-right: 14px; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.md-source.nowrap .tx { white-space: pre; overflow-wrap: normal; }
.md-source.nowrap .src-line { width: max-content; min-width: 100%; }
.src-line.code, .src-line.fence { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.src-line.fence .tx { color: var(--muted); }
.src-line.heading .tx { color: var(--brand-navy); font-weight: 700; }
:root[data-theme="dark"] .src-line.heading .tx { color: var(--accent); }
.src-line.quote .tx { color: var(--muted); }
.src-line.flash { background: color-mix(in srgb, var(--brand-orange) 26%, transparent); }
.tk-mark { color: var(--brand-orange-dark); font-weight: 700; }
:root[data-theme="dark"] .tk-mark { color: var(--brand-orange); }
.tk-code { color: #b4235a; } :root[data-theme="dark"] .tk-code { color: #ff8fb8; }
.tk-math, .src-line.math .tx { color: #0f7a5c; } :root[data-theme="dark"] .tk-math, :root[data-theme="dark"] .src-line.math .tx { color: #5fd3a8; }
.tk-link { color: var(--accent); }
.tk-url { color: var(--muted); }
.tk-html { color: #7a4fb8; } :root[data-theme="dark"] .tk-html { color: #c4a8ff; }
.tk-strong { font-weight: 700; } .tk-em { font-style: italic; }
.tk-pipe { color: var(--muted); }

/* ===== Idioma, instalação, perguntas frequentes ===== */
button.ribbon-action.lang-switch { width: auto; min-width: 34px; padding: 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.welcome-faq { margin-top: 28px; text-align: left; }
.welcome .welcome-faq h2 { margin: 0 0 8px; font-size: 16px; letter-spacing: -.01em; }
.welcome-faq details { margin-top: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.welcome-faq summary { display: flex; justify-content: space-between; gap: 12px; padding: 10px 13px; cursor: pointer; font-size: 13.5px; font-weight: 650; list-style: none; }
.welcome-faq summary::-webkit-details-marker { display: none; }
.welcome-faq summary::after { content: "+"; color: var(--muted); font-weight: 500; }
.welcome-faq details[open] summary::after { content: "–"; }
.welcome .welcome-faq p { margin: 0; padding: 0 13px 12px; color: var(--muted); font-size: 13px; line-height: 1.55; text-align: left; }
.welcome-langs { margin-top: 12px; color: var(--muted); font-size: 12px; }
.welcome-langs a { color: var(--accent); }
.welcome-langs a[aria-current="true"] { color: var(--text); font-weight: 700; text-decoration: none; }
.noscript-box { max-width: 720px; margin: 24px auto; padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
@media print { .view-switch, .source-bar { display: none !important; } .md-source { border: 0; background: #fff; } }

/* ===== Aparência do texto (preferências do leitor). Tabelas e diagramas usam a mesma largura do texto. ===== */
#viewer { --reading-scale: 1; --reading-line: 1.72; --reading-gap: 1em; --reading-max: 960px; }
#viewer.density-compact { --reading-line: 1.5; --reading-gap: .6em; }
#viewer.density-relaxed { --reading-line: 1.92; --reading-gap: 1.35em; }
#viewer .markdown { max-width: var(--reading-max); font-size: calc(16px * var(--reading-scale)); line-height: var(--reading-line); }
#viewer .markdown p, #viewer .markdown ul, #viewer .markdown ol, #viewer .markdown blockquote, #viewer .markdown pre,
#viewer .markdown .table-wrap, #viewer .markdown .diagram, #viewer .markdown .katex-display { margin-top: var(--reading-gap); margin-bottom: var(--reading-gap); }
#viewer .markdown h2 { margin-top: calc(var(--reading-gap) * 2); }
#viewer .markdown h3, #viewer .markdown h4 { margin-top: calc(var(--reading-gap) * 1.6); }
#viewer.density-compact .markdown li + li { margin-top: .1em; }
#viewer.density-compact .markdown th, #viewer.density-compact .markdown td { padding: 5px 8px; }
#viewer.density-relaxed .markdown th, #viewer.density-relaxed .markdown td { padding: 11px 14px; }
#viewer.align-justify .markdown p, #viewer.align-justify .markdown li { text-align: justify; hyphens: auto; }
#viewer.font-serif .markdown { font-family: Georgia, Cambria, "Times New Roman", serif; }
#viewer.font-serif .markdown :is(h1, h2, h3, h4, h5, h6, th, .table-tools, .diagram-tools) { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
#viewer .md-source { max-width: max(var(--reading-max), 860px); font-size: calc(13px * var(--reading-scale)); }
#viewer .doc-footer-promo { max-width: var(--reading-max); }
.reading-popover { width: 292px; max-height: calc(100vh - 76px); padding: 12px; overflow: auto; overscroll-behavior: contain; }
.reading-popover .field-label { margin: 12px 0 6px; }
.reading-popover .field-label:first-child { margin-top: 0; }
.segmented { display: flex; gap: 2px; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.tools-popover .segmented button { flex: 1 1 0; justify-content: center; width: auto; min-width: 0; min-height: 28px; padding: 3px 5px; color: var(--muted); border-radius: 6px; font-size: 11.5px; text-align: center; white-space: nowrap; }
.tools-popover .segmented button[aria-pressed="true"] { color: var(--text); background: var(--panel); box-shadow: 0 1px 3px rgba(16, 44, 65, .14); }
.stepper { display: flex; align-items: center; gap: 8px; }
.tools-popover .stepper button { justify-content: center; width: 44px; padding: 4px 0; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 800; }
.stepper output { flex: 1; font-size: 13px; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.reading-popover small { margin: 12px 0 0; }
.tools-popover .reading-reset { justify-content: center; margin-top: 10px; border: 1px solid var(--line); }
@media (max-width: 500px) { .reading-popover { position: fixed; top: 58px; right: 8px; left: 8px; width: auto; } }
@media print {
  #viewer .markdown { max-width: none; font-size: calc(10.5pt * var(--reading-scale)); line-height: calc(var(--reading-line) - .18); }
  #viewer .md-source { max-width: none; }
}
/* No celular a barra superior também fica fixa e acima do conteúdo, para os menus suspensos não ficarem por trás. */
@media (max-width: 700px) { .topbar { position: sticky; top: 0; z-index: 20; } }

/* ===== Uma única rolagem por área =====
   Elementos com posição absoluta dentro do texto (ex.: MathML oculto do KaTeX) ficam presos à área de leitura,
   e no computador a página ocupa exatamente a janela: rola só a lista lateral e o documento. */
#viewer, .markdown, .md-source { position: relative; }
@media (min-width: 701px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; }
  .topbar { flex: 0 0 auto; }
  .app-main { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  #drop-zone { flex: 0 0 auto; width: 100%; }
  .workspace { flex: 1 1 auto; width: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .files, .files.sidebar, .reader { height: auto; min-height: 0; }
}
/* No celular rola só a página (sem rolagem interna), e a barra do texto puro fica presa abaixo da barra superior. */
@media (max-width: 700px) {
  #viewer { overflow: visible; }
  .reader { overflow: clip; }
  .source-bar { top: 52px; }
}
/* Tabelas com larguras de coluna calculadas pelo app (colgroup) */
.markdown table[style*="fixed"] th, .markdown table[style*="fixed"] td { overflow-wrap: break-word; }
/* "clip" recorta os cantos sem criar área de rolagem, para a barra do texto puro ficar presa ao rolar. */
.md-source { overflow: clip; }
@media (min-width: 701px) { .source-bar { top: calc(-1 * clamp(20px, 3vw, 46px)); } }

/* ===== Diagramas com tamanho inteligente (o app define width/height do SVG) ===== */
#viewer .diagram-canvas { overflow: auto; padding: 18px; text-align: left; overscroll-behavior-x: contain; }
#viewer .diagram-canvas > svg, .diagram-preview > svg { display: block; max-width: none; max-height: none; margin: 0 auto; }
#viewer .diagram.overflowing .diagram-canvas { box-shadow: inset -22px 0 18px -18px rgba(16, 44, 65, .28); }
:root[data-theme="dark"] #viewer .diagram.overflowing .diagram-canvas { box-shadow: inset -22px 0 18px -18px rgba(0, 0, 0, .6); }
.diagram-tools { flex-wrap: wrap; }
.diagram-zoom { display: inline-flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.diagram-tools .diagram-zoom button { min-width: 24px; min-height: 22px; padding: 1px 6px; border: 0; border-radius: 0; font-size: 12px; font-weight: 750; }
.diagram-tools .diagram-zoom button + button { border-left: 1px solid var(--line); }
.diagram-tools .diagram-zoom .diagram-zoom-value { min-width: 64px; font-size: 10px; font-variant-numeric: tabular-nums; }
.diagram-tools .diagram-zoom button:hover:not(:disabled) { transform: none; box-shadow: none; background: var(--accent-soft); }
.diagram:fullscreen { display: flex; flex-direction: column; margin: 0; border: 0; border-radius: 0; background: var(--panel); }
.diagram:fullscreen .diagram-canvas { flex: 1; display: flex; overflow: auto; }
.diagram:fullscreen .diagram-canvas > svg { margin: auto; }
.diagram-preview { display: flex; }
.diagram-preview > svg { margin: auto; }
@media print {
  #viewer .diagram-canvas { overflow: visible; box-shadow: none !important; }
  #viewer .diagram-canvas > svg { max-width: 100% !important; height: auto !important; }
}
.table-tools .table-label, .diagram-tools .table-label { flex: 1 0 auto; white-space: nowrap; }

/* ===== Textos colados no Explorador ===== */
.file-row { position: relative; }
.file-row.pasted .file-entry { padding-right: 58px; }
.file-row.pasted .file-entry::before { border-style: dashed; }
.file-actions { position: absolute; top: 7px; right: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s ease; }
.file-row:hover .file-actions, .file-row:focus-within .file-actions { opacity: 1; }
.file-actions button { width: 24px; min-width: 24px; height: 24px; min-height: 24px; padding: 0; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.file-actions button:hover:not(:disabled) { color: var(--text); transform: none; box-shadow: none; }
@media (hover: none) { .file-actions { opacity: 1; } }

/* ===== Diálogo "Colar Markdown" ===== */
dialog.paste-dialog { width: min(980px, calc(100vw - 24px)); height: min(760px, calc(100vh - 24px)); }
.paste-body { display: flex; flex-direction: column; gap: 10px; }
.paste-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.paste-row .paste-name { flex: 1 1 260px; }
.ms-dialog .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 650; }
.ms-dialog .field input[type="text"], .ms-dialog .field select { width: 100%; min-height: 34px; padding: 6px 9px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 13px; font-weight: 500; }
.ms-dialog .field input[type="text"]:focus, .ms-dialog .field select:focus, #paste-text:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
#paste-text { flex: 1; min-height: 240px; width: 100%; padding: 12px 14px; color: var(--text); background: var(--code); border: 1px solid var(--line); border-radius: 9px; font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; resize: none; tab-size: 4; }
.paste-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11.5px; }
#paste-count { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ===== Diálogo "Exportar PDF ou Word" ===== */
dialog.export-dialog { width: min(860px, calc(100vw - 24px)); }
.export-format { display: flex; gap: 8px; margin-bottom: 14px; }
.export-format label { flex: 1; position: relative; cursor: pointer; }
.export-format input { position: absolute; opacity: 0; pointer-events: none; }
.export-format span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; font-size: 13.5px; font-weight: 750; color: var(--muted); }
.export-format input:checked + span { color: var(--text); background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.export-format input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.export-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.export-grid fieldset { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 10px; }
.export-grid fieldset.span-2 { grid-column: 1 / -1; }
.export-grid legend { padding: 0 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cover-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-left: 25px; }
.cover-fields.disabled { opacity: .5; }
.checks-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.field-hint { color: var(--muted); font-size: 11px; }
.export-dialog .check { padding: 3px 0; }
#export-note { max-width: 420px; }
@media (max-width: 700px) { .export-grid, .checks-2, .cover-fields { grid-template-columns: 1fr; } .cover-fields { padding-left: 0; } #export-note { display: none; } }

/* ===== Dicionário de termos em inglês ===== */
.dict-term { text-decoration: underline dotted color-mix(in srgb, var(--accent) 70%, transparent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; cursor: help; border-radius: 2px; }
.dict-term:hover, .dict-term.flash { background: color-mix(in srgb, var(--accent-soft) 85%, transparent); }
body.dict-off .dict-term { text-decoration: none; cursor: inherit; background: none; }
.dict-popover { position: fixed; z-index: 95; width: min(360px, calc(100vw - 16px)); padding: 12px 14px 10px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--brand-orange); border-radius: 12px; box-shadow: 0 20px 50px rgba(8, 20, 30, .28); font: 13px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; text-align: left; }
.dict-popover[hidden] { display: none; }
.dict-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dict-head strong { font-size: 16px; letter-spacing: -.01em; }
.dict-cat { margin-right: auto; padding: 1px 7px; color: var(--accent); background: var(--accent-soft); border-radius: 99px; font-size: 10px; font-weight: 750; }
.dict-close { width: 24px; min-width: 24px; height: 24px; min-height: 24px; padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 16px; }
.dict-popover p { margin: 6px 0 0; }
.dict-popover p span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.dict-translation { font-size: 14.5px; font-weight: 700; }
.dict-definition { font-style: italic; }
.dict-more { display: inline-block; margin-top: 8px; color: var(--accent); font-size: 12px; font-weight: 650; }
.dict-source, .dict-loading { color: var(--muted); font-size: 11.5px; }
.glossary-panel { margin: 4px 8px 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.glossary-panel[hidden] { display: none; }
.glossary-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 4px; }
.glossary-hint { margin: 0 4px 6px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.glossary-entry { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 0; margin: 0 0 2px; padding: 5px 8px; color: var(--text); background: transparent; border: 0; border-radius: 6px; text-align: left; font-size: 12px; font-weight: 500; line-height: 1.3; }
.glossary-entry strong { font-weight: 700; }
.glossary-entry span { color: var(--muted); font-size: 11.5px; }
.glossary-entry:hover:not(:disabled) { background: var(--accent-soft); transform: none; box-shadow: none; }
.selection-toolbar #annotate-dict[hidden] { display: none; }
.follow-check { padding: 2px 0 6px; border-bottom: 1px dashed var(--line); margin-bottom: 2px; }

/* ===== Modo leitura em páginas (estilo Kindle) ===== */
.book-reader { --book-bg: #f6efdf; --book-text: #33291d; --book-muted: #7a6a55; --book-line: #e2d6bd; --book-accent: #a84c16; --book-chrome: #efe5cf;
  position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; color: var(--book-text); background: var(--book-bg); outline: 0; }
.book-reader[hidden] { display: none; }
.book-reader[data-theme="light"] { --book-bg: #fdfcf9; --book-text: #1f2328; --book-muted: #6b7280; --book-line: #e6e3dc; --book-accent: #1f5f8b; --book-chrome: #f4f2ec; }
.book-reader[data-theme="dark"] { --book-bg: #141414; --book-text: #d9d4cb; --book-muted: #918a7f; --book-line: #2c2b29; --book-accent: #ef9b57; --book-chrome: #1d1c1b; }
body.book-open { overflow: hidden; }
.book-top, .book-bottom { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--book-chrome); border-bottom: 1px solid var(--book-line); transition: opacity .2s ease; }
.book-bottom { border-top: 1px solid var(--book-line); border-bottom: 0; }
.book-reader.chrome-hidden .book-top, .book-reader.chrome-hidden .book-bottom, .book-reader.chrome-hidden .book-turn { opacity: 0; pointer-events: none; }
.book-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.book-heading strong { overflow: hidden; font: 700 14px system-ui, "Segoe UI", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.book-heading span { overflow: hidden; color: var(--book-muted); font: 12px system-ui, "Segoe UI", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.book-tools { display: flex; align-items: center; gap: 6px; }
.book-reader .book-button { min-width: 34px; min-height: 32px; padding: 4px 9px; color: var(--book-text); background: transparent; border: 1px solid var(--book-line); border-radius: 8px; font: 700 13px system-ui, "Segoe UI", sans-serif; }
.book-reader .book-button:hover:not(:disabled) { border-color: var(--book-accent); transform: none; box-shadow: none; }
#book-close { font-size: 20px; line-height: 1; }
#book-toc { max-width: 220px; min-height: 32px; padding: 4px 8px; color: var(--book-text); background: transparent; border: 1px solid var(--book-line); border-radius: 8px; font: 13px system-ui, "Segoe UI", sans-serif; }
#book-toc option { color: #1f2328; background: #fff; }
.book-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: stretch; }
.book-viewport { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; user-select: text; }
.book-turn { position: absolute; top: 50%; z-index: 2; width: 44px; min-height: 88px; padding: 0; color: var(--book-muted); background: transparent; border: 0; font-size: 34px; transform: translateY(-50%); transition: opacity .2s ease; }
.book-turn:hover:not(:disabled) { color: var(--book-accent); transform: translateY(-50%); box-shadow: none; }
.book-turn:disabled { opacity: 0; }
.book-turn.prev { left: 4px; } .book-turn.next { right: 4px; }
.book-content.markdown { box-sizing: border-box; max-width: none; margin: 0; overflow: hidden; color: var(--book-text); column-fill: auto; font-size: calc(19px * var(--book-scale, 1)); line-height: 1.62; text-align: justify; hyphens: auto; -webkit-hyphens: auto; orphans: 2; widows: 2; }
.book-reader[data-font="serif"] .book-content { font-family: "Literata", Georgia, Cambria, "Times New Roman", serif; }
.book-reader[data-font="sans"] .book-content { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.book-content :is(h1, h2, h3, h4, h5, h6) { color: var(--book-text); text-align: left; break-after: avoid; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.book-content h1 { margin-top: 0; font-size: 1.7em; border-bottom: 1px solid var(--book-line); }
.book-content h2 { font-size: 1.32em; border-bottom: 1px solid var(--book-line); }
.book-content h3 { font-size: 1.12em; }
.book-content p, .book-content ul, .book-content ol, .book-content blockquote { margin: 0 0 .8em; }
.book-content a { color: var(--book-accent); }
.book-content blockquote { color: var(--book-muted); background: transparent; border-left-color: var(--book-accent); }
.book-content code { background: color-mix(in srgb, var(--book-line) 60%, transparent); }
.book-content pre { white-space: pre-wrap; overflow-wrap: anywhere; background: color-mix(in srgb, var(--book-line) 45%, transparent); box-shadow: none; font-size: .8em; text-align: left; }
/* Altura limitada para o título anterior caber na mesma página que a imagem ou o diagrama. */
.book-content img, .book-content .diagram-canvas > svg { display: block; max-width: 100%; max-height: calc(var(--book-page-height, 80vh) * 0.7); width: auto; height: auto; margin: 0 auto; }
.book-content .diagram, .book-content img, .book-content tr, .book-content .katex-display, .book-content figure { break-inside: avoid; }
.book-content .diagram { margin: .8em 0; background: transparent; border: 0; }
.book-content .diagram-canvas { padding: 0; overflow: visible; box-shadow: none !important; }
.book-content .katex-display { overflow: hidden; }
.book-content .table-wrap { margin: .8em 0; background: transparent; border-color: var(--book-line); box-shadow: none; }
.book-content table { width: 100%; table-layout: auto; font-size: .82em; text-align: left; hyphens: auto; }
.book-content th, .book-content td { padding: 5px 7px; border-color: var(--book-line); overflow-wrap: anywhere; }
.book-content thead th { color: var(--book-text); background: color-mix(in srgb, var(--book-line) 70%, transparent); border-bottom-color: var(--book-muted); }
.book-content tbody tr:nth-child(even) td, .book-content tbody tr:hover td { background: transparent; }
.book-content td.num, .book-content td.nowrap { white-space: normal; }
.book-content .table-wrap.stacked tr { border-color: var(--book-line); }
.book-content .table-wrap.stacked tbody tr:nth-child(even) { background: color-mix(in srgb, var(--book-line) 30%, transparent); }
.book-content .dict-term { text-decoration-color: color-mix(in srgb, var(--book-accent) 70%, transparent); }
.book-end { margin-top: 2em !important; padding-top: 1em; color: var(--book-muted); border-top: 1px solid var(--book-line); font: italic 12px system-ui, "Segoe UI", sans-serif; text-align: center !important; }
.book-bottom #book-progress { flex: 1; accent-color: var(--book-accent); }
.book-page, .book-left { color: var(--book-muted); font: 12px system-ui, "Segoe UI", sans-serif; white-space: nowrap; font-variant-numeric: tabular-nums; }
.book-hint { position: absolute; left: 50%; bottom: 52px; margin: 0; padding: 6px 12px; color: var(--book-muted); background: var(--book-chrome); border: 1px solid var(--book-line); border-radius: 99px; font: 11.5px system-ui, "Segoe UI", sans-serif; transform: translateX(-50%); animation: book-hint 5s ease forwards; pointer-events: none; white-space: nowrap; }
@keyframes book-hint { 0%, 70% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.book-reader .dict-popover { z-index: 96; }
@media (max-width: 700px) {
  .book-top { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .book-heading { order: 2; flex-basis: 100%; }
  .book-tools { flex: 1; justify-content: flex-end; }
  #book-toc { max-width: 120px; }
  #book-spread, .book-left, .book-hint { display: none; }
  .book-turn { width: 30px; font-size: 26px; }
}
@media print { .book-reader, .dict-popover { display: none !important; } .dict-term { text-decoration: none; } }
/* Blocos com overflow:hidden não se dividem entre páginas; no modo leitura tabelas e código precisam poder continuar na página seguinte. */
.book-content .table-wrap, .book-content .table-scroll, .book-content pre { overflow: visible; }
.book-content .table-wrap.stacked tr { break-inside: avoid; }
