:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f242e;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #d97757;
  --accent-2: #c4633f;
  --user: #2a3140;
  --assistant: #1f242e;
  --error: #ff6b6b;
  --ok: #4caf50;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--error); min-height: 1.2em; margin-top: 8px; font-size: 0.9rem; }

.screen { height: 100dvh; display: flex; flex-direction: column; }

/* ---- Login ---- */
#login { align-items: center; justify-content: center; }
.login-card {
  background: var(--panel);
  padding: 32px; border-radius: 16px; width: min(360px, 90vw);
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-card h1 { margin: 0 0 4px; font-size: 1.6rem; }
.login-card input {
  width: 100%; margin-top: 18px; padding: 14px; border-radius: 10px;
  border: 1px solid #2c333f; background: var(--panel-2); color: var(--text); font-size: 1rem;
}
.login-card button {
  width: 100%; margin-top: 14px; padding: 14px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: var(--accent-2); }

/* ---- App ---- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid #232a35;
}
.brand { font-weight: 700; }
.header-actions { display: flex; gap: 8px; }
.ghost {
  background: transparent; border: 1px solid #2c333f; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.85rem;
}
.ghost:hover { color: var(--text); border-color: #3a424f; }

main#conversation {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg {
  max-width: 85%; padding: 12px 16px; border-radius: 14px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word; animation: fade .2s ease;
}
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--assistant); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--muted); font-style: italic; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ---- Player ---- */
.player { background: var(--panel); border-top: 1px solid #232a35; padding: 10px 14px; }
.player-row { display: flex; align-items: center; gap: 10px; }
.circle {
  background: var(--panel-2); color: var(--text); border: 1px solid #2c333f;
  border-radius: 50%; width: 44px; height: 44px; cursor: pointer; font-size: 0.8rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.circle:hover { border-color: var(--accent); }
.circle.big { width: 52px; height: 52px; background: var(--accent); border-color: var(--accent); color: #fff; font-size: 1.2rem; }
.circle.big:hover { background: var(--accent-2); }
.seek-wrap { flex: 1; }
#seek { width: 100%; accent-color: var(--accent); cursor: pointer; }
.times { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.speed {
  background: var(--panel-2); color: var(--muted); border: 1px solid #2c333f;
  border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 0.8rem; flex: none;
}

/* ---- Footer ---- */
footer {
  background: var(--panel); border-top: 1px solid #232a35;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.status { font-size: 0.85rem; min-height: 1.2em; text-align: center; }
.status.rec { color: var(--accent); }
.status.err { color: var(--error); }
.mic {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, box-shadow .2s;
}
.mic:hover { background: var(--accent-2); }
.mic.recording { animation: pulse 1.2s infinite; background: #e0473e; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224,71,62,.6); }
  70% { box-shadow: 0 0 0 18px rgba(224,71,62,0); }
  100% { box-shadow: 0 0 0 0 rgba(224,71,62,0); }
}
.text-form { display: flex; gap: 8px; width: min(560px, 100%); }
.text-form input {
  flex: 1; padding: 12px 14px; border-radius: 10px; border: 1px solid #2c333f;
  background: var(--panel-2); color: var(--text); font-size: 1rem;
}
.send {
  border: 0; border-radius: 10px; background: var(--panel-2); color: var(--text);
  padding: 0 16px; cursor: pointer; font-size: 1.1rem; border: 1px solid #2c333f;
}
.send:hover { border-color: var(--accent); }

/* ---- Gespraechs-Liste (Seitenpanel) ---- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
.chats-panel {
  position: fixed; top: 0; left: 0; height: 100dvh; width: min(340px, 86vw); z-index: 21;
  background: var(--panel); border-right: 1px solid #232a35;
  display: flex; flex-direction: column; box-shadow: 6px 0 40px rgba(0,0,0,.55);
}
.chats-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid #232a35; font-weight: 700;
}
.chats-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.chats-empty { padding: 14px; }
.chat-item {
  text-align: left; background: var(--panel-2); border: 1px solid #2c333f; color: var(--text);
  border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.chat-item:hover { border-color: var(--accent); }
.chat-item.active { border-color: var(--accent); background: #25201d; }
.chat-title { font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta { font-size: 0.75rem; color: var(--muted); }
.chat-row { display: flex; align-items: stretch; gap: 6px; }
.chat-row .chat-item { flex: 1; min-width: 0; }
.chat-row.active .chat-item { border-color: var(--accent); background: #25201d; }
.chat-del {
  flex: none; width: 40px; border-radius: 10px; cursor: pointer;
  background: var(--panel-2); border: 1px solid #2c333f; color: var(--muted); font-size: 0.95rem;
}
.chat-del:hover { border-color: var(--error); color: var(--error); }

/* ---- Gedaechtnis-Panel ---- */
.mem-add { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid #232a35; }
.mem-add input {
  flex: 1; min-width: 0; padding: 10px; border-radius: 8px;
  border: 1px solid #2c333f; background: var(--panel-2); color: var(--text); font-size: 0.9rem;
}
.mem-item {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid #2c333f;
  border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; line-height: 1.4; word-break: break-word;
}
