:root {
  --bg: #080a12;
  --panel: rgba(15, 18, 31, 0.78);
  --panel-strong: #111524;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f7f8fc;
  --muted: #9298ad;
  --primary: #7c5cff;
  --primary-2: #9d7cff;
  --green: #4ade80;
  --shadow: 0 24px 80px rgba(0,0,0,.42);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(124, 92, 255, .16), transparent 32%),
    radial-gradient(circle at 85% 80%, rgba(50, 84, 255, .12), transparent 34%),
    var(--bg);
}
button, textarea { font: inherit; }
button { color: inherit; }
.ambient { position: fixed; width: 360px; height: 360px; border-radius: 50%; filter: blur(110px); opacity: .22; pointer-events: none; }
.ambient-one { background: #795cff; top: -160px; left: 18%; }
.ambient-two { background: #315aff; right: -180px; bottom: -160px; }
.app-shell {
  width: min(1440px, calc(100vw - 32px));
  height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(9, 11, 20, .72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  border-right: 1px solid var(--border);
  background: rgba(11, 13, 23, .78);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 4px 12px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 13px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #4f7cff);
  box-shadow: 0 10px 28px rgba(124,92,255,.35);
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; }
.brand span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.new-chat {
  border: 1px solid rgba(143, 117, 255, .4);
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(124,92,255,.2), rgba(79,124,255,.08));
  text-align: left;
  cursor: pointer;
  transition: .2s ease;
}
.new-chat:hover { transform: translateY(-1px); border-color: var(--primary-2); }
.new-chat span { margin-right: 8px; }
.sidebar-section { display: grid; gap: 8px; }
.section-label { padding: 0 10px 5px; color: #676e84; font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.feature { padding: 10px; border-radius: 11px; color: var(--muted); font-size: 13px; }
.feature span { display: inline-block; width: 24px; color: #b3a5ff; }
.feature.active { color: #fff; background: rgba(255,255,255,.05); }
.model-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
}
.status-row { display: flex; align-items: center; gap: 7px; color: #b7bdcf; font-size: 11px; margin-bottom: 10px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(74,222,128,.8); }
.model-card strong { display: block; font-size: 12px; }
.model-card small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.sidebar footer { color: #555c70; text-align: center; font-size: 10px; }
.chat-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; background: rgba(14, 16, 27, .48); }
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 15px; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 10px; display: flex; align-items: center; gap: 6px; }
.icon-button {
  width: 36px; height: 36px; margin-left: auto;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 11px;
  background: rgba(255,255,255,.035); cursor: pointer;
}
.menu-button { display: none; margin-left: 0; }
.messages {
  overflow-y: auto;
  padding: 28px clamp(18px, 6vw, 80px);
  scroll-behavior: smooth;
}
.welcome { max-width: 760px; margin: clamp(40px, 9vh, 110px) auto 0; text-align: center; }
.hero-icon {
  width: 62px; height: 62px; margin: 0 auto 22px; display: grid; place-items: center;
  border: 1px solid rgba(160,137,255,.35); border-radius: 20px;
  background: linear-gradient(145deg, rgba(124,92,255,.25), rgba(80,104,255,.08));
  color: #c8bcff; font-size: 27px;
  box-shadow: 0 18px 48px rgba(82,61,180,.22);
}
.welcome h2 { margin: 0; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.04em; }
.welcome > p { max-width: 610px; margin: 14px auto 30px; color: var(--muted); line-height: 1.7; font-size: 13px; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.suggestions button {
  min-height: 92px; padding: 15px;
  display: flex; align-items: flex-start; gap: 11px;
  border: 1px solid var(--border); border-radius: 15px;
  background: rgba(255,255,255,.025); text-align: left; cursor: pointer;
  transition: .2s ease;
}
.suggestions button:hover { transform: translateY(-2px); border-color: rgba(157,124,255,.45); background: rgba(124,92,255,.07); }
.suggestions button > span { color: #a993ff; font-size: 17px; }
.suggestions strong, .suggestions small { display: block; }
.suggestions strong { font-size: 12px; }
.suggestions small { margin-top: 8px; color: var(--muted); font-size: 10px; }
.message { max-width: 860px; margin: 0 auto 22px; display: flex; gap: 12px; animation: fadeUp .25s ease; }
.message.user { justify-content: flex-end; }
.avatar {
  flex: 0 0 32px; width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 10px; background: linear-gradient(135deg, var(--primary), #4f7cff);
  font-size: 12px; font-weight: 700;
}
.message.user .avatar { order: 2; background: #24293a; }
.bubble {
  max-width: min(78%, 720px);
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.045);
  color: #e8eaf2;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.user .bubble {
  background: linear-gradient(135deg, rgba(124,92,255,.32), rgba(75,95,207,.19));
  border-color: rgba(144,119,255,.26);
}
.message.error .bubble { border-color: rgba(255,100,100,.28); color: #ffb8b8; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #aaa4c8; animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.composer-wrap { padding: 12px clamp(18px, 6vw, 80px) 18px; }
.composer {
  max-width: 860px;
  margin: 0 auto;
  display: flex; align-items: flex-end; gap: 10px;
  padding: 9px 9px 9px 16px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 18px;
  background: rgba(20,23,38,.92);
  box-shadow: 0 14px 45px rgba(0,0,0,.25);
}
.composer:focus-within { border-color: rgba(145,119,255,.62); box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
textarea {
  width: 100%; max-height: 160px; resize: none;
  border: 0; outline: 0; padding: 9px 0;
  color: #fff; background: transparent;
  font-size: 13px; line-height: 1.5;
}
textarea::placeholder { color: #737a91; }
.send-button {
  flex: 0 0 38px; width: 38px; height: 38px;
  border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #4f7cff);
  cursor: pointer; font-size: 20px;
  box-shadow: 0 8px 20px rgba(124,92,255,.28);
}
.send-button:disabled { opacity: .45; cursor: not-allowed; }
.disclaimer { margin: 9px auto 0; color: #5e6578; text-align: center; font-size: 9px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
@keyframes pulse { 0%, 80%, 100% { opacity: .3; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@media (max-width: 800px) {
  .app-shell { width: 100vw; height: 100vh; margin: 0; border: 0; border-radius: 0; grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; width: 260px; inset: 0 auto 0 0; transform: translateX(-100%); transition: .25s ease; box-shadow: 20px 0 60px rgba(0,0,0,.4); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: grid; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome { margin-top: 25px; }
  .messages { padding-top: 20px; }
  .bubble { max-width: 88%; }
}


.model-select-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}
.model-select-wrap label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}
.model-select-wrap select {
  min-width: 185px;
  padding: 9px 32px 9px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #151827;
  font-size: 11px;
  cursor: pointer;
}
.model-select-wrap select:focus {
  border-color: rgba(145,119,255,.62);
}
.topbar .icon-button {
  margin-left: 0;
}
@media (max-width: 650px) {
  .model-select-wrap label { display: none; }
  .model-select-wrap select {
    min-width: 135px;
    max-width: 145px;
    font-size: 10px;
  }
}


/* ===== V2: uzun sohbet kaydırma ve sohbet geçmişi ===== */

html,
body {
  width: 100%;
  height: 100%;
}

body {
  min-height: 100%;
}

.app-shell {
  min-height: 0;
}

.sidebar,
.chat-panel,
.messages {
  min-height: 0;
}

.sidebar {
  overflow: hidden;
}

.chat-panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.messages {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-bottom: 42px;
}

.messages::-webkit-scrollbar,
.conversation-list::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb,
.conversation-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.messages::-webkit-scrollbar-track,
.conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

.composer-wrap {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,.045);
  background: linear-gradient(to top, rgba(10,12,21,.98), rgba(10,12,21,.86));
  backdrop-filter: blur(16px);
}

.chat-history-section {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-right: 4px;
}

.history-clear-button {
  border: 0;
  padding: 4px 6px;
  background: transparent;
  color: #6f768c;
  font-size: 9px;
  cursor: pointer;
}

.history-clear-button:hover {
  color: #c8bcff;
}

.conversation-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 3px;
}

.conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: .18s ease;
}

.conversation-item:hover {
  border-color: rgba(255,255,255,.06);
  background: rgba(255,255,255,.035);
}

.conversation-item.active {
  border-color: rgba(142,116,255,.23);
  background: linear-gradient(135deg, rgba(124,92,255,.15), rgba(70,90,190,.06));
}

.conversation-open {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 10px 32px 10px 9px;
  border-radius: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.conversation-icon {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #aa98ff;
  background: rgba(124,92,255,.09);
  font-size: 11px;
}

.conversation-copy {
  min-width: 0;
  flex: 1;
}

.conversation-copy strong,
.conversation-copy small {
  display: block;
}

.conversation-copy strong {
  overflow: hidden;
  color: #dfe2ed;
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-copy small {
  margin-top: 4px;
  color: #62697d;
  font-size: 8px;
}

.conversation-delete {
  position: absolute;
  right: 5px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #6f768a;
  background: transparent;
  opacity: 0;
  cursor: pointer;
  transition: .18s ease;
}

.conversation-item:hover .conversation-delete,
.conversation-item.active .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  color: #ffb0b0;
  background: rgba(255,90,90,.09);
}

.empty-history {
  padding: 14px 9px;
  color: #596074;
  font-size: 10px;
  line-height: 1.5;
}

.empty-history[hidden] {
  display: none;
}

.model-card {
  flex: 0 0 auto;
  margin-top: 8px;
}

.message {
  width: 100%;
}

.bubble {
  overflow: visible;
}

@media (max-width: 800px) {
  .chat-panel {
    height: 100vh;
  }

  .sidebar {
    height: 100vh;
  }

  .messages {
    padding-bottom: 26px;
  }

  .composer-wrap {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .conversation-delete {
    opacity: 1;
  }
}


/* ==========================================================
   V3.1 - Kesin kaydırma ve geçmiş düzeltmeleri
   Bu bölüm kasıtlı olarak dosyanın en sonundadır.
   ========================================================== */

html {
  height: 100%;
  overflow: hidden;
}

body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.app-shell {
  display: flex !important;
  width: min(1440px, calc(100vw - 32px));
  height: calc(100dvh - 32px) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  height: 100%;
  min-height: 0 !important;
  overflow: hidden !important;
}

.chat-panel {
  display: flex !important;
  flex: 1 1 auto;
  flex-direction: column;
  width: 0;
  height: 100%;
  min-width: 0;
  min-height: 0 !important;
  overflow: hidden !important;
}

.topbar {
  flex: 0 0 76px;
  min-height: 76px;
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  max-width: min(420px, 42vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  position: relative;
  display: block !important;
  flex: 1 1 0 !important;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  padding-top: 28px;
  padding-bottom: 48px !important;
}

.composer-wrap {
  position: relative !important;
  bottom: auto !important;
  flex: 0 0 auto;
  width: 100%;
}

.message {
  min-width: 0;
}

.bubble {
  min-width: 0;
  max-width: min(78%, 760px);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-history-section {
  flex: 1 1 0 !important;
  min-height: 0 !important;
}

.conversation-list {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 800px) {
  .app-shell {
    width: 100vw;
    height: 100dvh !important;
    margin: 0;
  }

  .sidebar {
    position: fixed;
    width: min(290px, 86vw);
    min-width: 0;
    height: 100dvh;
  }

  .chat-panel {
    width: 100%;
    height: 100dvh;
  }

  .topbar-title h1 {
    max-width: 32vw;
  }

  .messages {
    padding-bottom: 32px !important;
  }

  .bubble {
    max-width: 88%;
  }
}
