/* ==========================================================================
   FT Chat Widget — Glassmorphism monochrome floating window
   ========================================================================== */

/* --- Design tokens --- */
:root {
    --ft-bg-panel: rgba(8, 8, 8, 0.58);
    --ft-bg-user: rgba(255, 255, 255, 0.18);
    --ft-bg-assistant: rgba(255, 255, 255, 0.06);
    --ft-bg-input: rgba(0, 0, 0, 0.25);
    --ft-bg-input-field: rgba(255, 255, 255, 0.1);
    --ft-text: rgba(255, 255, 255, 0.9);
    --ft-text-muted: rgba(255, 255, 255, 0.45);
    --ft-border: rgba(255, 255, 255, 0.16);
    --ft-border-subtle: rgba(255, 255, 255, 0.1);
    --ft-hover: rgba(255, 255, 255, 0.1);
    --ft-radius: 12px;
    --ft-radius-lg: 16px;
    --ft-panel-w: 420px;
    --ft-panel-h: 560px;
    --ft-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Floating button (small pill) --- */
.ft-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: rgba(20, 20, 20, 0.9);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: box-shadow var(--ft-transition), border-color var(--ft-transition), transform var(--ft-transition);
    line-height: 1;
}

.ft-chat-btn:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.15), 0 4px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.ft-chat-btn:active {
    transform: translateY(0);
}

.ft-chat-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
    opacity: 0.8;
}

/* On very small screens, collapse to icon-only circle */
@media (max-width: 400px) {
    .ft-chat-btn span {
        display: none;
    }
    .ft-chat-btn {
        padding: 10px;
        border-radius: 50%;
    }
}

/* --- Chat panel (floating window) --- */
.ft-chat-panel {
    position: fixed;
    right: 40px;
    bottom: 40px;
    width: var(--ft-panel-w);
    height: var(--ft-panel-h);
    z-index: 10001;
    display: none;
    flex-direction: column;
    background: var(--ft-bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--ft-radius-lg);
    backdrop-filter: blur(36px) saturate(200%);
    -webkit-backdrop-filter: blur(36px) saturate(200%);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--ft-text);
    overflow: hidden;
    position: fixed;
    /* needed for the absolutely positioned resize grip child */

    /* Resizable via JS handles */
    min-width: 300px;
    min-height: 200px;
    max-width: 700px;
    max-height: 90vh;
}

.ft-chat-panel.ft-chat-open {
    display: flex;
}

/* When minimized, fix height */
.ft-chat-panel.ft-chat-minimized {
    height: auto !important;
    min-height: 0;
}

/* Mobile: full-width, anchored at bottom */
@media (max-width: 520px) {
    .ft-chat-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 80vh;
        border-radius: var(--ft-radius-lg) var(--ft-radius-lg) 0 0;
        resize: none;
        max-width: none;
    }
}

/* --- Resize handles (invisible strips + corners with cursor indicators) --- */
.ft-chat-resize-n,
.ft-chat-resize-s,
.ft-chat-resize-e,
.ft-chat-resize-w,
.ft-chat-resize-nw,
.ft-chat-resize-ne,
.ft-chat-resize-sw,
.ft-chat-resize-se {
    position: absolute;
    z-index: 20;
}

/* Edge strips */
.ft-chat-resize-n  { top: 0;    left: 14px;  right: 14px; height: 6px;  cursor: n-resize; }
.ft-chat-resize-s  { bottom: 0; left: 14px;  right: 14px; height: 6px;  cursor: s-resize; }
.ft-chat-resize-w  { left: 0;   top: 14px;   bottom: 14px; width: 6px;  cursor: w-resize; }
.ft-chat-resize-e  { right: 0;  top: 14px;   bottom: 14px; width: 6px;  cursor: e-resize; }

/* Corners — slightly larger hit area */
.ft-chat-resize-nw { top: 0;    left: 0;   width: 14px; height: 14px; cursor: nw-resize;
    border-top-left-radius: var(--ft-radius-lg); }
.ft-chat-resize-ne { top: 0;    right: 0;  width: 14px; height: 14px; cursor: ne-resize;
    border-top-right-radius: var(--ft-radius-lg); }
.ft-chat-resize-sw { bottom: 0; left: 0;   width: 14px; height: 14px; cursor: sw-resize;
    border-bottom-left-radius: var(--ft-radius-lg); }

/* SE corner — diagonal grip visual */
.ft-chat-resize-se {
    bottom: 0; right: 0; width: 18px; height: 18px; cursor: se-resize;
    border-bottom-right-radius: var(--ft-radius-lg);
    background-image:
        linear-gradient(135deg,
            transparent 40%, rgba(255,255,255,0.25) 40%, rgba(255,255,255,0.25) 50%,
            transparent 50%, transparent 65%, rgba(255,255,255,0.25) 65%, rgba(255,255,255,0.25) 75%,
            transparent 75%
        );
}

/* NW corner — mirrored grip visual */
.ft-chat-resize-nw {
    background-image:
        linear-gradient(-45deg,
            transparent 40%, rgba(255,255,255,0.18) 40%, rgba(255,255,255,0.18) 50%,
            transparent 50%, transparent 65%, rgba(255,255,255,0.18) 65%, rgba(255,255,255,0.18) 75%,
            transparent 75%
        );
}

/* --- Panel header (drag handle) --- */
.ft-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ft-border-subtle);
    flex-shrink: 0;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
}

.ft-chat-header-title {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ft-text);
    letter-spacing: 0.01em;
}

/* White dot indicator next to title */
.ft-chat-header-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}

.ft-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ft-chat-btn-export,
.ft-chat-btn-clear,
.ft-chat-btn-minimize,
.ft-chat-btn-close {
    background: none;
    border: none;
    color: var(--ft-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.ft-chat-btn-export:hover,
.ft-chat-btn-clear:hover,
.ft-chat-btn-minimize:hover,
.ft-chat-btn-close:hover {
    color: #fff;
    background: var(--ft-hover);
}

/* Export / New chat carry a label — an icon alone doesn't say what they do,
   and "New chat" in particular has to advertise that it wipes the context. */
.ft-chat-btn-export,
.ft-chat-btn-clear {
    gap: 5px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    border: 1px solid transparent;
}

.ft-chat-btn-export:hover,
.ft-chat-btn-clear:hover {
    border-color: var(--ft-border-subtle);
}

.ft-chat-btn-export svg,
.ft-chat-btn-clear svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    display: block;
    flex: none;
}

/* --- Messages area --- */
.ft-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    background: transparent;
}

/* Custom scrollbar: thin white */
.ft-chat-messages::-webkit-scrollbar {
    width: 3px;
}

.ft-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ft-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Firefox scrollbar */
.ft-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* --- Welcome message --- */
.ft-chat-welcome {
    text-align: center;
    padding: 32px 16px;
    color: var(--ft-text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.ft-chat-welcome strong {
    display: block;
    color: var(--ft-text);
    font-size: 15px;
    margin-bottom: 8px;
    font-weight: 600;
}

/* --- Message bubbles --- */
.ft-chat-msg {
    max-width: 92%;
    animation: ft-chat-fade-in 0.2s ease;
}

@keyframes ft-chat-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ft-chat-msg-user {
    align-self: flex-end;
}

.ft-chat-msg-assistant {
    align-self: flex-start;
}

.ft-chat-bubble {
    padding: 10px 14px;
    border-radius: var(--ft-radius);
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
}

/* User bubble: glass white */
.ft-chat-msg-user .ft-chat-bubble {
    background: var(--ft-bg-user);
    color: var(--ft-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-right-radius: 4px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Assistant bubble: barely visible */
.ft-chat-msg-assistant .ft-chat-bubble {
    background: var(--ft-bg-assistant);
    color: var(--ft-text);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* --- Markdown content inside bubbles --- */
.ft-chat-bubble h1,
.ft-chat-bubble h2,
.ft-chat-bubble h3,
.ft-chat-bubble h4 {
    margin: 10px 0 4px;
    font-weight: 600;
    line-height: 1.3;
    color: #fff;
}

.ft-chat-bubble h1 { font-size: 16px; }
.ft-chat-bubble h2 { font-size: 14.5px; }
.ft-chat-bubble h3 { font-size: 13.5px; }

.ft-chat-bubble p {
    margin: 0 0 8px;
}

.ft-chat-bubble p:last-child {
    margin-bottom: 0;
}

.ft-chat-bubble ul,
.ft-chat-bubble ol {
    margin: 4px 0 8px 18px;
    padding: 0;
}

.ft-chat-bubble li {
    margin-bottom: 2px;
}

.ft-chat-bubble code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12.5px;
    font-family: "Fira Code", "Consolas", "Monaco", monospace;
    color: rgba(255, 255, 255, 0.85);
}

.ft-chat-bubble pre {
    background: rgba(0, 0, 0, 0.35);
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ft-chat-bubble pre code {
    background: none;
    padding: 0;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.ft-chat-bubble a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ft-chat-bubble a:hover {
    color: #fff;
}

.ft-chat-bubble table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12.5px;
    width: 100%;
}

.ft-chat-bubble th,
.ft-chat-bubble td {
    border: 1px solid var(--ft-border);
    padding: 4px 8px;
    text-align: left;
}

.ft-chat-bubble th {
    background: rgba(255, 255, 255, 0.06);
    font-weight: 600;
}

.ft-chat-bubble blockquote {
    border-left: 2px solid rgba(255, 255, 255, 0.25);
    margin: 8px 0;
    padding: 4px 12px;
    color: var(--ft-text-muted);
}

/* --- Next-step options (Claude-Desktop-style list) ---
   Numbered, keyboard-navigable list of follow-up suggestions. Sits
   between bugs and sources. Mouse hover OR ArrowUp/Down/digit keys
   move the highlight; Enter or click submits the highlighted row
   through the normal chat input pipeline. */
.ft-chat-options {
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--ft-radius);
    overflow: hidden;
}

.ft-chat-options-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.5);
    padding: 8px 12px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ft-chat-options-list {
    display: flex;
    flex-direction: column;
}

.ft-chat-option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.88);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.35;
    text-align: left;
    width: 100%;
    transition: background 0.12s;
}

.ft-chat-option-row + .ft-chat-option-row {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.ft-chat-option-row:hover,
.ft-chat-option-row.ft-chat-option-selected {
    background: rgba(255, 255, 255, 0.08);
}

.ft-chat-option-num {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.09);
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.ft-chat-option-row:hover .ft-chat-option-num,
.ft-chat-option-row.ft-chat-option-selected .ft-chat-option-num {
    background: rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.9);
}

.ft-chat-option-text {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ft-chat-option-enter {
    flex: 0 0 auto;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.12s;
}

.ft-chat-option-row:hover .ft-chat-option-enter,
.ft-chat-option-row.ft-chat-option-selected .ft-chat-option-enter {
    opacity: 1;
}

.ft-chat-option-row.ft-chat-option-picked {
    background: rgba(255, 255, 255, 0.16);
}

.ft-chat-option-row.ft-chat-option-picked .ft-chat-option-enter {
    opacity: 1;
}

/* --- Sources --- */
.ft-chat-sources {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ft-chat-sources-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.55);
    opacity: 1;
    margin-bottom: 4px;
}

.ft-chat-source-link {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    padding: 2px 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.15s;
}

.ft-chat-source-link:hover {
    color: #fff;
    opacity: 1;
    text-decoration: underline;
}

.ft-chat-source-score {
    color: var(--ft-text-muted);
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.5;
}

/* --- Search query tags (collapsible) --- */
.ft-chat-queries {
    margin-top: 6px;
}

.ft-chat-queries-toggle {
    background: none;
    border: none;
    color: var(--ft-text-muted);
    font-size: 10px;
    cursor: pointer;
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.ft-chat-queries-toggle:hover {
    opacity: 1;
    color: var(--ft-text);
}

.ft-chat-queries-toggle svg {
    width: 10px;
    height: 10px;
    fill: currentColor;
    transition: transform 0.15s;
}

.ft-chat-queries-toggle.ft-expanded svg {
    transform: rotate(90deg);
}

.ft-chat-queries-list {
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.ft-chat-queries-list.ft-visible {
    display: flex;
}

.ft-chat-query-tag {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.55);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

/* --- Typing indicator --- */
.ft-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--ft-bg-assistant);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--ft-radius);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ft-chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    animation: ft-chat-bounce 1.4s ease-in-out infinite;
}

.ft-chat-typing-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.ft-chat-typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

.ft-chat-typing-model {
    font-size: 10px;
    color: var(--ft-text-muted);
    margin-left: 6px;
    opacity: 0.7;
}

@keyframes ft-chat-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30%           { transform: translateY(-5px); opacity: 0.8; }
}

/* --- Error message --- */
.ft-chat-error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: rgba(255, 180, 180, 0.9);
    padding: 8px 12px;
    border-radius: var(--ft-radius);
    font-size: 12.5px;
    line-height: 1.5;
    align-self: flex-start;
    max-width: 92%;
}

/* --- Input area --- */
.ft-chat-input-area {
    padding: 10px 14px 14px;
    border-top: 1px solid var(--ft-border-subtle);
    background: var(--ft-bg-input);
    flex-shrink: 0;
}

.ft-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ft-chat-input {
    flex: 1;
    resize: none;
    border: none;
    border-radius: 10px;
    background: var(--ft-bg-input-field);
    color: var(--ft-text);
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    min-height: 38px;
    outline: none;
    transition: background 0.15s;
}

.ft-chat-input::placeholder {
    color: var(--ft-text-muted);
}

.ft-chat-input:focus {
    background: rgba(255, 255, 255, 0.12);
}

/* Send button: white circle with dark arrow */
.ft-chat-send {
    background: rgba(255, 255, 255, 0.85);
    color: #000;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s, transform 0.15s;
}

.ft-chat-send:hover {
    background: #fff;
    transform: scale(1.05);
}

.ft-chat-send:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    transform: none;
}

.ft-chat-send svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

/* --- Model selector (pill buttons below input) --- */
.ft-chat-models {
    display: flex;
    gap: 4px;
    padding: 6px 0 2px;
    align-items: center;
}

.ft-chat-model-btn {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    font-family: inherit;
    padding: 3px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

.ft-chat-model-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
}

/* The active model must read as "this one is answering" at a glance — the old
   18%-white fill was nearly indistinguishable from the hover state. */
.ft-chat-model-btn.ft-model-active,
.ft-chat-model-btn.ft-model-active:hover {
    background: rgba(255, 255, 255, 0.92);
    border-color: #fff;
    color: #111;
    font-weight: 600;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* --- Answer footer: vote + re-ask --- */
.ft-chat-answer-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 2px 2px;
}

.ft-chat-answer-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--ft-border-subtle);
    color: var(--ft-text-muted);
    font: inherit;
    font-size: 11px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ft-chat-answer-btn:hover:not(:disabled) {
    background: var(--ft-hover);
    color: #fff;
    border-color: var(--ft-border);
}

.ft-chat-answer-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* A cast vote stays lit so the user can see it registered. */
.ft-chat-vote.ft-vote-cast,
.ft-chat-vote.ft-vote-cast:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: #fff;
    cursor: default;
}

/* Nudged apart from the votes — it's an action, not a rating. */
.ft-chat-reask {
    margin-left: auto;
}

/* --- Overlay for mobile (dim background) --- */
.ft-chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

@media (max-width: 520px) {
    .ft-chat-overlay.ft-chat-overlay-visible {
        display: block;
    }
}

/* --- Clarification card (replaces bot bubble when server asks for clarification) --- */
.ft-chat-clarification {
    align-self: flex-start;
    max-width: 92%;
    background: rgba(255, 200, 80, 0.08);
    border: 1px solid rgba(255, 200, 80, 0.18);
    border-left: 3px solid rgba(255, 200, 80, 0.7);
    border-radius: var(--ft-radius);
    border-bottom-left-radius: 4px;
    padding: 12px 14px;
    color: var(--ft-text);
    animation: ft-chat-fade-in 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.2s, filter 0.2s;
}

.ft-chat-clarification.ft-clarification-dimmed {
    opacity: 0.55;
    filter: grayscale(0.4);
}

.ft-chat-clarification-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ft-chat-clarification-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 200, 80, 0.18);
    color: rgba(255, 220, 140, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.ft-chat-clarification-text {
    flex: 1;
    min-width: 0;
}

.ft-chat-clarification-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.ft-chat-clarification-subtitle {
    font-size: 11px;
    color: var(--ft-text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.ft-chat-clarification-list {
    margin: 10px 0 0 0;
    padding-left: 22px;
    font-size: 13px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.88);
}

.ft-chat-clarification-list li {
    margin: 4px 0;
}

/* --- Bugs (Known issues) section --- */
.ft-chat-bugs {
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 8px;
}

.ft-chat-bugs-toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    width: 100%;
    text-align: left;
}

.ft-chat-bugs-toggle:hover {
    color: #fff;
}

.ft-chat-bugs-toggle-icon {
    transition: transform 0.15s;
    display: inline-block;
    font-size: 10px;
    width: 8px;
}

.ft-chat-bugs-toggle.ft-expanded .ft-chat-bugs-toggle-icon {
    transform: rotate(90deg);
}

.ft-chat-bugs-hint {
    font-size: 11px;
    color: var(--ft-text-muted);
    margin: 4px 0 0;
    line-height: 1.4;
    font-style: italic;
}

.ft-chat-bugs-list {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.ft-chat-bugs-list.ft-visible {
    display: flex;
}

.ft-chat-bug-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ft-text);
    scroll-margin-top: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ft-chat-bug-card.ft-bug-flash {
    border-color: rgba(255, 220, 140, 0.55);
    box-shadow: 0 0 0 2px rgba(255, 220, 140, 0.18);
}

.ft-chat-bug-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    color: var(--ft-text-muted);
}

.ft-chat-bug-id {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.92);
}

.ft-chat-bug-sep {
    opacity: 0.4;
}

.ft-chat-bug-title {
    margin-top: 4px;
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.4;
    cursor: help;
}

.ft-chat-bug-meta {
    font-size: 10.5px;
    color: var(--ft-text-muted);
    margin-top: 3px;
}

.ft-chat-bug-jira {
    font-size: 10.5px;
    color: var(--ft-text-muted);
    margin-top: 3px;
}

.ft-chat-bug-jira a {
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
}

.ft-chat-bug-jira a:hover {
    color: #fff;
    text-decoration: underline;
}

.ft-chat-bug-footer {
    margin-top: 6px;
}

.ft-chat-bug-link {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.16);
    padding: 3px 9px;
    border-radius: 12px;
    display: inline-block;
    line-height: 1.4;
}

.ft-chat-bug-link:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.06);
}

.ft-chat-bug-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.5;
}

.ft-chat-bug-badge.ft-badge-success {
    background: rgba(80, 200, 120, 0.18);
    color: rgba(140, 230, 170, 0.95);
}

.ft-chat-bug-badge.ft-badge-danger {
    background: rgba(220, 80, 80, 0.18);
    color: rgba(255, 170, 170, 0.95);
}

.ft-chat-bug-badge.ft-badge-warning {
    background: rgba(240, 180, 60, 0.18);
    color: rgba(255, 215, 140, 0.95);
}

.ft-chat-bug-badge.ft-badge-neutral {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

/* --- FT-id mention inside answer text --- */
.ft-chat-bug-mention {
    background: rgba(255, 220, 140, 0.14);
    color: rgba(255, 230, 170, 0.95) !important;
    border-bottom: 1px dashed rgba(255, 220, 140, 0.45);
    padding: 0 3px;
    border-radius: 3px;
    text-decoration: none !important;
    font-weight: 600;
    cursor: pointer;
}

.ft-chat-bug-mention:hover {
    background: rgba(255, 220, 140, 0.22);
    color: #fff !important;
}

/* --- Print: hide the widget entirely --- */
@media print {
    .ft-chat-btn,
    .ft-chat-panel,
    .ft-chat-overlay {
        display: none !important;
    }
}
