/* VIJA Note – vzhľad */
:root {
  --bg: #faf6ee;
  --surface: #ffffff;
  --ink: #2a1626;
  --muted: #7a6b75;
  --line: #eadfd9;
  --primary: #b02a6b;
  --primary-ink: #ffffff;
  --primary-soft: #fbe6ef;
  --danger: #b4372f;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 16px rgb(0 0 0 / 0.06);
  --topbar-h: 52px;
  --c-yellow: #fdf0a0;
  --c-green: #c5ebc3;
  --c-blue: #bfdff9;
  --c-pink: #f8c8dc;
  --c-orange: #fdd6b3;
  --c-purple: #dccff6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { min-height: 100dvh; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
[hidden] { display: none !important; }

.c-yellow { --c: var(--c-yellow); }
.c-green { --c: var(--c-green); }
.c-blue { --c: var(--c-blue); }
.c-pink { --c: var(--c-pink); }
.c-orange { --c: var(--c-orange); }
.c-purple { --c: var(--c-purple); }

/* ---------- tlačidlá a formuláre ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #c9c3b6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.btn-small { min-height: 32px; padding: 0 10px; font-size: 0.875rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  min-width: 40px; height: 40px; padding: 0 8px; border-radius: 10px; border: 0;
  background: transparent; color: var(--ink); font-size: 1.2rem; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: rgb(0 0 0 / 0.05); }
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 9px 11px; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
label { display: grid; gap: 5px; font-size: 0.875rem; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--ink); font-size: 1rem; }
.form-error { color: var(--danger); font-size: 0.9rem; }

/* ---------- horná lišta ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: linear-gradient(90deg, #ff9a3c, #ff4f7b 38%, #a63fd1 70%, #3a78d1); pointer-events: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand img { height: 28px; width: auto; }
.mainnav { display: flex; gap: 4px; margin-left: 8px; }
.mainnav a { padding: 8px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
.mainnav a.active { background: var(--primary-soft); color: var(--primary); }
.viewer-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usermenu { margin-left: auto; position: relative; }
.usermenu summary {
  list-style: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 700; cursor: pointer;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-pop {
  position: absolute; right: 0; top: 44px; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid;
}
.usermenu-pop a, .usermenu-pop button {
  display: block; text-align: left; padding: 10px 12px; border-radius: 8px; border: 0; background: none;
  font: inherit; color: var(--ink); text-decoration: none; cursor: pointer; width: 100%;
}
.usermenu-pop a:hover, .usermenu-pop button:hover { background: var(--bg); }
.usermenu-name { padding: 8px 12px; color: var(--muted); font-size: 0.875rem; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.flash { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: 6px; }
.flash > div { background: var(--surface); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); }
.flash-error { border-color: var(--danger) !important; color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #233; color: #fff; padding: 11px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); }
.toast-ok { background: var(--primary); }

/* ---------- dialóg ---------- */
.dlg {
  border: 0; border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 24px));
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.25); color: var(--ink);
}
.dlg::backdrop { background: rgb(20 30 28 / 0.35); }
.dlg form { display: grid; gap: 14px; padding: 20px; }
.dlg h2 { margin: 0; font-size: 1.15rem; word-break: break-word; }
.dlg-body { margin: 0; color: var(--muted); font-style: italic; max-height: 30vh; overflow: auto; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg-extra { margin-right: auto; }

/* ---------- prihlásenie ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.page-plain .auth, body:not(.page-library) .auth { min-height: calc(100dvh - var(--topbar-h)); }
.auth-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 18px; padding: 28px;
  box-shadow: var(--shadow); display: grid; gap: 14px;
}
.auth-card h1 { margin: 0; text-align: center; }
.auth-card p { margin: 0; text-align: center; }
.auth-logo { display: block; margin: 0 auto 6px; max-width: 70%; height: auto; }

/* ---------- knižnica ---------- */
.library { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100dvh - var(--topbar-h)); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 12px 8px; overflow: auto; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 8px; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; }
.tree { display: grid; gap: 1px; }
.tree-row { display: flex; align-items: center; padding-left: calc(var(--depth, 0) * 16px); border-radius: 9px; }
.tree-row.active, .tree > a.tree-item.active { background: var(--primary-soft); }
.tree-item { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 9px; color: var(--ink); text-decoration: none; min-width: 0; }
.tree-row:hover, .tree > a.tree-item:hover { background: var(--bg); }
.tree-row.active:hover { background: var(--primary-soft); }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-more { border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 1.1rem; opacity: .6; }
.tree-row:hover .tree-more, .tree-row.active .tree-more { opacity: 1; }
.lib-main { padding: 16px 20px 40px; min-width: 0; position: relative; }
.lib-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 1.1rem; flex: 1; min-width: 160px; flex-wrap: wrap; }
.crumbs a { color: var(--ink); text-decoration: none; }
.crumbs a:last-child { color: var(--primary); }
.crumbs .sep { color: var(--muted); }
.search { max-width: 260px; }
.upload-btn { cursor: pointer; }
.only-mobile { display: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  text-align: left; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; color: var(--ink); cursor: pointer; min-height: 62px;
}
.tile:hover { border-color: var(--primary); }
.tile-icon { grid-row: span 2; font-size: 1.5rem; }
.tile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { color: var(--muted); font-size: 0.8rem; }
.tile-new { border-style: dashed; color: var(--muted); background: transparent; grid-template-rows: auto; }
.tile-new .tile-icon { grid-row: auto; }
.tile-new .tile-name { font-weight: 500; }
.doclist { display: grid; gap: 8px; }
.doc { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding-right: 6px; }
.doc:hover { border-color: #c9c3b6; }
.doc-main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; min-width: 0; }
.doc-icon { font-size: 1.6rem; }
.doc-text { display: grid; min-width: 0; }
.doc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty.small { padding: 16px; font-size: 0.9rem; }
.uploads { display: grid; gap: 8px; margin-bottom: 12px; }
.upload { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.upload progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--primary); }
.upload-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { color: var(--muted); font-size: 0.85rem; }
.upload-error { border-color: var(--danger); }
.upload-error .upload-status { color: var(--danger); }
.drop-hint { display: none; position: fixed; inset: 12px; border: 3px dashed var(--primary); border-radius: 20px; background: rgb(227 239 237 / 0.85); z-index: 40; place-items: center; font-size: 1.4rem; font-weight: 600; color: var(--primary); pointer-events: none; }
body.dragging .drop-hint { display: grid; }

@media (max-width: 760px) {
  .library { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 35; top: var(--topbar-h); bottom: 0; left: 0; width: 82vw; max-width: 320px; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: none; }
  .only-mobile { display: inline-flex; }
  .lib-main { padding: 12px; }
  .search { max-width: none; order: 5; flex-basis: 100%; }
  .mainnav { margin-left: 0; }
  .brand span { display: none; }
}

/* ---------- prehliadač ---------- */
body.page-viewer { overflow: hidden; }
.page-viewer .mainnav { display: none; }
.vtoolbar {
  position: fixed; z-index: 25; left: 0; right: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 54px;
  background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.tool-group { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 11px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tool.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); font-weight: 600; }
.tool-ico { font-size: 1.05rem; }
.color-group { display: flex; gap: 4px; padding: 0 4px; }
.spacer { flex: 1; }
.pageind { min-width: 84px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; font: inherit; cursor: pointer; font-variant-numeric: tabular-nums; }
.badge { position: absolute; top: 2px; right: 0; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 0.7rem; line-height: 18px; }
.badge:empty { display: none; }
.cdot {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; background: var(--c); cursor: pointer;
  box-shadow: 0 0 0 1px var(--line); flex: none; padding: 0;
}
.cdot.active { box-shadow: 0 0 0 2px var(--ink); }
.viewer-wrap { position: fixed; left: 0; right: 0; bottom: 0; top: calc(var(--topbar-h) + var(--vtb-h, 54px) + env(safe-area-inset-top)); display: flex; }
.viewer-container { position: absolute; inset: 0; overflow: auto; background: #e9e6df; touch-action: pan-x pan-y; }
body.panel-open .viewer-container { right: 340px; }
.pdfViewer { transform-origin: top center; }
.pdfViewer .page { box-shadow: 0 1px 4px rgb(0 0 0 / 0.15); }
body[data-tool="marker"] .viewer-container { touch-action: none; cursor: crosshair; }
body[data-tool="marker"] .textLayer span { cursor: crosshair; }
body[data-tool="note"] .viewer-container .page { cursor: copy; }
body.marking .textLayer ::selection { background: color-mix(in srgb, var(--mark-color) 85%, transparent); }

.vija-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; mix-blend-mode: multiply; }
.hl { position: absolute; border-radius: 2px; }
.hl.highlight { background: var(--c); }
.hl.underline { border-bottom: 2.5px solid var(--c); filter: saturate(3) brightness(0.8); }
.hl.flash, .note-pin.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { opacity: 1; box-shadow: 0 0 0 4px var(--c); } }
.comment-dot { position: absolute; transform: translate(-30%, -70%); font-size: 13px; filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.3)); }
.note-pin {
  position: absolute; pointer-events: auto; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 8px; border: 0; background: var(--c); cursor: pointer;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3); font-size: 16px; display: grid; place-items: center; padding: 0;
}

.seltools {
  position: fixed; z-index: 45; display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: var(--surface); border-radius: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.22);
}
.seltools-colors { display: flex; gap: 5px; }
.seltool { width: 36px; height: 36px; border: 0; border-radius: 9px; background: var(--bg); cursor: pointer; font-size: 1rem; }

.anpanel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 340px; background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s; z-index: 20;
}
body.panel-open .anpanel { transform: none; }
.anpanel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.anpanel-head strong { flex: 1; }
.anlist { overflow: auto; padding: 8px 12px 40px; display: grid; gap: 8px; align-content: start; }
.anlist-page { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 8px; }
.ancard { position: relative; padding: 10px 34px 10px 12px; border-radius: 10px; background: var(--bg); border-left: 5px solid var(--c); cursor: pointer; }
.ancard:hover { background: #efece5; }
.ancard-quote { font-size: 0.92rem; line-height: 1.4; }
.ancard-kind { font-weight: 600; font-size: 0.9rem; }
.ancard-comment { margin-top: 6px; font-size: 0.9rem; color: var(--primary); }
.ancard-edit { position: absolute; top: 6px; right: 4px; border: 0; background: none; width: 30px; height: 30px; cursor: pointer; color: var(--muted); border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 0.78rem; padding: 2px 8px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; z-index: 15; top: 120px; }

@media (max-width: 900px) {
  body.panel-open .viewer-container { right: 0; }
  .anpanel { width: min(360px, 92vw); box-shadow: var(--shadow); }
  .tool-label { display: none; }
  .tool { padding: 0 10px; }
}
@media (max-width: 520px) {
  .color-group .cdot { width: 26px; height: 26px; }
  .pageind { min-width: 70px; }
  .brand span { display: none; }
}

/* ---------- súhrn ---------- */
.summary { max-width: 900px; margin: 0 auto; padding: 18px 16px 60px; }
.sum-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.sum-head h1 { margin: 0; font-size: 1.5rem; }
.sum-export { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 16px 0 10px; padding: 14px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); align-items: end; }
.filter-colors { display: flex; gap: 6px; align-items: center; min-height: 42px; }
.seg { display: inline-flex; background: var(--bg); padding: 3px; border-radius: 11px; min-height: 42px; }
.seg button { white-space: nowrap; flex: 1; border: 0; background: none; border-radius: 9px; font: inherit; color: var(--muted); cursor: pointer; padding: 0 10px; }
.seg button.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.sumlist { display: grid; gap: 18px; margin-top: 10px; }
.sum-doc h2 { font-size: 1.2rem; margin: 6px 0 4px; }
.sum-doc h2 a { color: var(--ink); text-decoration: none; }
.sum-page { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px; }
.sum-item { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; break-inside: avoid; }
.sum-quote { margin: 0; line-height: 1.55; font-size: 1rem; }
.sum-quote.faded { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.sum-quote mark { background: var(--c); padding: 0 1px; border-radius: 2px; color: inherit; }
.sum-comment { margin: 8px 0 0; color: var(--primary); font-weight: 500; }
.sum-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.sum-open { margin-left: auto; font-size: 0.85rem; }

@media print {
  .topbar, .filters, .sum-export, .sum-open, .toast { display: none !important; }
  body { background: #fff; }
  .sum-item { border-color: #ccc; }
}

/* ---------- ručné písmo na lístky ---------- */
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/vendor/fonts/caveat-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/vendor/fonts/caveat-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- pero ---------- */
.ink-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ink-svg path.flash { animation: flash-ink 1.2s ease 2; }
@keyframes flash-ink { 50% { opacity: .3; } }
.pen-options { display: flex; align-items: center; gap: 6px; }
.seg-small { min-height: 36px; }
.seg-small button { padding: 0 9px; display: grid; place-items: center; }
.wdot { display: block; width: var(--s); height: var(--s); border-radius: 50%; background: currentColor; }
.toggle-btn { opacity: .55; }
.toggle-btn.active { opacity: 1; background: var(--primary-soft); color: var(--primary); }
body[data-tool="pen"] .viewer-container, body[data-tool="eraser"] .viewer-container { touch-action: none; }
body[data-tool="pen"] .textLayer, body[data-tool="eraser"] .textLayer { pointer-events: none; }
body[data-tool="pen"] .viewer-container .page { cursor: crosshair; }
body[data-tool="eraser"] .viewer-container .page { cursor: cell; }
.cdot.small { width: 26px; height: 26px; }
.ink-count { margin-top: 10px; }

/* ---------- lepiace lístky ---------- */
.vija-notes { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
body.hide-notes .vija-notes { display: none; }
.sticky {
  position: relative; width: 160px; aspect-ratio: 1; container-type: inline-size; isolation: isolate;
  transform: rotate(var(--rot, 0deg)); transform-origin: 50% 40%;
  filter: drop-shadow(0 1px 1.5px rgb(0 0 0 / 0.22)) drop-shadow(0 3px 6px rgb(0 0 0 / 0.10));
  --curl: 13%; --lift: 1; --flap: #e9d777; --paper: #fdf0a0; --note-ink: #2a2a2a;
}
.sticky.on-page { position: absolute; width: 20%; pointer-events: auto; cursor: grab; touch-action: none; }
.sticky.on-page.dragging { cursor: grabbing; z-index: 10; filter: drop-shadow(0 6px 10px rgb(0 0 0 / 0.3)); }
.sticky-paper {
  position: absolute; inset: 0; background: var(--paper); overflow: hidden;
  /* papier s jemným tieňovaním hore (lepiaci pásik) */
  box-shadow: inset 0 11cqw 9cqw -10cqw rgb(0 0 0 / 0.07);
}
.sticky.side-r .sticky-paper {
  -webkit-mask: linear-gradient(to top left, transparent calc(var(--curl) / 2), #000 calc(var(--curl) / 2));
  mask: linear-gradient(to top left, transparent calc(var(--curl) / 2), #000 calc(var(--curl) / 2));
}
.sticky.side-l .sticky-paper {
  -webkit-mask: linear-gradient(to top right, transparent calc(var(--curl) / 2), #000 calc(var(--curl) / 2));
  mask: linear-gradient(to top right, transparent calc(var(--curl) / 2), #000 calc(var(--curl) / 2));
}
.sticky-flap { position: absolute; bottom: 0; width: var(--curl); height: var(--curl); z-index: 2; }
.sticky.side-r .sticky-flap {
  right: 0;
  background: linear-gradient(to bottom right, color-mix(in srgb, var(--flap) 82%, #000) 0%, var(--flap) 28%, color-mix(in srgb, var(--flap) 55%, #fff) 49%, transparent 50%);
  filter: drop-shadow(-0.5cqw -0.5cqw 0.6cqw rgb(0 0 0 / 0.18));
}
.sticky.side-l .sticky-flap {
  left: 0;
  background: linear-gradient(to bottom left, color-mix(in srgb, var(--flap) 82%, #000) 0%, var(--flap) 28%, color-mix(in srgb, var(--flap) 55%, #fff) 49%, transparent 50%);
  filter: drop-shadow(0.5cqw -0.5cqw 0.6cqw rgb(0 0 0 / 0.18));
}
/* tieň pod nadvihnutým rohom */
.sticky-lift {
  position: absolute; bottom: 5%; width: 42%; height: 10%; z-index: -1;
  box-shadow: 0 calc(2.2cqw * var(--lift)) calc(3.2cqw * var(--lift)) rgb(0 0 0 / 0.28);
}
.sticky.side-r .sticky-lift { right: 4%; transform: rotate(calc(3deg * var(--lift))) skewX(25deg); }
.sticky.side-l .sticky-lift { left: 4%; transform: rotate(calc(-3deg * var(--lift))) skewX(-25deg); }
.sticky-text {
  position: absolute; inset: 9cqw 8cqw 10cqw 9cqw; margin: 0; padding: 0; border: 0; background: transparent;
  font-family: "Caveat", "Segoe Print", "Bradley Hand", cursive; font-weight: 500; font-size: 11cqw; line-height: 1.05;
  color: var(--note-ink); white-space: pre-wrap; overflow: hidden; overflow-wrap: anywhere; resize: none; outline: none;
  min-height: 0; width: auto; border-radius: 0;
}
textarea.sticky-text:focus { outline: none; }
.sticky-ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sticky.drawing .sticky-ink { pointer-events: auto; touch-action: none; cursor: crosshair; }
.sticky.drawing textarea.sticky-text { pointer-events: none; }

/* editor lístka */
.note-editor { width: min(440px, calc(100vw - 16px)); }
.note-editor { padding: 18px; }
.note-editor > * + * { margin-top: 12px; }
.ne-stage { display: grid; place-items: center; padding: 8px 0 14px; background: radial-gradient(circle at 50% 40%, #faf8f3, #ece8df); border-radius: 12px; }
.sticky.big { width: min(300px, 74vw); }
.ne-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ne-pens { display: flex; align-items: center; gap: 6px; }
.ne-label { font-size: 0.875rem; color: var(--muted); }
.ne-bgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; max-height: 128px; overflow: auto; padding: 2px; }
.bg-swatch {
  aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; padding: 0;
  background: var(--paper); container-type: inline-size;
}
.bg-swatch.active { outline: 3px solid var(--primary); outline-offset: 1px; }

/* lístok v súhrne */
.sum-sticky { display: flex; gap: 16px; align-items: flex-start; }
.sum-sticky .sticky { width: 150px; flex: none; margin: 4px 6px 10px; }
.sum-sticky .sum-quote { flex: 1; }
@media (max-width: 520px) { .sum-sticky { flex-direction: column; } }

/* ---------- nastavenia ---------- */
.settings { max-width: 860px; margin: 0 auto; padding: 18px 16px 60px; }
.settings h1 { margin: 0 0 6px; font-size: 1.5rem; }
.set-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.set-card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.set-card p { margin: 0 0 12px; }
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.swatch {
  display: grid; gap: 4px; justify-items: center; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; font: inherit; font-size: 0.8rem; color: var(--ink); position: relative;
}
.swatch .chip-c { width: 34px; height: 34px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }
.swatch.on { border-color: var(--primary); background: var(--primary-soft); }
.swatch.on::after { content: "✓"; position: absolute; top: 4px; right: 7px; color: var(--primary); font-weight: 700; }
.swatch .rm { position: absolute; top: 2px; left: 4px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; }
.custom-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.custom-row input[type="color"] { width: 52px; height: 42px; padding: 3px; }
.order-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; min-height: 36px; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.bg-item { display: grid; gap: 6px; justify-items: center; padding: 10px 6px 8px; border: 1px solid var(--line); border-radius: 12px; background: #faf8f3; cursor: pointer; font: inherit; font-size: 0.85rem; color: var(--ink); position: relative; }
.bg-item .sticky { width: 84px; }
.bg-item.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.bg-item .rm { position: absolute; top: 4px; right: 6px; border: 0; background: rgb(255 255 255 / 0.85); border-radius: 6px; cursor: pointer; color: var(--danger); }
.set-saved { color: var(--primary); font-size: 0.875rem; margin-left: 8px; }

/* ---------- vložky medzi riadky ---------- */
.vija-open { position: absolute; left: 0; width: 100%; z-index: 7; background: #fff; }
.vija-seg { position: absolute; left: 0; width: 100%; overflow: hidden; pointer-events: none; }
.vija-seg-mirror { position: absolute; left: 0; }
.vija-seg-mirror .vija-layer, .vija-seg-mirror .vija-notes { pointer-events: none !important; }
.vija-seg-mirror .sticky { pointer-events: none !important; }
.ins-strip {
  position: absolute; left: 0; width: 100%; z-index: 2;
  box-shadow: inset 0 6px 6px -6px rgb(0 0 0 / 0.35), inset 0 -6px 6px -6px rgb(0 0 0 / 0.35);
  border-left: 4px solid #e8771a;
}
.ins-paper, .ins-preview .ins-paper {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), #b9cfe8 calc(var(--lh) - 1px) var(--lh)),
    #fffdf3;
}
.ins-ink { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.ins-text {
  position: absolute; inset: 0 70px 0 3%; margin: 0; padding: 0; border: 0; background: transparent;
  font: inherit; font-size: calc(var(--lh) * 0.62); line-height: var(--lh); color: #1d2f4f;
  white-space: pre-wrap; overflow: hidden; pointer-events: none; resize: none; min-height: 0; width: auto; border-radius: 0;
}
textarea.ins-text.editing { pointer-events: auto; z-index: 3; outline: 2px solid rgb(232 119 26 / 0.5); outline-offset: -2px; }
.ins-tools { position: absolute; top: 2px; right: 4px; display: flex; gap: 2px; z-index: 4; }
.ins-btn {
  min-width: 28px; height: 26px; border: 1px solid var(--line); border-radius: 7px; background: rgb(255 255 255 / 0.92);
  cursor: pointer; font-size: 14px; padding: 0 5px; color: var(--ink); line-height: 1;
}
.ins-btn.danger { color: var(--danger); }
.ins-add { position: absolute; right: 4px; bottom: 3px; z-index: 4; font-weight: 700; color: #e8771a; }
.ins-dot {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; padding: 0;
  background: #e8771a; border: 2px solid #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
  pointer-events: auto; cursor: pointer; z-index: 8;
}
.ins-dot::after { content: ""; position: absolute; inset: -9px; } /* väčšia plocha na ťuknutie */
.ins-dot.flash { animation: flash 1.2s ease 2; }
.ins-preview { position: relative; container-type: inline-size; margin-top: 6px; max-width: 760px; border-left: 3px solid #e8771a; border-radius: 4px; overflow: hidden; }
.ins-preview > * { --lh: 3.4cqw; }
.ins-preview .ins-text { inset: 0 6px 0 3%; }
.ins-preview .ins-ink { pointer-events: none; }
.sum-insert { margin-top: 8px; }
.sum-ink-title { display: block; margin-bottom: 6px; }
.sum-ink-box { background: #fffef9; border: 1px dashed var(--line); border-radius: 8px; padding: 6px; }
.sum-ink { display: block; max-height: 260px; }

/* ---------- strom z poznámok ---------- */
.view-seg { min-height: 40px; }
body.view-tree .summary { max-width: 1200px; }
.tree-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.tree-toolbar select { width: auto; min-width: 200px; max-width: 100%; }
.tree-toolbar .spacer { flex: 1; }
.tree-help { margin: 10px 0 6px; }
.tree-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.tree-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; min-height: 240px; }
.tree-box.drop-root { outline: 2px dashed var(--primary); outline-offset: -4px; }
.tree-ul { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.tree-ul.root { padding-left: 0; }
.tree-ul:not(.root)::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 14px; border-left: 2px solid #ddd6c8; }
.tn { position: relative; }
.tree-ul:not(.root) > .tn::before { content: ""; position: absolute; left: -11px; top: 19px; width: 10px; border-top: 2px solid #ddd6c8; }
.tn-row {
  display: flex; align-items: flex-start; gap: 4px; padding: 6px 6px 6px 2px; margin: 2px 0; border-radius: 9px;
  border: 1px solid transparent; border-left: 4px solid var(--c, transparent); cursor: pointer; background: var(--surface);
}
.tn-row:hover { background: var(--bg); }
.tn-row.selected { border-color: var(--primary); background: var(--primary-soft); }
.tn-row.is-topic { border-left-color: var(--primary); }
.tn-row.drop-before { box-shadow: 0 -3px 0 var(--primary); }
.tn-row.drop-after { box-shadow: 0 3px 0 var(--primary); }
.tn-row.drop-inside { outline: 2px solid var(--primary); background: var(--primary-soft); }
.tn-toggle { width: 26px; height: 26px; flex: none; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.tn-toggle.leaf { cursor: default; opacity: .5; }
.tn-handle { flex: none; width: 22px; height: 26px; display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; user-select: none; }
.tn-body { flex: 1; min-width: 0; padding-top: 3px; line-height: 1.4; }
.tn-topic { font-weight: 700; font-size: 1.02rem; }
.tn-count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.tn-icon { margin-right: 4px; }
.tn-comment { color: var(--primary); }
.tn-src { color: var(--muted); font-size: 0.8rem; }
.tn-missing { color: var(--muted); font-style: italic; }
.tn-actions { display: flex; gap: 2px; flex: none; opacity: .35; }
.tn-row:hover .tn-actions, .tn-row.selected .tn-actions { opacity: 1; }
.tn-btn { min-width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer; font-size: 0.9rem; padding: 0 4px; }
.tn-btn.danger { color: var(--danger); }
.tn.collapsed > .tn-row .tn-topic::after { content: " …"; color: var(--muted); }
.tn-ghost { position: fixed; z-index: 200; pointer-events: none; max-width: 280px; padding: 8px 12px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 0.85rem; box-shadow: var(--shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-tray-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; position: sticky; top: 64px; max-height: calc(100dvh - 80px); overflow: auto; }
.tray-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tree-tray-wrap p { margin: 4px 0 8px; }
.tree-tray { display: grid; gap: 6px; }
.tray-item { display: flex; align-items: flex-start; gap: 4px; padding: 6px; border-radius: 8px; background: var(--bg); border-left: 4px solid var(--c); font-size: 0.88rem; }
@media (max-width: 860px) {
  .tree-layout { grid-template-columns: 1fr; }
  .tree-tray-wrap { position: static; max-height: none; }
  .tn-actions { opacity: 1; flex-wrap: wrap; max-width: 96px; justify-content: flex-end; }
}
@media print {
  .view-seg, .tree-toolbar, .tree-help, .tree-tray-wrap, .tn-actions, .tn-handle { display: none !important; }
  .tree-layout { display: block; }
  .tree-box { border: 0; padding: 0; }
  .tn-row { border-color: transparent !important; background: none !important; }
}

.seg { min-width: max-content; }
.filters-wrap > summary { display: none; }
body.view-tree #fContext, body.view-tree .sum-export { display: none; }
@media (max-width: 700px) {
  .filters-wrap > summary { display: list-item; cursor: pointer; font-weight: 600; padding: 10px 14px; margin-top: 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .filters-wrap[open] > summary { border-radius: var(--radius) var(--radius) 0 0; }
  .filters-wrap[open] .filters { margin-top: 0; border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
}
@media print { .filters-wrap { display: none !important; } }
.g-box { display: grid; gap: 10px; }
.g-box p { margin: 0; }

/* ---------- pozvánky a profil ---------- */
.prof-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.inv-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.inv-warn { border-color: #e8b04a; background: #fff8e6; display: grid; gap: 4px; }
.inv-result { margin-top: 16px; padding: 14px; background: var(--primary-soft); border-radius: var(--radius); display: grid; gap: 10px; }
.inv-note { margin: 0; }
.inv-note.ok { color: var(--primary); font-weight: 600; }
.inv-note.err { color: var(--danger); }
.inv-preview pre { white-space: pre-wrap; font: inherit; font-size: 0.9rem; background: var(--surface); padding: 10px; border-radius: 8px; }
.inv-list { display: grid; gap: 8px; }
.inv-item { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.inv-main { flex: 1 1 220px; min-width: 0; word-break: break-word; }
.inv-acts { display: flex; gap: 6px; }
.chip-ok { background: #dff3e1; color: #1d6b2c; }
.chip-off { background: #eee; color: #777; }

/* ---------- verejné stránky ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 28px 18px 70px; line-height: 1.6; }
.legal h1 { margin: 10px 0 4px; }
.legal h2 { margin: 28px 0 6px; font-size: 1.15rem; }
.legal .lead { font-size: 1.1rem; color: var(--muted); }
.legal-logo { display: block; }
.legal code { background: #ece8df; padding: 1px 6px; border-radius: 5px; font-size: 0.9em; word-break: break-all; }
.legal ul { padding-left: 22px; }
.legal li { margin: 4px 0; }
.legal-links { text-align: center; font-size: 0.85rem; margin: 4px 0 0; }
.legal-links a { color: var(--muted); }

/* ---------- vlastné dokumenty: text a tabuľka ---------- */
.editor-wrap { position: fixed; left: 0; right: 0; bottom: 0; top: calc(var(--topbar-h) + var(--vtb-h, 54px) + env(safe-area-inset-top)); overflow: auto; background: var(--bg); padding: 12px; }
.text-wrap { position: relative; width: min(100%, 860px); margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.text-editor, .text-mirror {
  margin: 0; padding: 28px 32px; border: 0; border-radius: var(--radius);
  font: 1.05rem/1.7 Georgia, "Times New Roman", serif; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
  letter-spacing: normal; tab-size: 4;
}
/* textarea sa roztiahne podľa textu (posúva sa celá strana), aby zvýraznenie pod ním sedelo na riadky */
.text-editor { position: relative; z-index: 1; display: block; width: 100%; min-height: calc(100vh - 160px); background: transparent; color: var(--ink); resize: none; overflow: hidden; }
.text-mirror { position: absolute; inset: 0; z-index: 0; overflow: hidden; color: transparent; pointer-events: none; }
.text-mirror mark { color: transparent; background: var(--c); border-radius: 3px; }
.hl-group { display: flex; align-items: center; gap: 4px; background: var(--bg); padding: 2px 6px; border-radius: 11px; }
.hl-label { font-size: 1.05rem; }
.text-editor:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.table-scroll { overflow: auto; max-height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.grid-table { border-collapse: separate; border-spacing: 0; font-size: 0.95rem; }
.grid-table th { position: sticky; top: 0; z-index: 1; background: #efece4; color: var(--muted); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 34px; }
.grid-table tbody th { position: sticky; left: 0; top: auto; z-index: 1; }
.grid-table th.corner { left: 0; z-index: 2; }
.grid-table td { padding: 0; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.grid-table td input { width: 150px; min-width: 100%; padding: 8px 8px; border: 0; background: transparent; font: inherit; color: var(--ink); }
.grid-table td input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--primary-soft); }
.save-state { font-size: 0.85rem; color: var(--muted); padding: 0 8px; }
.save-state.bad { color: var(--danger); font-weight: 600; }
.new-menu { display: grid; gap: 8px; }

/* ---------- tvary a pravítko ---------- */
.shape-options { position: relative; }
.shape-ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; vertical-align: -4px; margin-right: 4px; }
.shape-pop {
  position: fixed; z-index: 40; top: calc(var(--topbar-h) + var(--vtb-h, 54px) + 4px + env(safe-area-inset-top)); left: 12px; max-width: calc(100vw - 24px);
  display: grid; grid-template-columns: repeat(4, 86px); gap: 6px; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.shape-pop button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--surface); font: inherit; font-size: 0.72rem; color: var(--ink); cursor: pointer;
}
.shape-pop button.active { background: var(--primary-soft); border-color: var(--primary); font-weight: 600; }
.shape-pop .shape-ico { width: 30px; height: 30px; margin: 0; }
body[data-tool="shape"] .viewer-container { touch-action: none; cursor: crosshair; }
.ruler {
  position: fixed; z-index: 30; width: 440px; height: 66px; border-radius: 6px; touch-action: none; cursor: grab;
  background: linear-gradient(180deg, rgb(180 215 235 / 0.55), rgb(200 228 245 / 0.45));
  border: 1px solid rgb(60 110 150 / 0.55); box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  background-image:
    repeating-linear-gradient(90deg, rgb(30 60 90 / 0.7) 0 1px, transparent 1px 18.9px),
    repeating-linear-gradient(90deg, rgb(30 60 90 / 0.7) 0 1px, transparent 1px 18.9px);
  background-size: 100% 9px, 100% 9px; background-position: 0 0, 0 100%; background-repeat: no-repeat;
}
.ruler[hidden] { display: none; }
.ruler::after { content: ""; position: absolute; inset: 0; border-radius: 6px; pointer-events: none;
  background: repeating-linear-gradient(90deg, rgb(30 60 90 / 0.8) 0 1.5px, transparent 1.5px 37.8px); background-size: 100% 16px; background-repeat: no-repeat; }
.ruler-rot, .ruler-close {
  position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgb(60 110 150 / 0.7);
  background: #fff; color: #1f4f6f; font-size: 1.1rem; display: grid; place-items: center; cursor: pointer; padding: 0; touch-action: none;
}
.ruler-rot { right: 8px; top: 16px; cursor: grab; }
.ruler-close { left: 8px; top: 16px; }

/* ---------- horná lišta na tablete a telefóne: dva riadky, farby pod tlačidlom ---------- */
.tb-break, #colorBtn { display: none; }
.cdot.cur { width: 22px; height: 22px; margin-right: 4px; pointer-events: none; }
@media (max-width: 1100px) {
  .vtoolbar { flex-wrap: wrap; overflow: visible; row-gap: 2px; padding: 4px 8px; }
  .tb-break { display: block; flex-basis: 100%; height: 0; }
  .vtoolbar .spacer { flex: 1 1 8px; }
  #colorBtn:not([hidden]) { display: inline-flex; align-items: center; width: auto; padding: 0 8px; }
  #markerColors, #penOptions { display: none !important; }
  body.colors-open #markerColors:not([hidden]), body.colors-open #penOptions:not([hidden]) {
    display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px; position: fixed; z-index: 40; left: 8px; right: 8px;
    top: calc(var(--topbar-h) + var(--vtb-h, 96px) + 4px + env(safe-area-inset-top));
    padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  body.colors-open #markerColors:not([hidden]) .cdot, body.colors-open #penColors .cdot { width: 34px; height: 34px; }
  #shapeBtnName { display: none; }
}
@media (max-width: 520px) {
  .vtoolbar .icon-btn { width: 32px; min-width: 0; padding: 0; white-space: nowrap; font-size: 1rem; }
  .vtoolbar { gap: 1px; padding: 4px 6px; }
  .vtoolbar .pageind { min-width: 54px; height: 32px; padding: 0 4px; font-size: 0.85rem; }
  .vtoolbar .spacer { flex: 0 0 0; }
  #addPage { font-size: 0.8rem !important; }
  #colorBtn:not([hidden]) { width: auto; padding: 0 6px; }
  #zoomOut, #zoomIn { display: none; }
}

/* ---------- skener ---------- */
body.scanning { overflow: hidden; }
.scanner { position: fixed; inset: 0; z-index: 100; background: #111; color: #fff; display: flex; flex-direction: column; }
.scan-screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: #111; }
.scan-screen.flash::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: 0.7; pointer-events: none; }
.scan-top, .scan-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
.scan-bottom { padding-bottom: calc(14px + env(safe-area-inset-bottom)); padding-top: 12px; background: #111; }
.scan-video { background: #000; }
.scan-shutter { width: 68px; height: 68px; border-radius: 50%; border: 4px solid #fff; background: #fff; box-shadow: inset 0 0 0 4px #111; cursor: pointer; flex: none; }
.scan-shutter:active { transform: scale(0.94); }
.scan-count { font-weight: 600; min-width: 50px; text-align: right; }
.scan-msg { position: absolute; inset: 70px 20px auto; text-align: center; background: rgb(0 0 0 / 0.7); padding: 16px; border-radius: 12px; }
.btn-ghost-light { background: rgb(255 255 255 / 0.12); color: #fff; border: 1px solid rgb(255 255 255 / 0.25); }
.scan-review { background: var(--bg); color: var(--ink); }
.scan-review .scan-top { background: #111; color: #fff; }
.scan-form { display: grid; gap: 8px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.scan-form input[type=text], .scan-form select { width: 100%; max-width: 560px; }
.scan-ocr { font-size: 0.9rem; color: var(--muted); }
.scan-grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; align-content: start; }
.scan-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.scan-thumb { aspect-ratio: 3 / 4; display: grid; place-items: center; background: #e9e6df; overflow: hidden; }
.scan-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.15s; }
.scan-card-bar { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px; font-weight: 600; }
.scan-review .scan-bottom { background: var(--surface); border-top: 1px solid var(--line); }
.scan-review .btn-ghost-light { background: var(--surface); color: var(--ink); border-color: var(--line); }
.scan-ocr { display: flex; align-items: flex-start; gap: 8px; }
.scan-ocr input[type=checkbox] { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.scan-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.scan-ocr { flex-direction: row !important; }
.scan-bottom { flex-wrap: wrap; justify-content: center; }
.scan-bottom .btn { padding-left: 10px; padding-right: 10px; }
.scan-ocr input[type=checkbox] { appearance: auto; -webkit-appearance: checkbox; accent-color: var(--primary); }

/* skener: živé zameranie a úprava rohov */
.scan-stage { position: relative; flex: 1; min-height: 0; background: #000; }
.scan-stage .scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.scan-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scan-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 6px 14px; border-radius: 20px; background: rgb(0 0 0 / 0.6); font-size: 0.9rem; white-space: nowrap; pointer-events: none; }
.scan-auto.on { background: #2e8b57; border-color: #2e8b57; }
.scan-crop { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: #111; }
.crop-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 20px; overflow: hidden; }
.crop-wrap { position: relative; display: inline-block; touch-action: none; }
.crop-wrap img { display: block; max-width: calc(100vw - 40px); max-height: calc(100vh - 220px); user-select: none; -webkit-user-drag: none; }
.crop-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crop-svg polygon { fill: rgb(60 160 255 / 0.18); stroke: #59a8ff; stroke-width: 3; vector-effect: non-scaling-stroke; }
.crop-handle { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgb(89 168 255 / 0.35); border: 3px solid #59a8ff; touch-action: none; cursor: grab; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
