:root {
  --bg: #0e0d12;
  --bg-2: #16141c;
  --surface: #1d1a25;
  --surface-2: #26222f;
  --line: #2f2a3a;
  --text: #f3eff7;
  --muted: #9b93a8;
  --faint: #6d6679;
  --accent: #ff6a4d;
  --accent-ink: #1a0a06;
  --accent-soft: rgba(255, 106, 77, .14);
  --safe: #5fc9b3;
  --flirty: #ff7eb3;
  --bold: #ff6a4d;
  --good: #6fd38a;
  --bad: #ff6b6b;
  --radius: 18px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { font-size: 16px; } /* voorkomt inzoomen op iOS */
.hidden { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; }

/* ---------- topbalk ---------- */
.topbar {
  flex: none;
  padding: calc(var(--top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(var(--bg) 70%, rgba(14, 13, 18, 0));
  position: relative; z-index: 2;
}
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; font-weight: 750; flex: 1; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { color: var(--muted); font-size: 13px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--surface); color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.94); }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* ---------- login ---------- */
.login {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--top) + 24px) 24px calc(var(--bottom) + 24px);
  max-width: 420px; width: 100%; margin: 0 auto;
}
.logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 20px; }
.login h1 { font-size: 34px; margin: 0 0 6px; letter-spacing: -.03em; }
.login p { color: var(--muted); margin: 0 0 28px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 4px; }
.input, .textarea, .select {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { resize: none; min-height: 96px; line-height: 1.4; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; margin: 4px 4px 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px;
  background: var(--surface-2); font-weight: 600;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: 0 14px; border-radius: 12px; font-size: 14px; }

/* ---------- chatlijst ---------- */
.search { padding: 0 16px 8px; }
.search .input { padding: 11px 14px; background: var(--bg-2); }
.list { padding: 4px 8px calc(var(--bottom) + 100px); }
.chat-row {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 16px;
}
.chat-row:active { background: var(--surface); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
  background: var(--surface-2); color: var(--text); position: relative;
}
.avatar i {
  position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; border-radius: 50%;
  border: 2.5px solid var(--bg);
}
.chat-row .meta { flex: 1; min-width: 0; }
.chat-row .meta b { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.chat-row .meta b span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row .meta p { margin: 2px 0 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .when { color: var(--faint); font-size: 12px; flex: none; align-self: flex-start; margin-top: 4px; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); flex: none;
}
.badge.opener { color: var(--muted); }
.badge.warm { color: var(--safe); background: rgba(95, 201, 179, .12); }
.badge.flirty { color: var(--flirty); background: rgba(255, 126, 179, .12); }
.badge.spicy { color: var(--bold); background: var(--accent-soft); }
.empty { text-align: center; color: var(--muted); padding: 60px 30px; }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }
.section-label { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 18px 12px 6px; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--bottom) + 20px);
  height: 56px; padding: 0 22px 0 18px; border-radius: 28px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 10px 30px rgba(255, 106, 77, .35);
}
.fab svg { width: 22px; height: 22px; }

/* ---------- fasebalk ---------- */
.stages {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  margin: 0 16px 8px; padding: 4px; border-radius: 14px; background: var(--bg-2);
}
.stages button {
  padding: 8px 0; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.stages button.on { background: var(--surface-2); color: var(--text); }
.stages button.on[data-stage="warm"] { color: var(--safe); }
.stages button.on[data-stage="flirty"] { color: var(--flirty); }
.stages button.on[data-stage="spicy"] { color: var(--bold); }

/* ---------- gesprek ---------- */
.thread { padding: 8px 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.read-card {
  margin: 4px 0 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--bg-2); border: 1px solid var(--line); font-size: 14px;
}
.read-card .row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.meter { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--safe), var(--flirty), var(--bold)); }
.read-card .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.read-card p { margin: 0; color: var(--muted); }
.read-card .advice { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text); }
.notes-chip {
  align-self: center; margin: 4px 0 10px; font-size: 13px; color: var(--muted);
  padding: 6px 12px; border-radius: 99px; background: var(--bg-2); max-width: 90%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.msg { max-width: 82%; display: flex; flex-direction: column; }
.msg.her { align-self: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 9px 14px; border-radius: 20px; white-space: pre-wrap; word-wrap: break-word; text-align: left;
}
.msg.her .bubble { background: var(--surface); border-bottom-left-radius: 6px; }
.msg.me .bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg + .msg.her, .msg + .msg.me { margin-top: 2px; }
.msg.her + .msg.me, .msg.me + .msg.her { margin-top: 10px; }
.msg .tag { font-size: 11px; color: var(--faint); margin: 3px 6px 0; display: flex; gap: 6px; align-items: center; }
.rate { display: flex; gap: 6px; margin-top: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.rate button {
  height: 32px; min-width: 44px; padding: 0 10px; border-radius: 16px; background: var(--surface);
  font-size: 16px; border: 1px solid var(--line);
}
.rate button.on.up { background: rgba(111, 211, 138, .18); border-color: var(--good); }
.rate button.on.down { background: rgba(255, 107, 107, .15); border-color: var(--bad); }
.rated { color: var(--faint); }
.rated.up { color: var(--good); }
.rated.down { color: var(--bad); }

/* ---------- composer ---------- */
.composer {
  flex: none; padding: 8px 12px calc(var(--bottom) + 10px);
  background: var(--bg); border-top: 1px solid var(--line);
}
.who { display: flex; gap: 6px; margin-bottom: 8px; }
.who button {
  padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 600;
  color: var(--muted); background: var(--bg-2);
}
.who button.on { color: var(--text); background: var(--surface-2); }
.who .spacer { flex: 1; }
.compose-row { display: flex; gap: 8px; align-items: flex-end; }
.compose-row .textarea {
  min-height: 46px; max-height: 140px; padding: 11px 14px; border-radius: 22px; background: var(--surface);
}
.send {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--surface-2);
}
.send svg { width: 22px; height: 22px; }
.send.primary { background: var(--accent); color: var(--accent-ink); }
.goal { margin-top: 8px; }
.goal .input { padding: 10px 14px; font-size: 16px; border-radius: 12px; background: var(--bg-2); }
.cta { margin-top: 8px; display: flex; gap: 8px; }
.cta .btn { flex: 1; }

/* ---------- sheets ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20;
  animation: fade .18s ease-out;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-2); border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(var(--bottom) + 18px);
  animation: up .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 20px; }
.sheet .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px 0; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); }

/* suggesties */
.sugg-read { font-size: 14px; color: var(--muted); margin: -4px 0 12px; }
.sugg-read b { color: var(--text); }
.option {
  width: 100%; text-align: left; display: block;
  padding: 14px; border-radius: 16px; margin-bottom: 10px;
  background: var(--surface); border: 1.5px solid transparent;
}
.option:active { transform: scale(.99); }
.option.picked { border-color: var(--accent); }
.option .lvl { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.option[data-level="safe"] .lvl { color: var(--safe); }
.option[data-level="flirty"] .lvl { color: var(--flirty); }
.option[data-level="bold"] .lvl { color: var(--bold); }
.option .txt { display: block; font-size: 17px; margin: 6px 0; white-space: pre-wrap; }
.option .why { display: block; font-size: 13px; color: var(--muted); }
.tip { font-size: 14px; color: var(--text); background: var(--accent-soft); padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; }
.edit-pick { margin-top: 4px; }
.edit-pick .textarea { min-height: 80px; margin-bottom: 10px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 40px 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* instellingen */
.settings { padding: 0 16px calc(var(--bottom) + 30px); }
.card { background: var(--bg-2); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats div { background: var(--surface); border-radius: 14px; padding: 12px 4px; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
.mock-banner { margin: 0 16px 8px; padding: 8px 12px; border-radius: 12px; font-size: 13px; background: rgba(255, 196, 77, .12); color: #ffc44d; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom) + 96px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 99px; transition: .2s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.badge { font-style: normal; }
.signal.playful_test { color: var(--flirty); }
.signal.interested { color: var(--good); }
.signal.real_no { color: var(--bad); }
.signal.unclear { color: #ffc44d; }
