/* 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; }
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:hover { border: 1px solid var(--teal); background: rgba(64, 199, 176, .07); }
body.mode-edit .eb.img:hover { 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; }

.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: 100; padding: 20px; }
.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:hover { 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:hover { 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: 0; 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: .5; }
body.left-closed .edge-l button svg { transform: none; }
body.right-closed .edge-r button { opacity: .5; }
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; }
body.right-closed #modeSwitch [data-mode="edit"], body.right-closed #modeSwitch [data-mode="redact"] { 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; }
