/* Dialogs and toasts (assets/js/sb_dialog.js), and the pieces the site's
   dialogs are built from: option cards, people lists, tabs, a search field,
   quick picks. Colours come from the theme tokens (--sb-*, sb_theme.css), so
   light and dark follow the page. Icons are Phosphor glyphs (.ph). */
.sbd-backdrop {
    --sbd-surface: var(--sb-surface, #fff); --sbd-surface-2: var(--sb-surface-2, #f0f2f5); --sbd-text: var(--sb-text, #1c1e21);
    --sbd-muted: var(--sb-text-muted, #65676b); --sbd-border: var(--sb-border, #e4e6eb); --sbd-hover: var(--sb-hover, #f2f3f5);
    --sbd-accent: var(--sb-accent, #0073b7); --sbd-danger: #e5484d; --sbd-success: #12b76a; --sbd-warning: #f79009; --sbd-info: #2e90fa;
    position: fixed; inset: 0; z-index: 10600; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(12, 15, 24, 0); transition: background-color .16s ease; font-family: var(--sb-font, inherit);
}
.sbd-backdrop.is-in { background: rgba(12, 15, 24, .55); }
.sbd-backdrop.is-leaving { background: rgba(12, 15, 24, 0); }
html.sbd-locked, html.sbd-locked body { overflow: hidden !important; }

.sbd {
    --tone: var(--sbd-accent);
    position: relative; width: 100%; max-width: 420px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
    background: var(--sbd-surface); color: var(--sbd-text); border-radius: 22px; overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .28), 0 0 0 1px rgba(0, 0, 0, .04);
    opacity: 0; transform: translateY(8px) scale(.97); transition: opacity .16s ease, transform .18s cubic-bezier(.2, .9, .3, 1.2);
}
.sbd.sbd-md { max-width: 520px; }
.sbd.sbd-lg { max-width: 640px; }
.is-in > .sbd { opacity: 1; transform: none; }
.is-leaving > .sbd { opacity: 0; transform: translateY(6px) scale(.98); transition-duration: .14s; }
.sbd.is-danger { --tone: var(--sbd-danger); }
.sbd.is-success { --tone: var(--sbd-success); }
.sbd.is-warning { --tone: var(--sbd-warning); }
.sbd.is-info { --tone: var(--sbd-info); }
.sbd.is-neutral { --tone: var(--sbd-muted); }
body.theme-dark .sbd { box-shadow: 0 24px 64px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .06); }

.sbd-head { display: flex; align-items: center; gap: 14px; padding: 22px 22px 6px; }
.sbd-icon { width: 48px; height: 48px; flex: none; border-radius: 15px; display: flex; align-items: center; justify-content: center; font-size: 26px;
            color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, transparent); }
.sbd-icon .ph { font-size: 26px; line-height: 1; }
.sbd-titles { flex: 1; min-width: 0; }
.sbd-titles h3 { margin: 0; font-size: 1.12rem; font-weight: 800; line-height: 1.3; letter-spacing: -.01em; color: var(--sbd-text); }
.sbd-titles p { margin: 3px 0 0; color: var(--sbd-muted); font-size: .9rem; line-height: 1.4; }
.sbd-head.no-icon .sbd-titles { padding-top: 6px; }
.sbd-x { width: 36px; height: 36px; flex: none; margin: 0 -6px 0 0; align-self: flex-start; border: 0; border-radius: 50%; background: transparent; color: var(--sbd-muted);
         display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background-color .12s; }
.sbd-x svg { width: 18px; height: 18px; }
.sbd-x:hover { background: var(--sbd-hover); color: var(--sbd-text); }
.sbd-body { padding: 8px 22px 6px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.sbd-text.is-lead { color: var(--sbd-text); font-size: 1rem; font-weight: 600; margin-top: 4px; }
.sbd-body.is-flush { padding-left: 0; padding-right: 0; }
.sbd-text { margin: 0 0 6px; color: var(--sbd-muted); font-size: .95rem; line-height: 1.5; white-space: pre-line; }
.sbd-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px 20px; }

.sbd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border: 0; border-radius: 12px;
           font: inherit; font-weight: 800; font-size: .93rem; cursor: pointer; white-space: nowrap; text-decoration: none !important;
           transition: filter .12s, background-color .12s, transform .06s; position: relative; }
.sbd-btn:active { transform: translateY(1px); }
.sbd-btn[disabled] { opacity: .55; cursor: default; }
.sbd-btn .ph { font-size: 1.05rem; }
.sbd-btn.is-primary { background: var(--sbd-accent, #0073b7); color: #fff !important; }
.sbd-btn.is-danger { background: var(--sbd-danger, #e5484d); color: #fff !important; }
.sbd-btn.is-primary:hover, .sbd-btn.is-danger:hover { filter: brightness(.93); }
.sbd-btn.is-ghost { background: var(--sbd-surface-2, #f0f2f5); color: var(--sbd-text, #1c1e21) !important; }
.sbd-btn.is-ghost:hover { background: var(--sb-hover-strong, #e7e9ed); }
.sbd-btn.is-busy { color: transparent !important; pointer-events: none; }
.sbd-btn.is-busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.45);
                          border-top-color: #fff; animation: sbd-spin .7s linear infinite; }
.sbd-btn.is-ghost.is-busy::after { border-color: rgba(0,0,0,.15); border-top-color: var(--sbd-text); }
@keyframes sbd-spin { to { transform: rotate(360deg); } }

/* Phones: a sheet from the bottom, full-width buttons. */
@media (max-width: 600px) {
    .sbd-backdrop { align-items: flex-end; padding: 0; }
    .sbd, .sbd.sbd-md, .sbd.sbd-lg { max-width: none; max-height: calc(100vh - 40px); border-radius: 22px 22px 0 0; transform: translateY(40px);
                                     padding-bottom: env(safe-area-inset-bottom, 0); }
    .sbd::before { content: ''; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--sbd-border); }
    .sbd-head { padding-top: 26px; }
    .sbd-foot { padding-bottom: 18px; }
    .sbd-foot .sbd-btn { flex: 1; }
    .is-leaving > .sbd { transform: translateY(40px); }
}
@media (prefers-reduced-motion: reduce) { .sbd, .sbd-backdrop { transition: none !important; } }

/* ── Building blocks ─────────────────────────────────────────────────── */
.sbd-search { position: relative; margin: 2px 0 10px; }
.sbd-search .ph { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--sbd-muted); font-size: 1.05rem; pointer-events: none; }
.sbd-search input, .sbd-input, .sbd-textarea, .sbd-select {
    width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--sbd-border); background: var(--sb-input-bg, var(--sbd-surface));
    color: var(--sbd-text); font: inherit; font-size: .95rem; padding: 10px 14px; outline: none; transition: border-color .12s, box-shadow .12s; }
.sbd-search input { padding-left: 40px; }
.sbd-search input:focus, .sbd-input:focus, .sbd-textarea:focus, .sbd-select:focus { border-color: var(--sbd-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sbd-accent) 22%, transparent); }
.sbd-textarea { min-height: 76px; resize: vertical; }
.sbd-label { display: block; margin: 12px 0 6px; font-size: .82rem; font-weight: 800; color: var(--sbd-muted); text-transform: uppercase; letter-spacing: .05em; }
.sbd-hint { margin: 6px 0 0; color: var(--sbd-muted); font-size: .84rem; }
.sbd-note { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--sbd-surface-2);
            color: var(--sbd-muted); font-size: .88rem; line-height: 1.45; }
.sbd-note .ph { color: var(--tone, var(--sbd-accent)); font-size: 1.1rem; flex: none; margin-top: 1px; }
.sbd-points { list-style: none; margin: 4px 0 6px; padding: 0; }
.sbd-points li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; color: var(--sbd-text); font-size: .93rem; line-height: 1.4; }
.sbd-points li .ph { color: var(--sbd-muted); font-size: 1.1rem; flex: none; margin-top: 1px; }

/* Choices, one or several: a list of cards with a mark on the right. */
.sbd-options { display: flex; flex-direction: column; gap: 8px; }
.sbd-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--sbd-border);
              background: transparent; color: var(--sbd-text); font: inherit; text-align: left; cursor: pointer; transition: border-color .12s, background-color .12s; }
.sbd-option:hover { background: var(--sbd-hover); }
.sbd-option.is-on { border-color: var(--sbd-accent); background: color-mix(in srgb, var(--sbd-accent) 8%, transparent); }
.sbd-option-ico { width: 36px; height: 36px; flex: none; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
                  background: var(--sbd-surface-2); color: var(--sbd-muted); }
.sbd-option.is-on .sbd-option-ico { color: var(--sbd-accent); background: color-mix(in srgb, var(--sbd-accent) 14%, transparent); }
.sbd-option-text { flex: 1; min-width: 0; }
.sbd-option-text b { display: block; font-weight: 700; font-size: .95rem; }
.sbd-option-text small { display: block; color: var(--sbd-muted); font-size: .82rem; margin-top: 1px; }
.sbd-mark { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--sbd-border); display: flex; align-items: center; justify-content: center;
            color: #fff; font-size: .8rem; transition: background-color .12s, border-color .12s; }
.sbd-option.is-on .sbd-mark { background: var(--sbd-accent); border-color: var(--sbd-accent); }
.sbd-mark .ph { opacity: 0; }
.sbd-option.is-on .sbd-mark .ph { opacity: 1; }

/* People: avatar, name, a line under it, something on the right. */
.sbd-people { list-style: none; margin: 0; padding: 0; }
.sbd-person { display: flex; align-items: center; gap: 12px; padding: 8px 22px; color: var(--sbd-text); text-decoration: none !important; position: relative; }
a.sbd-person:hover, button.sbd-person:hover { background: var(--sbd-hover); }
button.sbd-person { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
.sbd-avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; object-fit: cover; background: var(--sbd-surface-2); }
.sbd-avatar-wrap { position: relative; flex: none; }
.sbd-avatar-badge { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%; background: var(--sbd-surface);
                    display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--sbd-surface); }
.sbd-avatar-badge img { width: 18px; height: 18px; }
.sbd-person-text { flex: 1; min-width: 0; }
.sbd-person-text b { display: block; font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbd-person-text small { display: block; color: var(--sbd-muted); font-size: .82rem; }
.sbd-person.is-on { background: color-mix(in srgb, var(--sbd-accent) 8%, transparent); }
.sbd-group-label { padding: 10px 22px 4px; color: var(--sbd-muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.sbd-empty { padding: 28px 22px; text-align: center; color: var(--sbd-muted); font-size: .92rem; }
.sbd-empty .ph { display: block; font-size: 2rem; margin: 0 auto 8px; opacity: .6; }
.sbd-more { display: block; width: calc(100% - 44px); margin: 6px 22px 4px; }
.sbd-loading { padding: 26px; text-align: center; }
.sbd-loading::before { content: ''; display: inline-block; width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--sbd-border); border-top-color: var(--sbd-accent);
                       animation: sbd-spin .7s linear infinite; }

/* Tabs that scroll sideways on a phone. */
.sbd-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 22px 10px; scrollbar-width: none; border-bottom: 1px solid var(--sbd-border); }
.sbd-tabs::-webkit-scrollbar { display: none; }
.sbd-tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; border: 0; background: var(--sbd-surface-2);
           color: var(--sbd-text); font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.sbd-tab img { width: 18px; height: 18px; }
.sbd-tab.is-on { background: var(--sbd-accent); color: #fff; }
.sbd-tab small { font-weight: 700; opacity: .8; }

/* Quick picks: chips in a wrap. */
.sbd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sbd-chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 12px; border: 1.5px solid var(--sbd-border); background: transparent;
            color: var(--sbd-text); font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; }
.sbd-chip small { color: var(--sbd-muted); font-weight: 600; }
.sbd-chip:hover { background: var(--sbd-hover); }
.sbd-chip.is-on { border-color: var(--sbd-accent); background: color-mix(in srgb, var(--sbd-accent) 8%, transparent); }
.sbd-to { min-height: 22px; margin: 8px 0 0; color: var(--sbd-muted); font-size: .86rem; }
.sbd-to b { color: var(--sbd-text); }

/* ── Toasts ──────────────────────────────────────────────────────────── */
.sbt-stack { position: fixed; top: 80px; right: 20px; z-index: 10700; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px));
             pointer-events: none; font-family: var(--sb-font, inherit); }
.sbt { --tone: #2e90fa; position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 16px;
       background: var(--sb-surface, #fff); color: var(--sb-text, #1c1e21); box-shadow: 0 12px 32px rgba(0,0,0,.16), 0 0 0 1px var(--sb-border, #e4e6eb);
       pointer-events: auto; opacity: 0; transform: translateX(16px); transition: opacity .18s ease, transform .22s cubic-bezier(.2,.9,.3,1.2); }
body.theme-dark .sbt { box-shadow: 0 12px 32px rgba(0,0,0,.55), 0 0 0 1px var(--sb-border, #2c3142); }
.sbt.is-in { opacity: 1; transform: none; }
.sbt.is-leaving { opacity: 0; transform: translateX(16px); }
.sbt.is-success { --tone: #12b76a; } .sbt.is-error { --tone: #e5484d; } .sbt.is-warning { --tone: #f79009; } .sbt.is-info { --tone: #2e90fa; }
.sbt-icon { width: 32px; height: 32px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--tone);
            box-shadow: 0 0 0 5px color-mix(in srgb, var(--tone) 16%, transparent); margin-left: 3px; }
.sbt-icon svg { width: 18px; height: 18px; }
.sbt-text { flex: 1; min-width: 0; line-height: 1.35; }
.sbt-text b { display: block; font-weight: 700; font-size: .92rem; }
.sbt-text span { display: block; color: var(--sb-text-muted, #65676b); font-size: .84rem; margin-top: 1px; }
.sbt-x { width: 30px; height: 30px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--sb-text-muted, #65676b); cursor: pointer;
         display: flex; align-items: center; justify-content: center; }
.sbt-x svg { width: 15px; height: 15px; }
.sbt-x:hover { background: var(--sb-hover, #f2f3f5); }
.sbt-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--tone); opacity: .55; transform-origin: left;
           animation: sbt-bar var(--sbt-ms, 3500ms) linear forwards; }
.sbt.is-paused .sbt-bar { animation-play-state: paused; }
@keyframes sbt-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 600px) {
    .sbt-stack { top: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0)); left: 16px; right: 16px; width: auto; }
    .sbt { transform: translateY(12px); }
    .sbt.is-leaving { transform: translateY(12px); }
}

/* ── SweetAlert2 dialogs still opened with SbAlert.fire() ───────────── */
.swal2-container { z-index: 10600 !important; }
.swal2-popup.sb-swal { border-radius: 22px !important; padding: 22px !important; background: var(--sb-surface, #fff) !important; color: var(--sb-text, #1c1e21) !important;
                       box-shadow: 0 24px 64px rgba(0,0,0,.28) !important; font-family: var(--sb-font, inherit); }
.swal2-popup.sb-swal .swal2-title { color: var(--sb-text, #1c1e21) !important; font-size: 1.15rem !important; font-weight: 800 !important; }
.swal2-popup.sb-swal .swal2-content, .swal2-popup.sb-swal .swal2-html-container { color: var(--sb-text-muted, #65676b) !important; font-size: .95rem !important; }
.swal2-popup.sb-swal .swal2-actions { gap: 10px; }
.swal2-popup.sb-swal .swal2-actions .sbd-btn { margin: 0; }
.swal2-popup.sb-swal .swal2-select, .swal2-popup.sb-swal .swal2-input, .swal2-popup.sb-swal .swal2-textarea {
    border-radius: 12px !important; border: 1px solid var(--sb-border, #e4e6eb) !important; background: var(--sb-input-bg, #fff) !important; color: var(--sb-text, #1c1e21) !important; }
.swal2-popup.sb-swal .swal2-footer { border-top-color: var(--sb-border, #e4e6eb) !important; color: var(--sb-text-muted, #65676b) !important; font-size: .82rem; }
.swal2-popup.sb-swal .swal2-icon { transform: scale(.8); margin: 4px auto 0; }

/* A dialog whose pop-ups (the emoji picker) may hang outside it. */
.sbd.sbd-overflow, .sbd.sbd-overflow .sbd-body { overflow: visible; }
.sbd.sbd-overflow .emojionearea { border-radius: 12px; border-color: var(--sbd-border); background: var(--sb-input-bg, var(--sbd-surface)); }
.sbd.sbd-overflow .emojionearea .emojionearea-editor { min-height: 110px; color: var(--sbd-text); }
.sbd-person .sbd-mark { margin-left: auto; }
.sbd-person.is-on .sbd-mark { background: var(--sbd-accent); border-color: var(--sbd-accent); }
.sbd-person.is-on .sbd-mark .ph { opacity: 1; }
.sbcur-code { width: 46px; font-size: .72rem; font-weight: 800; letter-spacing: .02em; color: var(--sbd-text); }
.sbd-note.is-bad { color: var(--sbd-danger); }
.sbd-note.is-bad .ph { color: var(--sbd-danger); }
.sbd-mark svg { width: 13px; height: 13px; opacity: 0; }
.sbd-option.is-on .sbd-mark svg, .sbd-person.is-on .sbd-mark svg { opacity: 1; }
.sbd-option-ico .ph { font-size: 19px; }
.sbd-points li .ph, .sbd-note .ph { font-size: 18px; }
.sbd-search .ph { font-size: 17px; }
.sbd-btn .ph { font-size: 17px; }
.sbd-empty .ph { font-size: 30px; }
.sbd-tabs { padding-top: 2px; }
