:root {
  --bg: #f4f2f7;
  --panel: #ffffff;
  --panel-2: #f9f8fb;
  --text: #1d1a24;
  --muted: #6d6878;
  --line: #e4e0ea;
  --accent: #c2185b;
  --accent-text: #ffffff;
  --accent-soft: #fbe4ee;
  --mine: #c2185b;
  --mine-text: #ffffff;
  --theirs: #efedf3;
  --online: #2e9d5b;
  --danger: #b3261e;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121016;
    --panel: #1b1820;
    --panel-2: #221f28;
    --text: #ece9f1;
    --muted: #a19bab;
    --line: #2f2b36;
    --accent: #f06292;
    --accent-text: #1b0b12;
    --accent-soft: #3a1d2a;
    --mine: #d81b60;
    --mine-text: #ffffff;
    --theirs: #2a2631;
    --online: #4cc47f;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 0 16px; }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }

/* ---------- login ---------- */
.login {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 24px 16px;
}
.card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 24px;
}
.card h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.2; }
.lead { margin: 0; color: var(--muted); }
.login-main { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.why { width: 100%; padding: 0 4px; }
.hero { margin: 0; }
/* Mobiel: ronde uitsnede van het gezicht boven het formulier */
.hero img {
  display: block; width: 112px; height: 112px; object-fit: cover; object-position: 52% 22%;
  border-radius: 50%; border: 3px solid var(--panel); box-shadow: 0 6px 20px rgb(0 0 0 / .18);
}
/* Merk bovenaan */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.brand img { display: block; border-radius: 9px; }

/* Breed scherm: merk, dan afbeelding en formulier even hoog naast elkaar,
   daaronder de voordelen over de volle breedte */
@media (min-width: 900px) {
  .login {
    display: grid; justify-content: center; align-items: stretch;
    grid-template-columns: 360px 420px;
    grid-template-areas: "brand brand" "hero form" "why why";
    column-gap: 40px; row-gap: 32px; padding: 32px 24px 48px;
  }
  .login-main { display: contents; }
  .brand { grid-area: brand; }
  .hero { grid-area: hero; }
  .hero img {
    width: 360px; height: 100%; min-height: 482px; object-fit: cover; object-position: 50% 20%;
    border-radius: var(--radius); border: 0; box-shadow: 0 18px 50px rgb(0 0 0 / .18);
  }
  #login-form { grid-area: form; max-width: none; display: flex; flex-direction: column; justify-content: center; }
  .login .why { grid-area: why; padding: 0; }
  .login .why h2 { font-size: 20px; margin-bottom: 14px; }
  .login .why ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-bottom: 16px; }
  .login .why li {
    flex: 0 0 calc((100% - 28px) / 3); padding: 14px 16px; border: 1px solid var(--line); border-left: 0;
    border-top: 3px solid var(--accent); border-radius: 12px; background: var(--panel);
  }
}

.why h2 { font-size: 17px; margin: 0 0 10px; }
.why ul { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.why li { padding-left: 14px; border-left: 3px solid var(--accent-soft); color: var(--muted); font-size: 14px; }
.why li strong { display: block; color: var(--text); font-size: 15px; }
.card label { display: block; font-weight: 600; margin: 18px 0 6px; }
.card input[type=text], .card input:not([type]) {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 400 !important; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.card button[type=submit] {
  width: 100%; margin-top: 20px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.card button[disabled] { opacity: .6; cursor: default; }

/* ---------- layout ---------- */
.app { height: 100%; display: grid; grid-template-columns: 300px 1fr; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.me { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.me strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lists { overflow-y: auto; flex: 1; padding-bottom: 16px; }
.sidebar h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 18px 16px 6px; display: flex; gap: 6px; align-items: center;
}
.count { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.banner { background: #fff3cd; color: #6b4e00; padding: 8px 16px; font-size: 13px; }
@media (prefers-color-scheme: dark) { .banner { background: #3b3214; color: #f3dc8c; } }

.list { list-style: none; margin: 0; padding: 0 8px; }
.list button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 8px; border: 0;
  background: none; border-radius: 10px; text-align: left;
}
.list button:hover { background: var(--panel-2); }
.list button.active { background: var(--accent-soft); }
.list .meta { flex: 1; min-width: 0; }
.list .name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .preview { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; min-width: 20px; padding: 0 6px; font-size: 12px; font-weight: 700; text-align: center; }

.avatar {
  position: relative; flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; text-transform: uppercase;
}
.avatar.online::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--online); border: 2px solid var(--panel);
}
.avatar.gone { filter: grayscale(1); opacity: .55; }

/* ---------- chat ---------- */
.chat { min-height: 0; display: flex; flex-direction: column; }
.chat-empty { margin: auto; padding: 16px; text-align: center; }
.chat-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.peer { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.peer strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: 12px; color: var(--muted); }
.status.online { color: var(--online); }
.actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.link { background: none; border: 0; color: var(--accent); padding: 6px 8px; border-radius: 8px; font-size: 13px; }
.link:hover { background: var(--accent-soft); }
.icon { display: none; background: none; border: 0; font-size: 20px; padding: 4px 8px; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.more { align-self: center; margin-bottom: 8px; }
.msg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.msg { max-width: min(75%, 560px); display: flex; flex-direction: column; }
.msg .bubble {
  padding: 8px 12px; border-radius: 16px; background: var(--theirs);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg time { font-size: 11px; color: var(--muted); margin: 2px 6px 6px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.mine .bubble { background: var(--mine); color: var(--mine-text); }
.msg.pending .bubble { opacity: .6; }
.day { align-self: center; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.notice { align-self: center; font-size: 13px; color: var(--muted); text-align: center; margin: 8px 0; }

.typing { min-height: 22px; padding: 0 18px; font-size: 13px; color: var(--muted); font-style: italic; }
.composer {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel-2);
}
.composer button {
  border: 0; border-radius: 12px; padding: 0 18px; background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.composer button[disabled], .composer textarea[disabled] { opacity: .5; cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .2); z-index: 10;
}

/* ---------- mobiel: één paneel tegelijk ---------- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .app.show-chat .sidebar { display: none; }
  .app:not(.show-chat) .chat { display: none; }
  .icon { display: block; }
  .chat-head { padding: 8px 10px; }
  .msg { max-width: 85%; }
}

/* ---------- links en tekstpagina's (huisregels) ---------- */
a { color: var(--accent); text-underline-offset: 2px; }
.sidebar-footer { margin-top: 24px; }
.doc { max-width: 720px; margin: 0 auto; padding: 24px 16px 40px; }
.doc-card { max-width: none; padding: 28px 24px; }
.doc-card h1 { font-size: 28px; margin: 0 0 8px; }
.doc-card h2 { font-size: 18px; margin: 26px 0 8px; }
.doc-card ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.doc-card p { margin: 8px 0; }
.back-link { display: inline-block; font-weight: 600; text-decoration: none; padding: 6px 0; }
.back-link:hover { text-decoration: underline; }
