/* ICQ Web – Farben angelehnt an die Registrierungsseite (icq-register/style.css) */
:root {
  --bg: #eef1f6;
  --card: #fff;
  --ink: #1a1d24;
  --muted: #5a6376;
  --line: #d3d9e4;
  --hover: #f3f5f9;
  --active: #e3efe7;
  --accent: #1c7a3e;
  --accent-ink: #fff;
  --bubble-in: #f1f3f7;
  --bubble-out: #dff1e5;
  --err-bg: #fdecec;
  --err-line: #c0392b;
  --err-ink: #8e2018;
  --warn-bg: #fff6e0;
  --warn-line: #e3b23c;
  --st-online: #2e9e4f;
  --st-away: #d89b12;
  --st-busy: #d0571b;
  --st-dnd: #c0392b;
  --st-offline: #b14a4a;
  --st-invisible: #8a93a6;
  --unread: #c0392b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --card: #1c2029;
    --ink: #e6e9ef;
    --muted: #9aa3b5;
    --line: #2e3440;
    --hover: #232835;
    --active: #1f3328;
    --accent: #35a862;
    --accent-ink: #0d1013;
    --bubble-in: #252a35;
    --bubble-out: #1f3a2a;
    --err-bg: #3a1e1c;
    --err-line: #c0503f;
    --err-ink: #f0b7ae;
    --warn-bg: #322a12;
    --warn-line: #b4892c;
    --st-offline: #c86060;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: .5rem .9rem;
  cursor: pointer;
}
button:hover { background: var(--hover); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: .6; cursor: default; }
button.small { padding: .3rem .7rem; font-size: .9rem; }
.icon-btn {
  border: none;
  background: none;
  font-size: 1.25rem;
  line-height: 1;
  padding: .35rem .55rem;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.msg { padding: .55rem .75rem; border-radius: 8px; margin: .8rem 0 0; font-size: .92rem; }
.msg.err { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err-ink); }
.msg.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.hint { color: var(--muted); font-size: .85rem; margin: .6rem 0 0; }

/* Als installierte App: Platz für Statusleiste/Notch, kein Gummiband-Scrollen */
@media (display-mode: standalone) {
  body { overscroll-behavior: none; }
  .me, .chat-head { padding-top: calc(.75rem + env(safe-area-inset-top)); }
  .login { padding-top: calc(3rem + env(safe-area-inset-top)); }
}

.flower { font-size: 2.5rem; color: var(--accent); line-height: 1; }
.flower.big { font-size: 4rem; opacity: .35; }

/* ---------- Anmeldung ---------- */
.login { max-width: 24rem; margin: 0 auto; padding: 3rem 16px; }
.login-head { text-align: center; margin-bottom: 1.5rem; }
.login-head h1 { font-size: 1.6rem; margin: .4rem 0 .2rem; }
.sub { margin: 0; color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
}
.card label { display: block; font-weight: 600; margin: 1rem 0 .35rem; font-size: .95rem; }
.card label:first-of-type { margin-top: 0; }
.card label.check { font-weight: 400; display: flex; gap: .5rem; align-items: center; }
.card button.primary { width: 100%; margin-top: 1.1rem; padding: .65rem; }
.foot { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 1.5rem; }

/* ---------- Hauptansicht ---------- */
.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  height: 100dvh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--card);
  min-height: 0;
}
.me {
  position: relative;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem .75rem .75rem 1rem;
  border-bottom: 1px solid var(--line);
}
.me-text { flex: 1; min-width: 0; }
.me-text strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text select { padding: .15rem .4rem; font-size: .88rem; margin-top: .15rem; width: auto; }
.menu {
  position: absolute;
  right: .5rem;
  top: 100%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 15rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .15);
  padding: .3rem;
}
.menu button { border: none; text-align: left; border-radius: 6px; padding: .5rem .7rem; }
.away-row { display: flex; gap: .4rem; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
.away-row input { padding: .3rem .5rem; font-size: .9rem; }
.conn-banner {
  background: var(--err-bg);
  color: var(--err-ink);
  font-size: .85rem;
  padding: .4rem 1rem;
  border-bottom: 1px solid var(--err-line);
}

.flower-dot { font-size: 1.15rem; line-height: 1; color: var(--st-offline); flex: none; }
.flower-dot[data-state=online]    { color: var(--st-online); }
.flower-dot[data-state=away],
.flower-dot[data-state=idle]      { color: var(--st-away); }
.flower-dot[data-state=occupied]  { color: var(--st-busy); }
.flower-dot[data-state=dnd]       { color: var(--st-dnd); }
.flower-dot[data-state=invisible] { color: var(--st-invisible); }
.flower-dot[data-state=offline]   { color: var(--st-offline); opacity: .75; }
.flower-dot[data-state=unknown]   { color: var(--st-invisible); }

.buddy-list { flex: 1; overflow-y: auto; padding: .4rem 0 1rem; }
.group-head {
  display: flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
  border: none;
  border-radius: 0;
  background: none;
  padding: .55rem 1rem .25rem;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.group-head .caret { transition: transform .15s; display: inline-block; }
.group-head[aria-expanded=false] .caret { transform: rotate(-90deg); }
.group-head .count { font-weight: 400; margin-left: auto; }
.buddy {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  border: none;
  border-radius: 0;
  background: none;
  text-align: left;
  padding: .45rem 1rem .45rem 1.4rem;
}
.buddy:hover { background: var(--hover); }
.buddy.active { background: var(--active); }
.buddy .b-text { flex: 1; min-width: 0; }
.buddy .b-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buddy .b-sub { display: block; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buddy.offline .b-name { color: var(--muted); }
.badge {
  background: var(--unread);
  color: #fff;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  min-width: 1.3rem;
  padding: 0 .4rem;
  text-align: center;
}
.empty-list { color: var(--muted); padding: 1rem; font-size: .9rem; }
.sidebar-foot { padding: .6rem .75rem; border-top: 1px solid var(--line); }
.sidebar-foot button { width: 100%; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}
.chat-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem .75rem .65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.chat-title { flex: 1; min-width: 0; }
.chat-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: none; }

.messages {
  list-style: none;
  margin: 0;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.day-sep {
  align-self: center;
  color: var(--muted);
  font-size: .78rem;
  margin: .6rem 0 .2rem;
}
.m {
  max-width: min(75%, 40rem);
  padding: .45rem .7rem .3rem;
  border-radius: 12px;
  background: var(--bubble-in);
  align-self: flex-start;
  overflow-wrap: anywhere;
}
.m.out { background: var(--bubble-out); align-self: flex-end; }
.m .t { white-space: pre-wrap; }
.m .meta { display: block; font-size: .72rem; color: var(--muted); text-align: right; margin-top: .1rem; }
.m.pending { opacity: .6; }
.m.failed { border: 1px solid var(--err-line); }
.m.failed .meta { color: var(--err-ink); }
.m.system {
  align-self: center;
  background: none;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}
.typing { color: var(--muted); font-size: .85rem; padding: 0 1rem .3rem; font-style: italic; }

.compose {
  display: flex;
  gap: .5rem;
  padding: .65rem .75rem calc(.65rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
}
.compose textarea { resize: none; max-height: 9rem; line-height: 1.4; }
.compose button { align-self: flex-end; }

/* ---------- Dialog & Toast ---------- */
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  width: min(26rem, calc(100vw - 32px));
  padding: 1.25rem;
}
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog h2 { margin: 0 0 1rem; font-size: 1.15rem; }
dialog label { display: block; font-weight: 600; margin: .8rem 0 .3rem; font-size: .92rem; }
dialog label:first-of-type { margin-top: 0; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: .55rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  max-width: calc(100vw - 32px);
  z-index: 50;
  box-shadow: 0 6px 18px rgb(0 0 0 / .2);
}

/* ---------- Mobil ---------- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: none; }
  .app.show-chat .sidebar { display: none; }
  .app:not(.show-chat) .chat { display: none; }
  .back { display: inline-block; }
  .m { max-width: 85%; }
}

.forgot { text-align: center; margin: .9rem 0 0; font-size: .9rem; }
.forgot a { color: var(--muted); }

/* Kontextmenü für Kontakte */
.ctx-menu {
  position: fixed;
  right: auto;
  top: 0;
  left: 0;
  z-index: 50;
  min-width: 13rem;
  max-width: calc(100vw - 16px);
}
.ctx-head {
  display: flex;
  flex-direction: column;
  padding: .4rem .7rem .45rem;
  margin-bottom: .2rem;
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
}
.ctx-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-head span { color: var(--muted); font-size: .8rem; }
.ctx-sep { border: 0; border-top: 1px solid var(--line); margin: .25rem 0; }
.ctx-menu button.danger { color: var(--err-ink); }
.ctx-menu:focus { outline: none; }
/* Langes Drücken auf iOS: keine Lupe/Textauswahl/Link-Vorschau */
.buddy { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
