/* =====================================================================
   ESTILO DO QUADRO
   Cores principais nas variáveis abaixo — mude aqui para trocar o visual.
   ===================================================================== */
:root {
  --accent: #f2542d;        /* laranja: seleção, botões principais */
  --accent-soft: #fde7e0;
  --ink: #1f2125;           /* grafite: textos e barras escuras */
  --ink-soft: #6b6f78;
  --line: #e6e2dc;
  --canvas: #f6f4f1;        /* fundo claro de menus e botões */
  --grid: rgba(255, 255, 255, .035); /* quadriculado de giz, bem fraquinho */
  /* LOUSA DE VERDADE: verde + pó de giz (ruído) + manchas de apagador */
  --chalkboard: #24392f;
  --chalk-dust:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 -.2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2560' height='1600'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .012' numOctaves='4' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.6 -.75'/%3E%3C/filter%3E%3Crect width='2560' height='1600' filter='url(%23m)' opacity='.09'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 38% 22% at 18% 30%, rgba(255, 255, 255, .09), transparent 70%),
    radial-gradient(ellipse 30% 18% at 72% 18%, rgba(255, 255, 255, .075), transparent 70%),
    radial-gradient(ellipse 45% 25% at 60% 78%, rgba(255, 255, 255, .085), transparent 70%),
    radial-gradient(ellipse 25% 30% at 90% 60%, rgba(255, 255, 255, .06), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, .28));
  --card: #ffffff;
  --dark: #1f2125;          /* dock e barra flutuante */
  --dark-2: #33363c;
  --dark-ink: #ece9e4;
  --danger: #e5484d;
  --shadow-sm: 0 1px 2px rgba(31, 33, 37, .08), 0 2px 6px rgba(31, 33, 37, .05);
  --shadow: 0 2px 6px rgba(31, 33, 37, .10), 0 14px 34px rgba(31, 33, 37, .14);
  --radius: 12px;
  --top: 0px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--chalk-dust), var(--chalkboard);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Abertura ---------- */
.boot-msg { display: none; }
body.booting .boot-msg {
  display: grid; place-items: center; position: fixed; inset: 0;
  background: var(--canvas); color: var(--ink-soft); font-weight: 500; z-index: 50;
}
body.loading .board { opacity: .5; transition: opacity .2s; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-mark {
  display: inline-block; width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: url("../icon.svg") center / cover no-repeat;
}
.brand.big { font-size: 26px; }
.brand.big .brand-mark { width: 36px; height: 36px; border-radius: 10px; }

.btn {
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--canvas); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wide { width: 100%; height: 44px; }
.btn.install { height: 32px; font-size: 13px; }
.btn[hidden] { display: none; }
.install-wrap { position: relative; }
.install-help {
  position: absolute; right: 0; top: calc(100% + 10px); width: 300px; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px; color: var(--ink); font-size: 14px; display: grid; gap: 8px;
}
.install-help[hidden] { display: none; }
.install-help p { margin: 0; color: var(--ink-soft); }

/* ---------- Quadro ---------- */
.board {
  position: fixed; inset: var(--top) 0 0 0; overflow: hidden; touch-action: none;
  background-color: transparent; /* a lousa verde vem do fundo da página (body) */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  cursor: default;
}
.board.panning, .board.grab { cursor: grabbing; }
.board.dropping { box-shadow: inset 0 0 0 3px var(--accent); }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; --inv-zoom: 1; }
.world.moving { will-change: transform; }
.items-layer { position: absolute; left: 0; top: 0; isolation: isolate; z-index: 0; }
.connectors-layer { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; z-index: 1; pointer-events: none; }
.overlay-layer { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; }

.item { position: absolute; left: 0; top: 0; user-select: none; -webkit-user-select: none; }
.dragging .item { pointer-events: none; }
.item-error { width: 100%; height: 100%; display: grid; place-items: center; background: #fff0f0; color: var(--danger); border-radius: 8px; }

/* ---------- Marcações (quadradinhos no canto) ---------- */
.marks {
  position: absolute; right: 0; top: 0; z-index: 2; pointer-events: none;
  display: flex; gap: min(calc(4px * var(--inv-zoom)), 14px);
  transform: translate(35%, -35%);
}
.mark {
  width: min(calc(18px * var(--inv-zoom)), 64px); height: min(calc(18px * var(--inv-zoom)), 64px);
  border-radius: min(calc(5px * var(--inv-zoom)), 16px);
  border: min(calc(2.5px * var(--inv-zoom)), 8px) solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}

/* ---------- Seleção ---------- */
.sel-outline {
  position: absolute; left: 0; top: 0; border-radius: 4px;
  /* espessura constante na tela, mas sem passar de 4px da lousa (vários itens pequenos com zoom longe) */
  outline: min(calc(2px * var(--inv-zoom)), 4px) solid var(--accent);
  outline-offset: min(calc(3px * var(--inv-zoom)), 3px);
}
.sel-handle {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  width: calc(14px * var(--inv-zoom)); height: calc(14px * var(--inv-zoom));
  margin: calc(-7px * var(--inv-zoom)) 0 0 calc(-7px * var(--inv-zoom));
  background: #fff; border: calc(2px * var(--inv-zoom)) solid var(--accent);
}
.sel-handle.resize { border-radius: calc(3px * var(--inv-zoom)); cursor: nwse-resize;
  margin: calc(-4px * var(--inv-zoom)) 0 0 calc(-4px * var(--inv-zoom)); }
.sel-handle.connect { border-radius: 50%; cursor: crosshair; background: var(--accent); border-color: #fff; }
/* sem 'scale' aqui: ele multiplicaria a posição (translate) e a bolinha "fugiria" do mouse */
.sel-handle.connect:hover { box-shadow: 0 0 0 calc(4px * var(--inv-zoom)) rgba(242, 84, 45, .35); }
.sel-handle.connect::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; } /* área de clique maior */
.sel-handle.connect.top { margin-top: calc(-26px * var(--inv-zoom)); }
.sel-handle.connect.bottom { margin-top: calc(12px * var(--inv-zoom)); }
.sel-handle.connect.left { margin-left: calc(-26px * var(--inv-zoom)); }
.sel-handle.connect.right { margin-left: calc(12px * var(--inv-zoom)); }
.box-select {
  position: absolute; left: 0; top: 0;
  background: rgba(242, 84, 45, .07); border: calc(1.5px * var(--inv-zoom)) dashed var(--accent);
}

/* ---------- Setas ---------- */
.conn-line { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.conn-line.dashed { stroke-dasharray: 8 7; }
.conn-hit { fill: none; stroke: transparent; stroke-width: calc(16px * var(--inv-zoom)); pointer-events: stroke; cursor: pointer; }
[data-connector].selected .conn-hit { stroke: rgba(242, 84, 45, .25); }
.conn-temp { stroke: var(--accent); stroke-width: calc(2px * var(--inv-zoom)); stroke-dasharray: 6 5; }

/* ---------- Nota (caixa de texto divisível) ---------- */
.note {
  width: 100%; height: 100%; display: flex; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(31, 33, 37, .12);
}
.note.dark { color: var(--dark-ink); border-color: transparent; }
.note.dark .note-split > * + * { border-color: rgba(255, 255, 255, .18); }
.note.dark .note-cell[contenteditable="true"] { background: rgba(255, 255, 255, .06); }
.note-split { display: flex; flex: 1 1 0; min-width: 0; min-height: 0; }
.note-split.dir-row { flex-direction: row; }
.note-split.dir-col { flex-direction: column; }
.note-split.dir-row > * + * { border-left: 1.5px dashed rgba(31, 33, 37, .22); }
.note-split.dir-col > * + * { border-top: 1.5px dashed rgba(31, 33, 37, .22); }
.note-cell {
  flex: 1 1 0; min-width: 0; min-height: 0; padding: 12px 14px; overflow: hidden;
  font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; outline: none; cursor: default;
}
.note-cell[contenteditable="true"] {
  cursor: text; overflow: auto; user-select: text; -webkit-user-select: text;
  background: rgba(255, 255, 255, .5); box-shadow: inset 0 0 0 2px rgba(242, 84, 45, .45);
}
.note-cell:empty::before { content: ""; }
.note-cell p, .note-cell div { margin: 0; }
.note-cell ul, .note-cell ol { margin: 0; padding-left: 1.3em; }

/* ---------- Imagem / PDF ---------- */
.media-box { width: 100%; height: 100%; border-radius: 4px; overflow: hidden; box-shadow: var(--shadow-sm); background: #e9ebf1; }
.media { width: 100%; height: 100%; display: block; object-fit: fill; }
/* imagem carregada: sem caixa cinza nem sombra → PNG transparente fica transparente na lousa */
.item-image .media-box:not(.loading):not(.failed) { background: transparent; box-shadow: none; border-radius: 0; }
.loading, .pdf-sheet.loading { background: linear-gradient(100deg, #e9ebf1 30%, #f4f5f8 50%, #e9ebf1 70%) 0 0 / 300% 100%; animation: shimmer 1.4s infinite linear; }
.failed { background: #fff0f0; }
@keyframes shimmer { to { background-position: -100% 0; } }

.pdf { width: 100%; height: 100%; display: flex; flex-direction: column; background: #fff; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
.pdf-sheet { flex: 1; position: relative; overflow: hidden; background: #fff; }
.pdf-sheet .media { position: absolute; inset: 0; }
.pdf-sheet.rendering::after { content: ""; position: absolute; right: 10px; top: 10px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pdf-bar { height: 40px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 6px; border-top: 1px solid var(--line); font-size: 13px; }
.pdf-btn { min-width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; font-size: 18px; line-height: 1; }
.pdf-btn.wide { font-size: 13px; font-weight: 600; padding: 0 10px; background: var(--accent-soft); color: var(--accent); }
.pdf-btn:hover:not(:disabled) { background: var(--canvas); }
.pdf-page { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.pdf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); padding: 0 6px; }

/* ---------- Checklist ---------- */
.checklist {
  width: 100%; height: 100%; display: flex; flex-direction: column; gap: 8px; padding: 14px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line); overflow: hidden;
}
.cl-head { display: flex; align-items: center; gap: 8px; }
.cl-title { flex: 1; min-width: 0; border: 0; padding: 2px 0; font-weight: 700; font-size: 17px; background: transparent; outline: none; }
.cl-count { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.cl-progress { height: 4px; border-radius: 4px; background: var(--canvas); overflow: hidden; flex: none; }
.cl-progress span { display: block; height: 100%; background: #2fb36d; transition: width .25s; }
.cl-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.cl-list li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.cl-list input[type="checkbox"] { width: 18px; height: 18px; accent-color: #2fb36d; flex: none; cursor: pointer; }
.cl-text { flex: 1; min-width: 0; border: 0; padding: 4px 2px; background: transparent; outline: none; border-radius: 4px; }
.cl-text:focus { background: var(--canvas); }
.cl-list li.done .cl-text { text-decoration: line-through; color: var(--ink-soft); }
.cl-del { border: 0; background: transparent; color: var(--ink-soft); width: 26px; height: 26px; border-radius: 6px; font-size: 18px; opacity: 0; }
.cl-list li:hover .cl-del, .cl-del:focus { opacity: 1; }
.cl-del:hover { background: #fff0f0; color: var(--danger); }
.cl-add { flex: none; border: 1px dashed var(--line); background: transparent; border-radius: 8px; height: 34px; color: var(--ink-soft); font-weight: 600; }
.cl-add:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Calendário ---------- */
.calendar {
  width: 100%; height: 100%; display: grid; grid-template-rows: auto auto 1fr;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line);
  overflow: hidden; container-type: size;
}
.cal-head { display: flex; align-items: center; gap: 1cqw; padding: 1.4cqw 2cqw; cursor: grab; }
.cal-title { font-weight: 700; font-size: max(18px, 2.6cqw); letter-spacing: -.01em; }
.cal-nav {
  width: max(30px, 3.2cqw); height: max(30px, 3.2cqw); border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: max(16px, 1.8cqw); line-height: 1;
}
.cal-nav:first-child { order: 2; margin-left: auto; }
.cal-nav:last-child { order: 3; }
.cal-nav:hover { background: var(--canvas); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); }
.cal-weekdays div { padding: .6cqw 1cqw; font-size: max(12px, 1.2cqw); font-weight: 600; color: var(--ink-soft); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(var(--weeks, 5), 1fr); border-top: 1px solid var(--line); }
.cal-day { position: relative; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transition: background .15s; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: #fafbfc; }
.cal-num {
  position: absolute; left: .7cqw; top: .6cqw; min-width: max(24px, 2.6cqw); height: max(24px, 2.6cqw);
  padding: 0 .5cqw; border: 0; border-radius: 99px; background: transparent;
  font-size: max(13px, 1.45cqw); font-weight: 600; font-variant-numeric: tabular-nums;
}
.cal-num:hover:not(:disabled) { background: rgba(0, 0, 0, .07); }
.cal-day.out .cal-num { color: #b7bac6; opacity: 1; }
.cal-day.today .cal-num { background: var(--accent); color: #fff; }
.cal-day:not(.out) { cursor: text; }
/* texto escrito no dia (abaixo do número) */
.cal-text, .cal-edit {
  position: absolute; inset: calc(max(24px, 2.6cqw) + 1cqw) .6cqw .4cqw .9cqw;
  font: 500 max(11px, 1.25cqw)/1.3 Manrope, system-ui, sans-serif; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden;
}
.cal-edit { width: auto; height: auto; resize: none; border: 0; padding: 0; margin: 0; background: rgba(255, 255, 255, .6); outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; overflow: auto; }
.day-picker {
  position: absolute; left: .7cqw; top: calc(max(24px, 2.6cqw) + 1cqw); z-index: 5;
  display: grid; grid-template-columns: repeat(3, max(26px, 2.4cqw)); gap: 6px; padding: 8px;
  background: #fff; border-radius: 10px; box-shadow: var(--shadow);
}

/* ---------- Livro (capa na lousa) ---------- */
.book { width: 100%; height: 100%; display: flex; border-radius: 6px 12px 12px 6px; overflow: hidden; box-shadow: var(--shadow); background: var(--dark); color: #fff; }
.bk-spine { width: 14px; flex: none; background: linear-gradient(90deg, #0f1012, #2b2d33); }
.bk-cover { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 18px 16px; }
.bk-img { width: 100%; flex: 1; min-height: 0; object-fit: cover; border-radius: 6px; }
.bk-title { font-weight: 800; font-size: 22px; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.bk-cover .bk-img[hidden] + .bk-title { margin-top: auto; }
.bk-meta { font-size: 13px; color: #b9b6b0; }
.bk-open { margin-top: 6px; height: 36px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; }
.bk-open:hover { filter: brightness(1.08); }

/* ---------- Editor de livro ---------- */
/* tela cheia: esconde a lousa */
body.book-full .dock, body.book-full .menu, body.book-full .statusbar, body.book-full .chat, body.book-full .formatbar { display: none; }
.book-editor {
  position: fixed; inset: 0; z-index: 40; display: grid; grid-template-rows: auto auto minmax(0, 1fr);
  background: #ece9e4; container-type: inline-size;
}
/* metade da tela: livro à direita, lousa à esquerda continua funcionando */
body.book-half .book-editor { left: auto; width: var(--book-w, 50vw); box-shadow: -8px 0 30px rgba(0, 0, 0, .12); }
body.book-half .board { right: var(--book-w, 50vw); }
body.book-half .dock { left: calc((100vw - var(--book-w, 50vw)) / 2); max-width: calc(100vw - var(--book-w, 50vw) - 20px); }
body.book-half .dock-group:last-child, body.book-half .dock-label { display: none; } /* zoom continua na roda do mouse */
body.book-half .dock-btn.ai { padding: 0 12px; }
body.book-half .statusbar { right: calc(var(--book-w, 50vw) + 14px); }
body.book-half .chat { right: calc(var(--book-w, 50vw) + 14px); }
.be-splitter { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 3; }
.be-splitter::after { content: ""; position: absolute; left: 4px; top: 50%; width: 3px; height: 48px; margin-top: -24px; border-radius: 3px; background: #c9c4bc; }
.be-splitter:hover::after { background: var(--accent); }
body.book-full .be-splitter { display: none; }
@container (max-width: 980px) {
  .be-main { grid-template-columns: minmax(0, 1fr) !important; }
  .be-toc { display: none; }
}
@container (max-width: 700px) {
  .be-field { font-size: 0; gap: 4px; }           /* esconde os rótulos, mantém os controles */
  .be-tool { padding: 0 6px; }
}
.be-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.be-title { flex: 1; min-width: 160px; border: 0; font-size: 20px; font-weight: 800; outline: none; background: transparent; }
.be-field { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.be-step { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 18px; line-height: 1; }
.be-step:hover { border-color: var(--accent); color: var(--accent); }
.be-count { min-width: 22px; text-align: center; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.be-top .btn.primary { display: flex; align-items: center; gap: 6px; }
.be-top .btn .icon { width: 18px; height: 18px; }
.be-toolbar { display: flex; align-items: center; gap: 2px; padding: 6px 12px; background: var(--dark); color: var(--dark-ink); flex-wrap: wrap; }
.be-tool { height: 34px; min-width: 34px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 14px; font-weight: 600; }
.be-tool:hover { background: var(--dark-2); }
.be-tool .icon { width: 19px; height: 19px; }
.be-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .15); margin: 0 6px; }
.be-menu-wrap { position: relative; }
.be-menu { position: absolute; left: 0; top: calc(100% + 6px); z-index: 5; background: #fff; color: var(--ink); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 210px; }
.be-menu[hidden] { display: none; }
.be-menu button { text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 7px; font-size: 14px; }
.be-menu button:hover { background: var(--canvas); }
.be-main { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; }
.be-toc { border-right: 1px solid var(--line); background: #f6f4f1; overflow: auto; padding: 14px 10px; }
.be-toc-head { font-weight: 800; padding: 0 8px 8px; }
.be-toc-list, .be-toc-preview { display: grid; gap: 1px; }
.be-toc-list button, .be-toc-preview button { text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: 7px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.be-toc-list button:hover, .be-toc-preview button:hover { background: var(--accent-soft); color: var(--accent); }
.toc-l1 { font-weight: 700; }
.toc-l2 { padding-left: 22px !important; color: var(--ink-soft); }
.toc-l3 { padding-left: 36px !important; color: var(--ink-soft); font-size: 13px !important; }
/* folhas com tamanho FIXO do formato (o zoom só muda a visualização) */
.be-pages { overflow: auto; padding: 24px 24px 80px; scrollbar-gutter: stable; }
.be-zoom { margin: 0 auto; position: relative; }
.be-zoom-inner { width: var(--page-w); transform-origin: 0 0; display: grid; gap: 28px; }
.be-chapters { display: grid; gap: 28px; }
.be-sheet {
  width: var(--page-w); min-height: var(--page-h); box-sizing: border-box; position: relative;
  padding: var(--m-top) var(--m-side) var(--m-bottom);
  background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); display: flex; flex-direction: column; gap: 10px;
}
/* altura = nº de páginas × altura da página (JS). "clip" e não "hidden": hidden deixava a folha rolar sozinha ao digitar */
.be-sheet.be-chapter { display: block; min-height: 0; overflow: clip; }
/* faixas invisíveis que fazem o texto pular as margens entre páginas (ver paginate.js) */
.pg-bands { height: 0; }
.pg-spacer { float: left; clear: left; width: 0; }
.pg-band { float: left; clear: left; width: 100%; }
.pg-chrome { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.pg-gap { position: absolute; left: 0; right: 0; height: 14px; background: #ece9e4; box-shadow: inset 0 4px 5px -4px rgba(0, 0, 0, .3), inset 0 -4px 5px -4px rgba(0, 0, 0, .3); }
.pg-num { position: absolute; left: 0; right: 0; text-align: center; font: 11.25px RobotoPDF, Roboto, sans-serif; color: #a3a09a; }
.be-sheet-head, .be-ch-title, .be-body, .be-chapter .be-sheet-label { position: relative; z-index: 1; }
.be-body { background: transparent; }
.be-floats { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: clip; }
.be-float { position: absolute; height: auto; user-select: none; -webkit-user-select: none; }
.be-float.broken { min-width: 60px; min-height: 60px; background: #fff0f0; }
/* modo "Mover imagens": imagens por cima e clicáveis, texto fica transparente e travado */
.book-editor.arrange .be-floats { z-index: 2; pointer-events: auto; }
.book-editor.arrange .be-body, .book-editor.arrange .be-ch-title { pointer-events: none; opacity: .45; }
.book-editor.arrange .be-float { cursor: grab; outline: 2px dashed rgba(242, 84, 45, .55); outline-offset: 2px; }
.book-editor.arrange .be-float.selected { outline: 3px solid var(--accent); }
.book-editor.arrange .be-float.dragging { cursor: grabbing; opacity: .85; }
.be-tool.on { background: var(--accent); color: #fff; }
.be-menu-label { font-size: 12px; font-weight: 700; color: var(--ink-soft); padding: 8px 10px 2px; }
.float-panel {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: calc(100% - 24px);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px;
}
.float-panel[hidden] { display: none; }
.pos-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 10px; border-left: 1px solid var(--line); }
.pos-field { display: flex; align-items: center; gap: 4px; }
.pos-number { width: 62px; }
/* barrinha de tamanho */
.size-control { display: flex; align-items: center; gap: 8px; }
.size-label { font-size: 13px; font-weight: 600; }
.size-range { width: 160px; accent-color: var(--accent); }
.size-number { width: 64px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font-size: 14px; text-align: right; }
.size-unit { font-size: 13px; color: var(--ink-soft); }
.img-tools .size-control { color: #fff; padding: 0 6px; }
.img-tools .size-unit { color: #cfcac3; }
.img-tools .size-number { background: #fff; color: var(--ink); }
.be-mini { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.be-mini:disabled { opacity: .3; }
.be-mini.danger:hover { color: var(--danger); border-color: var(--danger); }
.be-body:empty::before { content: attr(data-placeholder); color: #b5b2ac; }
.be-body img:hover { outline: 3px solid var(--accent-soft); }
.be-body img.broken { min-height: 60px; background: #fff0f0; }
.be-cover { align-items: center; justify-content: center; text-align: center; height: var(--page-h); }
/* Texto com as mesmas medidas do PDF (Roboto; 1pt = 1,25px; espaçamentos iguais) */
.be-sheet-label { font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--accent); }
.be-chapter .be-sheet-label { display: block; font: 700 12.5px/19.75px RobotoPDF, Roboto, sans-serif; letter-spacing: 1.25px; }
.be-ch-title { display: block; width: 100%; border: 0; outline: none; padding: 0; background: transparent; font: 700 30px/1.287 RobotoPDF, Roboto, sans-serif; margin: 5px 0 20px; color: var(--ink); }
.be-body { outline: none; font: 13.75px/1.58 RobotoPDF, Roboto, sans-serif; font-kerning: none; font-variant-ligatures: none; color: #1f2125; overflow-wrap: anywhere; min-height: 22px;
  white-space: pre-wrap; tab-size: 44.29px; } /* Tab = recuo de 1,25 cm (44,29px = 35,43pt × 1,25) */
.be-body p { margin: 0 0 7.5px; }
.be-body a { color: #1a5fb4; text-decoration: underline; cursor: text; } /* Ctrl+clique abre */
.be-body.ctrl a { cursor: pointer; }
.be-body h2 { font-size: 20px; line-height: 1.58; margin: 15px 0 7.5px; }
.be-body h3 { font-size: 16.25px; line-height: 1.58; margin: 12.5px 0 5px; }
.be-body ul, .be-body ol { margin: 0 0 7.5px; padding-left: 1.4em; }
.be-body img { display: block; margin: 7.5px auto 12.5px; max-width: 100%; max-height: var(--content-h); height: auto; cursor: pointer; }
.be-body hr.page-break { display: block; border: 0; border-top: 2px dashed #d6d2cb; margin: 0; box-sizing: border-box; }
.be-sheet-head { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; gap: 4px; opacity: .35; transition: opacity .15s; }
.be-sheet:hover .be-sheet-head { opacity: 1; }
.be-cover-img { max-width: 70%; max-height: 360px; object-fit: contain; }
.be-cover-img[hidden] { display: none; }
.be-cover-title { font-size: 34px; font-weight: 800; line-height: 1.1; }
.be-author { border: 0; outline: none; text-align: center; font-size: 18px; color: var(--ink-soft); width: 100%; }
.be-cover-actions { display: flex; gap: 8px; margin-top: 18px; }
.be-toc-preview .muted { color: var(--ink-soft); margin: 0; }
.img-tools { position: fixed; z-index: 65; display: flex; align-items: center; gap: 4px; background: var(--dark); padding: 5px; border-radius: 10px; box-shadow: var(--shadow); }
.img-tools button { border: 0; background: transparent; color: #fff; padding: 6px 10px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.img-tools button:hover, .img-tools button.on { background: var(--accent); }
.img-tools button.danger:hover { background: var(--danger); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; overflow: auto; padding: 4px; }
.pick { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px; display: grid; gap: 6px; font-size: 13px; text-align: left; }
.pick:hover { border-color: var(--accent); }
.pick img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--canvas); }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 800px) { .be-main { grid-template-columns: minmax(0, 1fr); } .be-toc { display: none; } }

/* corretor (LanguageTool) */
::highlight(lt-erro) { text-decoration: underline wavy #e5484d; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
::highlight(lt-aviso) { text-decoration: underline wavy #e8a300; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.be-spell-status { font-size: 12px; color: #cfcac3; padding: 0 6px; }
.be-lt-link { margin-left: auto; font-size: 12px; color: #a9a49c; text-decoration: none; padding: 0 6px; }
.be-lt-link:hover { color: #fff; text-decoration: underline; }
.lt-pop {
  position: fixed; z-index: 80; width: 320px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; font-size: 14px;
}
.lt-msg { color: var(--ink); line-height: 1.4; }
.lt-sugs { display: flex; flex-wrap: wrap; gap: 6px; }
.lt-sug { border: 0; background: var(--accent); color: #fff; font-weight: 700; border-radius: 8px; padding: 6px 10px; }
.lt-sug:hover { filter: brightness(1.08); }
.lt-none { color: var(--ink-soft); font-size: 13px; }
.lt-actions { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.lt-actions button { border: 0; background: transparent; color: var(--ink-soft); font-weight: 600; font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.lt-actions button:hover { background: var(--canvas); color: var(--ink); }

/* desenho */
.draw-modal { z-index: 75; }
.draw-box { width: min(1200px, 96vw); background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; }
.draw-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.draw-group { display: flex; gap: 4px; align-items: center; }
.draw-size { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: grid; place-items: center; }
.draw-size span { display: block; border-radius: 50%; background: var(--ink); }
.draw-size.on, .draw-tools .btn.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.draw-tools .swatch.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.spacer { flex: 1; }
.draw-paper { background: repeating-conic-gradient(#f3f1ee 0% 25%, #fff 0% 50%) 0 0 / 24px 24px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.draw-canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }

/* ---------- Comentários ---------- */
.comments {
  width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line); overflow: hidden;
}
.cm-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); background: #faf7f3; }
.cm-title { width: 100%; border: 0; background: transparent; font-weight: 700; font-size: 16px; outline: none; }
.cm-list { list-style: none; margin: 0; padding: 10px 14px; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.cm-empty { color: var(--ink-soft); font-size: 14px; }
.cm-meta { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.cm-meta time { color: var(--ink-soft); }
.cm p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.cm-del { margin-left: auto; border: 0; background: transparent; color: var(--ink-soft); border-radius: 5px; }
.cm-del:hover { color: var(--danger); background: #fff0f0; }
.cm-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.cm-input { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; outline: none; }
.cm-input:focus { border-color: var(--accent); }
.cm-send { border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; padding: 0 14px; }

/* ---------- Menu da logo (canto superior esquerdo) ---------- */
.menu { position: fixed; left: 14px; top: 14px; z-index: 30; }
.menu-logo {
  width: 46px; height: 46px; border-radius: 14px; border: 0; padding: 0;
  display: grid; place-items: center; background: transparent; box-shadow: var(--shadow);
  transition: transform .12s;
}
.menu-logo .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
.menu-logo:hover, .menu-logo[aria-expanded="true"] { transform: scale(1.05); }
.menu-panel {
  position: absolute; left: 0; top: calc(100% + 8px); width: 290px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 10px; display: grid; gap: 4px; animation: drop .14s ease-out;
}
.menu-panel[hidden] { display: none; }
.menu-panel::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; } /* ponte para o mouse */
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
.menu-title { font-weight: 800; font-size: 18px; letter-spacing: -.02em; padding: 4px 8px 6px; }
.menu-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 4px 8px; }
.menu-boards { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.menu-board, .menu-action {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 40px; padding: 6px 8px; border: 0; border-radius: 9px; background: transparent; font-size: 15px;
}
.menu-board:hover, .menu-action:hover { background: var(--canvas); }
.menu-board.on { background: var(--accent-soft); font-weight: 700; }
.menu-board-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--line); flex: none; }
.menu-board.on .menu-board-dot { background: var(--accent); }
.menu-board-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-action .icon { width: 20px; height: 20px; color: var(--ink-soft); }
.menu-actions { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; display: grid; gap: 2px; }
.menu-help { padding: 4px 8px 8px 38px; font-size: 13px; color: var(--ink-soft); display: grid; gap: 6px; }
.menu-help[hidden] { display: none; }
.menu-help p { margin: 0; }
.menu-user { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; display: grid; gap: 2px; }
.menu-user-info { display: flex; align-items: center; gap: 10px; padding: 4px 8px 6px; min-width: 0; }
.menu-user-info > div { min-width: 0; }
.menu-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--dark); color: #fff; font-weight: 700;
}
.menu-user-name { font-weight: 700; }
.menu-user-email { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Selo de status (canto superior direito) ---------- */
.statusbar {
  position: fixed; right: 14px; top: 14px; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 99px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(6px);
  border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.statusbar::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2fb36d; }
.statusbar[data-state="saving"]::before { background: #f0b400; }
.statusbar[data-state="error"] { color: var(--danger); }
.statusbar[data-state="error"]::before { background: var(--danger); }
.online:not(:empty) { color: var(--ink); padding-left: 8px; border-left: 1px solid var(--line); }

/* ---------- Dock (embaixo, no centro) ---------- */
.dock {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: var(--dark); color: var(--dark-ink); border-radius: 18px; box-shadow: var(--shadow);
  max-width: calc(100vw - 16px);
}
.dock-group { display: flex; align-items: center; gap: 2px; }
.dock-group + .dock-group { padding-left: 6px; border-left: 1px solid rgba(255, 255, 255, .12); }
.dock-btn, .dock-pct {
  position: relative; height: 44px; min-width: 44px; border: 0; border-radius: 12px;
  background: transparent; color: inherit; display: grid; place-items: center;
}
.dock-btn:hover, .dock-pct:hover { background: var(--dark-2); }
.dock-group:first-child .dock-btn:hover { color: #fff; background: var(--accent); }
.dock-pct { min-width: 58px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dock-tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: var(--dark); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap;
  padding: 5px 9px; border-radius: 7px; pointer-events: none; opacity: 0; transition: opacity .12s;
}
.dock-btn:hover .dock-tip, .dock-pct:hover .dock-tip { opacity: 1; }
.icon { display: inline-grid; width: 22px; height: 22px; }
.icon svg { width: 100%; height: 100%; }

/* ---------- Barra flutuante ---------- */
.formatbar {
  position: fixed; left: 0; top: 0; z-index: 25; display: flex; align-items: center; gap: 2px; padding: 5px;
  background: var(--dark); color: var(--dark-ink); border-radius: 14px; box-shadow: var(--shadow);
  max-width: calc(100vw - 16px); flex-wrap: wrap;
}
.formatbar[hidden] { display: none; }
.fb-group { display: flex; align-items: center; gap: 2px; padding: 0 4px; }
.fb-group + .fb-group { border-left: 1px solid rgba(255, 255, 255, .12); }
.fb-btn {
  min-width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: inherit;
  display: grid; place-items: center; padding: 0 6px;
}
.fb-btn .icon { width: 20px; height: 20px; }
.fb-btn:hover:not(:disabled) { background: var(--dark-2); }
.fb-btn.on { background: var(--accent); color: #fff; }
.fb-btn.letter { font-size: 15px; font-weight: 600; }
.fb-btn.letter.b { font-weight: 800; }
.fb-btn.letter.u { text-decoration: underline; }
.fb-btn.letter.s { text-decoration: line-through; }
.fb-btn.letter.big { font-size: 17px; }
.swatch {
  width: 22px; height: 22px; border-radius: 7px; border: 1px solid rgba(0, 0, 0, .14); padding: 0; margin: 0 1px;
}
.swatch.small { width: 18px; height: 18px; }
.fb-btn.clear-marks { font-size: 12px; font-weight: 700; padding: 0 8px; }
.swatch.on { box-shadow: 0 0 0 2px var(--dark), 0 0 0 4px var(--accent); }
.day-picker .swatch.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.swatch.none { background: #fff; color: var(--ink-soft); font-size: 13px; line-height: 1; }
.day-picker .swatch { width: 100%; height: auto; aspect-ratio: 1; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; font-weight: 500; animation: rise .2s ease-out; max-width: min(520px, 90vw); }
.toast.out { opacity: 0; transition: opacity .25s; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Janelas ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(20, 22, 40, .35); }
.dialog { width: min(420px, 92vw); background: #fff; border-radius: 14px; padding: 22px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.field { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 16px; outline: none; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Assistente ---------- */
.dock-btn.ai { display: flex; gap: 8px; padding: 0 14px; background: var(--accent); color: #fff; }
.dock-btn.ai:hover { background: #ff6a47; }
.dock-label { font-weight: 700; font-size: 14px; }
.chat {
  position: fixed; right: 14px; top: 14px; bottom: 14px; width: min(400px, calc(100vw - 28px)); z-index: 26;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line);
  animation: slide .16s ease-out;
}
.chat[hidden] { display: none; }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } }
body.chat-open .statusbar { right: 428px; }
body.chat-open .dock { left: calc(50% - 207px); }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; margin-right: auto; }
.chat-title .icon { color: var(--accent); }
.chat-model { font-size: 12px; font-weight: 600; color: var(--ink-soft); background: var(--canvas); padding: 3px 8px; border-radius: 99px; }
.chat-icon-btn { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; display: grid; place-items: center; color: var(--ink-soft); }
.chat-icon-btn:hover { background: var(--canvas); color: var(--ink); }
.chat-icon-btn .icon { width: 19px; height: 19px; }
.chat-log { overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 13px; border-radius: 14px; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.msg ul { margin: 4px 0; padding-left: 1.2em; }
.msg.user { align-self: flex-end; background: var(--dark); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--canvas); border-bottom-left-radius: 4px; }
.msg.error { align-self: stretch; background: #fff0f0; color: var(--danger); font-weight: 600; }
.msg.thinking { align-self: flex-start; background: var(--canvas); display: flex; gap: 5px; padding: 13px 14px; }
.msg.thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); animation: blink 1s infinite; }
.msg.thinking span:nth-child(2) { animation-delay: .15s; } .msg.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; } }
.chip { align-self: flex-start; font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 4px 10px; border: 1px dashed var(--line); border-radius: 99px; }
.chip::before { content: "✓ "; color: #2fb36d; }
.chip.note { border-style: solid; } .chip.note::before { content: "↻ "; color: var(--ink-soft); }
.msg.error .retry { display: block; margin-top: 8px; border: 1px solid currentColor; background: #fff; color: var(--danger); border-radius: 8px; padding: 5px 10px; font-weight: 700; font-size: 13px; }
.chip.error { color: var(--danger); border-color: #f3c2c3; } .chip.error::before { content: "! "; color: var(--danger); }
.chat-welcome { color: var(--ink); display: grid; gap: 8px; }
.chat-welcome p { margin: 0; } .chat-welcome .muted { color: var(--ink-soft); font-size: 14px; }
.chat-suggest { display: grid; gap: 6px; margin-top: 6px; }
.chat-suggest button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.chat-suggest button:hover { border-color: var(--accent); color: var(--accent); }
.chat-foot { border-top: 1px solid var(--line); padding: 8px 10px 10px; display: grid; gap: 6px; }
.chat-sel { font-size: 12px; font-weight: 600; color: var(--accent); min-height: 0; }
.chat-sel:empty { display: none; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; }
.chat-input { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 15px; outline: none; max-height: 160px; }
.chat-input:focus { border-color: var(--accent); }
.chat-send { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.chat-send:disabled { opacity: .5; }
.chat-send.stop { background: var(--dark); }
.stop-square { width: 14px; height: 14px; border-radius: 3px; background: #fff; }
@media (max-width: 900px) { body.chat-open .dock { display: none; } body.chat-open .statusbar { display: none; } }

/* instruções do assistente */
.chat-settings { overflow: auto; padding: 16px; display: grid; gap: 10px; align-content: start; }
.chat-settings[hidden], .chat-log[hidden] { display: none; }
.chat-settings h3 { margin: 0; font-size: 17px; }
.chat-settings .muted { margin: 0; color: var(--ink-soft); font-size: 14px; }
.instr-input { width: 100%; resize: vertical; min-height: 220px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.5; outline: none; }
.instr-input:focus { border-color: var(--accent); }
.instr-meta { margin: 0; font-size: 12px; color: var(--ink-soft); }
.instr-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Compartilhar ---------- */
.share-sub { margin: 0; color: var(--ink-soft); font-size: 14px; }
.share-form { display: flex; gap: 8px; }
.share-form .field { flex: 1; }
.share-form .btn { height: 44px; }
.share-result { background: #f2faf4; border: 1px solid #cfe9d6; border-radius: 12px; padding: 12px; display: grid; gap: 8px; font-size: 14px; }
.share-result[hidden] { display: none; }
.share-result p { margin: 0; }
.share-msg { width: 100%; resize: none; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 13px/1.5 Manrope, system-ui, sans-serif; background: #fff; }
.share-h { margin: 6px 0 0; font-size: 14px; }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 220px; overflow: auto; }
.share-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.share-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-role { color: var(--ink-soft); font-size: 13px; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.menu-tag { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--ink-soft); background: var(--canvas); padding: 2px 7px; border-radius: 99px; flex: none; }

/* ---------- Itens apagados ---------- */
.dialog.wide { width: min(860px, 94vw); max-height: 84vh; grid-template-rows: auto minmax(0, 1fr); }
.dialog-head { display: flex; align-items: center; gap: 10px; }
.dialog-head h2 { margin-right: auto; }
.field.small { height: 36px; width: auto; font-size: 14px; }
.trash-list { list-style: none; margin: 0; padding: 0; overflow: auto; border-top: 1px solid var(--line); }
.trash-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 200px) auto; gap: 14px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.trash-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-meta, .trash-when { font-size: 13px; color: var(--ink-soft); }
.trash-when { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trash-who { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-na { color: var(--ink-soft); text-align: center; min-width: 90px; }
.trash-empty { padding: 20px 4px; color: var(--ink-soft); }
@media (max-width: 640px) {
  .trash-row { grid-template-columns: minmax(0, 1fr) auto; }
  .trash-who { grid-column: 1; }
}

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background-color: var(--canvas);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}
.login-card { width: min(380px, 100%); background: #fff; border-radius: 18px; padding: 30px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-sub { margin: 0 0 6px; color: var(--ink-soft); }
.login-error { margin: 0; color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- Telas pequenas ---------- */
@media (max-width: 720px) {
  .dock { gap: 2px; padding: 4px; }
  .dock-group:last-child { display: none; }
  .dock-btn { min-width: 40px; height: 40px; }
  .dock-tip { display: none; }
  .statusbar .online { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* =====================================================================
   EDITOR DE LIVRO "DE VIDRO"
   Só a folha do capítulo onde está o cursor fica acesa. O resto (topo,
   sumário, outras folhas, fundo) fica transparente como vidro e acende
   quando o mouse passa por cima. A barra de ferramentas fica sempre visível.
   ===================================================================== */
.book-editor {
  background: rgba(18, 32, 26, .38);
  backdrop-filter: blur(10px) saturate(1.1); -webkit-backdrop-filter: blur(10px) saturate(1.1);
}
body.book-half .book-editor { box-shadow: -8px 0 30px rgba(0, 0, 0, .3); border-left: 1px solid rgba(255, 255, 255, .12); }
/* topo (fechar, tela cheia, nome, formato, extrair) e sumário: vidro */
.be-top, .be-toc {
  background: rgba(255, 255, 255, .10); border-color: rgba(255, 255, 255, .12);
  transition: background .2s, opacity .2s; opacity: .5;
}
.be-top:hover, .be-top:focus-within, .be-toc:hover {
  background: rgba(255, 255, 255, .82); opacity: 1;
}
.be-top:not(:hover):not(:focus-within) .be-title, .be-toc:not(:hover) { color: #f4f1e8; }
.be-top:not(:hover):not(:focus-within) .be-field { color: rgba(244, 241, 232, .85); }
/* no modo vidro os botões e caixas viram só contorno de giz */
.be-top:not(:hover):not(:focus-within) :is(.btn.ghost, select, .be-step, .be-count) {
  background: transparent; color: #f4f1e8; border-color: rgba(244, 241, 232, .35);
}
.be-top { opacity: 1; }
.be-top:not(:hover):not(:focus-within) > * { opacity: .6; transition: opacity .2s; }
/* barra de ferramentas (Texto, Subtítulo, B, I...) sempre visível */
.be-toolbar { background: rgba(31, 33, 37, .9); position: relative; z-index: 2; }
.be-pages { background: transparent; }
.be-splitter::after { background: rgba(255, 255, 255, .35); }
/* folhas: só a do capítulo ativo acesa */
.be-sheet { transition: opacity .25s, box-shadow .25s; }
.book-editor .be-sheet:not(.active) { opacity: .42; }
.book-editor .be-sheet:not(.active):hover { opacity: .8; }
.book-editor .be-sheet.active { box-shadow: 0 0 0 1px rgba(255, 255, 255, .25), 0 10px 40px rgba(0, 0, 0, .45); }
.pg-gap { background: rgba(36, 57, 47, .85); }
