- server.py: FastAPI + WebSocket server wrapping Brain, TTS, Actions
- WS /ws/chat: streaming chat with token-by-token delivery
- GET /api/audio/{filename}: serve generated TTS audio
- GET /api/health: server status check
- Serves static web UI from web/ directory
- web/: self-contained HTML/CSS/JS frontend
- Responsive chat interface with message bubbles
- WebSocket client for real-time streaming
- Voice input via Web Speech API (mic button)
- TTS audio playback (auto + manual replay)
- Conversation sidebar with history
- Settings panel (voice, TTS, sidebar toggles)
- Dark mode support via prefers-color-scheme
- Updated requirements.txt with fastapi, uvicorn, websockets
- Updated .env.example with SERVER_HOST/PORT config
625 lines
13 KiB
CSS
625 lines
13 KiB
CSS
/* =========================================================================
|
|
Echo Voice Assistant — Web UI Styles
|
|
========================================================================= */
|
|
|
|
:root {
|
|
--bg: #ffffff;
|
|
--bg-secondary: #f8f9fa;
|
|
--bg-tertiary: #f1f3f5;
|
|
--surface: #ffffff;
|
|
--border: #e5e7eb;
|
|
--border-light: #f0f0f0;
|
|
--text: #111827;
|
|
--text-secondary: #6b7280;
|
|
--text-muted: #9ca3af;
|
|
--primary: #111827;
|
|
--primary-fg: #ffffff;
|
|
--accent: #10b981;
|
|
--accent-hover: #059669;
|
|
--danger: #ef4444;
|
|
--danger-bg: #fef2f2;
|
|
--shadow-sm: 0 1px 2px rgba(0,0,0,.05);
|
|
--shadow-md: 0 4px 12px rgba(0,0,0,.08);
|
|
--shadow-lg: 0 8px 24px rgba(0,0,0,.12);
|
|
--radius: 12px;
|
|
--radius-lg: 16px;
|
|
--transition: .2s ease;
|
|
--sidebar-width: 272px;
|
|
--header-height: 56px;
|
|
}
|
|
|
|
.dark {
|
|
--bg: #0f0f0f;
|
|
--bg-secondary: #1a1a1a;
|
|
--bg-tertiary: #252525;
|
|
--surface: #1a1a1a;
|
|
--border: #2a2a2a;
|
|
--border-light: #222;
|
|
--text: #f0f0f0;
|
|
--text-secondary: #999;
|
|
--text-muted: #666;
|
|
--primary: #e5e5e5;
|
|
--primary-fg: #111;
|
|
--accent: #10b981;
|
|
--accent-hover: #34d399;
|
|
--danger: #f87171;
|
|
--danger-bg: #2a1515;
|
|
--shadow-sm: 0 1px 2px rgba(0,0,0,.2);
|
|
--shadow-md: 0 4px 12px rgba(0,0,0,.3);
|
|
--shadow-lg: 0 8px 24px rgba(0,0,0,.4);
|
|
}
|
|
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
height: 100vh;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* ---- Layout ---- */
|
|
#app {
|
|
display: flex;
|
|
height: 100vh;
|
|
}
|
|
|
|
.hidden { display: none !important; }
|
|
|
|
/* ---- Sidebar ---- */
|
|
.sidebar {
|
|
width: var(--sidebar-width);
|
|
min-width: var(--sidebar-width);
|
|
background: var(--surface);
|
|
border-right: 1px solid var(--border);
|
|
display: flex;
|
|
flex-direction: column;
|
|
transition: margin-left var(--transition), opacity var(--transition);
|
|
z-index: 20;
|
|
}
|
|
|
|
.sidebar.collapsed {
|
|
margin-left: calc(-1 * var(--sidebar-width));
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.sidebar-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 16px;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.logo {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
font-weight: 700;
|
|
font-size: 15px;
|
|
color: var(--accent);
|
|
}
|
|
|
|
.new-chat-btn {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin: 12px;
|
|
padding: 10px 16px;
|
|
border: 1px dashed var(--border);
|
|
border-radius: var(--radius);
|
|
background: transparent;
|
|
color: var(--text);
|
|
font-size: 13px;
|
|
cursor: pointer;
|
|
transition: all var(--transition);
|
|
}
|
|
.new-chat-btn:hover {
|
|
background: var(--bg-tertiary);
|
|
border-color: var(--accent);
|
|
color: var(--accent);
|
|
}
|
|
|
|
.history-list {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 4px 8px;
|
|
}
|
|
.history-list::-webkit-scrollbar { width: 4px; }
|
|
.history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
|
|
|
|
.history-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
padding: 10px 12px;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition: background var(--transition);
|
|
margin-bottom: 2px;
|
|
}
|
|
.history-item:hover { background: var(--bg-tertiary); }
|
|
.history-item.active { background: var(--primary); color: var(--primary-fg); }
|
|
|
|
.history-item .title {
|
|
flex: 1;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.history-item .time {
|
|
font-size: 11px;
|
|
opacity: .5;
|
|
white-space: nowrap;
|
|
}
|
|
.history-item .delete-btn {
|
|
opacity: 0;
|
|
background: none;
|
|
border: none;
|
|
color: inherit;
|
|
cursor: pointer;
|
|
padding: 2px;
|
|
transition: opacity var(--transition);
|
|
}
|
|
.history-item:hover .delete-btn { opacity: .6; }
|
|
.history-item .delete-btn:hover { opacity: 1; }
|
|
|
|
.sidebar-footer {
|
|
padding: 12px 16px;
|
|
border-top: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--text-muted);
|
|
}
|
|
.status-dot.online { background: var(--accent); }
|
|
.status-dot.offline { background: var(--danger); }
|
|
|
|
.status-text { color: var(--text-secondary); }
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
color: var(--text-muted);
|
|
font-size: 13px;
|
|
padding: 32px 16px;
|
|
}
|
|
|
|
/* ---- Main ---- */
|
|
.main {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-width: 0;
|
|
}
|
|
|
|
/* ---- Header ---- */
|
|
.header {
|
|
height: var(--header-height);
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0 16px;
|
|
gap: 12px;
|
|
background: var(--surface);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.header-center { flex: 1; min-width: 0; }
|
|
.header-center h1 { font-size: 15px; font-weight: 600; }
|
|
.header-subtitle { font-size: 12px; color: var(--text-secondary); }
|
|
|
|
.header-right { display: flex; align-items: center; gap: 4px; }
|
|
|
|
.icon-btn {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 36px;
|
|
height: 36px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
background: transparent;
|
|
color: var(--text-secondary);
|
|
cursor: pointer;
|
|
transition: all var(--transition);
|
|
}
|
|
.icon-btn:hover { background: var(--bg-tertiary); color: var(--text); }
|
|
|
|
.badge {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 6px 12px;
|
|
border: 1px solid var(--border);
|
|
border-radius: 20px;
|
|
background: transparent;
|
|
color: var(--text-secondary);
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all var(--transition);
|
|
}
|
|
.badge:hover { border-color: var(--text-secondary); }
|
|
.badge.active { border-color: var(--accent); color: var(--accent); }
|
|
.badge.recording {
|
|
border-color: var(--danger);
|
|
color: var(--danger);
|
|
background: var(--danger-bg);
|
|
animation: pulse-badge 1.5s ease infinite;
|
|
}
|
|
|
|
@keyframes pulse-badge {
|
|
0%, 100% { opacity: 1; }
|
|
50% { opacity: .7; }
|
|
}
|
|
|
|
/* ---- Chat Area ---- */
|
|
.chat-area {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 16px;
|
|
}
|
|
.chat-area::-webkit-scrollbar { width: 6px; }
|
|
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
|
|
|
|
.welcome {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100%;
|
|
text-align: center;
|
|
gap: 12px;
|
|
padding: 32px;
|
|
}
|
|
.welcome-icon {
|
|
width: 72px;
|
|
height: 72px;
|
|
border-radius: 20px;
|
|
background: linear-gradient(135deg, var(--accent), #06b6d4);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: white;
|
|
margin-bottom: 8px;
|
|
}
|
|
.welcome h2 { font-size: 22px; font-weight: 700; }
|
|
.welcome p { font-size: 14px; color: var(--text-secondary); max-width: 320px; line-height: 1.6; }
|
|
|
|
.messages {
|
|
max-width: 720px;
|
|
margin: 0 auto;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
/* ---- Message Bubbles ---- */
|
|
.message {
|
|
display: flex;
|
|
gap: 10px;
|
|
padding: 8px 0;
|
|
animation: msg-in .25s ease;
|
|
}
|
|
@keyframes msg-in {
|
|
from { opacity: 0; transform: translateY(8px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
.message.user { flex-direction: row-reverse; }
|
|
|
|
.avatar {
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
font-size: 14px;
|
|
}
|
|
.message.user .avatar { background: var(--primary); color: var(--primary-fg); }
|
|
.message.assistant .avatar { background: var(--bg-tertiary); color: var(--text-secondary); }
|
|
|
|
.bubble {
|
|
max-width: 75%;
|
|
padding: 10px 16px;
|
|
border-radius: 18px;
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
position: relative;
|
|
}
|
|
.message.user .bubble {
|
|
background: var(--primary);
|
|
color: var(--primary-fg);
|
|
border-bottom-right-radius: 4px;
|
|
}
|
|
.message.assistant .bubble {
|
|
background: var(--bg-tertiary);
|
|
color: var(--text);
|
|
border-bottom-left-radius: 4px;
|
|
}
|
|
|
|
.bubble .speak-btn {
|
|
position: absolute;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
opacity: 0;
|
|
transition: opacity var(--transition);
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: 50%;
|
|
width: 28px;
|
|
height: 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
color: var(--text-secondary);
|
|
}
|
|
.message.assistant .bubble .speak-btn { left: -36px; }
|
|
.bubble:hover .speak-btn { opacity: 1; }
|
|
|
|
/* Typing indicator */
|
|
.typing-indicator {
|
|
display: flex;
|
|
gap: 5px;
|
|
padding: 4px 0;
|
|
}
|
|
.typing-indicator span {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--text-muted);
|
|
animation: typing-bounce 1.4s ease-in-out infinite;
|
|
}
|
|
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
|
|
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
|
|
@keyframes typing-bounce {
|
|
0%, 60%, 100% { transform: translateY(0); }
|
|
30% { transform: translateY(-6px); }
|
|
}
|
|
|
|
/* Streaming cursor */
|
|
.streaming-cursor {
|
|
display: inline-block;
|
|
width: 2px;
|
|
height: 16px;
|
|
background: var(--text-secondary);
|
|
vertical-align: text-bottom;
|
|
animation: blink .8s ease infinite;
|
|
margin-left: 2px;
|
|
}
|
|
@keyframes blink {
|
|
0%, 50% { opacity: 1; }
|
|
51%, 100% { opacity: 0; }
|
|
}
|
|
|
|
/* Action card */
|
|
.action-card {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 8px 14px;
|
|
margin-top: 8px;
|
|
border-radius: 10px;
|
|
background: var(--accent);
|
|
color: white;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
}
|
|
.action-card svg { flex-shrink: 0; }
|
|
|
|
/* ---- Input Area ---- */
|
|
.input-area {
|
|
border-top: 1px solid var(--border);
|
|
padding: 12px 16px;
|
|
background: var(--surface);
|
|
}
|
|
|
|
.chat-form {
|
|
max-width: 720px;
|
|
margin: 0 auto;
|
|
display: flex;
|
|
align-items: flex-end;
|
|
gap: 10px;
|
|
}
|
|
|
|
.mic-btn {
|
|
width: 42px;
|
|
height: 42px;
|
|
border-radius: 50%;
|
|
border: 1px solid var(--border);
|
|
background: transparent;
|
|
color: var(--text-secondary);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
transition: all var(--transition);
|
|
}
|
|
.mic-btn:hover { border-color: var(--text-secondary); color: var(--text); }
|
|
.mic-btn.recording {
|
|
background: var(--danger);
|
|
border-color: var(--danger);
|
|
color: white;
|
|
animation: pulse-mic 1.5s ease infinite;
|
|
}
|
|
@keyframes pulse-mic {
|
|
0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
|
|
50% { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
|
|
}
|
|
|
|
.input-wrapper {
|
|
flex: 1;
|
|
position: relative;
|
|
}
|
|
|
|
#message-input {
|
|
width: 100%;
|
|
padding: 10px 16px;
|
|
border: 1px solid var(--border);
|
|
border-radius: 22px;
|
|
background: var(--bg-secondary);
|
|
color: var(--text);
|
|
font-size: 14px;
|
|
font-family: inherit;
|
|
resize: none;
|
|
outline: none;
|
|
line-height: 1.5;
|
|
max-height: 160px;
|
|
transition: border-color var(--transition);
|
|
}
|
|
#message-input:focus { border-color: var(--accent); }
|
|
#message-input::placeholder { color: var(--text-muted); }
|
|
|
|
.send-btn {
|
|
width: 42px;
|
|
height: 42px;
|
|
border-radius: 50%;
|
|
border: none;
|
|
background: var(--primary);
|
|
color: var(--primary-fg);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
transition: all var(--transition);
|
|
opacity: .4;
|
|
}
|
|
.send-btn:not(:disabled) { opacity: 1; }
|
|
.send-btn:not(:disabled):hover { transform: scale(1.05); }
|
|
|
|
.recording-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 6px;
|
|
margin-top: 6px;
|
|
font-size: 12px;
|
|
color: var(--danger);
|
|
}
|
|
.rec-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--danger);
|
|
animation: blink 1s ease infinite;
|
|
}
|
|
|
|
/* ---- Settings Panel ---- */
|
|
.overlay {
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(0,0,0,.4);
|
|
z-index: 40;
|
|
backdrop-filter: blur(2px);
|
|
}
|
|
|
|
.settings-panel {
|
|
position: fixed;
|
|
top: 0;
|
|
right: 0;
|
|
width: 360px;
|
|
max-width: 90vw;
|
|
height: 100vh;
|
|
background: var(--surface);
|
|
border-left: 1px solid var(--border);
|
|
z-index: 50;
|
|
display: flex;
|
|
flex-direction: column;
|
|
box-shadow: var(--shadow-lg);
|
|
}
|
|
|
|
.settings-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 16px 20px;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
.settings-header h2 { font-size: 16px; font-weight: 600; }
|
|
|
|
.settings-body {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.setting-group h3 {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: .05em;
|
|
color: var(--text-muted);
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.setting-row {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 10px 0;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.setting-label { font-size: 14px; font-weight: 500; display: block; }
|
|
.setting-desc { font-size: 12px; color: var(--text-muted); display: block; margin-top: 2px; }
|
|
|
|
.setting-row input[type="checkbox"] {
|
|
width: 40px;
|
|
height: 22px;
|
|
accent-color: var(--accent);
|
|
cursor: pointer;
|
|
}
|
|
|
|
.divider {
|
|
border: none;
|
|
border-top: 1px solid var(--border);
|
|
margin: 16px 0;
|
|
}
|
|
|
|
.about-text {
|
|
font-size: 13px;
|
|
color: var(--text-secondary);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
/* ---- Responsive ---- */
|
|
@media (max-width: 768px) {
|
|
.sidebar {
|
|
position: fixed;
|
|
left: 0;
|
|
top: 0;
|
|
height: 100vh;
|
|
z-index: 30;
|
|
box-shadow: var(--shadow-lg);
|
|
}
|
|
.sidebar.collapsed {
|
|
margin-left: 0;
|
|
transform: translateX(-100%);
|
|
}
|
|
.bubble { max-width: 85%; }
|
|
.badge span { display: none; }
|
|
.settings-panel { width: 100%; }
|
|
}
|
|
|
|
/* ---- Theme toggle (top-right of settings) ---- */
|
|
.theme-toggle {
|
|
margin-top: auto;
|
|
padding-top: 16px;
|
|
}
|