.module-panel {
    --chat-content-max-width: 980px;
}

.chat-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 10px;
}

.chat-main-column {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-side-container {
    width: 160px;
    flex-shrink: 0;
    margin: 14px 16px 20px 0;
    border: 1px solid #d9e2ec;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease, margin 0.2s ease, border-width 0.2s ease, box-shadow 0.2s ease;
}

.chat-mode.chat-side-collapsed .chat-side-container {
    width: 0;
    margin-left: 0;
    margin-right: 0;
    border-width: 0;
    box-shadow: none;
}

.chat-mode.chat-side-collapsed .chat-layout {
    gap: 0;
}

.chat-mode.chat-side-collapsed .chat-side-head {
    opacity: 0;
    pointer-events: none;
    transition-delay: 0s;
}

.chat-side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 10px 8px 6px;
    transition: opacity 0.05s linear 0.2s;
}

.chat-side-title {
    padding: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    flex: 1;
}

.chat-side-search-toggle {
    width: 22px;
    height: 22px;
    border: 1px solid #dbe4f0;
    border-radius: 6px;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.chat-side-search-wrap {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 8px;
    transition: max-height 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
}

.chat-side-container.chat-side-search-open .chat-side-search-wrap {
    max-height: 44px;
    opacity: 1;
    padding: 0 8px 8px;
}

.chat-side-search-input {
    width: 100%;
    height: 28px;
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    padding: 0 8px;
    font-size: 12px;
    outline: none;
}

.chat-side-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-side-item-btn {
    width: 100%;
    border: 1px solid #dbe4f0;
    background: #ffffff;
    border-radius: 8px;
    padding: 8px;
    text-align: left;
    cursor: pointer;
    font-size: 12px;
    color: #334155;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.chat-side-item-btn:hover {
    border-color: #93c5fd;
    background: #f8fbff;
}

.chat-side-item-btn.active {
    border-color: #60a5fa;
    background: #eff6ff;
}

.chat-side-item-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    padding-right: 12px;
}

.chat-side-item-text::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), #ffffff 80%);
}

.chat-records-container {
    flex: 1;
    min-height: 0;
    display: flex;
    padding: 14px 30px 0;
}

.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 18px 20px;
    overflow-y: auto;
    max-width: var(--chat-content-max-width);
    margin: 0 auto;
    width: 100%;
    border: 1px solid #d9e2ec;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.message {
    margin-bottom: 25px;
    max-width: 85%;
    line-height: 1.6;
}

.message.agent {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message.system {
    align-self: center;
    max-width: 92%;
}

.bubble {
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    white-space: pre-wrap;
    word-break: break-word;
}

.agent .bubble {
    background-color: var(--agent-gray);
    border-bottom-left-radius: 2px;
    text-align: left;
}

.user .bubble {
    background-color: var(--user-blue);
    color: var(--primary-blue);
    border-bottom-right-radius: 2px;
}

.system .bubble {
    background: #f1f5f9;
    color: #334155;
    border-radius: 999px;
    font-size: 12px;
    padding: 8px 14px;
}

.agent-prefix {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: 0.1px;
}

.agent-prefix-content {
    font-weight: 500;
}

.agent-disclaimer {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.45;
    color: #94a3b8;
    opacity: 0.9;
    text-align: right;
}

.agent-prefix-evomind {
    background: #dbeafe;
    color: #1d4ed8;
}

.agent-prefix-evohub {
    background: #dcfce7;
    color: #15803d;
}

.agent-prefix-evotune {
    background: #fef3c7;
    color: #b45309;
}

.bubble-toolbar {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-bubble-toolbar {
    gap: 24px;
    width: auto;
    justify-content: flex-end;
    align-self: flex-end;
}

.bubble-tool-btn {
    border: 1px solid #dbeafe;
    background: #ffffff;
    color: #1e3a8a;
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.bubble-tool-btn.copied {
    border-color: #86efac;
    background: #f0fdf4;
    color: #15803d;
}

.bubble-tool-btn.copy-failed {
    border-color: #fecaca;
    background: #fff1f2;
    color: #be123c;
}

.bubble-tool-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.bubble-tool-btn.is-disabled {
    opacity: 0.2;
    cursor: default;
    position: relative;
}

.bubble-tool-btn.is-disabled[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%) translateY(3px);
    white-space: nowrap;
    font-size: 10px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(15, 23, 42, 0.92);
    border-radius: 8px;
    padding: 3px 7px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.08s ease, transform 0.08s ease;
}

.bubble-tool-btn.is-disabled[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.rewind-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.rewind-modal {
    width: min(480px, calc(100vw - 28px));
    background: #ffffff;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.24);
    padding: 18px 18px 14px;
}

.rewind-modal-title {
    font-size: 15px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.5;
}

.rewind-modal-subtitle {
    margin-top: 10px;
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
}

.rewind-modal-list {
    margin: 8px 0 0;
    padding-left: 18px;
    max-height: 168px;
    overflow: auto;
}

.rewind-modal-list li {
    color: #334155;
    font-size: 12px;
    line-height: 1.6;
    margin: 4px 0;
}

.rewind-modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.rewind-modal-btn {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    border-radius: 10px;
    padding: 7px 13px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.rewind-modal-btn.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #be123c;
}

.bubble-tool-btn.active {
    background: #eff6ff;
    border-color: #93c5fd;
}

.bubble-version-pager {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bubble-version-label {
    font-size: 11px;
    color: #475569;
    min-width: 38px;
    text-align: center;
}

.intro-bubble {
    white-space: normal;
    line-height: 1.8;
}

.intro-title {
    display: block;
    margin: 2px 0 8px;
    font-weight: 700;
    color: #1f2937;
}

.intro-list {
    margin: 0;
    padding-left: 18px;
}

.intro-list li {
    margin: 4px 0;
}

.chat-tools-container {
    width: 100%;
    padding: 10px 30px 0;
}

.chat-tools-container > * {
    max-width: var(--chat-content-max-width);
    width: 100%;
    margin: 0 auto;
}

.chat-input-container {
    width: 100%;
    padding: 10px 30px 0;
}

.agent-switcher-container {
    width: 100%;
    padding: 10px 30px 16px;
}

.agent-switcher-container > * {
    max-width: var(--chat-content-max-width);
    width: 100%;
    margin: 0 auto;
}

.agent-switcher-bar {
    margin-top: -4px;
    display: flex;
    justify-content: flex-start;
}

.agent-selector-wrap {
    position: relative;
}

.agent-selector-toggle {
    border: 1px solid #bfdbfe;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    color: #1e3a8a;
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.18);
}

.agent-selector-toggle[data-agent="evomind"] {
    border-color: #93c5fd;
    color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.agent-selector-toggle[data-agent="evohub"] {
    border-color: #86efac;
    color: #15803d;
    background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.16);
}

.agent-selector-toggle[data-agent="evotune"] {
    border-color: #fcd34d;
    color: #b45309;
    background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.16);
}

.agent-selector-toggle::after {
    content: "▴";
    font-size: 10px;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
}

.agent-selector-toggle.is-open::after {
    transform: rotate(180deg);
}

.agent-selector-options {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    min-width: 210px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
}

.agent-selector-options.open {
    display: flex;
}

.agent-option-btn {
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #ffffff;
    padding: 8px 10px;
    text-align: left;
    font-size: 11px;
    color: #334155;
    cursor: pointer;
    font-weight: 600;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.agent-option-btn[data-agent="evomind"] {
    color: #1d4ed8;
}

.agent-option-btn[data-agent="evohub"] {
    color: #15803d;
}

.agent-option-btn[data-agent="evotune"] {
    color: #b45309;
}

.agent-option-btn:hover {
    background: #f8fbff;
    border-color: #dbeafe;
}

.agent-option-btn.active {
    background: #eff6ff;
    border-color: #93c5fd;
}

.agent-option-btn.active[data-agent="evomind"] {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.agent-option-btn.active[data-agent="evohub"] {
    background: #f0fdf4;
    border-color: #86efac;
    color: #15803d;
}

.agent-option-btn.active[data-agent="evotune"] {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #b45309;
}

.input-container {
    max-width: var(--chat-content-max-width);
    margin: 0 auto;
    display: flex;
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-container[data-agent="evomind"] {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.2), 0 4px 12px rgba(59, 130, 246, 0.16);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.input-container[data-agent="evohub"] {
    border-color: #86efac;
    box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.24), 0 4px 12px rgba(22, 163, 74, 0.16);
    background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.input-container[data-agent="evotune"] {
    border-color: #fcd34d;
    box-shadow: 0 0 0 3px rgba(252, 211, 77, 0.22), 0 4px 12px rgba(217, 119, 6, 0.16);
    background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
}

.send-btn {
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.send-btn.send-btn-interrupt {
    background: #ef4444;
}

.send-btn.send-btn-interrupting {
    background: #f97316;
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.upload-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.upload-status {
    font-size: 12px;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-btn {
    border: 1px solid #cbd5e0;
    background: #ffffff;
    color: #2d3748;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 10px;
    flex-shrink: 0;
}

.upload-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}
