/* Felder – gemeinsame Formularfelder (Kiosk + Helferportal). Eigene --ff-* Variablen mit Rückfall auf beide Farbwelten. */
.ff-form, .ff-builder, .ff-display, .ff-summary {
  --ff-accent: var(--accent, var(--red, #e30613));
  --ff-text: var(--text, #16181d);
  --ff-muted: var(--muted, #5d6573);
  --ff-line: var(--border, var(--line, #d0d5dd));
  --ff-bg: var(--surface-2, var(--card, #fff));
  --ff-card: var(--surface, var(--card, #fff));
  --ff-ok: var(--ok, #15803d);
  --ff-bad: var(--bad, var(--due, #c81e1e));
  --ff-radius: var(--radius-sm, 12px);
  --ff-star: #f59e0b;
  /* Rückfall ohne color-mix */
  --ff-edge: rgba(128, 128, 128, .5);
  --ff-tint: rgba(227, 6, 19, .1);
  --ff-soft: rgba(128, 128, 128, .12);
  --ff-ring: rgba(227, 6, 19, .3);
  color: var(--ff-text);
  font-size: 16px;
  line-height: 1.45;
  min-width: 0;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .ff-form, .ff-builder, .ff-display, .ff-summary {
    --ff-edge: color-mix(in srgb, var(--ff-text) 26%, transparent);
    --ff-tint: color-mix(in srgb, var(--ff-accent) 13%, transparent);
    --ff-soft: color-mix(in srgb, var(--ff-text) 8%, transparent);
    --ff-ring: color-mix(in srgb, var(--ff-accent) 30%, transparent);
  }
}
.ff-form *, .ff-builder *, .ff-display *, .ff-summary * { box-sizing: border-box; }
.ff-form [hidden], .ff-builder [hidden] { display: none !important; }
.ff-display, .ff-summary { user-select: text; }

/* ---------- Formular ---------- */
.ff-form { display: flex; flex-direction: column; gap: 22px; }
.ff-field { position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ff-field.ff-invalid::before { content: ""; position: absolute; left: -10px; top: 2px; bottom: 2px; width: 3px; border-radius: 2px; background: var(--ff-bad); }
.ff-label { font-weight: 650; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.ff-req { color: var(--ff-accent); }
.ff-help { font-size: 14px; color: var(--ff-muted); white-space: pre-line; overflow-wrap: anywhere; margin: -4px 0 0; }
.ff-err { color: var(--ff-bad); font-size: 14.5px; font-weight: 650; }
.ff-err:empty { display: none; }
.ff-err::before { content: "⚠ "; }
.ff-section { padding-top: 6px; }
.ff-section .ff-help { margin-top: 4px; }
.ff-heading { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.ff-form > .ff-section:not(:first-child) { border-top: 1px solid var(--ff-line); padding-top: 20px; }
.ff-info { padding: 12px 14px; border-radius: var(--ff-radius); background: var(--ff-soft); border-left: 4px solid var(--ff-accent); white-space: pre-line; overflow-wrap: anywhere; font-size: 15px; }
.ff-info strong { display: block; margin-bottom: 2px; }

.ff-form .ff-input, .ff-builder .ff-input {
  display: block; width: 100%; min-height: 48px; margin: 0; padding: 11px 13px;
  font: inherit; font-size: 16px; color: var(--ff-text); background: var(--ff-bg);
  border: 1px solid var(--ff-edge); border-radius: var(--ff-radius); outline: none; box-shadow: none; transform: none;
}
.ff-form textarea.ff-input, .ff-builder textarea.ff-input { min-height: 112px; resize: vertical; line-height: 1.45; }
.ff-form .ff-short { max-width: 240px; }
.ff-builder .ff-input { font-weight: 400; }
.ff-form .ff-input:focus, .ff-builder .ff-input:focus { border-color: var(--ff-accent); box-shadow: 0 0 0 3px var(--ff-ring); }
.ff-form .ff-input::placeholder, .ff-builder .ff-input::placeholder { color: var(--ff-muted); opacity: .8; }
.ff-invalid .ff-input, .ff-invalid .ff-choice, .ff-invalid .ff-sig-pad, .ff-invalid .ff-seg-btn, .ff-invalid .ff-scale-btn { border-color: var(--ff-bad); }
.ff-select { display: flex; flex-direction: column; gap: 8px; }

/* Auswahl (Eine / Mehrere Antworten) */
.ff-choices { display: flex; flex-direction: column; gap: 8px; }
.ff-choice {
  display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 10px 14px; cursor: pointer;
  border: 1px solid var(--ff-edge); border-radius: var(--ff-radius); background: var(--ff-bg); font-size: 16px; line-height: 1.3;
}
.ff-choice.ff-on { border-color: var(--ff-accent); background: var(--ff-tint); box-shadow: inset 0 0 0 1px var(--ff-accent); }
.ff-choice-text { overflow-wrap: anywhere; min-width: 0; }
.ff-form .ff-choice input { width: 22px; height: 22px; min-height: 0; margin: 0; padding: 0; flex: none; accent-color: var(--ff-accent); transform: none; }
.ff-choice-other { flex-wrap: wrap; }
.ff-form .ff-choice-other .ff-other-text { flex: 1 1 180px; width: auto; min-height: 42px; padding: 8px 11px; }
.ff-form .ff-select .ff-other-text { min-height: 48px; }
.ff-link { align-self: flex-start; background: none; border: 0; padding: 8px 2px; min-height: 40px; font: inherit; font-size: 14px; color: var(--ff-muted); text-decoration: underline; cursor: pointer; }

/* Ja/Nein, Sterne, Skala */
.ff-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 360px; }
.ff-seg-btn, .ff-scale-btn {
  min-height: 50px; padding: 6px; font: inherit; font-size: 16px; font-weight: 650; cursor: pointer;
  color: var(--ff-text); background: var(--ff-bg); border: 1px solid var(--ff-edge); border-radius: var(--ff-radius);
  font-variant-numeric: tabular-nums; touch-action: manipulation;
}
.ff-seg-btn.ff-on, .ff-scale-btn.ff-on { background: var(--ff-accent); border-color: var(--ff-accent); color: #fff; }
.ff-rating { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ff-stars { display: flex; gap: 2px; }
.ff-stars-btn { width: 48px; height: 48px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 36px; line-height: 1; color: var(--ff-edge); border-radius: 10px; touch-action: manipulation; }
.ff-stars-btn.ff-lit { color: var(--ff-star); }
.ff-rating-text { color: var(--ff-muted); font-size: 14.5px; font-weight: 600; }
.ff-scale { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); }
@supports (container-type: inline-size) {
  .ff-scale-wrap { container-type: inline-size; }
  .ff-scale { grid-template-columns: repeat(var(--ff-n, 10), minmax(0, 1fr)); }
  @container (max-width: 540px) { .ff-scale.ff-many { grid-template-columns: repeat(var(--ff-half, 5), minmax(0, 1fr)); } }
}

/* Datei / Foto */
.ff-file { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.ff-form .ff-file-input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; border: 0; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.ff-file-input:focus-visible + .ff-file-btn { outline: 2px solid var(--ff-accent); outline-offset: 2px; }
.ff-file-ic { font-size: 18px; line-height: 1; }
.ff-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.ff-files:empty { display: none; }
.ff-file-item { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 8px; border: 1px solid var(--ff-line); border-radius: var(--ff-radius); background: var(--ff-bg); }
.ff-file-thumb { width: 56px; height: 56px; flex: none; border-radius: 10px; object-fit: cover; background: var(--ff-soft); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ff-muted); }
.ff-file-meta { flex: 1; min-width: 0; }
.ff-file-name { overflow-wrap: anywhere; font-weight: 600; font-size: 15px; }
.ff-file-size { color: var(--ff-muted); font-size: 13.5px; }
.ff-file-status { color: var(--ff-muted); font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ff-file-status:empty { display: none; }
.ff-busy::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ff-edge); border-top-color: var(--ff-accent); animation: ff-spin .8s linear infinite; }
@keyframes ff-spin { to { transform: rotate(360deg); } }

/* Unterschrift (immer weißer Grund, dunkle Tinte) */
.ff-sig { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.ff-sig-pad { position: relative; height: 190px; background: #fff; border: 1px solid var(--ff-edge); border-radius: var(--ff-radius); overflow: hidden; touch-action: none; }
.ff-sig-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.ff-sig-hint { position: absolute; left: 18px; right: 18px; bottom: 34px; padding-bottom: 6px; border-bottom: 1.5px dashed #9aa3b2; color: #5d6573; font-size: 14px; pointer-events: none; }
.ff-signed .ff-sig-hint { color: transparent; }
.ff-readonly .ff-sig-canvas { cursor: default; }
.ff-sig-bar { display: flex; justify-content: flex-end; }

/* Knöpfe */
.ff-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 16px; margin: 0;
  font: inherit; font-size: 15px; font-weight: 650; line-height: 1.2; color: var(--ff-text); background: var(--ff-bg);
  border: 1px solid var(--ff-edge); border-radius: var(--ff-radius); cursor: pointer; text-align: center; touch-action: manipulation;
}
.ff-btn:hover:not(:disabled) { border-color: var(--ff-text); }
.ff-btn:disabled { opacity: .45; cursor: default; }
.ff-btn-small { min-height: 44px; padding: 8px 14px; font-size: 14.5px; }
.ff-btn-danger { color: var(--ff-bad); }
.ff-btn-danger.ff-armed { background: var(--ff-bad); border-color: var(--ff-bad); color: #fff; }
.ff-icon-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; flex: none; font-size: 22px; font-weight: 500; }
.ff-form :focus-visible, .ff-builder :focus-visible { outline: 2px solid var(--ff-accent); outline-offset: 2px; }
.ff-form .ff-input:focus-visible, .ff-builder .ff-input:focus-visible { outline: none; }

/* Nur lesen */
.ff-readonly .ff-choice, .ff-readonly .ff-seg-btn, .ff-readonly .ff-scale-btn, .ff-readonly .ff-stars-btn { cursor: default; }
.ff-readonly .ff-input:disabled, .ff-readonly .ff-choice input:disabled { opacity: 1; color: var(--ff-text); -webkit-text-fill-color: var(--ff-text); }
.ff-readonly button:disabled { opacity: 1; }
.ff-readonly .ff-choice:not(.ff-on), .ff-readonly .ff-seg-btn:not(.ff-on), .ff-readonly .ff-scale-btn:not(.ff-on) { opacity: .6; }

/* ---------- Übersicht (display) ---------- */
.ff-display { display: flex; flex-direction: column; }
.ff-display .ff-heading { padding: 18px 0 6px; font-size: 17px; }
.ff-d-row { display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 11px 0; border-bottom: 1px solid var(--ff-line); }
.ff-d-label { flex: 1 1 200px; min-width: 0; color: var(--ff-muted); font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.ff-d-value { flex: 2 1 260px; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.ff-d-empty { color: var(--ff-muted); font-style: italic; }
.ff-d-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; white-space: normal; }
.ff-d-files a { color: inherit; display: inline-flex; flex-direction: column; gap: 4px; text-decoration: none; }
.ff-d-fname { text-decoration: underline; }
.ff-d-fsize { color: var(--ff-muted); font-size: 13.5px; }
.ff-d-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; display: block; }
.ff-d-sig { display: block; width: 100%; max-width: 300px; height: auto; background: #fff; border: 1px solid var(--ff-line); border-radius: 8px; }
.ff-d-stars { color: var(--ff-star); letter-spacing: 1px; font-size: 18px; }
.ff-d-stars span { color: var(--ff-edge); }
.ff-d-mark { margin-top: 4px; font-size: 14px; font-weight: 650; white-space: normal; }
.ff-d-ok { color: var(--ff-ok); }
.ff-d-bad { color: var(--ff-bad); }

/* ---------- Baukasten ---------- */
.ff-builder { display: flex; flex-direction: column; gap: 12px; }
.ff-b-list { display: flex; flex-direction: column; gap: 14px; }
.ff-b-card { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--ff-line); border-radius: calc(var(--ff-radius) + 4px); background: var(--ff-card); min-width: 0; }
.ff-b-card.ff-invalid { border-color: var(--ff-bad); box-shadow: inset 0 0 0 1px var(--ff-bad); }
.ff-b-head { display: flex; align-items: center; gap: 10px; }
.ff-b-num { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--ff-accent); color: #fff; font-weight: 700; font-size: 15px; }
.ff-builder .ff-b-type { flex: 1; min-width: 0; font-weight: 650; }
.ff-b-lab { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ff-muted); min-width: 0; }
.ff-b-opts { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.ff-b-sub { font-size: 14px; font-weight: 600; color: var(--ff-muted); }
.ff-b-opt { display: flex; align-items: center; gap: 8px; width: 100%; }
.ff-builder .ff-b-opt .ff-input { flex: 1; min-width: 0; }
.ff-b-right { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; flex: none; border: 1px solid var(--ff-edge); border-radius: var(--ff-radius); font-size: 14px; font-weight: 600; cursor: pointer; }
.ff-builder .ff-b-right input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; accent-color: var(--ff-ok); transform: none; }
.ff-b-right.ff-on { border-color: var(--ff-ok); color: var(--ff-ok); }
.ff-b-tip { font-size: 13px; color: var(--ff-muted); }
.ff-b-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.ff-b-flags { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.ff-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 15px; font-weight: 600; }
.ff-builder .ff-sw-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; transform: none; }
.ff-sw { position: relative; width: 46px; height: 28px; flex: none; border-radius: 14px; background: var(--ff-soft); border: 1px solid var(--ff-edge); transition: background .15s; }
.ff-sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .15s; }
.ff-sw-input:checked + .ff-sw { background: var(--ff-accent); border-color: var(--ff-accent); }
.ff-sw-input:checked + .ff-sw::after { transform: translateX(18px); }
.ff-sw-input:focus-visible + .ff-sw { outline: 2px solid var(--ff-accent); outline-offset: 2px; }
.ff-b-more summary { min-height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ff-muted); font-size: 14.5px; font-weight: 600; list-style: none; }
.ff-b-more summary::-webkit-details-marker { display: none; }
.ff-b-more summary::before { content: "▸"; font-size: 13px; transition: transform .15s; }
.ff-b-more[open] summary::before { transform: rotate(90deg); }
.ff-b-more[open] summary { margin-bottom: 6px; }
.ff-b-err { color: var(--ff-bad); font-size: 14.5px; font-weight: 650; }
.ff-b-err:empty { display: none; }
.ff-b-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--ff-line); }
.ff-b-actions .ff-btn { flex: 1 1 auto; }
.ff-b-add { width: 100%; min-height: 54px; border-style: dashed; font-size: 16px; }
.ff-b-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 12px; border: 1px dashed var(--ff-edge); border-radius: calc(var(--ff-radius) + 4px); }
.ff-b-pick { justify-content: flex-start; text-align: left; }
.ff-b-cancel { justify-content: center; color: var(--ff-muted); }
.ff-b-empty { padding: 26px 16px; text-align: center; color: var(--ff-muted); border: 1px dashed var(--ff-edge); border-radius: calc(var(--ff-radius) + 4px); }

/* ---------- Auswertung (summaryHtml) ---------- */
.ff-summary { display: flex; flex-direction: column; gap: 14px; }
.ff-summary .ff-heading { margin-top: 8px; font-size: 18px; }
.ff-s-total, .ff-s-empty { margin: 0; color: var(--ff-muted); }
.ff-s-total b { color: var(--ff-text); }
.ff-s-card { padding: 14px 16px 16px; border: 1px solid var(--ff-line); border-radius: calc(var(--ff-radius) + 4px); background: var(--ff-card); min-width: 0; }
.ff-s-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.ff-s-q { margin: 0; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; min-width: 0; }
.ff-s-count { color: var(--ff-muted); font-size: 13.5px; white-space: nowrap; }
.ff-s-none { margin: 0; color: var(--ff-muted); font-size: 14.5px; }
.ff-bars { display: flex; flex-direction: column; gap: 12px; }
.ff-bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l n" "b b"; gap: 5px 12px; align-items: baseline; }
.ff-bar-label { grid-area: l; font-size: 14.5px; overflow-wrap: anywhere; }
.ff-bar-num { grid-area: n; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ff-bar-num span { color: var(--ff-muted); font-weight: 400; }
.ff-bar-track { grid-area: b; height: 10px; border-radius: 4px; background: var(--ff-soft); overflow: hidden; }
.ff-bar-fill { height: 100%; border-radius: 4px; background: var(--ff-accent); }
.ff-bar-ok .ff-bar-fill { background: var(--ff-ok); }
.ff-bars-compact { gap: 8px; }
.ff-bars-compact .ff-bar-row { grid-template-columns: 6em minmax(0, 1fr) 6.5em; grid-template-areas: "l b n"; align-items: center; }
.ff-bars-compact .ff-bar-num { text-align: right; }
.ff-s-ok { color: var(--ff-ok); font-size: 13px; font-weight: 650; white-space: nowrap; }
.ff-s-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.ff-s-big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ff-s-stats .ff-d-stars { font-size: 20px; }
.ff-s-sub { margin: 14px 0 6px; font-size: 14px; font-weight: 600; color: var(--ff-muted); }
.ff-s-texts { list-style: none; margin: 0; padding: 0 4px 0 0; max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.ff-s-texts li { padding: 8px 11px; border-radius: 10px; background: var(--ff-soft); font-size: 14.5px; white-space: pre-line; overflow-wrap: anywhere; }
.ff-s-texts .ff-s-more { background: none; color: var(--ff-muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { .ff-busy::before { animation-duration: 2s; } .ff-sw, .ff-sw::after { transition: none; } }

/* ab 3.4: Bedingungen („Wann anzeigen?“) */
.ff-form [hidden], .ff-display [hidden] { display: none !important; }
.ff-b-cond { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: var(--ff-radius); border: 1px dashed var(--ff-line); }
.ff-b-cond.ff-on { border-style: solid; border-color: var(--ff-edge); background: var(--ff-soft); }
.ff-b-cond .ff-b-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
