/* ==========================================================================
   Omni Forms — application chrome (forms list + builder)
   The form itself is styled by /form-kit/design-system.css.
   ========================================================================== */
:root {
    --fb-canvas: #eef2f7;  --fb-dot: #d5dce6;
    --fb-panel: #ffffff;   --fb-line: #e2e8f0;
    --fb-text: #0f172a;    --fb-muted: #64748b;
    --fb-field: #f8fafc;   --fb-hover: #f1f5f9;
    --fb-accent: #6366f1;  --fb-accent-soft: #e0e7ff; --fb-accent-ink: #4338ca;
    --fb-top: 60px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --fb-canvas: #020617;  --fb-dot: #1e293b;
        --fb-panel: #0f172a;   --fb-line: #1e293b;
        --fb-text: #e2e8f0;    --fb-muted: #94a3b8;
        --fb-field: #1e293b;   --fb-hover: #172033;
        --fb-accent: #818cf8;  --fb-accent-soft: #1e1b4b; --fb-accent-ink: #c7d2fe;
        color-scheme: dark;
    }
}

/* ---------- Shared ---------- */
body.fb, body.fb-page { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--fb-text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
.fb svg, .fb-page svg { flex-shrink: 0; }
.fb-btn { font: inherit; font-size: 0.875rem; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--fb-line); background: var(--fb-panel); color: var(--fb-text); cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; white-space: nowrap; text-decoration: none; }
.fb-btn:hover:not(:disabled) { background: var(--fb-hover); }
.fb-btn:focus-visible, .fb-icon-btn:focus-visible, .fb-tool:focus-visible, .fb-seg button:focus-visible, .fb-layout-btn:focus-visible, .fb-act-btn:focus-visible, .fb-status:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-btn:disabled { opacity: 0.45; cursor: default; }
.fb-btn.ghost { border-color: transparent; background: transparent; }
.fb-btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.fb-btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4); }
.fb-btn.danger:hover { color: var(--error); border-color: #fecaca; }
.fb-btn.fb-wide { width: 100%; justify-content: center; margin-top: 4px; }
.fb-icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 7px; border: 0; background: transparent; color: var(--fb-muted); cursor: pointer; }
.fb-icon-btn:hover { background: var(--fb-hover); color: var(--fb-text); }

/* ==========================================================================
   Forms list
   ========================================================================== */
/* Column layout so the footer sits at the bottom of short pages too. */
body.fb-page { background: var(--fb-canvas); min-height: 100vh; display: flex; flex-direction: column; }
body.fb-page > main { flex: 1 0 auto; width: 100%; }

/* Footer (layouts/app) */
.fb-footer { border-top: 1px solid var(--fb-line); background: var(--fb-panel); color: var(--fb-muted); font-size: 0.85rem; padding: 0 20px; }
.fb-footer-in { max-width: 1000px; margin: 0 auto; }
.fb-page.has-wide .fb-footer-in { max-width: 1240px; }
.fb-footer-grid { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(120px, 0.7fr)) minmax(230px, 1.2fr); gap: 28px 36px; padding: 36px 0 28px; }
.fb-footer-brand .fb-brand { margin-bottom: 10px; }
.fb-footer-brand p { line-height: 1.55; max-width: 320px; }
.fb-footer-col { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.fb-footer-col h2 { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fb-text); margin-bottom: 4px; }
.fb-footer-col a, .fb-footer-col button { color: var(--fb-muted); text-decoration: none; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.fb-footer-col a:hover, .fb-footer-col button:hover { color: var(--fb-accent); }
.fb-footer-col a:focus-visible, .fb-footer-col button:focus-visible, .fb-footer-top:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; border-radius: 4px; }
.fb-footer-col form { margin: 0; }
.fb-keys { display: grid; gap: 7px; margin: 0; }
.fb-keys div { display: flex; align-items: center; gap: 10px; }
.fb-keys dt { flex: none; min-width: 92px; white-space: nowrap; }
.fb-keys dd { margin: 0; }
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; border: 1px solid var(--fb-line); border-bottom-width: 2px; border-radius: 5px; background: var(--fb-canvas); color: var(--fb-text); font: 600 0.72rem ui-monospace, SFMono-Regular, Consolas, monospace; text-align: center; }
.fb-footer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 16px 0; border-top: 1px solid var(--fb-line); font-size: 0.8rem; }
.fb-footer-grid + .fb-footer-bar { border-top: 1px solid var(--fb-line); }
.fb-footer-in > .fb-footer-bar:first-child { border-top: 0; }
.fb-footer-bar b { color: var(--fb-text); font-weight: 600; }
.fb-footer-top { margin-left: auto; color: var(--fb-muted); text-decoration: none; font-weight: 600; }
.fb-footer-top:hover { color: var(--fb-accent); }
@media (max-width: 860px) { .fb-footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .fb-footer-grid { grid-template-columns: 1fr; } .fb-footer-top { margin-left: 0; } }

/* Forms list: overview cards */
.fb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.fb-stat { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: 12px; text-decoration: none; color: inherit; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; }
.fb-stat:hover { border-color: var(--fb-accent); transform: translateY(-2px); box-shadow: 0 8px 20px -14px rgb(15 23 42 / 0.35); }
.fb-stat:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-stat-icon { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; }
.fb-stat-icon.is-blue { background: #e0ecff; color: #1d4ed8; }
.fb-stat-icon.is-violet { background: #ede9fe; color: #6d28d9; }
.fb-stat-icon.is-green { background: #dcfce7; color: #15803d; }
.fb-stat-icon.is-amber { background: #fef3c7; color: #b45309; }
.fb-stat-icon.is-rose { background: #ffe4e6; color: #be123c; }
.fb-stat-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.fb-stat-text b { font-size: 1.3rem; font-weight: 800; color: var(--fb-text); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.fb-stat-text span { font-size: 0.78rem; color: var(--fb-muted); line-height: 1.25; }
.fb-combo { white-space: nowrap; } /* keeps "Ctrl C" on one line */

/* Forms list: Quick start + tips below the list */
.fb-extras { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; margin-top: 32px; }
.fb-panel-block { background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: 12px; padding: 18px; }
.fb-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.fb-block-head h2 { font-size: 0.98rem; font-weight: 700; color: var(--fb-text); }
.fb-block-head a { font-size: 0.82rem; font-weight: 600; color: var(--fb-accent); text-decoration: none; white-space: nowrap; }
.fb-block-head a:hover { text-decoration: underline; }
.fb-starter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fb-starter-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--fb-line); border-radius: 10px; text-decoration: none; color: inherit; transition: border-color 0.15s, background 0.15s; }
.fb-starter-card:hover { border-color: var(--fb-accent); background: color-mix(in srgb, var(--fb-accent) 5%, var(--fb-panel)); }
.fb-starter-card:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-starter-ico { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--fb-accent-soft); color: var(--fb-accent-ink); }
.fb-starter-card:hover .fb-starter-ico { background: var(--fb-accent); color: #fff; }
.fb-starter-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fb-starter-txt b { font-size: 0.88rem; color: var(--fb-text); }
.fb-starter-txt span { font-size: 0.76rem; color: var(--fb-muted); line-height: 1.35; }
.fb-tips { list-style: none; display: grid; gap: 12px; margin: 0; padding: 0; }
.fb-tips li { display: flex; gap: 10px; align-items: flex-start; font-size: 0.84rem; color: var(--fb-muted); line-height: 1.45; }
.fb-tips b { color: var(--fb-text); font-weight: 600; }
.fb-tip-ico { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--fb-hover); color: var(--fb-accent-ink); }
@media (max-width: 860px) { .fb-extras { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .fb-starter-grid { grid-template-columns: minmax(0, 1fr); } }
.fb-nav { background: var(--fb-panel); border-bottom: 1px solid var(--fb-line); padding: 0 20px; }
.fb-nav-in { max-width: 1000px; margin: 0 auto; height: 60px; display: flex; align-items: center; }
.fb-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--fb-text); text-decoration: none; }
.fb-brand svg { color: var(--fb-accent); }
.fb-wrap { max-width: 1000px; margin: 0 auto; padding: 40px 20px 80px; }
.fb-list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.fb-list-head h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.025em; }
.fb-list-head p { color: var(--fb-muted); font-size: 0.95rem; }
.fb-list-actions { display: flex; gap: 10px; }
.btn.fb-btn-md { height: 42px; padding: 0 18px; font-size: 0.95rem; }
a.btn { text-decoration: none; }
.fb-list-actions label.btn { cursor: pointer; }
.fb-list-actions label.btn:focus-within { box-shadow: var(--shadow-glow); }
.fb-list-search { position: relative; margin-bottom: 16px; }
.fb-list-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--fb-muted); }
.fb-list-search .form-control { padding-left: 40px; background: var(--fb-panel); border-color: var(--fb-line); color: var(--fb-text); }
/* (no overflow: hidden, so the action tooltips on the first row aren't cut off; the rows round their own corners) */
.fb-form-list { list-style: none; background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: var(--radius-md); }
.fb-form-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--fb-line); flex-wrap: wrap; }
.fb-form-row:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.fb-form-row:last-child { border-bottom: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.fb-form-row:only-child { border-radius: var(--radius-md); }
/* Row actions: a soft "Edit" button and a group of icon buttons (tooltips from .fb-icon-act). */
.fb-form-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.fb-act-group { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--fb-line); border-radius: 10px; background: var(--fb-panel); }
.fb-act-group form { display: contents; }
.fb-act-group .fb-icon-act { border-color: transparent; background: transparent; width: 32px; height: 32px; }
.fb-act-group .fb-icon-act:hover, .fb-act-group .fb-icon-act:focus-visible { border-color: transparent; }
.fb-edit-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; background: var(--fb-accent-soft); color: var(--fb-accent-ink); font-size: 0.85rem; font-weight: 700; text-decoration: none; border: 1px solid transparent; transition: background 0.15s, color 0.15s, box-shadow 0.15s; }
.fb-edit-btn:hover { background: var(--fb-accent); color: #fff; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--fb-accent) 60%, transparent); }
.fb-edit-btn:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
@media (max-width: 640px) { .fb-form-actions { width: 100%; justify-content: space-between; } }
.fb-form-row:hover { background: var(--fb-hover); }
.fb-form-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.fb-form-title { font-weight: 600; font-size: 1rem; color: var(--fb-text); }
.fb-form-main:hover .fb-form-title { color: var(--fb-accent); }
.fb-form-desc { font-size: 0.875rem; color: var(--fb-muted); }
.fb-form-meta { font-size: 0.8rem; color: var(--fb-muted); }
.fb-form-actions form { display: contents; }
.fb-act-btn { font: inherit; font-size: 0.8rem; font-weight: 600; padding: 6px 10px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--fb-muted); cursor: pointer; text-decoration: none; }
.fb-act-btn:hover { background: var(--fb-panel); border-color: var(--fb-line); color: var(--fb-text); }
.fb-act-btn.is-danger:hover { color: var(--error); border-color: #fecaca; }
.fb-act-btn.is-disabled { opacity: 0.4; cursor: default; }
/* Pager (forms/pagination.blade.php): summary, page buttons, "Go to page", per page */
.fb-pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 20px; margin-top: 20px; }
.fb-pager-info { font-size: 0.85rem; color: var(--fb-muted); margin: 0; }
.fb-pager-info strong { color: var(--fb-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.fb-pager-pages { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0; padding: 0; }
.fb-page-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--fb-line); background: var(--fb-panel); color: var(--fb-text); font: inherit; font-size: 0.85rem; font-weight: 600; text-decoration: none; cursor: pointer; font-variant-numeric: tabular-nums; white-space: nowrap; }
a.fb-page-btn:hover, button.fb-page-btn:hover { border-color: var(--fb-accent); color: var(--fb-accent-ink); }
.fb-page-btn:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-page-btn.is-current { background: var(--fb-accent); border-color: var(--fb-accent); color: #fff; cursor: default; }
.fb-page-btn.is-disabled { opacity: 0.4; cursor: default; }
.fb-page-gap { display: inline-block; min-width: 20px; text-align: center; color: var(--fb-muted); }
.fb-pager-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.fb-pager-tools form { display: flex; align-items: center; gap: 6px; margin: 0; }
.fb-pager-tools label { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 600; color: var(--fb-muted); white-space: nowrap; }
.fb-pager-tools .form-control { height: 36px; padding: 4px 8px; font-size: 0.85rem; background: var(--fb-panel); border-color: var(--fb-line); color: var(--fb-text); }
.fb-pager-jump .form-control { width: 72px; }
.fb-pager-size .form-control { width: auto; padding-right: 26px; }
.fb-pager-of { font-size: 0.82rem; color: var(--fb-muted); }
@media (max-width: 640px) { .fb-page-btn .lbl { display: none; } .fb-pager { justify-content: center; } }

/* List filters (forms, users): one row of search + compact filters with the label inside the box,
   then a results bar with the count, "Clear filters" and Sort. */
.fb-filterbar { margin-bottom: 12px; }
.fb-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fb-filters .fb-filter-search { flex: 1 1 220px; min-width: 200px; margin: 0; }
.fb-filters .fb-filter-search .form-control { height: 40px; }
.fb-filter { position: relative; display: inline-flex; align-items: center; height: 40px; border: 1px solid var(--fb-line); border-radius: 10px; background: var(--fb-panel); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; }
.fb-filter:hover { border-color: var(--fb-muted); }
.fb-filter:focus-within { border-color: var(--fb-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fb-accent) 22%, transparent); }
.fb-filter > span { padding-left: 12px; font-size: 0.78rem; font-weight: 600; color: var(--fb-muted); white-space: nowrap; pointer-events: none; }
.fb-filter select { appearance: none; -webkit-appearance: none; height: 100%; border: 0; outline: 0; background: transparent; font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--fb-text); padding: 0 30px 0 6px; cursor: pointer; field-sizing: content; max-width: 200px; text-overflow: ellipsis; }
.fb-filter::after { content: ''; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; margin-top: -5px; border: solid var(--fb-muted); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); pointer-events: none; }
.fb-filter select option { color: #0f172a; background: #fff; font-weight: 500; }
/* A filter that is narrowing the list is tinted, so it is clear at a glance what is applied. */
.fb-filter.is-set { border-color: color-mix(in srgb, var(--fb-accent) 55%, var(--fb-line)); background: var(--fb-accent-soft); }
.fb-filter.is-set > span, .fb-filter.is-set select { color: var(--fb-accent-ink); }
.fb-resultbar { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-top: 12px; }
.fb-filter-result { margin: 0; font-size: 0.85rem; color: var(--fb-muted); }
.fb-filter-result b { color: var(--fb-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.fb-filter-clear { margin-left: 10px; font-size: 0.85rem; font-weight: 600; color: var(--fb-accent); text-decoration: none; white-space: nowrap; }
.fb-filter-clear:hover { text-decoration: underline; }
.fb-sort { height: 34px; border-color: transparent; background: transparent; }
.fb-sort:hover { border-color: var(--fb-line); background: var(--fb-panel); }
@media (max-width: 640px) { .fb-filters .fb-filter-search { flex-basis: 100%; } .fb-filters .fb-filter { flex: 1 1 auto; } .fb-filters .fb-filter select { flex: 1; max-width: none; } }
.fb-empty-list { text-align: center; padding: 64px 24px; background: var(--fb-panel); border: 2px dashed var(--fb-line); border-radius: var(--radius-md); }
.fb-empty-list svg { color: var(--fb-accent); margin-bottom: 12px; }
.fb-empty-list h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.fb-empty-list p { color: var(--fb-muted); max-width: 460px; margin: 0 auto 20px; }
.fb-empty-list a { color: var(--fb-accent); }

/* ==========================================================================
   New form: template gallery
   ========================================================================== */
.fb-wrap.fb-wrap-wide { max-width: 1240px; }

/* ---------- Accounts: top-bar user menu, sign-in and account pages, admin user list ---------- */
/* ---------- Top bar: brand, main tabs, account menu ---------- */
.fb-nav { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--fb-panel) 92%, transparent); backdrop-filter: saturate(160%) blur(8px); border-bottom: 1px solid var(--fb-line); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px -12px rgba(15, 23, 42, 0.18); }
.fb-nav-in { gap: 28px; height: 64px; }
.fb-page.has-wide .fb-nav-in { max-width: 1240px; } /* the bar lines up with the page below it (.fb-wrap / .fb-wrap-wide) */
.fb-brand { gap: 10px; font-size: 1.02rem; letter-spacing: -0.02em; flex-shrink: 0; }
.fb-brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 4px 10px -4px rgba(79, 70, 229, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.fb-brand svg { color: inherit; }
.fb-brand:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 4px; border-radius: 8px; }
.fb-nav-main { display: flex; align-self: stretch; gap: 4px; }
.fb-nav-tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; font-size: 0.88rem; font-weight: 600; color: var(--fb-muted); text-decoration: none; transition: color 0.15s; }
.fb-nav-tab svg { opacity: 0.8; }
.fb-nav-tab::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--fb-accent); transform: scaleX(0); transition: transform 0.18s; }
.fb-nav-tab:hover { color: var(--fb-text); }
.fb-nav-tab.is-active { color: var(--fb-text); }
.fb-nav-tab.is-active svg { color: var(--fb-accent); opacity: 1; }
.fb-nav-tab.is-active::after { transform: scaleX(1); }
.fb-nav-tab:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: -6px; border-radius: 8px; }
/* Account menu */
.fb-account { position: relative; margin-left: auto; }
.fb-account-btn { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border: 1px solid transparent; border-radius: 999px; background: none; font: inherit; color: var(--fb-text); cursor: pointer; text-align: left; transition: background 0.15s, border-color 0.15s; }
.fb-account-btn:hover, .fb-account.is-open .fb-account-btn { background: var(--fb-hover); border-color: var(--fb-line); }
.fb-account-btn:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; color: var(--fb-accent-ink); background: var(--fb-accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fb-accent) 25%, transparent); }
.fb-avatar.is-lg { width: 42px; height: 42px; font-size: 0.9rem; }
.fb-account-who { display: flex; flex-direction: column; line-height: 1.2; }
.fb-account-name { font-size: 0.86rem; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-account-role { font-size: 0.72rem; color: var(--fb-muted); }
.fb-account-caret { color: var(--fb-muted); transition: transform 0.15s; }
.fb-account.is-open .fb-account-caret { transform: rotate(180deg); }
.fb-account-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 272px; padding: 6px; border-radius: 12px; background: var(--fb-panel); border: 1px solid var(--fb-line); box-shadow: 0 16px 40px -12px rgba(15, 23, 42, 0.28), 0 2px 6px rgba(15, 23, 42, 0.06); }
.fb-account-menu[hidden] { display: none; }
.fb-account-head { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--fb-line); }
.fb-account-head-name { font-size: 0.9rem; font-weight: 700; color: var(--fb-text); margin: 0; }
.fb-account-head-meta { font-size: 0.76rem; color: var(--fb-muted); margin: 1px 0 4px; word-break: break-all; }
.fb-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 0.86rem; font-weight: 500; color: var(--fb-text); text-decoration: none; cursor: pointer; text-align: left; }
.fb-menu-item svg { color: var(--fb-muted); flex-shrink: 0; }
.fb-menu-item:hover, .fb-menu-item:focus-visible { background: var(--fb-hover); outline: none; }
.fb-menu-item:hover svg, .fb-menu-item:focus-visible svg { color: var(--fb-accent); }
.fb-menu-item.is-danger:hover, .fb-menu-item.is-danger:focus-visible { background: #fef2f2; color: #b91c1c; }
.fb-menu-item.is-danger:hover svg, .fb-menu-item.is-danger:focus-visible svg { color: #b91c1c; }
.fb-menu-sep { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--fb-line); }
@media (max-width: 720px) {
    .fb-nav-in { gap: 12px; }
    .fb-brand-name, .fb-account-who { display: none; }
    .fb-nav-tab { padding: 0 8px; }
}
.fb-auth { max-width: 420px; margin: 24px auto 0; }
.fb-auth.fb-auth-wide { max-width: 560px; margin-top: 0; }
.fb-auth h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; color: var(--fb-text); }
.fb-auth-lead { color: var(--fb-muted); font-size: 0.92rem; margin-bottom: 20px; }
.fb-auth-note { color: var(--fb-muted); font-size: 0.82rem; margin-top: 16px; text-align: center; }
.fb-page-back { font-size: 0.85rem; margin-bottom: 10px; } .fb-page-back a { color: var(--fb-accent); text-decoration: none; } /* not .fb-back: the builder uses that */
.fb-card { background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: var(--radius-md); padding: 24px; }
.fb-form-field { margin-bottom: 16px; }
.fb-form-field > label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--fb-text); }
.fb-form-field .form-control { background: var(--fb-field); border-color: var(--fb-line); color: var(--fb-text); }
.fb-form-field .form-control[readonly] { color: var(--fb-muted); cursor: default; }
.fb-form-field .form-control.is-invalid { border-color: var(--error); }
.fb-form-field .mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.fb-optional { font-weight: 500; color: var(--fb-muted); font-size: 0.78rem; }
.fb-field-help { font-size: 0.78rem; color: var(--fb-muted); margin-top: 5px; }
.fb-field-error { font-size: 0.8rem; color: var(--error); margin-top: 5px; font-weight: 500; }
.fb-profile-meta { font-size: 0.82rem; color: var(--fb-muted); margin: 4px 0 18px; }
.fb-wide-btn { width: 100%; justify-content: center; }
.fb-pw-row { display: flex; gap: 8px; } .fb-pw-row .form-control { flex: 1; min-width: 0; }
.fb-pw-rules { margin: 8px 0 0; padding-left: 18px; font-size: 0.78rem; color: var(--fb-muted); columns: 2; column-gap: 18px; }
.fb-alert { padding: 12px 14px; border-radius: 10px; font-size: 0.88rem; font-weight: 500; margin-bottom: 14px; line-height: 1.45; }
.fb-alert.is-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.fb-alert.is-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.fb-auth-lead .mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.85em; }
.fb-check { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 20px; font-size: 0.88rem; font-weight: 600; color: var(--fb-text); cursor: pointer; }
.fb-check input[type="checkbox"] { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--fb-accent); flex-shrink: 0; }
.fb-check .fb-field-help { display: block; font-weight: 400; margin-top: 2px; }
.fb-badge { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.02em; vertical-align: middle; white-space: nowrap; }
.fb-badge + .fb-badge { margin-left: 4px; }
.fb-badge.is-admin { background: var(--fb-accent-soft); color: var(--fb-accent-ink); }
.fb-badge.is-active { background: #dcfce7; color: #166534; }
.fb-badge.is-locked { background: #fef3c7; color: #92400e; }
.fb-badge.is-blocked { background: #fee2e2; color: #991b1b; }
.fb-table-card { background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: var(--radius-md); overflow-x: auto; margin-bottom: 16px; }
.fb-user-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; color: var(--fb-text); }
.fb-user-table th { text-align: left; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fb-muted); padding: 12px 14px; border-bottom: 1px solid var(--fb-line); white-space: nowrap; }
.fb-user-table td { padding: 12px 14px; border-bottom: 1px solid var(--fb-line); vertical-align: middle; }
.fb-user-table tbody tr:last-child td { border-bottom: 0; }
.fb-user-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.fb-user-name { display: block; font-weight: 600; } .fb-you { font-weight: 500; color: var(--fb-muted); }
.fb-user-login { display: block; font-size: 0.78rem; color: var(--fb-muted); font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.fb-user-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
/* Icon action buttons with a tooltip from data-tip (shown on hover and on keyboard focus) */
.fb-icon-act { position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 8px; border: 1px solid var(--fb-line); background: var(--fb-panel); color: var(--fb-muted); cursor: pointer; text-decoration: none; transition: color 0.15s, border-color 0.15s, background-color 0.15s; }
.fb-icon-act:hover, .fb-icon-act:focus-visible { color: var(--fb-accent-ink); border-color: var(--fb-accent); background: var(--fb-accent-soft); }
.fb-icon-act.is-danger:hover, .fb-icon-act.is-danger:focus-visible { color: #b91c1c; border-color: #fca5a5; background: #fef2f2; }
.fb-icon-act.is-good:hover, .fb-icon-act.is-good:focus-visible { color: #15803d; border-color: #86efac; background: #f0fdf4; }
.fb-icon-act:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-icon-act::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translate(-50%, 3px); padding: 5px 9px; border-radius: 6px; background: #0f172a; color: #fff; font-size: 0.74rem; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.12s, transform 0.12s; z-index: 5; }
.fb-icon-act:hover::after, .fb-icon-act:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.fb-user-table td:last-child { width: 1%; white-space: nowrap; }
.fb-icon-slot { display: inline-block; width: 32px; height: 32px; }
.fb-user-actions form { display: inline; }
.fb-form-owner { color: var(--fb-text); font-weight: 600; }
/* Favorites (pin) and Trash */
.fb-pin-form { margin: 0; }
.fb-pin { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: #cbd5e1; cursor: pointer; transition: color 0.15s, background 0.15s, transform 0.15s; }
.fb-pin:hover { color: #f59e0b; background: #fffbeb; }
.fb-pin.is-on { color: #f59e0b; }
.fb-pin:active { transform: scale(0.9); }
.fb-pin:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-pin::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); padding: 5px 9px; border-radius: 6px; background: #0f172a; color: #fff; font-size: 0.74rem; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.12s; z-index: 5; }
.fb-pin:hover::after, .fb-pin:focus-visible::after { opacity: 1; }
.fb-form-row.is-pinned { background: color-mix(in srgb, #f59e0b 4%, var(--fb-panel)); }
.fb-form-title .fb-badge { margin-left: 8px; }
.fb-badge.is-pinned { background: #fef3c7; color: #92400e; }
.fb-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--fb-hover); color: var(--fb-muted); font-size: 0.72rem; font-weight: 700; }
.fb-btn-danger:hover { color: #b91c1c; border-color: #fca5a5; background: #fef2f2; }
.fb-form-row.is-trashed .fb-form-title { color: var(--fb-muted); }
/* (the toast's Undo button uses the builder's existing .fb-toast-action style) */
@media (max-width: 720px) { .fb-pw-rules { columns: 1; } }
.tpl-back { display: inline-block; font-size: 0.85rem; font-weight: 600; color: var(--fb-muted); text-decoration: none; margin-bottom: 6px; }
.tpl-back:hover { color: var(--fb-accent); }
/* New form: a compact step panel on the left, a live preview that stays in view on the right. */
.tpl-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.tpl-top h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.tpl-top-form { display: flex; gap: 10px; flex: 1 1 420px; max-width: 560px; }
.tpl-title.form-control { flex: 1; min-width: 0; padding: 10px 14px; font-size: 1rem; font-weight: 600; background: var(--fb-panel); border-color: var(--fb-line); color: var(--fb-text); }
.tpl-create { white-space: nowrap; }

.tpl-studio { display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); gap: 20px; align-items: start; }
/* Height: the screen below the page header (~200px), so the step footer is in view without scrolling the page. */
.tpl-side, .tpl-preview { position: sticky; top: 12px; height: max(460px, calc(100vh - 210px)); display: flex; flex-direction: column; background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: 14px; overflow: hidden; min-width: 0; }

.tpl-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 6px; border-bottom: 1px solid var(--fb-line); background: var(--fb-hover); }
.tpl-tabs [role="tab"] { display: flex; align-items: center; gap: 8px; padding: 8px; border: 0; border-radius: 9px; background: none; color: var(--fb-muted); text-align: left; cursor: pointer; min-width: 0; transition: background 0.15s, color 0.15s; }
.tpl-tabs [role="tab"]:hover { color: var(--fb-text); }
.tpl-tabs [aria-selected="true"] { background: var(--fb-panel); color: var(--fb-text); box-shadow: 0 1px 3px rgb(15 23 42 / 0.12); }
.tpl-tabs [role="tab"]:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 1px; }
.tpl-tab-num { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--fb-line); font-size: 0.74rem; font-weight: 700; }
.tpl-tabs [aria-selected="true"] .tpl-tab-num { background: var(--fb-accent); color: #fff; }
.tpl-tab-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.tpl-tab-text b { font-size: 0.82rem; }
.tpl-tab-text small { font-size: 0.72rem; color: var(--fb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tpl-pane { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px; overscroll-behavior: contain; }
.tpl-pane[hidden] { display: none; }
.tpl-pane-hint { font-size: 0.8rem; color: var(--fb-muted); margin-bottom: 10px; }
.tpl-pane-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.tpl-find { flex: 1 1 160px; position: relative; }
.tpl-find svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--fb-muted); pointer-events: none; }
.tpl-side .tpl-find .form-control { width: 100%; padding: 7px 10px 7px 32px; font-size: 0.86rem; background: var(--fb-field); border-color: var(--fb-line); color: var(--fb-text); }
.tpl-chips { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--fb-line); border-radius: 9px; }
.tpl-chips button, .tpl-seg button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; font-size: 0.78rem; font-weight: 600; color: var(--fb-muted); cursor: pointer; }
.tpl-chips [aria-pressed="true"], .tpl-seg [aria-pressed="true"] { background: var(--fb-accent-soft); color: var(--fb-accent-ink); }
.tpl-chips button:focus-visible, .tpl-seg button:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 1px; }

.tpl-starters { display: grid; gap: 6px; }
.tpl-starter { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--fb-line); border-radius: 10px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.tpl-starter:hover { border-color: var(--fb-muted); background: var(--fb-hover); }
.tpl-starter:has(input:checked) { border-color: var(--fb-accent); background: color-mix(in srgb, var(--fb-accent) 7%, var(--fb-panel)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-accent) 25%, transparent); }
.tpl-starter:has(input:focus-visible) { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.tpl-starter-icon { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--fb-accent-soft); color: var(--fb-accent-ink); }
.tpl-starter:has(input:checked) .tpl-starter-icon { background: var(--fb-accent); color: #fff; }
.tpl-starter-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tpl-starter-name { font-weight: 700; font-size: 0.9rem; }
.tpl-starter-desc { font-size: 0.78rem; color: var(--fb-muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-starter-meta { font-size: 0.72rem; font-weight: 600; color: var(--fb-muted); }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.tpl-card { display: flex; flex-direction: column; border: 1px solid var(--fb-line); border-radius: 10px; overflow: hidden; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.tpl-card[hidden] { display: none; }
.tpl-card:hover { border-color: var(--fb-muted); transform: translateY(-2px); }
.tpl-card:has(input:checked) { border-color: var(--fb-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-accent) 35%, transparent); }
.tpl-card:has(input:focus-visible) { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.tpl-thumb { display: block; height: 82px; overflow: hidden; border-bottom: 1px solid var(--fb-line); pointer-events: none; }
.tpl-scale { display: block; transform-origin: top left; }
.tpl-stage { display: block; padding: 22px; background: var(--bg-color); color-scheme: light; }
.tpl-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 9px; }
.tpl-name { font-weight: 700; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-card:has(input:checked) .tpl-name { color: var(--fb-accent-ink); }
.tpl-swatches { display: flex; flex: none; }
.tpl-swatches i { width: 11px; height: 11px; margin-left: -3px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--fb-panel), inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.tpl-none { padding: 20px; text-align: center; color: var(--fb-muted); font-size: 0.86rem; }

.tpl-field { margin-bottom: 14px; }
.tpl-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl-field label, .tpl-colors legend { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; }
.tpl-side .form-control { padding: 8px 12px; background: var(--fb-field); border-color: var(--fb-line); color: var(--fb-text); }
.tpl-colors { border: 0; margin-bottom: 12px; }
.tpl-colors legend span { font-weight: 500; color: var(--fb-muted); margin-left: 4px; }
.tpl-color { display: grid; grid-template-columns: 38px 1fr 92px; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--fb-line); }
.tpl-color:last-child { border-bottom: 0; }
.tpl-color label { font-size: 0.9rem; cursor: pointer; }
.tpl-color input[type="color"] { width: 38px; height: 30px; padding: 2px; border: 1px solid var(--fb-line); border-radius: 7px; background: var(--fb-panel); cursor: pointer; }
.tpl-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.tpl-color input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.tpl-color input[type="color"]::-moz-color-swatch { border: 0; border-radius: 4px; }
.tpl-hex { width: 100%; font: 500 0.85rem ui-monospace, SFMono-Regular, Consolas, monospace; padding: 6px 8px; border: 1px solid var(--fb-line); border-radius: 7px; background: var(--fb-field); color: var(--fb-text); text-transform: lowercase; }
.tpl-hex:focus, .tpl-color input[type="color"]:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 1px; }
.tpl-hex[aria-invalid="true"] { border-color: var(--error); }
.tpl-checks { list-style: none; display: grid; gap: 4px; margin-bottom: 12px; font-size: 0.8rem; }
.tpl-checks li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 10px; border-radius: 7px; background: var(--fb-hover); }
.tpl-checks b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tpl-checks .is-ok b { color: #047857; }
.tpl-checks .is-low b { color: #b45309; }
@media (prefers-color-scheme: dark) { .tpl-checks .is-ok b { color: #34d399; } .tpl-checks .is-low b { color: #fbbf24; } }
.tpl-side .btn-outline { background: var(--fb-panel); color: var(--fb-text); border-color: var(--fb-line); }
.tpl-side .btn-outline:disabled { opacity: 0.45; cursor: default; }
.tpl-side-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--fb-line); }
.tpl-side-foot [hidden] { display: none; }
.tpl-foot-note { flex: 1; font-size: 0.74rem; color: var(--fb-muted); line-height: 1.3; }

.tpl-preview { transition: box-shadow 0.15s; }
.tpl-preview.is-peeking { box-shadow: 0 0 0 3px color-mix(in srgb, var(--fb-accent) 30%, transparent); }
.tpl-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--fb-line); flex-wrap: wrap; }
.tpl-preview-title { flex: 1 1 220px; display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 0.8rem; color: var(--fb-muted); }
.tpl-preview-title b { color: var(--fb-text); font-size: 0.88rem; white-space: nowrap; }
.tpl-preview-title span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-live-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 3px rgb(16 185 129 / 0.2); align-self: center; }
.tpl-preview-tools { display: flex; align-items: center; gap: 6px; }
.tpl-seg { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--fb-line); border-radius: 9px; margin-left: 4px; }
.tpl-preview-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; background: var(--fb-hover); }
.tpl-preview-frame { overflow: hidden; }
.tpl-preview.is-mobile .tpl-preview-frame { width: 390px; max-width: 100%; margin: 16px auto; border-radius: 22px; box-shadow: 0 0 0 8px #0f172a, 0 20px 40px -12px rgb(0 0 0 / 0.4); }
.tpl-preview.is-mobile .layer-grid { grid-template-columns: minmax(0, 1fr) !important; }
.tpl-preview .tpl-stage { padding: 32px 28px; }
.tpl-preview.is-mobile .tpl-stage { padding: 18px 12px; }
.tpl-peek { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px; background: #0f172a; color: #fff; font-size: 0.76rem; font-weight: 600; pointer-events: none; box-shadow: 0 6px 18px rgb(0 0 0 / 0.25); }
.tpl-peek[hidden] { display: none; }

@media (max-width: 900px) {
    .tpl-studio { grid-template-columns: minmax(0, 1fr); }
    .tpl-side, .tpl-preview { position: static; height: auto; }
    .tpl-pane { max-height: 60vh; }
    .tpl-preview-scroll { max-height: 75vh; }
    .tpl-top-form { max-width: none; }
}
@media (max-width: 520px) { .tpl-top-form { flex-wrap: wrap; } .tpl-create { width: 100%; justify-content: center; } .tpl-foot-note { display: none; } }
@media (prefers-reduced-motion: reduce) { .tpl-card, .tpl-starter { transition: none; } .tpl-card:hover { transform: none; } }

/* ==========================================================================
   Builder
   ========================================================================== */
html:has(body.fb), body.fb { height: 100%; }
body.fb { background: var(--fb-canvas); display: flex; flex-direction: column; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.fb-topbar { height: var(--fb-top); flex-shrink: 0; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 12px; background: var(--fb-panel); border-bottom: 1px solid var(--fb-line); position: relative; z-index: 20; }
.fb-back-link { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: 8px; font-size: 0.875rem; font-weight: 600; color: var(--fb-muted); text-decoration: none; }
.fb-back-link:hover { background: var(--fb-hover); color: var(--fb-text); }
.fb-doc-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 32ch; padding-left: 14px; border-left: 1px solid var(--fb-line); }
.fb-status { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 0.8rem; font-weight: 500; color: var(--fb-muted); background: none; border: 0; padding: 4px 6px; border-radius: 6px; cursor: default; white-space: nowrap; }
.fb-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.fb-status.is-dirty .fb-status-dot { background: var(--warning); }
.fb-status.is-saving .fb-status-dot { background: var(--fb-accent); animation: fbPulse 1s ease-in-out infinite; }
.fb-status.is-error { color: var(--error); cursor: pointer; }
.fb-status.is-error .fb-status-dot { background: var(--error); }
.fb-status.is-error:hover { background: var(--error-light); }
@keyframes fbPulse { 50% { opacity: 0.3; } }
.fb-spacer { flex: 1; }
.fb-actions { display: flex; align-items: center; gap: 6px; }
.fb-sep { width: 1px; height: 24px; background: var(--fb-line); margin: 0 6px; }

.fb-export { position: relative; }
.fb-menu { position: absolute; right: 0; top: calc(100% + 6px); width: 270px; background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: 10px; box-shadow: 0 16px 40px -12px rgba(2, 6, 23, 0.35); padding: 6px; z-index: 30; }
.fb-menu button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 9px 12px; border: 0; border-radius: 7px; background: none; color: var(--fb-text); font: inherit; text-align: left; cursor: pointer; }
.fb-menu button:hover, .fb-menu button:focus-visible { background: var(--fb-hover); outline: none; }
.fb-menu strong { font-size: 0.875rem; }
.fb-menu span { font-size: 0.78rem; color: var(--fb-muted); }

.fb-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 20px; background: #fffbeb; color: #78350f; border-bottom: 1px solid #fde68a; font-size: 0.875rem; font-weight: 500; }
.fb-banner[hidden] { display: none; }
.fb-banner span { flex: 1; min-width: 200px; }
.fb-banner .fb-btn { height: 32px; }

/* Panes */
.fb-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr) 336px; }
.fb-pane { min-height: 0; overflow-y: auto; background: var(--fb-panel); }
.fb-pane-head { position: sticky; top: 0; z-index: 2; background: var(--fb-panel); padding: 16px 16px 12px; border-bottom: 1px solid var(--fb-line); }
.fb-pane-head h2 { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; }
.fb-pane-head p { font-size: 0.8rem; color: var(--fb-muted); margin-top: 2px; }

/* Toolbox */
.fb-toolbox { border-right: 1px solid var(--fb-line); }
.fb-search { position: relative; margin-top: 12px; }
.fb-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--fb-muted); pointer-events: none; }
.fb-search .form-control.fb-input { padding-left: 34px; }
.fb-tool-group { padding: 14px 12px 4px; }
.fb-tool-group h3 { font-size: 0.78rem; font-weight: 600; color: var(--fb-muted); padding: 0 6px 8px; }
.fb-tool-list { display: flex; flex-direction: column; gap: 3px; }
.fb-tool { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; border: 1px solid transparent; cursor: grab; user-select: none; -webkit-user-select: none; color: var(--fb-text); }
.fb-tool:hover { background: var(--fb-hover); border-color: var(--fb-line); }
.fb-tool-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--fb-accent-soft); color: var(--fb-accent-ink); flex-shrink: 0; }
.fb-tool-name { font-size: 0.86rem; font-weight: 600; flex: 1; min-width: 0; }
.fb-tool-tag { font-size: 0.7rem; font-weight: 600; color: var(--fb-muted); border: 1px solid var(--fb-line); border-radius: 6px; padding: 1px 6px; }
.fb-tool[hidden], .fb-tool-group[hidden] { display: none; }
.fb-tool-empty { padding: 24px 18px; font-size: 0.85rem; color: var(--fb-muted); }

/* Canvas & paper */
.fb-canvas { min-height: 0; overflow-y: auto; padding: 28px 24px 80px; background-color: var(--fb-canvas); background-image: radial-gradient(var(--fb-dot) 1px, transparent 1px); background-size: 18px 18px; }
.fb-paper { max-width: 920px; margin: 0 auto; color: var(--text-main); color-scheme: light; }
.fb-paper .form-header { cursor: pointer; padding: 30px 34px; }
.fb-paper .form-header h2 { font-size: 1.55rem; }
.fb-paper .form-body { padding: 20px 20px 24px; }
.fb-paper .form-actions { padding: 20px 34px; cursor: pointer; }
.fb-paper .form-actions .btn { pointer-events: none; }
.fb-pages { display: flex; align-items: center; gap: 12px; }
.fb-pages ol { flex-shrink: 0; }
.fb-pages a.is-selected { box-shadow: inset 0 0 0 2px var(--primary); border-radius: 8px; }
.fb-page-add { display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; padding: 5px 11px 5px 8px; font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); background: transparent; border: 1px dashed var(--border); border-radius: 999px; cursor: pointer; white-space: nowrap; }
.fb-page-add:hover { color: var(--primary); border-color: var(--primary); border-style: solid; }
.fb-page-add:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.fb-pages a.is-cond .form-page-title::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--warning); vertical-align: middle; }
.fb-cond-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px; font-size: 0.68rem; font-weight: 700; line-height: 1.4; color: #92400e; background: #fef3c7; white-space: nowrap; }
.fb-item > .fb-cond-chip { margin: 0 0 6px; }
.fb-pages-hint { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.fb-paper.is-form-selected { outline: 2px solid var(--primary); outline-offset: 4px; }

/* Layers */
.fb-layers { display: flex; flex-direction: column; gap: 14px; }
.fb-layer { border: 1px solid var(--border-soft, #e2e8f0); border-radius: 12px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.fb-layer:hover { border-color: #c7d2fe; }
.fb-layer.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14); }
.fb-layer-head { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 8px; border-bottom: 1px dashed var(--border-soft, #e2e8f0); cursor: grab; border-radius: 12px 12px 0 0; background: color-mix(in srgb, var(--primary) 4%, var(--surface)); outline: none; }
.fb-layer-head:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.fb-layer-grip { color: #94a3b8; display: grid; }
.fb-layer-num { font-size: 0.75rem; font-weight: 700; color: var(--primary-hover); background: var(--primary-light); border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.fb-layer-name { font-size: 0.8rem; color: var(--text-muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-layer-layout { display: grid; color: #a5b4fc; }
.fb-layout-icon rect { fill: currentColor; }
.fb-layer-bar { display: flex; gap: 1px; opacity: 0; transition: opacity 0.15s; }
.fb-layer:hover .fb-layer-bar, .fb-layer.is-selected .fb-layer-bar, .fb-layer-head:focus-within .fb-layer-bar { opacity: 1; }
.fb-layer-bar button, .fb-item-bar button { width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: #64748b; cursor: pointer; }
.fb-layer-bar button:hover, .fb-item-bar button:hover { background: #eef2ff; color: #0f172a; }
.fb-layer-bar button.del:hover, .fb-item-bar button.del:hover { background: var(--error-light); color: var(--error); }
.fb-layer-bar button:disabled, .fb-item-bar button:disabled { opacity: 0.3; cursor: default; background: transparent; }
.fb-layer-body { padding: 16px; }
.fb-layer-body .form-section-title { margin-bottom: 18px; }
.fb-layer-body .layer-grid { gap: 12px; }
.fb-col { min-height: 70px; border-radius: 10px; display: flex; flex-direction: column; gap: 6px; padding: 2px; position: relative; }
.fb-col.is-empty { border: 2px dashed var(--border-soft, #dbe2ea); background: var(--field-bg, #fbfcfe); align-items: center; justify-content: center; }
.fb-col.is-empty::after { content: 'Drop fields here'; font-size: 0.8rem; font-weight: 500; color: var(--placeholder, #94a3b8); pointer-events: none; }
.fb-layer .layer-grid > .fb-col + .fb-col { position: relative; }

/* Field items */
.fb-item { position: relative; padding: 10px; border-radius: 10px; border: 1px dashed transparent; cursor: grab; transition: border-color 0.15s, background-color 0.15s; outline: none; }
.fb-item:hover { border-color: var(--border-focus); background: rgba(99, 102, 241, 0.03); }
.fb-item:focus-visible { border-color: var(--primary); border-style: solid; }
.fb-item.is-selected { border: 1px solid var(--primary); background: rgba(99, 102, 241, 0.05); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
.fb-item-body { pointer-events: none; }
.fb-item-body .form-group { margin-bottom: 0; }
.fb-item-body .dropzone:hover { transform: none; box-shadow: none; }
.fb-item-tag { position: absolute; top: -11px; left: 10px; font-size: 0.7rem; font-weight: 600; line-height: 1; padding: 5px 8px; border-radius: 6px; background: var(--primary); color: #fff; opacity: 0; transform: translateY(3px); transition: opacity 0.15s, transform 0.15s; pointer-events: none; white-space: nowrap; z-index: 2; }
.fb-item.is-selected .fb-item-tag { opacity: 1; transform: none; }
.fb-item-bar { position: absolute; top: -14px; right: 8px; display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: #fff; border: 1px solid #e2e8f0; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 3; }
.fb-item:hover .fb-item-bar, .fb-item.is-selected .fb-item-bar, .fb-item:focus-within .fb-item-bar { opacity: 1; pointer-events: auto; }
.fb-hidden-chip { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--text-muted); background: var(--bg-color); flex-wrap: wrap; }
.fb-hidden-chip code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.8rem; color: var(--text-main); overflow-wrap: anywhere; }

/* Drag feedback */
.fb-col > .fb-tool, .fb-newlayer > .fb-tool { height: 48px; border: 2px dashed var(--primary); background: var(--primary-light); color: var(--primary-hover); border-radius: 10px; justify-content: center; }
.fb-col > .fb-tool .fb-tool-tag, .fb-newlayer > .fb-tool .fb-tool-tag { display: none; }
.fb-ghost { opacity: 0.35; }

/* Nested layers: a layer inside a column, among its fields */
.fb-col.is-empty:not(.no-nest)::after { content: 'Drop fields or a layout here'; }
.fb-layer.is-nested { border-style: dashed; border-color: color-mix(in srgb, var(--primary) 30%, var(--surface)); border-radius: 10px; background: color-mix(in srgb, var(--primary) 2%, var(--surface)); }
.fb-layer.is-nested:hover { border-color: var(--border-focus); }
.fb-layer.is-nested.is-selected { border-style: solid; border-color: var(--primary); }
.fb-layer.is-nested > .fb-layer-head { height: 30px; border-radius: 10px 10px 0 0; }
.fb-layer.is-nested > .fb-layer-head .fb-layer-num { font-size: 0.7rem; padding: 1px 6px; }
.fb-layer.is-nested > .fb-layer-body { padding: 10px; }
.fb-layer.is-nested .fb-col { min-height: 56px; }
.fb-tool-layout .fb-tool-icon { color: var(--fb-accent-ink); }
.fb-col > .fb-tool-layout .fb-tool-icon { background: transparent; }
.fb-chosen { box-shadow: var(--shadow-lg); }

/* New layer zone */
.fb-newlayer { margin-top: 14px; padding: 14px 16px; border: 2px dashed var(--border, #cbd5e1); border-radius: 12px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--field-bg, #fbfcfe); }
.fb-newlayer-copy { display: flex; flex-direction: column; flex: 1; min-width: 200px; font-size: 0.85rem; color: var(--text-muted); }
.fb-newlayer-copy strong { color: var(--text-main); font-size: 0.9rem; }
.fb-newlayer > .fb-item { width: 100%; }
.fb-newlayer.is-hero { margin-top: 0; flex-direction: column; text-align: center; padding: 48px 24px; }
.fb-newlayer.is-hero .fb-newlayer-copy { align-items: center; }
.fb-newlayer.is-hero svg { color: var(--primary); margin-bottom: 10px; }
.fb-newlayer.is-hero h3 { font-size: 1.15rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.fb-newlayer.is-hero p { max-width: 420px; font-size: 0.9rem; }
.fb-layout-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-newlayer.is-hero .fb-layout-picker { justify-content: center; }
.fb-layout-btn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; font: inherit; font-size: 0.78rem; font-weight: 600; color: #334155; cursor: pointer; }
.fb-layout-btn svg { color: #a5b4fc; }
.fb-layout-btn:hover { border-color: var(--primary); color: var(--primary-hover); }
.fb-layout-btn:hover svg { color: var(--primary); }
.fb-newlayer:not(.is-hero) .fb-layout-btn span { display: none; }

/* Inspector */
.fb-inspector { border-left: 1px solid var(--fb-line); }
.fb-insp-head { display: flex; align-items: flex-start; gap: 10px; }
.fb-insp-head .fb-tool-icon { margin-top: 1px; }
.fb-insp-head > div { flex: 1; min-width: 0; }
.fb-insp-head h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-insp-section { padding: 16px; border-bottom: 1px solid var(--fb-line); }
.fb-insp-section:last-child { border-bottom: 0; }
.fb-insp-section > h3 { font-size: 0.8rem; font-weight: 600; color: var(--fb-muted); margin-bottom: 12px; }
.fb-field { margin-bottom: 14px; }
.fb-field:last-child { margin-bottom: 0; }
.fb-field > label, .fb-field > .fb-label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; color: var(--fb-text); }
.fb-field .attr { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-weight: 500; font-size: 0.78rem; color: var(--fb-accent-ink); background: var(--fb-accent-soft); padding: 1px 6px; border-radius: 4px; }
.fb-hint { font-size: 0.75rem; color: var(--fb-muted); margin-top: 5px; line-height: 1.45; }
.fb-rules { display: grid; gap: 10px; margin-bottom: 10px; }
.fb-rules-empty { margin-top: 0; }
.fb-rule { border: 1px solid var(--fb-line); border-radius: 10px; padding: 10px 12px 12px; background: var(--fb-field); }
.fb-rule .fb-field { margin-bottom: 10px; }
.fb-rule .fb-field:last-child { margin-bottom: 0; }
.fb-rule-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.fb-rule-head strong { flex: 1; font-size: 0.85rem; min-width: 0; }
.fb-rule-head .fb-icon-btn { width: 26px; height: 26px; }
.fb-rule-head .fb-icon-btn:disabled { opacity: 0.3; cursor: default; background: transparent; }
.fb-rule-n { width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 0.7rem; font-weight: 700; background: var(--fb-accent-soft); color: var(--fb-accent-ink); margin-right: 4px; }
.fb-rule-logic { font-size: 0.8rem; line-height: 1.45; color: var(--fb-text); background: var(--fb-panel); border: 1px dashed var(--fb-line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.fb-rule-add { font-weight: 600; color: var(--fb-accent-ink); }
.fb-rule .fb-btn.fb-wide { margin: 0 0 10px; }
.fb-dialog.fb-dialog-rule { width: min(860px, 100%); height: auto; max-height: min(820px, 100%); }
.rl-body { overflow-y: auto; padding: 4px 22px 22px; }
.rl-part { padding: 16px 0; border-bottom: 1px solid var(--fb-line); }
.rl-part:last-child { border-bottom: 0; }
.rl-part h3 { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fb-accent-ink); margin-bottom: 8px; }
.rl-lead { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 0.9rem; margin-bottom: 10px; }
.rl-lead .rl-match { width: auto; padding: 4px 8px; }
.rl-cond { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.rl-cond .form-control { padding: 7px 9px; font-size: 0.85rem; }
.rl-cond:has(> :nth-child(4):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)) 30px; }
.rl-summary p { font-size: 0.92rem; line-height: 1.5; padding: 10px 12px; border-radius: 8px; background: var(--fb-hover); }
@media (max-width: 700px) { .rl-cond, .rl-cond:has(> :nth-child(4):last-child) { grid-template-columns: minmax(0, 1fr) 30px; } .rl-cond > .form-control { grid-column: 1; } .rl-cond > .fb-icon-btn { grid-column: 2; grid-row: 1; } }
.fb-field.fb-theme-color { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; margin-bottom: 8px; }
.fb-field.fb-theme-color > label { margin: 0; font-weight: 500; font-size: 0.85rem; cursor: pointer; }
.fb-theme-color input[type="color"] { width: 34px; height: 28px; padding: 2px; border: 1px solid var(--fb-line); border-radius: 6px; background: var(--fb-panel); cursor: pointer; }
.fb-theme-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.fb-theme-color input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 3px; }
.fb-theme-color input[type="color"]:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 1px; }
.fb-theme-color code { font: 500 0.78rem ui-monospace, 'SF Mono', Menlo, Consolas, monospace; color: var(--fb-muted); }
.fb-warn { font-size: 0.75rem; color: var(--error); margin-top: 5px; font-weight: 500; }
.fb-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fb-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.form-control.fb-input { padding: 8px 11px; font-size: 0.875rem; background-color: var(--fb-field); border-color: var(--fb-line); color: var(--fb-text); box-shadow: none; border-radius: 8px; }
.form-control.fb-input:hover:not(:disabled) { border-color: var(--border-focus); }
.form-control.fb-input:focus { background-color: var(--fb-panel); border-color: var(--fb-accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18); }
textarea.form-control.fb-input { min-height: 72px; line-height: 1.5; }
.fb-input.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.8rem; }
input[type="color"].form-control.fb-input { height: 38px; padding: 3px; }
.fb-switch-row, .fb-field > label.fb-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; cursor: pointer; font-size: 0.85rem; font-weight: 500; margin-bottom: 0; }
.fb-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.fb-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.fb-switch span { position: absolute; inset: 0; border-radius: 20px; background: var(--fb-line); transition: background 0.2s; pointer-events: none; }
.fb-switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.2s; }
.fb-switch input:checked + span { background: var(--fb-accent); }
.fb-switch input:checked + span::after { transform: translateX(16px); }
.fb-switch input:focus-visible + span { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.fb-stepper { display: flex; align-items: stretch; border: 1px solid var(--fb-line); border-radius: 8px; overflow: hidden; background: var(--fb-field); }
.fb-stepper button { width: 32px; border: 0; background: transparent; color: var(--fb-muted); cursor: pointer; display: grid; place-items: center; }
.fb-stepper button:hover { background: var(--fb-hover); color: var(--fb-text); }
.fb-stepper .form-control.fb-input { border: 0; border-radius: 0; text-align: center; padding: 7px 0; min-width: 0; -moz-appearance: textfield; }
.fb-stepper input::-webkit-outer-spin-button, .fb-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fb-stepper-row { margin-bottom: 0; }
.fb-colheads { display: flex; flex-direction: column; gap: 6px; }
.fb-colhead-row, .fb-colhead-labels { display: grid; grid-template-columns: minmax(0, 1fr) 124px; gap: 6px; }
/* Column widths (layer side panel) */
.fb-width-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fb-chip { border: 1px solid var(--fb-border, #e2e8f0); background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 0.75rem; font-weight: 600; color: var(--fb-text, #0f172a); cursor: pointer; }
.fb-chip:hover { border-color: var(--fb-accent, #6366f1); }
.fb-chip[aria-pressed="true"] { background: var(--fb-accent-soft, #eef2ff); border-color: var(--fb-accent, #6366f1); color: var(--fb-accent-ink, #3730a3); }
.fb-colwidth-row { display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.8rem; color: var(--fb-muted, #64748b); }

/* New elements in the canvas and side panel */
.fb-image-empty { display: flex; align-items: center; gap: 10px; padding: 18px; border: 2px dashed var(--border-soft, #dbe2ea); border-radius: 10px; color: var(--placeholder, #94a3b8); font-size: 0.82rem; }
.fb-upload { cursor: pointer; justify-content: center; }
.fb-preset-pick { margin-top: 8px; color: var(--fb-muted, #64748b); }
.fb-rep-chip { color: var(--primary-hover); }
.fb-hint code { font-size: 0.75rem; background: rgba(99, 102, 241, 0.08); padding: 0 4px; border-radius: 4px; }
.fb-item-body .fb-signature-pad { pointer-events: none; }

/* Size box: number + px/% picker */
.fb-len { display: grid; grid-template-columns: minmax(48px, 1fr) 56px; gap: 4px; align-items: center; min-width: 0; }
.fb-len > select.fb-input { padding-left: 6px; padding-right: 4px; }
.fb-len > em { font-style: normal; font-size: 0.78rem; color: var(--fb-muted, #64748b); text-align: center; }
.te-num .fb-len { width: 150px; }
.te-colcard .fb-len { width: 100%; }
.te-rowh .fb-len { width: 120px; }
.fb-layout-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.fb-layout-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border: 1px solid var(--fb-line); border-radius: 9px; background: var(--fb-field); color: var(--fb-muted); font: inherit; font-size: 0.7rem; font-weight: 600; cursor: pointer; text-align: center; line-height: 1.2; }
.fb-layout-grid button svg { color: #a5b4fc; }
.fb-layout-grid button:hover { border-color: var(--border-focus); }
.fb-layout-grid button[aria-pressed="true"] { border-color: var(--fb-accent); background: var(--fb-accent-soft); color: var(--fb-accent-ink); }
.fb-layout-grid button[aria-pressed="true"] svg { color: var(--fb-accent); }
.fb-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 3px; border-radius: 9px; background: var(--fb-field); border: 1px solid var(--fb-line); }
.fb-seg button { font: inherit; font-size: 0.8rem; font-weight: 600; height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--fb-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.fb-seg button[aria-pressed="true"] { background: var(--fb-panel); color: var(--fb-text); box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 0 0 1px var(--fb-line); }
.fb-seg-sm button { height: 26px; font-size: 0.75rem; padding: 0 8px; }
.fb-insp-foot { display: flex; gap: 8px; padding: 16px; }
.fb-insp-foot .fb-btn { flex: 1; justify-content: center; }
.fb-back { display: none; }

/* Toast action (Undo) */
.fb-toast-action { font: inherit; font-size: 0.85rem; font-weight: 700; color: var(--primary-hover); background: var(--primary-light); border: 0; border-radius: 6px; padding: 5px 10px; margin-left: 12px; cursor: pointer; }

/* Modals */
.fb-modal { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 24px; background: rgba(2, 6, 23, 0.55); backdrop-filter: blur(3px); }
.fb-modal[hidden] { display: none; }
.fb-dialog { width: min(1180px, 100%); height: min(880px, 100%); display: flex; flex-direction: column; background: var(--fb-panel); color: var(--fb-text); border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5); border: 1px solid var(--fb-line); animation: fbPop 0.18s ease-out; }
@keyframes fbPop { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.fb-dialog-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--fb-line); }
.fb-dialog-head h2 { font-size: 1rem; font-weight: 700; }
.fb-dialog-head p { font-size: 0.8rem; color: var(--fb-muted); }
.fb-dialog-body { flex: 1; min-height: 0; position: relative; }
.fb-preview-stage { height: 100%; overflow: auto; background: var(--fb-canvas); display: flex; justify-content: center; }
.fb-preview-stage iframe { width: 100%; height: 100%; border: 0; background: #f8fafc; }
.fb-preview-stage.mobile { padding: 20px 0; }
.fb-preview-stage.mobile iframe { width: 390px; border-radius: 16px; border: 1px solid var(--fb-line); box-shadow: var(--shadow-lg); }

/* Table editor: settings sidebar on the left, the grid gets the full height */
.te-body { display: grid; grid-template-columns: 252px minmax(0, 1fr); overflow: hidden; }
.te-toolbar { overflow-y: auto; border-right: 1px solid var(--fb-line); background: var(--fb-panel); }
.te-toolbar section { padding: 14px 16px; border-bottom: 1px solid var(--fb-line); }
.te-toolbar section:last-child { border-bottom: 0; }
.te-toolbar h4 { font-size: 0.75rem; font-weight: 600; color: var(--fb-muted); margin-bottom: 10px; }
.te-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.te-note { font-size: 0.72rem; color: var(--fb-muted); margin-top: 8px; line-height: 1.45; }
.te-align { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.72rem; color: var(--fb-muted); }
.te-num, .te-labeled, .te-color { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; font-weight: 600; }
.te-num-in, .te-width { display: flex; align-items: center; gap: 4px; }
.te-num-in .fb-input { width: 76px; }
.te-num .fb-stepper { width: 104px; }
.te-num em, .te-width em { font-style: normal; font-size: 0.72rem; color: var(--fb-muted); }
.te-color input { width: 48px; height: 34px; border: 1px solid var(--fb-line); border-radius: 7px; padding: 2px; background: var(--fb-field); cursor: pointer; }
.te-sw { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 500; cursor: pointer; min-height: 30px; width: 100%; }
.te-sw-sm { min-height: 26px; font-size: 0.75rem; width: auto; }
.te-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.te-grid-wrap { flex: 1; min-height: 200px; overflow: auto; background: var(--fb-canvas); }
.te-grid { border-collapse: separate; border-spacing: 0; font-size: 0.8rem; }
.te-grid th, .te-grid td { border-right: 1px solid var(--fb-line); border-bottom: 1px solid var(--fb-line); background: var(--fb-panel); vertical-align: top; }
.te-grid thead th { position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 500; }
.te-grid tbody th { position: sticky; left: 0; z-index: 1; }
.te-grid thead th.te-corner { left: 0; z-index: 3; }
.te-corner { min-width: 120px; padding: 10px; color: var(--fb-muted); font-size: 0.72rem; }
.te-corner span { display: block; }
.te-colcard { min-width: 224px; padding: 10px; }
.te-colcard-in { display: flex; flex-direction: column; gap: 6px; }
.te-colbar { display: flex; align-items: center; gap: 2px; }
.te-colnum { flex: 1; font-size: 0.72rem; font-weight: 700; color: var(--fb-accent-ink); }
.te-colbar button, .te-rowbtns button { width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--fb-muted); cursor: pointer; }
.te-colbar button:hover, .te-rowbtns button:hover { background: var(--fb-hover); color: var(--fb-text); }
.te-colbar button.del:hover, .te-rowbtns button.del:hover { background: var(--error-light); color: var(--error); }
.te-colbar button:disabled, .te-rowbtns button:disabled { opacity: 0.3; cursor: default; background: transparent; }
.te-head-input { font-weight: 600; }
.te-two { display: grid; grid-template-columns: minmax(0, 1fr) 80px; gap: 6px; }
.te-width .fb-input { width: 100%; min-width: 0; }
.te-key { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; color: var(--fb-muted); }
.te-key .fb-input { padding: 4px 8px; font-size: 0.75rem; }
.te-rowhead { padding: 8px 10px; min-width: 128px; }
.te-rownum { display: block; font-weight: 700; font-size: 0.72rem; color: var(--fb-accent-ink); margin-bottom: 4px; }
.te-rowh { margin-bottom: 4px; }
.te-rowh .fb-input { width: 70px; padding: 5px 8px; }
.te-rowbtns { display: flex; gap: 2px; }
.te-grid td { padding: 8px; min-width: 120px; vertical-align: middle; }
.te-grid td .fb-input { padding: 6px 9px; }
.te-fixed { font-weight: 600; }
.te-cell-check { width: 18px; height: 18px; accent-color: var(--fb-accent); }
.te-grid td.te-pad { background: transparent; border: 0; min-width: 60px; }
.te-addcol { background: transparent !important; border: 0 !important; padding: 10px; vertical-align: middle !important; }
.te-addcol button, .te-addrow button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px dashed var(--border-focus); border-radius: 8px; background: var(--fb-panel); color: var(--fb-accent-ink); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.te-addcol button:hover, .te-addrow button:hover { border-style: solid; background: var(--fb-accent-soft); }
.te-addrow { padding: 10px; background: var(--fb-canvas) !important; border: 0 !important; }
.te-preview { flex-shrink: 0; max-height: 32%; overflow: auto; padding: 10px 18px 14px; border-top: 1px solid var(--fb-line); background: var(--fb-canvas); }
.te-preview summary { font-size: 0.78rem; font-weight: 600; color: var(--fb-muted); cursor: pointer; padding: 2px 0; }
.te-preview[open] summary { margin-bottom: 8px; }
.te-preview-body { background: #fff; color: var(--text-main); border-radius: 10px; padding: 16px; color-scheme: light; }
.te-preview-body .form-group { margin-bottom: 0; }

/* Mobile */
.fb-tabs { display: none; }
@media (max-width: 1180px) { .fb-main { grid-template-columns: 236px minmax(0, 1fr) 300px; } .fb-doc-title { max-width: 18ch; } }
@media (max-width: 1000px) { .fb-btn .lbl { display: none; } .fb-btn { padding: 0 10px; } .fb-btn.primary .lbl { display: inline; } .fb-doc-title { display: none; } }
@media (max-width: 860px) {
    .fb-main { display: block; position: relative; }
    .fb-main > * { position: absolute; inset: 0; display: none; }
    .fb-main[data-panel="tools"] .fb-toolbox, .fb-main[data-panel="canvas"] .fb-canvas, .fb-main[data-panel="props"] .fb-inspector { display: block; }
    .fb-toolbox, .fb-inspector { border: 0; }
    .fb-canvas { padding: 16px 10px 40px; }
    .fb-paper .form-header { padding: 22px; }
    .fb-paper .form-body { padding: 12px 10px 18px; }
    .fb-layer-body { padding: 12px 8px; }
    .fb-tabs { display: grid; grid-template-columns: repeat(3, 1fr); flex-shrink: 0; border-top: 1px solid var(--fb-line); background: var(--fb-panel); padding-bottom: env(safe-area-inset-bottom, 0px); }
    .fb-tabs button { font: inherit; font-size: 0.78rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 10px; border: 0; background: none; color: var(--fb-muted); cursor: pointer; }
    .fb-tabs button[aria-selected="true"] { color: var(--fb-accent); }
    .fb-back { display: inline-flex; }
    .fb-sep, #redoBtn, .fb-back-link .lbl { display: none; }
    .fb-modal { padding: 0; }
    .fb-dialog { border-radius: 0; height: 100%; }
    .fb-item-bar, .fb-layer-bar { opacity: 1; pointer-events: auto; }
    .fb-preview-seg { display: none; }
    .te-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 38%) minmax(0, 1fr); }
    .te-toolbar { border-right: 0; border-bottom: 1px solid var(--fb-line); }
}
@media (max-width: 560px) {
    .fb-topbar { gap: 6px; padding: 0 8px; }
    .fb-btn.primary .lbl, #undoBtn, .fb-status-text { display: none; }
    .fb-list-actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .fb-dialog { animation: none; } .fb-item, .fb-item-tag, .fb-item-bar, .fb-layer { transition: none; } .fb-status.is-saving .fb-status-dot { animation: none; } }

/* ---------- Left panel tabs: Fields / Outline ---------- */
.fb-left-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 12px 14px 0; padding: 3px; border-radius: 9px; background: var(--fb-field); border: 1px solid var(--fb-line); }
.fb-left-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border: 0; border-radius: 6px; background: transparent; font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--fb-muted); cursor: pointer; }
.fb-left-tabs button[aria-selected="true"] { background: var(--fb-panel); color: var(--fb-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--fb-line); }
.fb-left-tabs button:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 1px; }
.fb-pane-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fb-paste-btn { height: 28px; padding: 0 10px; font-size: 0.78rem; color: var(--fb-accent-ink); border-color: var(--fb-accent); background: var(--fb-accent-soft); }

/* ---------- Outline tree ---------- */
.fb-outline { padding: 4px 8px 24px; }
.fb-outline ul { list-style: none; margin: 0; padding: 0; }
.fb-ol-row { position: relative; display: flex; align-items: center; gap: 2px; min-height: 30px; padding-left: calc(var(--d, 0) * 14px); border-radius: 7px; }
.fb-ol-row:hover { background: var(--fb-hover); }
.fb-ol-row.is-selected { background: var(--fb-accent-soft); }
.fb-ol-row.is-selected .fb-ol-text { color: var(--fb-accent-ink); font-weight: 600; }
.fb-ol-toggle { flex: 0 0 18px; width: 18px; height: 22px; display: grid; place-items: center; border: 0; background: none; color: var(--fb-muted); cursor: pointer; padding: 0; border-radius: 4px; }
.fb-ol-toggle svg { transition: transform 0.12s; }
.fb-ol-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.fb-ol-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 4px; border: 0; background: none; font: inherit; font-size: 0.8rem; color: var(--fb-text); text-align: left; cursor: pointer; border-radius: 6px; }
.fb-ol-main:focus-visible, .fb-ol-acts button:focus-visible, .fb-ol-toggle:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: -2px; }
.fb-ol-icon { display: grid; place-items: center; color: var(--fb-muted); flex-shrink: 0; }
.fb-ol-icon .fb-layout-icon rect { fill: currentColor; }
.fb-ol-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-ol-sub { margin-left: auto; padding-left: 6px; font-size: 0.7rem; color: var(--fb-muted); white-space: nowrap; }
.fb-ol-row.is-page .fb-ol-text { font-weight: 700; }
.fb-ol-row.is-layer .fb-ol-text { font-weight: 600; }
.fb-ol-acts { display: flex; gap: 1px; opacity: 0; transition: opacity 0.12s; }
.fb-ol-row:hover .fb-ol-acts, .fb-ol-row:focus-within .fb-ol-acts, .fb-ol-row.is-selected .fb-ol-acts { opacity: 1; }
.fb-ol-row:hover .fb-ol-sub, .fb-ol-row:focus-within .fb-ol-sub, .fb-ol-row.is-selected .fb-ol-sub { display: none; }
.fb-ol-acts button { width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 5px; background: none; color: var(--fb-muted); cursor: pointer; }
.fb-ol-acts button:hover:not(:disabled) { background: var(--fb-panel); color: var(--fb-text); }
.fb-ol-acts button:disabled { opacity: 0.3; cursor: default; }
.fb-ol-col > span { display: block; padding: 4px 0 2px calc(var(--d, 0) * 14px + 22px); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fb-muted); }
.fb-ol-empty { padding: 6px 12px 10px 34px; font-size: 0.78rem; color: var(--fb-muted); }

/* ---------- History dialog ---------- */
/* Form check (top bar → Check) */
.fb-check-btn { position: relative; }
.fb-check-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px; border-radius: 999px; font-size: 0.7rem; font-weight: 800; color: #fff; background: #d97706; }
.fb-check-badge[hidden] { display: none; }
.fb-check-btn.has-errors .fb-check-badge { background: #dc2626; }
.fb-check-btn.has-errors [data-icon] { color: #dc2626; }
.fb-check-btn.is-clean [data-icon] { color: #16a34a; }
.fb-dialog-check { width: min(720px, 96vw); height: auto; max-height: min(820px, 100%); }
.fb-dialog-check .fb-dialog-body { overflow-y: auto; padding: 16px 20px 20px; }
.fb-check-group + .fb-check-group { margin-top: 18px; }
.fb-check-group h3 { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 700; }
.fb-check-group h3 span { min-width: 20px; height: 20px; display: inline-grid; place-items: center; padding: 0 6px; border-radius: 999px; font-size: 0.72rem; color: #fff; }
.fb-check-group > p { font-size: 0.8rem; color: var(--fb-muted); margin: 2px 0 8px; }
.fb-check-group ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--fb-line); border-radius: 10px; overflow: hidden; }
.fb-check-group li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 0.85rem; color: var(--fb-text); }
.fb-check-group li + li { border-top: 1px solid var(--fb-line); }
.fb-check-group li .fb-btn { height: 30px; padding: 0 10px; font-size: 0.8rem; margin-left: auto; flex: none; }
.fb-check-text { flex: 1; min-width: 0; line-height: 1.4; }
.fb-check-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; }
.fb-check-group.is-error h3 span, .fb-check-group.is-error .fb-check-dot { background: #dc2626; }
.fb-check-group.is-warn h3 span, .fb-check-group.is-warn .fb-check-dot { background: #d97706; }
.fb-check-group.is-info h3 span, .fb-check-group.is-info .fb-check-dot { background: #64748b; }
.fb-check-ok { text-align: center; padding: 28px 16px 20px; color: var(--fb-muted); }
.fb-check-ok svg { color: #16a34a; margin-bottom: 8px; }
.fb-check-ok h3 { font-size: 1.05rem; color: var(--fb-text); margin-bottom: 4px; }
.fb-check-ok p { font-size: 0.85rem; max-width: 46ch; margin: 0 auto; }
/* Section numbers on the canvas (Form settings → Numbering) */
.fb-sec-num { margin-right: 0.5em; font-variant-numeric: tabular-nums; opacity: 0.75; }
/* Form settings → Word & PDF page */
.fb-insp-sub { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--fb-muted); margin: 14px 0 8px; }
.fb-doc-logo { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--fb-line); border-radius: 8px; background: var(--fb-field); }
.fb-doc-logo img { max-height: 40px; max-width: 150px; object-fit: contain; background: #fff; border-radius: 4px; }
.fb-doc-logo .fb-btn { margin-left: auto; height: 30px; font-size: 0.8rem; }
.fb-doc-logo-pick { cursor: pointer; margin-top: 0; }
.fb-dialog-history { width: min(720px, 96vw); height: auto; max-height: min(880px, 100%); }
.fb-dialog-history .fb-dialog-body { overflow-y: auto; min-height: 120px; }
.fb-history-note { padding: 24px; text-align: center; color: var(--fb-muted); font-size: 0.9rem; }
.fb-history-note.is-error { color: var(--error); }
.fb-history { list-style: none; margin: 0; padding: 4px 18px 18px; }
.fb-history-day { position: sticky; top: 0; z-index: 1; padding: 12px 4px 6px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fb-muted); background: var(--fb-panel); }
.fb-history-item { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--fb-line); border-radius: 10px; margin-bottom: 8px; }
.fb-history-item.is-current { border-color: var(--fb-accent); background: color-mix(in srgb, var(--fb-accent) 4%, var(--fb-panel)); }
.fb-history-time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.fb-history-time strong { font-size: 0.95rem; color: var(--fb-text); }
.fb-history-time span { font-size: 0.72rem; color: var(--fb-muted); }
.fb-history-what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fb-history-reason { align-self: flex-start; font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--fb-hover); color: var(--fb-muted); }
.fb-history-reason.is-manual, .fb-history-reason.is-created { background: var(--fb-accent-soft); color: var(--fb-accent-ink); }
.fb-history-reason.is-restored { background: #dcfce7; color: #166534; }
.fb-history-reason.is-before-restore { background: #fef3c7; color: #92400e; }
.fb-history-title { font-weight: 600; font-size: 0.88rem; color: var(--fb-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-history-meta { font-size: 0.76rem; color: var(--fb-muted); }
.fb-history-acts { display: flex; gap: 6px; align-items: center; }
.fb-history-acts .fb-btn { height: 32px; font-size: 0.8rem; }
.fb-history-cur { font-size: 0.75rem; font-weight: 700; color: var(--fb-accent-ink); padding: 0 8px; }
@media (max-width: 600px) { .fb-history-item { grid-template-columns: 1fr; } }
