:root {
  --bg: #fbf7f4;
  --card: rgba(255,255,255,0.9);
  --card-solid: #ffffff;
  --text: #26201f;
  --muted: #877875;
  --line: #eadfdb;
  --rose: #b85f76;
  --rose-dark: #94485e;
  --rose-soft: #f3dce3;
  --beige: #efe4dd;
  --sage: #dfe8d6;
  --sage-text: #526548;
  --amber: #f7dfbd;
  --amber-text: #8a5b23;
  --black: #0d0b0b;
  --gold: #d8a15f;
  --shadow: 0 16px 45px rgba(90, 54, 59, 0.11);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #fff 0, var(--bg) 42%, #f7eeeb 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.app-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; padding: 18px 16px 120px; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 42px; line-height: 1.02; letter-spacing: -1px; }
h2 { font-size: 20px; font-weight: 800; }
.brand-small, .eyebrow { color: var(--rose); font-size: 14px; margin-bottom: 6px; font-weight: 800; letter-spacing: .2px; }
.muted { color: var(--muted); font-size: 13px; }
.card, .conversation-card, .booking-summary, .control-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); backdrop-filter: blur(8px);
}

/* Branded login */
.login-view { min-height: 95vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-hero-card, .home-hero {
  position: relative; overflow: hidden; border-radius: 28px; min-height: 260px; box-shadow: 0 22px 60px rgba(48, 26, 28, .20); border: 1px solid rgba(255,255,255,.35); background: #080606;
}
.login-hero-card img, .home-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.88) 0%, rgba(0,0,0,.58) 42%, rgba(0,0,0,.05) 100%), linear-gradient(0deg, rgba(0,0,0,.50), rgba(0,0,0,0) 55%); }
.login-hero-copy { position: absolute; left: 22px; right: 145px; bottom: 22px; color: #fff; }
.login-hero-copy .brand-small { color: #f09aaa; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.login-hero-copy h1 { font-size: 38px; color: #fff; text-shadow: 0 4px 18px rgba(0,0,0,.45); }
.login-hero-copy p { color: rgba(255,255,255,.86); font-size: 14px; margin-top: 8px; line-height: 1.45; }
.login-card { margin-top: 0; }
.login-card-head { display: flex; align-items: center; gap: 13px; margin-bottom: 6px; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--rose-soft), #fff); color: var(--rose-dark);
  font-family: Georgia, serif; font-size: 21px; box-shadow: var(--shadow); flex: 0 0 auto;
}

.form-card { padding: 18px; }
label { display: block; color: var(--muted); font-size: 13px; margin: 12px 0 7px; }
input, textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 16px;
  padding: 13px 14px; font: inherit; outline: none;
}
textarea { resize: none; }
input:focus, textarea:focus { border-color: var(--rose); box-shadow: 0 0 0 4px rgba(184,95,118,0.12); }
.primary-btn, .secondary-btn, .icon-btn, .tab {
  border: 0; border-radius: 999px; font: inherit; cursor: pointer; transition: transform .1s ease, opacity .15s ease;
}
.primary-btn { background: linear-gradient(135deg, var(--rose), var(--rose-dark)); color: #fff; padding: 13px 18px; font-weight: 700; }
.secondary-btn { background: #fff; border: 1px solid #d8bbc3; color: var(--rose-dark); padding: 12px 18px; font-weight: 700; }
.full { width: 100%; margin-top: 16px; }
.icon-btn { width: 44px; height: 44px; background: rgba(255,255,255,0.85); color: var(--text); font-size: 25px; display: inline-grid; place-items: center; }
button:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: not-allowed; }
.error-text { color: #b04444; font-size: 13px; margin-top: 10px; }

/* Branded home hero */
.home-hero { min-height: 214px; margin-bottom: 16px; }
.home-hero img { object-position: center top; }
.home-hero .hero-shade { background: linear-gradient(90deg, rgba(0,0,0,.92) 0%, rgba(0,0,0,.60) 44%, rgba(0,0,0,.12) 100%), linear-gradient(0deg, rgba(0,0,0,.52), rgba(0,0,0,0) 55%); }
.home-hero-copy { position: absolute; left: 20px; right: 112px; bottom: 20px; color: #fff; }
.home-hero-copy .brand-small { color: #f09aaa; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
.home-hero-copy h1 { color: #fff; font-size: 44px; text-shadow: 0 5px 20px rgba(0,0,0,.45); }
.home-hero-copy p { color: rgba(255,255,255,.78); font-size: 13px; margin-top: 6px; }
.logout-floating { position: absolute; right: 16px; top: 16px; background: rgba(255,255,255,.92); }

.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: rgba(255,255,255,.75); border: 1px solid var(--line); padding: 4px; border-radius: 999px; margin-bottom: 18px;
}
.tab { background: transparent; color: var(--muted); padding: 10px 8px; font-size: 13px; }
.tab.active { background: var(--rose); color: #fff; box-shadow: 0 8px 20px rgba(184,95,118,.22); }
.status-banner { padding: 12px 14px; border-radius: 16px; background: #fff7e8; color: #6e4d23; margin-bottom: 12px; }
.conversation-list { display: flex; flex-direction: column; gap: 13px; }
.conversation-card { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { flex: 0 0 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #d898a5, #a95f72); font-family: Georgia, serif; font-size: 21px; }
.name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.name { font-size: 18px; font-weight: 800; }
.tag { font-size: 12px; padding: 5px 9px; border-radius: 999px; background: var(--rose-soft); color: var(--rose-dark); }
.tag.warning { background: var(--amber); color: var(--amber-text); }
.tag.sage { background: var(--sage); color: var(--sage-text); }
.time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.detail-grid { display: grid; grid-template-columns: 80px 1fr; gap: 7px 12px; font-size: 14px; margin: 10px 0 12px 56px; }
.detail-grid .label { color: var(--muted); }
.preview { color: var(--muted); font-size: 13px; margin-left: 56px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; padding: 7px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--sage); color: var(--sage-text); white-space: nowrap; }
.status-pill.paused { background: var(--amber); color: var(--amber-text); }
.open-btn { padding: 9px 18px; background: #fff; border: 1px solid #d8bbc3; color: var(--rose-dark); border-radius: 999px; font-weight: 700; }
.thread-view { padding-bottom: 210px; }
.thread-header {
  position: sticky; top: 0; z-index: 5; margin: -18px -16px 10px; padding: 16px; background: rgba(251,247,244,.92);
  backdrop-filter: blur(12px); display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line);
}
.thread-title { flex: 1; min-width: 0; }
.booking-summary { padding: 14px; margin: 14px 0; }
.booking-summary h3 { margin: 0 0 10px; color: var(--rose-dark); font-size: 15px; }
.summary-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; font-size: 12px; }
.summary-row span { color: var(--muted); display: block; margin-bottom: 4px; }
.summary-row strong { display: block; font-size: 13px; }
.messages-list { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 20px; }
.message { max-width: 82%; padding: 11px 13px; border-radius: 18px; font-size: 15px; line-height: 1.38; box-shadow: 0 8px 20px rgba(70,50,55,.06); }
.message .meta { margin-top: 7px; font-size: 11px; color: var(--muted); }
.message.inbound { align-self: flex-start; background: #fff; border-bottom-left-radius: 6px; }
.message.ai { align-self: flex-end; background: #f7e3ea; border-bottom-right-radius: 6px; }
.message.human { align-self: flex-end; background: #e9f0e1; border-bottom-right-radius: 6px; }
.control-panel {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); padding: 14px 16px 18px; border-radius: 24px 24px 0 0; background: rgba(255,255,255,.96);
}
.ai-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.empty-state { text-align: center; padding: 24px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: 20px; background: rgba(255,255,255,.55); }
@media (min-width: 760px) { .app-shell { padding-top: 26px; } }
@media (max-width: 390px) {
  .login-hero-card { min-height: 235px; }
  .login-hero-copy, .home-hero-copy { right: 92px; }
  .login-hero-copy h1 { font-size: 32px; }
  .home-hero-copy h1 { font-size: 38px; }
  .tab { font-size: 12px; padding-left: 5px; padding-right: 5px; }
}

/* V1.4 bilingual / RTL polish */
.language-toggle {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid rgba(184,95,118,.22);
  background: rgba(255,255,255,.88);
  color: var(--rose-dark);
  border-radius: 999px;
  padding: 8px 13px;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 8px 25px rgba(90,54,59,.12);
  backdrop-filter: blur(10px);
}
body.rtl {
  direction: rtl;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
}
body.rtl h1 { letter-spacing: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif; font-weight: 900; }
body.rtl .login-hero-copy,
body.rtl .home-hero-copy { left: 110px; right: 20px; text-align: right; }
body.rtl .hero-shade { background: linear-gradient(270deg, rgba(0,0,0,.92) 0%, rgba(0,0,0,.60) 44%, rgba(0,0,0,.12) 100%), linear-gradient(0deg, rgba(0,0,0,.52), rgba(0,0,0,0) 55%); }
body.rtl .login-hero-card .hero-shade { background: linear-gradient(270deg, rgba(0,0,0,.88) 0%, rgba(0,0,0,.58) 42%, rgba(0,0,0,.05) 100%), linear-gradient(0deg, rgba(0,0,0,.50), rgba(0,0,0,0) 55%); }
body.rtl .logout-floating { right: auto; left: 16px; }
body.rtl .login-card-head,
body.rtl .person,
body.rtl .name-line,
body.rtl .card-head,
body.rtl .card-actions,
body.rtl .thread-header { direction: rtl; }
body.rtl .detail-grid { grid-template-columns: 88px 1fr; margin-left: 0; margin-right: 56px; }
body.rtl .preview { margin-left: 0; margin-right: 56px; }
body.rtl .message.inbound { align-self: flex-end; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; text-align: right; }
body.rtl .message.ai,
body.rtl .message.human { align-self: flex-start; border-bottom-right-radius: 18px; border-bottom-left-radius: 6px; text-align: right; }
body.rtl .message .meta { text-align: inherit; }
body.rtl .back-btn { transform: scaleX(-1); }
body.rtl input,
body.rtl textarea { text-align: right; direction: rtl; }
body.rtl .summary-row { direction: rtl; }
body.rtl .status-banner,
body.rtl .empty-state { text-align: center; }
.audio-player { margin-top: 8px; }
.audio-player audio { width: 100%; max-width: 260px; display: block; }
.voice-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 999px;
  background: rgba(184,95,118,.12);
  color: var(--rose-dark);
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 7px;
}
.message.human .voice-chip { background: rgba(82,101,72,.12); color: var(--sage-text); }
.message.inbound .voice-chip { background: rgba(184,95,118,.09); }
.transcript-label { color: var(--muted); font-size: 12px; font-weight: 700; margin: 4px 0; }
@media (max-width: 390px) {
  body.rtl .login-hero-copy,
  body.rtl .home-hero-copy { left: 92px; right: 18px; }
}

/* V1.5 image messages, WhatsApp profile label, and thumb scroll button */
.profile-muted {
  color: rgba(135, 120, 117, .78);
  font-size: 12px;
  margin-top: 2px;
  line-height: 1.2;
}
.thread-title .profile-muted {
  margin-top: 2px;
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-scroll-wrap {
  position: relative;
}
.scroll-bottom-btn {
  position: fixed;
  right: max(18px, calc(50% - 244px));
  bottom: 214px;
  z-index: 8;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(216, 187, 195, .75);
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: var(--rose-dark);
  box-shadow: 0 10px 30px rgba(90,54,59,.16);
  backdrop-filter: blur(10px);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.scroll-bottom-btn:active { transform: scale(.96); }
body.rtl .scroll-bottom-btn {
  right: auto;
  left: max(18px, calc(50% - 244px));
}
.image-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 999px;
  background: rgba(184,95,118,.12);
  color: var(--rose-dark);
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 8px;
}
.message.human .image-chip { background: rgba(82,101,72,.12); color: var(--sage-text); }
.message.inbound .image-chip { background: rgba(184,95,118,.09); }
.image-preview-link {
  display: block;
  text-decoration: none;
  margin: 2px 0 8px;
}
.message-image {
  display: block;
  width: 100%;
  max-width: 310px;
  max-height: 360px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(234,223,219,.9);
  box-shadow: 0 10px 24px rgba(70,50,55,.08);
  background: #f4ece9;
}
.message.inbound .message-image { border-bottom-left-radius: 7px; }
.message.ai .message-image,
.message.human .message-image { border-bottom-right-radius: 7px; }
body.rtl .message.inbound .message-image { border-bottom-left-radius: 16px; border-bottom-right-radius: 7px; }
body.rtl .message.ai .message-image,
body.rtl .message.human .message-image { border-bottom-right-radius: 16px; border-bottom-left-radius: 7px; }
@media (max-width: 390px) {
  .scroll-bottom-btn { right: 16px; bottom: 212px; }
  body.rtl .scroll-bottom-btn { left: 16px; right: auto; }
  .message-image { max-height: 310px; }
}
