.workspace-chat-dialog .tg-close.workspace-chat-new {
    right: 54px;
}

.workspace-chat-dialog .tg-close.workspace-chat-history-btn {
    right: 54px;
}

.workspace-chat-dialog:has(#workspace-chat-new:not([hidden])) .tg-close.workspace-chat-history-btn {
    right: 94px;
}

.workspace-chat-head {
    display: none;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    min-width: 0;
    max-width: calc(100% - 96px);
    margin: 0 0 10px;
    padding: 2px 4px 0 2px;
}

.tg-layout[data-mode="thread"] .workspace-chat-head {
    display: flex;
    max-width: calc(100% - 138px);
}

.workspace-chat-head-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
}

.workspace-chat-head-icon svg {
    width: 100%;
    height: 100%;
    shape-rendering: geometricPrecision;
}

.workspace-chat-head h2 {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.25;
    color: var(--tg-ink, #1e1e1e);
}

.workspace-chat-dialog .tg-epic {
    max-width: min(220px, 46vw);
}

#workspaceChatModal.is-parent-picker-open {
    overflow: visible;
}

#workspaceChatModal.is-parent-picker-open .modal-dialog,
#workspaceChatModal.is-parent-picker-open .modal-content {
    overflow: visible;
}

.workspace-chat-dialog .task-chat-msg-block {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    max-width: min(86%, 520px);
}

.workspace-chat-dialog .task-chat-msg-block .tg-message {
    max-width: none;
}

.workspace-chat-dialog .task-chat-msg-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    padding: 0 2px;
}

.workspace-chat-dialog .task-chat-msg-time {
    color: var(--tg-mute, #6c757d);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.workspace-chat-new[hidden],
.workspace-chat-history-btn[hidden],
.workspace-chat-history-menu[hidden] {
    display: none !important;
}

.workspace-chat-history-btn.is-open {
    background: var(--tg-board, #f4f6fb);
    color: var(--tg-ink, #1e1e1e);
}

.workspace-chat-history-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.workspace-chat-history-menu {
    position: absolute;
    top: 52px;
    right: 14px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: min(320px, calc(100% - 28px));
    max-height: min(360px, calc(100% - 70px));
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--tg-line, #e6e6e6);
    border-radius: 12px;
    background: #fff;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 16px 36px -12px rgba(30, 30, 30, 0.18);
}

.workspace-chat-history-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tg-ink, #1e1e1e);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.workspace-chat-history-item:hover,
.workspace-chat-history-item:focus-visible,
.workspace-chat-history-item.is-active {
    background: var(--tg-board, #f4f6fb);
    outline: none;
}

.workspace-chat-history-item-title {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
    min-height: 1rem;
}

.workspace-chat-history-item-meta {
    color: var(--tg-mute, #6c757d);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.workspace-chat-history-empty {
    margin: 0;
    padding: 14px 10px;
    color: var(--tg-mute, #6c757d);
    font-size: 0.8rem;
    text-align: center;
}

.workspace-chat-dialog .tg-suggest-item:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.workspace-chat-dialog .tg-error[hidden] {
    display: none !important;
}

.workspace-chat-dialog .workspace-chat-task-link {
    color: var(--tg-signal, #1482fa);
    text-decoration: none;
}

.workspace-chat-dialog .workspace-chat-task-link:hover {
    text-decoration: underline;
}

.workspace-chat-dialog .tg-message-text a {
    word-break: break-word;
}

@media (max-width: 640px) {
    .workspace-chat-dialog {
        margin: 12px;
    }
}
