#fifi-root {
    position: relative;
    z-index: 9999;
}

/* Launcher */
.fifi-launcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 68px;
    height: 68px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;

    background: radial-gradient(circle at 35% 30%, #fffdf9 0%, #f8f0e3 72%, #eadcc3 100%);
    box-shadow:
            0 10px 28px rgba(0, 0, 0, 0.20),
            0 0 0 1px rgba(255, 240, 214, 0.55) inset;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.fifi-launcher:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
            0 14px 34px rgba(0, 0, 0, 0.24),
            0 0 0 1px rgba(255, 244, 224, 0.7) inset;
}

.fifi-launcher:active {
    transform: scale(0.98);
}

.fifi-launcher-avatar {
    position: relative;
    z-index: 2;
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 999px;
    animation: fifiFloat 3.1s ease-in-out infinite;
    filter: drop-shadow(0 2px 6px rgba(105, 62, 20, 0.18));
}

.fifi-launcher-ring {
    position: absolute;
    inset: -6px;
    border-radius: 999px;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255, 220, 146, 0.18) 0%, rgba(255, 220, 146, 0.06) 45%, rgba(255, 220, 146, 0) 72%);
    animation: fifiPulse 3.2s ease-in-out infinite;
}

@keyframes fifiFloat {
    0%   { transform: translateY(0px); }
    50%  { transform: translateY(-4px); }
    100% { transform: translateY(0px); }
}

@keyframes fifiPulse {
    0%   { transform: scale(0.96); opacity: 0.45; }
    50%  { transform: scale(1.04); opacity: 0.72; }
    100% { transform: scale(0.96); opacity: 0.45; }
}

/* Panel */
.fifi-panel {
    position: fixed;
    right: 18px;
    bottom: 94px;
    width: 370px;
    max-width: calc(100vw - 24px);
    height: 72vh;
    max-height: 720px;

    display: flex;
    flex-direction: column;
    overflow: hidden;

    border: 1px solid #edd9b7;
    border-radius: 18px;
    background: #fffaf2;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.2);
}

/* Fixed sections */
.fifi-header,
.fifi-meta,
.fifi-inputbar {
    flex: 0 0 auto;
}

/* Header */
.fifi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 16px;

    background: linear-gradient(180deg, #fff1d8 0%, #fde3bd 100%);
    border-bottom: 1px solid #efdcb8;
}

.fifi-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.1;
    color: #8b4513;
}

.fifi-subtitle {
    margin-top: 2px;
    font-size: 10px;
    line-height: 1.2;
    color: #6d4c3d;
}

.fifi-close {
    border: 0;
    background: transparent;
    cursor: pointer;

    font-size: 28px;
    line-height: 1;
    color: #7a533c;
}

/* Meta */
.fifi-meta {
    position: relative;
    z-index: 30;
    padding: 8px 12px;
    background: #fff7ea;
    border-bottom: 1px solid #f0e1c6;
}

.fifi-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.fifi-meta-row + .fifi-meta-row {
    margin-top: 6px;
}

.fifi-profile-hint {
    margin-right: 4px;
    white-space: nowrap;
    font-size: 9px;
    line-height: 1.1;
    color: #8a6a55;
}

.fifi-profile-btn,
.fifi-token-pill,
.fifi-premium-pill {
    border: 1px solid #e9d1a6;
    border-radius: 999px;
    background: #fff;
    color: #4d3428;

    padding: 4px 9px;
    font-size: 10px;
    line-height: 1.1;
}

.fifi-profile-btn {
    cursor: pointer;
}

/* Body */
.fifi-body {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fffdf8;
}

.fifi-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px 14px;
    scrollbar-gutter: stable;
}

.fifi-msg + .fifi-msg {
    margin-top: 14px;
}

.fifi-bubble {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 14px;

    font-size: 12px;
    line-height: 1.55;
    color: #2f241d;
}

.fifi-msg-user {
    display: flex;
    justify-content: flex-end;
}

.fifi-msg-user .fifi-bubble {
    background: #f7dca3;
}

.fifi-msg-assistant .fifi-bubble {
    background: #fff4df;
    border: 1px solid #f0dfba;
}

.fifi-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 14px;
    background: #fffdf8;
}

.fifi-chip {
    border: 1px solid #e7c995;
    border-radius: 999px;
    background: #fff9ef;
    color: #6b4320;
    cursor: pointer;

    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.2;
}

/* Input */
.fifi-inputbar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;

    background: #fff8ec;
    border-top: 1px solid #efdfc2;
}

.fifi-inputbar textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 46px;
    resize: none;

    border: 1px solid #dfcda9;
    border-radius: 12px;
    background: #fff;
    color: #2f241d;

    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.4;
}

.fifi-send {
    flex: 0 0 auto;
    min-width: 64px;
    height: 46px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;

    padding: 0 14px;
    background: #d88a2f;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

/* Profile picker */
.fifi-profile-picker {
    position: relative;
    z-index: 40;
    margin-top: 10px;
}

.fifi-profile-picker-card {
    position: relative;
    z-index: 50;
    padding: 10px;
    border: 1px solid #ecd8b2;
    border-radius: 14px;
    background: #fffaf2;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.fifi-profile-option {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    text-align: left;
    cursor: pointer;

    border: 1px solid #ecd2a0;
    border-radius: 12px;
    background: #fff;
    color: #4d3428;

    padding: 10px 12px;
    font-size: 12px;
}

.fifi-profile-option + .fifi-profile-option {
    margin-top: 8px;
}

.fifi-profile-option.is-active {
    background: #fff3dd;
    border-color: #dca04a;
}

.fifi-profile-option-name {
    font-weight: 600;
}

.fifi-profile-option-badge {
    border-radius: 999px;
    background: #f6dfb5;
    color: #8b5a22;

    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.1;
}

.fifi-profile-picker-footer {
    margin-top: 10px;
}

.fifi-profile-picker-empty {
    margin-bottom: 10px;
    font-size: 12px;
    line-height: 1.4;
    color: #5c463a;
}

/* Mobile */
@media (max-width: 767px) {
    .fifi-launcher {
        right: 14px;
        bottom: 14px;
        width: 62px;
        height: 62px;
    }

    .fifi-launcher-avatar {
        width: 53px;
        height: 53px;
    }

    .fifi-panel {
        top: env(safe-area-inset-top, 0);
        right: 0;
        bottom: 0;
        left: 0;

        width: 100vw;
        max-width: 100vw;
        height: auto;
        min-height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .fifi-header {
        padding-top: calc(14px + env(safe-area-inset-top, 0));
    }

    .fifi-title {
        font-size: 18px;
    }

    .fifi-subtitle,
    .fifi-profile-hint,
    .fifi-profile-btn,
    .fifi-token-pill,
    .fifi-premium-pill,
    .fifi-bubble,
    .fifi-chip,
    .fifi-inputbar textarea,
    .fifi-send,
    .fifi-profile-option,
    .fifi-profile-picker-empty,
    .fifi-profile-option-badge {
        font-size: 14px;
    }

    .fifi-meta {
        padding: 8px 10px;
    }

    .fifi-profile-btn,
    .fifi-token-pill,
    .fifi-premium-pill {
        padding: 5px 10px;
    }
}