/* PrivZeka — claymorphic arayüz
   Açık tema: sıcak krem. Koyu tema: yumuşak grafit. Vurgu: terrakota. */

:root {
  color-scheme: light;

  /* Varsayılan "Krem" teması. Tema motoru bu değişkenleri çalışma anında
     yeniden yazar; buradaki değerler betik yüklenmeden önceki görünümdür. */
  --bg:            #EDE7DB;
  --bg-tint:       #E5DECF;
  --surface:       #F6F2E9;
  --surface-2:     #FBF8F1;
  --surface-sunk:  #E7E0D2;

  --text:          #2F2C26;
  --text-soft:     #635C4E;
  --text-faint:    #8C8474;

  --accent:        #C15F3C;
  --accent-soft:   #DFA087;
  --accent-wash:   #F3E3DA;
  --accent-ink:    #FFFFFF;

  --line:          #D9D0BF;
  --danger:        #B3452F;
  --ok:            #5F7A4A;

  --font-size:     15px;

  /* clay gölgeleri: sol-üstten ışık, sağ-alta düşen yumuşak gölge */
  --clay-up:
    7px 7px 16px rgba(151, 133, 108, 0.26),
    -6px -6px 14px rgba(255, 255, 255, 0.85);
  --clay-up-sm:
    4px 4px 9px rgba(151, 133, 108, 0.21),
    -3px -3px 8px rgba(255, 255, 255, 0.77);
  --clay-in:
    inset 4px 4px 9px rgba(151, 133, 108, 0.25),
    inset -4px -4px 9px rgba(255, 255, 255, 0.81);
  --clay-rim: inset 0 1px 0 rgba(255, 255, 255, 0.68);

  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --r-xs: 10px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, monospace;

  --sidebar-w: 286px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #232321;
  --bg-tint:       #1C1C1A;
  --surface:       #2C2C29;
  --surface-2:     #333330;
  --surface-sunk:  #232321;

  --text:          #F0EBE1;
  --text-soft:     #B5AE9F;
  --text-faint:    #857F72;

  --accent:        #D97757;
  --accent-soft:   #8A4A33;
  --accent-wash:   #3A2A23;
  --accent-ink:    #1C1C1A;

  --line:          #403F3A;
  --danger:        #E0745C;
  --ok:            #92B071;

  --clay-up:
    7px 7px 16px rgba(0, 0, 0, 0.42),
    -6px -6px 14px rgba(255, 255, 255, 0.045);
  --clay-up-sm:
    4px 4px 9px rgba(0, 0, 0, 0.36),
    -3px -3px 8px rgba(255, 255, 255, 0.04);
  --clay-in:
    inset 4px 4px 9px rgba(0, 0, 0, 0.42),
    inset -4px -4px 9px rgba(255, 255, 255, 0.045);
  --clay-rim: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  /* Uygulama sabit yükseklikte bir kabuk; kaydırma yalnızca mesaj alanında
     olmalı. Sayfanın kendisi kayarsa üst çubuk ekrandan çıkıyor ve viewport
     koordinatıyla konumlanan menüler yanlış yere düşüyor. */
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--font-size);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Arka planda çok hafif bir doku: düz renk hissini kırar */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 700px at 12% -8%, rgba(193, 95, 60, 0.07), transparent 60%),
    radial-gradient(900px 600px at 105% 105%, rgba(150, 130, 100, 0.10), transparent 62%);
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(1100px 700px at 12% -8%, rgba(217, 119, 87, 0.10), transparent 60%),
    radial-gradient(900px 600px at 105% 105%, rgba(0, 0, 0, 0.35), transparent 62%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft); color: var(--text); }

/* ---------- Ortak parçalar ---------- */

.clay {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--clay-up), var(--clay-rim);
}

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  padding: 11px 18px;
  cursor: pointer;
  box-shadow: var(--clay-up-sm), var(--clay-rim);
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease),
              background 0.16s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  justify-content: center;
}

.btn:hover { transform: translateY(-1.5px); }
.btn:active { transform: translateY(1px); box-shadow: var(--clay-in); }
.btn:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 3px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--clay-up-sm), var(--clay-rim);
}
/* Üzerine gelince vurgu rengini kullanıcının seçtiği tondan türetiriz;
   sabit bir renk yazmak özel temaları bozardı. */
.btn-accent:hover { filter: brightness(1.08); }
[data-theme="dark"] .btn-accent:hover { filter: brightness(1.12); }

.btn-ghost {
  background: transparent;
  box-shadow: none;
  color: var(--text-soft);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--surface); box-shadow: var(--clay-up-sm); color: var(--text); }

.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: 13px;
  flex: 0 0 auto;
}

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-sunk);
  border: none;
  border-radius: var(--r-sm);
  padding: 12px 14px;
  width: 100%;
  box-shadow: var(--clay-in);
  transition: box-shadow 0.16s var(--ease);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  box-shadow: var(--clay-in), 0 0 0 2.5px var(--accent-soft);
}

label { font-size: 13px; font-weight: 600; color: var(--text-soft); }

/* ---------- Giriş / kayıt ---------- */

.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-card {
  width: 100%;
  max-width: 424px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--clay-up), var(--clay-rim);
  padding: 40px 36px 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.brand-mark {
  width: 44px; height: 44px;
  border-radius: 15px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  box-shadow: var(--clay-up-sm), var(--clay-rim);
  flex: 0 0 auto;
}

.brand-name {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

.auth-tagline {
  color: var(--text-soft);
  font-size: 14px;
  margin: 0 0 28px;
}

.field { margin-bottom: 17px; }
.field label { display: block; margin-bottom: 7px; }

.auth-card .btn-accent { width: 100%; margin-top: 8px; padding: 13px; }

.auth-alt {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 14px;
  color: var(--text-soft);
}

.alert {
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: var(--accent-wash); color: var(--danger); box-shadow: var(--clay-rim); }
.alert-info { background: var(--surface-sunk); color: var(--text-soft); box-shadow: var(--clay-in); }

.hint { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }

/* ---------- Uygulama düzeni ---------- */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  /* Tek satır, viewport'u aşamaz: minmax(0,1fr) olmadan grid satırı
     içeriğe göre büyür ve tüm kabuk ekranın dışına taşar. */
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Kenar çubuğu */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  background: var(--bg-tint);
  min-width: 0;
  min-height: 0;      /* grid öğesi: içeriğinden küçülebilsin */
  overflow: hidden;   /* kaydırma yalnızca .chat-list içinde */
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 2px;
}

.sidebar-head .brand-mark { width: 38px; height: 38px; border-radius: 13px; font-size: 21px; }
.sidebar-head .brand-name { font-size: 22px; }

.new-chat { width: 100%; }

.chat-list {
  flex: 1;
  min-height: 0;      /* flex öğesi: yoksa overflow-y hiç çalışmaz */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px;
  margin: 0 -2px;
}

.chat-list::-webkit-scrollbar { width: 9px; }
.chat-list::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 9px; border: 3px solid transparent;
  background-clip: content-box;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-soft);
  font-size: 14px;
  transition: background 0.14s var(--ease), box-shadow 0.14s var(--ease),
              color 0.14s var(--ease);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.chat-item:hover { background: var(--surface); color: var(--text); }

.chat-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--clay-up-sm), var(--clay-rim);
  font-weight: 600;
}

.chat-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chat-item-del {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  padding: 3px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.chat-item:hover .chat-item-del { opacity: 1; }
.chat-item-del:hover { color: var(--danger); background: var(--accent-wash); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--clay-up-sm);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  flex: 0 0 auto;
  text-transform: uppercase;
}

.user-meta { flex: 1; min-width: 0; }
.user-name {
  font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role { font-size: 12px; color: var(--text-faint); }

/* Ana sütun */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  /* "en alta in" düğmesi buna göre konumlanır; kaydırma kabının içine
     koyulursa içerikle birlikte kayıyor. */
  position: relative;
  min-height: 0;      /* grid öğesi: içeriğinden küçülebilsin */
  overflow: hidden;   /* kaydırma yalnızca .messages içinde */
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  min-height: 66px;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 15.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-sunk);
  padding: 5px 11px;
  border-radius: 9px;
  box-shadow: var(--clay-in);
  white-space: nowrap;
}

.badge-warn { color: var(--danger); background: var(--accent-wash); }

#model-badge {
  cursor: pointer;
  border: none;
  font-family: inherit;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
#model-badge:hover { color: var(--accent); box-shadow: var(--clay-in), 0 0 0 2px var(--accent-soft); }

/* Mesajlar */

.messages {
  flex: 1;
  /* ASIL DÜZELTME: flex öğesi min-height:auto ile içeriğinden küçülmez,
     dolayısıyla overflow-y:auto hiç devreye girmez ve kutu içerikle büyüyüp
     üst çubuğu ekranın dışına iter. */
  min-height: 0;
  overflow-y: auto;
  padding: 28px 22px 12px;
  /* Akış sırasında her yeni parçada kaydırıyoruz; yumuşak kaydırma burada
     geride kalıp titremeye yol açıyor, o yüzden anlık olsun. */
  scroll-behavior: auto;
  overscroll-behavior: contain;
}

.messages::-webkit-scrollbar { width: 11px; }
.messages::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 9px; border: 3.5px solid transparent;
  background-clip: content-box;
}

.thread { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; gap: 13px; align-items: flex-start; }
.msg-user { flex-direction: row-reverse; }

.msg-avatar {
  width: 33px; height: 33px;
  border-radius: 11px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  box-shadow: var(--clay-up-sm);
  margin-top: 2px;
}

.msg-assistant .msg-avatar {
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--serif); font-size: 17px;
}
.msg-user .msg-avatar { background: var(--surface); color: var(--text-soft); }

.msg-body { min-width: 0; max-width: 100%; }

.bubble {
  border-radius: var(--r-md);
  padding: 14px 18px;
  box-shadow: var(--clay-up-sm), var(--clay-rim);
  overflow-wrap: anywhere;
}

.msg-user .bubble {
  background: var(--accent-wash);
  border-top-right-radius: 7px;
}

.msg-assistant .bubble {
  background: var(--surface);
  border-top-left-radius: 7px;
}

.bubble > *:first-child { margin-top: 0; }
.bubble > *:last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 11px; }
.bubble ul, .bubble ol { margin: 0 0 11px; padding-left: 22px; }
.bubble li { margin-bottom: 5px; }
.bubble h1, .bubble h2, .bubble h3 {
  font-family: var(--serif); font-weight: 600; margin: 18px 0 9px; line-height: 1.25;
}
.bubble h1 { font-size: 21px; } .bubble h2 { font-size: 18.5px; } .bubble h3 { font-size: 16.5px; }
.bubble code {
  font-family: var(--mono); font-size: 0.88em;
  background: var(--surface-sunk); padding: 2px 6px; border-radius: 6px;
}
.bubble pre {
  background: var(--surface-sunk);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  overflow-x: auto;
  box-shadow: var(--clay-in);
  margin: 0 0 11px;
}
.bubble pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }
.bubble blockquote {
  margin: 0 0 11px; padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent-soft); color: var(--text-soft);
}
.bubble table { border-collapse: collapse; width: 100%; margin-bottom: 11px; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.bubble th { background: var(--surface-sunk); font-weight: 600; }

/* Düşünme bölümü */

.thinking {
  margin-bottom: 10px;
  border-radius: var(--r-sm);
  background: var(--surface-sunk);
  box-shadow: var(--clay-in);
  overflow: hidden;
}

.thinking summary {
  cursor: pointer;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before {
  content: "▸"; transition: transform 0.18s var(--ease); font-size: 11px;
}
.thinking[open] summary::before { transform: rotate(90deg); }

.thinking-body {
  padding: 0 14px 12px;
  font-size: 13.5px;
  color: var(--text-soft);
  white-space: pre-wrap;
  font-family: var(--mono);
  line-height: 1.55;
  max-height: 320px;
  overflow-y: auto;
}

.msg-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-faint);
  min-height: 22px;
}

.msg-user .msg-foot { justify-content: flex-end; }

.msg-action {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-faint); font: inherit; font-size: 12px;
  padding: 3px 8px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 5px;
}
.msg-action:hover { background: var(--surface-sunk); color: var(--text); }

.msg-error {
  color: var(--danger);
  background: var(--accent-wash);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 14px;
  box-shadow: var(--clay-rim);
}

/* Yazıyor göstergesi */

.typing { display: inline-flex; gap: 5px; align-items: center; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-soft);
  animation: bounce 1.25s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.cursor-blink {
  display: inline-block; width: 2px; height: 1.05em;
  background: var(--accent); vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Boş durum */

.empty {
  max-width: 620px;
  margin: 7vh auto 0;
  text-align: center;
}

.empty-mark {
  width: 66px; height: 66px; margin: 0 auto 20px;
  border-radius: 22px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 34px; font-weight: 600;
  box-shadow: var(--clay-up), var(--clay-rim);
}

.empty h2 {
  font-family: var(--serif); font-size: 27px; font-weight: 600;
  margin: 0 0 9px; letter-spacing: -0.015em;
}
.empty p { color: var(--text-soft); margin: 0 0 26px; }

.starters { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; text-align: left; }

.starter {
  background: var(--surface);
  border: none;
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--clay-up-sm), var(--clay-rim);
  font: inherit;
  color: var(--text);
  transition: transform 0.16s var(--ease);
}
.starter:hover { transform: translateY(-2px); }
.starter:active { box-shadow: var(--clay-in); transform: translateY(1px); }
.starter strong { display: block; font-size: 14px; margin-bottom: 3px; }
.starter span { font-size: 13px; color: var(--text-faint); }

/* Yazma alanı */

.composer-wrap { padding: 10px 22px 20px; }

.composer {
  max-width: 780px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--clay-up), var(--clay-rim);
  padding: 12px 12px 10px;
  transition: box-shadow 0.18s var(--ease);
}

.composer:focus-within { box-shadow: var(--clay-up), var(--clay-rim), 0 0 0 2.5px var(--accent-soft); }

.composer textarea {
  background: transparent;
  box-shadow: none;
  resize: none;
  padding: 6px 8px;
  max-height: 220px;
  min-height: 26px;
  line-height: 1.55;
  display: block;
}
.composer textarea:focus { box-shadow: none; }
.composer textarea::placeholder { color: var(--text-faint); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 4px 0;
}

.composer-hint { flex: 1; font-size: 12px; color: var(--text-faint); }

.send-btn {
  width: 42px; height: 42px; border-radius: 14px; padding: 0;
  flex: 0 0 auto;
}

/* Ayar paneli */

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 392px;
  max-width: 92vw;
  background: var(--bg-tint);
  box-shadow: -14px 0 40px rgba(0, 0, 0, 0.16);
  transform: translateX(102%);
  transition: transform 0.32s var(--ease);
  z-index: 40;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 {
  flex: 1; margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 600;
}

.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 26px; }

.drawer-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex; gap: 10px;
}
.drawer-foot .btn { flex: 1; }

.scrim {
  position: fixed; inset: 0;
  background: rgba(30, 26, 20, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s var(--ease);
  z-index: 35;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.set-group { margin-bottom: 24px; }
.set-group > h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.075em;
  color: var(--text-faint); margin: 0 0 12px; font-weight: 700;
}

.set-row { margin-bottom: 17px; }

.set-label {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 7px;
}
.set-label > span:first-child { font-weight: 600; font-size: 13.5px; flex: 1; }

.set-value {
  font-family: var(--mono); font-size: 12.5px;
  color: var(--accent); font-weight: 600;
  background: var(--surface-sunk); padding: 2px 8px; border-radius: 7px;
  box-shadow: var(--clay-in);
  min-width: 46px; text-align: center;
}

.set-help { font-size: 12px; color: var(--text-faint); margin-top: 5px; line-height: 1.45; }

/* Kaydırıcı */

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 9px; border-radius: 9px;
  background: var(--surface-sunk); box-shadow: var(--clay-in);
}
input[type="range"]::-moz-range-track {
  height: 9px; border-radius: 9px;
  background: var(--surface-sunk); box-shadow: var(--clay-in);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--accent); margin-top: -6px;
  box-shadow: var(--clay-up-sm);
  transition: transform 0.14s var(--ease);
}
input[type="range"]::-moz-range-thumb {
  width: 21px; height: 21px; border-radius: 50%; border: none;
  background: var(--accent);
  box-shadow: var(--clay-up-sm);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }

/* Anahtar */

.toggle {
  position: relative; width: 48px; height: 27px; flex: 0 0 auto;
  border-radius: 27px; border: none; cursor: pointer; padding: 0;
  background: var(--surface-sunk); box-shadow: var(--clay-in);
  transition: background 0.2s var(--ease);
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--surface-2);
  box-shadow: var(--clay-up-sm);
  transition: transform 0.22s var(--ease);
}
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(21px); }

.set-row-inline {
  display: flex; align-items: center; gap: 12px;
}
.set-row-inline .set-label { flex: 1; margin-bottom: 0; }

/* Kip / açılır menü */

.modal-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 26, 20, 0.38);
  backdrop-filter: blur(3px);
  display: none; place-items: center; padding: 20px;
}
.modal-scrim.show { display: grid; }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--clay-up), var(--clay-rim);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow-y: auto;
}
.modal h3 { font-family: var(--serif); font-size: 21px; margin: 0 0 4px; font-weight: 600; }
.modal p.sub { color: var(--text-soft); font-size: 13.5px; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

.menu {
  /* JS bunu viewport koordinatlarıyla konumlandırıyor (innerHeight - rect.top),
     absolute olursa sayfa kaydığı anda ekran dışına düşer. */
  position: fixed;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--clay-up), var(--clay-rim);
  padding: 7px;
  min-width: 194px;
  z-index: 60;
  display: none;
}
.menu.show { display: block; }
.menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--text);
  padding: 9px 12px; border-radius: var(--r-xs);
}
.menu button:hover { background: var(--surface-sunk); }
.menu button.danger { color: var(--danger); }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 6px 4px; }

/* Bildirim */

.toast-host {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 9px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--clay-up), var(--clay-rim);
  padding: 12px 20px; font-size: 14px; font-weight: 500;
  animation: rise 0.28s var(--ease);
}
.toast.err { color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }


/* ---------- Canlı düşünme göstergesi ---------- */

.thinking-live {
  box-shadow: var(--clay-in), 0 0 0 1.5px var(--accent-soft);
}
.thinking summary { gap: 7px; }
.think-label { flex: 0 0 auto; }

.think-dots { display: inline-flex; gap: 3px; align-items: center; }
.think-dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  animation: think-pulse 1.3s infinite ease-in-out;
}
.think-dots i:nth-child(2) { animation-delay: 0.18s; }
.think-dots i:nth-child(3) { animation-delay: 0.36s; }

@keyframes think-pulse {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35%           { opacity: 1;    transform: translateY(-2.5px); }
}

/* ---------- En alta in düğmesi ---------- */

.scroll-bottom {
  position: absolute;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%) translateY(8px);
  z-index: 20;
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: var(--clay-up), var(--clay-rim);
  cursor: pointer;
  display: grid; place-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.scroll-bottom.show {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.scroll-bottom:hover { color: var(--accent); }


/* ---------- Sunucu durum çubuğu (kenar çubuğu altı) ---------- */

.pod-bar {
  border-top: 1px solid var(--line);
  padding: 11px 6px 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pod-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  border: none; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  box-shadow: var(--clay-up-sm), var(--clay-rim);
  transition: transform 0.14s var(--ease);
}
.pod-toggle:hover { transform: translateY(-1px); }
.pod-toggle:active { box-shadow: var(--clay-in); transform: translateY(1px); }
.pod-toggle:disabled { opacity: 0.55; cursor: default; transform: none; }

.pod-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}
.pod-dot.on  { background: var(--ok); box-shadow: 0 0 0 3px rgba(120, 160, 90, 0.22); }
.pod-dot.off { background: var(--text-faint); }
.pod-dot.busy {
  background: var(--accent);
  animation: pod-pulse 1.1s infinite ease-in-out;
}
@keyframes pod-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.pod-stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 9px;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 0 3px;
  line-height: 1.55;
}
.pod-stats b {
  font-weight: 600; color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  justify-self: end;
}

/* ---------- Tema düzenleyici ---------- */

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.preset-card {
  border: none;
  border-radius: var(--r-md);
  padding: 12px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  background: var(--surface);
  box-shadow: var(--clay-up-sm), var(--clay-rim);
  transition: transform 0.16s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preset-card:hover { transform: translateY(-2px); }
.preset-card.active { box-shadow: var(--clay-in), 0 0 0 2.5px var(--accent); }

.preset-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.preset-note { font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }

.preset-swatches { display: flex; gap: 4px; }
.preset-swatches i {
  width: 100%; height: 16px; border-radius: 5px;
  border: 1px solid rgba(128, 128, 128, 0.22);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.color-row:last-child { border-bottom: none; }

.color-row .swatch {
  width: 38px; height: 30px;
  border-radius: var(--r-xs);
  border: none;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: var(--clay-up-sm);
  overflow: hidden;
}
.color-row .swatch input[type="color"] {
  width: 150%; height: 150%; margin: -25%;
  border: none; padding: 0; background: none; cursor: pointer;
  box-shadow: none;
}

.color-meta { flex: 1; min-width: 0; }
.color-meta .name { font-size: 13.5px; font-weight: 600; }
.color-meta .desc { font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }

.color-hex {
  font-family: var(--mono);
  font-size: 12px;
  width: 84px;
  padding: 6px 8px;
  text-align: center;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.theme-preview {
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 18px;
  background: var(--bg);
  box-shadow: var(--clay-in);
}
.theme-preview .pv-row { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 9px; }
.theme-preview .pv-bubble {
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px;
  box-shadow: var(--clay-up-sm);
  max-width: 78%;
}
.theme-preview .pv-them { background: var(--surface); color: var(--text); }
.theme-preview .pv-you {
  background: var(--accent-wash); color: var(--text); margin-left: auto;
}
.theme-preview .pv-foot {
  font-size: 11px; color: var(--text-faint); display: flex;
  align-items: center; gap: 8px;
}
.theme-preview .pv-btn {
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--r-xs); padding: 5px 12px; font-size: 12px; font-weight: 600;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.mobile-only { display: none; }

/* ---------- Duyarlı ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: var(--sidebar-w); z-index: 45;
    transform: translateX(-102%);
    transition: transform 0.3s var(--ease);
    box-shadow: 14px 0 40px rgba(0,0,0,0.18);
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-only { display: inline-flex; }
  .starters { grid-template-columns: 1fr; }
  .messages { padding: 20px 14px 10px; }
  .composer-wrap { padding: 8px 14px 14px; }
  .topbar { padding: 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
