:root {
  --bg: #0e1419;
  --panel: #151c23;
  --panel-2: #1b242c;
  --ink: #e6edf2;
  --muted: #7e8c97;
  --brand: #2fb59c;
  --brand-soft: #1c3833;
  --user: #2fb59c;
  --line: #232f38;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* Ana ekran ASLA dikey kaymaz — scroll yalnızca iç alanlarda (sol liste). */
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  height: 100vh;       /* dvh desteklemeyen tarayıcılar için fallback */
  height: 100dvh;
  display: grid;
  grid-template-columns: 300px 1fr;
  /* Satırı container yüksekliğine sabitle (auto DEĞİL): minmax(0,1fr) sayesinde
     öğeler 100dvh'yi aşamaz, içerik uzayınca .conv-list / .messages KENDİ
     içinde scroll olur — tüm sayfa aşağı kaymaz, Gönder butonu hep görünür. */
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 15px; }
.dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft);
  display: grid; place-items: center;
}
.dot::after { content: "🍀"; font-size: 15px; }

.new-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}
.new-btn:hover { border-color: var(--brand); color: var(--brand); }

.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
.conv {
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid transparent;
}
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--panel-2); border-color: var(--brand); }
.conv .phone { font-size: 14px; font-variant-numeric: tabular-nums; }
.conv .preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat */
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.chat-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-height: 51px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-head strong { color: var(--ink); }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row { display: flex; }
.row.user { justify-content: flex-end; }
.bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14.5px;
}
.row.bot .bubble { background: var(--panel-2); border-bottom-left-radius: 4px; }
.row.user .bubble { background: var(--user); color: #06231e; border-bottom-right-radius: 4px; }
.typing .bubble {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.typing-label {
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
}
.dots { display: inline-flex; gap: 4px; }
.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-block;
  animation: typing-blink 1.2s infinite both;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* Composer */
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* Dosya ekleme */
.attach-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 12px;
  height: 42px;
  padding: 0 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.attach-btn:hover { border-color: var(--brand); }

.file-preview { display: flex; }
.preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
  max-width: 100%;
}
.preview-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.preview-remove:hover { color: var(--brand); }

/* Balon içi dosya/görsel */
.bubble .thumb {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
}
.bubble .file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
}
.bubble .bubble-text { margin-top: 6px; }
.bubble .bubble-text:first-child { margin-top: 0; }

/* Kanal logosu (conv listesi + başlık) */
.chan {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 6px;
  flex-shrink: 0;
}
.chat-head .chan { width: 18px; height: 18px; vertical-align: -4px; }

/* Yeni konuşma — kanal seçim modalı */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 22px 16px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.modal-card h3 { margin: 0 0 4px; font-size: 17px; }
.modal-card p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }
.platform-choices { display: flex; gap: 12px; }
.platform-choice {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: border-color .15s ease, transform .05s ease, background .15s ease;
}
.platform-choice img { width: 40px; height: 40px; }
.platform-choice:hover { border-color: var(--brand); background: #20303a; }
.platform-choice:active { transform: translateY(1px); }
.modal-cancel {
  margin-top: 14px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.modal-cancel:hover { color: var(--ink); }
textarea#input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14.5px;
  max-height: 140px;
  outline: none;
}
textarea#input:focus { border-color: var(--brand); }
textarea#input::placeholder { color: var(--muted); }
button#send {
  border: none;
  background: var(--brand);
  color: #06231e;
  height: 42px;
  padding: 0 20px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .2px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  transition: background .15s ease, transform .05s ease;
}
button#send::after { content: "➤"; font-size: 13px; }
button#send:hover { background: #3ccbb0; }
button#send:active { transform: translateY(1px); }
button#send:disabled { opacity: .5; cursor: default; }

/* --- Mobil geri butonu (masaüstünde gizli) --- */
.mobile-back {
  display: none;
  background: none;
  border: none;
  color: var(--brand);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-right: 4px;
  flex-shrink: 0;
}

/* =============================================
   RESPONSIVE — ≤ 768 px
   ============================================= */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    position: relative;
    overflow: hidden;
  }

  /* Sidebar tam ekranı kaplar, üstte z-index ile */
  .sidebar {
    position: absolute;
    inset: 0;
    z-index: 10;
    transition: transform 0.22s ease;
    will-change: transform;
  }

  /* Konuşma seçilince sidebar sola kayar */
  .app.chat-active .sidebar {
    transform: translateX(-100%);
    pointer-events: none;
  }

  .chat {
    height: 100dvh;
  }

  .mobile-back {
    display: block;
  }

  .messages {
    padding: 14px 12px;
  }

  .bubble {
    max-width: 86%;
    font-size: 14px;
    padding: 9px 12px;
  }

  .composer {
    padding: 10px 12px;
  }

  /* iOS çift-dokunma zoom engellemek için ≥16px */
  textarea#input {
    font-size: 16px;
  }
}

/* =============================================
   RESPONSIVE — ≤ 400 px  (320px dahil)
   ============================================= */
@media (max-width: 400px) {
  .sidebar-head {
    padding: 12px 10px;
  }

  .brand strong {
    font-size: 13px;
  }

  .new-btn {
    padding: 6px 9px;
    font-size: 12px;
  }

  .messages {
    padding: 10px 8px;
    gap: 10px;
  }

  .bubble {
    max-width: 91%;
    font-size: 13.5px;
    padding: 8px 10px;
  }

  .composer {
    padding: 8px;
    gap: 6px;
  }

  button#send {
    padding: 0 13px;
    font-size: 13px;
  }

  .chat-head {
    padding: 12px 10px;
    font-size: 13px;
  }
}
