:root {
    --bg: #050510;
    --glass-bg: rgba(10, 10, 28, 0.72);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-hover: rgba(255, 255, 255, 0.10);
    --accent: #7c6aef;
    --accent-glow: rgba(124, 106, 239, 0.35);
    --accent-secondary: #4ecdc4;
    --text: rgba(255, 255, 255, 0.93);
    --text-dim: rgba(255, 255, 255, 0.50);
    --text-muted: rgba(255, 255, 255, 0.28);
    --danger: #ff6b6b;
    --success: #51cf66;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --header-h: 60px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* JarvisX Identity
   NAME    : Vedant Gandhi
   GITHUB  : VeduStorm
   DISCORD : cool_guy.57_alt
   EMAIL   : v9edant@gmail.com
   PROJECT : JarvisX
*/


*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
    user-select: none;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; }
textarea { font-family: var(--font); color: var(--text); }
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(32px) saturate(1.2);
    -webkit-backdrop-filter: blur(32px) saturate(1.2);
    border: 1px solid var(--glass-border);
}
.app {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#orb-container {
    position: fixed;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    width: min(600px, 80vw);
    height: min(600px, 80vw);
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#orb-container.active,
#orb-container.speaking {
    opacity: 1;
    animation: orbPulse 1.6s ease-in-out infinite;
}
@media (max-width: 900px) {
    .message { max-width: 95%; }
    .vitals-widget, .history-widget { width: min(340px, 85vw); }
    .orb-container { width: 90vw; height: 90vw; }
}
@media (max-width: 768px) {
    .header { 
        padding: max(12px, env(safe-area-inset-top)) 16px 12px; 
        height: auto; 
        min-height: 60px; 
        gap: 8px;
    }
    .tagline { display: none; }
    .logo { font-size: 1.1rem; letter-spacing: 2px; }
    .status-badge .status-text { display: none; }
    
    .btn-icon { width: 38px; height: 38px; } 

    .chat-messages { padding: 16px 12px; }
    .message { gap: 8px; max-width: 100%; }
    .msg-avatar { width: 28px; height: 28px; font-size: 0.65rem; margin-top: 2px; }
    .msg-avatar .msg-avatar-icon { width: 16px; height: 16px; }
    
    .msg-content { font-size: 0.85rem; padding: 10px 14px; }
    .welcome-title { font-size: 1.5rem; }

    .input-bar { 
        padding: 10px 12px; 
        padding-bottom: max(12px, env(safe-area-inset-bottom)); 
    }
    .input-wrapper { padding: 4px 4px 4px 12px; border-radius: 16px; }
    .input-actions { gap: 6px; }
    
    .action-btn { width: 42px; height: 42px; min-width: 42px; border-radius: 12px; }
    .action-btn svg { width: 20px; height: 20px; }

    .search-results-widget, .vitals-widget, .history-widget { 
        width: 100vw; 
        max-width: 100vw; 
        border-radius: 0;
        background: rgba(8, 8, 15, 0.98);
    }
    .search-results-header { padding: max(16px, env(safe-area-inset-top)) 16px 16px; }
    .history-content, .vitals-content, .search-results-list {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 400px) {
    .header-right { gap: 6px; }
    
    .welcome-chips { 
        flex-direction: column; 
        width: 100%; 
        max-width: 280px; 
        gap: 8px; 
    }
    .chip { width: 100%; text-align: center; padding: 12px; font-size: 0.82rem; }
    
    .input-actions { gap: 4px; }
    .action-btn { width: 38px; height: 38px; min-width: 38px; }
    .action-btn svg { width: 18px; height: 18px; }
}
@media (hover: none) {
    .btn-icon:hover, .action-btn:hover, .chip:hover, .history-item:hover {
        transform: none !important;
    }
}
.header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--header-h);
    padding: 0 20px;
    border-radius: 0 0 var(--radius) var(--radius);
    border-top: none;
    flex-shrink: 0;
}
.header-left { display: flex; align-items: baseline; gap: 10px; }

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.tagline {
    font-size: 0.68rem;
    font-weight: 300;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}
.auth-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(5, 5, 16, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: none;
    place-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.scene-tooltip {
    z-index: 10000 !important;
    pointer-events: none !important;
}
.cmd-palette-box {
    width: 90vw;
    max-width: 650px;
    margin-top: -15vh;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: fadeInDown 0.2s ease-out;
}
.cmd-input-wrap {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    gap: 12px;
}
.cmd-input-wrap svg { color: var(--accent); }
#cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 1.1rem;
    font-family: var(--font);
}
#cmd-input::placeholder { color: var(--text-muted); }
.cmd-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: monospace;
    background: rgba(255,255,255,0.05);
    padding: 4px 8px;
    border-radius: 4px;
}
.cmd-results-list {
    max-height: 350px;
    overflow-y: auto;
    padding: 8px;
}
.cmd-result-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cmd-result-item:hover, .cmd-result-item.selected {
    background: rgba(124, 106, 239, 0.15);
}
.cmd-res-title { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.cmd-res-desc { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}
.graph-box {
    width: 90vw;
    height: 85vh;
    padding: 0;
    max-width: 1200px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#3d-graph {
    flex: 1;
    width: 100%;
    height: 100%;
    cursor: grab;
}
#3d-graph:active { cursor: grabbing; }
#timeline-widget { left: auto; right: 0; transform: translateX(100%); border-radius: var(--radius) 0 0 var(--radius); }
#timeline-widget.open { transform: translateX(0); }

.timeline-item {
    position: relative;
    padding: 0 0 24px 20px;
    border-left: 2px solid rgba(124, 106, 239, 0.3);
    margin-left: 10px;
}
.timeline-item:last-child { border-left: 2px solid transparent; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}
.timeline-time {
    font-size: 0.7rem;
    color: var(--accent-secondary);
    font-family: monospace;
    margin-bottom: 4px;
}
.timeline-action {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.message.assistant .msg-content:has(strong:contains("SWARM DELEGATION")) {
    border-left: 3px solid var(--accent-secondary);
    background: rgba(78, 205, 196, 0.05);
    animation: alertPulse 2s infinite;
}

@keyframes alertPulse {
    0% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(78, 205, 196, 0); }
    100% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0); }
}
.timeline-details {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 6px;
    background: rgba(255,255,255,0.02);
    padding: 8px;
    border-radius: var(--radius-xs);
}
.auth-overlay.active {
    display: grid;
    opacity: 1;
}
.auth-box {
    padding: 40px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.5s ease;
}
.auth-sub {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 24px;
}
.auth-input-group {
    display: flex;
    gap: 10px;
}
.auth-input-group input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}
.auth-input-group input:focus {
    border-color: var(--accent);
}
.vitals-widget {
    position: fixed;
    top: 0; left: 0;
    width: min(340px, 90vw);
    height: 100%;
    z-index: 20;
    display: flex;
    flex-direction: column;
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: none;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.vitals-widget.open {
    transform: translateX(0);
}
.vitals-content {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.vital-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 14px;
}
.vital-card h4 {
    font-size: 0.75rem;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.vital-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.vital-row span:last-child {
    color: var(--text);
    font-weight: 500;
}
.vital-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.msg-content strong {
    color: var(--text);
    font-weight: 600;
}
.msg-content em {
    font-style: italic;
    color: var(--text-dim);
}
.msg-content, textarea, .search-results-answer, .search-result-card {
    user-select: text; 
    -webkit-user-select: text;
}
.msg-content h1, .msg-content h2, .msg-content h3 {
    margin-top: 14px;
    margin-bottom: 8px;
    color: var(--accent-secondary);
    font-weight: 600;
    line-height: 1.3;
}
.msg-content h3 { font-size: 1rem; }

.list-item {
    display: flex;
    gap: 8px;
    margin: 4px 0;
    padding-left: 4px;
}
.bullet {
    color: var(--accent);
    font-weight: bold;
}
.md-link {
    color: var(--accent-secondary);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-secondary);
    transition: all var(--transition);
}
.md-link:hover {
    color: #fff;
    border-bottom-style: solid;
}

.inline-code {
    background: rgba(124, 106, 239, 0.15);
    color: #cbbaff;
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    border: 1px solid rgba(124, 106, 239, 0.3);
}

.code-header {
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.code-wrapper {
    background: #1a1b26;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin: 12px 0;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mac-dots {
    display: flex;
    gap: 6px;
    width: 50px;
}
.mac-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.mac-dots span:nth-child(1) { background: #ff5f56; }
.mac-dots span:nth-child(2) { background: #ffbd2e; }
.mac-dots span:nth-child(3) { background: #27c93f; }

.lang-label {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.copy-btn {
    font-size: 0.7rem;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    transition: all var(--transition);
}
.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}
.copy-btn.copied {
    background: var(--success);
    color: #000;
    border-color: var(--success);
    font-weight: bold;
}

.code-block {
    margin: 0;
    padding: 0;
    overflow-x: auto;
}

.code-block .hljs {
    padding: 14px;
    font-family: 'Consolas', 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    background: transparent !important; /* Lets the Tokyo Night wrapper background show */
    white-space: pre;
    line-height: 1.5;
}

.code-block code {
    font-family: 'Consolas', 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: #e2e2e2;
    white-space: pre;
}
.vital-list li {
    font-size: 0.78rem;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 2px solid var(--accent);
}
.vital-list li.empty-state {
    border-left: 2px solid var(--glass-border);
    font-style: italic;
    color: var(--text-muted);
}
.auth-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 12px;
    height: 16px;
}

.msg-label {
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0 4px;
}
.message.user .msg-label { text-align: right; }
.input-meta {
    display: flex;
    justify-content: flex-end;
    padding: 5px 8px 0;
    font-size: 0.66rem;
    color: var(--text-muted);
}
.mode-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 4px);
    height: calc(100% - 6px);
    background: var(--accent);
    border-radius: 10px;
    transition: transform var(--transition);
    opacity: 0.18;
}
.mode-slider.right {
    transform: translateX(calc(100% + 2px));
}
.mode-btn {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 0.76rem;
    font-weight: 500;
    border-radius: 10px;
    color: var(--text-dim);
    transition: color var(--transition);
    white-space: nowrap;
}
.mode-btn.active { color: var(--text); }
.mode-btn svg { opacity: 0.7; }
.mode-btn.active svg { opacity: 1; }
.header-right { display: flex; align-items: center; gap: 10px; }
.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-dim);
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}
.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 6px var(--danger);
    animation: none;
}
.btn-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    transition: background var(--transition), border-color var(--transition);
}
.btn-icon:hover {
    background: var(--glass-hover);
    border-color: rgba(255, 255, 255, 0.14);
}
.chat-area {
    position: relative;
    z-index: 5;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}
.history-widget {
    position: fixed;
    top: 0; left: 0;
    width: min(300px, 85vw);
    height: 100%;
    z-index: 25; /* Sits above vitals if both open */
    display: flex;
    flex-direction: column;
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: none;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.history-widget.open {
    transform: translateX(0);
}
.history-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.history-item {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}
.history-item:hover, .history-item.active {
    background: rgba(124, 106, 239, 0.15);
    border-color: var(--accent);
    color: var(--text);
}
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 12px;
    padding: 40px 20px;
    animation: fadeIn 0.6s ease;
}
.welcome-icon {
    color: var(--accent);
    opacity: 0.5;
    margin-bottom: 6px;
}
.welcome-title {
    font-size: 1.7rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.welcome-sub {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 300;
}
.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}
.chip {
    padding: 8px 18px;
    font-size: 0.76rem;
    font-weight: 400;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    transition: all var(--transition);
}
.chip:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
}
.message {
    display: flex;
    gap: 10px;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    animation: msgIn 0.3s ease;
}
.message.user { flex-direction: row-reverse; }
.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 4px;
}
.msg-avatar .msg-avatar-icon {
    width: 18px;
    height: 18px;
}
.message.assistant .msg-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    color: #fff;
}
.message.user .msg-avatar {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-dim);
}
.msg-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.msg-content {
    padding: 11px 15px;
    border-radius: var(--radius);
    font-size: 0.87rem;
    line-height: 1.65;
    font-weight: 400;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.message.assistant .msg-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-top-left-radius: var(--radius-xs);
}
.message.user .msg-content {
    background: rgba(124, 106, 239, 0.13);
    border: 1px solid rgba(124, 106, 239, 0.16);
    border-top-right-radius: var(--radius-xs);
}
.msg-label {
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0 4px;
}
.message.user .msg-label { text-align: right; }
.typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: dotBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
.stream-cursor {
    animation: blink 0.8s step-end infinite;
    color: var(--accent);
    margin-left: 1px;
}
.input-bar {
    position: relative;
    z-index: 10;
    padding: 10px 20px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    flex-shrink: 0;
}
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 5px 5px 5px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrapper:focus-within {
    border-color: rgba(124, 106, 239, 0.35);
    box-shadow: 0 0 0 3px rgba(124, 106, 239, 0.08);
}
.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-size: 0.87rem;
    line-height: 1.5;
    padding: 8px 0;
    max-height: 120px;
    color: var(--text);
}
.input-wrapper textarea::placeholder { color: var(--text-muted); }

.input-actions {
    display: flex;
    gap: 6px;
    padding-bottom: 2px;
    flex-shrink: 0;
}
.action-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all var(--transition);
    color: var(--text-dim);
    flex-shrink: 0;
}
.action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.16);
    color: var(--text);
    transform: translateY(-1px);
}
.action-btn:active {
    transform: translateY(0);
}
.send-btn {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(124, 106, 239, 0.25);
}
.send-btn:hover {
    background: #6a58e0 !important;
    border-color: #6a58e0 !important;
    box-shadow: 0 4px 14px rgba(124, 106, 239, 0.35);
}
.send-btn:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
    transform: none;
}
.mic-btn .mic-icon-active { display: none; }
.mic-btn.listening .mic-icon { display: none; }
.mic-btn.listening .mic-icon-active { display: block; }
.mic-btn.listening {
    background: rgba(255, 107, 107, 0.18);
    border-color: rgba(255, 107, 107, 0.3);
    color: var(--danger);
    animation: micPulse 1.5s ease-in-out infinite;
}
.tts-btn .tts-icon-on { display: none; }
.tts-btn.tts-active .tts-icon-off { display: none; }
.tts-btn.tts-active .tts-icon-on { display: block; }
.tts-btn.tts-active {
    background: rgba(124, 106, 239, 0.18);
    border-color: rgba(124, 106, 239, 0.3);
    color: var(--accent);
}
.tts-btn.tts-speaking {
    animation: ttsPulse 1.5s ease-in-out infinite;
}
.input-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px 0;
    font-size: 0.66rem;
    color: var(--text-muted);
}
.mode-label { font-weight: 500; }

.search-results-widget {
    position: fixed;
    top: 0;
    right: 0;
    width: min(380px, 95vw);
    min-width: 0;
    max-height: 100vh;
    height: 100%;
    z-index: 20;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: none;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.search-results-widget.open {
    transform: translateX(0);
}
.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}
.search-results-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.search-results-title::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}
.search-results-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.search-results-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}
.search-results-query {
    padding: 12px 16px;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}
.search-results-answer {
    padding: 14px 16px;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text);
    background: rgba(124, 106, 239, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    max-height: 200px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.search-results-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.search-result-card {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    transition: background var(--transition), border-color var(--transition);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.search-result-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.1);
}
.search-result-card .card-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}
.search-result-card .card-content {
    font-size: 0.76rem;
    color: var(--text-dim);
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.search-result-card .card-url {
    font-size: 0.7rem;
    color: var(--accent);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.search-result-card .card-url:hover {
    text-decoration: underline;
}
.search-result-card .card-score {
    font-size: 0.68rem;
    color: var(--text-muted);
}
.search-results-answer::-webkit-scrollbar,
.search-results-list::-webkit-scrollbar {
    width: 6px;
}
.search-results-answer::-webkit-scrollbar-track,
.search-results-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}
.search-results-answer::-webkit-scrollbar-thumb,
.search-results-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}
.search-results-answer::-webkit-scrollbar-thumb:hover,
.search-results-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
@supports (scrollbar-color: rgba(255,255,255,0.12) rgba(255,255,255,0.03)) {
    .search-results-answer,
    .search-results-list {
        scrollbar-color: rgba(255, 255, 255, 0.12) rgba(255, 255, 255, 0.03);
        scrollbar-width: thin;
    }
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.14); }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes dotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-5px); opacity: 1; }
}
@keyframes blink {
    50% { opacity: 0; }
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.3); }
    50%      { box-shadow: 0 0 0 8px rgba(255, 107, 107, 0); }
}
@keyframes ttsPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(124, 106, 239, 0.3); }
    50%      { box-shadow: 0 0 0 8px rgba(124, 106, 239, 0); }
}
@keyframes orbPulse {
    0%, 100% { transform: scale(1); opacity: 0.92; }
    50%      { transform: scale(1.10); opacity: 1; }
}
@media (max-width: 768px) {
    .header { padding: 0 12px; gap: 8px; }
    .tagline { display: none; }
    .logo { font-size: 1rem; }
    .mode-btn { padding: 6px 10px; font-size: 0.72rem; }
    .mode-btn svg { display: none; }
    .status-badge .status-text { display: none; }
    .chat-messages { padding: 14px 10px; }
    .input-bar { padding: 8px 10px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom, 8px)); }
    .input-wrapper { padding: 4px 4px 4px 12px; }
    .action-btn { width: 36px; height: 36px; min-width: 36px; border-radius: 9px; }
    .msg-content { font-size: 0.84rem; padding: 10px 13px; }
    .welcome-title { font-size: 1.3rem; }
    .message { gap: 8px; }
    .msg-avatar { width: 26px; height: 26px; font-size: 0.62rem; }
    .msg-avatar .msg-avatar-icon { width: 16px; height: 16px; }
    .search-results-widget { width: min(100vw, 360px); }
    .search-results-header { padding: 12px 14px; }
    .search-results-query,
    .search-results-answer { padding: 10px 14px; }
    .search-results-list { padding: 10px 14px 20px; gap: 10px; }
    .search-result-card { padding: 10px 12px; }
}
@media (max-width: 480px) {
    .header-center { flex: 1; justify-content: center; display: flex; }
    .mode-switch { width: 100%; }
    .mode-btn { flex: 1; justify-content: center; }
    .new-chat-btn { display: none; }
    .welcome-chips { gap: 6px; }
    .chip { font-size: 0.72rem; padding: 6px 14px; }
    .action-btn { width: 34px; height: 34px; min-width: 34px; border-radius: 8px; }
    .action-btn svg { width: 17px; height: 17px; }
    .input-actions { gap: 5px; }
    .input-wrapper { gap: 4px; }
    .search-results-widget { width: 100vw; max-width: 100%; }
    .search-results-header { padding: 10px 12px; }
    .search-results-query { font-size: 0.72rem; padding: 10px 12px; }
    .search-results-answer { font-size: 0.82rem; padding: 10px 12px; max-height: 160px; }
    .search-results-list { padding: 8px 12px 16px; gap: 8px; }
    .search-result-card { padding: 10px 12px; }
    .search-result-card .card-title { font-size: 0.76rem; }
    .search-result-card .card-content { font-size: 0.72rem; -webkit-line-clamp: 3; }
}
