.tandyia-chat-panel {
    position: fixed;
    z-index: 49;
    right: 20px;
    bottom: 142px;
    width: min(360px, calc(100vw - 40px));
    max-height: min(620px, calc(100svh - 170px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    overflow: hidden;
    border: 1px solid rgba(76, 30, 12, 0.14);
    border-radius: 8px;
    color: #1a120f;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 60px rgba(76, 30, 12, 0.16);
}

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

.tandyia-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border-bottom: 1px solid rgba(76, 30, 12, 0.12);
}

.tandyia-chat-title {
    display: grid;
    gap: 3px;
}

.tandyia-chat-title strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.15rem;
    font-weight: 500;
}

.tandyia-chat-title span {
    color: #6f6256;
    font-size: 0.82rem;
    font-weight: 800;
}

.tandyia-chat-close {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(76, 30, 12, 0.14);
    border-radius: 999px;
    color: #4c1e0c;
    background: #f4ede2;
    cursor: pointer;
}

.tandyia-chat-messages {
    min-height: 220px;
    max-height: 320px;
    display: grid;
    align-content: start;
    gap: 10px;
    overflow-y: auto;
    padding: 16px;
}

.tandyia-chat-panel.is-actions-collapsed .tandyia-chat-messages {
    max-height: 420px;
}

.tandyia-message {
    max-width: 86%;
    padding: 10px 12px;
    border: 1px solid rgba(76, 30, 12, 0.1);
    border-radius: 8px;
    white-space: pre-line;
    font-size: 0.92rem;
    line-height: 1.45;
}

.tandyia-message.is-assistant {
    justify-self: start;
    color: #1a120f;
    background: #f4ede2;
}

.tandyia-message.is-user {
    justify-self: end;
    color: #ffffff;
    background: #4c1e0c;
}

.tandyia-message.is-error {
    border-color: rgba(143, 43, 32, 0.28);
    color: #8f2b20;
    background: #fff7e6;
}

.tandyia-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 14px;
}

.tandyia-chat-actions[hidden] {
    display: none;
}

.tandyia-chat-menu-row {
    display: flex;
    justify-content: flex-end;
    padding: 0 16px 10px;
}

.tandyia-menu-toggle {
    min-height: 28px;
    border: 1px solid rgba(76, 30, 12, 0.18);
    border-radius: 999px;
    color: #4c1e0c;
    background: rgba(244, 237, 226, 0.75);
    padding: 5px 10px;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
}

.tandyia-chip,
.tandyia-link-chip {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: 1px solid rgba(76, 30, 12, 0.18);
    border-radius: 999px;
    color: #4c1e0c;
    background: rgba(244, 237, 226, 0.75);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.tandyia-link-chip.is-primary {
    color: #ffffff;
    background: #4c1e0c;
}

.tandyia-chat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 14px 16px 16px;
    border-top: 1px solid rgba(76, 30, 12, 0.12);
}

.tandyia-chat-input {
    min-height: 42px;
    border: 1px solid rgba(76, 30, 12, 0.16);
    border-radius: 999px;
    color: #1a120f;
    background: #ffffff;
    padding: 10px 13px;
    font: inherit;
}

.tandyia-chat-submit {
    min-width: 78px;
    min-height: 42px;
    border: 1px solid rgba(76, 30, 12, 0.24);
    border-radius: 999px;
    color: #ffffff;
    background: #4c1e0c;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.tandyia-chat-submit:disabled,
.tandyia-chat-input:disabled {
    opacity: 0.62;
    cursor: wait;
}

@media (max-width: 560px) {
    .tandyia-chat-panel {
        right: 16px;
        bottom: 134px;
        width: min(342px, calc(100vw - 32px));
        max-height: calc(100svh - 154px);
    }

    .tandyia-chat-messages {
        max-height: 300px;
    }

    .tandyia-chat-panel.is-actions-collapsed .tandyia-chat-messages {
        max-height: 380px;
    }
}
