/* =====================================================================
 *  Destek Paneli — tasarım sistemi
 * ---------------------------------------------------------------------
 *  Yüzey tipi: OPERATE (konsol / gelen kutusu).
 *  Eylem yapılabilirliği ve seçim durumu baskındır; hero YOKTUR.
 *
 *  Belirteçler VoltAgent/awesome-design-md → design-md/linear.app/DESIGN.md
 *  dosyasından BİREBİR alınmıştır (canvas #010102, surface kademeleri,
 *  hairline tonları, primary #5e6ad2, rounded/spacing ölçekleri).
 *
 *  Derleme adımı yok: tek CSS dosyası, CDN'e bağımlılık yok.
 * ===================================================================== */

/* ---------------------------------------------------------------- *
 * BELİRTEÇLER
 * ---------------------------------------------------------------- */
:root {
  /* Yüzeyler — upstream token'ları. Gölge değil, parlaklık kademesi. */
  --canvas:  #010102;
  --surf-1:  #0f1011;
  --surf-2:  #141516;
  --surf-3:  #18191a;
  --surf-4:  #191a1b;
  --surf-5:  #202124;

  /* Metin — saf beyaz KULLANILMAZ (göz yorar) */
  --ink:     #f7f8f8;
  --ink-2:   #d0d6e0;
  --ink-3:   #8a8f98;
  --ink-4:   #767b85;

  /* Hairline — upstream: solid ton + yarı saydam varyant */
  --line:    #1c1d21;
  --line-2:  #23252a;
  --line-3:  #34343a;
  --line-4:  #3e3e44;
  --glow:    rgba(255, 255, 255, 0.055);

  /* Tek kromatik vurgu — dekoratif ASLA kullanılmaz */
  --primary:       #5e6ad2;
  --primary-hover: #828fff;
  --primary-press: #5e69d1;
  --primary-soft:  rgba(94, 106, 210, 0.16);
  --primary-ring:  rgba(113, 112, 255, 0.32);

  /* Durum */
  --ok:      #27a644;
  --ok-soft: rgba(39, 166, 68, 0.14);
  --warn:      #d9a441;
  --warn-soft: rgba(217, 164, 65, 0.13);
  --err:      #e5484d;
  --err-soft: rgba(229, 72, 77, 0.13);

  /* Yarıçap — upstream rounded ölçeği */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 9999px;

  /* Boşluk — upstream spacing ölçeği */
  --s-xxs: 4px;
  --s-xs:  8px;
  --s-sm:  12px;
  --s-md:  16px;
  --s-lg:  24px;
  --s-xl:  32px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* HAREKET — tek kaynak. Linear/Superhuman: hızlı, ince, farkedilmez.
     Hiçbir geçiş 220 ms'i aşmaz; kullanıcı beklemez, sadece "akıcı" hisseder. */
  --t-fast:  110ms;
  --t-base:  160ms;
  --t-slow:  220ms;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);   /* yumuşak duruş */
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);    /* giriş */
  --ease-in:   cubic-bezier(0.4, 0, 1, 1);       /* çıkış */

  --rail: 344px;
  --aside: 296px;
  --bar: 44px;
}

/* ---------------------------------------------------------------- *
 * TEMEL
 * ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; overscroll-behavior: none; }

body {
  background: var(--canvas);
  color: var(--ink-2);
  font-family: var(--font);
  /* cv01 + ss03: Inter'i Linear'ın geometrik alternatiflerine çevirir */
  font-feature-settings: 'cv01', 'ss03';
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
input, textarea, select { outline: none; }
.hidden { display: none !important; }
.ic { flex: none; display: block; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-3);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--line-4); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--primary-hover);
  outline-offset: 1px;
  border-radius: var(--r-xs);
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Hareket duyarlılığı: sistem ayarı kapalıysa TÜM hareket durur. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------------- *
 * MARKA — üç hat tek noktada birleşir (ürünün tek cümlesi)
 * ---------------------------------------------------------------- */
.mark { width: 18px; height: 18px; display: block; flex: none; overflow: visible; }
.mark line { stroke: var(--ink-3); stroke-width: 1.6; stroke-linecap: round; }
.mark circle { fill: var(--primary-hover); }

/* ---------------------------------------------------------------- *
 * GİRİŞ
 * ---------------------------------------------------------------- */
#loginView { height: 100%; display: none; place-items: center; padding: var(--s-lg); }
#loginView.show { display: grid; }

.login-card {
  width: 100%;
  max-width: 316px;
  animation: cardIn 420ms var(--ease-out) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
}

.login-head { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-head .mark { width: 22px; height: 22px; }
.login-head h1 {
  margin: 0; font-size: 14px; font-weight: 590;
  letter-spacing: -0.1px; color: var(--ink);
}
.login-head p { margin: 1px 0 0; font-size: 12px; color: var(--ink-4); }

.field { margin-bottom: var(--s-sm); }
.field label {
  display: block; font-size: 11px; font-weight: 510;
  color: var(--ink-3); margin-bottom: 5px;
}

.input {
  width: 100%;
  background: var(--surf-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.input::placeholder { color: var(--ink-4); }
.input:hover { border-color: var(--line-3); }
.input:focus {
  border-color: var(--primary);
  background: var(--surf-2);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* --- Butonlar: upstream component token'ları --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surf-3);
  color: var(--ink-2);
  font-size: 12px; font-weight: 510;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surf-5); border-color: var(--line-3); color: var(--ink); }
/* Basınca hafif çöker — dokunsal geri bildirim, "gerçek düğme" hissi */
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { cursor: default; }
.btn-xs:disabled { background: var(--surf-2); border-color: var(--line); color: var(--ink-3); }

.btn-primary { background: var(--primary); border-color: transparent; color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: transparent; color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--primary-press); }

.btn-ok:hover:not(:disabled) { background: var(--ok-soft); border-color: rgba(39,166,68,.42); color: #6ee08a; }
.btn-danger:hover:not(:disabled) { background: var(--err-soft); border-color: rgba(229,72,77,.42); color: #ff9ea1; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-4); }
.btn-ghost:hover:not(:disabled) { background: var(--surf-4); color: var(--ink); }

.btn-block { width: 100%; height: 32px; margin-top: var(--s-xxs); }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; border-radius: var(--r-xs); }
.btn-icon { width: 24px; padding: 0; }

.alert {
  margin-top: var(--s-md);
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  background: var(--err-soft);
  border: 1px solid rgba(229, 72, 77, 0.32);
  color: #ff9ea1;
  animation: shake 320ms var(--ease);
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  30%, 70% { transform: translateX(2px); }
  50% { transform: translateX(-2px); }
}

/* ---------------------------------------------------------------- *
 * KABUK
 * ---------------------------------------------------------------- */
#appView { height: 100%; display: none; flex-direction: column; }
#appView.show { display: flex; }

.topbar {
  height: var(--bar);
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px 0 12px;
  background: var(--surf-1);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand b { font-size: 12.5px; font-weight: 590; color: var(--ink); letter-spacing: -0.1px; }

.spacer { margin-left: auto; }

/* Bağlantı göstergesi — sessiz; yalnızca koptuğunda dikkat çeker */
.wsdot { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-4); }
.wsdot i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-4); flex: none;
           transition: background var(--t-base) var(--ease); }
.wsdot.on i  { background: var(--ok); }
.wsdot.off i { background: var(--err); animation: beat 1.3s ease-in-out infinite; }
.wsdot.off   { color: #ff9ea1; }
@keyframes beat { 50% { opacity: .3; transform: scale(.8); } }

.presence { display: flex; align-items: center; }
.presence .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--surf-1); transition: transform var(--t-base) var(--ease); }
.presence .av:first-child { margin-left: 0; }
.presence .av:hover { transform: translateY(-2px); z-index: 2; }

/* Avatar — deterministik ton: aynı kişi her zaman aynı renk */
.av {
  width: 22px; height: 22px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 590; letter-spacing: -0.2px;
  flex: none; user-select: none;
}
.av-lg { width: 32px; height: 32px; font-size: 12px; border-radius: var(--r-md); }

.me { display: flex; align-items: center; gap: 7px; padding-left: 10px; border-left: 1px solid var(--line); }
.me span { font-size: 12px; color: var(--ink-3); }

/* ---------------------------------------------------------------- *
 * DÜZEN
 * ---------------------------------------------------------------- */
.workspace { flex: 1; display: flex; min-height: 0; }

.rail {
  width: var(--rail); flex: none;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surf-1);
  border-right: 1px solid var(--line);
}

.rail-head { padding: var(--s-xs); border-bottom: 1px solid var(--line); }

.search { position: relative; display: flex; align-items: center; }
.search > .ic-wrap { position: absolute; left: 8px; pointer-events: none; color: var(--ink-4); display: flex; }
.search .input { padding-left: 28px; padding-right: 30px; height: 30px; }
.search kbd {
  position: absolute; right: 7px;
  font-family: var(--mono); font-size: 10px; color: var(--ink-4);
  border: 1px solid var(--line-2); border-radius: var(--r-xs);
  padding: 0 4px; line-height: 15px; pointer-events: none;
}

/* --- Sekmeler: kayan gösterge (Linear imzası) --- */
.tabs { position: relative; display: flex; gap: 2px; margin-top: 7px; }
.tabs::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: var(--ind-x, 0);
  width: var(--ind-w, 0);
  height: 2px;
  background: var(--primary-hover);
  border-radius: var(--r-pill);
  transition: left var(--t-slow) var(--ease), width var(--t-slow) var(--ease);
  opacity: var(--ind-o, 0);
}
.tab {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  height: 26px; border-radius: var(--r-xs);
  font-size: 11.5px; font-weight: 510; color: var(--ink-4);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tab:hover { background: var(--surf-3); color: var(--ink-2); }
.tab.on { color: var(--ink); }
.tab em {
  font-style: normal; font-family: var(--mono); font-size: 10px;
  color: var(--ink-4); transition: color var(--t-fast) var(--ease);
}
.tab.on em { color: var(--ink-3); }
.tab.has em { color: var(--primary-hover); }

.list { flex: 1; overflow-y: auto; }

/* --- Konuşma satırı --- */
.row {
  position: relative;
  display: flex; gap: 9px;
  padding: 9px 10px 9px 9px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
/* Seçim çubuğu: soldan büyür — anlık renk sıçraması yerine hareket */
.row::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--primary-hover);
  transform: scaleY(0); transform-origin: center;
  transition: transform var(--t-base) var(--ease);
}
.row:hover { background: var(--surf-2); }
.row.on { background: var(--surf-4); }
.row.on::before { transform: scaleY(1); }
.row.cursor:not(.on) { background: var(--surf-2); box-shadow: inset 0 0 0 1px var(--line-2); }

.row-body { min-width: 0; flex: 1; }
.row-top { display: flex; align-items: baseline; gap: 6px; }
.row-name {
  font-size: 12.5px; font-weight: 510; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row.unread .row-name { color: var(--ink); font-weight: 590; }
.row-time { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink-4); flex: none; }

.row-mid { display: flex; align-items: center; gap: 6px; margin-top: 2px; }

/* Kanal göstergesi — hangi hattan geldiği birinci sınıf bilgi */
.chan { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--ink-4); min-width: 0; }
.chan i { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.chan span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.who { font-size: 10.5px; color: var(--ink-4); white-space: nowrap; }
.who.free { color: var(--warn); }

.count {
  margin-left: auto; flex: none;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--primary); color: #fff;
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  display: grid; place-items: center;
  animation: pop var(--t-slow) var(--ease-out);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.row-prev {
  margin-top: 3px; font-size: 11.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row.unread .row-prev { color: var(--ink-2); }

.row-tags { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9.5px; font-weight: 510;
  padding: 0 5px; height: 16px;
  border-radius: var(--r-xs); border: 1px solid;
}
.prio {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9.5px; font-weight: 590; padding: 0 5px; height: 16px;
  border-radius: var(--r-xs); border: 1px solid;
}
.prio.urgent { background: var(--err-soft);  border-color: rgba(229,72,77,.4);  color: #ff9ea1; }
.prio.high   { background: var(--warn-soft); border-color: rgba(217,164,65,.4); color: #f0d9a8; }
.prio.low    { background: var(--surf-4);    border-color: var(--line-2);       color: var(--ink-4); }

/* --- Boş durum --- */
.empty {
  display: grid; place-items: center; gap: var(--s-xs);
  padding: 48px 22px; text-align: center;
  color: var(--ink-4); font-size: 12px; line-height: 1.6;
  animation: fadeIn var(--t-slow) var(--ease-out);
}
.empty .glyph {
  width: 34px; height: 34px; border-radius: var(--r-lg);
  background: var(--surf-3); border: 1px solid var(--line-2);
  display: grid; place-items: center; color: var(--ink-4);
}
.empty b { color: var(--ink-2); font-weight: 510; font-size: 12.5px; }
.empty small { font-size: 11px; color: var(--ink-4); }
@keyframes fadeIn { from { opacity: 0; } }

/* --- İSKELET YÜKLEME: "yükleniyor…" yazısı yerine yapı --- */
.sk { pointer-events: none; }
.sk-line, .sk-av {
  background: linear-gradient(90deg, var(--surf-2) 25%, var(--surf-5) 37%, var(--surf-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-xs);
}
.sk-av { width: 22px; height: 22px; border-radius: var(--r-sm); flex: none; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------------------------------------------------------------- *
 * SOHBET
 * ---------------------------------------------------------------- */
/* Sohbet zemini: saf canvas (#010102) yerine bir kademe yukarısı.
   Marketing sayfasında canvas doğru, ama uygulama yüzeyinde panel ile
   sohbet arasındaki ayrım kaybolur — kolonlar tek kara blok görünür. */
.thread { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #0a0b0c; }

.thread-blank { flex: 1; display: grid; place-items: center; color: var(--ink-4); font-size: 12.5px; }
.thread-blank .box { text-align: center; display: grid; gap: 10px; place-items: center; }
.thread-blank .glyph {
  width: 42px; height: 42px; border-radius: var(--r-lg);
  background: var(--surf-2); border: 1px solid var(--line-2);
  display: grid; place-items: center; color: var(--ink-4);
}
kbd {
  font-family: var(--mono); font-size: 10.5px;
  border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: var(--r-xs); padding: 1px 5px;
  color: var(--ink-3); background: var(--surf-2);
}

.thread-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  background: var(--surf-1);
  border-bottom: 1px solid var(--line);
}
.thread-id { min-width: 0; flex: 1; }
.thread-id .n { display: flex; align-items: center; gap: 8px; }
.thread-id b {
  font-size: 13px; font-weight: 590; color: var(--ink); letter-spacing: -0.1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thread-id .sub {
  display: flex; align-items: center; gap: var(--s-xs);
  font-size: 11px; color: var(--ink-4); margin-top: 2px;
}
.thread-id .sub > *:not(:first-child)::before {
  content: ''; display: inline-block;
  width: 2px; height: 2px; border-radius: 50%;
  background: currentColor; vertical-align: middle;
  margin-right: var(--s-xs); opacity: .55;
}
.thread-acts { display: flex; align-items: center; gap: 5px; flex: none; }
#chatAssignee { font-weight: 510; }

.sel {
  height: 24px; padding: 0 6px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line-2);
  background: var(--surf-3);
  color: var(--ink-3); font-size: 11.5px;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.sel:hover { color: var(--ink-2); border-color: var(--line-3); }

/* --- Mesajlar --- */
.msgs {
  flex: 1; overflow-y: auto;
  padding: var(--s-md) var(--s-md) 10px;
  display: flex; flex-direction: column; gap: 3px;
  min-height: 0;
  scroll-behavior: smooth;
}
.msgs > * { flex: none; }
/* Sohbet YUKARIDAN dolar.
   Daha önce margin-top:auto ile alta yaslanıyordu; bu, az mesajlı
   konuşmada ekranın üst yarısını (~400px) ölü alana çeviriyordu.
   Bağlam kartı en üstte durur, mesajlar altına akar — WhatsApp Web,
   Linear ve Superhuman'ın davranışı da budur. */

/* --- Konuşma başlığı: ölü alanı bilgiye çevirir ---
   Operate yüzeyinde 400px boş piksel kabul edilemez. Sohbetin başında
   "bu kim, hangi hattan, ne zaman başladı" duruyor; operatör konuşmaya
   girdiği anda bağlamı görür. Boşluk yok etmek yerine İŞ YAPTIRILDI. */
.thread-intro {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 16px 20px;
  text-align: center;
  animation: fadeIn 320ms var(--ease-out);
}
.thread-intro .av-lg { width: 40px; height: 40px; font-size: 14px; }
.thread-intro b { font-size: 14px; font-weight: 590; color: var(--ink); letter-spacing: -0.1px; }
.thread-intro .meta {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--ink-4);
}
.thread-intro .meta .chan { font-size: 11.5px; }
.thread-intro .facts {
  display: flex; gap: 5px; flex-wrap: wrap; justify-content: center;
  margin-top: 2px;
}
.fact {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surf-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  padding: 3px 9px;
  font-size: 10.5px; color: var(--ink-3);
}
.fact b { font-size: 10.5px; font-weight: 590; color: var(--ink-2); letter-spacing: 0; }

.daysep {
  display: flex; align-items: center; gap: 10px;
  margin: var(--s-sm) 0 9px;
  font-family: var(--mono); font-size: 10px; color: var(--ink-4);
}
.daysep::before, .daysep::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.msg { display: flex; align-items: flex-start; max-width: 100%; }
.msg.out { justify-content: flex-end; }
.msg + .msg.grp { margin-top: -1px; }

.bub {
  position: relative;
  max-width: min(70%, 520px);
  padding: 7px 11px 6px;
  border-radius: var(--r-lg);
  font-size: 13px; line-height: 1.45;
  transition: background var(--t-base) var(--ease), opacity var(--t-base) var(--ease);
}
/* pre-wrap YALNIZCA gövdede: şablon girintisi balonu şişirmez */
.bub-t { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }

.msg.in .bub {
  background: var(--surf-5);
  border: 1px solid var(--line-2);
  border-bottom-left-radius: var(--r-xs);
  color: var(--ink-2);
}
.msg.out .bub {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: var(--r-xs);
}
/* Optimistik mesaj: onaylanana kadar hafif soluk — "gidiyor" hissi */
.msg.pending .bub { opacity: .58; }
/* Başarısız giden mesaj: hâlâ GİDEN mesaj gibi görünür (mor zemin),
   yalnızca sol kenarında ince kırmızı işaret taşır. Tamamen kırmızıya
   boyamak mesajı okunmaz yapar ve ekranı ele geçirir. */
.msg.out.bad .bub {
  background: rgba(94, 106, 210, 0.42);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--err);
}

.bub-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 5px;
  margin-top: 2px;
  font-family: var(--mono); font-size: 9.5px;
  opacity: .62;
}
.msg.out .bub-meta { color: #fff; }
.msg.in  .bub-meta { color: var(--ink-4); opacity: 1; }
.bub-meta .ic { opacity: .9; }

/* Gönderim hatası balonun İÇİNİ doldurmaz: mesaj metni birincil,
   hata ikincil. Tek satır, sessiz ton — yoksa kırmızı blok tüm
   sohbeti ezer (slop tell 6: anıt öğe). */
.bub-err {
  margin-top: 4px; padding-top: 4px;
  border-top: 1px solid rgba(229,72,77,.22);
  font-size: 10px; color: rgba(255,158,161,.8);
  display: flex; align-items: center; gap: 5px;
}
/* Hata METNİ daralır ve kırpılır; "yeniden dene" butonu ASLA kesilmez —
   eylem, açıklamadan önce gelir. Mobilde buton "y" olarak kırpılmıştı. */
.bub-err > span {
  min-width: 0; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bub-err button { flex: none; }
.bub-err button {
  color: #fff; font-size: 10.5px; font-weight: 510;
  border-bottom: 1px solid rgba(255,255,255,.4);
  transition: border-color var(--t-fast) var(--ease);
}
.bub-err button:hover { border-bottom-color: #fff; }

/* "yazıyor" göstergesi */
.typing { display: inline-flex; gap: 3px; padding: 3px 0; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-3);
  animation: bounce 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity:.5 } 30% { transform: translateY(-4px); opacity:1 } }

/* --- Yazma alanı --- */
.composer {
  flex: none;
  padding: var(--s-xs) 10px;
  padding-bottom: calc(var(--s-xs) + env(safe-area-inset-bottom));
  background: var(--surf-1);
  border-top: 1px solid var(--line);
}

.canned {
  margin-bottom: 7px;
  max-height: 176px; overflow-y: auto;
  background: var(--surf-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.42);
  animation: sheetUp var(--t-base) var(--ease-out);
}
@keyframes sheetUp { from { opacity: 0; transform: translateY(6px); } }
.canned-item { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); transition: background var(--t-fast) var(--ease); }
.canned-item:last-child { border-bottom: none; }
.canned-item:hover, .canned-item.on { background: var(--surf-5); }
.canned-item b { font-family: var(--mono); font-size: 11px; color: var(--primary-hover); font-weight: 500; }
.canned-item i { font-style: normal; font-size: 11px; color: var(--ink-3); margin-left: 6px; }
.canned-item p { margin: 2px 0 0; font-size: 11.5px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.compose-box {
  display: flex; align-items: flex-end; gap: 7px;
  background: var(--surf-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 5px 5px 5px 11px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.compose-box:focus-within { border-color: var(--line-4); box-shadow: 0 0 0 3px rgba(255,255,255,.03); }

#msgInput {
  flex: 1; background: none; border: none; resize: none;
  max-height: 152px; padding: 4px 0;
  font-size: 13px; line-height: 1.45; color: var(--ink);
}
#msgInput::placeholder { color: var(--ink-4); }

.compose-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: 5px; padding: 0 2px;
  font-size: 10.5px; color: var(--ink-4);
}
.compose-foot kbd { font-size: 9.5px; padding: 0 3px; border-bottom-width: 1px; }
.warn-line { color: var(--warn); }

/* ---------------------------------------------------------------- *
 * MÜŞTERİ KARTI
 * ---------------------------------------------------------------- */
.aside {
  width: var(--aside); flex: none;
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
  background: var(--surf-1);
  border-left: 1px solid var(--line);
}
.aside-in { padding: var(--s-sm); }

.sect { margin-bottom: 18px; }
.sect:last-child { margin-bottom: 4px; }
.sect > h4 {
  margin: 0 0 8px;
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 590;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-4);
}
.sect > h4 span { text-transform: none; letter-spacing: 0; font-weight: 400; }

.who-card { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.who-card .t { min-width: 0; }
.who-card .t b { display: block; font-size: 13px; font-weight: 590; color: var(--ink); }
.who-card .t span { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.chip-x { opacity: .5; transition: opacity var(--t-fast) var(--ease); }
.chip-x:hover { opacity: 1; }

.note {
  background: var(--warn-soft);
  border: 1px solid rgba(217, 164, 65, 0.22);
  border-radius: var(--r-sm);
  padding: 7px 9px; margin-bottom: 5px;
  animation: noteIn var(--t-slow) var(--ease-out);
}
@keyframes noteIn { from { opacity: 0; transform: translateX(6px); } }
.note p { margin: 0; font-size: 11.5px; color: #f0d9a8; line-height: 1.45; }
.note span { display: block; margin-top: 3px; font-size: 10px; color: var(--ink-4); }

.hist { display: flex; flex-direction: column; gap: 4px; }
.hist a {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-4);
  text-decoration: none; cursor: pointer;
  padding: 3px 5px; margin: 0 -5px;
  border-radius: var(--r-xs);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.hist a:hover { color: var(--ink-2); background: var(--surf-3); }
.hist a.now { color: var(--primary-hover); }
.hist i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; flex: none; opacity: .7; }
.hist span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist em { font-style: normal; font-family: var(--mono); font-size: 9.5px; }

textarea.input { resize: none; }

/* Segment seçici (öncelik) */
.seg { display: flex; gap: 2px; background: var(--surf-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 2px; }
.seg button {
  flex: 1; height: 22px; border-radius: var(--r-xs);
  font-size: 10.5px; font-weight: 510; color: var(--ink-4);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink-2); }
.seg button.on { background: var(--surf-5); color: var(--ink); }
.seg button.on[data-p="urgent"] { background: var(--err-soft); color: #ff9ea1; }
.seg button.on[data-p="high"]   { background: var(--warn-soft); color: #f0d9a8; }

/* ---------------------------------------------------------------- *
 * KOMUT PALETİ (Cmd+K) — Linear/Superhuman imzası
 * ---------------------------------------------------------------- */
.cmdk {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.62);
  display: none;
  padding: 12vh 16px 16px;
  animation: fadeIn var(--t-fast) var(--ease-out);
}
.cmdk.show { display: block; }
.cmdk-box {
  max-width: 560px; margin: 0 auto;
  background: var(--surf-4);
  border: 1px solid var(--line-3);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.04);
  overflow: hidden;
  animation: cmdkIn var(--t-base) var(--ease-out);
}
@keyframes cmdkIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.cmdk-in { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.cmdk-in input { flex: 1; background: none; border: none; font-size: 14px; color: var(--ink); }
.cmdk-in input::placeholder { color: var(--ink-4); }
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 5px; }
.cmdk-grp { padding: 7px 9px 3px; font-size: 9.5px; font-weight: 590; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
.cmdk-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--ink-2); font-size: 12.5px;
}
.cmdk-item.on { background: var(--primary-soft); color: var(--ink); }
.cmdk-item .sub { margin-left: auto; font-size: 10.5px; color: var(--ink-4); }
.cmdk-foot { display: flex; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--line-2); font-size: 10.5px; color: var(--ink-4); }

/* ---------------------------------------------------------------- *
 * AYARLAR
 * ---------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.68);
  padding: var(--s-lg) var(--s-md);
  overflow-y: auto; display: none;
  animation: fadeIn var(--t-fast) var(--ease-out);
}
.modal.show { display: block; }

.sheet {
  max-width: 820px; margin: 0 auto;
  background: var(--surf-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  box-shadow: 0 16px 48px rgba(0,0,0,.55);
  animation: cmdkIn var(--t-base) var(--ease-out);
}
.sheet-head { display: flex; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { margin: 0; font-size: 13px; font-weight: 590; color: var(--ink); }
.sheet-head button { margin-left: auto; color: var(--ink-4); padding: 3px 5px; border-radius: var(--r-xs); transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.sheet-head button:hover { color: var(--ink); background: var(--surf-4); }

.stabs { display: flex; gap: 2px; padding: var(--s-xs) 16px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.stab {
  padding: 6px 10px; border-radius: var(--r-xs) var(--r-xs) 0 0;
  font-size: 11.5px; font-weight: 510; color: var(--ink-4);
  white-space: nowrap; border-bottom: 2px solid transparent;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.stab:hover { color: var(--ink-2); }
.stab.on { color: var(--ink); border-bottom-color: var(--primary-hover); }

.sheet-body { padding: 16px; }

.item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surf-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 11px; margin-bottom: 5px;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.item:hover { border-color: var(--line-2); background: var(--surf-3); }
.item .grow { min-width: 0; flex: 1; }
.item b { display: block; font-size: 12.5px; font-weight: 510; color: var(--ink); }
.item small { font-size: 11px; color: var(--ink-4); }

.pill {
  font-size: 9.5px; font-weight: 510;
  padding: 1px 7px; border-radius: var(--r-pill);
  border: 1px solid; white-space: nowrap;
}
.pill.role  { background: var(--primary-soft); border-color: rgba(113,112,255,.3); color: #a5aaff; }
.pill.on    { background: var(--ok-soft);   border-color: rgba(39,166,68,.3);  color: #6ee08a; }
.pill.off   { background: var(--err-soft);  border-color: rgba(229,72,77,.3);  color: #ff9ea1; }
.pill.mute  { background: var(--surf-4); border-color: var(--line-2); color: var(--ink-4); }

.divider { border-top: 1px solid var(--line); margin: var(--s-md) 0 var(--s-sm); }

.form-grid { display: grid; gap: 6px; grid-template-columns: repeat(4, 1fr); }
.form-grid.c3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.c2 { grid-template-columns: repeat(2, 1fr); }
.form-grid .input { height: 30px; font-size: 12px; }

.callout {
  background: var(--primary-soft);
  border: 1px solid rgba(113, 112, 255, 0.22);
  border-radius: var(--r-md);
  padding: 9px 11px; font-size: 11.5px;
  color: var(--ink-3); margin-bottom: var(--s-sm); line-height: 1.55;
}
.callout.done { background: var(--ok-soft); border-color: rgba(39,166,68,.28); }
.callout b { color: var(--ink); }
.callout code {
  font-family: var(--mono); font-size: 11px;
  background: var(--canvas); border-radius: var(--r-xs);
  padding: 1px 5px; color: var(--ink-2); word-break: break-all;
}
.callout .ln { margin-top: 5px; }

.meta-line { font-family: var(--mono); font-size: 10px; color: var(--ink-4); margin-top: 3px; word-break: break-all; }

.ev {
  display: flex; align-items: baseline; gap: 9px;
  padding: 6px 2px; border-bottom: 1px solid var(--line);
  font-size: 11.5px;
}
.ev time { font-family: var(--mono); font-size: 10px; color: var(--ink-4); flex: none; }
.ev .k { font-family: var(--mono); font-size: 10px; color: var(--primary-hover); flex: none; min-width: 128px; }
.ev p { margin: 0; color: var(--ink-3); }

/* ---------------------------------------------------------------- *
 * BİLDİRİM
 * ---------------------------------------------------------------- */
#toast {
  position: fixed; bottom: 18px; left: 50%;
  transform: translateX(-50%);
  z-index: 80; display: none;
  align-items: center; gap: 9px;
  max-width: 460px; padding: 9px 14px;
  border-radius: var(--r-md);
  background: var(--surf-5);
  border: 1px solid var(--line-3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  font-size: 12px; color: var(--ink);
}
#toast.show { display: flex; animation: toastIn var(--t-slow) var(--ease-out); }
#toast.err  { background: #2a1214; border-color: rgba(229,72,77,.45); color: #ffc9cb; }
#toast.warn { background: #2a2113; border-color: rgba(217,164,65,.45); color: #f0d9a8; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } }

/* Geri tuşu — medya sorgularından ÖNCE (sonra gelirse mobil boyutu ezer) */
#backBtn {
  display: none; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--r-xs); color: var(--ink-3);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
#backBtn:hover { background: var(--surf-4); color: var(--ink); }

/* ---------------------------------------------------------------- *
 * DUYARLI
 * ---------------------------------------------------------------- */
@media (max-width: 1180px) { .aside { display: none; } .aside.force { display: flex; } }
@media (max-width: 900px) { :root { --rail: 300px; } }

@media (max-width: 720px) {
  .rail { width: 100%; border-right: none; }
  .thread { display: none; }
  .aside { display: none; }

  body.view-thread .rail { display: none; }
  body.view-thread .thread { display: flex; }
  body.view-thread #backBtn { display: inline-flex; }

  .aside.force {
    display: flex; position: fixed; inset: var(--bar) 0 0;
    z-index: 40; width: 100%; border-left: none;
  }

  /* Sohbet başlığı: dar ekranda iki satır — butonlar adın üstüne binmesin */
  .thread-head { flex-wrap: wrap; row-gap: 7px; padding: var(--s-xs) 10px; }
  .thread-id { flex: 1 0 100%; min-width: 0; }
  .thread-acts { flex: 1 0 100%; }
  .thread-acts .btn, .thread-acts .sel { flex: 1; }
  .thread-acts .btn:last-child { flex: 0 0 36px; }
  .thread-id .sub { flex-wrap: wrap; row-gap: 2px; }

  /* Dokunma hedefi asgari 44px */
  .row { padding: 12px 12px 12px 10px; min-height: 58px; }
  .btn { height: 34px; }
  .btn-xs { height: 32px; padding: 0 11px; font-size: 12px; }
  .tab { height: 32px; font-size: 12px; }
  .sel { height: 32px; font-size: 12px; }
  #backBtn { width: 34px; height: 34px; }
  .search .input { height: 36px; }
  #sendBtn { height: 34px !important; min-width: 42px; }
  .presence, .wsdot span, .me span { display: none; }
  .me { padding-left: 6px; }
  .cmdk { padding: 8vh 12px 12px; }
}
