/* Note Brain — стили. Один файл на Windows (Electron), Android (WebView) и браузер. */
:root {
  --bg: #f4f4f1;
  --panel: #fbfbf9;
  --panel2: #efeee9;
  --line: #e1dfd8;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --faint: #9a988f;
  --accent: #0e7490;
  --accent-ink: #ffffff;
  --accent-soft: #dff1f5;
  --hover: rgba(0, 0, 0, .055);
  --press: rgba(0, 0, 0, .09);
  --page: #ffffff;
  --page-line: #c9dcef;
  --grid: #e3e6ea;
  --danger: #b4441d;
  --shadow: 0 6px 24px rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .1);
  --box-line: #b9c3c9;
  --mark: #fff176;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  --mono: Consolas, "Cascadia Mono", "Roboto Mono", monospace;
  --r: 8px;
  --top-h: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312; --panel: #1a1a19; --panel2: #232321; --line: #31302d; --text: #ebeae6; --muted: #a09f98;
    --faint: #75736c; --accent: #2aa7c2; --accent-ink: #061a1f; --accent-soft: #123139; --hover: rgba(255, 255, 255, .06);
    --press: rgba(255, 255, 255, .1); --page: #1b1b1a; --page-line: #2c3a48; --grid: #2a2c2e; --danger: #f08a5d;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); --box-line: #4a5358; --mark: #6b5d00;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131312; --panel: #1a1a19; --panel2: #232321; --line: #31302d; --text: #ebeae6; --muted: #a09f98;
  --faint: #75736c; --accent: #2aa7c2; --accent-ink: #061a1f; --accent-soft: #123139; --hover: rgba(255, 255, 255, .06);
  --press: rgba(255, 255, 255, .1); --page: #1b1b1a; --page-line: #2c3a48; --grid: #2a2c2e; --danger: #f08a5d;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); --box-line: #4a5358; --mark: #6b5d00;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent; overflow: hidden;
}
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ---------- иконки (svg вставляются из JS по data-icon) ---------- */
[data-icon] svg, .ico { width: 20px; height: 20px; flex: none; display: block; }
.sm [data-icon] svg, .ib.sm svg { width: 18px; height: 18px; }

.ib {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 36px; height: 36px; padding: 0 8px; border: 0; border-radius: var(--r); background: transparent;
  cursor: pointer; color: var(--text);
}
.ib.sm { min-width: 28px; height: 28px; padding: 0 4px; }
.ib:hover { background: var(--hover); }
.ib:active { background: var(--press); }
.ib.on { background: var(--accent-soft); color: var(--accent); }
.ib:disabled { opacity: .4; cursor: default; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer;
}
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- каркас ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.top {
  height: var(--top-h); flex: none; display: flex; align-items: center; gap: 4px; padding: 0 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 0 6px 0 2px; white-space: nowrap; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  background: linear-gradient(160deg, #1593b0, #0b5566);
  -webkit-mask: none;
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 5px 6px 5px 7px; border-radius: 1.5px; background: #fff;
  box-shadow: inset 3px 0 0 #0e6b80;
}
.top-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search {
  display: flex; align-items: center; gap: 6px; width: min(340px, 34vw); height: 34px; padding: 0 10px;
  border-radius: 17px; background: var(--panel2); border: 1px solid transparent; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); background: var(--page); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.sync-ind[data-state="busy"] svg { animation: spin 1.2s linear infinite; }
.sync-ind[data-state="error"] { color: var(--danger); }
.sync-ind[data-state="ok"] { color: var(--accent); }
.sync-ind[data-state="off"] { color: var(--faint); }
@keyframes spin { to { transform: rotate(360deg); } }

.main { flex: 1; min-height: 0; display: flex; }
.pane { min-width: 0; display: flex; flex-direction: column; }
.pane-head {
  height: 40px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 6px 0 14px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted); text-transform: uppercase;
}
.pane-head > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { width: 248px; flex: none; background: var(--panel); border-right: 1px solid var(--line); }
.pages { width: 264px; flex: none; background: var(--panel2); border-right: 1px solid var(--line); }
.view { flex: 1; background: var(--page); position: relative; }
.app.nav-hidden .nav { display: none; }

/* ---------- список блокнотов и разделов ---------- */
.nav-list { flex: 1; overflow: auto; padding: 0 6px 8px; }
.nb-row, .sec-row, .nav-link, .pg-row {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 4px 8px; border: 0;
  border-radius: 6px; background: transparent; text-align: left; cursor: pointer; color: var(--text); user-select: none;
}
.nb-row:hover, .sec-row:hover, .nav-link:hover, .pg-row:hover { background: var(--hover); }
.nb-row { font-weight: 600; }
.nb-row .chev { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform .15s; }
.nb-row.open .chev { transform: rotate(90deg); }
.nb-icon { width: 14px; height: 18px; border-radius: 2px 4px 4px 2px; flex: none; box-shadow: inset 3px 0 0 rgba(0, 0, 0, .22); }
.nb-name, .sec-name, .pg-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-row { padding-left: 32px; }
.sec-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sec-row.cur { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.row-more { opacity: 0; flex: none; }
.nb-row:hover .row-more, .sec-row:hover .row-more, .pg-row:hover .row-more, .row-more:focus { opacity: 1; }
.add-sec { padding-left: 32px; color: var(--muted); font-size: 13px; }
.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.drop-into { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-foot { flex: none; padding: 6px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.nav-link { color: var(--muted); }
.nav-link.cur { background: var(--accent-soft); color: var(--accent); }
.nav-link [data-icon] svg { width: 18px; height: 18px; }

/* ---------- список страниц ---------- */
.pages-list { flex: 1; overflow: auto; padding: 0 6px 6px; }
.pg-row { flex-direction: column; align-items: stretch; gap: 0; padding: 6px 8px; min-height: 40px; }
.pg-row .pg-line { display: flex; align-items: center; gap: 6px; }
.pg-row .pg-title { font-weight: 500; }
.pg-row .pg-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-row.cur { background: var(--page); box-shadow: inset 3px 0 0 var(--accent), 0 1px 2px rgba(0, 0, 0, .06); }
.pg-row[data-level="1"] { padding-left: 24px; }
.pg-row[data-level="2"] { padding-left: 40px; }
.pg-row.untitled .pg-title { color: var(--muted); font-style: italic; }
.pg-row mark, .result mark { background: var(--mark); color: inherit; border-radius: 2px; }
.add-page {
  flex: none; display: flex; align-items: center; gap: 8px; margin: 0 6px 8px; padding: 8px 10px; border: 1px dashed var(--line);
  border-radius: 6px; background: transparent; cursor: pointer; color: var(--muted);
}
.add-page:hover { background: var(--hover); color: var(--text); }
.list-note { padding: 14px; color: var(--muted); font-size: 13px; }
.group-title { padding: 10px 8px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.task-row { display: flex; align-items: flex-start; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.task-row:hover { background: var(--hover); }
.task-row input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.task-row.done .task-text { text-decoration: line-through; color: var(--muted); }
.task-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task-tag { flex: none; width: 18px; text-align: center; }
.filter-bar { display: flex; gap: 4px; padding: 0 8px 6px; flex-wrap: wrap; }
.chip {
  height: 28px; padding: 0 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- лента команд ---------- */
.ribbon { flex: none; background: var(--panel); border-bottom: 1px solid var(--line); }
.app:not(.has-page) .ribbon { display: none; }
.rtabs { display: flex; gap: 2px; padding: 4px 8px 0; overflow-x: auto; scrollbar-width: none; }
.rtab {
  height: 30px; padding: 0 12px; border: 0; background: transparent; border-radius: 6px 6px 0 0; cursor: pointer; color: var(--muted);
  white-space: nowrap; font-weight: 500;
}
.rtab.on { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.rtab.ctx { color: #8a5a00; }
:root[data-theme="dark"] .rtab.ctx { color: #e0b155; }
.rbar {
  display: flex; align-items: center; gap: 2px; padding: 4px 8px 6px; overflow-x: auto; scrollbar-width: thin; min-height: 46px;
}
.rbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex: none; }
.rbar .ib { flex: none; }
.rbar .ib.txt { font-weight: 600; min-width: 34px; }
.rbar .lbl { font-size: 13px; }
.rbar select {
  height: 32px; border-radius: 6px; border: 1px solid var(--line); background: var(--page); padding: 0 6px; flex: none;
}
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); flex: none; cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.color-ib { position: relative; }
.color-ib .bar { position: absolute; left: 8px; right: 8px; bottom: 5px; height: 4px; border-radius: 2px; }

/* ---------- страница ---------- */
.empty-view { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); padding: 24px; text-align: center; }
.empty-mark { width: 72px; height: 88px; border-radius: 6px 12px 12px 6px; background: var(--panel2); box-shadow: inset 10px 0 0 var(--line); }
.scroller { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.page { min-height: 100%; position: relative; padding-bottom: 40px; }
.page-head { padding: 26px 48px 6px; max-width: 900px; }
.page-title {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); outline: 0; background: transparent; padding: 4px 0 6px;
  font-size: 26px; font-weight: 300; letter-spacing: -.01em; font-family: var(--font);
}
.page-title:focus { border-bottom-color: var(--accent); }
.page-date { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.ink-note { margin: 8px 16px 0; padding: 8px 12px; border-radius: 6px; background: var(--accent-soft); font-size: 13px; }
.canvas-outer { position: relative; }
.canvas { position: relative; transform-origin: 0 0; min-height: 300px; cursor: text; }
.paper-lines .canvas {
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, var(--page-line) 27px 28px);
  background-position: 0 6px;
}
.paper-grid .canvas {
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
.page[data-color] .canvas, .page[data-color] { background-color: var(--page-color); }

/* блок текста (контейнер) */
.box { position: absolute; min-width: 60px; border: 1px solid transparent; border-radius: 3px; }
.box:hover { border-color: color-mix(in srgb, var(--box-line) 55%, transparent); }
.box.active { border-color: var(--box-line); }
.box-bar {
  position: absolute; left: -1px; right: -1px; top: -15px; height: 14px; border: 1px solid var(--box-line); border-bottom: 0;
  border-radius: 3px 3px 0 0; background: var(--panel2); cursor: move; opacity: 0; display: flex; justify-content: flex-end;
  touch-action: none;
}
.box:hover .box-bar, .box.active .box-bar { opacity: 1; }
.box-bar::before { content: ""; position: absolute; left: 50%; top: 4px; width: 22px; margin-left: -11px; height: 4px; border-top: 1px dotted var(--muted); border-bottom: 1px dotted var(--muted); }
.box-del { width: 18px; height: 13px; border: 0; padding: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 11px; line-height: 13px; }
.box-del:hover { color: var(--danger); }
.box-size {
  position: absolute; right: -6px; top: 0; bottom: 0; width: 10px; cursor: ew-resize; opacity: 0; touch-action: none;
}
.box:hover .box-size, .box.active .box-size { opacity: 1; }
.box-size::after { content: ""; position: absolute; right: 3px; top: 50%; height: 18px; margin-top: -9px; width: 3px; border-radius: 2px; background: var(--box-line); }
.box-body { outline: 0; padding: 4px 8px; min-height: 24px; overflow-wrap: anywhere; }

/* «по ширине экрана»: блоки друг под другом */
.canvas.flow { padding: 8px 12px 120px; min-height: 60vh; }
.canvas.flow .box { position: relative; left: auto !important; top: auto !important; width: auto !important; margin-bottom: 14px; border-color: transparent; }
.canvas.flow .box-bar, .canvas.flow .box-size { display: none; }
.canvas.flow .ink { display: none; }
.canvas.flow .box.active { border-color: transparent; box-shadow: inset 2px 0 0 var(--accent); }

/* содержимое заметок */
.box-body, .print-body { font-size: 15px; line-height: 1.5; }
.box-body p, .box-body div { margin: 0; }
.box-body h1 { font-size: 22px; font-weight: 600; margin: 4px 0; color: #1b5e7a; }
.box-body h2 { font-size: 18px; font-weight: 600; margin: 4px 0; color: #1d6d8c; }
.box-body h3 { font-size: 16px; font-weight: 600; margin: 2px 0; color: #2f6b80; }
:root[data-theme="dark"] .box-body h1, :root[data-theme="dark"] .box-body h2, :root[data-theme="dark"] .box-body h3 { color: #7fd0e3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .box-body :is(h1, h2, h3) { color: #7fd0e3; } }
.box-body ul, .box-body ol { margin: 0; padding-left: 26px; }
.box-body blockquote { margin: 4px 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.box-body pre {
  margin: 4px 0; padding: 8px 10px; border-radius: 6px; background: var(--panel2); font: 13px/1.45 var(--mono); white-space: pre-wrap;
}
.box-body code { font-family: var(--mono); font-size: .92em; background: var(--panel2); border-radius: 3px; padding: 0 3px; }
.box-body a { color: var(--accent); }
.box-body hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.box-body img { max-width: 100%; height: auto; vertical-align: bottom; cursor: default; border-radius: 2px; }
.box-body img.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.box-body table { border-collapse: collapse; margin: 4px 0; }
.box-body td, .box-body th { border: 1px solid var(--box-line); padding: 3px 8px; min-width: 56px; vertical-align: top; }
.box-body th { background: var(--panel2); font-weight: 600; text-align: left; }
.nb-file {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; margin: 2px 0; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); cursor: pointer; user-select: none; max-width: 100%;
}
.nb-file::before { content: ""; width: 22px; height: 26px; flex: none; border-radius: 2px 7px 2px 2px; background: var(--accent); opacity: .85; }
.nb-file:hover { border-color: var(--accent); }

/* теги */
.box-body [data-tag] { position: relative; padding-left: 26px; }
.box-body li[data-tag] { list-style: none; margin-left: -26px; }
.box-body [data-tag]::before {
  position: absolute; left: 2px; top: .2em; width: 17px; height: 17px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; font-size: 12px; line-height: 1; font-weight: 700; user-select: none;
}
.box-body [data-tag="todo"]::before { content: ""; border: 1.5px solid #6c7a85; background: var(--page); cursor: pointer; border-radius: 3px; width: 15px; height: 15px; top: .25em; }
.box-body [data-tag="todo"][data-done]::before { content: "✓"; background: #2e7d4f; border-color: #2e7d4f; color: #fff; font-size: 12px; }
.box-body [data-tag="todo"][data-done] { color: var(--muted); }
.box-body [data-tag="important"]::before { content: "★"; color: #e0a100; font-size: 16px; }
.box-body [data-tag="question"]::before { content: "?"; color: #fff; background: #7b55c7; border-radius: 50%; }
.box-body [data-tag="remember"]::before { content: "!"; color: #6b5000; background: #ffe066; }
.box-body [data-tag="idea"]::before { content: "i"; color: #fff; background: #e07b00; border-radius: 50%; font-family: Georgia, serif; font-style: italic; }
.box-body [data-tag="contact"]::before { content: "☎"; color: #2c7fb8; font-size: 15px; }
.box-body [data-tag="critical"]::before { content: "‼"; color: #fff; background: #c62828; }
.box-body [data-tag="remember"] { background: linear-gradient(transparent 55%, rgba(255, 224, 102, .45) 55%); }

::highlight(nb-search) { background-color: #ffd54f; color: #000; }
::highlight(nb-search-cur) { background-color: #ff9800; color: #000; }

/* рукописный слой */
.ink { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 5; }
.ink path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ink path.hl { mix-blend-mode: multiply; }
:root[data-theme="dark"] .ink path.hl { mix-blend-mode: screen; }
.drawing .ink { pointer-events: all; touch-action: none; cursor: crosshair; }
.drawing.erasing .ink { cursor: cell; }
.drawing .box { pointer-events: none; }
.drawing .canvas { cursor: crosshair; }

/* ручка изменения размера картинки */
.img-handle {
  position: absolute; width: 14px; height: 14px; border-radius: 3px; background: var(--accent); border: 2px solid var(--page);
  cursor: nwse-resize; z-index: 6; touch-action: none;
}

/* ---------- меню, окна, подсказки ---------- */
.menu {
  position: fixed; z-index: 100; min-width: 200px; max-width: 320px; padding: 5px; border-radius: 10px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow); max-height: 80vh; overflow: auto;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 5px 10px; border: 0; border-radius: 6px;
  background: transparent; cursor: pointer; text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: 0; }
.menu button.danger { color: var(--danger); }
.menu button .hint { margin-left: auto; color: var(--faint); font-size: 12px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.menu .colors { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
.menu-title { padding: 6px 10px 2px; font-size: 12px; color: var(--muted); font-weight: 600; }

.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog {
  width: min(520px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.dialog.wide { width: min(720px, 100%); }
.dialog h2 { margin: 0; padding: 18px 20px 6px; font-size: 18px; font-weight: 600; }
.dialog .d-body { padding: 8px 20px 12px; }
.dialog .d-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 20px 18px; flex-wrap: wrap; }
.dialog label.fld { display: block; margin: 8px 0; }
.dialog label.fld > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.dialog input[type="text"], .dialog input[type="url"], .dialog input[type="number"], .dialog select, .dialog textarea {
  width: 100%; height: 38px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--page); outline: 0;
}
.dialog textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
.dialog input:focus, .dialog select:focus, .dialog textarea:focus { border-color: var(--accent); }
.dialog p { margin: 6px 0; }
.dialog .muted { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { height: 36px; padding: 0 10px; border: 0; background: none; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.code {
  font: 600 18px/1.5 var(--mono); letter-spacing: .04em; padding: 10px 12px; border-radius: 8px; background: var(--panel2);
  user-select: all; word-break: break-all; text-align: center;
}
.qr { display: block; margin: 10px auto; background: #fff; padding: 10px; border-radius: 8px; width: 220px; height: 220px; image-rendering: pixelated; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.grid-pick { display: grid; grid-template-columns: repeat(8, 22px); gap: 3px; padding: 8px; }
.grid-pick span { width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 3px; background: var(--page); }
.grid-pick span.on { background: var(--accent-soft); border-color: var(--accent); }
.grid-label { padding: 0 8px 6px; font-size: 13px; color: var(--muted); }
.scan-video { width: 100%; border-radius: 8px; background: #000; max-height: 50vh; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 200; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; background: #252523; color: #f2f1ed; box-shadow: var(--shadow); opacity: 0;
  pointer-events: none; transition: opacity .18s, transform .18s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: none; border: 0; color: #6fd3ea; font-weight: 600; cursor: pointer; padding: 0; }

.link-pop {
  position: absolute; z-index: 20; display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; max-width: 360px;
}
.link-pop .u { padding: 4px 8px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.link-pop button { border: 0; background: none; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--accent); }
.link-pop button:hover { background: var(--hover); }

/* ---------- узкие экраны (телефон) ---------- */
.only-mobile { display: none !important; }
@media (max-width: 759px) {
  :root { --top-h: 52px; }
  body { font-size: 15px; }
  .only-mobile { display: inline-flex !important; }
  .only-desk { display: none !important; }
  .search { display: none; }
  .app.searching .search { display: flex; flex: 1; width: auto; }
  .app.searching .top-title, .app.searching .brand { display: none; }
  .brand-name { display: none; }
  .app[data-mview="nav"] .brand-name { display: inline; }
  .app[data-mview="nav"] #btnBack { display: none !important; }
  .main { position: relative; }
  .nav, .pages, .view { position: absolute; inset: 0; width: auto; border: 0; }
  .app[data-mview="nav"] .pages, .app[data-mview="nav"] .view { display: none; }
  .app[data-mview="pages"] .nav, .app[data-mview="pages"] .view { display: none; }
  .app[data-mview="page"] .nav, .app[data-mview="page"] .pages { display: none; }
  .app.nav-hidden .nav { display: flex; }
  .app[data-mview="pages"] .nav, .app[data-mview="page"] .nav { display: none; }
  .app:not([data-mview="page"]) .ribbon { display: none; }
  /* лента — внизу, над клавиатурой */
  .app { flex-direction: column; }
  .ribbon { order: 3; border-bottom: 0; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .rtabs { padding-top: 2px; }
  .rbar { min-height: 50px; padding: 4px 6px; }
  .rbar .ib { min-width: 40px; height: 40px; }
  .nb-row, .sec-row, .nav-link { min-height: 44px; }
  .pg-row { min-height: 52px; }
  .page-head { padding: 14px 16px 4px; }
  .page-title { font-size: 22px; }
  .row-more { opacity: 1; }
  .box-body { font-size: 16px; }
  .menu { min-width: 220px; }
  .menu button { min-height: 42px; }
  .dialog { border-radius: 14px; }
  .toast { bottom: 76px; }
}
@media (min-width: 760px) and (max-width: 1100px) {
  .nav { width: 210px; }
  .pages { width: 220px; }
}

/* ---------- печать: только страница ---------- */
@media print {
  body { overflow: visible; background: #fff; }
  .top, .ribbon, .nav, .pages, .toast, .ink-note, .box-bar, .box-size, .empty-view, .img-handle { display: none !important; }
  .app, .main, .view, .scroller { position: static !important; height: auto !important; overflow: visible !important; display: block !important; }
  .page-title { border: 0; }
  .box { border-color: transparent !important; }
}
