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

:root {
  --bg: #0a0e1a;
  --surface: #111827;
  --border: #1e2d45;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --user-bubble: #1e3a5f;
  --jarvis-bubble: #0f1e33;
  --idle: #3b82f6;
  --thinking: #f59e0b;
  --speaking: #10b981;
  --error: #ef4444;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 720px;
  height: 100dvh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 60px rgba(59, 130, 246, 0.08);
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#mode-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

#mode-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--idle);
  box-shadow: 0 0 8px var(--idle);
  transition: background 0.3s, box-shadow 0.3s;
  flex-shrink: 0;
}

#status-indicator.thinking {
  background: var(--thinking);
  box-shadow: 0 0 8px var(--thinking);
  animation: pulse 1s infinite;
}

#status-indicator.speaking {
  background: var(--speaking);
  box-shadow: 0 0 8px var(--speaking);
}

#status-indicator.error {
  background: var(--error);
  box-shadow: 0 0 8px var(--error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--accent);
  flex: 1;
}

#status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

#chat-container::-webkit-scrollbar {
  width: 4px;
}
#chat-container::-webkit-scrollbar-track {
  background: transparent;
}
#chat-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.jarvis {
  align-self: flex-start;
  align-items: flex-start;
}

.message-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.message-bubble {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
}

.message.user .message-bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
  color: var(--text);
}

.message.jarvis .message-bubble {
  background: var(--jarvis-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.message.error .message-bubble {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

#input-form {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

#user-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

#user-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

#user-input::placeholder {
  color: var(--text-muted);
}

#send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

#send-btn:hover:not(:disabled) {
  opacity: 0.85;
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#mic-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

#mic-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

#mic-btn.listening {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
  animation: pulse 1s infinite;
}

#mic-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Live-Modus ─────────────────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

#live-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

#live-orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, #1e3a5f, #0a0e1a);
  border: 2px solid var(--border);
  transition: all 0.3s;
}

#live-orb.active {
  border-color: var(--accent);
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(59,130,246,0.15);
  animation: pulse 2s infinite;
}

#live-orb.speaking {
  border-color: var(--speaking);
  box-shadow: 0 0 30px rgba(16,185,129,0.4), 0 0 60px rgba(16,185,129,0.2);
  animation: pulse 0.6s infinite;
}

#live-label {
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

#live-stop-btn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

#live-stop-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}
