:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #6b7580;
  --accent: #12314f;
  --accent-soft: #e7edf3;
  --user: #12314f;
  --line: #e3e1da;
  --radius: 16px;
  --maxw: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Georgia", "Iowan Old Style", "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Kopfzeile */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,.12);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--maxw);
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.55);
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 700; font-size: 19px; }
.brand-sub { font-size: 13px; opacity: .85; font-family: system-ui, sans-serif; }

/* Sprachumschalter */
.lang { display: flex; gap: 2px; flex: 0 0 auto; }
.lang button {
  border: 1px solid rgba(255,255,255,.4);
  background: transparent;
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  cursor: pointer;
  line-height: 1;
}
.lang button:first-child { border-radius: 6px 0 0 6px; }
.lang button:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.lang button.active { background: #fff; color: var(--accent); }

/* Chat-Bereich */
.chat {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 8px;
  overflow-y: auto;
}
.msg { display: flex; margin-bottom: 18px; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 88%;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user .bubble {
  background: var(--user);
  color: #fff;
  border-color: var(--user);
  border-bottom-right-radius: 5px;
}
.msg.bot .bubble { border-bottom-left-radius: 5px; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble .hint {
  font-size: 13.5px;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  border-top: 1px solid var(--line);
  padding-top: 9px;
  margin-top: 4px;
}

/* Quellen */
.sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: system-ui, sans-serif;
  font-size: 13.5px;
  color: var(--muted);
}
.sources b { color: var(--ink); font-weight: 600; }
.sources a { color: var(--accent); text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.sources .src-item { display: inline; }

/* System-/Fehlermeldung */
.msg.system .bubble {
  background: var(--accent-soft);
  border-color: #cdd9e4;
  font-family: system-ui, sans-serif;
  font-size: 15px;
  color: var(--accent);
}

/* Tipp-Anzeige */
.typing .bubble { display: inline-flex; gap: 5px; padding: 16px 18px; }
.typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); opacity: .5;
  animation: blink 1.3s infinite both;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.25} 40%{opacity:.9} }

/* Eingabe */
.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 16px 6px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
#input {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 13px 16px;
  border: 1px solid #cfccc3;
  border-radius: 14px;
  background: #fff;
  font-family: system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
}
#input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
#send {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity .15s, transform .05s;
}
#send:hover { opacity: .9; }
#send:active { transform: scale(.94); }
#send:disabled { opacity: .4; cursor: default; }

.footnote {
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 auto 10px;
  padding: 0 16px;
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .bubble { max-width: 92%; }
}
