.boke-ai-chat-card {
    --boke-ai-chat-primary: var(--zen-primary, #d4af37);
    --boke-ai-chat-primary-dark: var(--zen-primary-dark, #b8962f);
    --boke-ai-chat-primary-rgb: var(--zen-primary-rgb, 212, 175, 55);
    --boke-ai-chat-text: var(--zen-text, #333);
    --boke-ai-chat-heading: var(--zen-text-heading, #222);
    --boke-ai-chat-muted: var(--zen-text-muted, #999);
    --boke-ai-chat-surface: var(--zen-bg-card, #fff);
    --boke-ai-chat-soft: var(--zen-bg-alt, #f5f5f5);
    --boke-ai-chat-hover: var(--zen-bg-hover, #f9f9f9);
    --boke-ai-chat-border: var(--zen-border, #e9e9e9);
    --boke-ai-chat-border-light: var(--zen-border-light, #f0f0f0);
    --boke-ai-chat-shadow: var(--zen-shadow, rgba(0, 0, 0, 0.08));
    --boke-ai-chat-link: var(--zen-accent, #037ef3);
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 22px;
    padding: 18px;
    border: 1px solid var(--boke-ai-chat-border);
    border-top: 4px solid var(--boke-ai-chat-primary);
    border-radius: var(--zen-radius-lg, 8px);
    background: var(--boke-ai-chat-surface);
    box-shadow: 0 8px 22px var(--boke-ai-chat-shadow);
    color: var(--boke-ai-chat-text);
    font-size: 14px;
    line-height: 1.7;
}

.widget .boke-ai-chat-card {
    margin-bottom: 0;
}

.boke-ai-chat-card *,
.boke-ai-chat-card *::before,
.boke-ai-chat-card *::after {
    box-sizing: border-box;
}

.boke-ai-chat-card__title {
    margin: 0 0 14px;
    color: var(--boke-ai-chat-heading);
    font-size: 18px;
    line-height: 1.35;
    font-weight: 700;
}

.boke-ai-chat-question {
    display: block;
    width: 100%;
    height: 40px;
    min-height: 40px;
    padding: 6px 10px;
    resize: vertical;
    border: 1px solid var(--boke-ai-chat-border);
    border-radius: var(--zen-radius-md, 6px);
    background: var(--boke-ai-chat-surface);
    color: var(--boke-ai-chat-text);
    font: inherit;
}

.boke-ai-chat-question:focus {
    border-color: var(--boke-ai-chat-primary);
    outline: 2px solid rgba(var(--boke-ai-chat-primary-rgb), 0.18);
}

.boke-ai-chat-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.boke-ai-chat-sources {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px 18px;
    margin: 8px 0 0;
    padding: 0;
    border: 0;
    text-align: center;
}

.boke-ai-chat-source-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--boke-ai-chat-primary-dark);
    font: inherit;
    line-height: 1.35;
    cursor: pointer;
}

.boke-ai-chat-source-input {
    position: absolute;
    width: 14px;
    height: 14px;
    margin: 0;
    opacity: 0;
}

.boke-ai-chat-source-dot {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border: 1px solid var(--boke-ai-chat-primary);
    border-radius: 50%;
    background: var(--boke-ai-chat-surface);
}

.boke-ai-chat-source-input:checked + .boke-ai-chat-source-dot::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--boke-ai-chat-primary);
}

.boke-ai-chat-source-option:focus-within .boke-ai-chat-source-dot {
    outline: 2px solid rgba(var(--boke-ai-chat-primary-rgb), 0.22);
    outline-offset: 2px;
}

.boke-ai-chat-source-option.is-active {
    color: var(--boke-ai-chat-heading);
    font-weight: 700;
}

.boke-ai-chat-actions button,
.boke-ai-chat-open-drawer {
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--boke-ai-chat-primary);
    border-radius: var(--zen-radius-md, 6px);
    background: var(--boke-ai-chat-surface);
    color: var(--boke-ai-chat-primary-dark);
    cursor: pointer;
    font: inherit;
    line-height: 1.35;
    text-align: center;
}

.boke-ai-chat-card .boke-ai-chat-actions .boke-ai-chat-submit,
.boke-ai-chat-open-drawer {
    background: var(--boke-ai-chat-primary);
    background-color: var(--boke-ai-chat-primary);
    color: #fff;
}

.boke-ai-chat-card .boke-ai-chat-actions .boke-ai-chat-submit:hover {
    background: var(--boke-ai-chat-primary-dark);
    background-color: var(--boke-ai-chat-primary-dark);
}

.boke-ai-chat-actions button:hover,
.boke-ai-chat-open-drawer:hover {
    border-color: var(--boke-ai-chat-primary-dark);
}

.boke-ai-chat-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.boke-ai-chat-answer {
    margin-top: 12px;
    max-height: 320px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--boke-ai-chat-border-light);
    border-radius: var(--zen-radius-md, 6px);
    background: var(--boke-ai-chat-hover);
    color: var(--boke-ai-chat-text);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.boke-ai-chat-card--drawer .boke-ai-chat-answer {
    min-height: 68px;
}

.boke-ai-chat-card--drawer .boke-ai-chat-answer.has-content {
    max-height: none;
}

.boke-ai-chat-answer p {
    margin: 0 0 0.85em;
}

.boke-ai-chat-answer p:last-child {
    margin-bottom: 0;
}

.boke-ai-chat-answer h3,
.boke-ai-chat-answer h4,
.boke-ai-chat-answer h5 {
    margin: 1em 0 0.5em;
    font-size: 1.08em;
    line-height: 1.45;
}

.boke-ai-chat-answer ul,
.boke-ai-chat-answer ol {
    margin: 0 0 0.85em 1.35em;
    padding: 0;
}

.boke-ai-chat-answer li {
    margin: 0.2em 0;
}

.boke-ai-chat-answer code {
    padding: 0 4px;
    border-radius: 3px;
    background: var(--boke-ai-chat-soft);
    color: var(--boke-ai-chat-primary-dark);
}

.boke-ai-chat-ref {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--boke-ai-chat-link);
    cursor: pointer;
    font: inherit;
}

.boke-ai-chat-ref:hover {
    text-decoration: underline;
}

.boke-ai-chat-materials {
    margin-top: 10px;
}

.boke-ai-chat-materials summary {
    cursor: pointer;
    color: var(--boke-ai-chat-heading);
    font-weight: 600;
}

.boke-ai-chat-material-list {
    margin-top: 8px;
    max-height: 72px;
    overflow: auto;
}

.boke-ai-chat-material-list.has-content,
.boke-ai-chat-materials.has-content .boke-ai-chat-material-list {
    max-height: none;
    overflow: visible;
}

.boke-ai-chat-material {
    padding: 8px 0;
    border-bottom: 1px solid var(--boke-ai-chat-border-light);
}

.boke-ai-chat-material:last-child {
    border-bottom: 0;
}

.boke-ai-chat-material a,
.boke-ai-chat-material strong {
    color: var(--boke-ai-chat-link);
    font-weight: 600;
    text-decoration: none;
}

.boke-ai-chat-material a:hover {
    text-decoration: underline;
}

.boke-ai-chat-material__meta {
    margin-top: 2px;
    color: var(--boke-ai-chat-muted);
    font-size: 12px;
    line-height: 1.5;
}

.boke-ai-chat-material.is-highlighted {
    animation: boke-ai-chat-highlight 1.4s ease;
}

@keyframes boke-ai-chat-highlight {
    0% {
        background: rgba(var(--boke-ai-chat-primary-rgb), 0.22);
    }
    100% {
        background: transparent;
    }
}

.boke-ai-chat-open-drawer,
.boke-ai-chat-full-link {
    display: block;
    width: 100%;
    margin-top: 10px;
}

.boke-ai-chat-full-link {
    color: var(--boke-ai-chat-primary-dark);
    text-align: center;
    text-decoration: none;
}

.boke-ai-chat-full-link:hover {
    text-decoration: underline;
}

.boke-ai-chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 99980;
    background: rgba(0, 0, 0, 0.32);
}

.boke-ai-chat-overlay[hidden],
.boke-ai-chat-drawer[hidden] {
    display: none !important;
}

.boke-ai-chat-drawer {
    --boke-ai-chat-primary: var(--zen-primary, #d4af37);
    --boke-ai-chat-primary-dark: var(--zen-primary-dark, #b8962f);
    --boke-ai-chat-primary-rgb: var(--zen-primary-rgb, 212, 175, 55);
    --boke-ai-chat-text: var(--zen-text, #333);
    --boke-ai-chat-heading: var(--zen-text-heading, #222);
    --boke-ai-chat-muted: var(--zen-text-muted, #999);
    --boke-ai-chat-surface: var(--zen-bg-card, #fff);
    --boke-ai-chat-soft: var(--zen-bg-alt, #f5f5f5);
    --boke-ai-chat-hover: var(--zen-bg-hover, #f9f9f9);
    --boke-ai-chat-border: var(--zen-border, #e9e9e9);
    --boke-ai-chat-border-light: var(--zen-border-light, #f0f0f0);
    --boke-ai-chat-shadow: var(--zen-shadow, rgba(0, 0, 0, 0.08));
    --boke-ai-chat-link: var(--zen-accent, #037ef3);
    position: fixed;
    bottom: 0;
    left: 50%;
    z-index: 99990;
    display: flex;
    flex-direction: column;
    width: min(80vw, 640px);
    height: auto;
    max-height: min(68vh, calc(100vh - 28px));
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
    background: var(--boke-ai-chat-surface);
    box-shadow: 0 -18px 38px var(--boke-ai-chat-shadow);
    overflow: hidden;
}

.boke-ai-chat-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 22px 9px;
    border-bottom: 1px solid var(--boke-ai-chat-border-light);
}

.boke-ai-chat-drawer__header h2 {
    margin: 0;
    color: var(--boke-ai-chat-heading);
    font-size: 19px;
    line-height: 1.28;
}

.boke-ai-chat-drawer__header p {
    margin: 2px 0 0;
    color: var(--boke-ai-chat-muted);
    font-size: 13px;
    line-height: 1.45;
}

.boke-ai-chat-icon-button {
    width: 30px;
    height: 30px;
    border: 1px solid var(--boke-ai-chat-border);
    border-radius: 50%;
    background: var(--boke-ai-chat-surface);
    color: var(--boke-ai-chat-text);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.boke-ai-chat-card--drawer {
    flex: 0 1 auto;
    min-height: 0;
    overflow: auto;
    margin: 0;
    padding: 14px 22px 18px;
    border: 0;
    border-radius: 0;
    background: var(--boke-ai-chat-surface);
    box-shadow: none;
}

.boke-ai-chat-floating {
    position: fixed;
    right: 15px;
    bottom: calc(104px + env(safe-area-inset-bottom));
    z-index: 99970;
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--zen-border, #e9e9e9);
    border-radius: 50%;
    background: var(--zen-bg-card, #fff);
    color: var(--zen-primary-dark, #b8962f);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    overflow: hidden;
    line-height: 1;
    opacity: 0.45;
    transition: all 0.2s;
}

.boke-ai-chat-floating:hover {
    background: var(--zen-bg-card, #fff);
    background-color: var(--zen-bg-card, #fff);
    color: var(--zen-primary-dark, #b8962f);
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.boke-ai-chat-floating__icon {
    display: block;
    font-size: 18px;
    line-height: 1;
    transform: translateY(-1px);
}

html.boke-ai-chat-open {
    overflow: hidden;
}

@media (max-width: 782px) {
    .boke-ai-chat-drawer {
        width: 100%;
        height: auto;
        max-height: min(74vh, calc(100vh - 24px));
        border-radius: 12px 12px 0 0;
    }

    .boke-ai-chat-drawer__header {
        padding: 10px 16px 9px;
    }

    .boke-ai-chat-card--drawer {
        padding: 16px;
    }

    .boke-ai-chat-floating {
        display: flex;
    }
}
