/*
 * Farben zentral als Variablen: So lässt sich später ein Corporate Design
 * einsetzen, ohne das Stylesheet aufzubrechen.
 */
:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-input: #1f242c;
  --line: #2a313c;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #2f81f7;
  --danger: #f85149;
  --warn: #d29922;
  --radius: 12px;

  --name-0: #ff8a80; --name-1: #ffd180; --name-2: #ffff8d; --name-3: #ccff90;
  --name-4: #a7ffeb; --name-5: #84ffff; --name-6: #80d8ff; --name-7: #8c9eff;
  --name-8: #b388ff; --name-9: #ea80fc; --name-10: #ff80ab; --name-11: #f8bbd0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  /* Die Seite selbst scrollt nie - das übernimmt allein die Nachrichtenliste. */
  overflow: hidden;
}

/*
 * `--app-height` wird laufend auf die Höhe des tatsächlich sichtbaren Bereichs
 * gesetzt (siehe app.js). Kommt die Tastatur hoch, schrumpft der Wert - die
 * Nachrichtenliste wird kleiner, Eingabefeld und Reaktionstasten rutschen mit
 * nach oben und bleiben sichtbar.
 *
 * `100dvh` bleibt als Rückfall für Browser ohne VisualViewport-Schnittstelle.
 */
.screen {
  height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  /* Ohne Mindesthöhe kann die Liste bei sehr kleiner Tastaturhöhe verschwinden. */
  min-height: 0;
}
[hidden] { display: none !important; }

/* --- Anmeldung --- */
#login { align-items: center; justify-content: center; padding: 24px; }

.card {
  width: min(420px, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h1 { margin: 0; font-size: 22px; }
.hint { margin: 0 0 8px; color: var(--text-dim); font-size: 14px; }
label { font-size: 13px; color: var(--text-dim); }

input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px; /* verhindert das Zoomen auf iOS */
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  padding: 12px 16px;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }

.error { margin: 4px 0 0; color: var(--danger); font-size: 14px; }

/* --- Chat --- */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .3px; }
.status { font-size: 13px; color: var(--text-dim); }
.status[data-state="online"] { color: #3fb950; }
.status[data-state="offline"] { color: var(--danger); }
.online { margin-left: auto; font-size: 13px; color: var(--text-dim); }
.online::before { content: "👥 "; }

.messages {
  flex: 1 1 auto;
  /* Erlaubt dem Flex-Element, kleiner als sein Inhalt zu werden - ohne das
     wächst die Liste über den Bildschirm hinaus und schiebt die Eingabe weg. */
  min-height: 0;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.messages li { padding: 3px 0; word-wrap: break-word; overflow-wrap: anywhere; }
.messages .who { font-weight: 600; }
.messages .who::after { content: ": "; color: var(--text-dim); font-weight: 400; }
.messages li.own { background: rgba(47, 129, 247, .08); border-radius: 6px; padding-inline: 6px; }
.messages li.gone { opacity: .35; text-decoration: line-through; }
.messages .system { color: var(--text-dim); font-size: 13px; font-style: italic; }

.jump {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  /* Über der Eingabe, die selbst mit der Tastatur nach oben wandert. */
  bottom: calc(100dvh - var(--app-height, 100dvh) + 150px);
  padding: 6px 14px;
  background: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.composer {
  /* Darf nie schrumpfen: Was man tippt, muss man sehen. */
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.reactions { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.reactions button {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 22px;
  padding: 6px 14px;
  line-height: 1;
  transition: transform .08s ease;
}
.reactions button:active { transform: scale(1.25); }

#send-form { display: flex; gap: 8px; }
#send-form input { flex: 1; }
#send-form button { min-width: 56px; }

.notice { margin: 6px 0 0; min-height: 18px; font-size: 13px; color: var(--text-dim); }
.notice.warn { color: #d29922; }

/* --- Rückmeldung auf eine gesendete Reaktion --- */

/*
 * Das aufsteigende Emoji liegt über allem und fängt keine Klicks ab.
 * `position: fixed`, weil die Startposition aus getBoundingClientRect kommt -
 * also bezogen auf das sichtbare Fenster, nicht auf das Dokument.
 */
.fly {
  position: fixed;
  z-index: 50;
  font-size: 30px;
  line-height: 1;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Zu früh geklickt: Die Taste zuckt kurz, es fliegt aber nichts. */
.reactions button.abgelehnt {
  animation: abgelehnt .3s ease;
}

@keyframes abgelehnt {
  0%, 100% { transform: none; opacity: 1; }
  25%      { transform: translateX(-3px); opacity: .5; }
  75%      { transform: translateX(3px); opacity: .5; }
}

/* Wer Bewegung im Bild nicht verträgt, bekommt sie auch nicht. */
@media (prefers-reduced-motion: reduce) {
  .fly { display: none; }
  .reactions button.abgelehnt { animation: none; opacity: .5; }
}

/* Hinweise zu einer abgelehnten Nachricht - auffällig, aber nicht schreiend. */
.messages .system.warn {
  color: var(--warn, #d29922);
  font-style: normal;
  background: rgba(210, 153, 34, .1);
  border-left: 3px solid var(--warn, #d29922);
  border-radius: 4px;
  padding: 5px 10px;
  margin: 3px 0;
}
