:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --user-bubble: #4f46e5;
  --ai-bubble: #1e293b;
  --border: #334155;
  --success: #22c55e;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(90deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.control-group {
  flex: 1;
  min-width: 140px;
}

.control-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.chat-container {
  flex: 1;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 400px;
  max-height: calc(100vh - 320px);
}

.message {
  display: flex;
  gap: 0.75rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.message.user .avatar {
  background: var(--user-bubble);
}

.message.assistant .avatar {
  background: var(--surface-2);
}

.bubble {
  max-width: 75%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.welcome {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.welcome h2 {
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion:hover {
  border-color: var(--primary);
  color: var(--text);
  background: rgba(99, 102, 241, 0.15);
}

.input-area {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

#messageInput {
  flex: 1;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.95rem;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  font-family: inherit;
}

#messageInput:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#messageInput::placeholder {
  color: var(--text-muted);
}

#sendBtn {
  padding: 0.85rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#sendBtn:hover:not(:disabled) {
  background: var(--primary-hover);
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.typing {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0;
}

.typing span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing span:nth-child(1) { animation-delay: 0s; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.error-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #dc2626;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 100;
  animation: fadeIn 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mode-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab:hover {
  border-color: var(--primary);
  color: var(--text);
}

.mode-tab.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: var(--text);
}

.panel.hidden {
  display: none !important;
}

.panel {
  position: relative;
}

.live-container {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  backdrop-filter: blur(10px);
}

.live-top {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.live-video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
}

.live-video.hidden {
  display: none;
}

.live-status {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.live-status[data-state="listening"] {
  border-color: var(--success);
  color: #86efac;
}

.live-status[data-state="speaking"] {
  border-color: var(--primary);
  color: #c4b5fd;
}

.live-status[data-state="connecting"] {
  border-color: #f59e0b;
  color: #fcd34d;
}

.live-camera-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.live-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.live-transcript {
  min-height: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.live-line {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.live-role {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.live-line-user .live-text {
  color: #c7d2fe;
}

.live-line-assistant .live-text {
  color: var(--text);
}

.live-actions {
  display: flex;
  gap: 0.75rem;
  position: relative;
  z-index: 5;
}

.live-btn {
  flex: 1;
  padding: 0.9rem 1rem;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.live-btn-start {
  background: var(--success);
  color: #052e16;
}

.live-btn-stop {
  background: #dc2626;
  color: white;
}

.live-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.live-btn:not(:disabled) {
  pointer-events: auto;
  cursor: pointer;
}

@media (max-width: 600px) {
  .bubble { max-width: 90%; }
  .controls { flex-direction: column; }
  .live-top { grid-template-columns: 1fr; }
  .mode-tabs { flex-direction: column; }
}
