/* P5 nutzt ausschließlich die Gestaltungswerte und Bedienelemente aus P0–P4. */
.p5 { min-width: 0; }
.p5 h2 { font: 700 20px/1.35 var(--head); margin-bottom: 16px; }
.p5 h3 { font: 700 17px/1.4 var(--head); }
.p5 .p5-back { display: none; }
.p5-template-layout { display: grid; grid-template-columns: minmax(0,1fr) 400px; gap: 24px; align-items: start; }
.p5-template-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,220px),1fr)); gap: 12px; }
.p5-template { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 16px; min-width: 0; min-height: 190px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); color: var(--ink); cursor: pointer; }
.p5-template:hover { background: var(--sunken); }
.p5-template.on { background: var(--accent-soft); border: 2px solid var(--accent); padding: 17px; }
.p5-template.on b { color: var(--accent-ink); }
.p5-template-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--sunken); flex-shrink: 0; }
.p5-template-icon svg { width: 28px; height: 28px; }
.p5-template-text { display: grid; gap: 8px; min-width: 0; }
.p5-template-text b { font-size: 16px; font-weight: 700; line-height: 1.4; hyphens: manual; overflow-wrap: normal; word-break: normal; }
.p5-template-text > span { font-size: 14px; line-height: 1.5; color: var(--muted); }
.p5-other { border: 1.5px dashed var(--input-line); }
.p5-other:hover { border-color: var(--accent); }
.p5-template-panel { position: sticky; top: 88px; gap: 20px; }
.p5-template-panel h2 { margin-bottom: 8px; }
.p5-template-panel > .btn { width: 100%; }
.p5-important,.p5-level { border: 0; border-top: 1px solid var(--line); padding: 20px 0 0; margin: 0; min-width: 0; }
.p5-important legend,.p5-level legend { float: left; width: 100%; margin: 0 0 12px; padding: 0; font: 700 17px/1.4 var(--head); }
.p5 .p5-important > label { clear: both; display: flex; width: 100%; align-items: center; gap: 8px; min-height: 44px; }
.p5-important input { accent-color: var(--safe); flex-shrink: 0; }
.p5-level .field-help { clear: both; margin: 8px 0; }
.p5-segment { display: flex; border: 1px solid var(--input-line); border-radius: var(--r-ctl); overflow: hidden; }
.p5-segment label { position: relative; flex: 1; text-align: center; padding: 10px 4px; cursor: pointer; }
.p5-segment label+label { border-left: 1px solid var(--line); }
.p5-segment label.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.p5-segment input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.p5-segment label:focus-within { outline: 2px solid var(--accent-ink); outline-offset: -3px; }
.p5 .steps { margin-bottom: 24px; }
.p5 .steps .done .dot { background: var(--safe); color: var(--surface); border-color: var(--safe); }
.p5 .steps .on .dot { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.p5-assistant .wizard { grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: start; gap: 24px; }
.p5-assistant .wizard > * { min-width: 0; }
.p5-assistant .preview { position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow: auto; padding: 16px; }
.p5-assistant .preview .page-img { background: var(--paper); box-shadow: var(--shadow-pop); }
.p5 .p2-reading-steps { list-style: none; padding: 0; margin: 24px 0 0; }
.p5 .p2-reading-steps li { display: flex; gap: 16px; min-height: 80px; }
.p5 .p2-step-icon { flex-shrink: 0; }
/* Die rechte Spalte bestimmt die Höhe; das Papier scrollt innerhalb dieser Grenze. */
.p5-assistant .p5-example { align-self: stretch; min-height: 0; padding: 0; }
.p5-example-body { position: absolute; inset: 0; overflow: auto; padding: 16px; }
.p5-example-label,.p5-example-file { margin: 0 0 12px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.p5-example-file { margin: 12px 0 0; }
.p5-example .mark,.p5-example .mark.dim { background: var(--marker-wash); border: 0; border-radius: 2px; box-shadow: none; }
.p5-example .mark.on { border: 2px solid var(--accent); }
.p5-example-quotes { padding-left: 20px; font-size: 14px; }
.p5-example mark { background: var(--marker); color: #0F172A; }
.p5-draft { display: flex; flex-direction: column; gap: 24px; }
.p5-draft > * + * { margin-top: 0; }
.p5-draft-intro { display: grid; gap: 8px; }
.p5-draft-intro input { display: block; }
.p5-draft-summary { margin: 0; font-size: 14px; color: var(--muted); }
.p5-columns { border: 1px solid var(--line); border-radius: var(--r-ctl); min-width: 0; }
.p5-column-head,.p5-col { display: grid; grid-template-columns: 28px minmax(120px,1fr) 94px 54px 80px 32px; align-items: center; gap: 6px; }
.p5-column-head { min-height: 44px; background: var(--sunken); padding: 0 8px; color: var(--muted); font-size: 14px; font-weight: 600; border-radius: var(--r-ctl) var(--r-ctl) 0 0; }
.p5-cols { list-style: none; padding: 0; margin: 0; }
.p5-col { position: relative; min-height: 52px; border-top: 1px solid var(--line); padding: 5px 8px; background: var(--surface); }
.p5-col:hover { background: var(--sunken); }
.p5-col > * { min-width: 0; }
.p5-col .grip { width: 28px; height: 36px; min-height: 36px; padding: 4px; touch-action: none; }
.p5-col .grip span { min-height: 16px; }
.p5-col .p5-name input { width: 100%; min-width: 0; padding: 6px; border-color: transparent; background: transparent; }
.p5-col .p5-name input:hover,.p5-col .p5-name input:focus { border-color: var(--input-line); background: var(--surface); }
.p5-col .p5-type select { color: var(--muted); width: 100%; min-width: 0; padding: 6px 18px 6px 4px; background-color: transparent; border-color: transparent; }
.p5-required { display: flex; justify-content: center; align-items: center; gap: 8px; }
.p5-required span { display: none; }
.p5-format { font-size: 14px; overflow-wrap: anywhere; color: var(--muted); }
.p5-field-more { grid-column: 2/-1; padding: 10px 0; }
.p5-field-more[hidden] { display: none; }
.p5-field-more summary { font-size: 14px; }
.p5-field-more input,.p5-field-more select,.p5-field-more textarea { max-width: 100%; }
.p5-field-more .key { overflow-wrap: anywhere; }
.p5-menu { position: relative; }
.p5-menu summary { display: grid; place-items: center; width: 32px; height: 40px; cursor: pointer; list-style: none; font-size: 20px; border-radius: var(--r-ctl); }
.p5-menu summary::-webkit-details-marker { display: none; }
.p5-menu summary:hover { background: var(--sunken); }
.p5-menu > div { position: absolute; top: 40px; right: 0; z-index: 15; width: max-content; max-width: 240px; display: grid; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-pop); }
.p5-menu > div .btn { justify-content: flex-start; color: var(--ink); }
.p5-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.p5-rules li { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); }
.p5-rules li > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.p5-rules .pill { flex-shrink: 0; white-space: nowrap; }
.p5-draft .p5-rules { gap: 0; }
.p5-draft .p5-rules li { min-height: 52px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 8px 0; }
.p5-review-columns .p5-column-head,.p5-review-columns .p5-col { grid-template-columns: 32px minmax(0,1fr) 150px 96px; column-gap: 16px; }
.p5 .p5-duty { font-size: 14px; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.p5-review-columns .p5-name { overflow-wrap: anywhere; }
.p5-read { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); }
.p5-read > svg { width: 18px; height: 18px; color: var(--safe); }
.p5 .pill svg { width: 16px; height: 16px; }
.p5-test-result { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-ctl); background: var(--safe-bg); color: var(--safe); }
.p5-test-result > svg { width: 24px; height: 24px; flex-shrink: 0; }
.p5-draft-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.p5-draft-foot .primary { flex: 1; }
.p5-wizard-foot { grid-column: 1/-1; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); justify-content: flex-end; }
.p5-wizard-foot .primary { flex: 0 1 auto; }
.p5-edit { padding-bottom: 110px; }
.p5-edit-layout { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: 20px; align-items: stretch; }
.p5-edit-layout > .card { min-width: 0; padding: 20px; }
.p5-add { width: 100%; margin-top: 16px; }
.p5-more { margin-top: 16px; }
.p5-more > summary { cursor: pointer; font-weight: 600; }
.p5-more > .stack { margin-top: 20px; }
.fd-dialog:has(.p5-rule-editor) { width: min(900px,calc(100vw - 32px)); }
.p5-rule-editor { display: flex; flex-direction: column; gap: 20px; }
.p5-rule-editor > * + * { margin-top: 0; }
.p5-rule-editor input[readonly],.p5-rule-editor input[readonly]:hover,.p5-rule-editor input[readonly]:focus { background: var(--sunken); border-color: transparent; box-shadow: none; outline: none; }
.p5-rule-level { border: 0; padding: 0; margin: 0; min-width: 0; }
.p5-rule-level legend { margin-bottom: 12px; }
.p5-rule-level label.on.red { color: var(--error); background: var(--error-bg); }
.p5-rule-level label.on.amber { color: var(--check); background: var(--check-bg); }
.p5-rule-editor .rule-body { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.p5-rule-editor .rule-body select,.p5-rule-editor .rule-body input:not([type=checkbox]) { height: 44px; min-height: 44px; max-width: 100%; }
.p5-rule-editor .rule-body select { min-width: 140px; flex: 1 1 140px; width: auto; }
.p5-rule-editor .rule-body input:not([type=checkbox]) { width: 90px; }
.p5-rule-editor .rule-body .mini { display: flex; align-items: center; gap: 8px; }
.p5-rule-part { display: flex; flex: 1 1 160px; flex-wrap: wrap; gap: 4px; min-width: 0; }
.p5-rule-editor .p5-part-remove { font-size: 14px; min-height: 32px; }
.p5-rule-editor .rule-body .btn { min-height: 44px; }
@media (min-width:721px) { body:has(.ffb-knopf:not([hidden])) .p5-sticky-foot { padding-right: 72px; } }
.p5-sticky-foot { position: fixed; bottom: 0; left: 296px; right: 32px; max-width: 1200px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; padding: 16px 0; background: var(--desk); z-index: 10; border-top: 1px solid var(--line); }
.p5-sticky-foot .btn { white-space: normal; height: auto; min-height: 40px; }
@media (min-width:860px) and (max-width:1250px) { .p5-template-layout { grid-template-columns: minmax(0,1fr) 340px; } .p5-edit-layout { grid-template-columns: 1fr; } }
@media (min-width:860px) and (max-width:1023px) { .p5-sticky-foot { left: 104px; } }
@media (max-width:859px) {
  .p5 .p5-back { display: inline-flex; margin-bottom: 16px; }
  .p5-template-layout,.p5-assistant .wizard,.p5-edit-layout { grid-template-columns: minmax(0,1fr); gap: 20px; }
  .p5-template-grid { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .p5-template { flex-direction: row; align-items: center; height: 72px; min-height: 72px; padding: 10px 12px; gap: 12px; }
  .p5-template.on { padding: 9px 11px; }
  .p5-template-text { gap: 2px; }
  .p5-template-text > span { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
  .p5-template-icon { width: 40px; height: 40px; }
  .p5-template-panel { position: static; }
  .p5-template-empty { display: none; }
  .p5-selected .p5-template-choice,.p5-selected > .p5-back { display: none; }
  .p5-assistant .preview { position: static; max-height: 420px; padding: 0; }
  .p5 .steps { gap: 8px; }
  .p5 .steps li { font-size: 14px; flex: 1; min-width: 0; flex-direction: column; align-items: center; text-align: center; }
  .p5 .steps li::after { display: none; }
  .p5-assistant .tpl-set .formats { grid-template-columns: minmax(0,1fr); }
  .p5-assistant .card { padding: 16px; }
  .p5-assistant .p5-example { position: relative; height: 360px; max-height: 360px; }
  .p5-example-body { padding: 0; }
  .p5-review-columns .p5-column-head { display: none; }
  .p5-review-columns .p5-col { grid-template-columns: 32px minmax(0,1fr) auto; gap: 8px; }
  .p5-review-columns .p5-name { grid-column: 2; grid-row: 1; }
  .p5-review-columns .p5-col > .p5-read { grid-column: 1/-1; grid-row: 2; padding: 0; }
  .p5-review-columns .p5-col > span:last-child { grid-column: 3; grid-row: 1; justify-self: end; }
  .p5-edit .p5-column-head { display: none; }
  .p5-edit .p5-col { grid-template-columns: 28px minmax(0,1fr) auto 32px; gap: 4px; padding: 8px; }
  .p5-edit .p5-col > span:first-child { grid-column: 1; grid-row: 1/3; }
  .p5-edit .p5-name { grid-column: 2; grid-row: 1; }
  .p5-edit .p5-type { grid-column: 2; grid-row: 2; }
  .p5-edit .p5-type select { font-size: 14px; height: 32px; padding-left: 6px; }
  .p5-edit .p5-required { grid-column: 3; grid-row: 1/3; }
  .p5-edit .p5-required input { appearance: none; width: 36px; height: 22px; border-radius: var(--pill); border: 1px solid var(--input-line); background: var(--sunken); position: relative; }
  .p5-edit .p5-required input::before { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); top: 3px; left: 3px; }
  .p5-edit .p5-required input:checked { background: var(--accent); border-color: var(--accent); }
  .p5-edit .p5-required input:checked::before { left: 17px; background: var(--on-accent); }
  .p5-edit .p5-format { grid-column: 2; grid-row: 3; padding-left: 6px; }
  .p5-edit .p5-col > span:last-of-type { grid-column: 4; grid-row: 1/3; }
  .p5-field-more { grid-column: 1/-1; }
  .p5-edit-layout > .card { padding: 16px; }
  .p5-rules li { gap: 8px; flex-wrap: wrap; }
  .p5-rules li > span:first-child { flex-basis: 100%; }
  .p5-rules .p5-menu { margin-left: auto; }
  .p5-sticky-foot { position: fixed; bottom: calc(64px + env(safe-area-inset-bottom)); left: 0; right: 0; padding: 12px 16px; margin: 0; flex-direction: column; gap: 8px; }
  .p5-sticky-foot > div,.p5-sticky-foot .btn { width: 100%; }
  .p5-edit { padding-bottom: 170px; }
  .p5-draft-foot .btn { width: 100%; }
}
