.freddi-root {
    --freddi-accent: #f09c42;
    --freddi-accent-contrast: #000000;
    --freddi-accent-text: #a65400;
    --freddi-surface: #ffffff;
    --freddi-text: #1f2937;
    --freddi-muted: #4b5563;
    --freddi-border: #d1d5db;
    --freddi-user-surface: #fdebd5;
    --freddi-error: #b91c1c;
    --freddi-radius: 12px;
    --freddi-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
    --freddi-font: inherit;
    --freddi-z-index: 2147483000;
    --freddi-panel-width: 380px;
    --freddi-panel-height: 560px;
    font-family: var(--freddi-font);
    color: var(--freddi-text);
    line-height: 1.45;
}

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

.freddi-root--bubble {
    position: fixed;
    bottom: 20px;
    z-index: var(--freddi-z-index);
}

.freddi-root--bubble.freddi-root--right {
    right: 20px;
}

.freddi-root--bubble.freddi-root--left {
    left: 20px;
}

.freddi-toggle {
    width: 60px;
    height: 60px;
    border: 3px solid color-mix(in srgb, var(--freddi-accent) 50%, var(--freddi-surface));
    border-radius: 50%;
    background: var(--freddi-surface);
    color: var(--freddi-text);
    box-shadow: var(--freddi-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.freddi-toggle:focus-visible,
.freddi-button:focus-visible,
.freddi-pill:focus-visible,
.freddi-icon-button:focus-visible,
.freddi-input:focus-visible,
.freddi-link:focus-visible {
    outline: 3px solid var(--freddi-accent-text);
    outline-offset: 2px;
}

.freddi-toggle {
    padding: 0;
    overflow: hidden;
}

.freddi-toggle:hover,
.freddi-toggle[aria-expanded="true"] {
    border-color: var(--freddi-accent);
}

.freddi-toggle__icon {
    display: block;
    width: 100%;
    height: 100%;
    padding: 4px;
    object-fit: contain;
    border-radius: 50%;
}

.freddi-panel {
    display: flex;
    flex-direction: column;
    background: var(--freddi-surface);
    border: 1px solid var(--freddi-border);
    border-radius: var(--freddi-radius);
    overflow: hidden;
}

.freddi-panel[hidden] {
    display: none;
}

.freddi-root--bubble .freddi-panel {
    position: absolute;
    bottom: 76px;
    width: var(--freddi-panel-width);
    max-width: calc(100vw - 40px);
    height: var(--freddi-panel-height);
    max-height: calc(100vh - 120px);
    box-shadow: var(--freddi-shadow);
}

.freddi-root--bubble.freddi-root--right .freddi-panel {
    right: 0;
}

.freddi-root--bubble.freddi-root--left .freddi-panel {
    left: 0;
}

.freddi-root--embedded .freddi-panel {
    min-height: 420px;
    max-height: 720px;
}

.freddi-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--freddi-border);
}

.freddi-header__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.freddi-header__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.freddi-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.freddi-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--freddi-border);
    border-radius: 999px;
    background: var(--freddi-surface);
    color: var(--freddi-text);
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.2;
    cursor: pointer;
}

.freddi-pill .freddi-icon {
    width: 15px;
    height: 15px;
}

.freddi-pill:hover {
    border-color: var(--freddi-accent);
    background: var(--freddi-user-surface);
}

.freddi-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--freddi-muted);
    cursor: pointer;
}

.freddi-icon-button:hover {
    background: #f3f4f6;
    color: var(--freddi-text);
}

.freddi-ai-notice {
    margin: 0;
    padding: 0 16px 10px;
    font-size: 0.72rem;
    text-align: center;
    color: var(--freddi-muted);
}

.freddi-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.freddi-message {
    max-width: 92%;
    padding: 10px 12px;
    border-radius: var(--freddi-radius);
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.freddi-message--user {
    align-self: flex-end;
    background: var(--freddi-user-surface);
    border-bottom-right-radius: 4px;
}

.freddi-message--assistant,
.freddi-message--notice {
    align-self: flex-start;
    background: #f3f4f6;
    border-bottom-left-radius: 4px;
}

.freddi-message--error {
    align-self: flex-start;
    border: 1px solid var(--freddi-error);
    color: var(--freddi-error);
    background: #fef2f2;
}

.freddi-message__body p {
    margin: 0 0 0.5em;
}

.freddi-message__body p:last-child {
    margin-bottom: 0;
}

.freddi-message__body ul,
.freddi-message__body ol {
    margin: 0.25em 0 0.5em;
    padding-left: 1.25em;
}

.freddi-link {
    color: var(--freddi-accent-text);
    text-decoration: underline;
}

.freddi-sources__title {
    margin: 10px 0 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--freddi-muted);
}

.freddi-sources {
    margin: 0;
    padding-left: 1.1em;
    font-size: 0.85rem;
}

.freddi-handoff {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--freddi-border);
}

.freddi-handoff__text {
    margin: 0 0 6px;
    font-size: 0.9rem;
}

.freddi-handoff__links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.freddi-feedback {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--freddi-muted);
}

.freddi-consent {
    margin: 0 16px 8px;
    padding: 10px 12px;
    border: 1px solid var(--freddi-border);
    border-radius: 12px;
    background: var(--freddi-user-surface);
    font-size: 0.82rem;
}

.freddi-consent[hidden],
.freddi-consent-state[hidden] {
    display: none;
}

.freddi-consent__question {
    margin: 0 0 8px;
}

.freddi-consent__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.freddi-consent__yes {
    border-color: var(--freddi-accent);
    background: var(--freddi-accent);
    color: var(--freddi-accent-contrast);
}

.freddi-link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--freddi-accent-text);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.freddi-starters {
    padding: 0 16px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.freddi-starters[hidden] {
    display: none;
}

.freddi-starters__title {
    width: 100%;
    margin: 0;
    font-size: 0.8rem;
    color: var(--freddi-muted);
}

.freddi-typing {
    margin: 0;
    padding: 0 16px 6px;
    font-size: 0.85rem;
    color: var(--freddi-muted);
}

.freddi-typing:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 8px;
}

.freddi-typing[hidden] {
    display: none;
}

.freddi-typing__dots {
    display: inline-flex;
    gap: 3px;
}

.freddi-typing__dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--freddi-accent);
    animation: freddi-bounce 1.2s infinite ease-in-out both;
}

.freddi-typing__dots span:nth-child(1) {
    animation-delay: -0.24s;
}

.freddi-typing__dots span:nth-child(2) {
    animation-delay: -0.12s;
}

@keyframes freddi-bounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .freddi-typing__dots span {
        animation: none;
    }
}

.freddi-form {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin: 4px 12px 8px;
    padding: 6px 6px 6px 14px;
    border: 1px solid var(--freddi-border);
    border-radius: 22px;
    background: var(--freddi-surface);
}

.freddi-form:focus-within {
    border-color: var(--freddi-accent);
    box-shadow: 0 0 0 3px var(--freddi-user-surface);
}

.freddi-form[hidden] {
    display: none;
}

.freddi-input {
    flex: 1 1 auto;
    min-height: 34px;
    max-height: 140px;
    resize: none;
    padding: 7px 0;
    border: 0;
    outline: none;
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.35;
    color: var(--freddi-text);
    background: transparent;
}

.freddi-root .freddi-input:focus-visible {
    outline: none;
}

.freddi-send {
    flex: 0 0 auto;
    background: var(--freddi-border);
    color: var(--freddi-surface);
}

.freddi-form--filled .freddi-send,
.freddi-send:hover {
    background: var(--freddi-accent);
    color: var(--freddi-accent-contrast);
}

.freddi-send:disabled {
    opacity: 0.6;
    cursor: progress;
}

.freddi-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid var(--freddi-accent);
    border-radius: 999px;
    background: var(--freddi-accent);
    color: var(--freddi-accent-contrast);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
}

.freddi-button:disabled {
    opacity: 0.6;
    cursor: progress;
}

.freddi-button--ghost,
.freddi-retry {
    background: transparent;
    color: var(--freddi-accent-text);
}

.freddi-starter {
    border-color: var(--freddi-border);
    border-radius: 999px;
    background: var(--freddi-surface);
    color: var(--freddi-text);
    font-size: 0.85rem;
    text-align: left;
}

.freddi-starter:hover {
    border-color: var(--freddi-accent);
    background: var(--freddi-user-surface);
}

.freddi-handoff__link {
    font-size: 0.85rem;
}

.freddi-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.freddi-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 480px) {
    .freddi-root--bubble .freddi-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .freddi-toggle {
        transition: transform 0.15s ease, border-color 0.15s ease;
    }

    .freddi-toggle:hover {
        transform: scale(1.05);
    }
}

.freddi-contact {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 8px 0;
    padding: 10px;
    border: 1px solid var(--freddi-border);
    border-radius: var(--freddi-radius);
    background: var(--freddi-surface);
}

.freddi-contact__photo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.freddi-contact__name {
    margin: 0;
    font-weight: 600;
    font-size: 0.9rem;
}

.freddi-contact__role {
    margin: 0;
    font-size: 0.8rem;
    color: var(--freddi-muted);
}

.freddi-contact__links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
