@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

/* ============================================
   0) GLOBAL & BASE & MAIN LAYOUT
   ============================================ */
:root {
  --popup-max-w: 1280px;
  --popup-inset-x: 24px;
  --popup-inset-y: 56px;
  --history-w: 280px;
  --gap: 0px;

  --bg: #ffffff;
  --panel: #ffffff;
  --txt: #202124;
  --muted: #4a4a4a;
  --brand: #1d3e2f;
  --border: #e5e7eb;

  --z-modal: 2147483647;
  --z-loader: 2147483646;

  --header-h: 72px;
}

html,
body {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: -webkit-fill-available !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
  margin: 0 !important;
  padding: 0 !important;
  -webkit-text-size-adjust: 100%;
  font-family: "Manrope", sans-serif;
  background: #ffffff !important;
}

#finly-chat-mount,
#fc-shell {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  display: flex;
  margin: 0 !important;
  padding: 0 !important;
  background: #ffffff !important;
}

#finly-chat-mount :is(#fcLoader, #loginModal, #fc-shell, #accountModal, #logoutModal) {
  display: none;
}

#finly-chat-mount.is-auth #loginModal,
#finly-chat-mount.is-chat #fc-shell {
  display: flex;
}

#finly-chat-mount.is-chat :is(#accountModal, #logoutModal) {
  display: none;
}

#finly-chat-mount.is-loading #fcLoader {
  display: grid;
}

#loginModal.auth-pending {
  pointer-events: none;
}

#loginModal.auth-pending .login-box {
  opacity: 0.65;
  filter: grayscale(0.2);
}

#iconView {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 75px;
  height: 75px;
  text-align: center;
  cursor: pointer;
  z-index: 9999;
  display: none !important;
}

#iconView img {
  width: 75px;
  height: 75px;
  border-radius: 10px;
}

#popupContainer {
  position: relative !important;
  flex: 0 0 80%;
  width: 80% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  background: #ffffff !important;
  border: none;
  box-shadow: none;
}

#fc-chatPromoRight {
  flex: 0 0 20%;
  width: 20%;
  height: 100%;
  overflow: hidden;
  border-left: 1px solid var(--border);
}

#fc-chatPromoRight img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#fc-chatMain {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#popupContainer.history-closed #popupPanel {
  display: none;
}

#popupContainer.history-closed #chatContentArea {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
}

#popupBody {
  flex: 1 1 auto;
  height: calc(100% - var(--header-h));
  display: flex;
  box-sizing: border-box;
  background: #ffffff !important;
  position: relative;
  overflow: hidden;
}

/* --- 0) GLOBAL MOBILE --- */
@media (max-width: 820px) {

  body,
  html {
    background-color: #f0f4f9 !important;
  }

  #fc-chatPromoRight {
    display: none !important;
  }

  #popupContainer,
  #fc-chatMain {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    background: #ffffff !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #popupBody {
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: calc(100% - 60px) !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: #ffffff !important;
    display: flex !important;
  }
}

/* ============================================
   1) HEADER
   ============================================ */
#popupHeader {
  height: var(--header-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff !important;
  color: var(--brand);
  font-weight: 700;
  font-size: 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 10;
  touch-action: none !important;
}

#popupHeader .header-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}

#popupHeader .hdr-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

#popupHeader .hdr-icon-btn:hover {
  background: #f3f4f6;
}

#popupHeader .hdr-icon-btn i {
  pointer-events: none;
  font-size: 18px;
}

/* --- 1) HEADER MOBILE --- */
@media (max-width: 820px) {
  #popupHeader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 60px !important;
    margin: 0 !important;
    padding: 0 16px !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    background: #ffffff !important;
    z-index: 100 !important;
    touch-action: none !important;
    box-sizing: border-box !important;
  }
}

/* ============================================
   2) HISTORY ENTRY (SIDEBAR)
   ============================================ */
#popupPanel {
  flex: 0 0 var(--history-w);
  width: var(--history-w);
  padding: 12px 0 12px 12px;
  box-sizing: border-box;
  border-right: 1px solid var(--border);
  background: #f3f4f6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#historyList {
  flex: 1 1 auto;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-right: 12px;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: none !important;
  scrollbar-width: none;
}

#historyList:hover {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

#historyList::-webkit-scrollbar {
  width: 5px;
}

#historyList::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 10px;
}

#historyList:hover::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.1);
}

.history-entry {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 44px 10px 12px;
  margin: 0 0 4px;
  box-sizing: border-box;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  overflow: hidden;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
  outline: none !important;
}

.history-entry:hover {
  background: #e5e7eb;
}

.history-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #3c4043;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-entry:hover .history-title {
  color: #111827;
}

.history-more-btn {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #5f6368;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  cursor: pointer;
  z-index: 10;
}

.history-entry:hover .history-more-btn {
  opacity: 1;
}

.history-more-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #111827;
}

.history-entry.active-chat {
  background: #e5e7eb !important;
}

.history-entry:hover:not(.active-chat) {
  background: #ededf0;
}

/* --- 2) HISTORY ENTRY MOBILE (TIKLAMA VE BOŞLUK KESİN ÇÖZÜM) --- */
@media (max-width: 820px) {
  #popupPanel {
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 80vw !important;
    min-width: 80vw !important;
    opacity: 0;
    /* Yeni ekle */
    visibility: hidden;
    /* Yeni ekle */
    pointer-events: none;
    /* Yeni ekle */

    /* Beyaz boşluğu yok eden çift dikiş kural */
    height: 100% !important;
    max-height: 100% !important;

    z-index: 10001 !important;

    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background: #ffffff !important;
    border-right: 1px solid #e5e7eb;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);

    /* display: flex !important; BURADAN SİLİNDİ (Tıklamayı engelliyordu) */
  }

  #popupPanel.active {
    transform: translateX(0);
    opacity: 1;
    /* Yeni ekle */
    visibility: visible;
    /* Yeni ekle */
    pointer-events: auto;
    /* Yeni ekle */
  }

  /* JS'nin "Sohbet Seçildi, Paneli Kapat" emrine CSS'in kesin itaat etmesini sağlar */
  #popupContainer.history-closed #popupPanel {
    display: none !important;
    transform: translateX(-100%) !important;
  }

  .history-entry .history-more-btn {
    opacity: 1 !important; 
    /* Butonu mobilde hep görünür kılar, böylece iOS hover efekti için ilk tıklamayı yutmaz */
  }
}

/* ============================================
   3) USER INFO & MODALS
   ============================================ */
#userInfoBar {
  flex-shrink: 0;
  margin-top: auto;
  height: 144px;
  padding: 0 16px 32px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  background: #f3f4f6;
  box-sizing: border-box;
  font-size: 12px;
}

.user-main-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.user-info-text {
  display: flex;
  flex-direction: column;
}

.user-plan-tag {
  font-size: 11px;
  color: #6b7280;
}

.logout-area,
.logout-area .logout-button {
  display: none;
}

#accountModal,
#logoutModal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: var(--z-modal);
}

#accountModal {
  align-items: stretch;
  justify-content: flex-start;
  background: transparent;
}

#logoutModal {
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}

.account-modal-box {
  position: absolute;
  left: 24px;
  bottom: 88px;
  width: 260px;
  max-width: 260px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.logout-modal-box {
  width: 100%;
  max-width: 380px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  padding: 24px 22px 20px;
  text-align: center;
}

.account-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.account-modal-title-wrap {
  display: flex;
  flex-direction: column;
}

.account-modal-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.account-modal-email {
  font-size: 13px;
  color: #6b7280;
  word-break: break-all;
}

.account-modal-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 999px;
  color: #6b7280;
}

.account-modal-body {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.account-logout-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: #fef2f2;
  color: #dc2626;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.account-logout-btn:hover {
  background: #fee2e2;
}

.logout-modal-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

.logout-modal-text {
  margin: 0 0 20px;
  font-size: 14px;
  color: #4b5563;
}

.logout-modal-email {
  font-weight: 600;
}

.logout-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logout-modal-primary,
.logout-modal-secondary {
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.logout-modal-primary {
  background: #111827;
  color: #fff;
}

.logout-modal-secondary {
  background: #fff;
  color: #111827;
  border-color: #d1d5db;
}

/* --- 3) USER INFO MOBILE (ALTTAN SIFIRLANMIŞ VERSİYON) --- */
@media (max-width: 820px) {
  #userInfoBar {
    position: relative !important;
    /* Perdeleme (::after) için gerekli */
    display: flex !important;
    align-items: center !important;

    /* Sağdaki Input Box ile görsel hizayı (yüksekliği) yakalamak için */
    min-height: 105px !important;
    height: auto !important;

    /* Sağdaki kutunun padding ve güvenli alan değerleriyle birebir aynı */
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom)) 20px !important;

    background: #F3F4F6 !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-sizing: border-box !important;
    margin-top: auto !important;
  }

  /* KESİN ÇÖZÜM: User Info altındaki beyaz boşluğu kapatan perde */
  #userInfoBar::after {
    content: "";
    position: absolute;
    top: 100%;
    /* Kutunun hemen altından başla */
    left: 0;
    right: 0;
    height: 100px;
    /* Aşağıya doğru 100px boyunca rengi uzat */
    background: #F3F4F6 !important;
    z-index: -1;
  }

  #userInfoBar .user-main-info {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }
}

/* ============================================
   4) CHATBOX & MESSAGES
   ============================================ */
#chatContentArea {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: #ffffff !important;
}

#chatScrollArea {
  flex: 1 1 auto;
  overflow-y: auto !important;
  padding: 24px 24px 120px 24px;
  box-sizing: border-box;
  background: #ffffff !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  overscroll-behavior: none !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#chatScrollArea::-webkit-scrollbar {
  display: none;
}

#chatContainer {
  padding: 0 0 20px 0;
  box-sizing: border-box;
  height: auto;
  overflow: visible;
  scroll-behavior: smooth;
  max-width: 720px;
  margin: 0 auto;
}

.chat-entry {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0;
}

.chat-entry.bot {
  position: relative;
  padding-left: 0 !important;
  padding-top: 44px !important;
  margin-bottom: 32px;
  justify-content: flex-start;
  flex-direction: column;
  align-items: flex-start;
}

.chat-entry.bot::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  background-image: url('https://static.wixstatic.com/media/ba4616_885c99c666a14fd7a4deb062cd15ee6e~mv2.jpg');
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  border: 2px solid #ffffff;
  z-index: 5 !important;
}

.system-message {
  max-width: 100%;
  padding: 0 !important;
  background: transparent !important;
  font-size: 15.5px;
  line-height: 1.65;
  color: #1f2937;
}

.bot-action-bar {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
  align-self: flex-start;
}

.chat-entry.bot:hover .bot-action-bar {
  opacity: 1;
}

.bot-action-btn {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.bot-action-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.user-message {
  max-width: 80% !important;
  margin: 0;
  padding: 16px 44px 16px 20px !important;
  border-radius: 24px;
  background: #f3f4f6 !important;
  color: var(--txt);
  font-size: 15.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  align-self: flex-end;
  position: relative;
  transition: all 0.3s ease;
}

.user-message p {
  margin-bottom: 12px !important;
  display: block;
}

.user-message .msg-text p:last-child {
  margin-bottom: 0 !important;
}

.user-message .msg-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: unset;
}

.user-message.is-collapsed .msg-text {
  -webkit-line-clamp: 3;
}

.msg-toggle-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: transparent;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #4b5563;
  transition: background 0.2s, transform 0.3s ease;
}

.msg-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.user-message.has-toggle .msg-toggle-btn {
  display: flex;
}

.user-message.has-toggle:not(.is-collapsed) .msg-toggle-btn svg {
  transform: rotate(180deg);
}

.msg-tools {
  position: absolute;
  right: 14px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
  z-index: 10;
}

.user-message:hover .msg-tools {
  opacity: 1;
  pointer-events: auto;
}

.msg-icon {
  font-size: 14px;
  cursor: pointer;
  opacity: 0.7;
}

.msg-icon:hover {
  opacity: 1;
}

.msg-text {
  pointer-events: auto !important;
}

/* Chat Markdown Styles */
.system-message :is(h1, h2, h3) {
  font-weight: 700;
  line-height: 1.2;
  margin: 22px 0 12px;
  color: #111827;
}

.system-message h1 {
  font-size: 20px;
}

.system-message h2 {
  font-size: 18px;
}

.system-message h3 {
  font-size: 16px;
}

.system-message p {
  margin: 0 0 14px;
}

.system-message>p:nth-of-type(-n+3) {
  text-indent: 1em;
}

.system-message :is(ul, ol) {
  margin: 0 0 16px 24px;
  padding-left: 12px;
}

.system-message li {
  margin: 6px 0;
}

:where(#chatContainer, .system-message) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

:where(#chatContainer, .system-message) table {
  width: 100% !important;
  margin: 16px 0 !important;
  display: table !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
}

#chatContainer .system-message table,
#chatContainer .system-message table * {
  border-style: solid !important;
  border-color: rgba(0, 0, 0, 0.06) !important;
}

:where(#chatContainer, .system-message) th,
:where(#chatContainer, .system-message) td {
  padding: 10px 12px !important;
  vertical-align: top;
  border-width: 0 !important;
  border-right-width: 1px !important;
  border-bottom-width: 1px !important;
}

:where(#chatContainer, .system-message) thead th {
  background: #f9fafb !important;
  font-weight: 700 !important;
  color: #374151;
}

:where(#chatContainer, .system-message) tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.015);
}

/* Loaders & Spinners (Inside Chat Area) */
.edit-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  margin: 0 auto 10px auto;
  border-radius: 12px;
  font-size: 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  max-width: 800px;
  pointer-events: auto;
}

.edit-info button {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  background: #fcd34d;
  color: #78350f;
  font-weight: 600;
}

.finly-waiting {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding-left: 4px;
  font-size: 13px;
  font-style: italic;
  color: #6b7280;
}

.finly-waiting .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: blink 1.4s infinite ease-in-out both;
}

.finly-waiting .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.finly-waiting .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {

  0%,
  80%,
  100% {
    opacity: 0;
  }

  40% {
    opacity: 1;
  }
}

.fc-loader-inner {
  width: min(520px, calc(100vw - 48px));
  padding: 28px 22px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.12);
  display: grid;
  justify-items: center;
  gap: 14px;
}

.fc-loader-spinner {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  border: 10px solid rgba(29, 62, 47, 0.1);
  border-top-color: var(--brand);
  animation: fcSpin 0.9s linear infinite;
}

@keyframes fcSpin {
  to {
    transform: rotate(360deg);
  }
}

/* --- 4) CHATBOX & MESSAGES MOBILE --- */
@media (max-width: 820px) {

  #chatContentArea,
  #chatContainer {
    background-color: #ffffff !important;
  }

  #chatContentArea {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    overflow: hidden !important;
    background: #ffffff !important;
    transition: transform 0.3s ease;
  }

  #chatContentArea.reduced {
    transform: translateX(80vw);
  }

  #chatScrollArea {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 16px 16px calc(120px + env(safe-area-inset-bottom)) 16px !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    overscroll-behavior: none !important;
  }

  #popupPanel.active~#chatContentArea #chatScrollArea,
  #chatContentArea.reduced #chatScrollArea {
    overflow: hidden !important;
    touch-action: none !important;
    pointer-events: none;
  }

  .system-message {
    font-size: 15px !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  .user-message {
    font-size: 15px !important;
    padding: 14px 40px 14px 16px !important;
    max-width: 85% !important;
    border-radius: 20px;
  }
}

/* ============================================
   5) INPUT BOX
   ============================================ */
#messageInputContainer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 24px 32px 24px;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 25%, rgba(255, 255, 255, 1) 50%);
  z-index: 5;
  pointer-events: none;
  touch-action: none !important;
}

.message-box {
  display: flex;
  align-items: flex-end;
  padding: 12px 12px 12px 20px;
  border-radius: 24px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  pointer-events: auto;
}

.chat-input-div {
  display: block !important;
  width: 100% !important;
  cursor: text !important;
  -webkit-user-select: text !important;
  user-select: text !important;
  pointer-events: auto !important;
  outline: none !important;
  box-shadow: none !important;
}

.chat-input-div:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
  display: block;
  font-style: normal;
}

.chat-input-div:focus:before {
  content: "" !important;
}

.message-box .chat-input-div {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin-right: 14px !important;
  box-sizing: border-box;
  line-height: 22px;
  padding: 16px 0;
  min-height: 88px;
  max-height: 200px;
  overflow-y: auto !important;
  touch-action: pan-y !important;
  overscroll-behavior: none !important;
  resize: none;
  border: none;
  background: transparent;
  white-space: pre-wrap;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  font-size: 15.5px;
}

.message-box button {
  border: none;
  background: none;
  font-size: 18px;
  color: #d1d5db;
  cursor: not-allowed;
  margin-bottom: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  flex-shrink: 0 !important;
}

.message-box button.enabled {
  color: #ffffff;
  background: var(--brand);
  cursor: pointer;
}

/* --- 5) INPUT BOX MOBILE (GÜNCELLENDİ) --- */
@media (max-width: 820px) {
  #messageInputContainer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    /* Arka zemin beyaz, gri kutu öne çıksın diye */
    border-top: none !important;
    padding: 0 !important;
    z-index: 9999 !important;
    box-sizing: border-box !important;
    transition: none !important;
  }

  /* Klavye açılırken oluşan boşluğu gri ile dolduran perde */
  #messageInputContainer::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 50vh;
    background: #F3F4F6 !important;
    z-index: -1;
  }

  .message-box {
    width: 100% !important;
    max-width: 100% !important;
    background: #F3F4F6 !important;
    /* 1. İSTEK: Kutu arka planı #F3F4F6 */
    border: none !important;
    /* 2. İSTEK: Yalnızca üst köşelere çok az (16px) radius */
    border-radius: 16px 16px 0 0 !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05) !important;
    display: flex !important;
    flex-direction: column !important;
    /* Input üste, buton alta */
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom)) 20px !important;
    gap: 12px !important;
    box-sizing: border-box !important;
  }

  #messageInputContainer .message-box .chat-input-div {
    font-size: 16px !important;
    min-height: 24px !important;
    height: auto !important;
    max-height: 120px !important;
    display: block !important;
    text-align: left !important;
    width: 100% !important;
    background: transparent !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .chat-input-div:empty:before {
    font-size: 16px !important;
    display: block !important;
    position: static !important;
    text-align: left !important;
    color: #6b7280 !important;
  }

  /* 3. İSTEK: Butonun havada kalmasını engellemek için relative konumlandırma */
  #sendButton,
  .message-box button {
    position: relative !important;
    /* Kabuktan dışarı taşmasını KESİN engeller */
    align-self: flex-end !important;
    /* Sağ alt köşeye yaslar */
    margin: 0 !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 999px !important;
    /* Tam yuvarlak buton */
    background: transparent !important;
    border: 1px solid #d1d5db !important;
    color: #4b5563 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    /* Butonun ezilmesini engeller */
  }

  .message-box button.enabled {
    background: #e8f0fe !important;
    border-color: transparent !important;
    color: var(--brand) !important;
  }
}