.tpm-chat-shell {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 120;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

.tpm-chat-shell svg {
    width: 1.1rem;
    height: 1.1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tpm-chat-launcher,
.tpm-chat-close,
.tpm-chat-send,
.tpm-chat-tabs button {
    font: inherit;
}

.tpm-chat-launcher {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid rgba(34, 211, 168, 0.72);
    border-radius: 999px;
    padding: 0.78rem 1rem;
    color: #061629;
    background: linear-gradient(120deg, #22d3a8, #69d6ff);
    box-shadow: 0 18px 38px rgba(2, 7, 20, 0.34), 0 12px 28px rgba(34, 211, 168, 0.24);
    font-weight: 800;
    cursor: pointer;
}

.tpm-chat-launcher:hover,
.tpm-chat-launcher:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 20px 42px rgba(2, 7, 20, 0.4), 0 14px 30px rgba(34, 211, 168, 0.32);
}

.tpm-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.85rem);
    width: min(390px, calc(100vw - 2rem));
    max-height: min(680px, calc(100vh - 7rem));
    display: none;
    overflow: hidden;
    color: #eff5ff;
    background: rgba(8, 18, 39, 0.98);
    border: 1px solid rgba(139, 180, 255, 0.34);
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(2, 7, 20, 0.54);
}

.tpm-chat-shell.is-open .tpm-chat-panel {
    display: grid;
    grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
}

.tpm-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem 0.8rem;
    border-bottom: 1px solid rgba(139, 180, 255, 0.18);
}

.tpm-chat-title {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 0.72rem;
}

.tpm-chat-title strong,
.tpm-chat-title span {
    display: block;
}

.tpm-chat-title strong {
    font-size: 0.98rem;
}

.tpm-chat-title span {
    color: #b1bfdc;
    font-size: 0.78rem;
    line-height: 1.25;
}

.tpm-chat-mark {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 10px;
    color: #061629;
    background: linear-gradient(120deg, #ffd96e, #69d6ff);
}

.tpm-chat-close {
    display: inline-grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid rgba(139, 180, 255, 0.28);
    border-radius: 10px;
    color: #eff5ff;
    background: rgba(17, 35, 72, 0.76);
    cursor: pointer;
}

.tpm-chat-close:hover,
.tpm-chat-close:focus-visible {
    background: rgba(105, 214, 255, 0.16);
}

.tpm-chat-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    padding: 0.75rem 1rem;
}

.tpm-chat-tabs button {
    border: 1px solid rgba(139, 180, 255, 0.24);
    border-radius: 11px;
    padding: 0.55rem 0.75rem;
    color: #b1bfdc;
    background: rgba(17, 35, 72, 0.52);
    font-weight: 700;
    cursor: pointer;
}

.tpm-chat-tabs button.is-active {
    color: #061629;
    border-color: rgba(34, 211, 168, 0.62);
    background: linear-gradient(120deg, #22d3a8, #69d6ff);
}

.tpm-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 0;
    overflow-y: auto;
    padding: 0.15rem 1rem 0.8rem;
}

.tpm-chat-message {
    display: grid;
    gap: 0.55rem;
}

.tpm-chat-message-user {
    justify-items: end;
}

.tpm-chat-bubble {
    max-width: 92%;
    border: 1px solid rgba(139, 180, 255, 0.22);
    border-radius: 14px;
    padding: 0.72rem 0.82rem;
    color: #eff5ff;
    background: rgba(17, 35, 72, 0.82);
    font-size: 0.91rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.tpm-chat-message-user .tpm-chat-bubble {
    color: #061629;
    background: linear-gradient(120deg, #ffd96e, #ffba59);
    border-color: rgba(255, 214, 110, 0.68);
}

.tpm-chat-sources {
    display: grid;
    gap: 0.45rem;
}

.tpm-chat-source {
    border: 1px solid rgba(139, 180, 255, 0.18);
    border-radius: 12px;
    padding: 0.62rem 0.7rem;
    background: rgba(3, 10, 24, 0.38);
}

.tpm-chat-source a,
.tpm-chat-source strong {
    color: #69d6ff;
    font-size: 0.84rem;
    font-weight: 800;
    text-decoration: none;
}

.tpm-chat-source a:hover {
    text-decoration: underline;
}

.tpm-chat-source p {
    margin: 0.24rem 0 0;
    color: #b1bfdc;
    font-size: 0.78rem;
    line-height: 1.35;
}

.tpm-chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    border-top: 1px solid rgba(139, 180, 255, 0.18);
}

.tpm-chat-input-wrap {
    display: grid;
    min-width: 0;
}

.tpm-chat-input-wrap textarea {
    width: 100%;
    min-height: 2.65rem;
    max-height: 7.5rem;
    resize: none;
    border: 1px solid rgba(139, 180, 255, 0.28);
    border-radius: 13px;
    padding: 0.7rem 0.78rem;
    color: #eff5ff;
    background: rgba(3, 10, 24, 0.46);
    font: inherit;
    font-size: 0.91rem;
    line-height: 1.35;
    outline: none;
}

.tpm-chat-input-wrap textarea:focus {
    border-color: rgba(105, 214, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(105, 214, 255, 0.14);
}

.tpm-chat-send {
    display: inline-grid;
    place-items: center;
    align-self: end;
    width: 2.65rem;
    height: 2.65rem;
    border: 1px solid rgba(34, 211, 168, 0.62);
    border-radius: 13px;
    color: #061629;
    background: linear-gradient(120deg, #22d3a8, #69d6ff);
    cursor: pointer;
}

.tpm-chat-send:disabled {
    cursor: wait;
    opacity: 0.68;
}

.tpm-chat-foot {
    margin: 0;
    padding: 0 1rem 0.9rem;
    color: #8fa2c7;
    font-size: 0.73rem;
    line-height: 1.3;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 640px) {
    .tpm-chat-shell {
        right: 0.85rem;
        bottom: 0.85rem;
    }

    .tpm-chat-panel {
        width: calc(100vw - 1.7rem);
        max-height: calc(100vh - 6rem);
        border-radius: 16px;
    }

    .tpm-chat-launcher span {
        display: none;
    }

    .tpm-chat-launcher {
        width: 3.25rem;
        height: 3.25rem;
        justify-content: center;
        padding: 0;
    }
}
