:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #5b6b7a;
  --accent: #1f6feb;
  --accent-dark: #1a5fd0;
  --border: #d6dde4;
  --ok: #1a7f37;
  --error: #c0392b;
  --notice-bg: #fff8e1;
  --notice-border: #e6c200;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 1.25rem; margin: 0; }
header nav { display: flex; gap: 1rem; }
header nav a { color: var(--accent); text-decoration: none; font-weight: 600; }
header nav a:hover { text-decoration: underline; }

/* Ausfüllen-Kopf: alles in EINER Zeile (Titel, Bereich, Vorschau-Werkzeuge,
   Editor), bleibt beim Scrollen stehen. Bricht erst auf schmalen Schirmen um. */
.fill-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  padding: 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.fill-header h1 { font-size: 1.05rem; }
/* Bereich-Dropdown gehört zur linken Gruppe (ohne Beschriftung). */
.fill-header .head-bereich { min-width: 6rem; width: auto; margin: 0; }
/* Ab den Vorschau-Werkzeugen alles nach rechts (Header zweigeteilt). */
.fill-header .zoom-controls { margin-left: auto; }
.fill-header .preview-actions { margin-left: 0; }
.fill-header .head-status { display: inline-flex; align-items: center; gap: 0.4rem; }
.fill-header .status { margin: 0; font-size: 0.85rem; }
/* Vorschaustatus als Icon: Loading (dreht) / Ready / Fehler. */
.status-icon { font-size: 1.1rem; line-height: 1; }
.status-icon.ok { color: var(--ok); }
.status-icon.error { color: var(--error); }
.status-icon.busy { display: inline-block; color: var(--muted); animation: lz-spin 0.9s linear infinite; }
@keyframes lz-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status-icon.busy { animation: none; } }
/* Kompakter, damit die Zeile besser passt. */
.fill-header .preview-download { padding: 0.4rem 0.7rem; }
.fill-header .preview-actions button { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem;
}

.intro { color: var(--muted); }

/* Platzsparender Hinweis: Text erscheint beim Überfahren/Fokussieren. */
.intro-hint { margin: 0 0 0.5rem; }
.info-tip { position: relative; cursor: help; color: var(--accent); font-size: 0.85rem; font-weight: 600; }
.info-pop {
  display: none; position: absolute; left: 0; top: 1.5em; z-index: 50;
  width: min(440px, 84vw); background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.8rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  color: var(--muted); font-size: 0.85rem; font-weight: 400; line-height: 1.45;
}
.info-tip:hover .info-pop, .info-tip:focus .info-pop, .info-tip:focus-within .info-pop { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 { margin-top: 0; }

label {
  display: block;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
}

select, textarea,
input[type="file"], input[type="text"], input[type="email"],
input[type="date"], input[type="time"], input[type="number"], input[type="tel"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.hint { color: var(--muted); font-size: 0.85rem; margin: 0.35rem 0 0; }

button {
  margin-top: 1rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) { background: var(--accent-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary { background: #6b7785; }
button.danger { background: var(--error); }

.status { margin: 0.75rem 0 0; min-height: 1.2em; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.error { color: var(--error); }
.status.busy { color: var(--accent); }

.notice {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 6px;
  font-size: 0.92rem;
}

.download {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.6rem 1.1rem;
  background: var(--ok);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

code {
  background: #eef1f4;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.hidden { display: none !important; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 1.5rem;
}

/* --- settings page --- */
#area-picker-wrap {
  margin: 1rem 0 1.25rem;
}

#area-picker-wrap .hint { margin-top: 0.25rem; }

.profile-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #fbfcfd;
}

.profile-block h3 { margin: 0 0 0.5rem; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }

.group {
  margin-top: 0.75rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.75rem;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.group-head label { margin: 0; }

.toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.toolbar button { margin-top: 0; }

.small { font-size: 0.85rem; color: var(--muted); }

.tag {
  display: inline-block;
  font-size: 0.75rem;
  background: #eef1f4;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  color: var(--muted);
}

/* --- fill page: two-pane layout (form left, live PDF preview right) --- */
.fill-layout {
  display: flex;
  align-items: flex-start;
  /* Block aus Formular + Vorschau mittig: gleicher Rand links und rechts. */
  justify-content: center;
  gap: 1rem;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 0.9rem;
}

.fill-form-pane {
  /* Nicht wachsen: freier Platz wird zum Rand rechts neben der Vorschau. */
  flex: 0 1 520px;
  min-width: 0;
  max-width: 600px;
}

.fill-preview-pane {
  /* Breite wird per JS exakt auf die Dokumentbreite gesetzt (kein grauer Rand). */
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Pin the preview so the full A4 page stays in view while the form scrolls.
     Unter dem (sticky) Kopf bleiben: --head-h wird per JS gesetzt; Fallback für
     Seiten ohne Ausfüll-Kopf (Editor). */
  position: sticky;
  top: calc(var(--head-h, 0.5rem) + 0.5rem);
  align-self: flex-start;
  max-height: calc(100vh - var(--head-h, 1rem) - 1rem);
  /* Die Spalte selbst scrollt (Seiten), der Kopf bleibt per sticky oben stehen.
     Nie horizontal scrollen; Platz der Scrollleiste fest reservieren. */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.preview-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  /* Kopf (Titel + Download/Drucken/Outlook) bleibt beim Scrollen oben. */
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding-bottom: 0.55rem;
}
.preview-head h2 { margin: 0; }
.preview-head .status { margin: 0; font-size: 0.85rem; }

/* Aktionsgruppe rechts im Vorschaukopf (Download/Drucken/Outlook). */
.preview-actions { margin-left: auto; display: inline-flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.preview-actions button { margin: 0; }
.preview-download { padding: 0.45rem 0.95rem; background: var(--ok); font-size: 0.9rem; }
.preview-download:hover:not(:disabled) { background: #15692d; }

/* Zoom-Steuerung der Vorschau. */
.zoom-controls { display: inline-flex; gap: 0.25rem; margin-left: 0.25rem; }
.zoom-btn {
  margin: 0; min-width: 1.9rem; padding: 0.18rem 0.5rem; line-height: 1; font-size: 1rem;
  background: #e7edf3; color: var(--ink); border: 1px solid var(--border);
}
.zoom-btn:hover:not(:disabled) { background: #d8e0e8; }

.preview-pages {
  /* Kein grauer Rahmen — die weiße Seite „schwebt" auf dem Seitenhintergrund.
     Scrollt nicht selbst — die Spalte (.fill-preview-pane) übernimmt das. */
  padding: 0.25rem 0 0.5rem;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  flex: 0 0 auto;
}

.preview-pages canvas {
  max-width: 100%; /* nie breiter als die Vorschauspalte */
  height: auto;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
  background: #fff;
}

.preview-empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 1rem;
}

/* --- Editierbare Vorschau: interaktives Overlay über dem Seiten-Canvas --- */
.pv-page { position: relative; line-height: 0; }
.pv-page canvas { display: block; }
.pv-overlay { position: absolute; top: 0; left: 0; }
.pv-region { position: absolute; box-sizing: border-box; border-radius: 2px; }
.pv-text { cursor: text; }
.pv-cb { cursor: pointer; }
.pv-region:hover { background: rgba(31, 111, 235, 0.12); outline: 1px solid rgba(31, 111, 235, 0.55); }
.pv-cb:hover { background: rgba(31, 111, 235, 0.22); }
/* Im Editiermodus darf die Region nach unten wachsen (mehrzeiliger Text). */
.pv-region.editing { background: #fff; outline: 2px solid var(--accent); z-index: 2; height: auto; }
.pv-control {
  width: 100%; height: auto; min-height: 1.3em; box-sizing: border-box;
  display: block; margin: 0; padding: 0 2px; border: none; background: #fff; color: #000;
  font-family: "Frutiger 45 Light", "Carlito", "Calibri", -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.35; resize: none; overflow: hidden;
}
.pv-control:focus { outline: none; }
.pv-rich { white-space: pre-wrap; word-break: break-word; }
/* Hinweis, dass die Vorschau direkt bearbeitbar ist. */
.preview-pages .pv-page:first-child { margin-top: 0; }

@media (max-width: 980px) {
  .fill-layout { flex-direction: column; justify-content: flex-start; }
  .fill-layout .col-resizer { display: none; }
  .fill-form-pane,
  .fill-preview-pane {
    width: 100%;
    max-width: none;
  }
  .fill-preview-pane {
    position: static;
    max-height: none;
  }
}

/* --- fill page --- */
.field-grid {
  display: grid;
  /* Dichter: bis zu drei Spalten (links Platz sparen). */
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.4rem 0.8rem;
}

.field-row { display: flex; flex-direction: column; }
.field-row label { margin: 0.4rem 0 0.25rem; }
.field-row.hidden { display: none; }
/* Mehrzeilige Felder über die volle Breite (alle Spalten). */
.field-grid > .field-wide { grid-column: 1 / -1; }
.field-wide textarea { width: 100%; box-sizing: border-box; }

/* Datum in der Vergangenheit (verletzt das min-Attribut) sichtbar markieren. */
.field-row input[type="date"]:invalid {
  border: 1px solid var(--error);
  background: #fdecea;
}

/* Datumsfeld mit Wochentag rechts im Hintergrund (nur Anzeige). */
.date-wrap { position: relative; display: block; }
.date-wrap input[type="date"] { width: 100%; box-sizing: border-box; }
.date-weekday {
  position: absolute;
  top: 50%;
  right: 2.2rem;            /* links vom Kalender-Icon */
  transform: translateY(-50%);
  pointer-events: none;     /* nur Anzeige, nicht bearbeitbar */
  color: var(--muted);
  opacity: 0.65;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* free-text combo box (dropdown fields + Eingriff) */
.combo { position: relative; }

.combo-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

.combo-opt {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.combo-opt.active { background: #eef4ff; }
/* Default-Wert in der Auswahlliste hervorheben. */
.combo-opt.combo-default { font-weight: 700; }
.combo-opt.combo-default::after { content: " ★ Standard"; color: var(--accent); font-weight: 400; font-size: 0.8em; }

/* Aufklärungsfeld + Öffnen-Icon nebeneinander. */
.field-inline { display: flex; align-items: center; gap: 0.4rem; }
.field-inline > :first-child { flex: 1 1 auto; min-width: 0; }
.field-row .consent-icon {
  flex: 0 0 auto;
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
  white-space: nowrap;
}
.field-row .consent-icon:hover { opacity: 0.7; }

.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.35rem 1rem;
  margin-top: 0.5rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 400;
  margin: 0;
  cursor: pointer;
}

.check-item input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex: none;
}

.check-item .custom-exam { flex: 1; min-width: 8rem; }

.badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.badge-ok { background: #e6f4ea; color: var(--ok); border: 1px solid #b7e0c3; }
.badge-warn { background: var(--notice-bg); color: #8a6d00; border: 1px solid var(--notice-border); }

/* vorstationär selector — segmented control (mit / ohne vorstationärem Termin) */
.vorstat-choice {
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed var(--border);
}
.vorstat-choice-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.seg-opt { margin: 0; cursor: pointer; }
.seg-opt input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.seg-opt span {
  display: block;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.seg-opt + .seg-opt span { border-left: 1px solid var(--border); }
.seg-opt input:checked + span { background: var(--accent); color: #fff; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent-dark); outline-offset: -2px; }
.vorstat-choice .hint { margin-top: 0.4rem; }

.result-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.result-actions button { margin-top: 0; }


details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.5rem;
}

/* --- settings: Eingriffe editor --- */
.eingriff-row {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  background: #fff;
}
.eingriff-head { display: flex; gap: 0.5rem; align-items: center; }
.eingriff-head input[type="text"] { flex: 1; }
.eingriff-head .vs-label {
  display: flex; align-items: center; gap: 0.3rem;
  font-weight: 400; margin: 0; white-space: nowrap;
}
.eingriff-head .vs-label input { width: auto; }
.eingriff-vu {
  display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem;
  margin-top: 0.5rem;
}
.eingriff-vu label {
  display: flex; align-items: center; gap: 0.3rem;
  font-weight: 400; margin: 0; font-size: 0.9rem;
}
.eingriff-vu input { width: auto; }
.eingriff-row .danger { margin-top: 0; padding: 0.3rem 0.6rem; }

/* --- editor page --- */
/* Editor nutzt die volle Browserbreite (dreispaltig). Kein 1000px-Cap mehr —
   `:has(#editor)` ist id-spezifisch und würde main.editor-layout überstimmen. */
main:has(#editor) { max-width: none; }

.editor-toolbar { align-items: center; gap: 0.35rem; }
.editor-toolbar .spacer { flex: 1 1 0; min-width: 0; }
.editor-toolbar select { width: auto; min-width: 7rem; }
/* Kompaktere Buttons, damit die Leiste in die (schmale) Editor-Spalte passt. */
.editor-toolbar button { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.editor-toolbar .inline-label { font-size: 0.85rem; }
.inline-label { display: inline-block; font-weight: 600; margin: 0 0.35rem 0 0; white-space: nowrap; }

.editor-fieldbar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.5rem 0.75rem; margin-bottom: 1rem;
  background: #eef4ff; border: 1px solid #cfe0ff; border-radius: 8px;
  position: sticky; top: 0; z-index: 30;
}
.editor-fieldbar select { width: auto; }
.editor-fieldbar #field-insert { min-width: 12rem; }
.editor-fieldbar #font-size { min-width: 3.2rem; }
.editor-fieldbar .hint { margin: 0; }
/* Formatierungs-Icons (B/I/U/S). */
.fmt-btn {
  margin: 0; min-width: 2rem; padding: 0.3rem 0.55rem; line-height: 1; font-size: 0.95rem;
  background: #fff; color: var(--ink); border: 1px solid var(--border);
}
.fmt-btn:hover:not(:disabled) { background: #e7edf3; }
.fmt-btn b, .fmt-btn s { font-weight: 700; }
.fieldbar-sep { width: 1px; align-self: stretch; background: #cfe0ff; margin: 0 0.2rem; }

.section-title { margin: 1.5rem 0 0.5rem; }

.section-card { background: #fbfcfd; }
/* Gültigkeitsbereich farblich: Allgemein (grün) vs. Fachspezifisch (blau). */
.section-card.section-shared { border-left: 4px solid #2f9e44; }
.section-card.section-area { border-left: 4px solid #1f6feb; }
.section-shared .section-tag { background: #d3f2dd; color: #1b6b34; }
.section-area .section-tag { background: #dce8fb; color: #1a4fa0; }
.s-scope { width: auto; margin: 0; }
/* Struktur-Spalte: Abschnittskopf nach Gültigkeitsbereich einfärben. */
.ol-section.ol-shared .ol-sec-head { background: #e3f5e9; }
.ol-section.ol-area .ol-sec-head { background: #e3edfb; }
.section-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.section-head .spacer { flex: 1; }
.section-head .s-title { flex: 1 1 200px; font-weight: 700; }
.section-tag, .block-type {
  display: inline-block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  background: #e7edf3; color: var(--muted); border-radius: 4px; padding: 0.1rem 0.45rem;
}
.section-head .inline-label { font-weight: 400; }
.section-head .inline-label input { width: auto; }

.blocks { display: flex; flex-direction: column; gap: 0.6rem; }

.block { border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.block-controls { display: flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); background: #f6f8fa; border-radius: 6px 6px 0 0; }
.block-controls .spacer { flex: 1; }
.block-body { padding: 0.6rem 0.75rem; }

button.icon {
  margin: 0; padding: 0.15rem 0.5rem; font-size: 0.9rem; line-height: 1.2;
  background: #e7edf3; color: var(--ink);
}
button.icon:hover:not(:disabled) { background: #d8e0e8; }
button.icon.danger { background: #f7dcd8; color: var(--error); }
button.small { margin-top: 0; padding: 0.3rem 0.65rem; font-size: 0.85rem; }

.editable {
  min-height: 1.4em; padding: 0.4rem 0.55rem;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  font-family: inherit; line-height: 1.5;
}
.editable:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
/* Platzhalter für leere Rich-Felder (Briefkopf/Optionen). */
.rich-field { min-height: 1.6em; }
.rich-field:empty::before { content: attr(data-ph); color: var(--muted); pointer-events: none; }

.field-chip {
  display: inline-block; padding: 0.02rem 0.4rem; margin: 0 0.1rem;
  background: #1f6feb; color: #fff; border-radius: 4px;
  font-size: 0.82em; font-weight: 600; white-space: nowrap; user-select: none;
}

.b-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.b-row .editable { flex: 1 1 200px; }
.b-row input[type="text"] { flex: 1 1 140px; width: auto; }
.b-row select { width: auto; }
.b-check .editable { flex: 1 1 200px; }
.b-list .b-items { display: flex; flex-direction: column; gap: 0.35rem; }
.b-q .editable { margin-bottom: 0.4rem; }
.b-q label.inline-label { display: block; margin-top: 0.4rem; }

.block-adder { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.75rem; }
/* Weiße Schrift — die .small-Regel (muted) machte die Buttons schwer lesbar. */
.block-adder button { color: #fff; }

/* Panel „Eigene Felder anlegen". */
.custom-fields-panel { margin: 0.6rem 0; border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.7rem; background: #fbfcfd; }
.custom-fields-panel summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.cf-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.5rem; }
.cf-form input, .cf-form select { width: auto; min-width: 7rem; margin: 0; }
.cf-form #cf-name { min-width: 9rem; }
.cf-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.cf-list li { display: flex; align-items: center; gap: 0.4rem; }
.cf-tag { font-size: 0.85rem; }

/* --- Durchgehende Schreibfläche pro Abschnitt (WYSIWYG) --- */
.section-flow {
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  padding: 0.85rem 1rem; min-height: 3rem; line-height: 1.5;
  font-family: "Frutiger 45 Light", "Carlito", "Calibri", -apple-system, "Segoe UI", Roboto, sans-serif;
}
.section-flow:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.section-flow > * { margin: 0 0 0.55rem; }
.section-flow > *:last-child { margin-bottom: 0; }
.section-flow h3.fb-heading { font-size: 1.25rem; font-weight: 700; }
.section-flow h4.fb-heading { font-size: 1.05rem; font-weight: 700; }
.section-flow .fb-ul { padding-left: 1.4rem; }
.section-flow .fb-ul li { margin-bottom: 0.15rem; }
.fb-check { display: flex; align-items: baseline; gap: 0.4rem; }
.fb-cb { cursor: pointer; user-select: none; font-size: 1.15em; line-height: 1; }
.fb-check-text { flex: 1; }
.fb-widget { border: 1px dashed var(--border); border-radius: 6px; background: #f6f8fa; padding: 0.4rem 0.55rem; }
.fb-widget-head { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.3rem; }
.fb-widget-head .spacer { flex: 1; }
.fb-del { margin: 0; padding: 0.05rem 0.45rem; }
/* „Neue Seite" als deutliche, gestrichelte Seitenumbruch-Linie statt Box. */
.fb-widget[data-bt="pagebreak"] { border: none; border-top: 2px dashed var(--accent); border-radius: 0; background: transparent; padding: 0.25rem 0 0; margin: 0.6rem 0; }
.fb-widget[data-bt="pagebreak"] .block-body { display: none; }
.fb-widget[data-bt="pagebreak"] .block-type { color: var(--accent); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

.defaults { display: flex; flex-direction: column; gap: 0.4rem; }
.def-row { align-items: center; }
.def-row .danger { margin-top: 0; padding: 0.3rem 0.6rem; flex: 0 0 auto; }

/* --- Hausschrift Frutiger 45 Light — wie im PDF --- */
@font-face {
  font-family: "Frutiger 45 Light";
  src: url("../fonts/frutiger-45-light.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Frutiger 45 Light";
  src: url("../fonts/frutiger-bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Frutiger 45 Light";
  src: url("../fonts/frutiger-italic.otf") format("opentype");
  font-weight: 400; font-style: italic; font-display: swap;
}
/* Carlito als Rückfallebene (≈ Calibri). */
@font-face {
  font-family: "Carlito";
  src: url("../fonts/Carlito-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Carlito";
  src: url("../fonts/Carlito-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
/* Editierbare Blöcke spiegeln die PDF-Schrift. */
.editable, .editable * {
  font-family: "Frutiger 45 Light", "Carlito", "Calibri", -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* --- editor: three-pane (Editor links, Struktur Mitte, Live-Vorschau rechts) --- */
main.editor-layout {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 0.9rem;
}
/* Editier-Spalte bekommt das meiste Gewicht; volle Browserbreite nutzen. */
.editor-pane { flex: 2 1 560px; min-width: 0; }
.editor-layout .fill-preview-pane { flex: 1.4 1 360px; }

/* Zieh-Trenner zwischen den Spalten (Breiten anpassbar). */
.col-resizer {
  flex: 0 0 8px; align-self: stretch; cursor: col-resize;
  position: relative; touch-action: none; user-select: none;
}
.col-resizer::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px;
  transform: translateX(-50%); background: var(--border); border-radius: 2px;
}
.col-resizer:hover::before, .col-resizer.resizing::before { background: var(--accent); width: 3px; }

/* Mittlere Spalte: schematische Struktur mit Drag & Drop. */
.editor-outline-pane {
  flex: 0 1 250px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 1rem;
  align-self: flex-start;
  max-height: calc(100vh - 2rem);
}
.editor-outline-pane h2 { margin: 0 0 0.4rem; }
.editor-outline-pane .hint { margin: 0 0 0.6rem; }
.outline { overflow-y: auto; flex: 1 1 auto; padding-right: 0.25rem; min-height: 0; }

.ol-sections { display: flex; flex-direction: column; gap: 0.5rem; }
.ol-section { border: 1px solid var(--border); border-radius: 8px; background: #fbfcfd; }
.ol-sec-head {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.5rem; background: #eef2f6; border-radius: 8px 8px 0 0;
  cursor: grab; font-weight: 700; font-size: 0.85rem;
}
.ol-sec-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ol-badge { font-size: 0.62rem; background: #d9a441; color: #fff; border-radius: 3px; padding: 0.02rem 0.3rem; }

.ol-blocks { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.4rem; min-height: 1.6rem; }
.ol-block {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.4rem; background: #fff;
  border: 1px solid var(--border); border-radius: 6px;
  cursor: grab; font-size: 0.8rem;
}
.ol-block:hover { border-color: var(--accent); }
.ol-grip { color: var(--muted); cursor: grab; user-select: none; font-size: 0.8rem; line-height: 1; }
.ol-chip {
  flex: 0 0 auto; max-width: 5.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.02em;
  background: #e7edf3; color: var(--muted); border-radius: 4px; padding: 0.05rem 0.35rem;
}
.ol-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.ol-empty { font-size: 0.75rem; color: var(--muted); font-style: italic; padding: 0.2rem 0.3rem; }
.ol-dragging { opacity: 0.5; outline: 2px dashed var(--accent); outline-offset: 1px; }
/* Ein-/Ausklappen, Block entfernen, Block hinzufügen. */
.ol-toggle { margin: 0; padding: 0 0.2rem; min-width: 0.9rem; background: transparent; border: none; color: var(--muted); font-size: 0.65rem; line-height: 1; cursor: pointer; }
.ol-toggle:hover { color: var(--ink); }
.ol-section.collapsed .ol-blocks { display: none; }
.ol-del, .ol-dup { margin: 0; padding: 0 0.2rem; background: transparent; border: none; color: var(--muted); font-size: 0.8rem; line-height: 1; cursor: pointer; opacity: 0; }
.ol-block:hover .ol-del, .ol-block:hover .ol-dup, .ol-block:focus-within .ol-del, .ol-block:focus-within .ol-dup { opacity: 1; }
.ol-sec-head .ol-dup { opacity: 0.45; font-size: 0.75rem; }
.ol-sec-head:hover .ol-dup { opacity: 1; }
.ol-del:hover { color: var(--error); }
.ol-dup:hover { color: var(--accent); }
.ol-block:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
/* Touch: kein Doppeltipp-Zoom-Delay auf Bedienelementen. */
button, .col-resizer, .ol-block { touch-action: manipulation; }
.ol-sec-foot { padding: 0.3rem 0.4rem 0.4rem; }
.ol-add { width: 100%; font-size: 0.74rem; padding: 0.15rem 0.2rem; }

@media (max-width: 1100px) {
  main.editor-layout { flex-direction: column; }
  .editor-layout .col-resizer { display: none; }
  .editor-pane,
  .editor-outline-pane,
  .editor-layout .fill-preview-pane { width: 100%; max-width: none; }
  .editor-outline-pane,
  .editor-layout .fill-preview-pane { position: static; max-height: none; }
}
