* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0a0a1a;
    --surface: #111128;
    --accent: #00d4ff;
    --accent-dim: rgba(0, 212, 255, 0.15);
    --text: #e0e0f0;
    --text-dim: #6a6a8a;
    --user-bubble: #1a1a3e;
    --jarvis-bubble: #0d1a2a;
    --danger: #ff4444;
    --success: #44ff88;
    --warning: #ffaa44;
}

html, body {
    width: 100%; height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    overflow: hidden;
    touch-action: manipulation;
}

/* Status bar */
#status-bar {
    position: fixed; top: 0; left: 0; right: 0;
    display: flex; align-items: center; gap: 8px;
    padding: 12px 20px; z-index: 100;
    background: linear-gradient(to bottom, var(--bg), transparent);
}
#status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); transition: background 0.3s; }
#status-dot.connected { background: var(--success); }
#status-text { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

.icon-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1); background: transparent;
    color: var(--text-dim); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.active { border-color: var(--success); color: var(--success); background: rgba(68,255,136,0.1); }

/* Orb */
#orb-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
#orb-canvas { width: 100%; height: 100%; }

/* Transcripts */
#transcript-area {
    position: fixed; bottom: 120px; left: 0; right: 0;
    text-align: center; padding: 0 20px; z-index: 10; pointer-events: none;
}
.transcript-line {
    font-size: 18px; line-height: 1.4; margin: 8px auto;
    opacity: 0; transition: opacity 0.3s; max-width: 600px;
}
.transcript-line.visible { opacity: 1; }
.transcript-line.jarvis { color: var(--accent); font-weight: 500; }

/* Controls */
#controls {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 20px; background: linear-gradient(to top, var(--bg) 60%, transparent); z-index: 50;
}

#mic-btn {
    width: 72px; height: 72px; border-radius: 50%;
    border: 2px solid var(--accent); background: transparent; color: var(--accent);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; flex-shrink: 0;
}
#mic-btn:hover { background: var(--accent-dim); }
#mic-btn.recording { background: var(--accent); color: var(--bg); animation: pulse 1.5s infinite; box-shadow: 0 0 30px rgba(0, 212, 255, 0.5); }
#mic-btn.thinking { border-color: var(--text-dim); color: var(--text-dim); animation: spin 2s linear infinite; }
#mic-btn.listening { border-color: var(--success); color: var(--success); animation: breathe 3s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { box-shadow: 0 0 20px rgba(0,212,255,0.3); } 50% { box-shadow: 0 0 40px rgba(0,212,255,0.6); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 10px rgba(68,255,136,0.2); } 50% { box-shadow: 0 0 25px rgba(68,255,136,0.4); } }

#text-input-wrap {
    display: flex; align-items: center;
    background: var(--surface); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px; padding: 4px 4px 4px 16px; flex: 1; max-width: 280px;
}
#text-input { background: none; border: none; color: var(--text); font-size: 14px; flex: 1; outline: none; min-width: 0; }
#text-input::placeholder { color: var(--text-dim); }
#send-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: var(--accent); color: var(--bg); cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Panels */
.panel {
    position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100vw;
    background: rgba(10, 10, 26, 0.97); backdrop-filter: blur(15px);
    z-index: 60; overflow-y: auto; transition: transform 0.3s;
    border-left: 1px solid rgba(255,255,255,0.05);
}
.panel.hidden { transform: translateX(100%); pointer-events: none; }
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.05);
    position: sticky; top: 0; background: rgba(10,10,26,0.95); z-index: 1;
}
.panel-header h2 { font-size: 16px; font-weight: 600; color: var(--accent); }
.close-btn {
    background: none; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer;
}
.panel-body { padding: 16px 20px; }

.section { margin-bottom: 24px; }
.section h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }

/* Server grid */
.server-grid { display: flex; flex-direction: column; gap: 8px; }
.server-card {
    background: var(--surface); border-radius: 8px; padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.05);
}
.server-card .name { font-weight: 600; font-size: 13px; }
.server-card .ip { color: var(--accent); font-size: 12px; font-family: monospace; }
.server-card .meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }

/* Info grid */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.info-item {
    background: var(--surface); border-radius: 8px; padding: 10px;
    border: 1px solid rgba(255,255,255,0.05);
}
.info-item .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }
.info-item .value { font-size: 14px; font-weight: 600; margin-top: 4px; }

/* Network */
.net-device {
    display: flex; justify-content: space-between; padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 13px; font-family: monospace;
}
.net-device .state { font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.net-device .state.REACHABLE { background: rgba(68,255,136,0.15); color: var(--success); }
.net-device .state.STALE { background: rgba(255,170,68,0.15); color: var(--warning); }

/* Messages */
#messages { display: flex; flex-direction: column; gap: 12px; }
.msg { padding: 10px 14px; border-radius: 16px; max-width: 90%; font-size: 14px; line-height: 1.5; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
.msg.user { background: var(--user-bubble); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--jarvis-bubble); border: 1px solid rgba(0,212,255,0.1); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg .time { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

@media (max-width: 480px) {
    #mic-btn { width: 64px; height: 64px; }
    #text-input-wrap { max-width: 180px; }
    .panel { width: 100vw; }
}

/* --- Tools panel additions --- */
.tool-out { margin-top: 8px; font-size: 13px; color: var(--text); min-height: 20px; }
.tool-out .kv {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tool-out .kv span { flex: 1; color: var(--text-dim); font-size: 12px; }
.tool-out .kv b { color: var(--accent); font-weight: 600; }
.tool-out .kv button.cancel-rem {
    background: transparent; border: 1px solid var(--text-dim);
    color: var(--text-dim); padding: 2px 8px; border-radius: 4px; cursor: pointer;
}
.tool-out .kv button.cancel-rem:hover { color: #ff6b6b; border-color: #ff6b6b; }
.panel-body .section input, .panel-body .section input[type="number"] {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    color: var(--text); padding: 6px 10px; border-radius: 6px; font-size: 13px;
    margin: 4px 4px 4px 0; min-width: 160px;
}
.panel-body .section input[type="file"] { padding: 4px; }
.panel-body .section .btn {
    background: var(--accent); color: #000; border: none; padding: 6px 14px;
    border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 13px; margin: 4px 4px 4px 0;
}
.panel-body .section .btn:hover { opacity: 0.85; }
.panel-body .section .mini-btn {
    background: transparent; border: 1px solid var(--text-dim); color: var(--text-dim);
    padding: 1px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; margin-left: 8px;
}

/* --- Wake-word button --- */
#wake-btn.active { color: var(--accent); border-color: var(--accent); animation: wake-pulse 2s infinite; }
@keyframes wake-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(66,200,255,.4); } 50% { box-shadow: 0 0 0 6px rgba(66,200,255,0); } }


/* --- Charts --- */
.chart-row { margin: 6px 0; height: 70px; background: rgba(255,255,255,0.03); border-radius: 6px; position: relative; }
.chart { width: 100%; height: 100%; display: block; }

