:root {
  color-scheme: light dark;
  --bg: #f4efe8;
  --surface: #ffffff;
  --text: #1d1b19;
  --muted: #6f6a63;
  --line: #e3ddd3;
  --mine: #d8f0d2;
  --mine-text: #10230d;
  --theirs: #ffffff;
  --accent: #1f7a3d;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --warn-bg: #b3261e;
  --warn-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --surface: #1e1c18;
    --text: #f1ede6;
    --muted: #a29b90;
    --line: #33302a;
    --mine: #25472a;
    --mine-text: #e8f6e4;
    --theirs: #2a2722;
    --accent: #52b36b;
    --accent-text: #0c1f11;
    --danger: #f2b8b5;
    --warn-bg: #5a1f1b;
    --warn-text: #f9dedc;
  }
}

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

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 1.7rem;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  letter-spacing: normal;
  text-transform: none;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  user-select: none;
  flex: none;
}

.wrap { width: min(100% - 10vw, 44rem); margin-inline: auto; }
.sr { position: absolute; width: 0.0625rem; height: 0.0625rem; opacity: 0; pointer-events: none; }

/* Verbindingsbalk */
.net {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  background: var(--warn-bg); color: var(--warn-text);
  text-align: center; padding: 0.45rem 5vw; font-size: 1rem;
}

/* Knoppen */
.primary, .ghost, .who-btn, .link {
  border: 0; border-radius: 0.9rem; min-height: 3.4rem; padding: 0.7rem 1.2rem; font-weight: 600;
}
.primary { background: var(--accent); color: var(--accent-text); }
.primary:disabled { opacity: 0.6; cursor: default; }
.ghost { background: transparent; border: 0.0625rem solid var(--line); }
.link { background: none; color: var(--muted); font-weight: 400; text-decoration: underline; min-height: 3rem; }
.icon-btn {
  width: 3.2rem; height: 3.2rem; border: 0; border-radius: 50%; background: transparent;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--bg); }

/* Inloggen */
.login { min-height: 100dvh; display: grid; align-content: center; padding-block: 2rem; }
.card { text-align: center; }
.logo { font-size: 4rem; color: var(--accent); }
h1 { margin: 0.2rem 0 0; font-size: 2.4rem; }
.sub { margin: 0 0 1.6rem; color: var(--muted); }
.lead { margin: 0 0 0.4rem; font-size: 1.3rem; }
.who { display: grid; gap: 0.9rem; max-width: 24rem; margin-inline: auto; }
.who-btn {
  background: var(--surface); border: 0.0625rem solid var(--line); font-size: 1.5rem; min-height: 4.5rem;
  display: flex; align-items: center; justify-content: center; gap: 0.7rem;
}
.who-btn:hover { border-color: var(--accent); }
#pwForm { display: grid; gap: 0.8rem; max-width: 24rem; margin-inline: auto; text-align: left; }
label { font-size: 1.1rem; }
.pwrow { display: flex; align-items: center; gap: 0.3rem; }
.pwrow input {
  flex: 1; min-width: 0; min-height: 3.6rem; padding: 0.5rem 1rem; font-size: 1.3rem;
  border: 0.0625rem solid var(--line); border-radius: 0.9rem; background: var(--surface);
}
.err { margin: 0; min-height: 1.5rem; color: var(--danger); font-weight: 600; }

/* Chat */
.chat { display: flex; flex-direction: column; height: 100dvh; }
.bar {
  background: var(--surface); border-bottom: 0.0625rem solid var(--line);
  padding-block: 0.5rem; padding-top: calc(0.5rem + env(safe-area-inset-top));
}
.barin { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.id { display: flex; align-items: center; gap: 0.8rem; min-width: 0; font-size: 1.3rem; }
.avatar {
  width: 2.8rem; height: 2.8rem; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.toolbar { display: flex; gap: 0.3rem; margin-left: auto; }

.listwrap { position: relative; flex: 1; min-height: 0; display: flex; }
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-block: 1rem; }
.msgs { display: flex; flex-direction: column; }
.day {
  align-self: center; margin: 1.1rem 0 0.5rem; padding: 0.15rem 0.9rem; border-radius: 1rem;
  background: var(--surface); border: 0.0625rem solid var(--line); color: var(--muted); font-size: 0.9rem;
}
.msg {
  max-width: 85%; margin: 0.3rem 0; padding: 0.55rem 0.85rem 0.4rem; border-radius: 1.1rem;
  background: var(--theirs); border: 0.0625rem solid var(--line); border-bottom-left-radius: 0.3rem;
  align-self: flex-start;
}
.msg.mine {
  align-self: flex-end; background: var(--mine); color: var(--mine-text); border-color: transparent;
  border-radius: 1.1rem; border-bottom-right-radius: 0.3rem;
}
.msg .t { display: block; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.2rem; }
.msg a { color: inherit; text-decoration: underline; }
.msg .meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem;
  margin-top: 0.1rem; font-size: 0.8rem; color: var(--muted);
}
.msg .st { display: inline-flex; align-items: center; gap: 0.3rem; }
.msg .meta .material-symbols-outlined { font-size: 1.1rem; }
.msg.mine .time, .msg.mine .st { color: inherit; opacity: 0.7; }
/* Gelezen: twee vinkjes in de accentkleur. */
.msg.mine .st.read { color: var(--accent); opacity: 1; }
.msg.pending { opacity: 0.85; }
.msg.failed { border: 0.0625rem solid var(--danger); cursor: pointer; }
.msg.failed .st { color: var(--danger); opacity: 1; font-weight: 600; }

/* Nieuw / ongelezen */
.msg.new {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.1875rem color-mix(in srgb, var(--accent) 30%, transparent);
}
.newline {
  display: flex; align-items: center; gap: 0.8rem; margin: 1rem 0 0.4rem;
  color: var(--accent); font-size: 0.95rem; font-weight: 700;
}
.newline::before, .newline::after { content: ""; flex: 1; height: 0.0625rem; background: var(--accent); }

/* Meldingen */
.pushbar { background: var(--surface); border-bottom: 0.0625rem solid var(--line); padding-block: 0.6rem; }
.pushbar .row { align-items: center; gap: 0.8rem; }
.pushbar .grow { flex: 1; font-size: 1.05rem; line-height: 1.3; }
.pushbar .material-symbols-outlined { color: var(--accent); }
.primary.small { min-height: 2.8rem; padding: 0.4rem 1rem; }
#bell.on { color: var(--accent); }

.jump {
  position: absolute; right: 5vw; bottom: 0.9rem; width: 3.2rem; height: 3.2rem; border-radius: 50%;
  border: 0; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; box-shadow: 0 0.2rem 0.8rem rgb(0 0 0 / 0.25);
}

.composer {
  background: var(--surface); border-top: 0.0625rem solid var(--line);
  padding-block: 0.6rem; padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
}
.row { display: flex; align-items: flex-end; gap: 0.6rem; }
textarea {
  flex: 1; min-width: 0; resize: none; min-height: 3.2rem; max-height: 9rem; padding: 0.7rem 1rem;
  border: 0.0625rem solid var(--line); border-radius: 1.5rem; background: var(--bg); font-size: 1.2rem; line-height: 1.35;
}
.send {
  width: 3.2rem; height: 3.2rem; flex: none; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); display: grid; place-items: center;
}

/* Dialog */
dialog {
  border: 0; border-radius: 1.2rem; padding: 1.5rem; background: var(--surface); color: var(--text);
  width: min(90vw, 26rem);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin: 0 0 0.4rem; }
dialog p { margin: 0 0 1.2rem; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 0.7rem; }
