:root { color-scheme: light dark; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #0b0c0d;
  color: #e9ecef;
}

/* Topbar */
.topbar{
  position: sticky; top: 0;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: #111417; border-bottom: 1px solid #1f2428;
}
.brand{ font-weight: 600; }
.hidden{ display: none !important; }

/* Layout & Karten */
#app{ max-width: 960px; margin: 0 auto; padding: 16px; }
.card{
  background: #111417; border: 1px solid #1f2428; border-radius: 16px;
  padding: 20px; margin: 16px 0;
}
.card h1{ margin: 0 0 10px; font-size: 20px; }
.hint{ opacity: .8; font-size: 13px; }

/* Formulare */
form{ display: flex; gap: 10px; }
input, textarea, button{ font: inherit; }
input, textarea{
  flex: 1; padding: 12px 14px; border-radius: 12px;
  border: 1px solid #2a3036; background: #0b0c0d; color: inherit;
}
button{
  padding: 12px 16px; border: 0; border-radius: 12px;
  background: #2f6df7; color: #fff; cursor: pointer;
}
button[disabled]{ opacity: .6; cursor: not-allowed; }
.linklike{ background: transparent; color: #8cb4ff; padding: 0; }

/* Chat / Nachrichten */
.chat{ display: flex; flex-direction: column; gap: 12px; }

/* Wrapper (mit Intro-Overlay darüber) */
.messages{
  position: relative;
  display: flex; flex-direction: column; gap: 12px;
  padding: 12px;
  background: #0d0f12; border: 1px solid #1f2428; border-radius: 16px;
  min-height: 240px; max-height: 50vh; overflow: auto;
}

/* Hart codiertes Intro (liegt über #messages, aber klicktransparent) */
#introOverlay{
  position: absolute; inset: 12px; z-index: 2;
  pointer-events: none;
}
#introOverlay .msg{ margin: 0; }

/* Eigentliche Liste, wird vom JS gefüllt */
#messages{ position: relative; z-index: 1; }

/* Nachrichtenzeile */
.msg{ display: flex; width: 100%; gap: 10px; align-items: flex-start; }
.msg.user{ justify-content: flex-start; }
.msg.assistant{ justify-content: flex-end; }

/* vertikale Gruppe (Bubble + Dateinamen) */
.msg .bgroup{ display: flex; flex-direction: column; max-width: 85%; }
.msg.assistant .bgroup{ margin-left: auto; align-items: flex-end; }
.msg.user .bgroup{ margin-right: auto; }

/* Bubbles */
.msg .bubble{
  padding: 10px 12px; border-radius: 12px;
  background: #12161b; border: 1px solid #222a31; max-width: 100%;
}
.msg.user .bubble{ background: #132433; border-color: #254b6e; }
.msg.assistant .bubble{ background: #1a1b1e; border-color: #2a2f36; }

/* Anhänge (Thumbnails) */
.msg .att-thumbs{ margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg .att-thumbs a{
  display: block; width: 96px; height: 96px;
  border: 1px solid #2a3036; border-radius: 10px; overflow: hidden;
}
.msg .att-thumbs img{ width: 100%; height: 100%; object-fit: cover; display: block; }

/* Dateinamen-Chips */
.attachlist{ margin-top: 6px; font-size: 12px; opacity: .9; }
.attachlist span{
  display: inline-block; margin-right: 8px; padding: 2px 6px;
  border: 1px solid #2a3036; border-radius: 8px;
}
.msg.assistant .attachlist{ text-align: right; }

/* Uploader */
.uploader{
  border: 1px dashed #2a3036; border-radius: 16px; padding: 12px;
  background: #0d0f12; outline: none; margin-top: 12px;
}
.uploader:focus{ border-color: #3b82f6; box-shadow: 0 0 0 2px #1d4ed8 inset; }
.uploader-inner{ display: flex; flex-direction: column; gap: 10px; }
.thumbs{ display: flex; gap: 8px; flex-wrap: wrap; }
.thumb{
  position: relative; width: 84px; height: 84px;
  border: 1px solid #2a3036; border-radius: 12px; overflow: hidden;
}
.thumb img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button{
  position: absolute; top: 4px; right: 4px;
  background: #000a; border: 0; border-radius: 8px; padding: 4px 6px; color: #fff;
}

/* Composer */
.composer{ display: flex; gap: 10px; align-items: flex-end; margin-top: 8px; }
.composer textarea{ min-height: 48px; resize: vertical; }

@media (max-width: 520px){
  .composer{ flex-direction: column; align-items: stretch; }
  .composer button{ width: 100%; }
}
