.fiam-chat[hidden], .fiam-chat [hidden] { display: none !important; }

.fiam-chat {
    --chat-green: #174932;
    --chat-dark: #133526;
    --chat-light: #edf4e9;
    --chat-muted: #4d6758;
    position: fixed;
    z-index: 9999;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    color: var(--chat-dark);
    font: 400 15px/1.45 system-ui, sans-serif;
}

.fiam-chat button, .fiam-chat input { font: inherit; }
.fiam-chat button { cursor: pointer; }
.fiam-chat button:disabled { cursor: default; opacity: .65; }
.fiam-chat :focus-visible { outline: 2px solid #287345; outline-offset: 3px; }
.fiam-chat-header :focus-visible { outline-color: #fff; }

.fiam-chat-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding: 12px 18px;
    min-height: 48px;
    border: 0;
    border-radius: 100px;
    background: var(--chat-green);
    color: #fff;
    box-shadow: 0 5px 19px #13352633;
}

.fiam-chat .fiam-chat-toggle { font-weight: 700; }
.fiam-chat-toggle:hover { background: var(--chat-dark); }

.fiam-chat-icon {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 13px;
    border: 2px solid currentColor;
    border-radius: 5px;
}

.fiam-chat-icon::after {
    content: "";
    position: absolute;
    left: 2px;
    bottom: -4px;
    width: 5px;
    height: 5px;
    border: solid currentColor;
    border-width: 0 0 2px 2px;
    background: var(--chat-green);
    transform: skewY(-35deg);
}

.fiam-chat-panel {
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 36px));
    height: min(520px, calc(100vh - 90px));
    height: min(520px, calc(100dvh - 90px));
    margin: 0 0 11px;
    overflow: hidden;
    border: 1px solid #ceded0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 14px 42px #13352633;
}

.fiam-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    padding: 13px 16px;
    background: var(--chat-green);
    color: #fff;
}

.fiam-chat-header h2 { margin: 0; color: inherit; font-size: 19px; line-height: 1.25; letter-spacing: normal; }
.fiam-chat-header p { margin: 3px 0 0; color: #e2f1e2; font-size: 13px; }

.fiam-chat .fiam-chat-close {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 25px;
}

.fiam-chat-main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px; }
.fiam-chat-intro { margin: 0 0 12px; }
.fiam-chat-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.fiam-chat .fiam-chat-topics button {
    min-height: 36px;
    padding: 5px 9px;
    border-radius: 8px;
    border: 1px solid #ceded0;
    background: #fff;
    color: var(--chat-green);
    font-size: 13px;
    text-align: left;
}
.fiam-chat-topics button:hover { background: var(--chat-light); }

.fiam-chat-log { display: flex; flex-direction: column; gap: 8px; }
.fiam-chat-message { max-width: 92%; margin: 0; padding: 9px 11px; border-radius: 10px; overflow-wrap: anywhere; white-space: pre-wrap; }
.fiam-chat-reply { align-self: flex-start; background: var(--chat-light); }
.fiam-chat-user { align-self: flex-end; background: var(--chat-green); color: #fff; }
.fiam-chat-message a { display: block; margin-top: 5px; font-weight: 650; color: var(--chat-green); }

.fiam-chat-footer { flex: 0 0 auto; padding: 9px 14px 12px; border-top: 1px solid #dce7dc; background: #fff; }
.fiam-chat-form { display: flex; gap: 7px; margin: 0; }
.fiam-chat .fiam-chat-form input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #9caf9f;
    border-radius: 7px;
    color: var(--chat-dark);
    background: #fff;
    font-size: 16px;
}
.fiam-chat-form button { padding: 8px 12px; border: 0; border-radius: 7px; background: var(--chat-green); color: #fff; }
.fiam-chat-note, .fiam-chat-status { margin: 5px 0; color: var(--chat-muted); font-size: 12px; }
.fiam-chat-contact { color: var(--chat-green); font-size: 13px; font-weight: 700; }

@media (max-width: 480px) {
    .fiam-chat { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
    .fiam-chat-panel { width: min(390px, calc(100vw - 24px)); }
}
