/* ============================================================
   The Qubibyte Virtual Assistant (js/assistant-boot.js, js/assistant.js):
   the round chat button in the bottom-right corner and the chat panel it
   opens. Loaded in <head> on every page that has it, so both are styled
   in the first frame.

   Self-contained on purpose. It sits on pages with very different
   stylesheets (Bootstrap, the Qubi docs, the /ai page's paper look), so
   every size is in px, not rem, and every element it uses is given its
   own margins, fonts and colours rather than inheriting a page's.

   Colours follow the site's theme (data-theme on <html>, set before the
   first paint by js/theme-boot-inline.js): the navbar account menu's
   flat navy surface and hairlines on the dark themes, white on light,
   with the brand purple (#6B5FC7 / #554A9E) for the button.

   No animation runs on load. The panel only eases in when it is opened by
   a click (.qba-anim, added by js/assistant.js), never when it is restored
   open on a new page.
   ============================================================ */

.qba {
    --qba-surface: #0d0e1f;
    --qba-surface-2: #14162b;
    --qba-raised: #1a1d36;
    --qba-ink: #eef1fb;
    --qba-muted: #99a1c4;
    --qba-faint: #6c749a;
    --qba-line: rgba(150, 170, 255, 0.16);
    --qba-line-strong: rgba(150, 170, 255, 0.30);
    --qba-accent: #7dd3fc;
    --qba-link: #a5b4fc;
    --qba-bubble: #6b5fc7;
    --qba-bubble-edge: #8478dc;
    --qba-bubble-ink: #ffffff;
    --qba-user: #3b3477;
    --qba-user-ink: #f4f2ff;
    --qba-code-bg: #0a0a1a;
    --qba-code-head: #12142a;
    --qba-code-ink: #e2e8f0;
    --qba-error: #f6828b;
    --qba-error-bg: rgba(246, 130, 139, 0.10);
    --qba-warn: #fbbf24;
    --qba-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    --qba-bubble-shadow: 0 6px 20px rgba(20, 14, 60, 0.55), 0 2px 5px rgba(0, 0, 0, 0.35);
    --qba-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --qba-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace;
    /* The effort colours of the simulator's chip. */
    --qba-medium: #7dd3fc;
    --qba-deep: #c084fc;
}

html[data-theme="light"] .qba {
    --qba-surface: #ffffff;
    --qba-surface-2: #f6f7fb;
    --qba-raised: #ffffff;
    --qba-ink: #151932;
    --qba-muted: #5b6285;
    --qba-faint: #8189a8;
    --qba-line: rgba(40, 50, 120, 0.12);
    --qba-line-strong: rgba(40, 50, 120, 0.24);
    --qba-accent: #2563eb;
    --qba-link: #4f46e5;
    --qba-bubble: #554a9e;
    --qba-bubble-edge: #6b5fc7;
    --qba-user: #554a9e;
    --qba-user-ink: #ffffff;
    --qba-code-bg: #f8fafc;
    --qba-code-head: #eef1f7;
    --qba-code-ink: #1e293b;
    --qba-error: #c0342c;
    --qba-error-bg: rgba(192, 52, 44, 0.07);
    --qba-warn: #b45309;
    --qba-shadow: 0 18px 50px rgba(20, 30, 70, 0.18), 0 2px 8px rgba(20, 30, 70, 0.08);
    --qba-bubble-shadow: 0 6px 18px rgba(60, 50, 140, 0.35), 0 2px 5px rgba(20, 30, 70, 0.18);
    --qba-medium: #2563eb;
    --qba-deep: #9333ea;
}

html[data-theme="midnight"] .qba {
    --qba-surface: #111a2e;
    --qba-surface-2: #16213a;
    --qba-raised: #1b2742;
    --qba-ink: #e2e8f0;
    --qba-muted: #94a3b8;
    --qba-faint: #64748b;
    --qba-line: rgba(148, 163, 184, 0.16);
    --qba-line-strong: rgba(148, 163, 184, 0.30);
    --qba-accent: #38bdf8;
    --qba-link: #7dd3fc;
    --qba-bubble: #0e7cc0;
    --qba-bubble-edge: #38a5e0;
    --qba-user: #1e4a77;
    --qba-user-ink: #f0f9ff;
    --qba-code-bg: #0c1222;
    --qba-code-head: #131c31;
    --qba-code-ink: #e2e8f0;
    --qba-bubble-shadow: 0 6px 20px rgba(2, 20, 50, 0.6), 0 2px 5px rgba(0, 0, 0, 0.35);
}

html[data-theme="quantum"] .qba {
    --qba-surface: #1f0d2c;
    --qba-surface-2: #271336;
    --qba-raised: #2d1740;
    --qba-ink: #f5f0ff;
    --qba-muted: rgba(245, 240, 255, 0.66);
    --qba-faint: rgba(245, 240, 255, 0.45);
    --qba-line: rgba(217, 70, 239, 0.18);
    --qba-line-strong: rgba(217, 70, 239, 0.34);
    --qba-accent: #e879f9;
    --qba-link: #f0abfc;
    --qba-bubble: #a21caf;
    --qba-bubble-edge: #c026d3;
    --qba-user: #5b1a6e;
    --qba-user-ink: #fdf4ff;
    --qba-code-bg: #12081a;
    --qba-code-head: #1c0d27;
    --qba-code-ink: rgba(245, 240, 255, 0.92);
    --qba-bubble-shadow: 0 6px 20px rgba(40, 0, 50, 0.6), 0 2px 5px rgba(0, 0, 0, 0.35);
    --qba-medium: #7dd3fc;
    --qba-deep: #f0abfc;
}

/* ── Reset: nothing of the page's own element styles gets in ───────────── */

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

.qba {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 0;
    height: 0;
    z-index: 1045;
    font-family: var(--qba-sans);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 400;
    letter-spacing: normal;
    text-align: left;
    color: var(--qba-ink);
}

.qba [hidden] {
    display: none !important;
}

.qba p,
.qba h2,
.qba h3,
.qba h4,
.qba ul,
.qba ol,
.qba li,
.qba pre,
.qba blockquote {
    margin: 0;
    padding: 0;
    font-family: inherit;
    color: inherit;
    letter-spacing: normal;
    text-transform: none;
    text-shadow: none;
}

.qba button,
.qba textarea {
    font-family: inherit;
    letter-spacing: normal;
    text-transform: none;
}

.qba svg {
    display: block;
    flex: none;
}

/* ── The button ──────────────────────────────────────────────────────── */

.qba-bubble {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--qba-bubble-edge);
    border-radius: 50%;
    background: var(--qba-bubble);
    color: var(--qba-bubble-ink);
    box-shadow: var(--qba-bubble-shadow);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.qba-bubble:hover {
    transform: translateY(-1px);
    background: var(--qba-bubble-edge);
}

.qba-bubble:active {
    transform: translateY(0);
}

.qba-bubble:focus-visible {
    outline: 2px solid var(--qba-bubble-ink);
    outline-offset: -5px;
    box-shadow: var(--qba-bubble-shadow), 0 0 0 3px color-mix(in srgb, var(--qba-bubble) 45%, transparent);
}

.qba-ico-dot {
    fill: var(--qba-bubble);
}

.qba-bubble:hover .qba-ico-dot {
    fill: var(--qba-bubble-edge);
}

/* Open: the chat icon becomes a chevron that closes it. */
.qba-ico-down {
    display: none !important;
}

.qba.is-open .qba-ico-chat {
    display: none !important;
}

.qba.is-open .qba-ico-down {
    display: block !important;
}

/* Something new in the chat (a page it took you to, seen on a phone). */
.qba-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--qba-accent);
    border: 2px solid var(--qba-bubble);
    display: none;
}

.qba.has-unread .qba-dot {
    display: block;
}

/* ── The panel ───────────────────────────────────────────────────────── */

.qba-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 400px;
    height: 620px;
    max-height: calc(100vh - 116px);
    max-height: calc(100dvh - 116px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--qba-line-strong);
    border-radius: 16px;
    background: var(--qba-surface);
    box-shadow: var(--qba-shadow);
    overflow: hidden;
    color-scheme: dark;
}

html[data-theme="light"] .qba-panel {
    color-scheme: light;
}

/* Only when opened by a click: never on a restored page. */
.qba-panel.qba-anim {
    animation: qba-in 0.16s ease-out;
    transform-origin: bottom right;
}

@keyframes qba-in {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .qba-panel.qba-anim { animation: none; }
    .qba-bubble { transition: none; }
}

.qba-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 10px 0 16px;
    border-bottom: 1px solid var(--qba-line);
    background: var(--qba-surface);
}

.qba-head-mark {
    width: 30px;
    height: 30px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--qba-bubble);
    color: #fff;
}

.qba-head-mark svg {
    width: 16px;
    height: 16px;
}

.qba .qba-title {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    color: var(--qba-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qba-icon-btn {
    width: 34px;
    height: 34px;
    flex: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--qba-muted);
    cursor: pointer;
}

.qba-icon-btn:hover {
    background: color-mix(in srgb, var(--qba-ink) 8%, transparent);
    color: var(--qba-ink);
}

.qba-icon-btn:focus-visible,
.qba-chip:focus-visible,
.qba-code-btn:focus-visible,
.qba-signin:focus-visible,
.qba-go:focus-visible {
    outline: 2px solid var(--qba-accent);
    outline-offset: 1px;
}

/* ── Signed out ──────────────────────────────────────────────────────── */

.qba-out,
.qba-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 28px 32px;
}

.qba-out {
    flex: 1;
}

.qba-welcome {
    min-height: 100%;
}

.qba-welcome-mark {
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--qba-bubble) 22%, transparent);
    color: var(--qba-bubble-edge);
}

html[data-theme="light"] .qba-welcome-mark {
    color: var(--qba-bubble);
    background: color-mix(in srgb, var(--qba-bubble) 12%, transparent);
}

.qba-welcome-mark svg {
    width: 24px;
    height: 24px;
}

.qba .qba-welcome-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 24px;
    margin-bottom: 6px;
}

.qba .qba-welcome-text {
    font-size: 13.5px;
    line-height: 20px;
    color: var(--qba-muted);
    max-width: 300px;
}

.qba-signin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    margin-top: 20px;
    padding: 0 26px;
    border-radius: 8px;
    background: var(--qba-bubble);
    border: 1px solid var(--qba-bubble-edge);
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
}

.qba-signin:hover {
    background: var(--qba-bubble-edge);
}

.qba-suggest {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}

.qba-chip {
    height: 32px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--qba-line-strong);
    border-radius: 16px;
    background: transparent;
    color: var(--qba-ink);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 30px;
    cursor: pointer;
}

.qba-chip:hover {
    background: color-mix(in srgb, var(--qba-ink) 7%, transparent);
}

/* ── The conversation ────────────────────────────────────────────────── */

.qba-chat {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.qba-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 16px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--qba-line-strong) transparent;
    outline: none;
}

.qba-msg {
    margin: 0 0 14px;
    min-width: 0;
}

.qba-msg--user {
    display: flex;
    justify-content: flex-end;
}

.qba-bubble-text {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 14px 14px 4px 14px;
    background: var(--qba-user);
    color: var(--qba-user-ink);
    font-size: 14px;
    line-height: 20px;
    overflow-wrap: anywhere;
    white-space: normal;
}

.qba-msg--note {
    display: flex;
    justify-content: center;
}

.qba-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 10px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--qba-ink) 6%, transparent);
    color: var(--qba-muted);
    font-size: 12px;
    line-height: 18px;
}

.qba-note svg {
    width: 12px;
    height: 12px;
}

/* ── Rendered answers (the safe markdown in js/assistant.js) ───────────── */

.qba-md {
    font-size: 14px;
    line-height: 21px;
    color: var(--qba-ink);
    overflow-wrap: anywhere;
}

.qba-md > * + * {
    margin-top: 9px;
}

.qba-md h3,
.qba-md h4 {
    font-weight: 650;
    color: var(--qba-ink);
}

.qba-md h3 {
    font-size: 15.5px;
    line-height: 22px;
    margin-top: 14px;
}

.qba-md h4 {
    font-size: 14px;
    line-height: 20px;
    margin-top: 12px;
}

.qba-md > h3:first-child,
.qba-md > h4:first-child {
    margin-top: 0;
}

.qba-md ul,
.qba-md ol {
    padding-left: 22px;
}

.qba-md ul {
    list-style: disc;
}

.qba-md ol {
    list-style: decimal;
}

.qba-md ul ul {
    list-style: circle;
}

.qba-md li {
    margin: 3px 0 0;
    padding-left: 2px;
}

.qba-md li > ul,
.qba-md li > ol {
    margin-top: 3px;
}

.qba-md strong {
    font-weight: 650;
}

.qba-md em {
    font-style: italic;
}

.qba-md a,
.qba-sources a,
.qba-go {
    color: var(--qba-link);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--qba-link) 45%, transparent);
    text-underline-offset: 2px;
}

.qba-md a:hover,
.qba-sources a:hover {
    text-decoration-color: currentColor;
}

/* An outside address: shown, never linked. */
.qba-ext {
    color: var(--qba-muted);
    overflow-wrap: anywhere;
}

.qba-md blockquote {
    padding: 2px 0 2px 12px;
    border-left: 3px solid var(--qba-line-strong);
    color: var(--qba-muted);
}

.qba-md :not(pre) > code {
    padding: 1px 5px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--qba-ink) 9%, transparent);
    font-family: var(--qba-mono);
    font-size: 12.5px;
    color: var(--qba-ink);
    white-space: break-spaces;
}

/* The caret while an answer is being written. */
.qba-typing::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 15px;
    margin-left: 2px;
    vertical-align: -2px;
    border-radius: 1px;
    background: var(--qba-muted);
    animation: qba-blink 1s steps(2, start) infinite;
}

@keyframes qba-blink {
    to { visibility: hidden; }
}

/* Before the first word arrives. */
.qba-thinking {
    display: inline-flex;
    gap: 5px;
    padding: 6px 0;
}

.qba-thinking span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--qba-faint);
    animation: qba-pulse 1.2s ease-in-out infinite;
}

.qba-thinking span:nth-child(2) { animation-delay: 0.15s; }
.qba-thinking span:nth-child(3) { animation-delay: 0.3s; }

@keyframes qba-pulse {
    0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}

/* ── Code blocks ─────────────────────────────────────────────────────── */

.qba-code {
    border: 1px solid var(--qba-line-strong);
    border-radius: 10px;
    background: var(--qba-code-bg);
    overflow: hidden;
}

.qba-code-head {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 6px 0 12px;
    border-bottom: 1px solid var(--qba-line);
    background: var(--qba-code-head);
}

.qba-code-lang {
    flex: 1;
    min-width: 0;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--qba-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qba-code-btn {
    height: 24px;
    margin: 0;
    padding: 0 9px;
    border: 1px solid var(--qba-line-strong);
    border-radius: 6px;
    background: transparent;
    color: var(--qba-muted);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 22px;
    white-space: nowrap;
    cursor: pointer;
}

.qba-code-btn:hover {
    color: var(--qba-ink);
    background: color-mix(in srgb, var(--qba-ink) 7%, transparent);
}

.qba-code-btn--sim {
    color: var(--qba-ink);
}

.qba .qba-pre {
    margin: 0;
    padding: 10px 12px;
    max-height: 340px;
    overflow: auto;
    background: transparent;
    border: 0;
    font-family: var(--qba-mono);
    font-size: 12.5px;
    line-height: 19px;
    color: var(--qba-code-ink);
    white-space: pre;
    tab-size: 4;
    scrollbar-width: thin;
}

.qba-pre code {
    display: block;
    padding: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    white-space: inherit;
}

/* The Qubi editor's token colours (simulator/styles/main.css, as the Qubi
   docs copy them in qubi/manual.css), on the dark code well. */
.qba-pre .token-default { color: var(--qba-code-ink); }
.qba-pre .token-comment { color: #96addb; font-style: italic; }
.qba-pre .token-preprocessor { color: #f472b6; font-weight: 500; }
.qba-pre .token-gate { color: #c084fc; font-weight: 600; }
.qba-pre .token-keyword { color: #9295ff; font-weight: 600; }
.qba-pre .token-number { color: #fbbf24; }
.qba-pre .token-target-qubits { color: #60a5fa; }
.qba-pre .token-control-qubits { color: #63d4b6; }
.qba-pre .token-invalid { color: #ef4444; text-decoration: wavy underline; text-decoration-color: #ef4444; }

/* Darker on white, so every token still reads. */
html[data-theme="light"] .qba-pre .token-comment { color: #5b6f99; }
html[data-theme="light"] .qba-pre .token-preprocessor { color: #be185d; }
html[data-theme="light"] .qba-pre .token-gate { color: #7e22ce; }
html[data-theme="light"] .qba-pre .token-keyword { color: #4f46e5; }
html[data-theme="light"] .qba-pre .token-number { color: #b45309; }
html[data-theme="light"] .qba-pre .token-target-qubits { color: #1d4ed8; }
html[data-theme="light"] .qba-pre .token-control-qubits { color: #0f766e; }
html[data-theme="light"] .qba-pre .token-invalid { color: #dc2626; text-decoration-color: #dc2626; }

/* A circuit that did not pass the simulator's check. */
.qba .qba-code-note {
    padding: 8px 12px;
    border-top: 1px solid var(--qba-line);
    background: var(--qba-error-bg);
    color: var(--qba-error);
    font-size: 12px;
    line-height: 17px;
    overflow-wrap: anywhere;
}

/* ── Circuits (js/circuit-draw.js, as the Forum embeds them) ──────────── */

.qba-circuit {
    border-top: 1px solid var(--qba-line);
}

.qba-circuit-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px 0;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--qba-muted);
}

.qba-circuit-head svg {
    width: 13px;
    height: 13px;
    color: #10b981;
}

/* The builder's canvas colour on every theme, as the Forum's figures have it. */
.qba-circuit-figure {
    margin: 7px 8px 8px;
    padding: 10px 8px;
    border-radius: 8px;
    background: #0a0a1a;
    overflow: auto;
    max-height: 300px;
    display: flex;
    scrollbar-width: thin;
    scrollbar-color: #6b5fc7 transparent;
}

.qba-circuit-figure .cq {
    flex: 0 0 auto;
    margin: auto;
}

/*
 * The drawing's own rules. They live in css/account.css and
 * css/circuit-results.css on the Forum and profiles, which are far too large
 * to load on every page for this, so the parts the drawing needs are copied
 * here (values unchanged), scoped to the assistant.
 */
.qba .cq {
    position: relative;
    font-family: var(--qba-sans);
    --pr-faint: #8189a8;
}

.qba .cq-qlabel {
    position: absolute;
    left: 0;
    width: 30px;
    text-align: center;
    font-size: 10.5px;
    font-weight: 600;
    color: #94a3b8;
    line-height: 18px;
}

.qba .cq-wire {
    position: absolute;
    height: 2px;
    background: #6b5fc7;
    opacity: 0.6;
    transform: translateY(-1px);
}

.qba .cq-bus {
    position: absolute;
    width: 4px;
    background: var(--cq-color);
}

.qba .cq-tile {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    border-radius: 8px;
    border: 2px solid var(--cq-edge);
    background: var(--cq-color);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.qba .cq-tile-label {
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
}

.qba .cq-tile-sub {
    font-size: 6.7px;
    font-weight: 600;
    line-height: 1;
    opacity: 0.95;
    margin-top: 1px;
    white-space: nowrap;
}

.qba .cq-tile:has(.cq-tile-sub) .cq-tile-label {
    font-size: 11.8px;
}

.qba .cq-param {
    position: absolute;
    transform: translateX(-50%);
    font-size: 9px;
    line-height: 1;
    padding: 0 2px;
    border-radius: 3px;
    background: #0a0a1a;
    color: var(--pr-faint);
    white-space: nowrap;
    pointer-events: none;
    z-index: 3;
}

.qba .cq-disc {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--cq-edge);
    background: var(--cq-color);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.qba .cq-disc-label {
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
}

.qba .cq-disc-arrow {
    font-size: 5.76px;
    font-weight: 600;
    line-height: 1;
    margin-top: 1px;
    max-width: 30px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qba .cq-measure-block {
    position: absolute;
    border-radius: 8px;
    border: 2px solid #059669;
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.9), rgba(5, 150, 105, 0.9));
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    z-index: 0;
}

.qba .cq-tile,
.qba .cq-disc {
    z-index: 2;
}

.qba .cq-tile--measure {
    background: #10b981;
    border-color: #34d399;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.qba .cq-tile--if {
    border-style: dashed;
}

.qba .cq-tile-if {
    position: absolute;
    top: -6px;
    right: -6px;
    padding: 0 3px;
    border-radius: 6px;
    background: #0ea5e9;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    line-height: 11px;
    letter-spacing: 0.02em;
}

.qba .cq-more {
    position: absolute;
    color: #94a3b8;
    font-size: 17.6px;
    line-height: 20px;
}

.qba .cq-x { --cq-color: #ef4444; --cq-edge: #dc2626; }
.qba .cq-y { --cq-color: #22c55e; --cq-edge: #16a34a; }
.qba .cq-z { --cq-color: #3b82f6; --cq-edge: #2563eb; }
.qba .cq-h { --cq-color: #a855f7; --cq-edge: #9333ea; }
.qba .cq-phase { --cq-color: #06b6d4; --cq-edge: #0891b2; }
.qba .cq-swap { --cq-color: #f97316; --cq-edge: #ea580c; }
.qba .cq-measure { --cq-color: #10b981; --cq-edge: #059669; }
.qba .cq-default { --cq-color: #6b5fc7; --cq-edge: #554a9e; }

/* ── Loops, conditions, function bars, annotations ────────────────────────────
   The builder's control-flow blocks (components.css .control-flow-*), the
   function-call header bars (main.css .qubi-fn-span-bar) and the annotation
   boxes (.circuit-annotation), scaled with the tiles (50px -> 34px). */

.qba .cq .cq-cf {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 0.5rem;
    box-sizing: border-box;
    overflow: visible;
    z-index: 1;
}

.qba .cq .cq-cf--loop {
    background: linear-gradient(180deg, rgba(168, 85, 247, 0.9), rgba(139, 92, 246, 0.9));
    border: 2px solid #7c3aed;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.qba .cq .cq-cf--end {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
    border: 2px solid #dc2626;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.qba .cq .cq-cf--if {
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.9), rgba(2, 132, 199, 0.9));
    border: 2px solid #0369a1;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.qba .cq .cq-cf--else {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.9), rgba(217, 119, 6, 0.9));
    border: 2px solid #b45309;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.qba .cq .cq-cf-symbol {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.qba .cq .cq-cf--if .cq-cf-symbol,
.qba .cq .cq-cf--else .cq-cf-symbol {
    font-size: 10.5px;
    font-style: italic;
}

.qba .cq .cq-cf-label {
    font-size: 9px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 4px;
    border-radius: 3px;
    max-width: 44px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.qba .cq .cq-cf-end {
    font-size: 7px;
    font-weight: 500;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    max-width: 31px;
    overflow-wrap: break-word;
}

.qba .cq .cq-cf-cond {
    font-size: 7px;
    font-weight: 600;
    line-height: 1.15;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 3px;
    border-radius: 3px;
    text-align: center;
    max-width: 31px;
    overflow-wrap: break-word;
}

.qba .cq .cq-fn {
    position: absolute;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 0 5px;
    border-radius: 4px;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    z-index: 4;
}

.qba .cq .cq-fn-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qba .cq .cq-ann {
    position: absolute;
    box-sizing: border-box;
    padding: 1px 5px;
    border-radius: 3px;
    /* components.css: the primary colour 18% over the surface, border 42%. */
    background: #2a2b51;
    border: 1px solid #3b3c80;
    color: #e2e8f0;
    font-size: 8px;
    line-height: 13px;
    overflow: hidden;
    white-space: nowrap;
    z-index: 4;
}

.qba .cq .cq-ann--error {
    background: #593534;
    border-color: #91333a;
    color: #fecaca;
}

.qba .cq .cq-ann-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A LABEL name in place of q[n]. */
.qba .cq .cq-qlabel--custom {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A branch that does not run, as the builder's .reality-inactive. */
.qba .cq .cq-dim {
    opacity: 0.28;
    filter: grayscale(1);
}

/* ── Under an answer ─────────────────────────────────────────────────── */

.qba-sources {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin-top: 10px;
    font-size: 12px;
    line-height: 17px;
    color: var(--qba-faint);
}

.qba-sources-label {
    font-weight: 600;
}

.qba-go {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
}

.qba .qba-meta {
    margin-top: 8px;
    font-size: 11.5px;
    line-height: 16px;
    color: var(--qba-faint);
    font-variant-numeric: tabular-nums;
}

.qba-error {
    margin-top: 8px;
    padding: 8px 11px;
    border-radius: 8px;
    background: var(--qba-error-bg);
    color: var(--qba-error);
    font-size: 13px;
    line-height: 19px;
}

.qba-error a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* ── The composer ────────────────────────────────────────────────────── */

.qba-composer {
    flex: none;
    padding: 8px 12px 10px;
    border-top: 1px solid var(--qba-line);
    background: var(--qba-surface);
}

.qba-inputbox {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 6px 6px 6px 12px;
    border: 1px solid var(--qba-line-strong);
    border-radius: 12px;
    background: var(--qba-surface-2);
}

.qba-inputbox:focus-within {
    border-color: color-mix(in srgb, var(--qba-accent) 70%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--qba-accent) 16%, transparent);
}

.qba .qba-input {
    flex: 1;
    min-width: 0;
    display: block;
    height: 32px;
    min-height: 32px;
    max-height: 140px;
    margin: 0;
    padding: 6px 0;
    border: 0;
    outline: none;
    background: transparent;
    box-shadow: none;
    color: var(--qba-ink);
    font-size: 14px;
    line-height: 20px;
    resize: none;
    overflow-y: auto;
    scrollbar-width: thin;
}

.qba .qba-input::placeholder {
    color: var(--qba-faint);
    opacity: 1;
}

.qba-send {
    width: 32px;
    height: 32px;
    flex: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9px;
    background: var(--qba-bubble);
    color: #fff;
    cursor: pointer;
}

.qba-send:hover:not(:disabled) {
    background: var(--qba-bubble-edge);
}

.qba-send:disabled {
    background: color-mix(in srgb, var(--qba-ink) 12%, transparent);
    color: var(--qba-faint);
    cursor: default;
}

.qba-send:focus-visible {
    outline: 2px solid var(--qba-accent);
    outline-offset: 2px;
}

.qba-ico-stop {
    display: none !important;
}

.qba-send.is-stop .qba-ico-send {
    display: none !important;
}

.qba-send.is-stop .qba-ico-stop {
    display: block !important;
}

.qba-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 28px;
    margin-top: 6px;
}

.qba-count {
    font-size: 11.5px;
    color: var(--qba-faint);
    font-variant-numeric: tabular-nums;
}

.qba-count.at-limit {
    color: var(--qba-warn);
}

.qba .qba-cost {
    min-height: 16px;
    font-size: 11.5px;
    line-height: 16px;
    color: var(--qba-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── The model picker: the simulator's (simulator/styles/main.css), here
   opening upwards from the composer. ─────────────────────────────────── */

.qba-mode {
    position: relative;
    display: inline-flex;
}

.qba-model-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 200px;
    height: 26px;
    margin: 0 0 0 -6px;
    padding: 0 7px 0 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--qba-ink);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.qba-model-btn:hover,
.qba-model-btn[aria-expanded="true"] {
    background: color-mix(in srgb, var(--qba-ink) 7%, transparent);
    border-color: var(--qba-line-strong);
}

.qba-model-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--qba-accent) 30%, transparent);
}

.qba-model-effort {
    color: var(--qba-muted);
    font-weight: 500;
}

.qba-model-btn[data-mode="medium"] .qba-model-effort,
.qba-model-btn[data-mode="medium21"] .qba-model-effort { color: var(--qba-medium); }
.qba-model-btn[data-mode="high"] .qba-model-effort,
.qba-model-btn[data-mode="high21"] .qba-model-effort { color: var(--qba-deep); }

.qba-mode-caret {
    width: 11px;
    height: 11px;
    color: var(--qba-muted);
    transition: transform 0.15s;
}

.qba-model-btn[aria-expanded="true"] .qba-mode-caret {
    transform: rotate(180deg);
}

/* Deliberately neutral (2026-10-14 restyle, the simulator's menu in
   simulator/styles/main.css and /ai's paper and ink): a plain grey surface
   with a hairline border and a soft shadow, plain-text rows, a check by the
   chosen model, near-invisible zebra rows, small uppercase section labels
   and flat segmented switches. The brand colour appears only as the
   keyboard focus ring (--qm-focus). Dark, midnight and quantum share the
   dark values; light overrides below. */
.qba-mode-menu {
    --qm-bg: #1b1b1e;
    --qm-border: rgba(255, 255, 255, 0.10);
    --qm-line: rgba(255, 255, 255, 0.08);
    --qm-ink: #ececee;
    --qm-ink-2: #c9c9ce;
    --qm-muted: #8e8e96;
    --qm-faint: #66666e;
    --qm-zebra: rgba(255, 255, 255, 0.018);
    --qm-hover: rgba(255, 255, 255, 0.06);
    --qm-seg-bg: rgba(255, 255, 255, 0.035);
    --qm-seg-on: #323236;
    --qm-seg-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
    --qm-focus: color-mix(in srgb, var(--qba-bubble-edge) 75%, #ffffff);
    position: absolute;
    left: -6px;
    bottom: calc(100% + 6px);
    z-index: 5;
    width: 248px;
    max-width: calc(100vw - 24px);
    padding: 4px;
    border: 1px solid var(--qm-border);
    border-radius: 8px;
    background: var(--qm-bg);
    color: var(--qm-ink);
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
}

html[data-theme="light"] .qba-mode-menu {
    --qm-bg: #ffffff;
    --qm-border: rgba(0, 0, 0, 0.10);
    --qm-line: rgba(0, 0, 0, 0.07);
    --qm-ink: #1a1a1c;
    --qm-ink-2: #3f3f45;
    --qm-muted: #6e6e76;
    --qm-faint: #a1a1a8;
    --qm-zebra: rgba(0, 0, 0, 0.016);
    --qm-hover: rgba(0, 0, 0, 0.045);
    --qm-seg-bg: #f4f4f5;
    --qm-seg-on: #ffffff;
    --qm-seg-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.06);
    --qm-focus: var(--qba-bubble-edge);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
}

.qba-mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 32px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--qm-ink);
    text-align: left;
    cursor: pointer;
}

.qba-mode-option.is-alt {
    background: var(--qm-zebra);
}

.qba-mode-option:hover,
.qba-mode-option:focus-visible {
    outline: none;
    background: var(--qm-hover);
}

.qba-mode-option:focus-visible {
    box-shadow: inset 0 0 0 1.5px var(--qm-focus);
}

.qba-mode-others-btn {
    color: var(--qm-muted);
}

.qba-mode-others-btn .qba-mode-text strong {
    color: inherit;
    font-weight: 400;
}

.qba-mode-others-btn:hover,
.qba-mode-others-btn:focus-visible {
    color: var(--qm-ink);
}

.qba-mode-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.qba-mode-text strong {
    font-size: 13px;
    font-weight: 400;
    line-height: 16px;
}

.qba-mode-option[aria-checked="true"] .qba-mode-text strong {
    font-weight: 500;
}

.qba-mode-check {
    flex: none;
    width: 14px;
    height: 14px;
    color: var(--qm-ink);
    visibility: hidden;
}

.qba-mode-option[aria-checked="true"] .qba-mode-check {
    visibility: visible;
}

.qba-mode-sep {
    height: 1px;
    margin: 4px -4px;
    background: var(--qm-line);
}

/* "Other models": opens the older models in place (assistant.js), at the
   same indent as the rows above, a touch muted. */
.qba-mode-chevron {
    flex: none;
    width: 14px;
    height: 14px;
    color: var(--qm-muted);
    transition: transform 0.15s;
}

.qba-mode-others-btn[aria-expanded="true"] .qba-mode-chevron {
    transform: rotate(90deg);
}

.qba-mode-others,
.qba-mode-others.qba-is-flat {
    margin: 0;
    padding: 0;
    border: 0;
}

.qba-mode-others:not(.qba-is-flat) .qba-mode-option:not([aria-checked="true"]):not(:hover):not(:focus-visible) {
    color: var(--qm-ink-2);
}

.qba-mode-others[hidden] {
    display: none;
}

.qba .qba-where-msg a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--qm-faint);
    text-underline-offset: 2px;
}

.qba .qba-where-msg a:hover {
    color: var(--qm-ink);
    text-decoration-color: currentColor;
}

.qba-effort {
    padding: 8px;
}

.qba-effort-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 16px;
    margin-bottom: 8px;
    padding: 0;
}

.qba-effort-label {
    flex: none;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--qm-muted);
}

.qba-effort-hint {
    min-width: 0;
    font-size: 11px;
    line-height: 16px;
    color: var(--qm-muted);
    text-align: right;
}

.qba-effort-seg {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--qm-line);
    border-radius: 6px;
    background: var(--qm-seg-bg);
}

.qba-effort-opt {
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--qm-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.qba-effort-opt:hover:not(:disabled) {
    color: var(--qm-ink);
}

.qba-effort-opt:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1.5px var(--qm-focus);
}

.qba-effort-opt[aria-checked="true"] {
    background: var(--qm-seg-on);
    color: var(--qm-ink);
    font-weight: 500;
    box-shadow: var(--qm-seg-shadow);
}

.qba-effort-opt[aria-checked="true"]:focus-visible {
    box-shadow: var(--qm-seg-shadow), 0 0 0 1.5px var(--qm-focus);
}

.qba-effort-opt:disabled {
    cursor: not-allowed;
    color: var(--qm-faint);
    opacity: 0.6;
}

.qba-effort-opt[aria-checked="true"]:disabled {
    background: transparent;
    box-shadow: none;
}

.qba-effort.is-off .qba-effort-label {
    color: var(--qm-faint);
}

.qba-mode-more {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    color: var(--qm-muted) !important;
    font-size: 12px;
    line-height: 16px;
    text-decoration: none !important;
    text-underline-offset: 3px;
}

.qba-mode-more svg {
    flex: none;
    width: 11px;
    height: 11px;
}

.qba-mode-more:hover,
.qba-mode-more:focus-visible {
    outline: none;
    color: var(--qm-ink) !important;
    text-decoration: underline !important;
}

.qba-mode-more:focus-visible {
    box-shadow: inset 0 0 0 1.5px var(--qm-focus);
}

/* ── Fermi: "Environment" (in the effort row's place) ─────────────────── */

.qba-where-seg {
    grid-template-columns: repeat(2, 1fr);
}

.qba-where-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.qba-where-status[hidden] {
    display: none;
}

.qba-where-dot {
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--qm-faint);
}

.qba-where-status[data-state="loading"] .qba-where-dot { background: #f59e0b; }
.qba-where-status[data-state="blocked"] .qba-where-dot { background: #f59e0b; }
.qba-where-status[data-state="ready"] .qba-where-dot { background: #22c55e; }

.qba .qba-where-msg,
.qba .qba-where-err {
    margin: 8px 0 0;
    padding: 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--qm-muted);
}

.qba .qba-where-err {
    color: var(--qba-error);
}

.qba #qba-pair-help {
    margin-top: 4px;
    font-size: 11px;
}

.qba-where-pair {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--qm-line);
}

.qba-where-pair-label {
    display: block;
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: var(--qm-ink);
}

.qba-where-pair-row {
    display: flex;
    gap: 4px;
}

.qba .qba-pair-code {
    flex: 1;
    min-width: 0;
    height: 28px;
    margin: 0;
    padding: 0 8px;
    border: 1px solid var(--qm-border);
    border-radius: 6px;
    background: var(--qm-seg-bg);
    color: var(--qm-ink);
    font-family: var(--qba-mono);
    font-size: 13px;
    letter-spacing: 0.18em;
    box-shadow: none;
}

.qba .qba-pair-code::placeholder {
    color: var(--qm-faint);
}

.qba .qba-pair-code:focus {
    outline: none;
    border-color: var(--qm-focus);
    box-shadow: 0 0 0 1px var(--qm-focus);
}

.qba-pair-btn {
    flex: none;
    height: 28px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--qm-border);
    border-radius: 6px;
    background: var(--qm-seg-on);
    color: var(--qm-ink);
    font-size: 12px;
    font-weight: 500;
    line-height: 26px;
    cursor: pointer;
}

.qba-pair-btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--qm-ink) 8%, var(--qm-seg-on));
}

.qba-pair-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1.5px var(--qm-focus);
}

.qba-pair-btn:disabled {
    cursor: default;
    opacity: 0.6;
}

/* ── Fermi: a circuit being built on this computer (a ```fermi-local block) ── */

.qba-fl {
    padding: 10px 12px;
    border: 1px dashed var(--qba-line-strong);
    border-radius: 10px;
    background: var(--qba-surface-2);
}

.qba-fl-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 17px;
    color: var(--qba-ink);
}

.qba-fl-spin,
.qba-fl-mark {
    flex: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid var(--qba-line-strong);
}

.qba-fl-spin {
    border-top-color: var(--qba-accent);
    animation: qba-spin 0.9s linear infinite;
}

@keyframes qba-spin {
    to { transform: rotate(360deg); }
}

.qba .qba-fl-req {
    margin: 4px 0 0 21px;
    font-size: 11.5px;
    line-height: 16px;
    color: var(--qba-muted);
    overflow-wrap: anywhere;
}

.qba .qba-fl-err {
    margin: 8px 0 0;
    padding: 6px 9px;
    border-radius: 7px;
    background: var(--qba-error-bg);
    color: var(--qba-error);
    font-size: 12px;
    line-height: 17px;
    overflow-wrap: anywhere;
}

.qba-fl .qba-fl-btn {
    margin: 8px 0 0 21px;
    color: var(--qba-ink);
}

.qba-fl[data-state="error"] .qba-fl-btn,
.qba-fl[data-state="cloudfail"] .qba-fl-btn {
    margin-left: 0;
}

@media (prefers-reduced-motion: reduce) {
    .qba-fl-spin { animation-duration: 2.4s; }
}

/* For screen readers only. */
.qba-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ── Phones: the open panel is the whole screen ──────────────────────── */

@media (max-width: 640px) {
    .qba-bubble {
        right: 16px;
        bottom: 16px;
    }

    .qba-panel {
        inset: 0;
        width: auto;
        height: auto;
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .qba-panel.qba-anim {
        transform-origin: bottom center;
    }

    /* The panel has its own close button; the page behind does not scroll. */
    .qba.is-open .qba-bubble {
        display: none;
    }

    html.qba-is-open,
    html.qba-is-open body {
        overflow: hidden !important;
    }

    .qba-composer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* 16px stops iOS zooming into the field when it is focused. */
    .qba .qba-input {
        font-size: 16px;
    }
}

@media print {
    .qba {
        display: none !important;
    }
}
