:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --card: #1e1e1e;
  --input: #252525;
  --border: #2a2a2a;
  --text: #ffffff;
  --muted: #a0a0a0;
  --faint: #666666;
  --pink: #fe2c55;
  --purple: #6f00ff;
  --cyan: #25f4ee;
  --green: #00c853;
  --amber: #ffb300;
  --grad: linear-gradient(90deg, var(--pink), var(--purple));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
}

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---- Layar pilih produk */
.chooser { flex: 1; overflow-y: auto; padding: 32px 16px calc(24px + env(safe-area-inset-bottom)); }
.chooser-head { text-align: center; margin-bottom: 24px; }
.chooser-head h1 { margin: 14px 0 4px; font-size: 22px; font-weight: 800; }
.chooser-head p { margin: 0; color: var(--muted); }
.avatar.big { width: 64px; height: 64px; font-size: 20px; margin: 0 auto; }
.products { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 10px; max-width: 520px; }
.product {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.product:not(:disabled):hover, .product:not(:disabled):focus-visible { border-color: var(--pink); outline: none; }
.product:not(:disabled):active { transform: scale(.99); }
.product.soon { opacity: .55; cursor: default; }
.product.soon .avatar { background: var(--card); color: var(--muted); }
.product-text { flex: 1; min-width: 0; display: grid; }
.product-text strong { font-size: 16px; }
.product-text small { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tag { flex: none; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(37, 244, 238, .1); border: 1px solid rgba(37, 244, 238, .45); }
.product.soon .tag { background: transparent; border-color: var(--border); color: var(--muted); }

.back {
  flex: none;
  width: 36px;
  height: 36px;
  margin-left: -6px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.back:active { background: var(--card); }

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(90deg, rgba(254, 44, 85, .18), rgba(111, 0, 255, .18)), var(--surface);
  border-bottom: 1px solid var(--border);
}

.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  background: var(--grad);
}

.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { margin: 2px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--cyan); }
.status-waiting::before { background: var(--amber); }
.status-admin::before { background: var(--green); }
.status-closed::before { background: var(--faint); }

.mode {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid rgba(37, 244, 238, .6);
  background: rgba(37, 244, 238, .12);
  color: var(--cyan);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.mode:hover, .mode:focus-visible { background: rgba(37, 244, 238, .22); outline: none; }
.mode:active { transform: scale(.97); }
.mode::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* Tombol ke admin = aksen pink (warna tombol utama). */
.mode.to-admin { border-color: rgba(254, 44, 85, .6); background: rgba(254, 44, 85, .12); color: #ff5c7a; }
.mode.to-admin:hover, .mode.to-admin:focus-visible { background: rgba(254, 44, 85, .22); }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.loading, .empty { color: var(--muted); text-align: center; margin: auto; padding: 24px; }

/* min-width 0: tanpa ini gambar lebar menahan bubble di ukuran aslinya & halaman melebar ke samping. */
.msg { display: flex; flex-direction: column; max-width: 88%; min-width: 0; }
.msg .name { font-size: 11px; color: var(--muted); margin: 0 4px 3px; }
.bubble {
  padding: 10px 13px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.bubble p { margin: 0 0 6px; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 6px; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble strong { color: #fff; font-weight: 700; }
.bubble a { color: var(--cyan); }

.msg.bot, .msg.admin { align-self: flex-start; }
.msg.bot .bubble { border-top-left-radius: 4px; }
.msg.admin .bubble { border-top-left-radius: 4px; border-color: rgba(0, 200, 83, .5); background: #11241a; }
.msg.admin .name { color: var(--green); font-weight: 600; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .bubble { background: var(--grad); border: none; border-top-right-radius: 4px; white-space: pre-wrap; }
.msg.system { align-self: center; max-width: 92%; }
.restart { align-self: center; width: 100%; max-width: 320px; margin-top: 4px; }
.restart .btn-start { margin-top: 0; }
.msg.system .bubble { background: transparent; border: 1px dashed var(--border); color: var(--muted); font-size: 13px; text-align: center; }

.source { font-size: 11px; color: var(--faint); margin: 4px 4px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px solid rgba(37, 244, 238, .45);
  background: rgba(37, 244, 238, .08);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.chip:active { transform: scale(.97); }
.chip:disabled { opacity: .45; cursor: default; }

.typing .bubble { color: var(--muted); letter-spacing: 3px; }

.notice {
  margin: 0 16px 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(255, 179, 0, .12);
  border: 1px solid rgba(255, 179, 0, .5);
  color: var(--amber);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 120px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--input);
  color: var(--text);
  font: inherit;
  padding: 10px 14px;
  outline: none;
}
.composer textarea:focus { border-color: var(--pink); }
.composer button {
  flex: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.composer button:disabled { opacity: .5; cursor: default; }
.composer .attach { background: var(--input); border: 1px solid var(--border); color: var(--muted); }

.bubble.media-only { padding: 4px; }
.media { display: block; max-width: 100%; max-height: 320px; width: auto; height: auto; border-radius: 12px; background: #000; }
.bubble a.media-link { display: block; margin-bottom: 8px; }
.bubble video.media { margin-bottom: 8px; }
.bubble.media-only a.media-link, .bubble.media-only video.media { margin-bottom: 0; }

/* ---- Layar Onboarding: Form Nama & Email */
.onboarding {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.onboarding-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .4);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 4px 0;
  margin-bottom: 16px;
  cursor: pointer;
}
.back-link:hover { color: var(--text); }
.onboarding-head { text-align: center; margin-bottom: 24px; }
.onboarding-head h1, .onboarding-head h2 { margin: 14px 0 6px; font-size: 20px; font-weight: 800; color: var(--text); }
.onboarding-head p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.chooser-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .4);
}
.onboarding-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.form-group label { font-size: 13px; font-weight: 600; color: #ddd; }
.input-icon-wrap {
  display: flex;
  align-items: center;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-icon-wrap:focus-within {
  border-color: var(--pink);
  box-shadow: 0 0 0 2px rgba(254, 44, 85, .2);
}
.field-icon { color: var(--muted); flex-shrink: 0; }
.input-icon-wrap input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 12px 10px;
  outline: none;
}
.input-icon-wrap input::placeholder { color: var(--faint); }
.btn-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: opacity .15s ease, transform .1s ease;
}
.btn-start:hover { opacity: .95; }
.btn-start:active { transform: scale(.98); }

/* ---- Layar Lanjutkan / Mulai baru */
.resume-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.resume-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.resume-meta .status { margin: 0; }
.resume-preview { margin: 10px 0 4px; font-size: 14px; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
.resume-time { margin: 0; font-size: 12px; color: var(--faint); }
.btn-secondary {
  width: 100%;
  margin-top: 12px;
  padding: 13px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.btn-secondary:hover, .btn-secondary:focus-visible { border-color: var(--pink); outline: none; }
.resume-note { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--faint); }

