.an-chat, .an-chat-admin {
    --an-chat-ink: #24211f;
    --an-chat-paper: #fffefa;
    --an-chat-tint: #f1ece5;
    --an-chat-border: #d8cec3;
    color: var(--an-chat-ink);
    font: 15px/1.45 system-ui, sans-serif;
}
.an-chat [hidden], .an-chat-admin [hidden] { display: none !important; }
.an-chat *, .an-chat-admin * { box-sizing: border-box; }
.an-chat { position: fixed; z-index: 1000; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.an-chat__panel {
    position: absolute; right: 0; bottom: 0;
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    display: flex; flex-direction: column; overflow: auto;
    border: 1px solid var(--an-chat-border); border-radius: 15px;
    background: var(--an-chat-paper); box-shadow: 0 12px 36px #231b2229;
}
.an-chat__header { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--an-chat-border); }
.an-chat__header h2, .an-chat-admin h2 { margin: 0; font-size: 17px; line-height: 1.3; }
.an-chat__header h2 { color: inherit; }
.an-chat__close { border: 0; padding: 0 7px; background: transparent; color: inherit; font: 28px/1 system-ui, sans-serif; cursor: pointer; }
.an-chat__toggle, .an-chat__form button {
    border: 0; padding: 10px 14px; border-radius: 8px;
    background: var(--an-chat-ink); color: white; font: inherit; cursor: pointer;
}
.an-chat .an-chat__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    border: 1px solid #D8D2CA;
    border-radius: 999px;
    background: #FAF8F4;
    color: #292624;
    box-shadow: 0 3px 10px #241e181a;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}
.an-chat .an-chat__toggle:active,
.an-chat .an-chat__toggle[aria-expanded="true"] {
    background: #F1ECE5;
}
@media (hover: hover) {
    .an-chat .an-chat__toggle:hover { background: #F1ECE5; }
}
.an-chat__toggle-icon { display: block; flex: none; }
@media (max-width: 599px) {
    .an-chat .an-chat__toggle { width: 48px; height: 48px; padding: 0; }
    .an-chat .an-chat__toggle-label { display: none; }
}
@media (min-width: 600px) and (max-width: 1024px) {
    .an-chat .an-chat__toggle { height: 48px; }
}
.an-chat__form button:disabled { opacity: .52; cursor: default; }
.an-chat__messages { min-height: 96px; max-height: 40vh; overflow: auto; padding: 12px; overscroll-behavior: contain; }
.an-chat__intro { margin: 0 0 8px; color: #504840; }
.an-chat__bubble {
    width: fit-content; max-width: 90%; padding: 8px 11px; margin: 0 0 8px;
    border-radius: 8px 8px 8px 2px; background: var(--an-chat-tint);
}
.an-chat__bubble--mine { margin-left: auto; background: #e9e2da; border-radius: 8px 8px 2px 8px; }
.an-chat__bubble strong { font-size: 12px; }
.an-chat__bubble p { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.an-chat__form { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; }
.an-chat__form textarea {
    min-width: 0; flex: 1; min-height: 44px; padding: 8px;
    border: 1px solid var(--an-chat-border); border-radius: 8px;
    font: inherit; color: inherit; background: white; resize: vertical;
}
.an-chat__status, .an-chat__privacy { margin: 0; padding: 4px 12px; font-size: 12px; }
.an-chat__status:empty { display: none; }
.an-chat__privacy { padding-bottom: 10px; }
.an-chat__privacy a { color: inherit; text-decoration: underline; }
.an-chat__sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.an-chat :focus-visible, .an-chat-admin :focus-visible { outline: 2px solid #70573f; outline-offset: 2px; }
.an-chat-admin { display: grid; grid-template-columns: minmax(210px, 1fr) minmax(0, 2fr); gap: 16px; }
.an-chat-admin__inbox, .an-chat-admin__conversation { min-width: 0; padding: 12px; border: 1px solid var(--an-chat-border); border-radius: 8px; background: var(--an-chat-paper); }
.an-chat-admin__threads { margin: 8px 0; padding: 0; list-style: none; max-height: 65vh; overflow: auto; }
.an-chat-admin__threads button { width: 100%; text-align: left; padding: 8px; border: 0; border-radius: 5px; font: inherit; background: transparent; color: inherit; cursor: pointer; }
.an-chat-admin__threads button:hover, .an-chat-admin__threads button[aria-current="true"] { background: var(--an-chat-tint); }
@media (max-width: 640px) {
    .an-chat-admin { grid-template-columns: 1fr; }
    .an-chat-admin__threads { max-height: 28vh; }
    .an-chat__form textarea { font-size: 16px; }
}

.an-chat-admin__filters, .an-chat-admin__conversation-header {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.an-chat-admin__filters { margin-top: 10px; }
.an-chat-admin__conversation-header { justify-content: space-between; }
.an-chat-admin__filters button, .an-chat-admin__archive-action {
    border: 1px solid var(--an-chat-border); border-radius: 6px;
    padding: 5px 9px; background: var(--an-chat-paper); color: inherit;
    font: inherit; cursor: pointer;
}
.an-chat-admin__filters button[aria-pressed="true"] { background: var(--an-chat-tint); font-weight: 600; }
.an-chat-admin__archive-action { color: #8a3528; }
.an-chat-admin__archive-action:disabled { opacity: .55; cursor: default; }
.an-chat-admin__threads button.an-chat-admin__waiting { background: #fff2d5; box-shadow: inset 3px 0 #a56312; }
.an-chat-admin__threads button.an-chat-admin__waiting[aria-current="true"] { background: #ffe4ac; }
.an-chat-admin__reply-badge {
    display: inline-block; margin-inline-start: 7px; padding: 1px 5px;
    border-radius: 4px; background: #74430e; color: white; font-size: 12px;
}
.an-chat .an-chat__toggle[aria-expanded="true"] { display: none; }

.an-chat .an-chat__messages:not(:has(.an-chat__bubble)) { min-height: 0; padding-bottom: 8px; }
.an-chat .an-chat__messages:not(:has(.an-chat__bubble)) .an-chat__intro { margin-bottom: 0; }
.an-chat .an-chat__form { flex-direction: column; align-items: stretch; padding-top: 0; }
.an-chat .an-chat__form textarea { width: 100%; flex: none; }
.an-chat .an-chat__form button[type="submit"] { align-self: flex-end; background: #CDCDCB; color: #292624; }
