/* Revier Chat in the browser. Same design tokens as the Android, iOS and Windows apps (Apps/Branding). */

:root {
    --brand: #516fca;
    --brand-strong: #4460b8;
    --turquoise: #60d9db;
    --bg: #f6f7fb;
    --card: #ffffff;
    --surface: #eceef5;
    --line: #e1e4ee;
    --text: #1b1f2a;
    --muted: #667085;
    --bubble-out: #516fca;
    --bubble-out-text: #ffffff;
    --bubble-in: #ffffff;
    --danger: #c93a3a;
    --ok: #1f9d6b;
    --amber: #b7791f;
    --shadow: 0 1px 2px rgba(20, 28, 55, .06), 0 8px 24px rgba(20, 28, 55, .06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --brand: #7c95e6;
        --brand-strong: #92a8ee;
        --bg: #0f1117;
        --card: #181b24;
        --surface: #222634;
        --line: #2a2f40;
        --text: #eceef5;
        --muted: #9aa3b5;
        --bubble-out: #4a66c0;
        --bubble-in: #222634;
        --danger: #f07373;
        --ok: #4cc38a;
        --amber: #e0a94a;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    }
}

* { box-sizing: border-box; }

html, body, #app { height: 100%; margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.small { width: 16px; height: 16px; }
.mark { fill: var(--turquoise); }

/* ---- buttons and fields */

.btn {
    border: 0; border-radius: 999px; padding: 10px 20px; background: var(--brand); color: #fff; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
}
.btn:hover:not(:disabled) { background: var(--brand-strong); }
.btn.quiet { background: var(--surface); color: var(--text); }
.btn.quiet:hover:not(:disabled) { background: var(--line); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.btn.small { padding: 6px 14px; min-height: 32px; font-size: 13px; }
.btn.wide { width: 100%; }

.icon-btn {
    border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%; color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.icon-btn.accent { background: var(--brand); color: #fff; }
.icon-btn.accent:hover:not(:disabled) { background: var(--brand-strong); color: #fff; }

.field {
    width: 100%; border: 1px solid transparent; background: var(--surface); border-radius: 999px; padding: 10px 16px; min-height: 42px;
}
.field:focus { outline: none; border-color: var(--brand); background: var(--card); }
textarea.field { border-radius: 18px; resize: none; }
label.caption, .caption { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 4px; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }

.error { color: var(--danger); font-size: 14px; margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- the country picker of the phone step (spec 4.3) */
.caption.gap { margin-top: 14px; }
.picker-wrap { position: relative; }
.field.picker { display: flex; align-items: center; gap: 10px; text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.field.picker:focus-visible { outline: none; border-color: var(--brand); background: var(--card); }
.field.picker.wait { cursor: default; }
.picker .picker-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker .chevron { color: var(--muted); }
.flag { font-size: 18px; line-height: 1; width: 1.4em; text-align: center; flex: none; }
.picker-pop { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; }
.picker-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 280px; overflow-y: auto; }
.picker-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.picker-list li.active { background: var(--surface); }
.picker-list li.current .picker-name { font-weight: 600; }
.picker-list li .picker-name { flex: 1; min-width: 0; }
.picker-list li .dial { color: var(--muted); font-size: 13px; flex: none; }
.picker-list li.none { cursor: default; justify-content: center; }
.picker-failed { background: var(--surface); border-radius: 14px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.inline.phone { align-items: center; }
.dial-chip { flex: none; background: var(--surface); border-radius: 999px; padding: 10px 14px; min-height: 42px; display: flex; align-items: center; color: var(--muted); }
.tools .hint { margin: 6px 0 0 4px; }

/* ---- centred pages (sign-in, terms, notices) */

.page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; position: relative; overflow: hidden; }
.page::before {
    content: ""; position: absolute; inset: -10%; background: url(logo.svg) center / min(80vh, 80vw) no-repeat; opacity: .07; pointer-events: none;
}
.panel { position: relative; width: 100%; max-width: 420px; background: var(--card); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.panel.wide { max-width: 720px; }
.panel h1 { font-size: 22px; margin-bottom: 6px; }
.panel .lead { color: var(--muted); margin-bottom: 20px; }
.panel .row { display: flex; gap: 10px; margin-top: 18px; }
.hero { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--brand), var(--turquoise)); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.hero svg { width: 40px; height: 22px; }
.hero .mark { fill: #fff; }
.notice { display: flex; gap: 10px; background: var(--surface); border-radius: 14px; padding: 12px 14px; font-size: 13px; color: var(--muted); margin-top: 16px; }
.notice .icon { color: var(--brand); margin-top: 1px; }

/* QR sign-in: the code a signed-in phone scans */
.or { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.linkbox { display: flex; gap: 16px; align-items: center; }
.linkcode { flex: none; }
.qr { display: block; width: 148px; height: 148px; border-radius: 10px; background: #fff; }
.qr.wait { display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; box-sizing: border-box; background: var(--surface); }
.linktext h2 { font-size: 15px; margin: 0 0 6px; }
.linktext ol { margin: 0 0 8px; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.linktext p { margin: 0; }
@media (max-width: 520px) { .linkbox { flex-direction: column; align-items: flex-start; } }
.terms { height: 46vh; overflow: auto; background: var(--surface); border-radius: 14px; padding: 16px 20px; font-size: 14px; }
.terms h1 { font-size: 18px; margin: 14px 0 8px; }
.terms h2 { font-size: 16px; margin: 14px 0 6px; }
.terms h3 { font-size: 15px; margin: 12px 0 4px; }
.terms p, .terms ul, .terms ol, .terms table { margin: 8px 0; }
.terms table { border-collapse: collapse; }
.terms td, .terms th { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.code { letter-spacing: .5em; text-align: center; font-size: 22px; font-weight: 600; }
.sent-to { margin-bottom: 14px; }
.panel .row.again, .dialog .row.again { margin-top: 10px; justify-content: center; }
.inline { display: flex; gap: 8px; }
.inline .field { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--surface); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 8px auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- shell */

.shell { height: 100%; display: flex; }
.rail { width: 68px; flex: none; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; }
.rail .logo { width: 36px; height: 20px; margin: 6px 0 14px; }
.rail .spacer { flex: 1; }
.nav { position: relative; border: 0; background: transparent; width: 52px; height: 52px; border-radius: 14px; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; }
.nav:hover { background: var(--surface); color: var(--text); }
.nav.on { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.nav .dot { position: absolute; top: 6px; right: 8px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px; }

.list { width: 340px; flex: none; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.list header { padding: 18px 18px 10px; display: flex; align-items: center; gap: 8px; }
.list header h2 { font-size: 20px; flex: 1; }
.list .scroll { flex: 1; overflow: auto; padding: 4px 8px 12px; }
.list .tools { padding: 0 14px 10px; }
.section { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.section .count { display: inline-block; margin-left: 8px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 11px; line-height: 18px; letter-spacing: 0; text-align: center; padding: 0 5px; }
.empty { color: var(--muted); text-align: center; padding: 32px 20px; }

.item { width: 100%; border: 0; background: transparent; text-align: left; display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 14px; min-width: 0; }
button.item:hover { background: var(--surface); }
.item.on { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.item .body { flex: 1; min-width: 0; }
.item .top { display: flex; gap: 8px; align-items: baseline; }
.item .name { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 12px; color: var(--muted); flex: none; }
.item .preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .badge { min-width: 20px; height: 20px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; line-height: 20px; text-align: center; padding: 0 6px; flex: none; }
.item .actions { display: flex; gap: 6px; flex: none; }

.avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; color: #fff; background: linear-gradient(135deg, var(--brand), var(--turquoise)); }
.avatar.small { width: 32px; height: 32px; font-size: 12px; }

.status-bar { background: var(--amber); color: #fff; font-size: 13px; text-align: center; padding: 4px 10px; }

/* ---- conversation */

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.chat::before { content: ""; position: absolute; inset: 0; background: url(logo.svg) center / min(60vh, 50vw) no-repeat; opacity: .07; pointer-events: none; }
.chat > * { position: relative; }
.chat > header { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 12px; align-items: center; min-height: 64px; }
.chat > header .who { flex: 1; min-width: 0; }
.chat > header .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat > header .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.chat > header .back { display: none; }
.banner { background: color-mix(in srgb, var(--amber) 16%, var(--card)); color: var(--text); padding: 8px 16px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner span { flex: 1; }

.messages { flex: 1; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--card); border-radius: 999px; padding: 3px 12px; margin: 10px 0 6px; box-shadow: var(--shadow); }
.system { align-self: center; font-size: 12px; color: var(--muted); text-align: center; max-width: 80%; margin: 6px 0; }

.msg { display: flex; flex-direction: column; max-width: min(72%, 560px); align-self: flex-start; position: relative; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg .sender { font-size: 12px; color: var(--brand); font-weight: 600; margin: 4px 12px 2px; }
.bubble { background: var(--bubble-in); border-radius: 18px 18px 18px 6px; padding: 8px 12px; box-shadow: var(--shadow); overflow-wrap: anywhere; white-space: pre-wrap; min-width: 0; }
.msg.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-radius: 18px 18px 6px 18px; }
.bubble.deleted { font-style: italic; opacity: .7; }
.bubble .quote { border-left: 3px solid var(--turquoise); padding: 2px 8px; margin-bottom: 6px; font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.bubble .meta { font-size: 11px; opacity: .7; margin-left: 10px; float: right; margin-top: 6px; display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.bubble .meta .read { color: var(--turquoise); opacity: 1; }
.bubble img.picture { display: block; max-width: 280px; max-height: 280px; border-radius: 12px; margin-bottom: 4px; cursor: zoom-in; }
.bubble .file { display: flex; gap: 10px; align-items: center; border: 0; background: color-mix(in srgb, currentColor 10%, transparent); color: inherit; border-radius: 12px; padding: 8px 12px; text-align: left; max-width: 280px; }
.bubble .file .fname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble .file .fsize { font-size: 12px; opacity: .75; }
.reactions { display: flex; gap: 4px; margin: -6px 8px 2px; }
.reactions span { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; font-size: 13px; }
.failed { color: var(--danger); font-size: 12px; margin: 2px 8px; }
.failed button { border: 0; background: none; color: var(--brand); padding: 0 0 0 6px; text-decoration: underline; }

.msg .tools { position: absolute; top: -14px; right: 4px; display: none; background: var(--card); border-radius: 999px; box-shadow: var(--shadow); padding: 2px; z-index: 2; }
.msg:not(.out) .tools { right: auto; left: 4px; }
.msg:hover .tools, .msg:focus-within .tools { display: flex; }
.msg .tools button { border: 0; background: transparent; width: 28px; height: 28px; border-radius: 50%; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.msg .tools button:hover { background: var(--surface); color: var(--text); }

.typing { font-size: 12px; color: var(--muted); padding: 0 24px 6px; min-height: 22px; }
.composer { background: var(--card); border-top: 1px solid var(--line); padding: 10px 14px; }
.composer .context { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 0 6px 8px; }
.composer .context span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer .line { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; max-height: 140px; min-height: 42px; }
.placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 8px; text-align: center; padding: 20px; }
.placeholder .logo { width: 72px; height: 40px; }
.placeholder .lock { display: flex; gap: 6px; align-items: center; font-size: 13px; }

/* ---- settings */

.settings { flex: 1; overflow: auto; padding: 24px; }
.settings .inner { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border-radius: 18px; padding: 18px 20px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; margin-bottom: 12px; }
.card .rowline { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.card .rowline:first-of-type { border-top: 0; }
.card .rowline .grow { flex: 1; min-width: 0; }
.card .rowline input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.card .stack > * + * { margin-top: 12px; }
.card .rowline.lined { border-top: 1px solid var(--line); margin-top: 14px; padding-bottom: 0; }

/* ---- dialogs, menus, toast */

.overlay { position: fixed; inset: 0; background: rgba(10, 14, 28, .5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20; }
.dialog { background: var(--card); border-radius: 20px; padding: 24px; width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.dialog.wide { max-width: 720px; }
.dialog h3 { font-size: 18px; margin-bottom: 8px; }
.dialog .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.dialog .row.wrap { flex-wrap: wrap; }
.dialog .lead { margin-bottom: 16px; }
.dialog .hint { margin: 6px 4px 4px; }
.dialog .item.mailed { padding-left: 0; padding-right: 0; }
.safety { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; font: 600 18px/1.2 ui-monospace, Consolas, monospace; text-align: center; background: var(--surface); border-radius: 14px; padding: 16px; margin: 14px 0; }
.lightbox img, .lightbox video { max-width: 90vw; max-height: 80vh; border-radius: 12px; display: block; }
.lightbox audio { width: min(90vw, 420px); }
.lightbox .row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.menu { position: absolute; right: 12px; top: 58px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 10; min-width: 220px; }
.menu button { width: 100%; border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 10px; display: flex; gap: 10px; align-items: center; }
.menu button:hover { background: var(--surface); }
.menu button.danger { color: var(--danger); }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 30; max-width: 90vw; font-size: 14px; }

/* ---- narrow screens: one pane at a time */

@media (max-width: 820px) {
    .list { width: auto; flex: 1; border-right: 0; }
    .shell.open .list, .shell.open .rail { display: none; }
    .shell:not(.open) .chat { display: none; }
    .chat > header .back { display: inline-flex; }
    .msg { max-width: 86%; }
    .rail { width: 60px; }
    .settings { padding: 14px; }
    .shell.wide-main .list { display: none; }
    .shell.wide-main .chat { display: flex; }
}

/* ---- calls: the call screen (js/callui.js) and its video tiles (js/callmedia.js). Always dark, as in the apps. */

.call-screen { position: fixed; inset: 0; z-index: 15; background: #0f1117; color: #eef3f4; display: flex; flex-direction: column; }
.call-screen.hidden { display: none; }
.call-screen > header { display: flex; align-items: center; gap: 12px; padding: 14px 12px 8px 20px; }
.call-screen .who { flex: 1; min-width: 0; }
.call-screen .who .name { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-screen .who .sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #4cc38a; }
.call-screen .who .status { color: #c8d3d6; }
.call-screen .icon-btn { color: #c8d3d6; }
.call-screen .icon-btn:hover:not(:disabled) { background: #222634; color: #fff; }
.call-media { flex: 1; min-height: 0; position: relative; }
.call-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 12px 16px 20px; }
.call-btn { min-height: 44px; padding: 0 18px; background: #222634; color: #eef3f4; }
.call-btn:hover:not(:disabled) { background: #2a2f40; }
.call-btn.on { background: #eef3f4; color: #0f1117; }
.call-btn.on:hover:not(:disabled) { background: #fff; }
.call-btn.accept { background: #1f9d6b; color: #fff; min-width: 120px; }
.call-btn.accept:hover:not(:disabled) { background: #23b178; }
.call-btn.end { background: #d13438; color: #fff; min-width: 120px; }
.call-btn.end:hover:not(:disabled) { background: #e0474b; }

/* made small: a box in the corner, so the chats can be used during a call */
.call-screen.small { inset: auto 16px 16px auto; width: 300px; height: 230px; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 30px rgba(0, 0, 0, .45); }
.call-screen.small > header { padding: 8px 6px 4px 12px; }
.call-screen.small .who .name { font-size: 14px; }
.call-screen.small .call-controls { padding: 6px 8px 10px; gap: 6px; }
.call-screen.small .call-btn { min-width: 0; min-height: 36px; padding: 0 14px; }

.callmedia { position: absolute; inset: 0; }
.cm-stage { position: absolute; inset: 0; display: grid; gap: 8px; padding: 8px; }
.cm-tile { position: relative; background: #1b2b31; border-radius: 10px; overflow: hidden; border: 2px solid transparent; min-height: 0; min-width: 0; }
.cm-tile.speaking { border-color: #4cc38a; }
.cm-tile video { width: 100%; height: 100%; object-fit: cover; background: #0b1215; display: block; visibility: hidden; }
.cm-tile.video video { visibility: visible; }
/* .fit: the frame's shape differs from the tile's (a portrait phone on a wide screen), so it is shown whole on a dark
   letterbox rather than cropped to a strip; .screen: a shared screen is never cropped (callmedia.js fitTile) */
.cm-tile.fit video, .cm-tile.screen video { object-fit: contain; }
.cm-avatar { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cm-tile.video .cm-avatar { display: none; }
.cm-avatar span { width: 96px; height: 96px; border-radius: 50%; background: #dde3f6; color: #1a2a6c; display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 600; }
.call-screen.small .cm-avatar span { width: 48px; height: 48px; font-size: 20px; }
.cm-name { position: absolute; left: 10px; bottom: 10px; background: rgba(0, 0, 0, .55); padding: 3px 8px; border-radius: 6px; font-size: 13px; }
.cm-name:empty { display: none; }
.cm-self { position: absolute; right: 16px; bottom: 16px; width: 22%; max-width: 260px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #0b1215; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); display: none; }
.cm-self.on { display: block; }
.cm-self video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cm-self.screen video { transform: none; object-fit: contain; }
.cm-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9db0b6; }
.callmedia > audio { display: none; }

/* the Calls section */
.list .item.missed .name { color: var(--danger); }

/* Settings, "Audio and video" */
.card .rowline.device { align-items: flex-end; }
.card .rowline.device .caption { margin-bottom: 4px; }
.card .device-note { margin: 10px 0; }
.card .row.end { display: flex; justify-content: flex-end; margin-top: 10px; }
.devtest { position: relative; height: 180px; border-radius: 14px; overflow: hidden; background: #10191d; color: #eef3f4; font-size: 13px; }
.devtest video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0b1215; transform: scaleX(-1); display: none; }
.devtest .dt-meter, .devtest .dt-idle { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; text-align: center; }
.devtest .dt-idle { color: #9db0b6; }
.devtest[data-show=camera] video { display: block; }
.devtest[data-show=meter] .dt-meter { display: flex; }
.devtest[data-show=idle] .dt-idle { display: flex; }
.devtest .dt-bar { width: 80%; height: 14px; border-radius: 7px; background: #1b2b31; overflow: hidden; }
.devtest .dt-level { width: 0; height: 100%; background: #4cc38a; transition: width 60ms linear; }
.devtest .dt-caption { color: #c9d6da; }

@media (max-width: 820px) {
    .call-btn { padding: 0 14px; }
    .call-btn.accept, .call-btn.end { min-width: 0; }
    .cm-self { width: 30%; right: 10px; bottom: 10px; }
}

/* ---- Bots, Marketplace and Bot Monitor (js/botsui.js, js/marketui.js, js/monitorui.js): bot-channel screens, not end-to-end encrypted */

a.btn { text-decoration: none; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em; border-radius: 8px; padding: 1px 7px; vertical-align: middle; flex: none; }
.tag.bot { background: var(--amber); color: #fff; }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.avatar.bot { background: color-mix(in srgb, var(--brand) 16%, var(--card)); color: var(--brand); }
.hero-tile { width: 72px; height: 72px; border-radius: 20px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--brand) 16%, var(--card)); color: var(--brand); }
.hero-tile .icon { width: 32px; height: 32px; }
.placeholder .narrow { max-width: 440px; }
.list .tools.stack > * + * { margin-top: 8px; }
.list .tools.stack .caption { margin-bottom: -4px; }
.dialog .para { margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }

.bubble .options { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.bubble .options .btn { justify-content: flex-start; text-align: left; white-space: normal; }
.bubble a.file { text-decoration: none; }
.banner.error-bar { background: color-mix(in srgb, var(--danger) 14%, var(--card)); }

.infobar { display: flex; gap: 10px; align-items: center; border-radius: 14px; padding: 8px 8px 8px 14px; font-size: 14px; background: var(--surface); }
.infobar span { flex: 1; }
.infobar.ok { background: color-mix(in srgb, var(--ok) 16%, var(--card)); }
.infobar.warn { background: color-mix(in srgb, var(--amber) 18%, var(--card)); }
.infobar.error { background: color-mix(in srgb, var(--danger) 14%, var(--card)); }
.chat > .infobar { margin: 0 14px 8px; }

.market .inner { max-width: 1040px; }
.titleline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.titleline h2 { font-size: 20px; }
.titleline h3 { font-size: 20px; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.tools-line .sort { flex: none; width: 200px; }
.listings { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.listing { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 4px; min-height: 150px; min-width: 0; }
.listing:hover { border-color: var(--brand); }
.listing .name { font-weight: 600; }
.listing .desc { flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.price { font-weight: 600; }
.price.big { font-size: 18px; }
.strong { font-weight: 600; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.market .row.wrap, .card .row.wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.listing-page { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.listing-page .detail { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.listing-page h4 { margin: 8px 0 0; font-size: 15px; }
.bullets { margin: 0; padding-left: 20px; }
.shots { display: flex; gap: 8px; overflow-x: auto; }
.shots img { height: 220px; border-radius: 10px; flex: none; }
.sandbox { display: flex; flex-direction: column; gap: 8px; }
.sandbox h3 { margin-bottom: 0; }
.sandbox-log { height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-radius: 12px; padding: 10px; }
.sandbox-log .line { white-space: pre-wrap; overflow-wrap: anywhere; }
.sandbox-log .line.me { align-self: flex-end; text-align: right; }
.card.order h3 { margin-bottom: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.msg.line.right { align-self: flex-end; }
.msg.line.center { align-self: center; }
.msg.line .bubble { border-radius: 16px; }
.msg.line.note .bubble { background: color-mix(in srgb, var(--amber) 25%, var(--card)); }
.who-said { font-size: 12px; font-weight: 600; color: var(--muted); }
.composer { position: relative; }
.menu.up { top: auto; bottom: 58px; right: auto; left: 12px; max-height: 50vh; overflow: auto; }

@media (max-width: 820px) {
    .listing-page { grid-template-columns: minmax(0, 1fr); }
    .tools-line .sort { width: 150px; }
}

/* ---- Flows (js/flowsui.js, js/floweditui.js, js/flowsetupui.js): flows, connectors, own bots, setup; not end-to-end encrypted */

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
label.btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.field.narrow { width: 220px; max-width: 100%; }
select.field { appearance: auto; }
.okay { color: var(--ok); font-size: 14px; margin-top: 10px; }
.builder-card { max-width: 520px; }
.builder-card h3 { font-size: 18px; margin-bottom: 0; }
.flows .tabs, .setupnav { flex-wrap: wrap; }
.flowrow { flex-wrap: wrap; }
.flowrow .grow { min-width: 200px; }
.flowrow .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.card.group { padding: 0 20px; }
.card.group > summary { display: flex; gap: 12px; align-items: center; padding: 14px 0; cursor: pointer; list-style-position: inside; }
.card.group > summary .grow { flex: 1; min-width: 0; }
.card.group[open] > summary { border-bottom: 1px solid var(--line); }
.card.group .rowline:first-of-type { border-top: 0; }

.flowform .formrow, .props .formrow { margin-top: 12px; }
.flowform .formnote { margin: 6px 4px 0; }
.flowform .check { margin: 12px 0 0; }
.code-box { border-radius: 14px; font: 13px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre; overflow: auto; tab-size: 4; resize: vertical; }
.picture-row { align-items: center; flex-wrap: wrap; }
img.avatar { object-fit: cover; }
.picklist { max-height: 320px; overflow: auto; margin-top: 10px; padding: 0 4px; }
.picklist .check { margin: 8px 0; }
.wrapline { flex-wrap: wrap; align-items: center; }
.wrapline .field { min-width: 180px; }

.setup { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.setupnav { display: flex; flex-direction: column; gap: 2px; }
.setupnav .tab { text-align: left; border-bottom: 0; border-left: 2px solid transparent; border-radius: 0 10px 10px 0; }
.setupnav .tab.on { border-left-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.setupbody { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.setupbody .titleline { justify-content: space-between; }

.flowwork { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.flowwork .toolbar { align-items: center; }
.flowwork .flowname { width: 260px; max-width: 100%; font-weight: 600; min-height: 36px; padding: 6px 14px; }
.flowwork .zoom { min-width: 40px; text-align: center; }
.flowbody { flex: 1; min-height: 0; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.flowgrid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.flowgrid.canvasgrid { flex: 1; min-height: 0; align-items: stretch; }
.flowgrid .side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.canvasgrid .side { overflow: auto; }
.steptools { margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field.addstep { width: auto; min-height: 32px; padding: 4px 12px; font-size: 13px; }
.steplist { padding: 6px; }
.step { display: block; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 12px; border-radius: 12px; min-width: 0; }
.step:hover { background: var(--surface); }
.step.on { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.props h3 { margin-bottom: 0; }
.props h4 { margin: 16px 0 0; font-size: 14px; }
.optionrow { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.optionrow .grow { flex: 1; min-width: 140px; }
.arrowrow { padding: 4px 0 !important; }
.flowtest .sandbox-log { height: 220px; }
.flowtest .sandbox-log .line .btn { display: flex; margin-top: 4px; }
.flowtest .titleline { justify-content: space-between; }

/* the designer canvas: the web designer's colours and shapes (SPEC 9.1) */
.board-scroll { overflow: auto; background: #f7f9fb; border: 1px solid var(--line); border-radius: 14px; min-height: 320px; }
.board { position: relative; }
.board-inner {
    position: absolute; left: 0; top: 0; transform-origin: 0 0;
    background-image: linear-gradient(#e3e8ee 1px, transparent 1px), linear-gradient(90deg, #e3e8ee 1px, transparent 1px); background-size: 40px 40px;
}
.edges { position: absolute; left: 0; top: 0; pointer-events: none; }
.edge { fill: none; stroke-width: 2; stroke-linejoin: round; }
.edge.next { stroke: #1976d2; } .head.next { fill: #1976d2; }
.edge.check { stroke: #8e24aa; stroke-dasharray: 6 4; } .head.check { fill: #8e24aa; }
.edge.option { stroke: #43a047; } .head.option { fill: #43a047; }
.edge.back { stroke: #e65100; } .head.back { fill: #e65100; }
.gnode {
    position: absolute; border: 1px solid #0d47a1; background: #1565c0; color: #fff; padding: 0 3px; margin: 0; border-radius: 11px; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 9px; line-height: 1.15; text-align: center; cursor: grab;
    touch-action: none; user-select: none;
}
.gnode span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gnode .b { font-size: 11px; font-weight: 700; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gnode.business { background: #37474f; border-color: #263238; }
.gnode.start { background: #00695c; border-color: #004d40; border-radius: 50%; }
.gnode.end { background: #b71c1c; border-color: #7f0000; border-radius: 50%; }
.gnode.start .b, .gnode.end .b { font-size: 12px; }
.gnode.check { background: #6a1b9a; border: 0; border-radius: 0; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); padding: 0 12px; }
.gnode.option { background: #1b5e20; border-color: #2e7d32; border-radius: 999px; font-size: 10px; }
.gnode.sel { box-shadow: inset 0 0 0 3px #ffb300; }
.gnode.check.sel { background: linear-gradient(#6a1b9a, #6a1b9a) center / calc(100% - 12px) calc(100% - 12px) no-repeat, #ffb300; }
.gnode.target { cursor: crosshair; }
.gnode:focus-visible { outline: 3px solid #ffb300; outline-offset: 2px; }
.gnode.check:focus-visible { outline: 0; background: linear-gradient(#6a1b9a, #6a1b9a) center / calc(100% - 12px) calc(100% - 12px) no-repeat, #fff; }
.tag.kind { color: #fff; background: #1565c0; padding: 2px 8px; }
.tag.kind.check { background: #6a1b9a; }
.tag.kind.option { background: #1b5e20; }

@media (max-width: 820px) {
    .setup { grid-template-columns: minmax(0, 1fr); }
    .setupnav { flex-direction: row; border-bottom: 1px solid var(--line); }
    .setupnav .tab { border-left: 0; border-bottom: 2px solid transparent; border-radius: 0; }
    .setupnav .tab.on { border-bottom-color: var(--brand); }
    .flowgrid, .flowgrid.canvasgrid { grid-template-columns: minmax(0, 1fr); }
    .flowgrid.canvasgrid { flex: none; }
    .board-scroll { height: 60vh; }
    .canvasgrid .side { overflow: visible; }
    .flowwork .flowname { width: 100%; }
    .flowbody { padding: 10px; }
}

/* ---- chat list flags, voice notes, contact cards, app lock */

.item .flag { color: var(--muted); display: inline-flex; flex: none; }
.item.muted .preview { opacity: .8; }
.item .badge.quiet { background: var(--muted); }
.bubble .voice-note .icon { color: inherit; }
.bubble audio.voice { display: block; width: min(280px, 60vw); height: 40px; margin-bottom: 4px; }
.bubble .contact-card { white-space: normal; }
.bubble .contact-card .btn { flex: none; }
.bubble .file .btn.small { flex: none; margin-left: 4px; }
.composer .line.recording { align-items: center; min-height: 42px; }
.composer .line.recording .grow { flex: 1; min-width: 0; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; animation: rec-blink 1.2s ease-in-out infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 44px; }
@keyframes rec-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.banner .btn.small { flex: none; }
.dialog .pick { max-height: 50vh; overflow: auto; }
.field.pin { letter-spacing: .3em; text-align: center; font-size: 20px; }
button.link { border: 0; background: none; color: var(--brand); padding: 0; text-decoration: underline; font: inherit; cursor: pointer; }
@media (max-width: 520px) {
    .banner { flex-wrap: wrap; }
    .banner span { flex-basis: calc(100% - 34px); }
}
.lockform > * + * { margin-top: 10px; }
.lockform .btn .icon { margin-right: 6px; }
@media (max-width: 520px) {
    .card .rowline.lockrow { flex-wrap: wrap; }
    .card .rowline.lockrow .grow { flex-basis: 100%; }
}
