/* Margem — identidade visual própria (não derivada do LiquidText). */
:root {
  --bg: #f4f2ee; --panel: #ffffff; --panel-2: #faf9f6; --line: #e3dfd7; --text: #1e1f24; --muted: #6b6f78;
  --accent: #2f5bd3; --accent-2: #e6ecfc; --danger: #c62828; --ok: #2e7d32; --shadow: 0 6px 24px rgba(20, 22, 30, .14);
  --pdf-bg: #d9d5cc; --card: #ffffff; --left-w: 280px; --right-w: 420px; --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #16171b; --panel: #1f2026; --panel-2: #24262d; --line: #33353e; --text: #e8e8ec; --muted: #9a9daa;
  --accent: #7aa2ff; --accent-2: #26304a; --pdf-bg: #2a2b31; --card: #272930; --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--font); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 5px 10px; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); } button.danger.primary { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: 2px 8px; font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=url], select { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 5px 8px; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .pad { padding: 10px; } .mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
.sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.grow { flex: 1; }
.tb { padding: 4px 8px; background: transparent; border-color: transparent; border-radius: 6px; white-space: nowrap; }
.tb:hover { background: var(--accent-2); }
.tb.primary { background: var(--accent); color: #fff; }

.app { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.warn-bar { background: #fff3cd; color: #6b4e00; padding: 6px 12px; font-size: 13px; }
.topbar { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 8px; height: 44px; padding: 0 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.hb-left, .hb-right { display: flex; align-items: center; gap: 2px; min-width: 0; }
.hb-right { justify-content: flex-end; }
.doc-title { border: none; background: none; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; padding: 4px 6px; border-radius: 6px; }
.doc-title:hover { background: var(--accent-2); }
.ib { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; background: transparent; border-radius: 8px; color: var(--text); position: relative; }
.ib:hover { background: var(--accent-2); }
.ib.on, .ib[aria-expanded="true"] { background: var(--accent-2); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.ib.active::after { content: ''; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.tools { display: flex; gap: 1px; align-items: center; }
.tool { min-width: 0; }
.sync-ind { position: relative; display: inline-grid; place-items: center; width: 28px; height: 32px; padding: 0; border: none; background: none; }
.sync-ind .sync-count { position: absolute; top: 2px; right: -2px; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 7px; background: currentColor; font-size: 9px; line-height: 14px; font-weight: 600; text-align: center; }
.sync-ind .sync-count { color: #fff; background: #b26a00; }
.sync-ind.st-syncing .dot { animation: syncpulse 1s ease-in-out infinite; }
@keyframes syncpulse { 50% { opacity: .3; } }
.settings .conflict { border-top: 1px solid var(--line, #ddd); padding: 6px 0; font-size: 13px; }
.settings .transfers .err { color: var(--danger); }
.sync-ind .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.sync-ind.st-synced { color: var(--ok); } .sync-ind.st-error { color: var(--danger); } .sync-ind.st-conflict { color: #c2410c; }
.sync-ind.st-pending, .sync-ind.st-syncing { color: #b26a00; } .sync-ind.st-offline, .sync-ind.st-disabled { color: #b8b8b8; }
.tool-opts { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 35; display: flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.tool-opts[hidden] { display: none; }

/* popover / menus compactos */
.popover { position: fixed; z-index: 70; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; max-width: min(380px, 96vw); max-height: 80dvh; overflow: auto; }
.menu-list { display: flex; flex-direction: column; min-width: 220px; }
.menu-item { display: flex; align-items: center; gap: 10px; border: none; background: none; padding: 7px 10px; border-radius: 6px; text-align: left; width: 100%; }
.menu-item:hover, .menu-item.on { background: var(--accent-2); }
.menu-item span { flex: 1; } .menu-item kbd { font-size: 11px; color: var(--muted); font-family: inherit; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.menu-pad { padding: 4px 6px; } .menu-pad input { width: 100%; }
.menu-colors { display: flex; gap: 6px; padding: 4px; }
.flat-panel { display: flex; flex-direction: column; gap: 10px; padding: 6px; font-size: 13px; min-width: 300px; }
.fp-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fp-label { width: 58px; color: var(--muted); font-size: 12px; }
.fp-row input[type=range] { flex: 1; accent-color: var(--accent); }
.drawer-head { display: flex; justify-content: flex-end; gap: 2px; padding: 4px 4px 0; }

.flat-group, .filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.flat-group input[type=range] { width: 140px; accent-color: var(--accent); }
.flat-val { width: 38px; font-variant-numeric: tabular-nums; }
.chip { border-radius: 20px; padding: 2px 9px; font-size: 12px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.color-chip { width: 22px; height: 22px; border-radius: 50%; padding: 0; background: var(--c); border: 2px solid transparent; }
.color-chip.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel) inset; }

.panes { display: grid; grid-template-columns: 0 0 1fr 6px var(--right-w); min-height: 0; position: relative; }
.panes > .resizer:nth-of-type(1) { grid-column: 2; } .pane-center { grid-column: 3; } .panes > .resizer:nth-of-type(2) { grid-column: 4; } .pane-right { grid-column: 5; } .panes { grid-template-rows: 100%; }
.pane-center, .pane-right, .panes > .resizer { grid-row: 1; }
/* biblioteca como gaveta sobreposta; "fixar" a encaixa ao lado (interface completa) */
.pane-left { position: absolute; z-index: 45; top: 0; bottom: 0; left: 0; width: var(--left-w); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 0 0 0 1px var(--line), 6px 0 24px rgba(0,0,0,.12); visibility: hidden; }
.app.show-left .pane-left { transform: none; visibility: visible; }
.app.dock-left .pane-left { position: relative; grid-column: 1; grid-row: 1; transform: none; box-shadow: none; transition: none; visibility: visible; }
.app.dock-left .panes { grid-template-columns: var(--left-w) 6px 1fr 6px var(--right-w); }
.panes > .resizer:nth-of-type(1) { visibility: hidden; } .app.dock-left .panes > .resizer:nth-of-type(1) { visibility: visible; }
.app.hide-right .panes { grid-template-columns: 0 0 1fr 0 0; }
.app.dock-left.hide-right .panes { grid-template-columns: var(--left-w) 6px 1fr 0 0; }
.app.hide-center .panes { grid-template-columns: 0 0 0 0 1fr; }
.app.dock-left.hide-center .panes { grid-template-columns: var(--left-w) 6px 0 0 1fr; }
.app.hide-right .pane-right, .app.hide-center .pane-center, .app.hide-center .panes > .resizer:nth-of-type(2), .app.hide-right .panes > .resizer:nth-of-type(2) { visibility: hidden; }
.app.reader-full .panes { grid-template-columns: 0 0 1fr 0 0 !important; }
.app.reader-full .pane-right, .app.reader-full .resizer, .app.reader-full .topbar { display: none; }
.app.reader-full .pane-left:not(.x) { visibility: hidden; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); overflow: hidden; position: relative; }
.resizer { background: var(--line); cursor: col-resize; touch-action: none; }
.resizer:hover { background: var(--accent); }

/* ---------- painel esquerdo ---------- */
.left-tabs { display: flex; border-bottom: 1px solid var(--line); }
.left-tabs button { flex: 1; border: none; border-radius: 0; background: transparent; padding: 8px 2px; font-size: 13px; border-bottom: 2px solid transparent; }
.left-tabs button.active { border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { flex: 1; overflow: auto; display: flex; flex-direction: column; min-height: 0; }
.tab-body[hidden] { display: none; }
.lib-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
.lib-search { display: flex; gap: 4px; padding: 0 8px 6px; } .lib-search input { flex: 1; }
.lib-tree { max-height: 34%; overflow: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 0; flex-shrink: 0; }
.tree-row { display: flex; align-items: center; gap: 2px; padding: 3px 6px; cursor: pointer; border-radius: 6px; margin: 0 4px; }
.tree-row:hover { background: var(--panel-2); } .tree-row.active { background: var(--accent-2); font-weight: 600; }
.tree-row.drop-hover, .lib-row.drop-hover, .pane-left.drop-hover { outline: 2px dashed var(--accent); }
.twisty { border: none; background: none; width: 18px; padding: 0; color: var(--muted); }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 11px; }
.crumbs { padding: 6px 10px; font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.crumb { border: none; background: none; padding: 0 2px; color: var(--accent); }
.lib-sort { display: flex; gap: 4px; padding: 0 8px 6px; } .lib-sort select { flex: 1; }
.lib-list { flex: 1; overflow: auto; padding: 0 6px 12px; outline: none; }
.lib-row { padding: 6px 8px; border-radius: 7px; cursor: default; user-select: none; border: 1px solid transparent; }
.lib-row:hover { background: var(--panel-2); } .lib-row.selected { background: var(--accent-2); border-color: var(--accent); }
.lib-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta { font-size: 11.5px; }
.view-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; align-content: start; }
.view-thumbs .lib-row { text-align: center; } .thumb { width: 100%; height: 120px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.trash-bar { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 6px; font-size: 12px; grid-column: 1 / -1; }
.empty-list { padding: 16px 8px; text-align: center; }
.toc-item, .search-hit { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; border: none; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 6px 8px; }
.search-hit { display: block; font-size: 12.5px; }
.hl-head { display: flex; justify-content: space-between; align-items: center; padding: 8px; gap: 6px; }
.hl-item { border-left: 4px solid; margin: 4px 8px; padding: 4px 8px; background: var(--panel-2); border-radius: 0 6px 6px 0; }
.hl-text { border: none; background: none; text-align: left; padding: 0; font-size: 13px; }
.hl-meta { font-size: 11.5px; display: flex; justify-content: space-between; gap: 6px; }
.chk { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; }

/* ---------- leitor ---------- */
.doc-tabs { display: flex; gap: 2px; padding: 4px 6px 0; background: var(--panel-2); overflow-x: auto; min-height: 6px; }
.doc-tab { display: flex; align-items: center; border: 1px solid var(--line); border-bottom: none; border-radius: 7px 7px 0 0; background: var(--panel-2); max-width: 220px; }
.doc-tab.active { background: var(--panel); font-weight: 600; }
.doc-tab-name { border: none; background: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 8px; }
.doc-tab-close { border: none; background: none; padding: 2px 6px; color: var(--muted); }
.reader-toolbar.hud { position: absolute; z-index: 30; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 1px; padding: 3px 6px; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); opacity: .55; transition: opacity .15s; max-width: calc(100% - 20px); }
.reader-toolbar.hud:hover, .reader-toolbar.hud:focus-within { opacity: 1; }
.reader-toolbar .tb { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 50%; }
.reader-toolbar .rot90 svg { transform: rotate(90deg); }
.reader-toolbar .page-input { width: 38px; border: none; background: transparent; font-variant-numeric: tabular-nums; }
.hud-more { display: inline-flex; } .hud-more[hidden] { display: none; }
.doc-tabs[hidden] { display: none; }
.page-nav { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.page-nav .muted { white-space: nowrap; }
.page-input { width: 46px; text-align: center; }
.zoom-label { font-size: 12px; width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.pdf-scroller { flex: 1; overflow: auto; background: var(--pdf-bg); position: relative; outline: none; overscroll-behavior: contain; }
.pane-center:not(.has-doc) .pdf-scroller, .pane-center:not(.has-doc) .reader-toolbar { display: none; }
.strip { overflow: hidden; } .strip-text { position: absolute; left: 0; } .strip-text .textLayer { position: absolute; inset: 0; }
.pane-center.has-doc .empty-state { display: none; }
.empty-state { flex: 1; display: grid; place-content: center; text-align: center; color: var(--muted); } .empty-icon { font-size: 48px; }
.pdf-sizer { position: relative; margin: 0 auto; }
.pdf-page { position: absolute; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.22); }
.pdf-page.flat { background: transparent; box-shadow: none; }
.page-loading { position: absolute; inset: 0; display: grid; place-content: center; color: #999; font-size: 13px; }
.page-canvas { position: absolute; left: 0; top: 0; }
.strip { position: absolute; left: 0; right: 0; overflow: hidden; background: #fff; }
.strip canvas { display: block; }
.strip.gap { background: #f2efe8; }
.strip.gap.hidden-gap { background: repeating-linear-gradient(90deg, #d8d2c5 0 6px, transparent 6px 12px); box-shadow: inset 0 1px 0 #bbb, inset 0 -1px 0 #bbb; }
.strip.gap.hidden-gap canvas { opacity: .15; }
.strip.gap.expanded { outline: 1px dashed #b0a68f; }
.gap-expand, .gap-collapse { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 11px; padding: 0 6px; height: 18px; line-height: 16px; background: rgba(255,255,255,.95); border-radius: 9px; z-index: 5; }
.strip.gap .gap-expand { opacity: 0; height: 16px; line-height: 14px; } .strip.gap:hover .gap-expand, .gap-expand:focus { opacity: 1; }
@media (pointer: coarse) { .strip.gap .gap-expand { opacity: .85; } }
.gap-collapse { top: 10px; transform: none; }
.page-omitted-label { position: absolute; left: 4px; top: 0; font-size: 9px; color: #776; }
.page-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.page-interact { position: absolute; inset: 0; z-index: 4; pointer-events: none; touch-action: none; }
.pane-center[data-tool="crop"] .page-interact { cursor: crosshair; }
.pane-center[data-tool="note"] .page-interact { cursor: copy; }
.pane-center[data-tool="pen"] .page-interact, .pane-center[data-tool="marker"] .page-interact { cursor: crosshair; }
.hl { position: absolute; pointer-events: auto; cursor: pointer; border-radius: 2px; }
.hl-highlight { background: var(--hl); mix-blend-mode: multiply; opacity: .45; }
.hl-underline { border-bottom: 2.5px solid var(--hl); }
.hl-strike { background: linear-gradient(transparent 46%, var(--hl) 46% 58%, transparent 58%); }
.hl.reviewed { box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.flattened .hl-highlight { opacity: .4; }
.note-pin { position: absolute; pointer-events: auto; z-index: 3; width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 11px; background: #fff7c2; border: 1px solid #c9b23a; line-height: 18px; }
.note-pin.free { border-color: rgba(0,0,0,.3); }
.clip-origin { position: absolute; border: 1.5px dashed var(--c); border-radius: 3px; opacity: .7; pointer-events: none; }
.clip-origin.focus { border-style: solid; border-width: 2.5px; opacity: 1; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); animation: pulse 1s ease 2; }
.clip-tab { position: absolute; pointer-events: auto; width: 18px; height: 18px; padding: 0; font-size: 9px; border-radius: 4px; z-index: 3; background: #fff; }
.ink-layer { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.ink-layer.erasable path { pointer-events: stroke; cursor: not-allowed; }
.ink-live { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 6; }
.crop-box { position: absolute; border: 1.5px solid var(--accent); background: rgba(47,91,211,.07); z-index: 7; touch-action: none; }
.crop-box.ready { cursor: move; }
.crop-box.dragging { opacity: .55; }
.crop-handle { position: absolute; width: 12px; height: 12px; background: #fff; border: 1.5px solid var(--accent); border-radius: 50%; touch-action: none; z-index: 1; }
.crop-handle::after { content: ""; position: absolute; inset: -10px; } /* área de toque maior (dedo/caneta) */
.crop-handle.nw { left: -7px; top: -7px; cursor: nwse-resize; } .crop-handle.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.crop-handle.sw { left: -7px; bottom: -7px; cursor: nesw-resize; } .crop-handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.crop-handle.n { left: calc(50% - 6px); top: -7px; cursor: ns-resize; border-radius: 3px; } .crop-handle.s { left: calc(50% - 6px); bottom: -7px; cursor: ns-resize; border-radius: 3px; }
.crop-handle.w { top: calc(50% - 6px); left: -7px; cursor: ew-resize; border-radius: 3px; } .crop-handle.e { top: calc(50% - 6px); right: -7px; cursor: ew-resize; border-radius: 3px; }
.crop-bar { position: fixed; z-index: 60; display: flex; gap: 2px; align-items: center; background: var(--panel); padding: 3px; border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px; }
.crop-bar .cb { border: 0; background: transparent; color: var(--text); padding: 6px 10px; border-radius: 7px; cursor: pointer; font: inherit; }
.crop-bar .cb:hover { background: var(--hover, rgba(127,127,127,.14)); }
.crop-bar .cb.primary { background: var(--accent); color: #fff; }

/* camada de texto (adaptado de pdf_viewer.css do PDF.js, Apache-2.0) */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 1; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; -webkit-user-select: text; }
.textLayer { --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height)); --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer ::selection { background: rgba(47, 91, 211, .28); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.pane-center:not([data-tool="select"]):not([data-tool="highlight"]) .textLayer { pointer-events: none; }

.sel-menu { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 4px; max-width: min(460px, 96vw); }
.sel-menu .row { display: flex; flex-wrap: wrap; gap: 4px; }
.sel-menu .row.swatches { gap: 6px; padding: 2px 4px; }
.sm-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; border: none; background: none; padding: 4px 6px; border-radius: 8px; font-size: 10.5px; color: var(--text); min-width: 46px; }
.sm-btn:hover { background: var(--accent-2); } .sm-btn.primary { color: var(--accent); background: none; font-weight: 600; } .sm-btn.primary:hover { background: var(--accent-2); }
.sm-btn.icon-only { min-width: 30px; justify-content: center; }
.sm-more { display: flex; gap: 4px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 4px; } .sm-more[hidden] { display: none; }
.sm-more button { font-size: 12px; padding: 3px 8px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; padding: 0 !important; border: 2px solid rgba(0,0,0,.12); }
.swatch.on { border-color: var(--text); }
.drag-handle { cursor: grab; touch-action: none; background: var(--accent-2); }

/* ---------- espaço infinito ---------- */
.canvas-toolbar { display: flex; align-items: center; gap: 4px; height: 36px; padding: 0 8px; border-bottom: 1px solid var(--line); color: var(--muted); }
.canvas-toolbar .canvas-name { border: none; background: transparent; font-weight: 600; color: var(--text); max-width: 60%; }
.canvas-toolbar .tb { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; margin-left: auto; }
.canvas-rail { position: absolute; z-index: 20; right: 10px; top: 48px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.canvas-rail .tb { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; }
.canvas-rail .tb.on { background: var(--accent-2); color: var(--accent); }
.canvas-rail .sep { width: 70%; height: 1px; margin: 3px 0; align-self: center; }
.canvas-rail .zoom-label { font-size: 10.5px; width: auto; }
.item-bar { position: absolute; z-index: 22; top: 46px; left: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-width: calc(100% - 60px); }
.item-bar[hidden] { display: none; }
.ib-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; border: none; background: none; padding: 3px 5px; border-radius: 7px; font-size: 10.5px; white-space: nowrap; color: var(--text); }
.ib-btn:hover { background: var(--accent-2); } .ib-btn.danger { color: var(--danger); } .ib-btn.icon-only { justify-content: center; }
.ib-count { font-size: 11px; color: var(--muted); padding: 0 4px; } .ib-count:empty { display: none; }
.canvas-search { width: 120px; }
.canvas-viewport { flex: 1; position: relative; overflow: hidden; background-color: var(--panel-2); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; touch-action: none; outline: none; }
.canvas-viewport.drop-hover { box-shadow: inset 0 0 0 3px var(--accent); }
.canvas-hint { position: absolute; bottom: 8px; left: 8px; right: 8px; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }
.pane-right:not(.empty) .canvas-hint { display: none; }
.canvas-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; width: 1px; height: 1px; }
.conn-layer, .canvas-ink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.conn { fill: none; stroke-width: 2; } .conn.temp { stroke: var(--accent); stroke-dasharray: 4 4; }
.conn-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.drawing .canvas-viewport { cursor: crosshair; }
.connecting .card { cursor: alias; }
.card { position: absolute; background: var(--card); border-radius: var(--radius); box-shadow: 0 2px 10px rgba(0,0,0,.12); border: 1px solid var(--line); border-top: 4px solid var(--c, #9aa0a6); display: flex; flex-direction: column; overflow: hidden; touch-action: none; user-select: none; }
.card.selected { box-shadow: 0 0 0 2px var(--accent), 0 4px 16px rgba(0,0,0,.18); }
.card.flash { animation: pulse .8s ease 2; }
.card.dim { opacity: .3; } .card.match { box-shadow: 0 0 0 2px #f59a3c; }
.card.locked { border-style: dashed; }
.card.connect-src { box-shadow: 0 0 0 3px #f59a3c; }
.card-head { display: flex; align-items: center; gap: 4px; padding: 3px 6px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); }
.card-src { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-go { padding: 0 6px; font-size: 12px; }
.card-body { flex: 1; overflow: auto; padding: 6px 8px; font-size: 13px; }
.card-body p { margin: 0; }
.card-body img { width: 100%; height: auto; display: block; }
.card-clip .card-body { font-family: Georgia, "Times New Roman", serif; }
.card-notes { margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 4px; font-size: 12px; font-family: var(--font); }
.note-body { background: color-mix(in srgb, var(--c) 18%, var(--card)); }
.text-body { font-size: 15px; font-weight: 600; outline: none; user-select: text; }
.card-text { border-top-color: transparent; background: transparent; box-shadow: none; border-color: transparent; }
.card-text.selected { border-color: var(--accent); }
.resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--line) 50%); }
.conn-handle { position: absolute; right: -1px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--accent); opacity: 0; cursor: crosshair; }
.card:hover .conn-handle, .card.selected .conn-handle { opacity: .8; }
.marquee { position: absolute; border: 1px dashed var(--accent); background: rgba(47,91,211,.08); pointer-events: none; }

/* ---------- linhas dinâmicas entre painéis ---------- */
.link-overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 30; overflow: visible; }
.link-line { fill: none; stroke-linecap: round; }
.link-hit { fill: none; stroke: transparent; stroke-width: 8; pointer-events: stroke; cursor: pointer; }
.link-dot { stroke: #fff; stroke-width: 1.5; }
.link-chips { position: fixed; inset: 0; pointer-events: none; z-index: 31; }
.link-chip { position: fixed; pointer-events: auto; font-size: 11.5px; padding: 1px 8px; border-radius: 12px; border: 1.5px solid; background: var(--panel); box-shadow: var(--shadow); max-width: 196px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-chip.more { pointer-events: none; border-color: var(--line); }
.link-chip.hidden-origin { border-style: dashed; }
body.dragging-clip, body.dragging-clip * { cursor: grabbing !important; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; max-width: 260px; background: var(--card); border-radius: 8px; box-shadow: var(--shadow); border: 2px solid var(--accent); padding: 6px; opacity: .92; }
.drag-ghost img { max-width: 240px; max-height: 180px; display: block; }
.drag-ghost-text { font-size: 12px; max-height: 90px; overflow: hidden; }

/* ---------- modais, menus, toasts ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 20, .35); z-index: 80; display: grid; place-items: center; padding: 12px; }
.modal { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); width: min(440px, 100%); max-height: 90dvh; overflow: auto; padding: 14px 16px; }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.icon-btn { border: none; background: none; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 13px; }
.field input, .field select { width: 100%; }
.settings section { border-top: 1px solid var(--line); padding: 8px 0; }
.settings h3 { margin: 4px 0; font-size: 14px; }
.login { display: flex; gap: 6px; flex-wrap: wrap; } .login input { flex: 1 1 160px; }
.transfers .err { color: var(--danger); }
.info { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; } .info dt { color: var(--muted); } .info dd { margin: 0; }
.move-list { display: flex; flex-direction: column; max-height: 60dvh; overflow: auto; }
.move-target { text-align: left; border: none; border-bottom: 1px solid var(--line); border-radius: 0; }
.ctx-menu { position: fixed; z-index: 90; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); padding: 4px; min-width: 210px; display: flex; flex-direction: column; }
.ctx-menu button { display: flex; justify-content: space-between; gap: 16px; border: none; background: none; text-align: left; padding: 6px 10px; border-radius: 6px; }
.ctx-menu button:hover:not(:disabled), .ctx-menu button:focus { background: var(--accent-2); }
.ctx-menu kbd { color: var(--muted); font-size: 11px; font-family: inherit; }
.ctx-menu .sep { height: 1px; width: auto; margin: 3px 4px; }
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 95; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; max-width: min(380px, 90vw); }
.toast.error { pointer-events: auto; cursor: pointer; }
.toast { background: color-mix(in srgb, #23252c 88%, transparent); color: #fff; padding: 6px 12px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.18); font-size: 12.5px; line-height: 1.35; }
.only-phone-ib { display: none; }
.toast.error { background: var(--danger); } .toast.ok { background: #2e6b33; }
.note-editor .rich { min-height: 140px; max-height: 50dvh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; outline: none; background: var(--panel-2); }
.rich-toolbar { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 6px; align-items: center; }
.rich-toolbar button { padding: 2px 8px; }
.note-quote { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--panel-2); font-family: Georgia, serif; font-size: 13px; }
.lookup-modal { display: flex; flex-direction: column; overflow: hidden; width: min(640px, 100%); }
.lookup { display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1; }
.lk-bar { display: flex; gap: 6px; } .lk-bar input { flex: 1; font-size: 15px; }
.lk-status { font-size: 12px; min-height: 16px; }
.lk-results { flex: 1; min-height: 160px; max-height: 58dvh; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.lk-entry { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.lk-entry header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.lk-src { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.lk-title { font-weight: 600; }
.lk-label { font-size: 12px; font-style: italic; color: var(--muted); margin-top: 4px; }
.lk-sec ol { margin: 2px 0 4px; padding-left: 22px; } .lk-sec li { margin: 2px 0; }
.lk-sum { margin: 4px 0; line-height: 1.45; }
.lk-rel summary { cursor: pointer; font-size: 12.5px; } .lk-rel ul { padding-left: 18px; font-size: 12.5px; }
.lk-actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; }
.lk-actions.disabled button { opacity: .45; pointer-events: none; }
.lk-privacy { margin: 0; }
.lk-errors { border-top: 1px dashed var(--line); padding-top: 4px; }
@media (max-width: 760px) { .lookup-modal { width: 100%; max-height: 92dvh; } .lk-results { max-height: 60dvh; } }
.fatal { padding: 20px; color: var(--danger); white-space: pre-wrap; }
@keyframes pulse { 0%, 100% { transform: none; } 50% { filter: brightness(1.15); box-shadow: 0 0 0 6px rgba(47,91,211,.35); } }

/* ---------- iPhone / telas estreitas: uma seção por vez ---------- */
.mobile-nav { display: none; }
.only-phone { display: none; }
@media (max-width: 760px) {
  .panes { grid-template-columns: 1fr !important; }
  .resizer { display: none; }
  .pane { display: none; visibility: visible !important; }
  .app[data-mpane="library"] .pane-left, .app[data-mpane="reader"] .pane-center, .app[data-mpane="canvas"] .pane-right { display: flex; }
  .mobile-nav { display: flex; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav button { flex: 1; border: none; border-radius: 0; background: none; display: flex; flex-direction: column; align-items: center; padding: 6px 0; font-size: 18px; }
  .mobile-nav button small { font-size: 10.5px; } .mobile-nav button.active { color: var(--accent); }
  .only-phone { display: inline-block; } .no-phone { display: none; }
  .topbar { grid-template-columns: auto minmax(0,1fr) auto; gap: 2px; padding: 0 4px; }
  .topbar .doc-title, .topbar .lib-btn { display: none; }
  .tools { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .tools .sep { display: none; }
  .hb-right .ib[title^="Modo de exibição"] { display: none; }
  .ib { width: 34px; height: 36px; }
  .pane-left { position: relative; transform: none; box-shadow: none; transition: none; visibility: visible; width: auto; }
  .drawer-head { display: none; }
  .panes > * { grid-column: 1 !important; grid-row: 1 !important; }
  .reader-toolbar.hud { bottom: 8px; opacity: .85; }
  .reader-toolbar.hud .zoom-label, .reader-toolbar.hud .sep { display: none; }
  .item-bar { top: 8px; max-width: calc(100% - 20px); }
  .canvas-rail { top: auto; bottom: 10px; right: 50%; transform: translateX(50%); flex-direction: row; }
  .canvas-rail .sep { width: 1px; height: 20px; }
  .lib-tree { max-height: 28%; }
  .toasts { top: 50px; bottom: auto; right: 8px; left: 8px; align-items: center; max-width: none; }
  .ph-hide { display: none !important; }
  .only-phone-ib { display: inline-grid; }
  .topbar .tools { min-width: 0; overflow: hidden; justify-content: center; }
  .reader-toolbar.hud button[title="Voltar à posição anterior"], .reader-toolbar.hud button[title="Ajustar à largura"] { display: none; }
}
@media (pointer: coarse) { .tool { min-width: 40px; min-height: 36px; } .lib-row { padding: 9px 8px; } .card-go { padding: 3px 10px; } }

/* ---------- v0.3.0: leitura lado a lado ---------- */
.pane-center.split { --split: 50%; }
.pane-center.split > .pdf-scroller, .pane-center.split > .doc-tabs, .pane-center.split > .empty-state { margin-right: var(--split); }
.pane-center.split > .reader-toolbar.hud { left: calc((100% - var(--split)) / 2); }
.pane-center.reader2 { position: absolute; top: 0; right: 0; bottom: 0; width: var(--split); z-index: 6; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -2px 0 6px rgba(0,0,0,.06); }
.pane-center.reader2 > .reader-toolbar.hud { left: 50%; }
.split-grip { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 31; touch-action: none; }
.split-grip:hover { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.split-head { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.split-head .split-doc { max-width: 260px; border: none; background: transparent; font: inherit; font-weight: 600; }
.sel-menu .sm-more .connect-across { font-weight: 600; color: var(--accent); }

/* ---------- v0.3.0: busca na biblioteca e projetos ---------- */
.search-scope { padding: 0 10px 6px; } .search-scope select { width: 100%; }
.search-doc { padding: 8px 10px 2px; font-weight: 600; font-size: 12.5px; border-top: 1px solid var(--line); }
.proj-head { padding: 10px; }
.proj-list { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 12px; }
.proj-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel); }
.proj-card header { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.proj-docs { list-style: none; margin: 6px 0; padding: 0; font-size: 13px; }
.proj-docs li { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.proj-docs .linklike { background: none; border: none; padding: 2px 0; color: var(--accent); text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.proj-pick { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
