.daily-report-panel {
    position: relative;
}

.ai-page-trigger {
    position: absolute;
    z-index: 8;
    top: 14px;
    right: 14px;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent-blue) 30%, var(--border-color));
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent-blue) 9%, var(--card-bg));
    color: var(--accent-blue);
    cursor: pointer;
    font-size: 23px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
    transition: transform 180ms ease, background 180ms ease;
}

.ai-page-trigger:hover {
    background: var(--accent-blue);
    color: #fff;
    transform: rotate(12deg) scale(1.06);
}

.daily-report-panel > .daily-report-header {
    padding-right: 52px;
}

.ai-chat-drawer[hidden] {
    display: none;
}

.ai-chat-drawer {
    position: fixed;
    z-index: 9001;
    top: 14px;
    right: 14px;
    display: grid;
    width: min(360px, calc(100vw - 28px));
    height: min(520px, calc(50vh - 14px));
    min-height: 360px;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--modal-bg);
    color: var(--text-primary);
    box-shadow: 0 30px 90px rgba(0, 0, 0, .38);
}

.ai-chat-drawer > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    border-bottom: 1px solid var(--border-color);
}

.ai-chat-drawer > header strong,
.ai-chat-drawer > header span {
    display: block;
}

.ai-chat-drawer > header strong {
    color: var(--accent-blue);
    font-size: 17px;
}

.ai-chat-drawer > header span {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12px;
}

.ai-chat-drawer > header button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 24px;
}

.ai-chat-messages {
    overflow-y: auto;
    padding: 18px;
}

.ai-chat-welcome {
    padding: 16px;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

.ai-chat-message {
    max-width: 88%;
    margin-bottom: 14px;
}

.ai-chat-message.user {
    margin-left: auto;
}

.ai-chat-message > span {
    display: block;
    margin: 0 4px 5px;
    color: var(--text-muted);
    font-size: 11px;
}

.ai-chat-message p {
    margin: 0;
    padding: 11px 13px;
    border-radius: 13px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.55;
}

.ai-chat-message.user p {
    background: var(--accent-blue);
    color: #fff;
}

.ai-chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 38px;
    align-items: end;
    gap: 7px;
    padding: 10px;
    border-top: 1px solid var(--border-color);
}

.ai-chat-form textarea {
    width: 100%;
    min-height: 40px;
    max-height: 92px;
    resize: none;
    padding: 9px 10px;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-primary);
    font: inherit;
}

.ai-chat-form button {
    height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 9px;
    background: var(--accent-blue);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

.ai-chat-form .ai-chat-analyze {
    white-space: nowrap;
}

.ai-chat-form .ai-chat-send {
    width: 38px;
    padding: 0;
    font-size: 15px;
}

.ai-chat-form button:disabled {
    cursor: wait;
    opacity: .68;
}

@media (max-width: 640px) {
    .ai-chat-drawer {
        top: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        height: min(520px, calc(70vh - 10px));
        min-height: 340px;
        border-radius: 14px;
    }
}
