/* Voice Chat (Agent Space) Styles */
.conversation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0d1117;
    z-index: 10002;
    display: none;
    align-items: center;
    justify-content: center;
}

.conversation-panel {
    background: #0d1117;
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    display: flex;
    flex-direction: row;
    position: relative;
}

.dashboard-sidebar {
    width: 280px;
    background: rgba(22, 27, 34, 0.4);
    border-right: 1px solid rgba(139, 148, 158, 0.2);
    display: flex;
    flex-direction: column;
    padding: 0;
}

.sidebar-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f0f6fc;
    padding: 20px;
    border-bottom: 1px solid rgba(139, 148, 158, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-section {
    padding: 20px;
}

.sidebar-section h4 {
    font-size: 0.75rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.sidebar-section h4:hover {
    color: #4fd1c7;
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 30vh;
    overflow-y: auto;
}

.sidebar-list::-webkit-scrollbar {
    width: 4px;
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(139, 148, 158, 0.3);
    border-radius: 4px;
}

.sidebar-list li {
    padding: 10px 12px;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-list li:hover {
    background: rgba(79, 209, 199, 0.1);
}

.sidebar-list li.active {
    background: rgba(79, 209, 199, 0.2);
    color: #f0f6fc;
    border-left: 3px solid #4fd1c7;
}

.dashboard-panel {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}

.dashboard-panel.active {
    display: flex;
}

.agentspace-tabs {
    align-items: center;
    background: rgba(13, 17, 23, 0.78);
    border-bottom: 1px solid rgba(79, 209, 199, 0.16);
    display: flex;
    gap: 10px;
    padding: 12px 18px 0;
}

.agentspace-tab {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    color: #8b949e;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 14px;
    transition: all 0.2s ease;
}

.agentspace-tab i {
    margin-right: 6px;
}

.agentspace-tab:hover,
.agentspace-tab.active {
    background: rgba(79, 209, 199, 0.12);
    border-color: rgba(79, 209, 199, 0.2);
    color: #f0f6fc;
}

.agentspace-tab-panel {
    display: none;
    flex: 1;
    min-height: 0;
}

.agentspace-tab-panel.active {
    display: flex;
    flex-direction: column;
}

.organism-card {
    background: rgba(48, 54, 61, 0.4);
    border: 1px solid rgba(79, 209, 199, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.constitution-editor {
    width: 100%;
    height: 200px;
    background: #0d1117;
    color: #c9d1d9;
    border: 1px solid rgba(139, 148, 158, 0.2);
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    resize: none;
    outline: none;
}

.infra-terminal {
    background: #010409;
    color: #39ff14;
    font-family: 'Courier New', Courier, monospace;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #30363d;
    height: 300px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.terminal-line {
    margin-bottom: 4px;
}

.terminal-prompt {
    color: #58a6ff;
}

.resource-gauge {
    background: #161b22;
    border-radius: 8px;
    height: 8px;
    width: 100%;
    margin-top: 5px;
    overflow: hidden;
}

.resource-fill {
    height: 100%;
    background: #238636;
    width: 0%;
    transition: width 0.5s ease;
}

.resource-fill.warning {
    background: #d29922;
}

.resource-fill.critical {
    background: #f85149;
}

.mail-relay-panel {
    background: rgba(13, 17, 23, 0.82);
    border: 1px solid rgba(79, 209, 199, 0.18);
    border-radius: 14px;
    margin-bottom: 16px;
    padding: 16px;
}

.mail-relay-header {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.mail-relay-header h3 {
    color: #f0f6fc;
    font-size: 1rem;
    margin: 0 0 4px;
}

.mail-relay-header h3 i {
    color: #4fd1c7;
    margin-right: 6px;
}

.mail-relay-header p {
    color: #8b949e;
    font-size: 0.78rem;
    line-height: 1.5;
    margin: 0;
    max-width: 560px;
}

.mail-relay-actions {
    display: flex;
    gap: 8px;
}

.mail-relay-status {
    border-radius: 10px;
    font-size: 0.78rem;
    margin-bottom: 12px;
    padding: 10px 12px;
}

.mail-relay-status.info {
    background: rgba(79, 209, 199, 0.08);
    border: 1px solid rgba(79, 209, 199, 0.18);
    color: #9be7df;
}

.mail-relay-status.success {
    background: rgba(57, 255, 20, 0.08);
    border: 1px solid rgba(57, 255, 20, 0.18);
    color: #93ff8b;
}

.mail-relay-status.warn {
    background: rgba(255, 170, 0, 0.08);
    border: 1px solid rgba(255, 170, 0, 0.18);
    color: #ffd37a;
}

.mail-relay-status.error {
    background: rgba(255, 86, 86, 0.08);
    border: 1px solid rgba(255, 86, 86, 0.18);
    color: #ff9c9c;
}

.mail-relay-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.mail-relay-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mail-relay-grid span {
    color: #8b949e;
    font-size: 0.74rem;
    text-transform: uppercase;
}

.mail-relay-grid input {
    background: rgba(1, 4, 9, 0.72);
    border: 1px solid rgba(139, 148, 158, 0.22);
    border-radius: 8px;
    color: #f0f6fc;
    font-size: 0.82rem;
    outline: none;
    padding: 10px 12px;
}

.mail-relay-grid input:focus {
    border-color: rgba(79, 209, 199, 0.4);
}

.mail-relay-fallback {
    color: #8b949e;
    font-size: 0.77rem;
    line-height: 1.5;
    margin-top: 12px;
}

.mailbox-shell {
    background: rgba(13, 17, 23, 0.5);
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    padding: 18px;
}

.mailbox-toolbar {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.mailbox-eyebrow {
    color: #4fd1c7;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.mailbox-toolbar h3 {
    color: #f0f6fc;
    margin: 0 0 4px;
}

.mailbox-toolbar p {
    color: #8b949e;
    font-size: 0.84rem;
    line-height: 1.5;
    margin: 0;
}

.mailbox-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mailbox-summary-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.mailbox-summary-card {
    background: rgba(13, 17, 23, 0.82);
    border: 1px solid rgba(79, 209, 199, 0.16);
    border-radius: 12px;
    padding: 14px;
}

.mailbox-summary-card span {
    color: #8b949e;
    display: block;
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.mailbox-summary-card strong {
    color: #f0f6fc;
    font-size: 0.95rem;
    word-break: break-word;
}

.mailbox-composer {
    background: rgba(13, 17, 23, 0.82);
    border: 1px solid rgba(79, 209, 199, 0.16);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.mailbox-composer-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.mailbox-composer label {
    color: #c9d1d9;
    display: flex;
    flex-direction: column;
    font-size: 0.82rem;
    gap: 6px;
}

.mailbox-composer input,
.mailbox-composer textarea {
    background: rgba(1, 4, 9, 0.72);
    border: 1px solid rgba(139, 148, 158, 0.22);
    border-radius: 10px;
    color: #f0f6fc;
    font: inherit;
    padding: 10px 12px;
}

.mailbox-composer textarea {
    min-height: 120px;
    resize: vertical;
}

.mailbox-compose-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.mailbox-account-chip {
    align-items: center;
    background: rgba(79, 209, 199, 0.08);
    border: 1px solid rgba(79, 209, 199, 0.18);
    border-radius: 999px;
    color: #c9d1d9;
    display: inline-flex;
    font-size: 0.78rem;
    gap: 6px;
    padding: 6px 10px;
}

.mailbox-account-chip small {
    color: #8b949e;
    font-size: 0.72rem;
}

.mailbox-layout {
    display: grid;
    flex: 1;
    gap: 14px;
    grid-template-columns: minmax(280px, 360px) 1fr;
    min-height: 420px;
}

.mailbox-message-list,
.mailbox-preview {
    background: rgba(13, 17, 23, 0.82);
    border: 1px solid rgba(79, 209, 199, 0.16);
    border-radius: 14px;
    min-height: 0;
    overflow: auto;
}

.mailbox-message-item {
    border-bottom: 1px solid rgba(139, 148, 158, 0.12);
    cursor: pointer;
    padding: 14px 16px;
}

.mailbox-message-item:hover,
.mailbox-message-item.active {
    background: rgba(79, 209, 199, 0.08);
}

.mailbox-message-item:last-child {
    border-bottom: none;
}

.mailbox-message-top {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 6px;
}

.mailbox-message-from,
.mailbox-message-subject {
    color: #f0f6fc;
    font-size: 0.86rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mailbox-message-date,
.mailbox-message-preview {
    color: #8b949e;
    font-size: 0.78rem;
    line-height: 1.5;
}

.mailbox-message-preview {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.mailbox-unread-dot {
    background: #4fd1c7;
    border-radius: 999px;
    display: inline-block;
    height: 8px;
    margin-right: 8px;
    width: 8px;
}

.mailbox-preview {
    padding: 18px;
}

.mailbox-preview-empty {
    color: #8b949e;
    font-size: 0.9rem;
}

.mailbox-preview-header {
    border-bottom: 1px solid rgba(139, 148, 158, 0.14);
    margin-bottom: 14px;
    padding-bottom: 14px;
}

.mailbox-preview-header h4 {
    color: #f0f6fc;
    margin: 0 0 8px;
}

.mailbox-preview-meta {
    color: #8b949e;
    font-size: 0.8rem;
    line-height: 1.6;
}

.mailbox-preview-body {
    color: #c9d1d9;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.mailbox-thread-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mailbox-thread-message {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(139, 148, 158, 0.14);
    border-radius: 12px;
    padding: 14px;
}

.mailbox-thread-message.unread {
    border-color: rgba(79, 209, 199, 0.32);
    box-shadow: inset 0 0 0 1px rgba(79, 209, 199, 0.12);
}

.mailbox-empty-state {
    color: #8b949e;
    padding: 18px;
}

@media (max-width: 960px) {
    .mailbox-layout {
        grid-template-columns: 1fr;
    }
}

.avatar-talking {
    animation: pulse-avatar 0.5s infinite ease-in-out;
    filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.8));
}

@keyframes pulse-avatar {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

.message-container {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 12px;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(79, 209, 199, 0.1);
    border: 1px solid rgba(79, 209, 199, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #4fd1c7;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.message-container.ai .message-avatar {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.message-container.user .message-avatar {
    background: rgba(79, 209, 199, 0.1);
    border-color: rgba(79, 209, 199, 0.3);
    color: #4fd1c7;
    margin-left: auto;
    order: 2;
}

.message {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 80%;
    color: #c9d1d9;
}

.message-container.user .message {
    margin-left: auto;
    margin-right: 0;
    background: rgba(79, 209, 199, 0.1);
    border: 1px solid rgba(79, 209, 199, 0.2);
}

.message-container.ai .message {
    margin-right: auto;
    margin-left: 0;
}

.message.system {
    background: transparent;
    color: #8b949e;
    text-align: center;
    font-style: italic;
    margin: 10px auto;
    max-width: 100%;
    font-size: 0.95rem;
}

.conversation-header {
    padding: 20px 30px;
    border-bottom: 1px solid rgba(139, 148, 158, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-header h3 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 500;
    letter-spacing: 1px;
    color: #c9d1d9;
}

.conversation-header .close-btn {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.8;
    transition: color 0.3s ease;
}

.conversation-header .close-btn:hover {
    color: #f0f6fc;
}

.dashboard-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.chat-input-container {
    padding: 20px 30px;
    background: rgba(13, 17, 23, 0.8);
    border-top: 1px solid rgba(139, 148, 158, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

#voiceChatInput {
    width: 100%;
    background: #0d1117;
    color: #f0f6fc;
    border: 1px solid rgba(79, 209, 199, 0.3);
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.btn-voice-chat {
    background: #4fd1c7;
    color: #010409;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.btn-voice-chat.recording {
    background: #ff6b6b;
    animation: pulse-avatar 1.5s infinite;
}

.btn-chat-send {
    background: transparent;
    color: #4fd1c7;
    border: 1px solid #4fd1c7;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Resource Gagues etc */
.resource-fill {
    transition: width 0.5s ease;
}