#chatToggleBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    transition: right 0.3s ease;
    z-index: 10000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #015B7D 0%, #02A4DE 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(1, 91, 125, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatToggleBtn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(2, 164, 222, 0.4);
}

#chatToggleBtn.hidden {
    display: none;
}

#chatToggleBtn svg {
    width: 26px;
    height: 26px;
}

/* Chat Panel */
#chatPanel {
    position: fixed;
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: 400px;
    z-index: 10000;
    background: white;
    border-radius: 26px;
    box-shadow: 0 4px 20px rgba(1, 91, 125, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#chatPanel.open {
    display: flex;
}

#chatHeader {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(1, 91, 125, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: #015B7D;
}

#chatNewBtn,
#chatCloseBtn {
    background: none;
    border: none;
    cursor: pointer;
    color: #015B7D;
    padding: 4px 8px;
    border-radius: 50%;
}

#chatNewBtn {
    margin-left: auto;
}

#chatCloseBtn {
    font-size: 22px;
    line-height: 1;
}

#chatNewBtn:hover,
#chatCloseBtn:hover {
    background: rgba(1, 91, 125, 0.1);
}

/* Area Status */
#chatAreaStatus {
    padding: 8px 16px;
    border-bottom: 1px solid rgba(1, 91, 125, 0.1);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #015B7D;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#chatAreaText {
    opacity: 0.5;
}

#chatAreaStatus.has-area {
    background: rgba(2, 164, 222, 0.05);
}

#chatAreaStatus.has-area #chatAreaText {
    opacity: 1;
    font-weight: 500;
}

#drawAreaBtn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border: 1px solid #015B7D;
    border-radius: 999px;
    background: white;
    color: #015B7D;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

#drawAreaBtn:hover {
    background: rgba(2, 164, 222, 0.1);
    border-color: #02A4DE;
}

#drawAreaBtn.active {
    background: linear-gradient(135deg, #015B7D 0%, #02A4DE 100%);
    color: white;
    border-color: #02A4DE;
}

#drawAreaBtn.has-area {
    background: rgba(2, 164, 222, 0.1);
    border-color: #02A4DE;
}

/* Messages */
#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Input Area */
#chatInputArea {
    padding: 12px 16px;
    border-top: 1px solid rgba(1, 91, 125, 0.1);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#chatInput {
    flex: 1;
    border: 1px solid rgba(1, 91, 125, 0.3);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #015B7D;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
}

#chatInput:focus {
    border-color: #02A4DE;
    box-shadow: 0 0 0 2px rgba(2, 164, 222, 0.15);
}

#chatInput::placeholder {
    color: rgba(1, 91, 125, 0.4);
}

#chatSendBtn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #015B7D 0%, #02A4DE 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chatSendBtn:hover {
    box-shadow: 0 2px 8px rgba(2, 164, 222, 0.3);
}

#chatSendBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#chatSendBtn svg {
    width: 18px;
    height: 18px;
}

#chatInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Message Bubbles */
#chatMessages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: 18px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-msg code {
    background: rgba(1, 91, 125, 0.08);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 13px;
}

.chat-msg-human {
    align-self: flex-end;
    background: linear-gradient(135deg, #015B7D 0%, #02A4DE 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.chat-msg-ai {
    align-self: flex-start;
    background: rgba(1, 91, 125, 0.07);
    color: #1a3a4a;
    border-bottom-left-radius: 6px;
}

.chat-msg-tool {
    align-self: flex-start;
    background: transparent;
    color: #015B7D;
    opacity: 0.5;
    font-size: 12px;
    font-style: italic;
    padding: 2px 16px;
    max-width: 100%;
}

.chat-msg-thinking {
    align-self: flex-start;
    background: rgba(1, 91, 125, 0.07);
    padding: 12px 20px;
    border-bottom-left-radius: 6px;
    display: flex;
    gap: 5px;
}

.chat-msg-thinking::before,
.chat-msg-thinking::after,
.chat-msg-thinking span {
    display: none;
}

.chat-msg-thinking .dot {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #015B7D;
    opacity: 0.3;
    animation: thinking-bounce 1.2s infinite ease-in-out;
}

.chat-msg-thinking .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-msg-thinking .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.chat-msg-error {
    align-self: center;
    background: rgba(204, 68, 68, 0.1);
    color: #cc4444;
    font-size: 13px;
    text-align: center;
}

.chat-msg-rate-limit {
    align-self: center;
    background: rgba(204, 153, 0, 0.1);
    color: #cc9900;
    font-size: 13px;
    text-align: center;
}

/* Artifacts */
.chat-msg-artifact {
    align-self: flex-start;
    background: rgba(1, 91, 125, 0.07);
    border-bottom-left-radius: 6px;
    padding: 8px;
    max-width: 95%;
}

.chat-artifact-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.chat-artifact-label {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #015B7D;
}

.chat-artifact-image {
    width: 100%;
    border-radius: 10px;
    display: block;
    image-rendering: pixelated;
}

.chat-artifact-image-error {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(204, 68, 68, 0.08);
    border: 1px dashed rgba(204, 68, 68, 0.3);
    font-size: 12px;
    color: #cc4444;
}

.chat-artifact-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #1a3a4a;
    max-height: 300px;
    display: block;
    overflow: auto;
}

.chat-artifact-table thead {
    position: sticky;
    top: 0;
}

.chat-artifact-table th {
    background: #015B7D;
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 6px 10px;
    white-space: nowrap;
}

.chat-artifact-table td {
    padding: 4px 10px;
    border-bottom: 1px solid rgba(1, 91, 125, 0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.chat-artifact-table tbody tr:hover {
    background: rgba(2, 164, 222, 0.08);
}

.chat-artifact-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.chat-artifact-expand-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: none;
    background: rgba(1, 91, 125, 0.15);
    color: #015B7D;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-artifact-expand-btn:hover {
    background: rgba(2, 164, 222, 0.3);
}

/* Table modal overlay */
.chat-table-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-table-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-table-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(1, 91, 125, 0.1);
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: #015B7D;
}

.chat-table-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-table-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #015B7D;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
}

.chat-table-modal-close:hover {
    background: rgba(1, 91, 125, 0.1);
}

.chat-table-modal-table {
    max-height: none;
    overflow: auto;
    flex: 1;
}

.chat-table-modal-table td {
    max-width: none;
}

/* Chart modal */
.chat-chart-modal {
    width: 80vw;
    height: 70vh;
}

.chat-chart-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.chat-chart-canvas-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}

.chat-chart-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.chat-chart-controls {
    width: max-content;
    min-width: 120px;
    max-width: 250px;
    flex-shrink: 0;
    padding: 12px 16px;
    border-left: 1px solid rgba(1, 91, 125, 0.1);
    overflow-y: auto;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #1a3a4a;
}

.chat-chart-controls-title {
    font-weight: 600;
    font-size: 12px;
    color: #015B7D;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-chart-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    cursor: pointer;
}

.chat-chart-checkbox input {
    margin: 0;
    cursor: pointer;
}

.chat-chart-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.chat-chart-tooltip {
    display: none;
    position: absolute;
    z-index: 1;
    background: white;
    border: 1px solid rgba(1, 91, 125, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #1a3a4a;
    pointer-events: none;
    white-space: nowrap;
}

.chat-chart-tooltip-date {
    font-weight: 600;
    color: #015B7D;
    margin-bottom: 4px;
}

.chat-chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
}

.chat-chart-tooltip-swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.chat-artifact-source {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: #015B7D;
    opacity: 0.5;
    margin-top: 4px;
}

/* Example questions */
.chat-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 4px;
    justify-content: center;
}

.chat-examples-label {
    width: 100%;
    text-align: center;
    font-size: 13px;
    color: #888;
    margin-bottom: 4px;
}

.chat-example-pill {
    background: rgba(1, 91, 125, 0.08);
    color: #015B7D;
    border: 1px solid rgba(1, 91, 125, 0.2);
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.chat-example-pill:hover {
    background: rgba(1, 91, 125, 0.16);
    border-color: rgba(1, 91, 125, 0.4);
}
