/* FormForge form. Every rule is scoped to .ff-root so it cannot leak into, or be disturbed by, the page it sits on.
   Colours and sizes arrive as CSS variables (set from script). Fonts are NOT set here: the form uses the page's own. */
.ff-root { container: ff-root / inline-size; color: var(--ff-text); font: inherit; line-height: 1.5; box-sizing: border-box; }
.ff-root *, .ff-root *::before, .ff-root *::after { box-sizing: border-box; font: inherit; }
.ff-root .ff-form { container: ff-form / inline-size; background: var(--ff-bg); color: var(--ff-text); padding: 4px 0; }
.ff-root .ff-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ff-gap); margin: 0 0 var(--ff-gap); }
@container ff-form (min-width: 520px) { .ff-root .ff-row.ff-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ff-root .ff-col { display: grid; gap: var(--ff-gap); align-content: start; min-width: 0; }
.ff-root .ff-field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.ff-root .ff-label { font-weight: 600; color: var(--ff-text); padding: 0; }
.ff-root .ff-req { margin-left: 4px; }
.ff-root .ff-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ff-root .ff-input { width: 100%; min-height: var(--ff-field-h); padding: 8px 12px; font-size: max(16px, 1em); color: var(--ff-text); background: var(--ff-field-bg); border: var(--ff-bw) solid var(--ff-border); border-radius: var(--ff-radius); appearance: none; -webkit-appearance: none; }
.ff-root textarea.ff-input { min-height: calc(var(--ff-field-h) * 2); resize: vertical; }
.ff-root select.ff-input { padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--ff-text) 50%), linear-gradient(135deg, var(--ff-text) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.ff-root .ff-input:focus-visible, .ff-root .ff-submit:focus-visible, .ff-root .ff-close:focus-visible, .ff-root .ff-check input:focus-visible + .ff-box { outline: var(--ff-focus) solid var(--ff-accent); outline-offset: 2px; }
.ff-root .ff-input[aria-invalid="true"] { border-color: var(--ff-error); }
.ff-root .ff-error { margin: 0; color: var(--ff-error); font-size: 0.9em; }
.ff-root .ff-options { display: grid; gap: 2px; }
.ff-root .ff-check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.ff-root .ff-check input { position: absolute; opacity: 0; width: 24px; height: 24px; margin: 0; }
.ff-root .ff-box { flex: none; width: 24px; height: 24px; border: var(--ff-bw) solid var(--ff-border); background: var(--ff-field-bg); border-radius: min(var(--ff-radius), 6px); display: grid; place-items: center; }
.ff-root .ff-check input[type="radio"] + .ff-box { border-radius: 50%; }
.ff-root .ff-check input:checked + .ff-box { background: var(--ff-accent); border-color: var(--ff-accent); }
.ff-root .ff-check input:checked + .ff-box::after { content: ""; width: 6px; height: 12px; border: solid var(--ff-btn-text); border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg); }
.ff-root .ff-check input[type="radio"]:checked + .ff-box::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--ff-btn-text); transform: none; }
.ff-root .ff-text { color: var(--ff-text); }
.ff-root .ff-text p { margin: 0 0 0.75em; } .ff-root .ff-text p:last-child { margin-bottom: 0; }
.ff-root a { color: var(--ff-link); text-decoration: underline; text-underline-offset: 2px; }
.ff-root .ff-actions { margin-top: calc(var(--ff-gap) / 2); }
.ff-root .ff-submit { min-height: var(--ff-field-h); padding: 10px 24px; font-size: max(16px, 1em); font-weight: 700; cursor: pointer; border-radius: var(--ff-radius); border: var(--ff-bw) solid var(--ff-accent); width: var(--ff-btn-w); }
.ff-root .ff-submit.ff-solid { background: var(--ff-accent); color: var(--ff-btn-text); }
.ff-root .ff-submit.ff-solid:hover { background: var(--ff-accent-hover); border-color: var(--ff-accent-hover); }
.ff-root .ff-submit.ff-outline { background: transparent; color: var(--ff-text); border-width: max(2px, var(--ff-bw)); }
.ff-root .ff-submit.ff-outline:hover { background: var(--ff-accent); color: var(--ff-btn-text); }
.ff-root .ff-title { margin: 0 0 var(--ff-gap); font-weight: 700; font-size: 1.4em; line-height: 1.25; color: var(--ff-text); }
/* its own page */
.ff-root .ff-page { background: var(--ff-bg); padding: clamp(16px, 4cqw, 40px); }
.ff-root .ff-page .ff-form { max-width: 640px; margin: 0 auto; }
.ff-root .ff-page .ff-title { max-width: 640px; margin-left: auto; margin-right: auto; }
/* pop-up. On a real page it covers the window; in a preview it covers its stage. */
.ff-root .ff-overlay { position: fixed; inset: 0; z-index: 2147483000; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); }
.ff-stage .ff-root .ff-overlay { position: absolute; }
.ff-root .ff-dialog { position: relative; background: var(--ff-bg); color: var(--ff-text); width: calc(100% - 32px); max-width: var(--ff-modal-max); max-height: calc(100% - 32px); overflow: auto; padding: 24px; border-radius: var(--ff-modal-radius); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); }
.ff-root .ff-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; display: grid; place-items: center; background: transparent; border: 0; color: var(--ff-text); cursor: pointer; border-radius: var(--ff-radius); }
.ff-root .ff-close::before, .ff-root .ff-close::after { content: ""; position: absolute; width: 18px; height: 2px; background: currentColor; transform: rotate(45deg); }
.ff-root .ff-close::after { transform: rotate(-45deg); }
.ff-root .ff-dialog .ff-title { padding-right: 40px; }
@container ff-root (max-width: 599px) { .ff-root .ff-dialog { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; box-shadow: none; padding: 20px 16px; } }
