/* Öffentlicher Live-Fragen-Chat */
#public-chat-root {
  position: fixed; right: 14px; bottom: calc(132px + env(safe-area-inset-bottom));
  z-index: 57; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 10px;
}
/* 22.11.2026: kein schwebendes Mini-Fenster und kein Button mehr.
   Der Live Chat ist dauerhaft im Hauptfenster eingebettet – die
   Sprecherfarben (--pc-h) bleiben unverändert. */
.pc-fab { display: none !important; }
#public-chat-root[hidden] { display: none !important; }
#public-chat-root:not(.pc-in-arena) { display: none; }
.pc-fab {
  position: relative; pointer-events: auto; cursor: pointer;
  display: grid; gap: 1px; place-items: center;
  min-width: 58px; padding: 8px 10px 7px;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
  border-radius: 999px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 8px 22px -10px rgba(0,0,0,.45);
  font: inherit;
}
.pc-open .pc-fab { display: none; }
.pc-fab span { font-size: 17px; line-height: 1; }
.pc-fab small { font-size: 9px; font-weight: 750; letter-spacing: .02em; }
.pc-fab i {
  position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 4px;
  border-radius: 999px; background: #e2573f; color: #fff;
  font: 700 10px/19px sans-serif; text-align: center; display: none;
}
.pc-fab i[data-unread]:not([data-unread="0"]) { display: block; }
.pc-fab.has-unread { animation: pcPulse 1.9s ease-in-out infinite; }
@keyframes pcPulse {
  0%, 100% { box-shadow: 0 8px 22px -10px rgba(0,0,0,.45), 0 0 0 0 rgba(226,87,63,.55); }
  50%      { box-shadow: 0 8px 22px -10px rgba(0,0,0,.45), 0 0 0 9px rgba(226,87,63,0); }
}

.pc-panel {
  pointer-events: auto;
  width: 360px; max-width: calc(100vw - 24px);
  height: 480px; max-height: calc(100vh - 210px);
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); box-shadow: 0 22px 54px -20px rgba(0,0,0,.45);
  overflow: hidden; animation: pcIn .18s ease;
  touch-action: pan-y; /* kein Pinch/Zwei-Finger-Wischen im Fenster */
}
/* WICHTIG: hidden muss gewinnen, sonst ist das Fenster auf dem Handy immer offen */
.pc-panel[hidden] { display: none; }
@keyframes pcIn { from { transform: translateY(10px); opacity: 0; } }

.pc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--brand) 7%, var(--surface));
}
.pc-head > div { display: grid; gap: 2px; flex: 1 1 150px; min-width: 0; }
.pc-head b { font-size: 14px; }
/* „tippt gerade: Name" direkt neben dem Chat-Namen */
.pc-typing {
  font-style: normal; font-size: 11px; font-weight: 600;
  color: var(--brand); margin-left: 7px; white-space: nowrap;
}
.pc-typing[hidden] { display: none; }
.pc-head small { font-size: 10px; color: var(--ink-3); }
.pc-head button { border: 0; background: transparent; color: var(--ink-3); font-size: 16px; cursor: pointer; }
/* Tonauswahl direkt in der Kopf-Leiste */
.pc-sound { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--ink-2); }
.pc-sound select {
  max-width: 118px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 11px;
  padding: 4px 5px; cursor: pointer;
}
.pc-sound select:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
.pc-head .pc-bell { font-size: 15px; padding: 2px 4px; border-radius: 8px; }
.pc-head .pc-bell:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
/* Neue Nachrichten-Zähler AUCH im geöffneten Fenster (PC + Handy) */
.pc-head-unread {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  margin-left: 4px; padding: 0 5px; border-radius: 999px;
  background: #e2573f; color: #fff; font: 800 10px/1 sans-serif;
  vertical-align: middle;
}
.pc-head-unread[hidden] { display: none; }

.pc-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pc-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 0; align-content: start; padding: 10px 12px; }
.pc-empty { text-align: center; color: var(--ink-3); padding: 30px 16px; display: grid; gap: 6px; justify-items: center; }
.pc-empty span { font-size: 30px; }
.pc-empty b { color: var(--ink); font-size: 14px; }
.pc-empty p { margin: 0; font-size: 12px; line-height: 1.45; }

/* Chef 20.11.: KEINE Nachrichten-Kaesten mehr – flacher, ruhiger Chat-
   Verlauf wie ein echter Messenger. Nur Text + dezente Zeilen-Trennung. */
.pc-msg { border: 0; border-radius: 0; padding: 5px 4px; display: grid; gap: 2px; background: transparent; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.pc-msg:last-child { border-bottom: 0; }
.pc-msg.pc-admin { background: transparent; }
.pc-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pc-meta b { font-size: 11.5px; }
.pc-meta time { font-size: 9.5px; color: var(--ink-3); margin-left: auto; }
.pc-badge { font-size: 8.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; padding: 1px 5px; border-radius: 999px; background: #d49b1d; color: #1a1300; }
.pc-text { font-size: 13px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Sprecherfarbe: --pc-h kommt pro Nachricht aus dem JS (Hash der user_id,
   im sichtbaren Thread kollisionsfrei). Helligkeit folgt demTheme, damit
   light/dark beide lesbar bleiben. */
.pc-msg { color: hsl(var(--pc-h, 150), 68%, var(--pc-l, 30%)); }
.pc-reply { --pc-l: var(--pc-l-reply, 46%); }
[data-theme="dark"] { --pc-l: 72%; --pc-l-reply: 86%; }
.pc-reply-to { font-size: 10px; font-weight: 800; opacity: .8; }
.pc-deleted-text { font-style: italic; color: var(--ink-3); opacity: .75; }
.pc-msg.pc-deleted { opacity: .7; }
.pc-actions { display: flex; justify-content: flex-end; gap: 10px; }
.pc-actions button { border: 0; background: transparent; color: var(--brand); font: inherit; font-size: 10px; font-weight: 600; cursor: pointer; padding: 0; opacity: .45; }
.pc-actions .pc-del { color: #c2523d; }
@media (hover: hover) {
  .pc-actions { opacity: 0; transition: opacity .12s; }
  .pc-msg:hover .pc-actions, .pc-msg:focus-within .pc-actions { opacity: 1; }
  .pc-actions button { opacity: 1; }
}
.pc-reply { margin: 4px 0 0 14px; border-left: 0; background: transparent; padding-left: 8px; opacity: .85; }

.pc-replybar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 12px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-3);
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
}
.pc-replybar[hidden] { display: none; }
.pc-replybar button { border: 0; background: transparent; cursor: pointer; color: var(--ink-3); }

.pc-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.pc-compose textarea {
  flex: 1; min-height: 44px; max-height: 110px; resize: vertical;
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px;
}
.pc-compose .btn { flex: 0 0 auto; }
.pc-compose-label { display: none; }
.pc-compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-compose-foot small { color: var(--ink-3); font-size: 10px; }

/* Handy: nur der Button, Fenster auf Knopfdruck */
@media (max-width: 899px) {
  #public-chat-root { right: 8px; bottom: calc(132px + env(safe-area-inset-bottom)); }
  .pc-panel { height: min(560px, calc(100vh - 200px)); }
}

/* PC: Fenster dauerhaft oben rechts offen, kein Button nötig */
@media (min-width: 900px) {
  #public-chat-root {
    top: calc(var(--appbar-h, 74px) + var(--opbar-h, 0px) + var(--locbar-h, 0px) + 12px);
    bottom: auto; right: 16px;
  }
  .pc-panel {
    width: 340px;
    height: min(520px, calc(100vh - var(--appbar-h, 74px) - 34px));
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pc-panel, .pc-fab.has-unread { animation: none; }
}

/* Startseite (PC + Handy): Chat als EIN professioneller, vollbreiter Block
   ganz oben in der Arena. Champions + Live Matches bleiben darunter VOLL
   sichtbar. Auf dem Handy kein schwebender Button – das Fenster scrollt
   ganz normal mit der Seite (wie auf der Domain-Seite). */
#public-chat-root.pc-in-arena {
  position: static; inset: auto; display: block; width: 100%;
  margin: 0 0 14px; z-index: auto;
}
#public-chat-root.pc-in-arena .pc-fab,
#public-chat-root.pc-in-arena [data-pc-close] { display: none; }
#public-chat-root.pc-in-arena .pc-panel {
  width: 100%; height: 330px; max-height: none; border-radius: 14px;
  box-shadow: 0 14px 34px -22px rgba(0,0,0,.5);
}
#public-chat-root.pc-in-arena .pc-list { padding: 14px 16px; }
#public-chat-root.pc-in-arena .pc-compose { padding: 10px 14px; }
#public-chat-root.pc-in-arena .pc-compose textarea { max-height: 84px; }
/* Zwei Spalten: Nachrichten links, Eingabe rechts - wie ein echtes Postfach */
#public-chat-root.pc-in-arena .pc-body {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 1; min-height: 0;
}
#public-chat-root.pc-in-arena .pc-list { border-right: 1px solid var(--line); }
#public-chat-root.pc-in-arena .pc-replybar { grid-column: 1 / -1; }
#public-chat-root.pc-in-arena .pc-compose {
  display: flex; align-items: stretch; flex-direction: column; justify-content: flex-start;
  gap: 8px; border-top: 0; border-left: 0; padding: 14px;
  background: color-mix(in srgb, var(--brand) 4%, var(--surface));
}
#public-chat-root.pc-in-arena .pc-compose-label {
  display: block; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-3);
}
#public-chat-root.pc-in-arena .pc-compose textarea {
  flex: 1; min-height: 120px; max-height: none; resize: none;
}
#public-chat-root.pc-in-arena .pc-compose-foot { margin-top: auto; }

/* Handy: gleiches Fenster, aber eine Spalte und kompaktere Hoehe. */
@media (max-width: 899px) {
  #public-chat-root.pc-in-arena { margin: 0 0 12px; }
  #public-chat-root.pc-in-arena .pc-panel { height: 380px; }
  #public-chat-root.pc-in-arena .pc-body { display: flex; flex-direction: column; }
  #public-chat-root.pc-in-arena .pc-list {
    border-right: 0; padding: 10px 12px; overscroll-behavior: contain;
  }
  #public-chat-root.pc-in-arena .pc-replybar { grid-column: auto; }
  #public-chat-root.pc-in-arena .pc-compose {
    flex-direction: row; align-items: flex-end; gap: 8px; padding: 10px 12px;
  }
  #public-chat-root.pc-in-arena .pc-compose-label { display: none; }
  #public-chat-root.pc-in-arena .pc-compose textarea {
    min-height: 44px; max-height: 110px; resize: vertical;
  }
  #public-chat-root.pc-in-arena .pc-compose-foot { margin-top: 0; }
}
