/* ============================================================
   WhatsApp Flows Studio — design system
   A calm, WhatsApp-native editor: deep teal + vivid green,
   soft rounded surfaces, gentle depth, a realistic device.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,600;12..96,700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

.waf-app {
    --teal: #075e54;
    --teal-700: #0a7163;
    --green: #25d366;
    --green-600: #1ebe5d;
    --green-700: #14a44d;
    --ink: #0c211d;
    --muted: #6b7c79;
    --faint: #9aa8a4;
    --line: #e7edea;
    --line-strong: #d6e0dc;
    --surface: #ffffff;
    --surface-2: #f7faf9;
    --canvas: #eef3f1;
    --danger: #d1453b;
    --amber: #d98a00;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --r-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(10, 40, 35, .06), 0 1px 3px rgba(10, 40, 35, .04);
    --shadow-md: 0 4px 14px rgba(10, 40, 35, .08);
    --shadow-lg: 0 18px 50px rgba(10, 40, 35, .18);

    --font-display: "Bricolage Grotesque", system-ui, sans-serif;
    --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

    font-family: var(--font-ui);
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;

    display: flex;
    flex-direction: column;
    height: calc(100vh - 168px);
    min-height: 540px;
}

.waf-app *,
.waf-app *::before,
.waf-app *::after { box-sizing: border-box; }

/* ---------------- Toolbar ---------------- */
.waf-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.waf-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.01em;
    color: var(--teal);
    padding-right: 14px;
    border-right: 1px solid var(--line);
}
.waf-brand-mark {
    width: 26px; height: 26px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: linear-gradient(145deg, var(--green) 0%, var(--teal) 120%);
    color: #fff; font-size: 14px;
    box-shadow: var(--shadow-sm);
}
.waf-name-input {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    color: var(--ink);
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--r-sm);
    padding: 6px 10px;
    min-width: 220px;
    transition: background .15s, border-color .15s;
}
.waf-name-input:hover { background: var(--surface-2); }
.waf-name-input:focus { outline: none; background: var(--surface-2); border-color: var(--line-strong); }

.waf-toolbar-spacer { flex: 1; }

.waf-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 600;
    padding: 6px 12px; border-radius: var(--r-pill);
    cursor: default;
}
.waf-pill-ok { color: var(--green-700); background: rgba(37, 211, 102, .12); }
.waf-pill-warn { color: var(--amber); background: rgba(217, 138, 0, .12); cursor: pointer; }
.waf-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.waf-btn {
    font-family: var(--font-ui);
    font-weight: 600; font-size: 14px;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    padding: 9px 18px;
    cursor: pointer;
    transition: transform .08s, box-shadow .15s, background .15s, opacity .15s;
    display: inline-flex; align-items: center; gap: 7px;
}
.waf-btn:active { transform: translateY(1px); }
.waf-btn:disabled { opacity: .5; cursor: not-allowed; }
.waf-btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.waf-btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.waf-btn-primary { background: var(--green); color: #04231a; box-shadow: 0 2px 8px rgba(37, 211, 102, .35); }
.waf-btn-primary:hover:not(:disabled) { background: var(--green-600); }

/* ---------------- Onboarding mode switch ---------------- */
/* A behavior toggle, not a checkbox: on submit an onboarding flow writes the
   contact's details, marks them onboarded, and syncs to the user list. Off = a
   quiet ghost chip; on = the brand green used by Publish and the "ready" pill. */
.waf-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    padding: 7px 8px 7px 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}
.waf-mode-toggle:hover:not(.is-on) { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
.waf-mode-toggle:focus-visible {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(7, 94, 84, .18);
}
.waf-mode-toggle.is-on {
    color: var(--green-700);
    background: rgba(37, 211, 102, .12);
    border-color: rgba(37, 211, 102, .38);
}

.waf-mode-icon { font-size: 13px; width: 14px; text-align: center; transition: color .15s; }

.waf-mode-label { letter-spacing: -.005em; }

/* The switch: track + sliding knob. This is the state affordance. */
.waf-mode-switch {
    position: relative;
    flex: none;
    width: 34px;
    height: 20px;
    border-radius: var(--r-pill);
    background: var(--line-strong);
    transition: background .18s;
}
.waf-mode-toggle.is-on .waf-mode-switch { background: var(--green); }
.waf-mode-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform .18s cubic-bezier(.34, 1.35, .5, 1);
}
.waf-mode-toggle.is-on .waf-mode-knob { transform: translateX(14px); }

@media (prefers-reduced-motion: reduce) {
    .waf-mode-knob { transition: none; }
}

/* ---------------- Problems strip ---------------- */
.waf-problems {
    background: #fff8ec;
    border-bottom: 1px solid #f1e2c4;
    padding: 8px 18px;
    display: flex; flex-direction: column; gap: 4px;
}
.waf-problem {
    font-size: 12.5px; color: #8a5a00;
    display: inline-flex; align-items: center; gap: 6px;
    cursor: default;
}
.waf-problem.clickable { cursor: pointer; }
.waf-problem.clickable:hover { text-decoration: underline; }
.waf-problem::before { content: "▸"; color: var(--amber); font-size: 10px; }

/* ---------------- Screen tabs ----------------
   One tab per screen, replacing the old left-hand Screens panel. The active
   screen's id / final toggle / delete live on the right of the same strip. */
.waf-tabs {
    display: flex; align-items: center; gap: 16px;
    flex-wrap: wrap; row-gap: 10px;
    flex: none;
    padding: 10px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.waf-tabs-strip {
    display: flex; align-items: center; gap: 8px;
    flex: 1 1 320px; min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 2px;
}
.waf-tab {
    display: inline-flex; align-items: center; gap: 9px;
    flex: 0 0 auto; max-width: 240px;
    padding: 7px 13px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.waf-tab:hover:not(.active) { border-color: var(--line-strong); background: #fff; }
.waf-tab.active {
    background: var(--surface);
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, .14);
}
.waf-tab-num {
    width: 20px; height: 20px; flex: none;
    display: grid; place-items: center; border-radius: 50%;
    font-size: 11px; font-weight: 700;
    color: var(--muted); background: var(--surface); border: 1px solid var(--line);
}
.waf-tab.active .waf-tab-num { color: #04231a; background: var(--green); border-color: var(--green); }
.waf-tab-label {
    font-weight: 600; font-size: 13.5px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.waf-tab-input {
    font-family: var(--font-ui); font-weight: 600; font-size: 13.5px;
    color: var(--ink); border: none; background: transparent;
    padding: 0; width: 130px; outline: none;
}
.waf-tab-end {
    font-size: 9.5px; font-weight: 700; letter-spacing: .05em; flex: none;
    color: var(--teal); background: rgba(7, 94, 84, .1);
    border-radius: var(--r-pill); padding: 1px 7px;
}
.waf-tab-add {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--font-ui); font-weight: 600; font-size: 13px;
    color: var(--teal); background: transparent;
    border: 1.5px dashed var(--line-strong); border-radius: var(--r-pill);
    padding: 6px 14px; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.waf-tab-add:hover { border-color: var(--green); background: rgba(37, 211, 102, .06); }

.waf-tab-meta {
    display: flex; align-items: center; gap: 14px; flex: none;
    padding-left: 16px; border-left: 1px solid var(--line);
}
.waf-tab-meta-id {
    font-size: 11px; color: var(--faint); letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.waf-tab-final {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12.5px; font-weight: 600; color: var(--muted);
    cursor: pointer; user-select: none; white-space: nowrap;
}
.waf-tab-final input { width: 16px; height: 16px; accent-color: var(--green); }
.waf-tab-del {
    border: 1px solid var(--line-strong); background: var(--surface);
    color: var(--muted); width: 32px; height: 32px; border-radius: var(--r-sm);
    cursor: pointer; display: grid; place-items: center; font-size: 13px; flex: none;
    transition: border-color .12s, color .12s, background .12s;
}
.waf-tab-del:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); background: rgba(209, 69, 59, .06); }
.waf-tab-del:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- Workspace layout ---------------- */
.waf-root {
    display: flex;
    flex: 1;
    min-height: 0;
    background: var(--canvas);
}
.waf-screens { width: 248px; flex: none; }
.waf-builder { flex: 1; display: flex; min-width: 0; }
.waf-editor { flex: 1; min-width: 0; }
.waf-config { width: 340px; flex: none; }
.waf-preview {
    width: 400px; flex: none;
    background:
        radial-gradient(120% 80% at 50% -10%, #f3f9f6 0%, var(--canvas) 60%),
        var(--canvas);
    display: flex; align-items: center; justify-content: center;
    border-left: 1px solid var(--line);
    padding: 22px 16px;
    min-height: 0; min-width: 0;
    overflow: hidden;
}

/* ---------------- Panel chrome ---------------- */
.waf-panel { display: flex; flex-direction: column; height: 100%; background: var(--surface); border-right: 1px solid var(--line); }
.waf-screens .waf-panel { background: var(--surface-2); }
.waf-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px 10px;
    padding: 14px 16px 10px;
    position: sticky; top: 0; z-index: 2;
    background: inherit;
}
.waf-panel-title {
    font-family: var(--font-display);
    font-weight: 700; font-size: 12px;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--faint);
    display: flex; align-items: center; gap: 8px;
    min-width: 0; flex: 0 1 auto;
}
.waf-panel-count {
    font-size: 11px; font-weight: 700;
    color: var(--muted); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-pill);
    padding: 1px 8px;
}
.waf-screens .waf-panel-count { background: #fff; }
.waf-panel-body { flex: 1; overflow-y: auto; padding: 4px 14px 18px; }

/* ---------------- Screens ---------------- */
.waf-add-screen {
    width: 100%; margin: 0 0 12px;
    border: 1.5px dashed var(--line-strong);
    background: var(--surface);
    color: var(--teal); font-weight: 600; font-size: 13.5px;
    border-radius: var(--r-md); padding: 11px;
    cursor: pointer; transition: border-color .15s, background .15s;
    display: flex; align-items: center; justify-content: center; gap: 7px;
}
.waf-add-screen:hover { border-color: var(--green); background: rgba(37, 211, 102, .06); }

.waf-screen-item {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    padding: 10px 10px 10px 14px;
    margin-bottom: 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .08s;
}
.waf-screen-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.waf-screen-item.active {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, .14);
}
.waf-screen-item.active::before {
    content: ""; position: absolute; left: 0; top: 10px; bottom: 10px;
    width: 3px; border-radius: 3px; background: var(--green);
}
.waf-screen-grip { color: var(--faint); font-size: 13px; cursor: grab; }
.waf-screen-main { flex: 1; min-width: 0; }
.waf-screen-title-input {
    border: none; background: transparent; width: 100%;
    font-weight: 600; font-size: 14px; color: var(--ink); padding: 0;
}
.waf-screen-title-input:focus { outline: none; }
.waf-screen-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.waf-screen-id { font-size: 10.5px; color: var(--faint); letter-spacing: .02em; }
.waf-term-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10.5px; font-weight: 600; color: var(--muted);
    cursor: pointer; user-select: none;
}
.waf-term-toggle input { accent-color: var(--green); }
.waf-term-badge {
    font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
    color: var(--teal); background: rgba(7, 94, 84, .1);
    border-radius: var(--r-pill); padding: 1px 7px;
}
.waf-icon-btn {
    border: none; background: transparent; color: var(--faint);
    width: 26px; height: 26px; border-radius: 7px;
    cursor: pointer; font-size: 13px; line-height: 1;
    display: grid; place-items: center;
    transition: background .12s, color .12s; opacity: 0;
}
.waf-screen-item:hover .waf-icon-btn,
.waf-comp-item:hover .waf-icon-btn { opacity: 1; }
.waf-icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.waf-icon-btn.danger:hover { background: rgba(209, 69, 59, .1); color: var(--danger); }
.waf-icon-btn:disabled { opacity: .25; cursor: default; }

/* ---------------- Component editor ---------------- */
.waf-section-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--faint);
    margin: 14px 2px 8px;
}
.waf-palette {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 6px 8px; margin-bottom: 6px;
}
.waf-palette-group { border-radius: var(--r-sm); }
.waf-palette-summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    padding: 7px 4px; font-weight: 600; font-size: 13px; color: var(--ink);
}
.waf-palette-summary::-webkit-details-marker { display: none; }
.waf-palette-summary::after {
    content: "⌄"; margin-left: auto; color: var(--faint);
    transition: transform .15s; font-size: 14px;
}
details[open] .waf-palette-summary::after { transform: rotate(180deg); }
.waf-cat-dot { width: 8px; height: 8px; border-radius: 50%; }
.waf-cat-text .waf-cat-dot, .waf-chip.waf-cat-text::before { background: #6366f1; }
.waf-cat-input .waf-cat-dot, .waf-chip.waf-cat-input::before { background: #0ea5e9; }
.waf-cat-selection .waf-cat-dot, .waf-chip.waf-cat-selection::before { background: #f59e0b; }
.waf-cat-media .waf-cat-dot, .waf-chip.waf-cat-media::before { background: #ec4899; }
.waf-cat-navigation .waf-cat-dot, .waf-chip.waf-cat-navigation::before { background: #10b981; }

.waf-chip-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 8px 16px; }
.waf-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 600; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-pill); padding: 6px 12px; cursor: pointer;
    transition: border-color .12s, background .12s, transform .08s;
}
.waf-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.waf-chip:hover { border-color: var(--green); background: rgba(37, 211, 102, .07); }
.waf-chip:active { transform: scale(.97); }

/* ---------------- Add-component dropdown ----------------
   Component selection lives in a header dropdown so the panel body below is
   dedicated to the screen's layout (the placed components). */
.waf-adder { position: relative; flex: none; }
.waf-add-comp-btn {
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--font-ui); font-weight: 600; font-size: 12.5px;
    color: #fff; background: var(--green-700);
    border: none; border-radius: var(--r-pill);
    padding: 7px 13px; cursor: pointer; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(20, 164, 77, .28);
    transition: background .15s, transform .08s, box-shadow .15s;
}
.waf-add-comp-btn:hover { background: var(--green-600); box-shadow: 0 3px 12px rgba(20, 164, 77, .34); }
.waf-add-comp-btn:active { transform: translateY(1px); }
.waf-add-comp-caret { font-size: 9px; opacity: .85; transition: transform .18s; }
.waf-adder.open .waf-add-comp-caret { transform: rotate(180deg); }

.waf-adder-backdrop { position: fixed; inset: 0; z-index: 40; }
.waf-adder-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 41;
    width: 300px; max-width: 78vw;
    max-height: min(60vh, 460px); overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: 10px 12px 8px;
    transform-origin: top right;
    animation: waf-adder-pop .15s ease-out;
}
@keyframes waf-adder-pop {
    from { opacity: 0; transform: translateY(-6px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.waf-adder-menu-head {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--faint); padding: 2px 2px 8px;
}
.waf-adder-group { padding: 2px 0; }
.waf-adder-group + .waf-adder-group { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.waf-adder-group-label {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 12.5px; color: var(--ink);
    padding: 4px 2px 2px;
}
.waf-adder-menu .waf-chip-row { padding: 4px 0 2px 16px; }

.waf-layout-list { margin-top: 4px; }
.waf-comp-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 8px 10px 12px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.waf-comp-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.waf-comp-item.active { border-color: var(--green); box-shadow: 0 0 0 3px rgba(37, 211, 102, .14); }
.waf-comp-grip { color: var(--faint); cursor: grab; font-size: 13px; }
.waf-comp-main { flex: 1; min-width: 0; }
.waf-comp-label { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.waf-comp-type { font-size: 10.5px; color: var(--faint); }
.waf-comp-actions { display: flex; align-items: center; gap: 1px; }

/* ---------------- Empty states ---------------- */
.waf-empty {
    text-align: center; color: var(--muted);
    padding: 34px 18px; border: 1.5px dashed var(--line-strong);
    border-radius: var(--r-md); background: var(--surface-2); margin-top: 8px;
}
.waf-empty-icon { font-size: 26px; margin-bottom: 8px; opacity: .55; }
.waf-empty-title { font-weight: 600; color: var(--ink); font-size: 14px; margin-bottom: 3px; }
.waf-empty-sub { font-size: 12.5px; }

/* ---------------- Config form ---------------- */
.waf-config-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px 12px; border-bottom: 1px solid var(--line);
}
.waf-config-badge {
    width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center; color: #fff; font-size: 13px;
    background: linear-gradient(145deg, var(--green), var(--teal));
    flex: none;
}
.waf-config-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.waf-config-kind { font-size: 11px; color: var(--faint); }

.waf-field { margin: 0 0 14px; }
.waf-field-label {
    display: block; font-size: 12.5px; font-weight: 600;
    color: var(--ink); margin-bottom: 5px;
}
.waf-field-label .req { color: var(--danger); margin-left: 2px; }
.waf-field-info {
    margin-left: 5px; color: var(--faint); cursor: help;
    font-size: 11px; font-style: normal;
}
.waf-field-info:hover { color: var(--teal); }
.waf-input, .waf-select, .waf-textarea {
    width: 100%; font-family: var(--font-ui); font-size: 13.5px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: var(--r-sm); padding: 9px 11px; transition: border-color .15s, box-shadow .15s;
}
.waf-input:focus, .waf-select:focus, .waf-textarea:focus {
    outline: none; border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, .14);
}
.waf-textarea { resize: vertical; min-height: 70px; }
.waf-field-hint { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.waf-check {
    display: flex; align-items: center; gap: 9px; font-size: 13.5px;
    color: var(--ink); cursor: pointer; padding: 7px 0;
}
.waf-check input { width: 17px; height: 17px; accent-color: var(--green); }

.waf-subhead {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--faint);
    margin: 16px 0 8px; padding-top: 14px; border-top: 1px solid var(--line);
}
.waf-option-card {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 10px; margin-bottom: 8px;
    display: flex; flex-direction: column; gap: 6px;
}
.waf-mini-btn {
    align-self: flex-start; border: none; background: transparent;
    color: var(--danger); font-size: 12px; font-weight: 600; cursor: pointer; padding: 2px 0;
}
.waf-add-option {
    width: 100%; border: 1.5px dashed var(--line-strong); background: var(--surface);
    color: var(--teal); font-weight: 600; font-size: 13px; border-radius: var(--r-sm);
    padding: 9px; cursor: pointer; transition: border-color .15s, background .15s;
}
.waf-add-option:hover { border-color: var(--green); background: rgba(37, 211, 102, .06); }

.waf-error {
    color: var(--danger); font-size: 12.5px;
    background: rgba(209, 69, 59, .08); border: 1px solid rgba(209, 69, 59, .2);
    border-radius: var(--r-sm); padding: 7px 10px; margin-top: 8px;
    display: flex; align-items: center; gap: 7px;
}
.waf-error::before { content: "!"; font-weight: 700; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: #fff; display: grid; place-items: center; font-size: 10px; flex: none; }

/* ---------------- Phone preview ---------------- */
.waf-stage {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 14px;
    height: 100%; width: 100%; min-height: 0;
}
.waf-stage-label {
    flex: none;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--faint);
}
/* The phone keeps its 312:640 aspect ratio but shrinks to fit the available
   height. Bezel + notch are sized as a share of the phone's width so the
   device still reads as a phone at any scale. */
.waf-phone {
    flex: 0 1 640px;
    min-height: 0;
    max-height: 640px;
    aspect-ratio: 312 / 640;
    width: auto; height: auto;
    background: #000;
    border-radius: 40px;
    padding: clamp(7px, 3.4%, 11px);
    box-shadow: var(--shadow-lg);
    position: relative;
}
.waf-phone::before {
    content: ""; position: absolute; top: clamp(10px, 2.5%, 16px); left: 50%; transform: translateX(-50%);
    width: 34%; height: clamp(16px, 4%, 26px); background: #000; border-radius: 0 0 16px 16px; z-index: 5;
}
.waf-phone-screen {
    width: 100%; height: 100%; background: #fff;
    border-radius: 31px; overflow: hidden;
    display: flex; flex-direction: column;
}
.waf-phone-statusbar {
    height: 30px; background: var(--teal); color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px; font-size: 11px; font-weight: 600;
}
.waf-phone-header {
    background: var(--teal); color: #fff;
    padding: 8px 16px 14px; display: flex; align-items: center; gap: 12px;
}
.waf-phone-close { font-size: 20px; line-height: 1; opacity: .9; }
.waf-phone-biz { display: flex; flex-direction: column; }
.waf-phone-title { font-weight: 600; font-size: 15px; }
.waf-phone-sub { font-size: 10.5px; opacity: .8; }
.waf-phone-body {
    flex: 1; overflow-y: auto; padding: 18px 16px; background: #fff;
}
.waf-phone-footer { padding: 12px 16px 16px; background: #fff; border-top: 1px solid #f0f0f0; }
.waf-btn-wapp, .waf-btn-primary.waf-btn-wapp {
    width: 100%; background: var(--green-700); color: #fff; border: none;
    border-radius: var(--r-pill); padding: 13px; font-weight: 700; font-size: 15px;
    font-family: var(--font-ui); cursor: default; box-shadow: none;
}

/* selectable component wrapper inside preview */
.waf-pv-item {
    border-radius: 8px; cursor: pointer; padding: 2px;
    transition: outline-color .12s, background .12s;
    outline: 2px solid transparent; outline-offset: 1px;
}
.waf-pv-item:hover { background: rgba(37, 211, 102, .05); }
.waf-pv-item.selected { outline-color: var(--green); background: rgba(37, 211, 102, .07); }

.waf-pv-empty { text-align: center; color: var(--faint); font-size: 13px; padding: 40px 16px; line-height: 1.6; }
.waf-pv-screen { display: flex; flex-direction: column; min-height: 100%; }
.waf-pv-content { flex: 1; }
.waf-pv-footer { margin-top: 18px; padding-top: 14px; border-top: 1px solid #f0f2f3; }
.waf-pv-footer.waf-pv-item:hover { background: rgba(37, 211, 102, .05); }

/* Preview component primitives */
.waf-p-heading { font-size: 19px; font-weight: 700; color: #111b21; margin: 6px 0; }
.waf-p-subheading { font-size: 15px; font-weight: 600; color: #111b21; margin: 6px 0; }
.waf-p-body { font-size: 14px; color: #3b4a54; margin: 6px 0; line-height: 1.45; }
.waf-p-caption { font-size: 12px; color: #667781; margin: 4px 0; }
.waf-p-label { font-size: 13px; color: #3b4a54; margin-bottom: 5px; display: block; font-weight: 500; }
.waf-p-field { width: 100%; border: none; border-bottom: 2px solid #d1d7db; padding: 9px 0; font-size: 14px; outline: none; background: transparent; color: #111b21; }
.waf-p-optionrow { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #f0f2f3; font-size: 14px; color: #111b21; }
.waf-p-image { max-width: 100%; border-radius: 10px; display: block; }
.waf-p-link { color: #027eb5; font-size: 14px; cursor: pointer; font-weight: 500; }

/* ---------------- Responsive layout ----------------
   The four-column workspace is fixed-width by design. As the window narrows
   we first trim the side columns (the editor flexes to absorb it), then fall
   back to a single scrolling column on tablet/phone widths so nothing clips
   off the right edge. */
@media (max-width: 1366px) {
    .waf-screens { width: 224px; }
    .waf-config  { width: 312px; }
    .waf-preview { width: 352px; }
}
@media (max-width: 1180px) {
    .waf-screens { width: 204px; }
    .waf-config  { width: 284px; }
    .waf-preview { width: 312px; padding: 18px 12px; }
}

@media (max-width: 960px) {
    .waf-app { height: auto; min-height: 0; }

    .waf-toolbar { flex-wrap: wrap; gap: 10px 12px; }
    .waf-name-input { flex: 1 1 160px; min-width: 0; }

    .waf-root { flex-direction: column; min-height: 0; }
    .waf-builder { flex-direction: column; }
    .waf-screens,
    .waf-builder,
    .waf-editor,
    .waf-config,
    .waf-preview { width: 100%; flex: none; }

    /* Let each region grow to its content and scroll the page instead. */
    .waf-root .waf-panel { height: auto; border-right: none; }
    .waf-root .waf-panel-body { overflow: visible; }
    .waf-screens .waf-panel,
    .waf-config .waf-panel { border-bottom: 1px solid var(--line); }

    .waf-preview {
        border-left: none;
        border-top: 1px solid var(--line);
        padding: 28px 16px;
        min-height: 560px;
    }
}

/* ---------------- Convert-to-message modal ---------------- */
.waf-modal-overlay {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(10, 33, 29, .42);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    animation: waf-fade-in .14s ease-out;
}
@keyframes waf-fade-in { from { opacity: 0; } to { opacity: 1; } }
.waf-modal {
    width: 440px; max-width: 100%;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    max-height: calc(100vh - 48px);
    overflow: hidden;
    animation: waf-adder-pop .16s ease-out;
}
.waf-modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.waf-modal-head .waf-icon-btn { opacity: 1; }
.waf-modal-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink); }
.waf-modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.waf-modal-body { padding: 16px 20px 6px; overflow-y: auto; }
.waf-modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 20px 18px; border-top: 1px solid var(--line);
}
