/* Optik angelehnt an Bewertungstool / Rechnungstool: macOS-Seitenleiste, Türkis als Akzent, Glas-Pillen */
:root {
  --teal: #40c7b0;
  --teal-strong: #2fb39c;
  --teal-soft: rgba(64, 199, 176, .14);
  --bg: #ececee;            /* Hintergrund hinter den Seiten (wie Vorschau) */
  --panel: #ffffff;
  --panel-2: #f6f6f7;
  --side: #f2f2f4;
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --line: rgba(0, 0, 0, .1);
  --line-strong: rgba(0, 0, 0, .18);
  --danger: #d9443a;
  --danger-soft: rgba(217, 68, 58, .12);
  --mark: #e5483d;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.08);
  --glass: rgba(255, 255, 255, .72);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1b1d; --panel: #262628; --panel-2: #2d2d30; --side: #232325;
    --ink: #f2f2f4; --ink-soft: #a1a1a6; --line: rgba(255,255,255,.1); --line-strong: rgba(255,255,255,.18);
    --glass: rgba(44, 44, 46, .72); --teal-soft: rgba(64,199,176,.2); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #1b1b1d; --panel: #262628; --panel-2: #2d2d30; --side: #232325;
  --ink: #f2f2f4; --ink-soft: #a1a1a6; --line: rgba(255,255,255,.1); --line-strong: rgba(255,255,255,.18);
  --glass: rgba(44, 44, 46, .72); --teal-soft: rgba(64,199,176,.2); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 13px; color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden; -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
}
/* In der Mac-Hülle liegt hinter der Seitenleiste ein echtes Sidebar-Material */
body.native-mac { background: transparent; }
body.native-mac #topbar { display: none; }
body.native-mac #sidebar { background: transparent; }
svg { width: 16px; height: 16px; flex: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--ink); }

/* ---------- Werkzeugleiste (Browser / Windows) ---------- */
#topbar {
  height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--side); border-bottom: 1px solid var(--line); gap: 12px;
}
.tb-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tb-btn {
  width: 34px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--ink-soft);
}
.tb-btn:hover { background: var(--line); color: var(--ink); }
.tb-btn:disabled { opacity: .35; pointer-events: none; }
.tb-btn svg { width: 18px; height: 18px; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.tb-title { display: flex; flex-direction: column; margin-left: 10px; min-width: 0; }
#docTitle { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#docSub { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

.switcher { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); backdrop-filter: blur(20px); }
.switcher button {
  display: flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 6px 13px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.switcher button svg { width: 17px; height: 17px; }
.switcher button.on { background: var(--teal); color: #fff; }
.switcher button:not(.on):hover { background: var(--line); }
body.no-doc #modeSwitch button:not([data-mode="view"]) { opacity: .4; pointer-events: none; }

/* ---------- Grundlayout ---------- */
#shell { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 196px; flex: none; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
body.no-doc #sidebar, body.no-doc #inspector { display: none; }
.sb-head { display: flex; justify-content: space-between; padding: 12px 16px 6px; font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: none; letter-spacing: .2px; }
#thumbs { flex: 1; overflow-y: auto; padding: 4px 0 20px; }
.thumb { display: flex; flex-direction: column; align-items: center; padding: 8px 10px 6px; cursor: pointer; border-radius: 10px; margin: 0 10px; }
.thumb .tw { position: relative; background: #fff; box-shadow: 0 0 0 1px var(--line-strong), 0 1px 3px rgba(0,0,0,.12); border-radius: 2px; overflow: hidden; }
.thumb canvas, .thumb img, .gp canvas { display: block; width: 100%; height: 100%; }
.thumb .tn { font-size: 11px; color: var(--ink-soft); margin-top: 5px; padding: 1px 8px; border-radius: 6px; }
.thumb.cur .tw { box-shadow: 0 0 0 3px var(--teal), 0 1px 3px rgba(0,0,0,.12); }
.thumb.cur .tn { background: var(--teal); color: #fff; font-weight: 600; }
.thumb .badge { position: absolute; right: 4px; top: 4px; background: var(--mark); color: #fff; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 0 5px; }

#main { flex: 1; position: relative; min-width: 0; background: var(--bg); display: flex; }
#viewer { flex: 1; overflow: auto; outline: none; position: relative; }
body.no-doc #viewer, body.no-doc #zoomBar { display: none; }
#pages { display: flex; flex-direction: column; align-items: center; padding: 24px 24px 90px; gap: 18px; min-width: min-content; }
.page { position: relative; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 2px 10px rgba(0,0,0,.14); flex: none; }
.page > canvas.pc { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .ov { position: absolute; inset: 0; }
.page .pnum { position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%); font-size: 10.5px; color: var(--ink-soft); }

/* Textauswahl (Ansehen) */
.selq { position: absolute; background: rgba(64, 140, 255, .32); pointer-events: none; mix-blend-mode: multiply; }
.hitq { position: absolute; background: rgba(255, 214, 0, .45); pointer-events: none; mix-blend-mode: multiply; border-radius: 1px; }
.hitq.cur { background: rgba(255, 140, 0, .6); outline: 2px solid rgba(255,140,0,.8); }

/* Bearbeiten: Rahmen um Absätze und Bilder */
body.mode-edit .page .ov { cursor: default; }
.eb { position: absolute; border: 1px dashed transparent; border-radius: 2px; pointer-events: none; }   /* Auswahl per Programm: oberstes Element an der Klickstelle (pickAt) */
.eb .h { pointer-events: auto; }
body.mode-edit .eb { border-color: rgba(64, 199, 176, .45); cursor: pointer; }
body.mode-edit .eb.img { border-color: rgba(120, 120, 255, .45); }
body.mode-edit .eb.hot { border: 1px solid var(--teal); background: rgba(64, 199, 176, .07); }
body.mode-edit .eb.img.hot { border-color: #6c6cff; background: rgba(108, 108, 255, .06); }
.eb.sel { border: 1.5px solid var(--teal) !important; background: rgba(64,199,176,.06); cursor: move !important; }
.eb.img.sel { border-color: #6c6cff !important; }
.eb .h { position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--teal); border-radius: 2px; }
.eb.img .h { border-color: #6c6cff; }
.eb .h.br { right: -6px; bottom: -6px; cursor: nwse-resize; }
.eb .h.r { right: -6px; top: calc(50% - 5px); cursor: ew-resize; }
.eb.ghost { opacity: .6; border-style: solid !important; }
body.tool-addText .page .ov { cursor: text; }
.rotlayer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tedit {
  position: absolute; margin: 0; padding: 0; border: 0; outline: 1.5px solid var(--teal); outline-offset: 2px; resize: none; overflow: hidden;
  background: #fff; white-space: pre-wrap; word-break: normal; overflow-wrap: break-word; user-select: text; -webkit-user-select: text; box-shadow: 0 0 0 4px rgba(64,199,176,.18);
}
.tedit.nowrap { white-space: pre; }

/* Schwärzen */
.rm { position: absolute; background: rgba(229, 72, 61, .18); border: 1.5px solid var(--mark); }
.rm:hover { background: rgba(0,0,0,.85); }
.rm .x { position: absolute; right: -8px; top: -8px; width: 16px; height: 16px; border-radius: 50%; background: var(--mark); color: #fff; display: none; place-items: center; cursor: pointer; font-size: 11px; line-height: 1; }
.rm:hover .x { display: grid; }
.rdraw { position: absolute; border: 1.5px dashed var(--mark); background: rgba(229, 72, 61, .12); pointer-events: none; }
body.mode-redact.tool-rArea .page .ov, body.mode-redact.tool-rText .page .ov { cursor: crosshair; }
body.mode-redact.tool-rText .page .ov { cursor: text; }
body.mode-view .page .ov { cursor: text; }

/* ---------- Seitenübersicht ---------- */
#pageGrid { flex: 1; overflow: auto; padding: 24px 28px 60px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 22px 18px; outline: none; }
.gp { width: 168px; display: flex; flex-direction: column; align-items: center; padding: 10px 8px 6px; border-radius: 12px; cursor: pointer; position: relative; }
.gp:hover { background: var(--line); }
.gp.sel { background: var(--teal-soft); }
.gp .tw { background: #fff; box-shadow: 0 0 0 1px var(--line-strong), 0 2px 6px rgba(0,0,0,.14); display: grid; place-items: center; overflow: hidden; }
.gp.sel .tw { box-shadow: 0 0 0 3px var(--teal), 0 2px 6px rgba(0,0,0,.14); }
.gp .tn { margin-top: 7px; font-size: 11.5px; color: var(--ink-soft); }
.gp.sel .tn { color: var(--ink); font-weight: 600; }
.gp.drag { opacity: .35; }
.gp.dropL::before, .gp.dropR::after { content: ""; position: absolute; top: 8px; bottom: 24px; width: 3px; border-radius: 2px; background: var(--teal); }
.gp.dropL::before { left: -11px; }
.gp.dropR::after { right: -11px; }

/* ---------- Startbildschirm ---------- */
#startScreen { position: absolute; inset: 0; display: none; place-items: center; overflow: auto; padding: 30px; }
body.no-doc #startScreen { display: grid; }
.start-card { width: min(520px, 100%); background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 34px 28px; text-align: center; }
.start-hero { height: 150px; border-radius: 14px; margin-bottom: 20px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, rgba(64,199,176,.35), transparent 60%), linear-gradient(135deg, rgba(64,199,176,.22), rgba(64,199,176,.06)); }
.hero-icon { width: 120px; height: 120px; }
.start-card h1 { font-size: 22px; margin: 0 0 6px; font-weight: 700; letter-spacing: -.2px; }
.start-card p { color: var(--ink-soft); margin: 0 0 20px; line-height: 1.5; }
/* Rechtliches (Konto-Menü) */
.legal-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; }
.legal-row { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--panel-2); color: var(--ink); font: inherit; font-size: 13.5px; text-align: left; text-decoration: none; cursor: pointer; }
.legal-row:hover { background: var(--line); }
.legal-row svg { width: 14px; height: 14px; color: var(--ink-soft); }
.legal-box { max-height: min(60vh, 460px); overflow: auto; text-align: left; padding-right: 4px; }
.legal-box h4 { margin: 4px 0 8px; font-size: 14px; }
.legal-box p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--ink); }
.legal-more { margin-top: 14px; font-size: 12px; color: var(--ink-soft); }
.legal-more summary { cursor: pointer; padding: 4px 0; }
.legal-more p { color: var(--ink-soft); }
.legal-pre { white-space: pre-wrap; font: 11px/1.45 ui-monospace, Menlo, Consolas, monospace; color: var(--ink-soft); background: var(--panel-2); border-radius: 8px; padding: 10px; margin: 6px 0 0; }
.recent { text-align: left; margin-top: 24px; border-top: 1px solid var(--line); padding-top: 14px; }
.recent h3 { font-size: 11.5px; color: var(--ink-soft); margin: 0 0 6px; font-weight: 600; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.recent li:hover { background: var(--teal-soft); }
.recent li .rn { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent li .rp { color: var(--ink-soft); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.recent li .rc { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.recent li svg { color: var(--teal); width: 18px; height: 18px; }

/* ---------- Panel rechts ---------- */
#inspector { width: 286px; flex: none; background: var(--panel-2); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px 14px 30px; }
.panel { display: none; flex-direction: column; gap: 12px; }
body.mode-view .panel[data-for="view"], body.mode-edit .panel[data-for="edit"], body.mode-redact .panel[data-for="redact"], body.mode-pages .panel[data-for="pages"] { display: flex; }
.panel h2 { font-size: 17px; margin: 2px 2px 0; font-weight: 700; letter-spacing: -.2px; }
.panel h3 { font-size: 12px; margin: 0 0 8px; font-weight: 600; color: var(--ink); }
.card { background: var(--panel); border-radius: var(--radius); padding: 12px; box-shadow: 0 0 0 1px var(--line); }
.card label { display: block; font-size: 11.5px; color: var(--ink-soft); margin: 9px 0 4px; }
.card label.check { display: flex; gap: 7px; align-items: center; color: var(--ink); font-size: 12px; margin: 7px 0 0; }
.hint { color: var(--ink-soft); font-size: 12px; line-height: 1.45; margin: 0 2px; }
.note { color: var(--ink-soft); font-size: 11.5px; line-height: 1.45; margin: 8px 2px 0; }
.muted { color: var(--ink-soft); }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row .grow, .grow { flex: 1; min-width: 0; }
.row.two > * { flex: 1; }
.seg-row { margin-top: 10px; justify-content: space-between; }
input[type=number], input[type=search], input[type=text], select {
  width: 100%; height: 28px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel); padding: 0 8px; outline: none;
}
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
input[type=color] { width: 44px; height: 28px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel); }
input[type=range] { width: 100%; accent-color: var(--teal); }
input[type=checkbox] { accent-color: var(--teal); }

.btn-col { display: flex; flex-direction: column; gap: 6px; }
.btn-col hr, .menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.btn-col button, .modal-actions button, button.primary, .row.two button {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 30px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; font-size: 12.5px; font-weight: 500; padding: 5px 12px; line-height: 1.25;
}
.btn-col button { text-align: left; }
.btn-col button { justify-content: flex-start; }
.btn-col button:hover, .row.two button:hover { background: var(--teal-soft); border-color: rgba(64,199,176,.5); }
.btn-col button.danger { color: var(--danger); }
.btn-col button.danger:hover { background: var(--danger-soft); border-color: rgba(217,68,58,.4); }
button.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
button.primary:hover { background: var(--teal-strong); }
button.primary.big { height: 38px; font-size: 14px; padding: 0 18px; margin: 0 auto; border-radius: 10px; }
button.primary.big svg { width: 18px; height: 18px; }
button.danger-fill { background: #1d1d1f; border-color: #1d1d1f; width: 100%; }
button.danger-fill:hover { background: #000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.danger-fill { background: #f2f2f4; color: #111; border-color: #f2f2f4; } }
button:disabled { opacity: .45; pointer-events: none; }
button.link { border: 0; background: none; color: var(--teal-strong); cursor: pointer; font-size: 12px; padding: 0; font-weight: 500; }
.ic-btn { width: 30px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; }
.ic-btn:hover { background: var(--teal-soft); }

.tool-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.panel[data-for="edit"] .tool-row { grid-template-columns: repeat(2, 1fr); }
.tool { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 4px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 11.5px; font-weight: 500; }
.tool svg { width: 22px; height: 22px; color: var(--ink-soft); }
.tool:hover { border-color: rgba(64,199,176,.6); }
.tool.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.tool.on svg { color: #fff; }

.seg { display: inline-flex; background: var(--panel-2); border-radius: 8px; padding: 2px; box-shadow: inset 0 0 0 1px var(--line); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.seg button { border: 0; background: transparent; min-width: 32px; height: 26px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; font-size: 12.5px; padding: 0 8px; }
.seg button.on { background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.15), 0 0 0 1px var(--line); color: var(--teal-strong); }
.seg button svg { width: 15px; height: 15px; }
.seg.zrow button { height: 42px; }
.seg.zrow button svg { width: 30px; height: 30px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.chips button { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; }
.chips button:hover { background: var(--teal-soft); border-color: var(--teal); }
.results { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.res-head { display: flex; justify-content: space-between; align-items: baseline; }
.res-head h3 { margin: 0 0 6px; }
.res-head span { font-size: 11.5px; color: var(--ink-soft); }
.results ul, .marks { list-style: none; margin: 6px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.results li, .marks li { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 7px; font-size: 12px; cursor: pointer; }
.results li:hover, .marks li:hover { background: var(--teal-soft); }
.results li .pg, .marks li .pg { flex: none; font-size: 10.5px; color: var(--ink-soft); background: var(--panel-2); border-radius: 5px; padding: 1px 5px; margin-top: 1px; }
.results li .ctx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.results li .ctx b { color: var(--ink); font-weight: 600; background: rgba(255,214,0,.35); border-radius: 2px; }
.results li.done { opacity: .5; }
.marks li .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marks li .rm-x { border: 0; background: none; color: var(--ink-soft); cursor: pointer; padding: 0 2px; }
.marks li .rm-x:hover { color: var(--danger); }
.marks li.empty { color: var(--ink-soft); cursor: default; }
.marks li.empty:hover { background: none; }
.info { font-size: 12px; line-height: 1.6; }
.info .k { color: var(--ink-soft); }
.info .warn { color: #b46a00; display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; }

/* ---------- Schwebende Leisten ---------- */
.floating { position: absolute; z-index: 30; background: var(--glass); backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); }
#zoomBar { left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 3px 10px 3px 3px; border-radius: 999px; }
#zoomBar .ic, #findBar .ic { width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; cursor: pointer; }
#zoomBar .ic:hover, #findBar .ic:hover { background: var(--line); }
#zoomLabel { border: 0; background: transparent; min-width: 58px; height: 28px; border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums; font-weight: 500; }
#zoomLabel:hover { background: var(--line); }
.zb-sep { width: 1px; height: 16px; background: var(--line-strong); margin: 0 8px 0 4px; }
#pageLabel { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
#findBar { top: 12px; right: 16px; display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 12px; width: 380px; }
#findBar .fi { color: var(--ink-soft); }
#findBar input { border: 0; background: transparent; box-shadow: none; height: 28px; flex: 1; }
#findCount { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }

.menu { position: fixed; z-index: 80; background: var(--panel); border-radius: 10px; box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgba(0,0,0,.2); padding: 5px; min-width: 170px; display: flex; flex-direction: column; }
.menu button { border: 0; background: transparent; text-align: left; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.menu button:hover { background: var(--teal); color: #fff; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger); color: #fff; }

#dropHint { position: absolute; inset: 10px; border: 2.5px dashed var(--teal); border-radius: 16px; background: rgba(64,199,176,.12); display: none; place-items: center; z-index: 60; pointer-events: none; }
#dropHint > div { display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--teal-strong); background: var(--panel); padding: 18px 26px; border-radius: 14px; box-shadow: var(--shadow); }
#dropHint svg { width: 34px; height: 34px; }
body.dragging #dropHint { display: grid; }

/* ---------- Dialoge / Hinweise ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.28); display: grid; place-items: center; z-index: 300; padding: 20px; }   /* über Sperrbildschirm (200), damit „Geräte verwalten“ dort bedienbar ist */
.modal-box { width: min(460px, 100%); background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); padding: 20px 22px 18px; max-height: 90vh; overflow: auto; animation: pop .16s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box h3 { margin: 0 0 8px; font-size: 15px; }
.modal-box p { margin: 0 0 10px; color: var(--ink-soft); line-height: 1.5; font-size: 12.5px; }
.modal-box .opts { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.modal-box .opts label { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; }
.modal-box .opts label small { display: block; color: var(--ink-soft); font-size: 11px; }
.modal-box input[type=password], .modal-box input[type=text] { margin: 6px 0 4px; height: 30px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions button { min-width: 84px; justify-content: center; }
.modal-actions .left { margin-right: auto; }
.modal-actions button.primary { color: #fff; }
.modal-actions button.danger-fill { width: auto; color: #fff; }

.toast { position: fixed; top: 64px; right: 18px; z-index: 120; background: var(--glass); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); border-radius: 12px; padding: 10px 14px; max-width: 360px; font-size: 12.5px; display: flex; gap: 9px; align-items: flex-start; animation: pop .16s ease-out; }
body.native-mac .toast { top: 14px; }
.toast svg { color: var(--teal); width: 18px; height: 18px; margin-top: 1px; }
.toast.err svg { color: var(--danger); }
.busy { position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,.12); display: grid; place-content: center; justify-items: center; gap: 12px; font-weight: 500; }
.busy span { background: var(--panel); padding: 6px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--teal-soft); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(127,127,127,.35); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Größenauswahl */
.combo { display: flex; position: relative; }
.combo input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.combo button { width: 28px; height: 28px; flex: none; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 7px 7px 0; background: var(--panel); cursor: pointer; display: grid; place-items: center; }
.combo button:hover { background: var(--teal-soft); }
.combo button svg { width: 13px; height: 13px; }
.size-menu { max-height: 280px; overflow-y: auto; min-width: 90px; }

/* Kopf-/Fußzeilen */
body.mode-edit .eb.hf { border-color: rgba(162, 116, 224, .7); background: rgba(162, 116, 224, .2); }
body.mode-edit .eb.hf.hot { border: 1px solid #a274e0; background: rgba(162, 116, 224, .08); }
.eb.hf.sel { border-color: #a274e0 !important; background: rgba(162, 116, 224, .08) !important; }
.eb.hf .h { border-color: #a274e0; }
.eb .hf-tag { position: absolute; left: -1px; top: -17px; font-size: 10px; line-height: 15px; padding: 0 6px; border-radius: 5px 5px 0 0; background: #a274e0; color: #fff; white-space: nowrap; pointer-events: none; }
.hf-card { box-shadow: 0 0 0 1.5px rgba(162, 116, 224, .55); }
.hf-card h3 { color: #8a57d6; }
.eb.multi { border: 1.5px solid var(--teal) !important; background: rgba(64,199,176,.10) !important; }
.eb .h.b { left: calc(50% - 5px); bottom: -6px; cursor: ns-resize; }

/* Rechteckauswahl und Hilfslinien */
.marq { position: absolute; border: 1px solid var(--teal); background: rgba(64,199,176,.10); pointer-events: none; }
.guide { position: absolute; pointer-events: none; z-index: 5; }
.guide.v { top: 0; bottom: 0; width: 0; border-left: 1px dashed #ff2d87; }
.guide.h { left: 0; right: 0; height: 0; border-top: 1px dashed #ff2d87; }

/* Broschüre */
.bk-order { font-size: 11.5px; color: var(--ink-soft); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; max-height: 120px; overflow: auto; font-variant-numeric: tabular-nums; line-height: 1.6; }
.modal-box select { margin-top: 4px; }
.modal-box .field { margin: 10px 0 0; }
.modal-box .field > span { display: block; font-size: 11.5px; color: var(--ink-soft); margin-bottom: 4px; }

/* Ablage oben: neuer Tab */
#tabZone { position: fixed; left: 0; right: 0; top: 0; height: 90px; z-index: 70; display: none; place-items: center; pointer-events: none;
  background: rgba(64,199,176,.10); border-bottom: 2px dashed rgba(64,199,176,.6); }
#tabZone span { background: var(--panel); padding: 8px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; color: var(--teal-strong); }
body.dragging.tabdrop #tabZone { display: grid; }
body.tabhot #tabZone { background: rgba(64,199,176,.28); border-bottom-style: solid; }
body.tabhot #dropHint { opacity: .35; }

/* Unterschriften */
.sig-menu { width: 260px; padding: 8px; gap: 6px; }
.sig-menu .sig-item { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #fff; height: 64px; display: grid; place-items: center; cursor: pointer; }
.sig-menu .sig-item:hover { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.sig-menu .sig-item img { max-width: 92%; max-height: 54px; }
.sig-menu .sig-item .x { position: absolute; right: 4px; top: 4px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0,0,0,.08); color: #555; cursor: pointer; display: none; line-height: 18px; padding: 0; text-align: center; }
.sig-menu .sig-item:hover .x { display: block; }
.sig-menu .sig-empty { font-size: 12px; color: var(--ink-soft); padding: 4px 4px 2px; }
.sig-preview { height: 150px; border-radius: 10px; display: grid; place-items: center; margin: 8px 0 4px;
  background: repeating-conic-gradient(#e6e6e6 0% 25%, #fff 0% 50%) 50% / 16px 16px; }
.sig-preview img { max-width: 95%; max-height: 140px; }

/* Suchen & Ersetzen, Seitenauswahl-Chips */
#srCard .results { margin-top: 10px; }
.results li .rep { flex: none; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 6px; font-size: 11px; padding: 1px 7px; cursor: pointer; }
.results li .rep:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.chips button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.pg-chips { max-height: 150px; overflow-y: auto; margin-top: 4px; }
.pg-chips button { min-width: 34px; }
.eb.img.hf { border-color: rgba(162, 116, 224, .7); }
body.mode-edit .eb.img.hf { background: rgba(162, 116, 224, .2); }

/* Konto */
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--teal); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .3px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25), var(--shadow); flex: none; }
.avatar:hover { background: var(--teal-strong); }
.avatar.big { width: 42px; height: 42px; font-size: 15px; cursor: default; display: grid; place-items: center; }
#topbar { gap: 10px; }
.auth-view { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; overflow: auto;
  background: radial-gradient(circle at 25% 15%, rgba(64,199,176,.30), transparent 55%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 26px 28px 22px; text-align: center; }
.auth-card h1 { font-size: 22px; margin: 4px 0 14px; }
.auth-card h2 { font-size: 18px; margin: 10px 0 6px; }
.auth-card p { color: var(--ink-soft); line-height: 1.5; margin: 0 0 14px; font-size: 12.5px; }
.auth-logo svg { width: 78px; height: 78px; }
.auth-tabs.switcher { margin: 4px 0 6px; }
.auth-tabs.switcher button { flex: 1; justify-content: center; }
.auth-card form { text-align: left; }
.auth-card label { display: block; font-size: 11.5px; color: var(--ink-soft); margin: 10px 0 4px; }
.auth-card input[type=text], .auth-card input[type=email], .auth-card input[type=password] { width: 100%; height: 34px; font-size: 13.5px; }
.auth-card button.primary.big { width: 100%; margin-top: 16px; }
.auth-msg { margin-top: 12px; padding: 8px 10px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 12px; line-height: 1.4; }
.auth-foot { margin: 14px 0 0 !important; font-size: 11.5px !important; }
.auth-foot a { color: var(--teal-strong); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
.auth-card.lock .btn-col { margin-top: 6px; text-align: left; }
.lock-ic { width: 66px; height: 66px; border-radius: 50%; margin: 2px auto 0; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-strong); }
.acct-menu { position: fixed; top: 54px; right: 14px; z-index: 150; width: 270px; background: var(--panel); border-radius: 14px; box-shadow: 0 0 0 1px var(--line), 0 14px 40px rgba(0,0,0,.25); padding: 10px; display: flex; flex-direction: column; gap: 3px; }
body.native-mac .acct-menu { top: 8px; }
.acct-head { display: flex; gap: 10px; align-items: center; padding: 4px 4px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.acct-head div:last-child { display: flex; flex-direction: column; min-width: 0; }
.acct-head span { color: var(--ink-soft); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-line { font-size: 11.5px; color: var(--ink-soft); padding: 2px 6px 6px; }
.acct-menu button { border: 0; background: transparent; text-align: left; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.acct-menu button:hover { background: var(--teal); color: #fff; }
.acct-menu button.danger { color: var(--danger); }
.acct-menu button.danger:hover { background: var(--danger); color: #fff; }
.dev-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 300px; overflow: auto; }
.dev-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 9px; }
.dev-row div { display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; }
.dev-row span { font-size: 11px; color: var(--ink-soft); }
.dev-row button { flex: none; height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; font-size: 12px; }
.dev-row button:hover { background: var(--danger-soft); border-color: rgba(217,68,58,.4); color: var(--danger); }

/* Griffe: vier Ecken und vier Kanten */
.eb .h.tl { left: -6px; top: -6px; cursor: nwse-resize; }
.eb .h.tr { right: -6px; top: -6px; cursor: nesw-resize; }
.eb .h.bl { left: -6px; bottom: -6px; cursor: nesw-resize; }
.eb .h.l { left: -6px; top: calc(50% - 5px); cursor: ew-resize; }
.eb .h.t { left: calc(50% - 5px); top: -6px; cursor: ns-resize; }
.eb.shape { border-color: transparent; min-width: 8px; min-height: 8px; }
.eb.shape::before { content: ""; position: absolute; inset: -5px; }
body.mode-edit .eb.shape { border-color: transparent; }
body.mode-edit .eb.shape.hot { border: 1px solid #e0a020; background: rgba(224, 160, 32, .08); }
.eb.shape.sel { border-color: #e0a020 !important; background: rgba(224, 160, 32, .06) !important; }
.eb.shape .h { border-color: #e0a020; }

/* Ränder: Seitenleisten ein-/ausklappen */
.edge { position: absolute; top: 50%; transform: translateY(-50%); height: 140px; width: 40px; z-index: 26; display: grid; place-items: center; }
.edge-l { left: 0; }
.edge-r { right: 12px; justify-items: end; }
.edge button { width: 22px; height: 54px; border: 0; cursor: pointer; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); color: var(--ink-soft); display: grid; place-items: center; opacity: .85; transition: opacity .15s; padding: 0; }
.edge-l button { border-radius: 0 12px 12px 0; }
.edge-r button { border-radius: 12px 0 0 12px; }
.edge:hover button, .edge button:focus-visible { opacity: 1; }
.edge button svg { width: 14px; height: 14px; transition: transform .15s; }
.edge-l button svg { transform: rotate(180deg); }
body.left-closed .edge-l button { opacity: .85; }
body.left-closed .edge-l button svg { transform: none; }
body.right-closed .edge-r button { opacity: .85; }
body.right-closed .edge-r button svg { transform: rotate(180deg); }
body.no-doc .edge, body.mode-pages .edge-l { display: none; }
body.left-closed #sidebar { display: none; }
body.right-closed #inspector { display: none; }

/* Zoom-Schieber */
#zoomSlider { position: fixed; z-index: 90; width: 270px; height: 40px; border-radius: 999px; display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.zs-track { position: relative; flex: 1; height: 6px; border-radius: 3px; background: var(--line-strong); }
.zs-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--teal); width: 30%; }
.zs-thumb { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35), 0 0 0 1px var(--line); transform: translate(-50%, -50%); left: 30%; }
.zs-val { width: 46px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 500; }

/* Symbole */
.sym-menu { width: 252px; padding: 10px; }
.sym-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sym-grid button { height: 46px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); display: grid; place-items: center; text-align: center; }
.sym-grid button:hover { background: var(--teal-soft); border-color: var(--teal); color: inherit; }
.sym-grid svg { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sym-set { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); display: grid; gap: 6px; font-size: 12px; }
.sym-set .r { display: flex; gap: 8px; align-items: center; }
.sym-set label { color: var(--ink-soft); flex: none; }
.sym-set input[type=number], .sym-set select { height: 26px; }

/* Einfügen-Position */
.place-card { padding: 9px 10px; }
.place-card label { margin: 0 0 4px !important; }
.place-card select { height: 26px; font-size: 12px; }
.place-card .pg-chips { max-height: 110px; }

/* Suchergebnisse: ganze Zeile sichtbar */
.results li .ctx { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.results li { align-items: flex-start; }

/* Kopierrecht */
#inspector { display: flex; flex-direction: column; }
#inspector > .panel { flex: none; }
.copyright { margin-top: auto; padding-top: 22px; text-align: center; font-size: 10.5px; color: var(--ink-soft); opacity: .4; user-select: none; }
body.mode-pages .panel[data-for="pages"] .check { margin-top: 2px; }

/* Komprimieren */
.panel[data-for="edit"] .tool-row .tool-wide { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 8px; padding: 9px 4px; }
.cp-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 2px; font-size: 12.5px; }
.cp-head b { font-size: 15px; color: var(--teal-strong); font-variant-numeric: tabular-nums; }
.cp-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-soft); margin-top: -2px; }
.cp-list { list-style: none; margin: 10px 0 4px; padding: 0; display: grid; gap: 5px; }
.cp-list li { position: relative; padding-left: 16px; font-size: 11.5px; line-height: 1.4; color: var(--ink); }
.cp-list li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.cp-list li.warn { color: var(--danger); }
.cp-list li.warn::before { background: var(--danger); }
.cp-go { width: 100%; margin-top: 10px !important; }
.cp-res { margin: 10px 0 8px; padding: 9px 10px; border-radius: 8px; background: var(--teal-soft); font-size: 12.5px; line-height: 1.45; }
.cp-res b { color: var(--teal-strong); }
.cp-res small { display: block; color: var(--ink-soft); font-size: 11px; }

/* Update-Hinweis (klein, unaufdringlich) */
.update-note { display: block; margin: 0 0 6px; font-size: 11px; color: var(--teal-strong); text-decoration: none; text-align: center; }
.update-note:hover { text-decoration: underline; }
.update-note::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--teal); margin-right: 6px; vertical-align: middle; }
.acct-update { display: block; font-size: 12px; color: var(--teal-strong); text-decoration: none; padding: 6px 12px; }
.acct-update:hover { text-decoration: underline; }
.legal-ver { font-size: 11px; color: var(--ink-soft); margin: 4px 0 0; }

#scrim { display: none; }
/* ================= Handy und Tablet (Browser, schmales Fenster: body.mobile) ================= */
button, .tb-btn, .switcher button, .edge button { touch-action: manipulation; }
/* Touch-Bedienung: ausgewähltes Element nimmt Wischen selbst entgegen (Verschieben/Größe), alles andere scrollt */
@media (pointer: coarse) {
  .eb.sel { pointer-events: auto; touch-action: none; }
  .eb .h { width: 22px; height: 22px; border-radius: 6px; }
  .eb .h.br { right: -12px; bottom: -12px; }
  .eb .h.tl { left: -12px; top: -12px; }
  .eb .h.tr { right: -12px; top: -12px; }
  .eb .h.bl { left: -12px; bottom: -12px; }
  .eb .h.r { right: -12px; top: calc(50% - 11px); }
  .eb .h.l { left: -12px; top: calc(50% - 11px); }
  .eb .h.t { left: calc(50% - 11px); top: -12px; }
  .eb .h.b { left: calc(50% - 11px); bottom: -12px; }
  .tb-btn { width: 40px; height: 38px; }
}
body.mobile #viewer { touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
body.mobile { overscroll-behavior: none; }
body.mobile #topbar { height: auto; flex-wrap: wrap; justify-content: flex-start; padding: 6px 10px 8px; gap: 6px 8px; }
body.mobile .tb-left { order: 1; flex: 1 1 auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
body.mobile .tb-left::-webkit-scrollbar { display: none; }
body.mobile .tb-title, body.mobile .tb-sep { display: none; }
body.mobile #avatar { order: 2; flex: none; }
body.mobile #modeSwitch { order: 3; flex: 1 0 100%; justify-content: space-between; gap: 2px; }
body.mobile #modeSwitch button { flex: 1; justify-content: center; padding: 9px 4px; font-size: 12.5px; gap: 5px; min-width: 0; }
body.mobile .tb-btn { width: 42px; height: 40px; flex: none; }
body.mobile .tb-btn svg { width: 20px; height: 20px; }
/* Seitenleisten werden Schubladen über der Seite */
body.mobile #shell { position: relative; }
body.mobile #sidebar { position: absolute; left: 0; top: 0; bottom: 0; z-index: 70; width: min(168px, 44vw); box-shadow: 4px 0 24px rgba(0,0,0,.28); }
body.mobile #inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 70; width: min(340px, 90vw); box-shadow: -4px 0 24px rgba(0,0,0,.28); }
body.mobile #scrim { display: none; position: absolute; inset: 0; z-index: 60; background: rgba(0,0,0,.32); }
body.mobile:not(.left-closed):not(.no-doc) #scrim, body.mobile:not(.right-closed):not(.no-doc) #scrim { display: block; }
body.mobile.mode-pages #sidebar { display: none; }
body.mobile.right-closed #modeSwitch [data-mode="edit"], body.mobile.right-closed #modeSwitch [data-mode="redact"] { display: flex; }
/* Griffe zum Öffnen der Schubladen: gut sichtbar und groß genug zum Treffen */
body.mobile .edge { z-index: 55; height: 120px; width: 46px; }
body.mobile .edge-r { right: 0; }
body.mobile .edge button { width: 30px; height: 72px; opacity: .92; }
body.mobile.left-closed .edge-l button, body.mobile.right-closed .edge-r button { opacity: .92; }
/* geöffnete Schublade: der Griff zum Schließen sitzt an ihrer Kante und liegt über ihr */
body.mobile:not(.right-closed) .edge-r { right: min(340px, 90vw); z-index: 80; }
body.mobile:not(.left-closed) .edge-l { left: min(168px, 44vw); z-index: 80; }
body.mobile #pages { padding: 10px 6px 110px; gap: 12px; }
body.mobile #pageGrid { padding: 14px 8px 80px; gap: 12px 6px; justify-content: center; }
body.mobile .gp { width: 150px; }
body.mobile #zoomBar { bottom: 12px; max-width: calc(100% - 24px); }
body.mobile #selBar { left: 50%; bottom: 66px; transform: translateX(-50%); display: flex; gap: 4px; padding: 4px; border-radius: 999px; z-index: 56; }
body.mobile #selBar.hidden { display: none; }
#selBar button { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; border-radius: 999px; padding: 9px 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
#selBar button.danger { background: #d92d20; color: #fff; font-weight: 600; }
#selBar button.danger:hover { background: #b42318; }
#selBar { display: none; }
body.mobile #selBar { display: flex; }
body.mobile #findBar { left: 10px; right: 10px; width: auto; }
body.mobile .start-card { padding: 22px 18px; }
body.mobile .modal { padding: 12px; align-items: end; }
body.mobile .modal-box { width: 100%; max-height: 86vh; }
body.mobile .acct-menu { right: 8px; max-width: calc(100vw - 16px); }
body.mobile .auth-view { padding: 12px; }
@media (max-width: 420px) { body.mobile #modeSwitch button svg { display: none; } }

/* ---------- Register der geöffneten PDFs (Browser) ---------- */
#tabsBar { flex: none; display: flex; align-items: stretch; gap: 4px; padding: 6px 10px 0; background: var(--side); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
#tabsBar::-webkit-scrollbar { display: none; }
#tabsBar .tab { display: flex; align-items: center; gap: 8px; max-width: 240px; min-width: 110px; padding: 7px 8px 7px 14px; border-radius: 10px 10px 0 0; background: transparent; color: var(--ink-soft); font-size: 12.5px; cursor: pointer; border: 1px solid transparent; border-bottom: 0; flex: none; }
#tabsBar .tab:hover { background: var(--line); color: var(--ink); }
#tabsBar .tab.on { background: var(--bg); color: var(--ink); border-color: var(--line); font-weight: 600; box-shadow: inset 0 2px 0 var(--teal); }
#tabsBar .tn { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tabsBar .td { width: 7px; height: 7px; border-radius: 50%; background: transparent; flex: none; }
#tabsBar .td.on { background: var(--teal); }
#tabsBar .tx, #tabsBar .tab-add { width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; display: grid; place-items: center; cursor: pointer; color: inherit; flex: none; }
#tabsBar .tx:hover, #tabsBar .tab-add:hover { background: var(--line); color: var(--ink); }
#tabsBar .tx svg, #tabsBar .tab-add svg { width: 13px; height: 13px; }
#tabsBar .tab-add { align-self: center; margin: 0 2px 4px; }
body.mobile #tabsBar { padding: 4px 6px 0; }
body.mobile #tabsBar .tab { min-width: 96px; max-width: 170px; padding: 8px 6px 8px 12px; }
body.native-mac #tabsBar { display: none; }

/* iPhone/iPad: Eingabefelder unter 16 px lassen Safari beim Antippen in die Seite hineinzoomen (und danach vergrößert bleiben) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (pointer: coarse) { input, select, textarea:not(.tedit) { font-size: 16px !important; } }
body.mobile input, body.mobile select, body.mobile textarea:not(.tedit) { font-size: 16px !important; }
body.mobile { touch-action: manipulation; }

/* Rechteck-Auswahl per Touch: Aktivierung sichtbar machen und Textauswahl/Lupe des Browsers beim langen Drücken verhindern */
.marq.pulse { animation: marqPulse .9s ease-in-out infinite; }
@keyframes marqPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .55; } }
body.mobile .page, body.mobile .ov { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* Gruppen und Mehrfachauswahl */
/* Gruppe: ein blauer Rahmen um die ganze Gruppe, die Mitglieder zeigen keinen eigenen Umriss */
body.mode-edit .eb.gframe { border: 1px dashed rgba(59, 130, 246, .7); background: rgba(59, 130, 246, .2); border-radius: 2px; }
body.mode-edit .eb.gframe.ghot { border: 1px solid #3b82f6; background: rgba(59, 130, 246, .08); }
body.mode-edit .eb.gframe.on { border: 1px dashed #3b82f6; background: rgba(59, 130, 246, .08); }
body.mode-edit .eb.grp:not(.sel), body.mode-edit .eb.grp:not(.sel).multi, body.mode-edit .eb.grp:not(.sel).hot, body.mode-edit .eb.grp:not(.sel).hf { border-color: transparent !important; background: transparent !important; }
.marq.mdrag { border: 1.5px dashed var(--teal); background: rgba(64,199,176,.12); }
@media (pointer: coarse) { .eb.multi { pointer-events: auto; touch-action: none; } }

/* Drehgriff über ausgewählten Bildern, Unterschriften und Formen */
.eb .h.rot { left: calc(50% - 11px); top: -36px; width: 22px; height: 22px; border-radius: 50%; border-width: 1.5px; cursor: grab; display: grid; place-items: center; color: var(--teal); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.eb .h.rot svg { width: 14px; height: 14px; pointer-events: none; }
.eb .h.rot::before { content: ""; position: absolute; left: 50%; top: 100%; height: 14px; border-left: 1.5px solid var(--teal); pointer-events: none; }
.eb .h.rot.below { top: auto; bottom: -36px; }
.eb .h.rot.below::before { top: auto; bottom: 100%; }
body.rotating, body.rotating * { cursor: grabbing !important; }
.rotghost { position: absolute; border: 1.5px dashed var(--teal); background: rgba(64,199,176,.14); pointer-events: none; transform-origin: 50% 50%; z-index: 5; }
.rotval { position: absolute; left: 50%; top: -24px; transform: translateX(-50%); font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 8px; background: var(--teal); color: #fff; white-space: nowrap; }
@media (pointer: coarse) { .eb .h.rot { left: calc(50% - 16px); top: -46px; width: 32px; height: 32px; } .eb .h.rot svg { width: 18px; height: 18px; } .eb .h.rot.below { top: auto; bottom: -46px; } .eb .h.rot::before { height: 16px; } }
/* Seiten auf ein Register ziehen */
#tabsBar .tab.drophot { background: rgba(64,199,176,.22); border-color: var(--teal); color: var(--ink); }
/* Eigene Schriften */
.fm-note { font-size: 12.5px; line-height: 1.5; margin: 0 0 10px; }
.fm-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; margin-bottom: 10px; }
.fm-empty { padding: 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--ink-soft); font-size: 13px; text-align: center; }
.fm-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.fm-row.bad { border-color: var(--mark, #e5483d); }
.fm-main { flex: 1; min-width: 0; font-size: 13px; }
.fm-path-txt { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-err { color: #c0392b; font-size: 12px; margin-top: 2px; }
.fm-warn { color: #a06a00; font-size: 11.5px; margin-top: 2px; line-height: 1.4; }
.fm-del { flex: none; }
.fm-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.fm-lbl { display: block; margin: 8px 0 4px; font-size: 12px; }
.fm-path { display: flex; gap: 8px; }
.fm-path input { flex: 1; min-width: 0; }
.fm-msg { color: #c0392b; font-size: 12.5px; min-height: 0; margin: 6px 0; }
.fm-msg:empty { display: none; }
.fm-pending { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; font-size: 13px; }
.fm-pending .check { display: block; margin: 4px 0; }

/* Formularfelder: im Bearbeiten-Modus wie eine leere Textbox, aber rot gestrichelt mit rotem Hintergrund (in „Ansehen“ gibt es sie nicht) */
body.mode-edit .eb.ff { border: 1px dashed rgba(220, 38, 38, .9); background: rgba(220, 38, 38, .2); border-radius: 2px; }
body.mode-edit .eb.ff.sel { border-color: #dc2626 !important; background: rgba(220, 38, 38, .1) !important; }
body.mode-edit .eb.ff.hot { border: 1px solid #dc2626; background: rgba(220, 38, 38, .12); }
.eb.ff .h { border-color: #dc2626; }
.eb .ff-tag { position: absolute; left: -1px; top: -17px; font-size: 10px; line-height: 15px; padding: 0 6px; border-radius: 5px 5px 0 0; background: #dc2626; color: #fff; white-space: nowrap; pointer-events: none; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.ffdraw { position: absolute; border: 1px dashed #dc2626; background: rgba(220, 38, 38, .18); pointer-events: none; z-index: 5; }
/* Werkzeug „Formular“: nur Felder anfassen, Texte und Bilder zeigen keinen Rahmen */
body.tool-form.mode-edit .eb:not(.ff) { border-color: transparent !important; background: transparent !important; }
body.tool-form.mode-edit .pages .page, body.ff-armed.mode-edit .pages .page { cursor: crosshair; }
.ff-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 8px 0 10px; }
.ff-types button { display: flex; align-items: center; gap: 6px; justify-content: flex-start; min-width: 0; padding: 8px 8px; font-size: 12px; line-height: 1.2; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-align: left; overflow: hidden; }
.ff-types button span { min-width: 0; overflow-wrap: anywhere; }
.ff-types button:hover { border-color: rgba(64,199,176,.6); }
.ff-types button svg { width: 15px; height: 15px; flex: none; color: var(--ink-soft); }
.ff-types button.wide { grid-column: 1 / -1; }
.ff-types button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.ff-types button.on svg { color: #fff; }
#ffProps h4 { margin: 12px 0 2px; font-size: 13px; }
#ffProps textarea { width: 100%; resize: vertical; font: inherit; }
.ff-list { margin-top: 10px; font-size: 12px; }
.ff-list button { display: flex; width: 100%; justify-content: space-between; gap: 8px; padding: 4px 8px; margin: 2px 0; border: 0; background: transparent; color: var(--ink-soft); text-align: left; border-radius: 6px; cursor: pointer; }
.ff-list button:hover, .ff-list button.on { background: rgba(220, 38, 38, .12); color: var(--ink); }
.ff-list .t { color: var(--ink-soft); font-size: 11px; white-space: nowrap; }

.rotghost.snap { border-style: solid; background: rgba(64,199,176,.28); }
.rotghost.snap .rotval { background: #0f9d86; font-weight: 600; }

/* Ansehen: ausfüllbare Formularfelder (unsichtbar, beim Darüberfahren türkis; am Handy per Antippen) */
.ffv { position: absolute; z-index: 4; cursor: text; border-radius: 2px; mix-blend-mode: multiply; }
@media (hover: hover) { .ffv:not(.ro):hover { background: rgba(64, 199, 176, .32) !important; } }
.ffv.ro { cursor: default; }
.ffv.btn { cursor: pointer; }
.ffed { position: absolute; z-index: 30; box-sizing: border-box; border: 2px solid var(--teal); background: #fff; color: #000; font-family: Helvetica, Arial, sans-serif; padding: 0 3px; margin: 0; outline: none; border-radius: 2px; box-shadow: 0 2px 10px rgba(0,0,0,.25); resize: none; }
textarea.ffed { padding: 2px 3px; line-height: 1.2; }

/* Objekt duplizieren: schwebend mittig über dem Zoom */
#dupBar { left: 50%; bottom: 62px; transform: translateX(-50%); display: flex; padding: 3px; border-radius: 999px; z-index: 56; }
#dupBar.hidden { display: none; }
#dupBar button { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink); }
#dupBar button svg { width: 15px; height: 15px; }
#dupBar button:hover { background: var(--line); }
body.mobile #dupBar { bottom: 120px; }
/* Ansehen: Hintergrund der Eingabefelder nur am Bildschirm (kommt nicht in den Ausdruck); Pfeil der Dropdowns ebenfalls */
.ffv.cmb::after { content: ""; position: absolute; right: 4px; top: 50%; margin-top: -2px; border: 4px solid transparent; border-top: 5px solid rgba(60, 70, 90, .6); border-bottom: 0; pointer-events: none; }
.ffsig { width: 100%; height: 190px; border: 1px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; display: block; cursor: crosshair; }

/* Ähnliche Elemente nachträglich verknüpfen */
#simBar { left: 50%; bottom: 62px; transform: translateX(-50%); width: min(440px, calc(100% - 24px)); padding: 14px 16px 12px; border-radius: 16px; z-index: 58; max-height: calc(100% - 140px); overflow: auto; }
#simBar.hidden { display: none; }
#simBar.top { bottom: auto; top: 70px; }
body.mobile #simBar.top { top: 110px; bottom: auto; }
#simBar h4 { margin: 0 0 4px; font-size: 14px; }
#simBar .hint { margin: 0 0 8px; }
.sim-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; max-height: 190px; overflow: auto; }
.sim-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.sim-row:hover { background: var(--line); }
.sim-row input { flex: none; }
.sim-row .pg { font-weight: 600; flex: none; }
.sim-row .why { color: var(--ink-soft); font-size: 11.5px; min-width: 0; flex: 1; }
.sim-row .rm { margin-left: auto; border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.sim-add { display: flex; align-items: center; gap: 6px; width: 100%; border: 1px dashed var(--line); background: transparent; border-radius: 10px; padding: 8px 10px; font-size: 13px; cursor: pointer; color: var(--ink); }
.sim-add svg { width: 15px; height: 15px; }
.sim-add:hover, .sim-add.on { border-color: #a274e0; background: rgba(162, 116, 224, .12); }
.sim-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.sim-btns button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink); }
.sim-btns button.primary { background: #a274e0; border-color: #a274e0; color: #fff; }
.sim-btns button:disabled { opacity: .45; cursor: default; }
body.sim-pick .page { cursor: crosshair; }
body.mobile #simBar { bottom: 120px; }
/* Hervorhebung der gefundenen Elemente (lila, wie Kopf-/Fußzeilen) */
.eb.sim { pointer-events: none; border: 2px solid #a274e0; background: rgba(162, 116, 224, .28); border-radius: 3px; box-shadow: 0 0 0 3px rgba(162, 116, 224, .25); }
.eb.sim.off { opacity: .35; border-style: dashed; }
.eb.sim.ref { background: rgba(162, 116, 224, .12); }
.eb .sim-tag { position: absolute; left: -2px; top: -19px; font-size: 10.5px; line-height: 16px; padding: 0 6px; border-radius: 5px 5px 0 0; background: #a274e0; color: #fff; white-space: nowrap; pointer-events: none; }
body.mode-edit .eb.ff.linked { border-color: rgba(162, 116, 224, .9); background: rgba(162, 116, 224, .2); }
body.mode-edit .eb.ff.linked.sel { border-color: #a274e0 !important; background: rgba(162, 116, 224, .1) !important; }
.eb.ff.linked .h { border-color: #a274e0; }
.eb.ff.linked .ff-tag { background: #a274e0; }
