* { box-sizing: border-box; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial; }
body { margin: 0; background: #f3f5f7; color: #111; }

html, body { height: 100%; }
body { overflow: hidden; }

.center { min-height: 100vh; display: grid; place-items: center; }
.card { width: 320px; background: #fff; padding: 18px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.08); display: grid; gap: 10px; }
.card input, .card button { padding: 10px 12px; border-radius: 10px; border: 1px solid #ddd; }
.card button { background: #111; color: #fff; border: 0; cursor: pointer; }
.err { color: #b00020; min-height: 1.2em; margin: 0; }

.app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }
.sidebar { background:#fff; border-right:1px solid #e7e7e7; display:flex; flex-direction:column; height: 100vh; overflow: hidden; }

.sidebar {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}


.online { overflow: auto; min-height: 0; max-height: 30vh; }


.main { display:flex; flex-direction:column; height: 100vh; overflow: hidden; }



.bar { padding: 12px 14px; border-bottom:1px solid #eee; display:flex; align-items:center; justify-content:space-between; gap: 10px; }
.section { padding: 10px 12px; border-bottom:1px solid #eee; display:grid; gap: 8px; }
.section button { padding: 10px; border-radius: 10px; border:1px solid #ddd; background:#fafafa; cursor:pointer; }

.list {
  flex: 1;                 /* bekommt verfügbaren Platz */
  overflow-y: auto;        /* nur scrollen */
  min-height: 0;           /* Flexbox-Fix */
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatItem { text-align:left; padding:10px; border-radius: 10px; border:1px solid #eee; background:#fff; cursor:pointer;  flex: 0 0 auto;}
.chatItem:hover { background:#f7f7f7; }

.messages { flex:1; overflow:auto; padding: 12px; display:grid; gap: 10px; min-height: 0; }
.msg { background:#fff; border:1px solid #eee; border-radius: 14px; padding: 10px 12px; }
.msg .meta { font-size: 12px; opacity: .7; margin-bottom: 6px; }
.composer { display:flex; gap: 10px; padding: 12px; border-top:1px solid #eee; background:#fff; }
.composer input { flex:1; padding: 10px 12px; border-radius: 12px; border:1px solid #ddd; }
.composer button { padding: 10px 14px; border-radius: 12px; border:0; background:#111; color:#fff; cursor:pointer; }
.online { padding: 10px 12px; display:grid; gap: 6px; overflow:auto; }
.onlineRow { font-size: 14px; }


#newGroup {background-color: #fdf7d4;}
#newDM {background-color: #d0fbdd;}

/* Admin UI */
.adminTop {
  display:flex; justify-content:space-between; align-items:center;
  padding: 12px 14px; background:#fff; border-bottom:1px solid #e7e7e7;
}
.adminTopLeft { display:flex; gap:10px; align-items:baseline; }
.adminTopRight { display:flex; gap:10px; align-items:center; }
.adminWrap { max-width: 1100px; margin: 0 auto; padding: 14px; display:grid; gap: 14px; }
.panel { background:#fff; border:1px solid #eee; border-radius: 14px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.04); }
.panelHeader { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.panelActions { display:flex; gap:10px; align-items:center; }
.panelActions input { padding:10px 12px; border-radius: 10px; border:1px solid #ddd; }
.grid2 { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.grid2 label span { display:block; font-size: 13px; opacity:.8; margin-bottom: 6px; }
.grid2 input, .grid2 select { width:100%; padding:10px 12px; border-radius: 10px; border:1px solid #ddd; }
.hint { display:block; opacity:.65; margin-top: 6px; font-size: 12px; }
.rowEnd { display:flex; align-items:flex-end; justify-content:flex-end; }
.tableWrap { overflow:auto; margin-top: 10px; }
.tbl { width:100%; border-collapse: collapse; min-width: 780px; }
.tbl th, .tbl td { padding: 10px 10px; border-bottom: 1px solid #eee; text-align:left; white-space: nowrap; }
.tbl th { font-size: 13px; opacity: .75; }
.actions { display:flex; gap:8px; }
.btn, .btnPrimary, .btnDanger {
  padding: 10px 12px; border-radius: 10px; border:1px solid #ddd; background:#fafafa; cursor:pointer;
}
.btnPrimary { background:#111; color:#fff; border:0; }
.btnDanger { background:#b00020; color:#fff; border:0; }
.btnLink { text-decoration:none; padding:10px 12px; border-radius:10px; border:1px solid #ddd; background:#fafafa; color:#111; }
.muted { opacity:.7; }
.result { margin: 10px 0 0; min-height: 1.2em; }
.result.ok { color: #0a7a2f; }
.result.bad { color: #b00020; }
.tag.ok { color:#0a7a2f; }
.tag.bad { color:#b00020; }
.bullets { margin: 8px 0 0; padding-left: 18px; }
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}


/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display:grid; place-items:center; padding: 14px; }
.modal.hidden { display: none; }
.modalCard { width: min(420px, 100%); background:#fff; border-radius: 14px; padding: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.18); display:grid; gap: 12px; }
.modalHeader { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.modalLabel span { display:block; font-size: 13px; opacity:.8; margin-bottom: 6px; }
.modalLabel select { width:100%; padding:10px 12px; border-radius: 10px; border:1px solid #ddd; }
.modalActions { display:flex; justify-content:flex-end; }



.composer textarea {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #ddd;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}


.list:empty::after {
  content: 'Noch keine Chats';
  opacity: 0.6;
  font-size: 14px;
}


.chatItem { display:flex; justify-content:space-between; align-items:center; gap:10px; background-color: #e4ffff;}
.badge { font-size: 18px; line-height: 1; }
.chatItem.hasUnread { font-weight: 600; }


.panelRow { display:flex; gap:10px; align-items:center; }
.panelRow input { flex:1; padding:10px 12px; border-radius:10px; border:1px solid #ddd; }

.checkList {
  border:1px solid #eee;
  border-radius: 12px;
  padding: 8px;
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.checkItem {
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: 10px;
  border:1px solid #f0f0f0;
  background:#fff;
}

.checkItem:hover { background:#f8f8f8; }
.checkItem input { width: 18px; height: 18px; }


.memberRow { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.memberRow .name { display:flex; gap:10px; align-items:center; }
.memberTag { font-size:12px; opacity:.65; }



/* Icon button (optional hübscher) */
.iconBtn { width: 42px; padding: 10px 0; text-align:center; }

/* Overlay */
.sidebarOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 50;
}
.sidebarOverlay.hidden { display: none; }

/* Mobile drawer behavior */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr; /* Chat full width */
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: min(86vw, 340px);
    height: 100vh;
    z-index: 60;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
  }

  body.sidebarOpen .sidebar {
    transform: translateX(0);
  }

  body.sidebarOpen .sidebarOverlay {
    display: block;
  }

  /* Wenn Sidebar zu ist, soll man sie nicht tabben/clicken */
  body:not(.sidebarOpen) .sidebar {
    pointer-events: none;
  }
  body.sidebarOpen .sidebar {
    pointer-events: auto;
  }
}


/* Nachrichten */
.msg {
  max-width: 78%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f4f4f4;
  align-self: flex-start;
}

/* Eigene Nachrichten */
.msg.mine {
  background: #dcf8c6; /* WhatsApp-artig, freundlich */
  align-self: flex-end;
}

/* Meta-Info (Name + Zeit) */
.msg .meta {
  font-size: 12px;
  opacity: 0.65;
  margin-bottom: 4px;
}

/* Container muss Flex sein */
.messages {
  display: flex;
  flex-direction: column;
}


body.admin {
  overflow: auto;
}

.whoami{
  padding: 10px 12px;
  font-size: 13px;
  opacity: .8;
  border-bottom: 1px solid #eee;
}


.loginHint {
  padding: 12px;
  margin: 10px;
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
  border-radius: 8px;
  font-size: 14px;
}
.loginHint.hidden {
  display: none;
}


.pollBox { padding:10px; border:1px solid #eee; border-radius:10px; margin:6px 0; }
.pollRow { display:flex; justify-content:space-between; gap:10px; padding:6px 0; }
.pollRow label { display:flex; gap:8px; align-items:center; }
.pollMeta { font-size:12px; opacity:.7; margin-top:6px; }
.pollBtns { display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }


.pollBarRow {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.pollBarTrack {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  overflow: hidden;
}

.pollBarFill {
  height: 100%;
  width: 0%;
  background: currentColor;
  opacity: .22;
  border-radius: 999px;

  transition: width 300ms ease;   /* <<< Animation */
}


.pollPct {
  font-size: 12px;
  opacity: .75;
  min-width: 44px;
  text-align: right;
}

.pollVoted {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  opacity: .8;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.06);
}


/* Normale Messages bleiben "shrink-to-fit" (durch align-self flex-start/flex-end) */
/* Poll-/breite Messages sollen die maximale Bubble-Breite nutzen */
.msg.wide {
  width: 78%;           /* oder 80% – nach Geschmack */
  max-width: 78%;
}

/* Optional: auf sehr großen Screens nicht zu riesig */
.msg.wide {
  width: min(78%, 720px);
  max-width: min(78%, 720px);
}


.pollVotes {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,.08);
}


.pollNonvoters {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,.08);
  font-size: 13px;
  opacity: .85;
}


.writeHint {
  margin-top: 6px;
  font-size: 13px;
  opacity: .75;
}


.logo {
  max-width: 350px;
  width: 95%;
  margin: 0 auto 1rem;
  display: block;
}


.logo {
  opacity: 0.95;
}


.typingHint {
  font-size: 13px;
  opacity: .75;
  margin-top: 4px;
}
