/* ─── Chat toasts (idle mode) ─── */
.chat-toasts {
    position: fixed;
    bottom: 80px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 90;
    pointer-events: none;
    max-width: 380px;
}

.chat-toast {
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.6);
    line-height: 1.4;
    padding: 2px 0;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.chat-toast.fade {
    opacity: 0;
}

.chat-toast .chat-time {
    color: #999;
    font-size: 12px;
}

.chat-toast .chat-sender {
    color: var(--text-title);
    font-weight: 600;
}

.chat-toast .chat-system {
    color: var(--text-secondary);
    font-style: italic;
}

/* ─── Chat pinned (persistent last N messages) ─── */
.chat-pinned {
    position: fixed;
    bottom: 80px;
    left: 16px;
    display: none;
    flex-direction: column;
    gap: 3px;
    z-index: 90;
    pointer-events: none;
    max-width: 380px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    padding: 6px 10px;
}

.chat-pinned-msg {
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-pinned-msg .chat-time {
    color: #999;
    font-size: 12px;
}

.chat-pinned-msg .chat-sender {
    color: var(--text-title);
    font-weight: 600;
}

.chat-pinned-msg .chat-system {
    color: var(--text-secondary);
    font-style: italic;
}

/* ─── Chat panel (active mode) ─── */
.chat-panel {
    position: fixed;
    bottom: 80px;
    left: 16px;
    width: 380px;
    max-height: 320px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: var(--z-panel);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel.active {
    display: flex;
}

/* Header with pin button */
.chat-header {
    display: flex;
    justify-content: flex-end;
    padding: 4px 8px 0;
}

.chat-pin-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    opacity: 0.4;
    transition: opacity 0.15s, border-color 0.15s;
}

.chat-pin-btn:hover {
    opacity: 0.7;
}

.chat-pin-btn.active {
    opacity: 1;
    border-color: rgba(232, 162, 58, 0.4);
}

/* History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 4px 12px 8px;
    max-height: 248px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-history::-webkit-scrollbar {
    width: 4px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.chat-msg {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-time {
    color: var(--text-secondary);
    font-size: 12px;
    margin-right: 3px;
}

.chat-sender {
    color: var(--text-title);
    font-weight: 600;
}

.chat-system {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 12px;
}

.chat-op {
    color: #e8a23a;
    font-family: monospace;
    font-size: 12px;
}

/* Input row */
.chat-input-row {
    border-top: 1px solid var(--panel-border-inner);
    padding: 6px 8px;
}

.chat-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 6px 10px;
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.chat-input:focus {
    border-color: rgba(232, 162, 58, 0.4);
}

.chat-input::placeholder {
    color: var(--text-dim);
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
    .chat-toasts,
    .chat-pinned {
        bottom: 60px;
        left: 8px;
        max-width: 280px;
    }

    .chat-panel {
        bottom: 60px;
        left: 8px;
        right: 8px;
        width: auto;
    }
}
