.bombyx-assistant {
    --bombyx-assistant-accent: #0e756b;
    --bombyx-assistant-accent-text: #ffffff;
    --bombyx-assistant-background: #ffffff;
    --bombyx-assistant-text: #111827;
    --bombyx-assistant-radius: 16px;
    --bombyx-assistant-launcher-font-size: 14px;
    --bombyx-assistant-launcher-padding-y: 13px;
    --bombyx-assistant-launcher-padding-x: 18px;
}

.bombyx-assistant--inline {
    width: 100%;
    max-width: 840px;
    margin: 24px auto;
}

.bombyx-assistant__launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483647;
    border: 0;
    border-radius: 999px;
    background: var(--bombyx-assistant-accent);
    color: var(--bombyx-assistant-accent-text);
    padding: var(--bombyx-assistant-launcher-padding-y) var(--bombyx-assistant-launcher-padding-x);
    font: 600 var(--bombyx-assistant-launcher-font-size)/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
    cursor: pointer;
}

.bombyx-assistant__panel {
    position: fixed;
    right: 20px;
    bottom: 76px;
    width: min(380px, calc(100vw - 32px));
    height: 560px;
    max-height: calc(100vh - 110px);
    z-index: 2147483647;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #d1d5db;
    border-radius: var(--bombyx-assistant-radius);
    background: var(--bombyx-assistant-background);
    box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
    color: var(--bombyx-assistant-text);
    font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.bombyx-assistant__panel[hidden] {
    display: none;
}

.bombyx-assistant--inline .bombyx-assistant__panel {
    position: relative;
    right: auto;
    bottom: auto;
    z-index: 1;
    width: 100%;
    height: auto;
    max-height: none;
    border-radius: var(--bombyx-assistant-radius);
    box-shadow: 0 16px 40px rgba(15, 23, 42, .16);
}

.bombyx-assistant--inline .bombyx-assistant__launcher {
    display: none;
}

.bombyx-assistant--inline .bombyx-assistant__messages {
    flex: 0 1 auto;
    min-height: 0;
    max-height: min(480px, calc(100vh - 260px));
}

.bombyx-assistant__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    background: var(--bombyx-assistant-accent);
    color: var(--bombyx-assistant-accent-text);
    font-weight: 700;
}

.bombyx-assistant__header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.bombyx-assistant__clear,
.bombyx-assistant__close {
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    color: var(--bombyx-assistant-accent-text);
    padding: 5px 9px;
    font: 600 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
}

.bombyx-assistant__clear {
    white-space: nowrap;
}

.bombyx-assistant__clear-confirm {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 2;
    width: min(220px, calc(100vw - 48px));
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: var(--bombyx-assistant-background);
    color: var(--bombyx-assistant-text);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
    font-weight: 500;
}

.bombyx-assistant__clear-confirm[hidden] {
    display: none;
}

.bombyx-assistant__clear-confirm::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 22px;
    width: 12px;
    height: 12px;
    border-top: 1px solid #d1d5db;
    border-left: 1px solid #d1d5db;
    background: var(--bombyx-assistant-background);
    transform: rotate(45deg);
}

.bombyx-assistant__clear-confirm p {
    margin: 0 0 8px;
}

.bombyx-assistant__clear-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.bombyx-assistant__clear-confirm-actions button {
    border-radius: 999px;
    padding: 5px 10px;
    font: 600 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
}

.bombyx-assistant__clear-cancel {
    border: 1px solid #cbd5e1;
    background: transparent;
    color: var(--bombyx-assistant-text);
}

.bombyx-assistant__clear-confirm-button {
    border: 1px solid var(--bombyx-assistant-accent);
    background: var(--bombyx-assistant-accent);
    color: var(--bombyx-assistant-accent-text);
}

.bombyx-assistant__messages {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: color-mix(in srgb, var(--bombyx-assistant-background) 82%, #f8fafc);
}

.bombyx-assistant__bubble {
    width: fit-content;
    max-width: 88%;
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bombyx-assistant-background);
    border: 1px solid #e5e7eb;
}

.bombyx-assistant__bubble--user {
    margin-left: auto;
    background: var(--bombyx-assistant-accent);
    color: var(--bombyx-assistant-accent-text);
    border-color: var(--bombyx-assistant-accent);
}

.bombyx-assistant__answer p {
    margin: 0 0 10px;
}

.bombyx-assistant__answer p:last-child,
.bombyx-assistant__answer ul:last-child {
    margin-bottom: 0;
}

.bombyx-assistant__answer ul {
    margin: 0 0 10px;
    padding-left: 18px;
}

.bombyx-assistant__answer li + li {
    margin-top: 5px;
}

.bombyx-assistant__refs {
    margin-top: 8px;
    color: #64748b;
    font-size: 12px;
}

.bombyx-assistant__feedback {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    font-size: 12px;
}

.bombyx-assistant__feedback-prompt {
    width: 100%;
    color: #64748b;
    font-weight: 500;
}

.bombyx-assistant__form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: end;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: var(--bombyx-assistant-accent);
    color: var(--bombyx-assistant-accent-text);
    padding: 0;
    font: 600 13px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
}

.bombyx-assistant__form button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.5;
}

.bombyx-assistant__feedback button {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: transparent;
    color: #475569;
    padding: 4px 8px;
    font: 600 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
}

.bombyx-assistant__feedback button:hover,
.bombyx-assistant__feedback button:focus {
    border-color: var(--bombyx-assistant-accent);
    color: var(--bombyx-assistant-text);
}

.bombyx-assistant__feedback label {
    width: 100%;
    color: #475569;
}

.bombyx-assistant__feedback textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
}

.bombyx-assistant__form {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: var(--bombyx-assistant-background);
}

.bombyx-assistant__form textarea {
    min-width: 0;
    min-height: 58px;
    max-height: 132px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 9px 10px;
    font: inherit;
    line-height: 1.4;
    resize: none;
    overflow-y: hidden;
}

.bombyx-assistant__form small {
    grid-column: 1 / -1;
    color: #64748b;
}

.bombyx-assistant__form small a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bombyx-assistant-editor-preview .bombyx-assistant__panel {
    height: auto;
    max-height: none;
}

.bombyx-assistant-editor-preview .bombyx-assistant__messages {
    max-height: none;
}

@media (max-width: 600px) {
    .bombyx-assistant--inline {
        margin: 18px 0;
    }

    .bombyx-assistant--inline .bombyx-assistant__panel {
        height: auto;
        max-height: none;
    }

    .bombyx-assistant--inline .bombyx-assistant__messages {
        max-height: calc(100vh - 220px);
    }
}
