:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #22262f;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #5b8cff;
  --danger: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Login --- */
.login-body {
  justify-content: center;
  align-items: center;
}

.login-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.login-card h1 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.login-form label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.6rem;
}

.login-form input {
  background: var(--surface-2);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-size: 1rem;
}

.login-form button {
  margin-top: 1.2rem;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.login-form button:hover { opacity: 0.9; }
.hidden { display: none; }
.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; }

/* --- App Shell --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid #2a2e37;
}

.topbar h1 { font-size: 1.1rem; margin: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.switch { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }

#logout-btn {
  background: transparent;
  border: 1px solid #333;
  color: var(--muted);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.bubble {
  max-width: 75%;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  line-height: 1.4;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--surface-2);
}

.bubble.error {
  align-self: center;
  background: rgba(255,107,107,0.15);
  color: var(--danger);
  font-size: 0.9rem;
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.8rem 1.2rem 1.2rem;
  background: var(--surface);
  border-top: 1px solid #2a2e37;
}

#text-input {
  flex: 1;
  resize: none;
  max-height: 140px;
  background: var(--surface-2);
  border: 1px solid #333;
  border-radius: 10px;
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  font-family: inherit;
}

#mic-btn, #send-btn {
  background: var(--surface-2);
  border: 1px solid #333;
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
}

#mic-btn.listening {
  background: var(--danger);
  color: white;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,107,107,0.5); }
  70% { box-shadow: 0 0 0 12px rgba(255,107,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,107,0); }
}

#send-btn { background: var(--accent); color: white; }

/* --- Topbar-Icon-Buttons (Verlauf, Neuer Chat, Einstellungen) --- */
#history-btn, #new-chat-btn, #settings-btn {
  background: transparent;
  border: 1px solid #333;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}
#history-btn:hover, #new-chat-btn:hover, #settings-btn:hover { background: var(--surface-2); }

/* --- Panels (Verlauf, Einstellungen) --- */
.panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}

.panel.hidden { display: none; }

.panel-content {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  height: 100%;
  overflow-y: auto;
  padding: 1.2rem;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-header h2 { margin: 0; font-size: 1.1rem; }

.panel-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.panel-section {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.panel-section h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }

.panel-section label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.6rem;
}

.panel-section input, .panel-section textarea {
  background: var(--surface-2);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

.panel-section button {
  margin-top: 0.8rem;
  padding: 0.6rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  padding-left: 1.2rem;
  padding-right: 1.2rem;
}

.hint { font-size: 0.8rem; color: var(--muted); margin: 0.2rem 0; min-height: 1.1em; }

.conversation-list, .memory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.conversation-list li, .memory-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  cursor: default;
  font-size: 0.9rem;
}

.conversation-list li span { cursor: pointer; flex: 1; }
.conversation-list li:hover { background: #2a2f3a; }

.memory-list li span { flex: 1; white-space: pre-wrap; }

.conversation-list li button, .memory-list li button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
}

.memory-add {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
