:root {
    --bg-color: #0e1621;
    --card-bg: #182533;
    --accent-primary: #5288c1;
    --accent-secondary: #2b5278;
    --text-primary: #ffffff;
    --text-secondary: #7f91a4;
    --border-color: #101924;
    --danger: #ec3b57;
    --success: #4ea86d;
}

html {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0 0.35rem 0.35rem 0.35rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath d='M-10 40 L170 220 M20 -30 L200 150 M-40 100 L140 280' stroke='rgba(255,255,255,0.045)' stroke-width='1.2' fill='none'/%3E%3Cpath d='M170 30 L-10 210 M140 -20 L-40 160 M200 110 L20 290' stroke='rgba(255,255,255,0.03)' stroke-width='1' fill='none'/%3E%3Ccircle cx='40' cy='60' r='1.5' fill='rgba(255,255,255,0.05)'/%3E%3Ccircle cx='120' cy='130' r='1' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E");
    background-size: 160px 160px;
}

@media (min-width: 768px) {
    body {
        padding: 0 2rem 2rem 2rem;
    }
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

header {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

@media (min-width: 768px) {
    header {
        margin-bottom: 3rem;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}



h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@media (min-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }
}

.app-header {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 0.4rem;
    padding-top: 0.4rem;
}

.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0;
    background: var(--card-bg);
    padding: 0.2rem;
    border-radius: 6px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
}

@media (min-width: 768px) {
    .tabs {
        width: fit-content;
        justify-content: center;
    }
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .tab-btn {
        padding: 0.6rem 1rem;
    }
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.panel {
    display: none;
    animation: fadeIn 0.5s ease;
}

.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

#history-panel.active {
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath d='M-10 40 L170 220 M20 -30 L200 150 M-40 100 L140 280' stroke='rgba(255,255,255,0.045)' stroke-width='1.2' fill='none'/%3E%3Cpath d='M170 30 L-10 210 M140 -20 L-40 160 M200 110 L20 290' stroke='rgba(255,255,255,0.03)' stroke-width='1' fill='none'/%3E%3Ccircle cx='40' cy='60' r='1.5' fill='rgba(255,255,255,0.05)'/%3E%3Ccircle cx='120' cy='130' r='1' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E");
    background-size: 160px 160px;
    background-repeat: repeat;
    border-radius: 6px;
    overflow-y: hidden !important;
}

#memory-panel.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    #memory-panel.active {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        align-items: start;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    margin-bottom: 1.5rem;
    width: 100%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.08);
}

@media (min-width: 768px) {
    .card {
        padding: 2rem;
    }
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    /* border-bottom: 1px solid rgba(255, 255, 255, 0.05); */
    /* padding-bottom: 1rem; */
}

@media (min-width: 480px) {
    .card-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

textarea {
    width: 100%;
    min-height: 200px;
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 1rem;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s;
}

textarea:focus {
    border-color: var(--accent-primary);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    border: none;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-system-restart {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(139, 92, 246, 0.2);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-system-restart:hover {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    transform: translateY(-2px);
}

.btn-system-shutdown {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-system-shutdown:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

/* Compact Header for System Action Controls */
.card-header.compact-header {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 1rem !important;
    width: 100% !important;
    padding-bottom: 0 !important;
    margin-bottom: 1rem !important;
}

.card-header.compact-header .btn {
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
}

/* Messages Styles */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.message-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.65rem;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    max-width: 85%;
    width: fit-content;
}

.message-user {
    align-self: flex-end;
    background: rgba(82, 136, 193, 0.15); /* Tono oscuro con azul primario */
    border: 1px solid rgba(82, 136, 193, 0.3);
    border-bottom-right-radius: 2px;
}

.message-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.03);
    border-bottom-left-radius: 2px;
}

@media (min-width: 768px) {
    .message-item {
        padding: 1rem;
    }
}

.message-content {
    flex: 1;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.sender {
    font-weight: 700;
    text-transform: uppercase;
}

.sender.agent {
    color: var(--accent-primary);
}

.sender.user {
    color: var(--accent-secondary);
}

.timestamp {
    color: var(--text-secondary);
}

.message-body {
    line-height: 1.5;
}

.delete-msg-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    opacity: 0.5;
    border-radius: 6px;
    transition: all 0.2s;
}

.delete-msg-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 2rem;
    border-radius: 6px;
    background: var(--success);
    color: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.notification.show {
    transform: translateY(0);
}

/* Commands Table Styles */
table th,
table td {
    border-bottom: 1px solid var(--border-color);
}

table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 0.75rem;
    border-radius: 6px;
    transition: transform 0.2s;
}

.file-item:nth-child(even) {
    background: rgba(255, 255, 255, 0.06);
}

.audio-custom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    width: fit-content;
    cursor: pointer;
    margin: 8px 0;
    transition: all 0.2s;
}

.audio-custom:hover {
    background: rgba(255, 255, 255, 0.12);
}

.audio-play-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.audio-progress {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    width: 120px;
    overflow: hidden;
}

.audio-bar {
    height: 100%;
    background: var(--accent-primary);
    width: 0%;
}


/* ── Terminal Card ── */
.terminal-card {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #1e293b;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(139, 92, 246, 0.08);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.terminal-header {
    background: linear-gradient(135deg, #1a2234 0%, #0f172a 100%);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.terminal-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.terminal-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.term-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.terminal-title {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #64748b;
    letter-spacing: 0.02em;
}

/* Connection badge */
.conn-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.conn-connecting {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.conn-live {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.conn-error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.conn-archive {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

.conn-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.conn-live .conn-dot {
    animation: none;
}

/* Filter buttons */
.log-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-btn {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid #1e293b;
    color: #64748b;
    padding: 3px 12px;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.filter-btn:hover {
    border-color: #475569;
    color: #94a3b8;
    background: rgba(30, 41, 59, 0.7);
}

.filter-btn.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: #8b5cf6;
    color: #c084fc;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
    text-shadow: 0 0 5px rgba(139, 92, 246, 0.3);
}

/* Special active states for specific tags when active in multi-select */
.filter-btn[data-type="brain"].active {
    background: rgba(139, 92, 246, 0.15);
    border-color: #8b5cf6;
    color: #c084fc;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.25);
}

.filter-btn[data-type="skill"].active {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #34d399;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.25);
}

.filter-btn[data-type="thought"].active {
    background: rgba(236, 72, 153, 0.15);
    border-color: #ec4899;
    color: #f472b6;
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.25);
}

.filter-btn[data-type="error"].active {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #f87171;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.25);
}

.filter-btn[data-type="debug"].active {
    background: rgba(100, 116, 139, 0.15);
    border-color: #64748b;
    color: #94a3b8;
    box-shadow: 0 0 8px rgba(100, 116, 139, 0.25);
}

.filter-btn[data-type="all"].active {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #60a5fa;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.25);
}

.term-clear-btn {
    padding: 3px 12px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.term-clear-btn:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

/* Terminal body */
.terminal-body {
    flex: 1;
    /* Slight height increase for beautiful display */
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: #cbd5e1;
    background: #040711;
    /* Even richer black */
    box-shadow: inset 0 8px 32px rgba(0, 0, 0, 0.5);
}

.terminal-body::-webkit-scrollbar {
    width: 8px;
}

.terminal-body::-webkit-scrollbar-track {
    background: transparent;
}

.terminal-body::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* Log entries */
.log-entry {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 5px;
    border-left: 3px solid transparent;
    padding: 4px 8px 4px 10px;
    border-radius: 4px;
    transition: all 0.20s ease;
    position: relative;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.02);
}

.log-entry.hidden {
    display: none !important;
}

.log-time {
    color: #334155;
    margin-right: 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 1px;
    font-weight: 500;
}

.log-type {
    font-weight: 700;
    margin-right: 0.6rem;
    text-transform: uppercase;
    font-size: 0.68rem;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.06em;
    display: inline-block;
    text-align: center;
    min-width: 60px;
}

.log-icon {
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.6rem;
    margin-top: 2px;
    opacity: 0.8;
    flex-shrink: 0;
}

.log-message {
    word-break: break-word;
    flex: 1;
    padding-top: 1px;
}

.log-expand-btn {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #c084fc;
    cursor: pointer;
    font-size: 0.68rem;
    font-family: inherit;
    margin-left: 10px;
    padding: 1px 8px;
    border-radius: 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    align-self: center;
}

.log-expand-btn:hover {
    background: rgba(139, 92, 246, 0.25);
    color: #fff;
    border-color: rgba(139, 92, 246, 0.5);
    transform: scale(1.04);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.2);
}

/* Type colours & Beautiful Left Borders & Glows */
.type-info {
    border-left-color: #3b82f6;
}

.type-info .log-type {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.type-info:hover {
    background: rgba(59, 130, 246, 0.02);
}

.type-warn {
    border-left-color: #f59e0b;
}

.type-warn .log-type {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.type-warn:hover {
    background: rgba(245, 158, 11, 0.02);
}

.type-error {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.02);
}

.type-error .log-type {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.type-error .log-message {
    color: #fecaca;
}

.type-error:hover {
    background: rgba(239, 68, 68, 0.05);
}

.type-debug {
    border-left-color: #475569;
}

.type-debug .log-type {
    background: rgba(71, 85, 105, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(71, 85, 105, 0.2);
}

.type-debug .log-message {
    color: #64748b;
}

.type-debug:hover {
    background: rgba(71, 85, 105, 0.02);
}

.type-brain {
    border-left-color: #8b5cf6;
}

.type-brain .log-type {
    background: rgba(139, 92, 246, 0.1);
    color: #c084fc;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.type-brain:hover {
    background: rgba(139, 92, 246, 0.03);
}

.type-skill {
    border-left-color: #10b981;
}

.type-skill .log-type {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.type-skill:hover {
    background: rgba(16, 185, 129, 0.03);
}

.type-thought {
    border-left-color: #ec4899;
    background: rgba(236, 72, 153, 0.02);
}

.type-thought .log-type {
    background: rgba(236, 72, 153, 0.1);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

.type-thought .log-message {
    color: #fbcfe8;
    font-style: italic;
}

.type-thought:hover {
    background: rgba(236, 72, 153, 0.04);
}

/* Premium expanded block */
.log-details-block {
    display: block;
    width: 100%;
    flex-basis: 100%;
    margin-top: 0.6rem;
    margin-bottom: 0.4rem;
    padding: 0.85rem 1.1rem;
    background: #02040a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.25);
    border-left: 4px solid #8b5cf6;
    animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.type-info .log-details-block {
    border-left-color: #3b82f6;
    color: #93c5fd;
}

.type-warn .log-details-block {
    border-left-color: #f59e0b;
    color: #fde68a;
}

.type-error .log-details-block {
    border-left-color: #ef4444;
    color: #fca5a5;
}

.type-thought .log-details-block {
    border-left-color: #ec4899;
    color: #fbcfe8;
}

.type-brain .log-details-block {
    border-left-color: #8b5cf6;
    color: #c084fc;
}

.type-skill .log-details-block {
    border-left-color: #10b981;
    color: #6ee7b7;
}

.type-debug .log-details-block {
    border-left-color: #475569;
    color: #cbd5e1;
}

/* DEFAULT STRUCTURAL LAYOUT FOR NEW SUB-CONTAINERS */
.log-entry {
    display: flex !important;
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.log-entry-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.log-entry-content {
    display: flex;
    align-items: flex-start;
    flex: 1;
    min-width: 280px;
    gap: 8px;
}

/* ── Mobile Layout Refinements (max-width: 768px) ── */
@media (max-width: 768px) {
    .terminal-body {
        padding: 0.75rem 0.6rem !important;
        height: 520px !important;
        font-size: 0.75rem !important;
    }

    .log-entry {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
        padding: 8px !important;
        margin-bottom: 8px !important;
        background: rgba(15, 23, 42, 0.4) !important;
        border: 1px solid rgba(255, 255, 255, 0.03) !important;
    }

    .log-entry-header {
        width: 100% !important;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.05) !important;
        padding-bottom: 5px !important;
        gap: 6px !important;
    }

    .log-entry-content {
        width: 100% !important;
        padding-left: 2px !important;
        gap: 6px !important;
        min-width: 0 !important;
        /* overrides min-width constraints */
    }

    .log-message {
        font-size: 0.75rem !important;
        line-height: 1.55 !important;
        word-break: break-word !important;
        white-space: pre-wrap !important;
    }

    .log-expand-btn {
        align-self: flex-start !important;
        margin-left: 0 !important;
        margin-top: 4px !important;
    }

    .log-details-block {
        padding: 0.65rem 0.85rem !important;
        font-size: 0.72rem !important;
        word-break: break-word !important;
        /* Prevents single-character aggressive breaks */
        overflow-x: auto !important;
    }

    /* Responsive layout for filters to avoid overflow */
    .log-filters {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        justify-content: flex-start !important;
        width: 100% !important;
    }

    .filter-btn {
        padding: 0.2rem 0.45rem !important;
        font-size: 0.65rem !important;
    }

    .term-clear-btn {
        padding: 0.2rem 0.5rem !important;
        font-size: 0.65rem !important;
    }

    /* Terminal Header adjustments */
    .terminal-header {
        padding: 0.5rem 0.6rem !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    .terminal-header-left,
    .terminal-header-right {
        width: 100% !important;
        justify-content: space-between !important;
    }

    #log-file-select {
        max-width: 180px !important;
        font-size: 0.7rem !important;
    }

    /* HIDE TABS SCROLLBAR FOR PREMIUM NATIVE APP LOOK */
    .tabs::-webkit-scrollbar {
        display: none !important;
    }

    .tabs {
        -ms-overflow-style: none !important;
        scrollbar-width: none !important;
    }

    /* CHAT MESSAGE LAYOUT ENHANCEMENTS */
    .message-item {
        padding: 0.75rem !important;
        border-radius: 10px !important;
        gap: 8px !important;
    }

    .message-body {
        font-size: 0.8rem !important;
        line-height: 1.45 !important;
    }

    .message-header {
        font-size: 0.75rem !important;
        margin-bottom: 0.35rem !important;
    }

    /* MEMORY PANEL TEXTAREAS */
    #memory-panel textarea {
        height: 180px !important;
        font-size: 0.8rem !important;
        padding: 0.6rem !important;
    }

    /* CARD HEADERS STRUCTURAL AUTO-STACKING */
    .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .card-title {
        font-size: 1.05rem !important;
    }

    .card-header .btn {
        width: 100% !important;
        /* Spans 100% width on phone for simple thumb-tap */
        justify-content: center !important;
    }

    /* RESPONSIVE STACKED CARDS FOR TABLES (Tareas, Recordatorios, Comandos) */
    .card table,
    .card thead,
    .card tbody,
    .card th,
    .card td,
    .card tr {
        display: block !important;
        width: 100% !important;
    }

    .card thead {
        display: none !important;
        /* Hide flat horizontal column headers */
    }

    .card tr {
        background: rgba(15, 23, 42, 0.4) !important;
        border: 1px solid rgba(255, 255, 255, 0.04) !important;
        border-radius: 12px !important;
        padding: 0.85rem !important;
        margin-bottom: 1rem !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    }

    .card td {
        padding: 0.5rem 0 !important;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.03) !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
    }

    .card td:last-child {
        border-bottom: none !important;
        align-items: flex-end !important;
        /* Right-align action buttons */
    }

    /* Add mobile field labels using pseudo-elements */
    /* 1. Tareas list */
    #tasks-list td:nth-of-type(1)::before {
        content: "DESCRIPCIÓN";
    }

    #tasks-list td:nth-of-type(2)::before {
        content: "ESTADO";
    }

    #tasks-list td:nth-of-type(3)::before {
        content: "ACCIONES";
    }

    /* 2. Recordatorios list */
    #reminders-list td:nth-of-type(1)::before {
        content: "FECHA Y HORA";
    }

    #reminders-list td:nth-of-type(2)::before {
        content: "TIEMPO RESTANTE";
    }

    #reminders-list td:nth-of-type(3)::before {
        content: "MOTIVO";
    }

    #reminders-list td:nth-of-type(4)::before {
        content: "ESTADO";
    }

    #reminders-list td:nth-of-type(5)::before {
        content: "ACCIONES";
    }

    /* 3. Comandos list */
    #commands-list td:nth-of-type(1)::before {
        content: "PROPÓSITO / PALABRA CLAVE";
    }

    #commands-list td:nth-of-type(2)::before {
        content: "PLANTILLA DEL COMANDO";
    }

    #commands-list td:nth-of-type(3)::before {
        content: "EJEMPLO";
    }

    #commands-list td:nth-of-type(4)::before {
        content: "ACCIONES";
    }

    /* Labeled pseudo-element styling */
    #tasks-list td::before,
    #reminders-list td::before,
    #commands-list td::before {
        font-size: 0.62rem !important;
        font-weight: 700 !important;
        color: var(--accent-primary) !important;
        /* Beautiful violet theme accent color */
        letter-spacing: 0.08em !important;
        margin-bottom: 4px !important;
        text-transform: uppercase !important;
    }
}

/* API Key Dashboard Cards */
.api-keys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.api-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.api-card:hover {
    transform: translateY(-4px);
    border-color: rgba(6, 182, 212, 0.3);
    box-shadow: 0 10px 25px rgba(6, 182, 212, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

.api-card.inactive-key {
    opacity: 0.5;
    border-color: rgba(255, 255, 255, 0.04);
}

.api-card.inactive-key:hover {
    transform: none;
    box-shadow: none;
    background: rgba(15, 23, 42, 0.6);
}

.api-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.api-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.api-status-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
}

.badge-active {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-inactive {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-warn {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.api-card-metrics {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.metric-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

.metric-value {
    font-weight: 700;
    color: var(--text-primary);
}

.metric-progress-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 99px;
    overflow: hidden;
}

.metric-progress-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-cyan {
    background: linear-gradient(90deg, #06b6d4, #0891b2);
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
}

.progress-purple {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

/* Contenedor responsivo del Dashboard de APIs */
.system-api-container {
    background: rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

/* Optimizaciones responsivas para teléfonos móviles */
@media (max-width: 480px) {
    .system-api-container {
        padding: 1rem !important;
        border-radius: 12px !important;
    }

    .api-keys-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        margin-top: 0.75rem !important;
    }

    .api-card {
        padding: 1rem !important;
        border-radius: 12px !important;
    }

    .api-card-header {
        margin-bottom: 0.5rem !important;
    }

    .api-card-title {
        font-size: 0.95rem !important;
    }

    .api-status-badge {
        font-size: 0.65rem !important;
        padding: 1px 6px !important;
    }

    .metric-label-row {
        font-size: 0.75rem !important;
    }

    .metric-value {
        font-size: 0.78rem !important;
    }
}