:root {
  --bg: #0f1512;
  --panel: #16201b;
  --panel-2: #1d2a23;
  --brand: #1f7a5a;
  --brand-2: #2a9d77;
  --text: #e9efe9;
  --muted: #8aa394;
  --bubble-me: #1f7a5a;
  --bubble-them: #222e27;
  --danger: #e06a6a;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  overscroll-behavior: none;
}
body { display: flex; flex-direction: column; }
.hidden { display: none !important; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---- Auth ---- */
#auth { align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border-radius: 20px; padding: 28px 22px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.logo { font-size: 44px; }
.auth-card h1 { margin: 6px 0 4px; font-size: 24px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; line-height: 1.4; }
.tabs { display: flex; background: var(--panel-2); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 9px; font-size: 15px; font-weight: 600; }
.tab.active { background: var(--brand); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
input, button { font-size: 16px; font-family: inherit; }
.auth-form input {
  padding: 14px; border-radius: 12px; border: 1px solid #2c3a31;
  background: var(--panel-2); color: var(--text);
}
.auth-form button {
  padding: 14px; border: 0; border-radius: 12px; background: var(--brand);
  color: #fff; font-weight: 700; margin-top: 4px;
}
.error { color: var(--danger); font-size: 14px; min-height: 18px; margin: 12px 0 0; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  background: var(--panel); border-bottom: 1px solid #223028;
  position: sticky; top: 0; z-index: 5;
}
.conv-name { font-weight: 700; font-size: 18px; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--panel-2); border: 0; color: var(--text);
  width: 40px; height: 40px; border-radius: 11px; font-size: 18px;
}
.icon-btn.on { background: var(--brand); }

/* ---- Berichten ---- */
.messages {
  flex: 1; overflow-y: auto; padding: 14px 12px 6px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.msg { max-width: 82%; display: flex; flex-direction: column; gap: 3px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .sender { font-size: 12px; font-weight: 700; padding: 0 6px; }
.bubble {
  background: var(--bubble-them); padding: 9px 12px; border-radius: var(--radius);
  border-bottom-left-radius: 5px; word-wrap: break-word; overflow-wrap: anywhere;
  position: relative; line-height: 1.35;
}
.msg.me .bubble { background: var(--bubble-me); color: #fff; border-bottom-left-radius: var(--radius); border-bottom-right-radius: 5px; }
.bubble img, .bubble video { max-width: 100%; border-radius: 10px; display: block; margin: -2px 0 4px; }
.bubble .caption { margin-top: 2px; }
.time { font-size: 11px; color: var(--muted); padding: 0 6px; }
.msg.me .time { color: var(--muted); }

/* Reacties */
.reactions { display: flex; gap: 4px; flex-wrap: wrap; padding: 2px 4px 0; }
.reaction {
  background: var(--panel-2); border: 1px solid #2c3a31; border-radius: 20px;
  padding: 1px 8px; font-size: 13px; line-height: 1.6;
}
.reaction.mine { border-color: var(--brand-2); background: #1c3a2e; }
.react-trigger {
  align-self: flex-start; background: transparent; border: 0; color: var(--muted);
  font-size: 12px; padding: 0 6px; cursor: pointer;
}
.msg.me .react-trigger { align-self: flex-end; }

/* Reactie-kiezer */
.react-bar {
  display: flex; gap: 4px; background: var(--panel); border: 1px solid #2c3a31;
  border-radius: 24px; padding: 4px 6px; margin: 2px 4px; width: fit-content;
}
.react-bar button { background: transparent; border: 0; font-size: 22px; padding: 2px 4px; }

/* ---- Banner (iOS-tips e.d.) ---- */
.banner { background: var(--panel-2); color: var(--text); font-size: 13px; padding: 10px 14px; border-top: 1px solid #223028; line-height: 1.4; }
.banner b { color: var(--brand-2); }
.banner .x { float: right; color: var(--muted); cursor: pointer; }

/* ---- Composer ---- */
.composer {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid #223028;
}
.attach { font-size: 22px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; }
#text-input {
  flex: 1; padding: 12px 14px; border-radius: 22px; border: 1px solid #2c3a31;
  background: var(--panel-2); color: var(--text);
}
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 18px; }

/* ---- Preview-overlay ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20; }
.preview-box { background: var(--panel); border-radius: 18px; padding: 16px; width: 100%; max-width: 460px; }
#preview-media img, #preview-media video { max-width: 100%; max-height: 50vh; border-radius: 12px; display: block; margin: 0 auto 12px; }
#preview-caption { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid #2c3a31; background: var(--panel-2); color: var(--text); margin-bottom: 12px; }
.preview-actions { display: flex; gap: 10px; justify-content: flex-end; }
.preview-actions button { padding: 12px 20px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; }
.preview-actions .ghost { background: var(--panel-2); color: var(--text); }

.day-sep { align-self: center; background: var(--panel-2); color: var(--muted); font-size: 12px; padding: 4px 12px; border-radius: 20px; margin: 4px 0; }
.sending { opacity: .6; }

/* ---- Uitnodigingscode-paneel ---- */
.invite-title { margin: 0 0 6px; font-size: 20px; }
.invite-help { color: var(--muted); font-size: 14px; line-height: 1.4; margin: 0 0 14px; }
.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 30px; font-weight: 700; letter-spacing: 2px; text-align: center;
  background: var(--panel-2); color: var(--brand-2); border: 1px dashed var(--brand-2);
  border-radius: 12px; padding: 18px; margin-bottom: 14px; user-select: all;
}
.invite-actions { flex-wrap: wrap; }
