:root {
    --kg-bg: #ffffff;
    --kg-panel: #ffffff;
    --kg-text: #171717;
    --kg-muted: #6b6b6b;
    --kg-border: #e2e2e2;
    --kg-soft: #f5f5f5;
    --kg-dark: #171717;
    --kg-accent: #ef2b75;
}

.kg-intelligence-app {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    color: var(--kg-text);
    font-family: Inter, Arial, Helvetica, sans-serif;
}

.kg-intelligence-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    border: 1px solid var(--kg-border);
    border-radius: 18px 18px 0 0;
    background: var(--kg-panel);
}

.kg-intelligence-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kg-intelligence-logo {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--kg-dark);
    color: white;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .5px;
}

.kg-intelligence-brand strong,
.kg-intelligence-brand span {
    display: block;
}

.kg-intelligence-brand strong {
    font-size: 16px;
}

.kg-intelligence-brand span {
    margin-top: 2px;
    color: var(--kg-muted);
    font-size: 13px;
}

.kg-intelligence-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--kg-muted);
    font-size: 13px;
}

.kg-intelligence-status span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.kg-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 430px;
    max-height: 640px;
    overflow-y: auto;
    padding: 38px 28px;
    border-right: 1px solid var(--kg-border);
    border-left: 1px solid var(--kg-border);
    background: var(--kg-bg);
    scroll-behavior: smooth;
}

.kg-chat-welcome {
    width: 100%;
    max-width: 760px;
    margin: auto;
    text-align: center;
}

.kg-welcome-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 18px;
    border: 1px solid var(--kg-border);
    border-radius: 18px;
    background: var(--kg-soft);
    font-size: 28px;
}

.kg-chat-welcome h2 {
    margin: 0 0 10px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.08;
}

.kg-chat-welcome p {
    max-width: 620px;
    margin: 0 auto 26px;
    color: var(--kg-muted);
    font-size: 16px;
    line-height: 1.55;
}

.kg-suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    text-align: left;
}

.kg-suggestion {
    padding: 16px;
    border: 1px solid var(--kg-border);
    border-radius: 14px;
    background: white;
    color: var(--kg-text);
    cursor: pointer;
    text-align: left;
    transition: transform .2s, background .2s, border-color .2s;
}

.kg-suggestion:hover {
    transform: translateY(-1px);
    border-color: #cfcfcf;
    background: #fafafa;
}

.kg-suggestion strong,
.kg-suggestion span {
    display: block;
}

.kg-suggestion strong {
    margin-bottom: 4px;
    font-size: 14px;
}

.kg-suggestion span {
    color: var(--kg-muted);
    font-size: 12px;
    line-height: 1.4;
}

.kg-message-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kg-message-row.user {
    align-items: flex-end;
}

.kg-message-label {
    color: var(--kg-muted);
    font-size: 12px;
    font-weight: 700;
}

.kg-message-bubble {
    max-width: 82%;
    padding: 15px 17px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.kg-message-row.user .kg-message-bubble {
    background: var(--kg-soft);
}

.kg-message-row.assistant .kg-message-bubble {
    max-width: 100%;
    padding: 0;
    background: transparent;
}

.kg-message-bubble h2,
.kg-message-bubble h3 {
    margin: 20px 0 8px;
    font-size: 18px;
}

.kg-message-bubble p {
    margin: 0 0 12px;
}

.kg-message-bubble ul,
.kg-message-bubble ol {
    margin: 8px 0 16px 22px;
}

.kg-message-bubble li {
    margin-bottom: 5px;
}

.kg-user-image {
    width: auto;
    max-width: 320px;
    max-height: 280px;
    margin-top: 10px;
    border-radius: 12px;
    object-fit: contain;
}

.kg-image-preview {
    padding: 12px 18px 0;
    border-right: 1px solid var(--kg-border);
    border-left: 1px solid var(--kg-border);
    background: white;
}

.kg-image-preview[hidden] {
    display: none;
}

.kg-image-preview-card {
    display: flex;
    align-items: center;
    gap: 11px;
    width: fit-content;
    max-width: 100%;
    padding: 9px;
    border: 1px solid var(--kg-border);
    border-radius: 13px;
}

.kg-image-preview-card img {
    width: 52px;
    height: 52px;
    border-radius: 9px;
    object-fit: cover;
}

.kg-image-preview-card span {
    display: block;
    max-width: 260px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
}

.kg-image-preview-card button {
    margin-top: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #c62828;
    cursor: pointer;
    font-size: 12px;
}

.kg-chat-form {
    padding: 14px;
    border: 1px solid var(--kg-border);
    border-radius: 0 0 18px 18px;
    background: var(--kg-panel);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .06);
}

.kg-chat-form textarea {
    display: block;
    width: 100%;
    min-height: 42px;
    max-height: 180px;
    padding: 8px 7px 12px;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--kg-text);
    font: inherit;
    font-size: 16px;
    line-height: 1.5;
    box-shadow: none;
}

.kg-chat-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kg-attach-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    border-radius: 11px;
    color: var(--kg-muted);
    cursor: pointer;
    font-size: 13px;
}

.kg-attach-button:hover {
    background: var(--kg-soft);
}

.kg-attach-icon {
    font-size: 20px;
    line-height: 1;
}

.kg-send-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--kg-dark);
    color: white;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.kg-send-button:disabled {
    cursor: wait;
    opacity: .5;
}

.kg-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--kg-muted);
}

.kg-loading::before {
    content: "";
    width: 15px;
    height: 15px;
    border: 2px solid #ddd;
    border-top-color: #333;
    border-radius: 50%;
    animation: kg-spin .8s linear infinite;
}

@keyframes kg-spin {
    to { transform: rotate(360deg); }
}

.kg-cta-card {
    margin-top: 22px;
    padding: 18px;
    border: 1px solid var(--kg-border);
    border-radius: 14px;
    background: var(--kg-soft);
    text-align: center;
}

.kg-cta-card strong {
    display: block;
    margin-bottom: 12px;
    font-size: 15px;
}

.kg-cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 20px;
    border-radius: 11px;
    background: var(--kg-dark);
    color: white !important;
    font-weight: 700;
    text-decoration: none !important;
}

.kg-error {
    padding: 13px;
    border: 1px solid #efc2c2;
    border-radius: 12px;
    background: #fff4f4;
    color: #9d2222;
    font-size: 14px;
}

.kg-intelligence-disclaimer {
    max-width: 720px;
    margin: 12px auto 0;
    color: #8a8a8a;
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
}

@media (max-width: 700px) {
    .kg-intelligence-header {
        align-items: flex-start;
    }

    .kg-intelligence-status {
        display: none;
    }

    .kg-chat-messages {
        min-height: 380px;
        padding: 28px 16px;
    }

    .kg-suggestion-grid {
        grid-template-columns: 1fr;
    }

    .kg-message-bubble {
        max-width: 94%;
    }

    .kg-attach-button span:last-child {
        display: none;
    }
}
