/* ==========================================================================
   PDF Editor 24 — Design System
   Systemschriften, keine externen Requests (Google-Fonts-Problematik,
   LG Muenchen I, Az. 3 O 17493/20). Alles laeuft lokal.
   ========================================================================== */

:root {
  --bg:          #f5f7fa;
  --bg-alt:      #eef1f6;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --text:        #10151c;
  --muted:       #5b6673;
  --border:      #dde3ea;
  --border-str:  #c3ccd8;

  --primary:     #1452d6;
  --primary-h:   #0f42af;
  --primary-ink: #ffffff;
  --primary-bg:  #e8eefc;

  --trust:       #0f7b4f;
  --trust-bg:    #e7f5ef;
  --trust-br:    #b9e2d0;

  --danger:      #b32318;
  --danger-bg:   #fdeceb;

  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
  --shadow-lg:   0 8px 28px rgba(16,24,40,.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0f1319; --bg-alt:#141a22; --surface:#171d26; --surface-2:#1d242e;
    --text:#e8edf3; --muted:#9aa7b5; --border:#2a333f; --border-str:#3b4654;
    --primary:#5b8dfb; --primary-h:#77a1fc; --primary-ink:#0b1017; --primary-bg:#18233a;
    --trust:#4ec89a; --trust-bg:#12241d; --trust-br:#1f4435;
    --danger:#f97066; --danger-bg:#2a1512;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.5);
  }
}

:root[data-theme="dark"] {
  --bg:#0f1319; --bg-alt:#141a22; --surface:#171d26; --surface-2:#1d242e;
  --text:#e8edf3; --muted:#9aa7b5; --border:#2a333f; --border-str:#3b4654;
  --primary:#5b8dfb; --primary-h:#77a1fc; --primary-ink:#0b1017; --primary-bg:#18233a;
  --trust:#4ec89a; --trust-bg:#12241d; --trust-br:#1f4435;
  --danger:#f97066; --danger-bg:#2a1512;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; }

/* Symbole aus icons/ – die Farbe kommt ueber currentColor aus dem Schalter. */
.ico-flip { transform: scaleX(-1); }

/* Eine eigene display-Angabe schlaegt das Attribut hidden, egal wie die
   Spezifitaet steht. Ohne diese Regel bleiben ausgeblendete Schalter
   sichtbar – und ein toter Schalter ist schlimmer als gar keiner. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.85rem); }
h3 { font-size: 1.1rem; }
p  { margin: 0 0 1em; }

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-h); }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: 16px; }
.section { padding: 56px 0; }
.section--alt { background: var(--bg-alt); }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }
.center { text-align: center; }
.center .lede { margin-inline: auto; }

/* ---------- Kopfzeile ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; gap: 20px; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.05rem;
         color: var(--text); text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.brand svg { flex: 0 0 auto; }
.site-nav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: .93rem; font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }
.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 34px; height: 34px; border-radius: var(--radius-sm); cursor: pointer;
  display: grid; place-items: center; flex: 0 0 auto;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-str); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { background: var(--primary-h); color: var(--primary-ink); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-str); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn--danger-solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn--danger-solid:hover { filter: brightness(.92); color: #fff; }
.btn--sm { padding: 7px 12px; font-size: .86rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Startseite: Hero ---------- */
.hero { padding: 64px 0 40px; }
.hero h1 { max-width: 20ch; }
.hero .lede { margin-bottom: 24px; }
.claims { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; padding: 0; list-style: none; }
.claims li {
  font-size: .86rem; font-weight: 600; color: var(--trust);
  background: var(--trust-bg); border: 1px solid var(--trust-br);
  padding: 5px 11px; border-radius: 999px;
}

/* ---------- Vertrauensbox ---------- */
.trustbox {
  background: var(--trust-bg); border: 1px solid var(--trust-br);
  border-radius: var(--radius); padding: 20px 22px;
}
.trustbox h3 { color: var(--trust); display: flex; align-items: center; gap: 9px; margin-bottom: .6em; }
.trustbox ul { margin: 0; padding-left: 1.15em; }
.trustbox li { margin-bottom: 5px; }
.trustbox li::marker { color: var(--trust); }

/* ---------- 3 Schritte ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; counter-reset: s; }
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); position: relative;
}
.step::before {
  counter-increment: s; content: counter(s);
  display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 12px;
  background: var(--primary); color: var(--primary-ink);
  border-radius: 50%; font-weight: 700; font-size: .92rem;
}
.step h3 { margin-bottom: .3em; }
.step p { margin: 0; color: var(--muted); font-size: .94rem; }

/* ---------- Werkzeug-Raster ---------- */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tool {
  display: flex; flex-direction: column; gap: 7px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; text-decoration: none; color: var(--text);
  box-shadow: var(--shadow); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tool:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--text); }
.tool svg { color: var(--primary); }
.tool b { font-size: .98rem; font-weight: 650; }
.tool span { font-size: .85rem; color: var(--muted); line-height: 1.45; }

/* ---------- FAQ ---------- */
.faq { max-width: 760px; }
.faq details {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px;
}
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--primary); font-weight: 700; font-size: 1.25rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details > p { margin: 12px 0 2px; color: var(--muted); }

/* ---------- Fusszeile ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 34px 0; margin-top: 10px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 26px; align-items: center; }
.site-footer a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer .copy { color: var(--muted); font-size: .9rem; margin-left: auto; }

/* ---------- Rechtstexte ---------- */
.legal { max-width: 760px; }
.legal h2 { margin-top: 1.6em; font-size: 1.25rem; }
.legal .todo {
  background: var(--danger-bg); border-left: 3px solid var(--danger);
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: .92rem; margin-bottom: 1.2em;
}
.legal .todo strong { color: var(--danger); }

/* ---------- Startseite und Rechtstexte auf schmalen Geräten ---------- */
@media (max-width: 860px) {
  .section { padding: 40px 0; }
  .hero { padding: 44px 0 30px; }
  .steps { grid-template-columns: 1fr; }
  .site-header .wrap { gap: 12px; height: auto; min-height: 58px; padding-block: 9px; flex-wrap: wrap; }
  .site-nav { gap: 14px; }
  .lede { font-size: 1.02rem; }
}

@media (max-width: 560px) {
  .tools { grid-template-columns: 1fr; }
  .brand span { font-size: .98rem; }
  .site-nav a { font-size: .88rem; }
  /* Umbrechen statt über den Rand hinauslaufen. */
  .site-nav { flex-wrap: wrap; width: 100%; margin-left: 0; gap: 12px 16px; }
  .btn-row .btn { flex: 1 1 100%; justify-content: center; }
  .site-footer { padding: 26px 0; }
  .site-footer .wrap { gap: 10px 18px; }
  .site-footer .copy { margin-left: 0; width: 100%; }
}


/* ==========================================================================
   Editor – Anwendungsgerüst
   Eine Bildschirmhöhe, drei Reihen (Kopf, Band, Arbeitsfläche) und in der
   Arbeitsfläche drei Spalten (Miniaturen, Bühne, Eigenschaften).
   ========================================================================== */
.app-body { height: 100%; overflow: hidden; }

.app {
  display: flex; flex-direction: column;
  height: 100dvh; min-height: 0; background: var(--bg);
}

/* ---------- Kopfleiste ---------- */
.appbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  height: 54px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.appbar__back { display: none; color: var(--muted); padding: 6px; border-radius: var(--radius-sm); }
.appbar__back:hover { color: var(--text); background: var(--surface-2); }
.appbar__brand {
  display: flex; align-items: center; gap: 9px; flex: 0 0 auto;
  font-weight: 800; font-size: 1rem; color: var(--text); text-decoration: none;
}
.appbar__brand svg { color: var(--primary); }
.appbar .spacer { margin-left: auto; }

.appbar__doc {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .84rem; color: var(--muted);
}
.appbar__doc svg { flex: 0 0 auto; color: var(--primary); }
.appbar__doc b {
  font-weight: 600; color: var(--text);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body[data-view="empty"] .appbar__doc { display: none !important; }

.appbar__acts { display: flex; align-items: center; gap: 6px; }
.appbar .appbar__more { display: none; }

/* ---------- Reiter ---------- */
.tabs { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.tab {
  border: 0; background: none; font: inherit; font-size: .9rem; font-weight: 600;
  color: var(--muted); padding: 7px 13px; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--primary); background: var(--primary-bg); }
body[data-view="empty"] .tabs { display: none; }

/* ---------- Kontextband ---------- */
.ribbon {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 7px 12px; min-height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.ribbon__pane { display: none; align-items: center; gap: 4px; width: 100%; }
.ribbon__pane .spacer { margin-left: auto; }
body[data-tab="edit"]     .ribbon__pane[data-pane="edit"],
body[data-tab="annotate"] .ribbon__pane[data-pane="annotate"],
body[data-tab="pages"]    .ribbon__pane[data-pane="pages"],
body[data-tab="text"]     .ribbon__pane[data-pane="text"] { display: flex; }
.ribbon__sep { flex: 0 0 auto; width: 1px; height: 32px; background: var(--border); margin-inline: 7px; }

.tool-btn {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 64px; padding: 6px 9px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; color: var(--muted); font: inherit; font-size: .72rem; font-weight: 600;
  cursor: pointer; text-align: center; line-height: 1.2;
}
.tool-btn:hover { background: var(--surface-2); color: var(--text); }
.tool-btn.active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.tool-btn:disabled { opacity: .4; cursor: not-allowed; }
.tool-btn:disabled:hover { background: none; color: var(--muted); }
.tool-btn--danger:hover { background: var(--danger-bg); color: var(--danger); }
.tool-btn--row { flex-direction: row; gap: 7px; font-size: .84rem; padding: 9px 12px; }

/* ---------- Arbeitsfläche ---------- */
.work { flex: 1; min-height: 0; display: flex; position: relative; }

/* Miniaturen links */
.rail {
  flex: 0 0 186px; width: 186px; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.rail__head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 9px 10px 9px 16px; border-bottom: 1px solid var(--border);
  font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.rail__head > span:first-child { margin-right: auto; }
.rail__list { flex: 1; overflow-y: auto; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; }

.rcard {
  position: relative; border: 0; background: none; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px; font: inherit;
}
.rcard__sheet {
  width: 100%; aspect-ratio: 1 / 1.414; overflow: hidden;
  background: #fff; border: 2px solid var(--border);
  border-radius: var(--radius-sm); display: grid; place-items: center;
  transition: border-color .12s;
}
.rcard__sheet img { max-width: 100%; max-height: 100%; display: block; }
.rcard:hover .rcard__sheet { border-color: var(--border-str); }
.rcard__n {
  font-size: .74rem; font-weight: 600; color: var(--muted);
  min-width: 21px; padding: 1px 6px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.rcard.current .rcard__sheet { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.rcard.current .rcard__n { background: var(--primary); color: var(--primary-ink); }
.rcard.selected .rcard__sheet { border-color: var(--primary); border-style: dashed; }
.rcard__dot {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--primary); color: var(--primary-ink);
  font-size: .62rem; font-weight: 700; display: grid; place-items: center;
}
.rcard__ocr {
  position: absolute; left: 5px; bottom: 26px; z-index: 2;
  background: var(--trust); color: #fff; font-size: .58rem; font-weight: 700;
  letter-spacing: .04em; padding: 1px 5px; border-radius: 999px;
}

/* Griff zum Ein- und Ausblenden */
.rail-toggle {
  position: absolute; top: 50%; left: 186px; z-index: 6;
  transform: translate(-50%, -50%);
  width: 20px; height: 42px; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
  transition: left .16s;
}
.rail-toggle:hover { color: var(--primary); border-color: var(--primary); }
.rail-toggle svg { transition: transform .16s; }
body.rail-off .rail { display: none; }
/* Buendig am Rand statt zur Haelfte dahinter. */
body.rail-off .rail-toggle {
  left: 0; transform: translate(0, -50%);
  border-radius: 0 999px 999px 0; border-left-color: transparent;
}
body.rail-off .rail-toggle svg { transform: rotate(180deg); }
body[data-view="empty"] .rail-toggle,
body[data-view="grid"]  .rail-toggle,
body[data-view="grid"]  .rail { display: none; }

/* Mitte */
.canvas-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* Eigenschaften rechts */
.side {
  flex: 0 0 272px; width: 272px; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
}
.side__head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 9px 8px 9px 14px; border-bottom: 1px solid var(--border);
  font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.side__head > span:first-child { margin-right: auto; }
body[data-view="empty"] .side,
body[data-view="grid"]  .side,
body.side-off .side { display: none; }
.stage-bar .side-reveal { display: none; }
body.side-off .stage-bar .side-reveal { display: grid; }

/* ---------- Ablagefläche ---------- */
.dropzone { flex: 1; display: none; place-items: center; padding: 40px 16px; overflow: auto; }
body[data-view="empty"] .dropzone { display: grid; }
.dropzone__inner {
  max-width: 540px; width: 100%; text-align: center;
  border: 2px dashed var(--border-str); border-radius: var(--radius);
  background: var(--surface); padding: 40px 24px; cursor: pointer;
}
.dropzone__inner svg { color: var(--primary); margin-bottom: 14px; }
.dropzone__inner h2 { margin-bottom: .35em; }
.dropzone__inner p { color: var(--muted); }
body.dragging .dropzone__inner,
.dropzone__inner.hot { border-color: var(--primary); background: var(--primary-bg); }
.hint { font-size: .84rem; color: var(--muted); margin-top: 14px; }

/* ---------- Große Seitenübersicht ---------- */
.grid-view { flex: 1; min-height: 0; overflow: auto; padding: 20px; background: var(--bg); }
.pages {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px; max-width: var(--maxw); margin-inline: auto;
}
.page-card {
  position: relative; background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 9px; cursor: pointer; user-select: none;
  transition: border-color .12s, box-shadow .12s;
}
.page-card:hover { border-color: var(--border-str); box-shadow: var(--shadow); }
.page-card.selected { border-color: var(--primary); background: var(--primary-bg); }
.page-card.drag-over { border-color: var(--primary); border-style: dashed; }
.page-card.dragging { opacity: .4; }
.page-card__thumb {
  aspect-ratio: 1 / 1.414; display: grid; place-items: center; overflow: hidden;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.page-card__thumb img { max-width: 100%; max-height: 100%; display: block; }
.page-card__meta {
  display: flex; align-items: center; gap: 7px; margin-top: 8px;
  font-size: .78rem; color: var(--muted);
}
.page-card__num { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.page-card__src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-card__acts {
  position: absolute; top: 14px; right: 14px; display: flex; gap: 4px;
  opacity: 0; transition: opacity .12s;
}
.page-card:hover .page-card__acts, .page-card.selected .page-card__acts { opacity: 1; }
.page-card__badge {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink);
  border-radius: 9px; font-size: .68rem; font-weight: 700;
}
.card__ocr {
  position: absolute; left: 14px; bottom: 40px; z-index: 2;
  background: var(--trust); color: #fff;
  font-size: .62rem; font-weight: 700; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 999px; pointer-events: none;
}

/* ---------- Kleine runde Schalter ---------- */
.icon-btn {
  display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--muted); cursor: pointer; font: inherit; padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--primary); }
.icon-btn--danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn--bar { width: 32px; height: 32px; border-color: transparent; background: none; font-size: 1.1rem; }
.icon-btn--bar:hover { background: var(--surface-2); border-color: var(--border); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn:disabled:hover { background: none; border-color: transparent; color: var(--muted); }

/* ==========================================================================
   Bühne
   ========================================================================== */
.annot-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.stage-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding: 7px 14px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.stage-bar .spacer { margin-left: auto; }
.stage-bar .sep { width: 1px; height: 22px; background: var(--border); margin-inline: 5px; }
.stage-label { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 60px; text-align: center; }

.stage-wrap {
  flex: 1; overflow: auto; display: grid; place-items: center;
  padding: 26px; background: var(--bg-alt); min-height: 0;
}
.stage {
  position: relative; background: #fff; box-shadow: var(--shadow-lg);
  touch-action: none; flex: 0 0 auto;
}
#pageCanvas { display: block; }
#shapeLayer { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
#objLayer { position: absolute; inset: 0; pointer-events: none; }

/* Nur die Formebene nimmt die ganze Fläche an. Die Objektebene darüber
   bleibt durchlässig; klickbar sind allein ihre Kinder (Text, Bilder,
   Griffe). Sonst fängt sie jeden Klick ab, und Formen, Markierungen und
   Freihandstriche lassen sich mit der Auswahl nicht mehr anklicken. */
.stage[data-tool="select"] #shapeLayer { pointer-events: auto; }

/* Freihand ändern: die Striche nehmen Klicks an, es wird nicht gezeichnet. */
.stage[data-tool="ink-pick"] #shapeLayer { pointer-events: auto; }
.stage[data-tool="ink-pick"] .ann-shape { cursor: move; }
.stage[data-tool="ink-pick"] { cursor: default; }
.stage[data-tool="ink-pick"] .ann-grab { pointer-events: stroke; }

.stage[data-tool="text"]      { cursor: text; }
.stage[data-tool="ink"]       { cursor: crosshair; }
.stage[data-tool="rect"],
.stage[data-tool="ellipse"],
.stage[data-tool="line"],
.stage[data-tool="arrow"],
.stage[data-tool="highlight"],
.stage[data-tool="redact"]    { cursor: crosshair; }

/* ---------- Anmerkungen ---------- */
.ann-shape { pointer-events: visiblePainted; }
.stage[data-tool="select"] .ann-shape { cursor: move; }
.ann-shape.ann-selected { outline: none; filter: drop-shadow(0 0 0 transparent); }

.ann-obj { position: absolute; pointer-events: none; }
.stage[data-tool="select"] .ann-obj { pointer-events: auto; cursor: move; }

.ann-text { white-space: pre; line-height: 1.2; transform-origin: left bottom; }
/* Der Text, der gerade im Eingabefeld steht, nicht ein zweites Mal zeigen. */
.ann-text.ann-editing { visibility: hidden; }
/* Ziehen soll verschieben, nicht Text im Browser markieren. */
.stage { -webkit-user-select: none; user-select: none; }
.ann-edit { -webkit-user-select: text; user-select: text; }
/* Mit dem Textwerkzeug vorhandenen Text anfassen statt daneben neu anzulegen. */
.stage[data-tool="text"] .ann-text { pointer-events: auto; cursor: move; }
.ann-img  { display: block; }

.ann-box {
  position: absolute; pointer-events: none;
  border: 1px dashed var(--primary); outline: 1px solid rgba(255,255,255,.6);
}
.ann-handle {
  position: absolute; width: 11px; height: 11px; margin: -6px 0 0 -6px;
  background: var(--surface); border: 2px solid var(--primary); border-radius: 2px;
  pointer-events: auto; cursor: nwse-resize; z-index: 3;
}
.ann-edit {
  position: absolute; pointer-events: auto; z-index: 4;
  border: 1px solid var(--primary); border-radius: 2px;
  background: rgba(255,255,255,.97); color: inherit;
  padding: 0 2px; margin: 0; line-height: 1.2; resize: none; overflow: hidden;
  white-space: pre; outline: none;
}

/* ---------- Eigenschaften ---------- */
.props { flex: 1; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.props h3 { margin: 0 0 2px; font-size: .95rem; }
.prop { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; }
.prop > span { color: var(--muted); font-weight: 600; }
.prop input[type="color"] { width: 100%; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.prop input[type="range"] { width: 100%; accent-color: var(--primary); }
.prop input[type="number"],
.prop input[type="text"],
.prop select {
  font: inherit; font-size: .88rem; padding: 6px 8px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-str); border-radius: var(--radius-sm);
}
.fillgrp { display: flex; align-items: center; gap: 8px; }
.fillgrp input[type="color"] { flex: 1; }
.chip {
  width: 32px; height: 32px; border: 1px solid var(--border-str); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: .92rem;
}
.chip.active { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
.prop-note { font-size: .79rem; color: var(--muted); line-height: 1.5; margin: 0; }

/* Umschalter Zeichnen / Ändern */
.segbar {
  display: flex; gap: 2px; padding: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.seg {
  flex: 1; border: 0; background: none; font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--muted); padding: 6px 8px; border-radius: 4px; cursor: pointer;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* Striche durchblättern */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper b {
  flex: 1; text-align: center; font-size: .82rem; font-weight: 600;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.stepper .chip { display: grid; place-items: center; width: 30px; height: 30px; }
.prop-del { margin-top: auto; }

/* ==========================================================================
   Suche, Texterkennung
   ========================================================================== */
.search-field {
  display: flex; align-items: center; gap: 7px; flex: 0 1 272px; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border-str);
  border-radius: var(--radius-sm); padding: 0 10px; height: 34px; color: var(--muted);
}
.search-field:focus-within { border-color: var(--primary); color: var(--primary); }
.search-field input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font: inherit; font-size: .9rem; color: var(--text); height: 100%;
}
.search-field input::-webkit-search-cancel-button { cursor: pointer; }

.sel-count { font-size: .86rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#searchCount { min-width: 68px; text-align: center; }

.mini-select {
  flex: 0 0 auto; height: 34px; max-width: 152px;
  border: 1px solid var(--border-str); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: .86rem; padding: 0 6px;
}
.mini-select:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.chk {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: .84rem; color: var(--muted); cursor: pointer; user-select: none;
  padding-inline: 4px;
}
.chk input { accent-color: var(--primary); }

.sr-lbl, .visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ==========================================================================
   Untere Navigation (mobil)
   ========================================================================== */
.tabbar {
  display: none; flex: 0 0 auto;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__btn {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; font: inherit; font-size: .66rem; font-weight: 600;
  color: var(--muted); padding: 8px 2px 7px; cursor: pointer;
  border-top: 2px solid transparent; margin-top: -1px;
}
.tabbar__btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tabbar__btn.active { color: var(--primary); border-top-color: var(--primary); }

/* ==========================================================================
   Werkzeugblatt (mobil)
   ========================================================================== */
.sheet { position: fixed; inset: 0; z-index: 94; display: flex; align-items: flex-end; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(8,12,20,.5); }
.sheet__panel {
  position: relative; width: 100%; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0; overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: sheetUp .22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(14%); opacity: .4; } }

.sheet__hero {
  position: relative; flex: 0 0 auto; padding: 18px 20px 22px;
  background: linear-gradient(135deg, #1452d6 0%, #2f6ae8 55%, #1a4fc4 100%);
  color: #fff;
}
.sheet__hero h2 { font-size: 1.4rem; margin: 0 0 .25em; color: #fff; max-width: 15ch; }
.sheet__hero p { margin: 0; font-size: .88rem; color: rgba(255,255,255,.88); max-width: 30ch; }
.sheet__hero-art { position: absolute; right: 18px; bottom: 14px; color: #fff; opacity: .9; }
.sheet__close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.18); color: #fff;
}
.sheet__close:hover { background: rgba(255,255,255,.3); }

.sheet__body { flex: 1; overflow-y: auto; padding: 16px 16px 26px; }
.sheet__h {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 10px;
}
.sheet__h:first-of-type { margin-top: 4px; }

.filecard {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px; box-shadow: var(--shadow);
}
.filecard__thumb {
  flex: 0 0 auto; width: 42px; height: 56px; border-radius: 5px; overflow: hidden;
  background: #fff; border: 1px solid var(--border); display: grid; place-items: center;
}
.filecard__thumb img { max-width: 100%; max-height: 100%; display: block; }
.filecard__txt { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.filecard__txt b { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filecard__txt span { font-size: .82rem; color: var(--muted); }

.tilegrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  aspect-ratio: 1 / .96; padding: 6px 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); font: inherit; font-size: .68rem; font-weight: 600;
  text-align: center; line-height: 1.2; cursor: pointer;
}
.tile svg { color: var(--primary); }
.tile:hover, .tile:active { border-color: var(--primary); background: var(--primary-bg); }
.tile:disabled { opacity: .4; cursor: not-allowed; }
.tile span {
  max-width: 100%; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

.sheet__save { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet__save .btn { justify-content: center; }
.sheet__note {
  margin: 18px 0 0; font-size: .8rem; color: var(--muted); line-height: 1.5; text-align: center;
}

/* ==========================================================================
   Dialog, Meldungen, Fortschritt
   ========================================================================== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; z-index: 95; padding: 16px;
}
.modal__box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 22px; width: min(560px, 94vw);
}
.modal__box h2 { font-size: 1.2rem; margin-bottom: .2em; }
.modal__lede { color: var(--muted); font-size: .88rem; margin-bottom: 14px; }
.signpad {
  width: 100%; height: 190px; display: block; background: #fff;
  border: 2px dashed var(--border-str); border-radius: var(--radius);
  touch-action: none; cursor: crosshair;
}
.signrow { display: flex; gap: 14px; align-items: flex-end; margin-top: 14px; }
.signrow .prop:first-child { flex: 1; }
.signrow input[type="color"] { width: 54px; }
.modal__acts { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.modal__acts .spacer { margin-left: auto; }

/* Allgemeiner Dialog */
.dlg-fields { display: flex; flex-wrap: wrap; gap: 14px; }
/* Doppelte Klasse, damit die mobile Regel für .prop in der rechten Leiste
   den Dialog nicht in schmale Spalten zwängt. */
.dlg-fields .dlg-field { flex: 1 1 100%; min-width: 0; }
.dlg-fields .dlg-field--half { flex: 1 1 calc(50% - 7px); min-width: 140px; }
.dlg-fields .segbar .seg { white-space: nowrap; }
.dlg-field input[type="text"], .dlg-field input[type="number"], .dlg-field select { width: 100%; }
.dlg-field .opacity-value { float: right; color: var(--muted); font-weight: 500; }
.dlg-note { margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--primary-bg); color: var(--text); font-size: .84rem; line-height: 1.5; }

/* --------------------------------------------- Speichern, Fortschritt, Feedback */
.xp { position: relative; width: min(500px, 94vw); padding: 26px 28px 24px; border-radius: 16px;
  max-height: calc(100vh - 32px); overflow-y: auto; }
.xp h2 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin: 0 40px 18px 0; }
.xp .modal__lede { font-size: .95rem; color: var(--text); margin: -8px 0 16px; }
.xp__close { position: absolute; top: 18px; right: 18px; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.xp__close:hover { background: var(--surface-2); }
.xp__field { display: flex; flex-direction: column; gap: 7px; margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.xp__label { font-weight: 700; font-size: .95rem; color: var(--text); padding: 0; }
.xp__label--light { font-weight: 500; }
.xp__field input[type="text"], .xp__field input[type="email"], .xp__field select, .xp__field textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: .98rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-str); border-radius: 8px; }
.xp__field textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
.xp__field input:focus, .xp__field select:focus, .xp__field textarea:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.xp__radio { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: .98rem; cursor: pointer; }
.xp__radio input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); flex: 0 0 auto; }
.xp__radio b { font-weight: 700; }
.xp__range { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 0 30px; }
.xp__range small, .xp__count, .xp__hint { color: var(--muted); font-size: .8rem; }
.xp__count { align-self: flex-end; margin-top: -2px; }
.xp__hint { margin: -4px 0 0; line-height: 1.5; }
.xp__more { margin: 0 0 16px; }
.xp__more summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  font-size: .98rem; padding: 4px 0; color: var(--text); }
.xp__more summary::-webkit-details-marker { display: none; }
.xp__more summary svg { transition: transform .15s; }
.xp__more[open] summary svg { transform: rotate(180deg); }
.xp__moreBody { padding: 12px 0 0 26px; }
.xp__check { display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; line-height: 1.45; cursor: pointer; }
.xp__check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.xp__safe { display: flex; align-items: center; gap: 12px; margin: 0; padding: 14px 16px; border-radius: 10px;
  background: #d9f7ea; color: #0b4a33; font-size: .98rem; }
.xp__safe svg { flex: 0 0 auto; }
.xp__err { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--danger-bg);
  color: var(--danger); font-size: .88rem; }
.xp .modal__acts { margin-top: 22px; gap: 12px; }
.xp .modal__acts .btn { min-width: 120px; }

/* Fortschritt */
.xp--prog { text-align: center; width: min(460px, 94vw); }
.xp--prog h2 { text-align: left; }
.xp__ring { position: relative; width: 200px; height: 200px; margin: 6px auto 18px; }
.xp__ring svg:first-child { width: 100%; height: 100%; transform: rotate(-90deg); }
.xp__track, .xp__bar { fill: none; stroke-width: 12; }
.xp__track { stroke: var(--primary-bg); }
.xp__bar { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73;
  transition: stroke .2s; }
.xp__pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6rem; font-weight: 800;
  letter-spacing: -.03em; color: var(--text); font-variant-numeric: tabular-nums; }
.xp__done { position: absolute; inset: 0; margin: auto; color: var(--primary); opacity: 0; transform: scale(.6);
  transition: opacity .2s, transform .25s; }
.xp--prog.is-done .xp__pct, .xp--prog.is-error .xp__pct { opacity: 0; }
.xp--prog.is-done .xp__done { opacity: 1; transform: none; }
.xp--prog.is-error .xp__bar { stroke: var(--danger); }
.xp__status { margin: 0; font-size: 1.2rem; font-weight: 700; overflow-wrap: anywhere; }
.xp__sub { margin: 6px 0 0; color: var(--muted); font-size: .95rem; }
.xp__doneActs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.xp__promo { display: flex; align-items: center; gap: 16px; margin-top: 22px; padding: 18px 20px; text-align: left;
  border-top: 0; border-radius: 12px; background: var(--primary-bg); color: var(--text); text-decoration: none;
  box-shadow: 0 -12px 0 -11px var(--border); }
.xp__promo svg { flex: 0 0 auto; color: var(--primary); }
.xp__promo b { display: block; font-size: 1.02rem; }
.xp__promo small { display: block; color: var(--muted); font-size: .88rem; margin: 2px 0 4px; }
.xp__promo u { color: var(--primary); font-weight: 600; text-underline-offset: 3px; }
.xp__promo:hover u { text-decoration-thickness: 2px; }

/* Danke-Zustand des Feedbacks */
.xp__thanks { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 6px; text-align: center; }
.xp__thanks svg { color: var(--primary); }
.xp__thanks b { font-size: 1.15rem; }
.xp__thanks span { color: var(--muted); }

@media (max-width: 520px) {
  .xp { padding: 22px 18px 18px; }
  .xp h2 { font-size: 1.3rem; }
  .xp__ring { width: 160px; height: 160px; }
  .xp__pct { font-size: 2.1rem; }
  .xp .modal__acts .btn { min-width: 0; flex: 1 1 0; }
  .xp .modal__acts .spacer { display: none; }
}
:root[data-theme="dark"] .xp__safe { background: #12352a; color: #b8f0d6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .xp__safe { background: #12352a; color: #b8f0d6; } }

/* Bild wählen in der rechten Leiste */
.img-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 22px 14px; border: 2px dashed var(--border-str); border-radius: var(--radius);
  background: var(--surface-2); color: var(--muted); }
.img-pick svg { color: var(--primary); margin-bottom: 4px; }
.img-pick b { color: var(--text); font-size: .92rem; }
.img-pick span, .img-pick small { font-size: .8rem; }
.img-pick .btn { margin: 4px 0; }
.img-pick.hot { border-color: var(--primary); background: var(--primary-bg); }
.img-pick--compact { flex-direction: row; justify-content: center; gap: 10px; padding: 10px; }
.img-pick--compact .btn { margin: 0; }

/* Im Bild-Werkzeug lassen sich Bilder direkt anfassen. */
.stage[data-tool="image"] #objLayer .ann-img { pointer-events: auto; cursor: move; }

/* Ebenenliste der Bilder */
.layer-list { display: flex; flex-direction: column; gap: 6px; }

/* Seitenzahlen: Position als kleine Seite mit sechs Ankerpunkten */
.pos-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 30px 44px 30px;
  gap: 4px; width: 132px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); }
.pos-page { grid-column: 1 / -1; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); }
.pos-cell { display: grid; place-items: center; padding: 0; border: 1px solid transparent;
  border-radius: 4px; background: var(--surface-2); cursor: pointer; }
.pos-cell i { width: 14px; height: 4px; border-radius: 2px; background: var(--border-str); }
.pos-cell:hover { border-color: var(--border-str); }
.pos-cell.active { border-color: var(--primary); background: var(--primary-bg); }
.pos-cell.active i { background: var(--primary); }
.prop-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prop-pair .prop { min-width: 0; }
.prop--check { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.prop--check span { color: var(--text); font-size: .85rem; }
.layer-group { display: flex; flex-direction: column; gap: 6px; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.layer-group--here { border-color: var(--primary); }
.layer-group__head { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--text); }
.layer-group__head em { font-style: normal; font-weight: 600; color: var(--primary); font-size: .72rem; }
.layer-group__head span { margin-left: auto; color: var(--muted); font-weight: 600; }
.layer-list__head { display: flex; align-items: center; justify-content: space-between;
  font-size: .8rem; font-weight: 700; color: var(--muted); }
.layer-list__head span { min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .72rem; }
.layer { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.layer:hover { border-color: var(--border-str); }
.layer.active { border-color: var(--primary); background: var(--primary-bg); }
.layer img { width: 44px; height: 34px; object-fit: contain; flex: 0 0 auto;
  background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.layer b { display: block; font-size: .85rem; }
.layer small { display: block; color: var(--muted); font-size: .74rem; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 180%);
  background: #10151c; color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: .9rem; max-width: min(520px, 92vw); text-align: center;
  box-shadow: var(--shadow-lg); z-index: 120; transition: transform .25s;
}
.toast.show { transform: translate(-50%, 0); }
.toast.toast--err { background: var(--danger); color: #fff; }

.progress {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: none; place-items: center; z-index: 110;
}
.progress.show { display: grid; }
.progress__box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 32px; box-shadow: var(--shadow-lg); text-align: center; min-width: 260px;
}
.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress__bar {
  height: 6px; margin: 14px auto 0; width: 220px; max-width: 100%;
  background: var(--border); border-radius: 999px; overflow: hidden;
}
.progress__bar > span {
  display: block; height: 100%; width: 0;
  background: var(--primary); border-radius: 999px; transition: width .25s;
}
.progress__act { margin: 14px 0 0; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .sheet__panel { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ==========================================================================
   Schmale Fenster
   ========================================================================== */
@media (max-width: 1180px) {
  .rail { flex-basis: 158px; width: 158px; }
  .rail-toggle { left: 158px; }
  .side { flex-basis: 248px; width: 248px; }
  .appbar__doc b { max-width: 130px; }
}

@media (max-width: 1040px) {
  .appbar__brand span { display: none; }
  .appbar__doc { display: none; }
  .appbar__save .lbl { display: none; }
}

/* Mobil: Reiter wandern nach unten, Eigenschaften werden zur Fußleiste. */
@media (max-width: 900px) {
  .appbar { height: 52px; padding: 0 8px; gap: 6px; }
  .appbar__back { display: grid; }
  .appbar__brand { display: none; }
  body[data-view="empty"] .appbar__brand { display: flex; }
  .appbar__doc {
    display: flex; margin-right: auto; border: 0; background: none; padding-inline: 2px;
  }
  .appbar__doc b { max-width: 42vw; font-size: .95rem; }
  .appbar__doc span, .appbar__doc svg { display: none; }
  .appbar .appbar__more { display: grid; }
  .appbar__save .lbl { display: none; }
  .tabs { display: none; }
  .tabbar { display: flex; }
  body[data-view="empty"] .tabbar { display: none; }

  .ribbon { min-height: 54px; padding: 5px 8px; }
  .tool-btn { min-width: 58px; padding: 5px 7px; font-size: .68rem; }
  .tool-btn--row { font-size: .78rem; padding: 7px 10px; }

  .rail { flex-basis: 92px; width: 92px; }
  .rail__head { padding: 7px 6px; font-size: .62rem; justify-content: center; }
  .rail__head > span:first-child { display: none; }
  .rail__list { padding: 10px 11px; gap: 9px; }
  .rail-toggle { left: 92px; }
  .rcard__ocr { display: none; }

  .side {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 7;
    flex-basis: auto; width: auto; max-height: 48%;
    border-left: 0; border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(16,24,40,.14);
  }
  body.side-empty .side { display: none; }
  .props { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
  .props h3 { width: 100%; }
  .prop { min-width: 118px; flex: 1; }
  .prop-del { margin-top: 0; width: 100%; }

  .stage-wrap { padding: 14px; }
  .stage-bar { padding: 6px 8px; gap: 3px; }
  .stage-bar .sep { margin-inline: 2px; }
  .stage-label { min-width: 50px; font-size: .8rem; }
  #zoomFit { display: none; }

  .grid-view { padding: 12px; }
  .pages { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 11px; }
  .page-card__acts { opacity: 1; }
}

@media (max-width: 560px) {
  /* Drehen liegt im Werkzeugblatt – die Leiste bleibt dadurch einzeilig. */
  #pageRotL, #pageRotR, .stage-bar .sep:last-of-type { display: none; }
  .stage-label { min-width: 44px; }
  .tile { font-size: .64rem; gap: 5px; }
  .sheet__save { grid-template-columns: 1fr; }
  .sheet__hero h2 { font-size: 1.22rem; max-width: 14ch; }
  .sheet__hero p { max-width: 22ch; font-size: .83rem; }
  .ribbon__pane--text .search-field { flex: 1 1 150px; min-width: 120px; }
  .mini-select { max-width: 104px; }
  .rail { flex-basis: 80px; width: 80px; }
  .rail-toggle { left: 80px; }
  .pages { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

/* Sehr niedrige Fenster: das Band darf schrumpfen. */
@media (max-width: 340px) {
  .tilegrid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-height: 560px) {
  .ribbon { min-height: 48px; }
  .tool-btn span { display: none; }
  .tool-btn { min-width: 40px; }
  .tool-btn--row span { display: inline; }
}
