/* WhatsApp settings panel (wa-settings.js, sql/055 + sql/056): a large sheet
   from the right on a computer, the whole screen on a phone. Same palette,
   inputs and switches as Settings and the Forms editor (fm-in, fm-switch). */

body.wst-lock { overflow: hidden; }

.wst-overlay {
    position: fixed; inset: 0; z-index: 9999990;
    background: rgba(17, 24, 39, 0.42);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity 0.22s ease;
}
.wst-overlay.is-on { opacity: 1; pointer-events: auto; }

.wst-sheet {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 9999991;
    width: min(920px, calc(100vw - 48px));
    display: flex; flex-direction: column;
    background: var(--bg-page, #F8F9FC);
    box-shadow: -24px 0 60px rgba(17, 24, 39, 0.18);
    border-left: 1px solid var(--border-soft);
    font-family: var(--font-ui);
    color: var(--text-body);
    transform: translateX(104%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    visibility: hidden;
}
.wst-sheet.is-on { transform: translateX(0); visibility: visible; }
.wst-sheet *, .wst-sheet *::before, .wst-sheet *::after { box-sizing: border-box; }
.wst-sheet button { font-family: inherit; }

/* ── head ── */
.wst-head {
    display: flex; align-items: center; gap: 14px; flex: none;
    padding: 18px 24px; background: #fff; border-bottom: 1px solid var(--border-soft);
}
.wst-head-icon {
    flex: none; width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, #2BD96B 0%, #12A150 100%); color: #fff; font-size: 23px;
    box-shadow: 0 4px 12px rgba(18, 161, 80, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.wst-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wst-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; color: var(--text-strong); line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--text-muted); }
.wst-num { font-weight: 600; color: var(--text-body); letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.wst-pill {
    display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
    background: var(--bg-alt); border: 1px solid var(--border-soft);
    font-size: 11.5px; font-weight: 600; color: var(--text-muted);
}
.wst-pill.is-on { background: #E9F9EF; border-color: #BDEBCD; color: #11773C; }
.wst-pill.is-warn { background: #FFF6E5; border-color: #F8DDA6; color: #93520A; }
.wst-dot { width: 6px; height: 6px; border-radius: 50%; background: #16A34A; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }

.wst-icon-btn {
    flex: none; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-muted);
    font-size: 18px; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.wst-icon-btn:hover { background: var(--bg-alt); color: var(--text-strong); }
.wst-icon-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.wst-icon-btn.is-sm { width: 26px; height: 26px; font-size: 14px; border-radius: 7px; }
.wst-close { background: var(--bg-alt); }
.wst-close:hover { background: #E4E8F2; }

/* ── tabs ── */
.wst-tabs {
    display: flex; gap: 4px; flex: none; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--border-soft);
    overflow-x: auto; scrollbar-width: none;
}
.wst-tabs::-webkit-scrollbar { display: none; }
.wst-tabs[hidden] { display: none; }
.wst-tab {
    position: relative; display: inline-flex; align-items: center; gap: 8px; flex: none;
    height: 46px; padding: 0 12px; border: 0; background: none; cursor: pointer;
    font-size: 13.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap;
    transition: color 0.12s;
}
.wst-tab i { font-size: 16px; }
.wst-tab-short { display: none; }
.wst-tab:hover { color: var(--text-strong); }
.wst-tab.is-on { color: var(--blue); }
.wst-tab.is-on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--blue); }
.wst-tab:focus-visible { outline: 2px solid var(--blue); outline-offset: -4px; border-radius: 8px; }
.wst-count {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-alt); color: var(--text-muted); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.wst-tab.is-on .wst-count { background: var(--blue-wash); color: var(--blue); }

/* ── body ── */
.wst-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px 28px 32px; }
.wst-body > * + * { margin-top: 16px; }
.wst-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 64px 0; font-size: 13.5px; color: var(--text-muted); }
.wst-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-soft); border-top-color: var(--blue); animation: wst-spin 0.8s linear infinite; }
@keyframes wst-spin { to { transform: rotate(360deg); } }

.wst-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 16px; }
.wst-empty-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
    background: #fff; border: 1px solid var(--border-soft); color: var(--text-muted); font-size: 26px; box-shadow: 0 1px 2px rgba(33, 37, 49, 0.05); }
.wst-empty-title { font-size: 16px; font-weight: 700; color: var(--text-strong); }
.wst-empty-text { margin: 0; max-width: 420px; font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }

.wst-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.wst-intro-text { min-width: 0; }
.wst-h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.2px; color: var(--text-strong); }
.wst-h3-n { margin-left: 4px; font-size: 13px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.wst-p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--text-muted); max-width: 560px; }

.wst-note {
    display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: 10px;
    background: var(--blue-wash); border: 1px solid #D5DEFA; font-size: 13px; line-height: 1.5; color: #22306B;
}
.wst-note > i { flex: none; margin-top: 2px; font-size: 16px; color: var(--blue); }
.wst-note.is-warn { background: #FFF8EB; border-color: #F5DFB3; color: #6A3F06; }
.wst-note.is-warn > i { color: #B45309; }
.wst-link { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--blue); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ── buttons ── */
.wst-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: none;
    height: 38px; padding: 0 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
    font-size: 13.5px; font-weight: 600; color: var(--text-strong); cursor: pointer; white-space: nowrap;
    box-shadow: 0 1px 2px rgba(33, 37, 49, 0.05); transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.wst-btn i { font-size: 16px; }
.wst-btn:hover:not(:disabled) { background: var(--bg-alt); }
.wst-btn:active:not(:disabled) { transform: translateY(1px); }
.wst-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.wst-btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.wst-btn.is-primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(0, 67, 251, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.wst-btn.is-primary:hover:not(:disabled) { background: var(--blue-hover); border-color: var(--blue-hover); }
.wst-btn.is-danger { background: #D92D20; border-color: #D92D20; color: #fff; }
.wst-btn.is-danger:hover:not(:disabled) { background: #B42318; border-color: #B42318; }
.wst-btn.is-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }

/* ── trigger icons (one hue each, the same everywhere) ── */
.wst-ticon { flex: none; width: 40px; height: 40px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.wst-ticon.t-booked { background: #E7F7EE; color: #147A3F; }
.wst-ticon.t-before_rdv { background: #FFF3DF; color: #A85B06; }
.wst-ticon.t-no_reply { background: #EBF0FF; color: #0043FB; }
.wst-ticon.t-missed_call { background: #FDECEC; color: #C2261B; }
.wst-ticon.t-new_lead { background: #E4F5F8; color: #0B6E86; }
.wst-ticon.is-wa { background: #E7F7EE; color: #12A150; }

/* ── rule cards ── */
.wst-rules { display: flex; flex-direction: column; gap: 10px; }
.wst-rule {
    display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "icon main side" "icon meta meta";
    column-gap: 14px; row-gap: 10px; align-items: start;
    padding: 16px 16px 14px 18px; border-radius: 14px; background: #fff; border: 1px solid var(--border-soft);
    box-shadow: 0 1px 2px rgba(33, 37, 49, 0.04); transition: border-color 0.12s, box-shadow 0.12s;
}
.wst-rule:hover { border-color: #C7CEE0; box-shadow: 0 4px 14px rgba(33, 37, 49, 0.06); }
.wst-rule > .wst-ticon { grid-area: icon; }
.wst-rule-main {
    grid-area: main; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none;
    text-align: left; cursor: pointer; color: inherit;
}
.wst-rule-main:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 6px; }
.wst-rule-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wst-rule-name { font-size: 15px; font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst-rule-main:hover .wst-rule-name { color: var(--blue); }
.wst-rule-sum { font-size: 13.5px; line-height: 1.5; color: var(--text-body); }
.wst-badge { flex: none; height: 20px; padding: 0 8px; border-radius: 999px; display: inline-flex; align-items: center;
    background: var(--bg-alt); color: var(--text-muted); font-size: 11px; font-weight: 600; }
.wst-rule-side { grid-area: side; display: flex; align-items: center; gap: 6px; padding-top: 2px; }
.wst-rule-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 6px; }
.wst-rule.is-off { background: #FCFCFE; }
.wst-rule.is-off > .wst-ticon { filter: grayscale(1); opacity: 0.55; }
.wst-rule.is-off .wst-rule-sum { color: var(--text-muted); }
.wst-tag {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; max-width: 100%; padding: 0 10px; border-radius: 8px;
    background: var(--bg-alt); border: 1px solid transparent; font-size: 12px; font-weight: 500; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wst-tag i { flex: none; font-size: 14px; }
.wst-tag.is-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.wst-tag.is-pending { background: var(--blue-wash); color: var(--blue); font-weight: 600; cursor: pointer; border: 0; }
.wst-tag.is-pending:hover { border-color: #C2D1FF; box-shadow: inset 0 0 0 1px #C2D1FF; }

/* ── the menu ── */
.wst-menu {
    position: absolute; z-index: 5; min-width: 190px; padding: 6px; border-radius: 12px; background: #fff;
    border: 1px solid var(--border-soft); box-shadow: 0 12px 32px rgba(17, 24, 39, 0.16), 0 2px 6px rgba(17, 24, 39, 0.06);
}
.wst-menu[hidden] { display: none; }
.wst-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 12px; border: 0; border-radius: 8px;
    background: none; font-size: 13.5px; font-weight: 500; color: var(--text-strong); cursor: pointer; text-align: left;
}
.wst-menu button i { font-size: 16px; color: var(--text-muted); }
.wst-menu button:hover:not(:disabled), .wst-menu button:focus-visible { background: var(--bg-alt); outline: none; }
.wst-menu button:disabled { opacity: 0.45; cursor: default; }
.wst-menu button.is-danger, .wst-menu button.is-danger i { color: #C4320A; }
.wst-menu button.is-danger:hover { background: #FEF3F2; }

/* ── presets ── */
.wst-hero {
    display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px 24px 28px; text-align: center;
    border-radius: 16px; background: #fff; border: 1px solid var(--border-soft);
    background-image: radial-gradient(120% 80% at 50% 0%, #F1F5FF 0%, rgba(241, 245, 255, 0) 60%);
}
.wst-hero-icon { width: 52px; height: 52px; border-radius: 15px; display: flex; align-items: center; justify-content: center;
    background: var(--blue); color: #fff; font-size: 24px; box-shadow: 0 6px 16px rgba(0, 67, 251, 0.25); }
.wst-hero-title { margin-top: 4px; font-size: 17px; font-weight: 700; color: var(--text-strong); }
.wst-hero-text { margin: 0 0 8px; max-width: 460px; font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }
.wst-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.wst-presets.is-big { margin-bottom: 8px; text-align: left; }
.wst-preset {
    display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 14px; border-radius: 12px; cursor: pointer; text-align: left;
    background: #fff; border: 1px solid var(--border-soft); transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.wst-preset:hover { border-color: #AFC2FF; box-shadow: 0 6px 16px rgba(0, 67, 251, 0.08); }
.wst-preset:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.wst-preset .wst-ticon { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
.wst-preset-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wst-preset-text b { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.wst-preset-text small { font-size: 12px; line-height: 1.4; color: var(--text-muted); }
.wst-preset-add { flex: none; width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-alt); color: var(--text-muted); font-size: 14px; transition: background 0.12s, color 0.12s; }
.wst-preset:hover .wst-preset-add { background: var(--blue); color: #fff; }
.wst-sugg { margin-top: 24px !important; padding-top: 20px; border-top: 1px dashed var(--border); }
.wst-sugg-label { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.wst-sugg-label i { font-size: 15px; color: var(--blue); }

/* ── the editor ── */
.wst-body.is-editor { padding-top: 20px; }
.wst-ed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.wst-ed-form { display: flex; flex-direction: column; min-width: 0; }
.wst-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 14px; }
.wst-step-rail { position: relative; display: flex; justify-content: center; }
.wst-step-rail::after { content: ""; position: absolute; top: 34px; bottom: 6px; left: 50%; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--border-soft); }
.wst-step:last-child .wst-step-rail::after { display: none; }
.wst-step-num {
    position: relative; z-index: 1; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--blue); color: #fff; font-size: 13px; font-weight: 700; box-shadow: 0 0 0 4px var(--bg-page, #F8F9FC);
}
.wst-step.is-locked .wst-step-num { background: #fff; color: var(--text-muted); border: 1.5px solid var(--border); }
.wst-step-body {
    min-width: 0; margin-bottom: 18px; padding: 18px 20px 20px; border-radius: 14px; background: #fff; border: 1px solid var(--border-soft);
    display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 2px rgba(33, 37, 49, 0.04);
}
.wst-step.is-locked .wst-step-body { background: transparent; box-shadow: none; border-style: dashed; }
.wst-step-mnum { display: none; flex: none; width: 22px; height: 22px; margin-right: 8px; border-radius: 50%; align-items: center; justify-content: center;
    background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; vertical-align: 1px; }
.wst-step.is-locked .wst-step-mnum { background: var(--bg-alt); color: var(--text-muted); }
.wst-step-title { display: flex; align-items: center; margin: 0; font-size: 15px; font-weight: 700; color: var(--text-strong); letter-spacing: -0.1px; }
.wst-step-desc { margin: -10px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.wst-locked { margin: -6px 0 0; font-size: 13px; color: var(--text-muted); font-style: italic; }

.wst-trigs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.wst-trig {
    position: relative; display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 12px 34px 12px 12px; border-radius: 12px;
    background: #fff; border: 1px solid var(--border-soft); cursor: pointer; text-align: left; transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.wst-trig:hover { border-color: #B6C2DE; }
.wst-trig:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.wst-trig .wst-ticon { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
.wst-trig-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wst-trig-text b { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.wst-trig-text small { font-size: 12px; line-height: 1.4; color: var(--text-muted); }
.wst-trig-check { position: absolute; top: 10px; right: 10px; font-size: 18px; color: var(--blue); opacity: 0; transform: scale(0.6); transition: opacity 0.12s, transform 0.12s; }
.wst-trig.is-on { border-color: var(--blue); background: #F7F9FF; box-shadow: inset 0 0 0 1px var(--blue); }
.wst-trig.is-on .wst-trig-check { opacity: 1; transform: scale(1); }

.wst-f { gap: 6px; }
.wst-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.wst-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wst-row-tpl { grid-template-columns: minmax(0, 1fr) 190px; }
.wst-hint { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }
.wst-hint-icon { display: flex; align-items: flex-start; gap: 7px; }
.wst-hint-icon i { flex: none; margin-top: 1px; font-size: 15px; color: var(--blue); }
.wst-err { font-size: 12.5px; line-height: 1.45; font-weight: 500; color: #B42318; }
.wst-err[hidden] { display: none; }
.wst-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.wst-sheet select.fm-in { padding-right: 30px; appearance: none; -webkit-appearance: none; cursor: pointer;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 256 256'%3E%3Cpath fill='%2348516A' d='M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80a8 8 0 0 1 11.32-11.32L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32Z'/%3E%3C/svg%3E") no-repeat right 11px center; }
.wst-sheet .fm-in { height: 40px; border-radius: 9px; }
.wst-sheet .fm-ta { height: auto; }

.wst-dur { display: flex; max-width: 300px; }
.wst-dur .wst-dur-n { width: 96px; flex: none; border-top-right-radius: 0; border-bottom-right-radius: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.wst-dur .wst-dur-u { flex: 1; min-width: 0; margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; background-color: var(--bg-alt); }
.wst-dur .fm-in:focus { position: relative; z-index: 1; }

.wst-choice { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 11px; background: var(--bg-alt); border: 1px solid var(--border-soft); align-self: flex-start; max-width: 100%; }
.wst-choice-btn {
    display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border: 0; border-radius: 8px; background: none;
    font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.wst-choice-btn i { font-size: 15px; }
.wst-choice-btn:hover { color: var(--text-strong); }
.wst-choice-btn.is-on { background: #fff; color: var(--blue); box-shadow: 0 1px 3px rgba(33, 37, 49, 0.12); }
.wst-choice-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.wst-status-sel { max-width: 320px; }

.wst-sub-card { display: flex; flex-direction: column; gap: 14px; padding: 14px; border-radius: 12px; background: var(--bg-page, #F8F9FC); border: 1px solid var(--border-soft); }
.wst-inline-switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.wst-inline-switch .fm-switch { margin-top: 1px; }
.wst-inline-switch > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.wst-inline-switch b { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.wst-inline-switch small { font-size: 12.5px; color: var(--text-muted); }

.wst-window { max-width: 380px; }
.wst-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wst-chips.is-bad .wst-chip { border-color: #F04438; }
.wst-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; min-width: 46px; justify-content: center; padding: 0 12px; border-radius: 999px;
    background: #fff; border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.wst-chip:hover { border-color: #9FAECF; color: var(--text-strong); }
.wst-chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.wst-chip.is-on { background: var(--blue); border-color: var(--blue); color: #fff; }
.wst-chip-status { font-weight: 500; }
.wst-chip-status.is-on { background: #FEF3F2; border-color: #FDA29B; color: #B42318; font-weight: 600; }
.wst-chip-status i { font-size: 14px; }

.wst-ta { min-height: 118px; font-size: 14px; line-height: 1.55; }
.wst-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.wst-vars-label { font-size: 12px; color: var(--text-muted); margin-right: 2px; }
.wst-var {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 10px; border-radius: 8px; cursor: pointer;
    background: #fff; border: 1px solid var(--border-soft); font-size: 12px; font-weight: 600; color: var(--text-strong);
    transition: border-color 0.12s, background 0.12s;
}
.wst-var code { padding: 1px 5px; border-radius: 5px; background: var(--bg-alt); font: 500 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text-muted); }
.wst-var:hover { border-color: var(--blue); background: var(--blue-wash); }
.wst-var:hover code { background: #fff; color: var(--blue); }
.wst-var:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.wst-count-chars { margin-left: auto; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.wst-name-f { padding-top: 14px; border-top: 1px solid var(--border-soft); }

/* the side: preview and summary */
.wst-ed-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.wst-side-card { padding: 14px; border-radius: 14px; background: #fff; border: 1px solid var(--border-soft); box-shadow: 0 1px 2px rgba(33, 37, 49, 0.04); }
.wst-side-label { margin-bottom: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.wst-side-sum { margin: 0; font-size: 14px; line-height: 1.55; font-weight: 500; color: var(--text-strong); }
.wst-side-note { margin: 10px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--text-muted); }
.wst-phone { border-radius: 12px; overflow: hidden; border: 1px solid #E3DED5; }
.wst-phone-bar { display: flex; align-items: center; gap: 9px; padding: 9px 12px; background: #075E54; color: #fff; }
.wst-phone-av { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.2); font-size: 14px; }
.wst-phone-name { font-size: 13px; font-weight: 600; }
.wst-phone-feed {
    display: flex; flex-direction: column; align-items: flex-end; min-height: 150px; padding: 16px 12px;
    background-color: #EFEAE2;
    background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px);
    background-size: 14px 14px;
}
.wst-phone-feed.is-flat { min-height: 0; border-radius: 12px; }
.wst-bubble {
    position: relative; max-width: 94%; padding: 8px 10px 20px; border-radius: 10px 2px 10px 10px; background: #D9FDD3;
    font-size: 13.5px; line-height: 1.45; color: #111B21; white-space: pre-wrap; overflow-wrap: anywhere;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}
.wst-bubble.is-empty { padding-bottom: 8px; background: #fff; color: #667085; font-style: italic; border-radius: 10px; }
.wst-bubble-meta { position: absolute; right: 8px; bottom: 4px; display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; color: #667781; }
.wst-bubble-meta i { font-size: 14px; color: #53BDEB; }
.wst-mark { padding: 0 2px; border-radius: 3px; background: rgba(18, 140, 126, 0.16); color: inherit; font-weight: 600; }
.wst-mark.is-bad { background: #FEE4E2; color: #B42318; }

/* ── foot (the editor's and General's Save bar) ── */
.wst-foot {
    display: flex; align-items: center; gap: 14px; flex: none; padding: 14px 24px;
    background: #fff; border-top: 1px solid var(--border-soft); box-shadow: 0 -4px 16px rgba(33, 37, 49, 0.04);
}
.wst-foot[hidden] { display: none; }
.wst-foot-switch { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-strong); cursor: pointer; flex: none; }
.wst-foot-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wst-dirty { font-size: 12.5px; font-weight: 600; color: #B54708; }
.wst-dirty[hidden] { display: none; }
.wst-foot-btns { display: flex; align-items: center; gap: 8px; flex: none; }
.wst-foot-btns [hidden] { display: none; }

/* ── planned sends ── */
.wst-filter { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 12px; border-radius: 999px;
    background: var(--blue-wash); color: var(--blue); font-size: 12.5px; font-weight: 600; }
.wst-q-sec { display: flex; flex-direction: column; gap: 8px; }
.wst-q-sec + .wst-q-sec { margin-top: 24px; }
.wst-q-label { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.wst-q-list { border-radius: 14px; background: #fff; border: 1px solid var(--border-soft); overflow: hidden; box-shadow: 0 1px 2px rgba(33, 37, 49, 0.04); }
.wst-q-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 16px; }
.wst-q-row + .wst-q-row { border-top: 1px solid var(--border-soft); }
.wst-q-when { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.wst-q-when b { font-size: 13.5px; font-weight: 700; color: var(--text-strong); }
.wst-q-when small { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.wst-q-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.wst-q-lead { max-width: 100%; padding: 0; border: 0; background: none; font-size: 14px; font-weight: 600; color: var(--text-strong); cursor: pointer; text-align: left;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst-q-lead:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.wst-q-lead.is-gone { cursor: default; color: var(--text-muted); font-weight: 500; }
.wst-q-rule { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 100%; font-size: 12.5px; color: var(--text-muted); }
.wst-q-rule i { flex: none; font-size: 14px; }
.wst-q-att { white-space: nowrap; padding: 1px 6px; border-radius: 6px; background: var(--bg-alt); font-size: 11px; font-weight: 600; }
.wst-q-why { font-size: 12.5px; color: var(--text-muted); text-align: right; max-width: 240px; }
.wst-q-empty { display: flex; align-items: center; gap: 8px; padding: 18px 16px; font-size: 13px; color: var(--text-muted); }
.wst-q-empty i { font-size: 17px; }
.wst-st { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--bg-alt); color: var(--text-muted); }
.wst-st.st-sent { background: #E7F7EE; color: #147A3F; }
.wst-st.st-failed { background: #FEECEC; color: #B42318; }
.wst-st.st-expired, .wst-st.st-skipped { background: #FFF3DF; color: #93520A; }

/* ── General ── */
.wst-gen { display: flex; flex-direction: column; gap: 16px; }
.wst-card { border-radius: 14px; background: #fff; border: 1px solid var(--border-soft); box-shadow: 0 1px 2px rgba(33, 37, 49, 0.04); }
.wst-card > * + * { border-top: 1px solid var(--border-soft); }
.wst-card-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; }
.wst-card-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wst-card-head { display: flex; flex-direction: column; gap: 3px; padding: 16px 20px 0; }
.wst-card-head + .wst-card-pad { border-top: 0; }
.wst-card-pad { padding: 14px 20px 18px; }
.wst-card-title { font-size: 14.5px; font-weight: 600; color: var(--text-strong); }
.wst-card-desc { font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.wst-big-num { font-size: 18px; font-weight: 700; letter-spacing: 0.01em; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.wst-warn-text { color: #B54708; }
.wst-agents { display: flex; flex-direction: column; gap: 10px; }
.wst-agent { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 280px); align-items: center; gap: 6px 16px; }
.wst-agent-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13.5px; font-weight: 500; color: var(--text-strong); overflow-wrap: anywhere; }
.wst-agent-name small { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.wst-av { flex: none; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--blue-wash); color: var(--blue); font-size: 12.5px; font-weight: 700; }
.wst-agent.is-off .wst-agent-name, .wst-agent.is-off .fm-in { opacity: 0.55; }
.wst-agent-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wst-gen-tpl { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; align-items: start; }
.wst-gen-tpl-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.wst-gen-prev { min-width: 0; }
.wst-meta { font-size: 12.5px; color: var(--text-muted); padding: 0 4px; }
.wst-meta[hidden] { display: none; }

/* ── the confirmation ── */
.wst-ask {
    position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(17, 24, 39, 0.32); animation: wst-fade 0.14s ease;
}
.wst-ask[hidden] { display: none; }
.wst-ask-card {
    width: 100%; max-width: 400px; padding: 22px; border-radius: 16px; background: #fff; text-align: center;
    box-shadow: 0 20px 50px rgba(17, 24, 39, 0.25); animation: wst-pop 0.16s cubic-bezier(0.32, 0.72, 0, 1);
}
.wst-ask-icon { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--blue-wash); color: var(--blue); font-size: 22px; }
.wst-ask-icon.is-danger { background: #FEF3F2; color: #D92D20; }
.wst-ask-title { font-size: 16px; font-weight: 700; color: var(--text-strong); overflow-wrap: anywhere; }
.wst-ask-text { margin: 6px 0 18px; font-size: 13.5px; line-height: 1.5; color: var(--text-muted); overflow-wrap: anywhere; }
.wst-ask-btns { display: flex; gap: 8px; }
.wst-ask-btns .wst-btn { flex: 1; min-width: 0; white-space: normal; height: auto; min-height: 40px; padding: 8px 12px; }
@keyframes wst-fade { from { opacity: 0; } }
@keyframes wst-pop { from { opacity: 0; transform: scale(0.96) translateY(6px); } }

/* ── wide: the editor gets its side column ── */
@media (min-width: 1000px) {
    .wst-ed { grid-template-columns: minmax(0, 1fr) 280px; }
    .wst-ed-side { position: sticky; top: 0; }
}

/* ── narrow: the whole screen ── */
@media (max-width: 760px) {
    .wst-sheet { width: 100vw; border-left: 0; box-shadow: none; transform: translateY(24px); opacity: 0;
        transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.2s ease; }
    .wst-sheet.is-on { transform: none; opacity: 1; }
    .wst-head { padding: 12px 12px 12px 16px; gap: 10px; padding-top: max(12px, env(safe-area-inset-top)); }
    .wst-head-icon { width: 36px; height: 36px; font-size: 20px; border-radius: 10px; }
    .wst-back + .wst-head-icon { display: none; }
    .wst-title { font-size: 16px; }
    .wst-tabs { padding: 0 8px; }
    .wst-tab { padding: 0 10px; font-size: 13px; }
    .wst-tabs { justify-content: space-between; }
    .wst-tab { gap: 6px; }
    .wst-tab > i, .wst-tab-long { display: none; }
    .wst-tab-short { display: inline; }
    .wst-body { padding: 16px 16px 24px; }
    .wst-intro { flex-direction: column; align-items: stretch; }
    .wst-intro > .wst-btn { width: 100%; }
    .wst-presets { grid-template-columns: minmax(0, 1fr); }
    .wst-hero { padding: 24px 14px 20px; }
    .wst-rule { grid-template-columns: 36px minmax(0, 1fr) auto; column-gap: 12px; padding: 14px 12px 12px 14px; }
    .wst-rule > .wst-ticon { width: 36px; height: 36px; font-size: 18px; }
    .wst-rule-name { white-space: normal; }
    .wst-rule-meta { grid-column: 1 / -1; }
    .wst-rule { grid-template-areas: "icon main side" "meta meta meta"; }
    .wst-step { grid-template-columns: minmax(0, 1fr); }
    .wst-step-rail { display: none; }
    .wst-step-body { padding: 16px 14px; margin-bottom: 14px; }
    .wst-step-mnum { display: inline-flex; }
    .wst-trigs { grid-template-columns: minmax(0, 1fr); }
    .wst-row-2, .wst-row-tpl { grid-template-columns: minmax(0, 1fr); }
    .wst-window { max-width: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wst-dur { max-width: none; }
    .wst-chip { min-width: 0; padding: 0 10px; }
    .wst-foot { flex-wrap: wrap; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); gap: 10px; }
    .wst-foot-text { order: -1; flex-basis: 100%; }
    .wst-foot-text:not(:has(:not([hidden]))) { display: none; }
    .wst-foot-btns { flex: 1; justify-content: flex-end; }
    .wst-foot-btns .wst-btn { flex: 1; }
    .wst-q-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main btn" "when btn"; gap: 6px 12px; padding: 12px 14px; }
    .wst-q-row .wst-q-main { grid-area: main; }
    .wst-q-row .wst-q-when { grid-area: when; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
    .wst-q-row > .wst-btn { grid-area: btn; }
    .wst-q-row.is-done { grid-template-areas: "main main" "when when" "why why"; }
    .wst-q-row.is-done .wst-q-why { grid-area: why; text-align: left; max-width: none; }
    .wst-card-row, .wst-card-pad { padding-left: 16px; padding-right: 16px; }
    .wst-card-head { padding-left: 16px; padding-right: 16px; }
    .wst-agent { grid-template-columns: minmax(0, 1fr); }
    .wst-gen-tpl { grid-template-columns: minmax(0, 1fr); }
}
