:root {
  --teal: #2e5a67;
  --teal-deep: #1f4550;
  --orange: #f07823;
  --accent: #ff9a00;
  --ink: #242424;
  --paper: #fbf8f3;
  --line: #e6e0d6;
  --user: #ffe7d1;
  --sys: #eef0ef;
  --radius: 18px;
  --top-h: 64px;
  --composer-h: 72px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* ---------- כותרת ---------- */
.top {
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.top__logo { height: 40px; width: auto; }
.top__title { flex: 1; min-width: 0; line-height: 1.1; }
.top__title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: var(--teal);
  letter-spacing: -0.01em;
}
.top__title p { margin: 2px 0 0; font-size: 13px; color: #6b6b6b; }
.top__new {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.top__new:active { background: var(--paper); }

/* ---------- צ'אט ---------- */
.chat {
  padding: calc(var(--top-h) + env(safe-area-inset-top) + 14px) 14px calc(var(--composer-h) + env(safe-area-inset-bottom) + 20px);
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.msg--user {
  align-self: flex-start; /* RTL: start = right */
  background: var(--user);
  border-end-end-radius: 6px;
}
.msg--bot {
  align-self: flex-end;
  background: #fff;
  border: 1px solid var(--line);
  border-end-start-radius: 6px;
}
.msg--sys {
  align-self: center;
  max-width: 96%;
  background: var(--sys);
  color: #555;
  font-size: 14px;
  text-align: center;
}

.msg--bot.typing::after {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-inline-start: 4px;
  border-radius: 50%;
  background: var(--orange);
  animation: blink 1s infinite;
  vertical-align: middle;
}
@keyframes blink { 50% { opacity: .2; } }

/* ---------- בלוק ברכה ---------- */
.greeting {
  margin: 8px -4px 4px;
  background: var(--teal);
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px 12px;
  white-space: normal;
}
.greeting__title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 900;
  color: #ffd9b8;
}
.greeting__lines {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.greeting__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 9px 14px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: #fff;
  color: var(--teal);
}
.btn--orange { background: var(--orange); color: #fff; }
.btn--ghost { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.55); }
.modal .btn--ghost { color: var(--teal); border-color: var(--line); }
.btn:active { transform: translateY(1px); }
.btn.done { background: var(--accent); color: #fff; }

/* ---------- שורת כתיבה ---------- */
.composer {
  position: fixed;
  inset: auto 0 0 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  z-index: 5;
}
.composer textarea {
  flex: 1;
  font: inherit;
  font-size: 16px; /* מונע זום באייפון */
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  resize: none;
  max-height: 140px;
  background: var(--paper);
  outline: none;
}
.composer textarea:focus { border-color: var(--teal); background: #fff; }
.composer button {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--orange);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.composer button:disabled { background: #d9c8b8; }
.composer button svg { transform: scaleX(-1); }

/* ---------- מודאל כרטיס ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(31, 69, 80, .55);
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal__box {
  width: 100%;
  max-width: 560px;
  max-height: 94vh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal__box { border-radius: 20px; }
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.modal__head h2 { margin: 0; font-size: 18px; color: var(--teal); }
.modal__close { border: 0; background: none; font-size: 18px; cursor: pointer; color: #666; padding: 6px; }
.modal__body {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  overflow: auto;
  display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.pick { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; width: 100%; padding: 22px 10px; border: 2px dashed var(--line); border-radius: 14px; cursor: pointer; }
.pick input { display: none; }
.pick__btn { background: var(--teal); color: #fff; font-weight: 700; padding: 10px 18px; border-radius: 999px; }
.pick__hint { font-size: 13px; color: #777; }
#card { width: 100%; max-width: 420px; height: auto; border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.modal__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
