/* ==========================================================================
   Liebes-Chat – Stylesheet
   Mobil-first: erst Handy (Inge), dann Laptop (Thomas)
   ========================================================================== */
:root {
  --rose:        #d2446b;
  --rose-dark:   #a82c50;
  --rose-soft:   #fbe3ea;
  --rose-softer: #fff3f6;
  --ink:         #3a2a30;
  --ink-soft:    #7d6770;
  --line:        #efdde3;
  --bg:          #fdf7f9;
  --white:       #ffffff;
  --bubble-me:   linear-gradient(135deg, #e2567a, #c93a63);
  --bubble-you:  #ffffff;
  --radius:      22px;
  --shadow:      0 10px 30px rgba(168, 44, 80, .10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  /* Kein height:100% – sonst kann der Inhalt langer Seiten überlaufen */
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;      /* jede Seite darf immer scrollen */
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, #ffe6ee 0%, transparent 45%),
    radial-gradient(circle at 88% 92%, #fdeaf1 0%, transparent 45%),
    var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

a { color: var(--rose-dark); }

/* ------------------------------------------------------------ Login-Seite */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* Wenn der Platz nicht reicht, oben beginnen statt abzuschneiden */
@media (max-height: 620px) {
  .auth-wrap { justify-content: flex-start; }
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px 26px 30px;
  border: 1px solid var(--line);
  text-align: center;
}

.auth-heart {
  font-size: 46px;
  line-height: 1;
  animation: beat 1.8s ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  15%      { transform: scale(1.16); }
  30%      { transform: scale(1); }
  45%      { transform: scale(1.10); }
}

.auth-card h1 {
  font-size: 1.5rem;
  margin: 12px 0 6px;
  letter-spacing: .2px;
}
.auth-card p.sub {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: .92rem;
}

label.field {
  display: block;
  text-align: left;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 6px 4px;
  letter-spacing: .3px;
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;               /* verhindert Zoom auf iOS */
  color: var(--ink);
  background: #fffafc;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus {
  border-color: var(--rose);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(210, 68, 107, .12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  border: 0;
  border-radius: 14px;
  padding: 13px 20px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, filter .15s, box-shadow .15s;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, #e2567a, #c93a63);
  color: #fff;
  box-shadow: 0 8px 20px rgba(201, 58, 99, .30);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-ghost {
  background: var(--rose-softer);
  color: var(--rose-dark);
  border: 1px solid var(--line);
}
.btn-sm { padding: 9px 14px; font-size: .88rem; border-radius: 11px; }

.muted { color: var(--ink-soft); }
.small { font-size: .84rem; }

.flash {
  border-radius: 13px;
  padding: 11px 14px;
  font-size: .9rem;
  text-align: left;
  margin-bottom: 16px;
}
.flash.error   { background: #fff0f2; color: #a3243f; border: 1px solid #f7ccd5; }
.flash.success { background: #effaf1; color: #1f6b3a; border: 1px solid #cbead5; }
.flash.info    { background: var(--rose-softer); color: var(--rose-dark); border: 1px solid var(--line); }

/* ------------------------------------------------------------ Chat-Layout */
.chat-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  background: var(--white);
  position: relative;
}

@media (min-width: 861px) {
  .chat-app {
    height: calc(100dvh - 40px);
    margin: 20px auto;
    border-radius: 26px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--line);
  }
}

/* Nur auf der Chat-Seite bleibt die Seite selbst stehen (der Chat scrollt innen) */
html.chat-page,
body.chat-page {
  height: 100dvh;
  overflow: hidden;      /* die Seite selbst bleibt stehen, nur der Chat scrollt */
}

/* Kopfzeile */
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #e2567a, #c93a63);
  color: #fff;
  flex: 0 0 auto;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(168, 44, 80, .18);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  border: 2px solid rgba(255, 255, 255, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  flex: 0 0 auto;
  overflow: hidden;
  position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar .dot-online {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #57d98a;
  border: 2px solid #d2446b;
}

.chat-head .who { flex: 1 1 auto; min-width: 0; }
.chat-head .who .name {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head .who .status {
  font-size: .78rem;
  opacity: .88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 0;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: rgba(255, 255, 255, .30); }

/* Nachrichtenbereich */
.chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background-image:
    radial-gradient(circle at 15% 25%, rgba(255, 214, 226, .30) 0, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(255, 226, 234, .35) 0, transparent 40%);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-thumb { background: #f0d6de; border-radius: 8px; }

.day-sep {
  align-self: center;
  margin: 16px 0 10px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--rose-dark);
  background: var(--rose-soft);
  border-radius: 999px;
  padding: 5px 14px;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-top: 2px;
  max-width: 100%;
  animation: pop .22s ease-out;
}
.msg-row.mine { flex-direction: row-reverse; }

@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.msg-row + .msg-row.gap { margin-top: 10px; }

.bubble {
  position: relative;
  max-width: min(78%, 520px);
  padding: 9px 13px 7px;
  border-radius: var(--radius);
  font-size: .97rem;
  line-height: 1.42;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  box-shadow: 0 2px 6px rgba(120, 60, 80, .07);
}

/* Zeilenumbrüche nur im Text selbst erhalten – nicht im HTML-Quelltext */
.bubble .txt, .bubble .caption { white-space: pre-wrap; }

.msg-row.you .bubble {
  background: var(--bubble-you);
  border: 1px solid var(--line);
  border-bottom-left-radius: 7px;
  color: var(--ink);
}
.msg-row.mine .bubble {
  background: var(--bubble-me);
  color: #fff;
  border-bottom-right-radius: 7px;
}
.msg-row.mine .bubble a { color: #ffe6ee; }

.bubble .meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: .68rem;
  margin-top: 3px;
  opacity: .68;
  line-height: 1;
}
.msg-row.mine .bubble .meta { color: #fff; }
.msg-row.you  .bubble .meta { color: var(--ink-soft); }

.bubble .meta .tick { font-size: .78rem; letter-spacing: -1px; }
.bubble .meta .tick.read { color: #9fe8ff; }

/* Foto-Nachricht */
.bubble.photo {
  padding: 5px 5px 4px;
  background: #fff;
  border: 1px solid var(--line);
}
.msg-row.mine .bubble.photo { background: #fff; border-color: #f6d9e1; }

/* Feste Breite für Fotoblasen – sonst zieht die Bild-Größe die Blase auf */
.bubble.photo { width: min(76%, 320px); }

.bubble.photo img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 46dvh;          /* Hochkant-Handyfotos sprengen nicht den Chat */
  object-fit: contain;        /* nichts verzerren, nichts abschneiden */
  border-radius: 17px;
  cursor: zoom-in;
  background: #faf4f6;
}

.bubble.photo .caption {
  color: var(--ink);
  font-size: .92rem;
  padding: 7px 9px 2px;
}
.bubble.photo .meta { padding: 0 8px 2px; color: var(--ink-soft); opacity: .8; }

.bubble.deleted {
  font-style: italic;
  opacity: .72;
  background: #f7f2f4 !important;
  color: var(--ink-soft) !important;
  border: 1px dashed var(--line);
}

/* Herz-Reaktion */
.bubble .heart-badge {
  position: absolute;
  bottom: -9px;
  right: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .72rem;
  padding: 1px 6px 2px;
  box-shadow: 0 2px 6px rgba(168, 44, 80, .12);
  line-height: 1.3;
  color: var(--rose);
}
.msg-row.mine .bubble .heart-badge { right: auto; left: 8px; }

/* "schreibt …" */
.typing-bubble {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-bottom-left-radius: 7px;
  padding: 12px 16px;
  display: none;
  gap: 5px;
  margin: 4px 0 4px;
}
.typing-bubble.on { display: inline-flex; }
.typing-bubble i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #d9a3b4;
  animation: tdot 1.3s infinite;
}
.typing-bubble i:nth-child(2) { animation-delay: .18s; }
.typing-bubble i:nth-child(3) { animation-delay: .36s; }
@keyframes tdot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

.leer {
  margin: auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: .92rem;
  padding: 30px 20px;
  line-height: 1.6;
}
.leer .big { font-size: 2.6rem; display: block; margin-bottom: 10px; }

/* ------------------------------------------------------- Eingabeleiste */
.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 9px 10px calc(9px + var(--safe-b));
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer .attach {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--rose-softer);
  color: var(--rose);
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.composer .attach:active { transform: scale(.94); }
.composer .attach:hover { background: var(--rose-soft); }

.composer textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 44px;
  max-height: 130px;
  padding: 11px 15px;
  border-radius: 22px;
  background: #fdf4f7;
  border-color: #f6e2e9;
  line-height: 1.4;
  overflow-y: auto;
}

.composer .send {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #e2567a, #c93a63);
  color: #fff;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(201, 58, 99, .28);
  transition: transform .12s, filter .15s;
}
.composer .send:active { transform: scale(.93); }
.composer .send:disabled { opacity: .5; box-shadow: none; cursor: default; }

/* Fortschritt beim Foto-Upload */
.upload-bar {
  display: none;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  font-size: .82rem;
  color: var(--rose-dark);
  background: var(--rose-softer);
  border-top: 1px solid var(--line);
}
.upload-bar.on { display: flex; }
.upload-bar .track {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 4px;
  background: #f3d7e0;
  overflow: hidden;
}
.upload-bar .track span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e2567a, #c93a63);
  border-radius: 4px;
  transition: width .18s;
}

/* --------------------------------------------------------------- Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 15, 25, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  backdrop-filter: blur(3px);
}
.overlay.on { opacity: 1; pointer-events: auto; }
.overlay img {
  max-width: 100%;
  max-height: 88dvh;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}
.overlay .close-x {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 14px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
}

/* Kontextmenü (lange drücken / Doppelklick) */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: none;                 /* geschlossen komplett aus dem Layout */
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 10px 12px calc(16px + var(--safe-b));
  transform: translateY(105%);
  transition: transform .2s ease;
  z-index: 110;
  box-shadow: 0 -8px 30px rgba(88, 30, 50, .2);
}
.sheet.on { display: block; transform: none; animation: sheetUp .2s ease-out; }
@keyframes sheetUp {
  from { transform: translateY(105%); }
  to   { transform: translateY(0); }
}
.sheet .grab {
  width: 42px; height: 4px; border-radius: 3px;
  background: #eddfe4; margin: 4px auto 12px;
}
.sheet .actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 2px 0 6px;
}
.sheet .actions button {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: var(--rose-softer);
  color: var(--rose);
  font-size: 1.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s, background .15s;
}
.sheet .actions button:hover { background: var(--rose-soft); }
.sheet .actions button:active { transform: scale(.92); }
.sheet .actions button.danger { color: #b02a45; background: #fdeef1; }
@media (min-width: 861px) {
  .sheet { max-width: 400px; left: 50%; transform: translate(-50%, 105%); border-radius: 20px; bottom: 28px; }
  .sheet.on { display: block; transform: translate(-50%, 0); animation: sheetUpDesk .2s ease-out; }
  @keyframes sheetUpDesk {
    from { transform: translate(-50%, 105%); }
    to   { transform: translate(-50%, 0); }
  }
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: rgba(58, 26, 38, .94);
  color: #fff;
  font-size: .86rem;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------- Profil / Admin */
.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 18px 16px calc(30px + var(--safe-b));
}
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.page-head h1 { font-size: 1.22rem; margin: 0; flex: 1 1 auto; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(168, 44, 80, .05);
}
.card h2 {
  font-size: .95rem;
  margin: 0 0 14px;
  color: var(--rose-dark);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.card .row { margin-bottom: 14px; }
.card .row:last-child { margin-bottom: 0; }

.avatar-big {
  width: 96px; height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--rose-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.1rem; font-weight: 700; color: var(--rose-dark);
  border: 3px solid #fff;
  box-shadow: 0 6px 18px rgba(168, 44, 80, .16);
  margin: 0 auto 10px;
}
.avatar-big img { width: 100%; height: 100%; object-fit: cover; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; padding-bottom: 0; }
.switch-row .txt { flex: 1 1 auto; }
.switch-row .txt b { display: block; font-size: .95rem; font-weight: 600; }
.switch-row .txt span { font-size: .8rem; color: var(--ink-soft); }

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 50px; height: 29px;
}
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  background: #ecd9e0; border-radius: 999px;
  transition: background .18s;
  pointer-events: none;
}
.switch .track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 23px; height: 23px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  transition: transform .18s;
}
.switch input:checked + .track { background: var(--rose); }
.switch input:checked + .track::after { transform: translateX(21px); }

table.users { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.users th {
  text-align: left; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--ink-soft);
  padding: 0 8px 8px; font-weight: 700;
}
table.users td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
table.users tr:last-child td { border-bottom: 0; }

.pill {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: .3px;
}
.pill.admin { background: var(--rose-soft); color: var(--rose-dark); }
.pill.user  { background: #eef2ff; color: #3f4c9e; }
.pill.on    { background: #e6f9ed; color: #1f6b3a; }
.pill.off   { background: #f2eef0; color: #85727a; }

.storage { font-size: .85rem; color: var(--ink-soft); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 7px;
}
.gallery-grid a {
  display: block;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--rose-softer);
}
.gallery-grid img { width: 100%; height: 100%; object-fit: cover; }

/* Installer */
.inst-step {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .9rem;
}
.inst-step:last-child { border-bottom: 0; }
.inst-step .ic { font-size: 1.05rem; line-height: 1.5; flex: 0 0 auto; }
.inst-step b { font-weight: 600; }
.inst-step .det { color: var(--ink-soft); font-size: .83rem; }

code {
  background: #fdf0f4;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: .86em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  word-break: break-all;
}

/* Handy-Feinheiten */
@media (max-width: 380px) {
  .bubble { font-size: .93rem; }
  .head-actions .icon-btn { width: 34px; height: 34px; font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Nur für Screenreader / Struktur, nicht sichtbar */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
