/* ==================================================================
   modules/chat.css · Mesajlar + AI Coworker
   Renk anlamı: turuncu = müşteri görür (dış), mor = AI, mavi = sana/yeni.
   Bütün renkler tema token'larından; sabit renk yok.
================================================================== */

/* ---------- Kabuk: 3 sütun, sayfa kaymaz ---------- */
.ch-shell { flex: 1; min-height: 0; position: relative; display: grid; grid-template-columns: 272px minmax(0, 1fr) auto; overflow: hidden; background: var(--bg); }
.ch-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.ch-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* ---------- Kanal listesi ---------- */
.ch-side { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--bg); }
.ch-side-top { padding: 12px 12px 8px; flex: none; }
.ch-side-top .search { width: 100%; }
.ch-side-top .input { width: 100%; }
.ch-side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 16px; overscroll-behavior: contain; }
.ch-grp { margin-top: 12px; }
.ch-grp-h { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 10px; font-size: 11.5px; font-weight: 650; color: var(--text-3); letter-spacing: .01em; }
.ch-grp-h > span { display: inline-flex; align-items: center; gap: 6px; }
.ch-grp-h .icon-btn { margin-left: auto; width: 24px; height: 24px; }
.ch-grp-empty, .ch-no-res { padding: 6px 10px; font-size: 12.5px; color: var(--text-3); }
.ch-ext-tag { height: 17px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; background: var(--t-amber-bg); color: var(--t-amber); letter-spacing: .02em; }

.ch-row { display: flex; align-items: center; gap: 9px; min-height: 32px; padding: 4px 8px 4px 10px; border-radius: 7px; color: var(--text-2); text-decoration: none; font-size: 13.5px; transition: background-color 100ms ease, color 100ms ease; }
.ch-row:hover { background: var(--hover); color: var(--text); }
.ch-row[aria-current="page"] { background: var(--selected); color: var(--text); font-weight: 600; }
.ch-row.unread { color: var(--text); font-weight: 650; }
.ch-row.muted { opacity: .62; }
.ch-row-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-row-t small { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.ch-row .avatar.md { width: 22px; height: 22px; font-size: 9.5px; }
.ch-ic { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 6px; color: var(--text-3); }
.ch-ic svg.i { width: 15px; height: 15px; }
.ch-ic.ext { background: var(--t-amber-bg); color: var(--t-amber); }
.ch-n { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--t-gray-bg); color: var(--t-gray); }
.ch-n.hot { background: var(--accent); color: var(--on-accent); }
.ch-mute { color: var(--text-3); display: grid; }
.ch-ai-row { margin-top: 2px; min-height: 42px; }
.ch-ai-row .ch-row-t { font-weight: 600; color: var(--text); }
.ch-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--text-3); }
.ch-dot[data-state="online"] { background: var(--green); }
.ch-dot[data-state="busy"] { background: var(--accent); }
.ch-dot[data-state="offline"] { background: var(--red); }

/* ---------- İleti dizisi başlığı ---------- */
.ch-head { flex: none; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 14px 8px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.ch-head.is-ext { background: var(--t-amber-bg); border-bottom-color: color-mix(in srgb, var(--t-amber) 28%, transparent); }
.ch-head .ch-ic { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); }
.ch-head .ch-ic svg.i { width: 17px; height: 17px; }
.ch-head.is-ext .ch-ic { background: var(--bg); color: var(--t-amber); }
.ch-head .avatar.md { width: 30px; height: 30px; font-size: 11px; }
.ch-head-t { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ch-head-t h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-head-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); min-width: 0; white-space: nowrap; }
.ch-head-sub > span { overflow: hidden; text-overflow: ellipsis; }
.ch-head-sub svg.i { width: 13px; height: 13px; flex: none; }
.ch-ext-badge { height: 20px; font-size: 11.5px; gap: 4px; padding: 0 7px; flex: none; }
.ch-ext-badge svg.i { width: 12px; height: 12px; }
.ch-sub-txt { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.ch-spacer { flex: 1; }
.ch-head-ref { font-family: var(--mono); font-size: 12px; }
.ch-back { display: none; }

/* ---------- Mesaj akışı ---------- */
.ch-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 0 12px; overscroll-behavior: contain; display: flex; flex-direction: column; }
.ch-msgs:focus-visible { outline-offset: -2px; }
.ch-msgs > .empty-state { margin: auto; }
.ch-day { display: flex; align-items: center; gap: 12px; margin: 14px 20px 6px; font-size: 12px; font-weight: 650; color: var(--text-2); }
.ch-day::before, .ch-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.ch-new { display: flex; align-items: center; gap: 10px; margin: 8px 20px 4px; font-size: 11.5px; font-weight: 700; color: var(--accent); }
.ch-new::before { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.ch-new span { order: 2; }
.ch-new::after { content: ""; order: 3; width: 18px; height: 1px; background: color-mix(in srgb, var(--accent) 55%, transparent); }

.ch-msg { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; padding: 7px 20px 5px; transition: background-color 120ms ease; }
.ch-msg.cont { padding-top: 1px; padding-bottom: 3px; }
.ch-msg:hover, .ch-msg:focus-within { background: var(--hover); }
.ch-msg.at-me { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); box-shadow: inset 2px 0 0 var(--accent); }
.ch-msg.flash { animation: ch-flash 1.2s var(--ease-out); }
@keyframes ch-flash { 0% { background: var(--selected); } 100% { background: transparent; } }
.ch-gut { display: flex; justify-content: center; padding-top: 1px; }
.ch-gut .avatar.lg { width: 32px; height: 32px; font-size: 11.5px; }
.ch-ht { font-size: 10.5px; color: var(--text-3); padding-top: 4px; opacity: 0; font-variant-numeric: tabular-nums; }
.ch-msg:hover .ch-ht, .ch-msg:focus-within .ch-ht { opacity: 1; }
.ch-cnt { min-width: 0; }
.ch-mh { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12.5px; line-height: 18px; }
.ch-mh strong { font-size: 13.5px; font-weight: 650; }
.ch-mh time { color: var(--text-3); font-variant-numeric: tabular-nums; }
.ch-ed { font-size: 11.5px; color: var(--text-3); margin-left: 4px; }
.ch-ai-tag, .ch-cl-tag { height: 18px; padding: 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
.ch-cl-tag { background: var(--t-amber-bg); color: var(--t-amber); }
.ch-body { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; color: var(--text); }
.ch-body p { margin: 0 0 6px; } .ch-body p:last-child { margin-bottom: 0; }
.ch-body ul { margin: 2px 0 6px; padding-left: 20px; } .ch-body li { margin: 1px 0; }
.ch-body code { font-family: var(--mono); font-size: 12.5px; background: var(--thumb); padding: 1px 4px; border-radius: 4px; }
.ch-body blockquote { margin: 4px 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--line-strong); color: var(--text-2); }
.ch-at { color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.ch-at.me { background: var(--accent); color: var(--on-accent); }
.ch-at.ai { color: var(--t-purple); background: var(--t-purple-bg); }

/* Müşteri kanalında iç not */
.ch-msg.is-note .ch-body, .ch-msg.is-note .ch-files { padding: 6px 10px; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--surface-2); }
.ch-msg.is-note.cont .ch-body { margin-top: 2px; }
.ch-note-l { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-2); margin: 2px 0 4px; }
.ch-note-l svg.i { width: 12px; height: 12px; }

/* Yanıt alıntısı */
.ch-quote { display: flex; align-items: center; gap: 6px; max-width: 100%; margin: 3px 0 4px; padding: 3px 8px; border: 0; border-left: 2px solid var(--line-strong); border-radius: 0 6px 6px 0; background: var(--surface-2); font-size: 12.5px; color: var(--text-2); text-align: left; }
.ch-quote:hover { color: var(--text); background: var(--hover); }
.ch-quote strong { flex: none; font-weight: 600; color: var(--text); }
.ch-quote span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-quote svg.i { flex: none; color: var(--text-3); }

/* Dosyalar ve bağlantı */
.ch-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ch-img { border: 0; padding: 0; background: none; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.ch-img img { display: block; width: 180px; max-width: 100%; height: 120px; object-fit: cover; }
.ch-file { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12.5px; max-width: 100%; }
.ch-file svg.i { color: var(--text-3); }
.ch-file-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.ch-file small { color: var(--text-3); white-space: nowrap; }
.ch-ref { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; margin-top: 6px; height: 26px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-size: 12.5px; color: var(--text-2); }
.ch-ref:hover { color: var(--text); border-color: var(--line-strong); }
.ch-ref span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Mesaj araçları (hover / odak) */
.ch-tools { position: absolute; top: -12px; right: 16px; display: flex; gap: 1px; padding: 2px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none; transition: opacity 120ms ease; }
.ch-msg:hover .ch-tools, .ch-msg:focus-within .ch-tools { opacity: 1; pointer-events: auto; }
.ch-tools .icon-btn { width: 28px; height: 28px; }
.ch-msg.cont .ch-tools { top: -14px; }
@media (hover: none), (pointer: coarse) {
  .ch-tools { opacity: 1; pointer-events: auto; top: 4px; right: 8px; box-shadow: none; background: transparent; }
  .ch-msg.cont .ch-tools { top: -2px; }
  .ch-tools [data-ch-m="reply"] { display: none; }
  .ch-mh { padding-right: 28px; }
}

/* Düzenleme */
.ch-edit { margin-top: 3px; }
.ch-edit-ta { width: 100%; min-height: 40px; resize: none; }
.ch-edit-a { display: flex; align-items: center; gap: 6px; margin-top: 6px; justify-content: flex-end; }
.ch-edit-a .hint { margin-right: auto; font-size: 11.5px; color: var(--text-3); }

/* ---------- AI kartı ---------- */
.ch-msg.is-ai .ch-mh strong { color: var(--t-purple); }
.ch-av-ai svg.i { width: 15px; height: 15px; }
.avatar.ch-av-ai:not(.lg):not(.md) svg.i { width: 12px; height: 12px; }
.ch-ai-card { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); max-width: 720px; }
.ch-ai-card[data-state="needs_human"] { border-color: color-mix(in srgb, var(--t-amber) 35%, transparent); }
.ch-ai-card[data-state="error"] { border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.ch-ai-st { display: flex; align-items: center; gap: 8px; }
.ch-ai-q { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ch-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; }
.ch-steps li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); min-height: 22px; }
.ch-steps li[data-s="done"] { color: var(--text); }
.ch-steps li[data-s="todo"] { color: var(--text-3); }
.ch-steps li code { margin-left: auto; font: 11px var(--mono); color: var(--text-3); background: var(--thumb); padding: 1px 5px; border-radius: 4px; }
.ch-sti { width: 18px; height: 18px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.ch-steps li[data-s="done"] .ch-sti { background: var(--t-green-bg); color: var(--t-green); }
.ch-steps li[data-s="fail"] .ch-sti { background: var(--t-red-bg); color: var(--t-red); }
.ch-steps li[data-s="wait"] .ch-sti { background: var(--t-amber-bg); color: var(--t-amber); }
.ch-sti svg.i { width: 11px; height: 11px; stroke-width: 2.4; }
.ch-ring { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.ch-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: ch-spin .8s linear infinite; }
@keyframes ch-spin { to { transform: rotate(360deg); } }
.ch-ai-a { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.ch-rem { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ch-rem svg.i { width: 13px; height: 13px; color: var(--green); }

.ch-confirm { margin-top: 10px; padding: 10px 12px; border-radius: 9px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--t-amber) 40%, transparent); }
.ch-confirm[data-status="approved"] { border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.ch-confirm[data-status="rejected"] { border-color: var(--line); }
.ch-confirm-h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.ch-confirm-h strong { color: var(--text); font-size: 13px; }
.ch-confirm-h svg.i { color: var(--t-amber); }
.ch-confirm-h code { font: 11px var(--mono); background: var(--thumb); padding: 1px 5px; border-radius: 4px; }
.ch-confirm blockquote { margin: 8px 0; padding: 8px 10px; border-left: 2px solid var(--t-amber); background: var(--t-amber-bg); border-radius: 0 6px 6px 0; font-size: 13px; line-height: 1.5; color: var(--text); }
.ch-confirm[data-status="approved"] blockquote { border-left-color: var(--green); background: var(--surface-2); }
.ch-confirm[data-status="rejected"] blockquote { border-left-color: var(--line-strong); background: var(--surface-2); color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--text-3); }
.ch-confirm-a, .ch-confirm-r { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ch-confirm-r { font-size: 12px; color: var(--text-2); }

/* ---------- Yazma alanı (altta sabit) ---------- */
.ch-compose { flex: none; padding: 8px 20px 16px; background: var(--bg); }
.ch-compose .composer .ch-ta { min-height: 44px; max-height: 220px; resize: none; padding: 11px 12px; font-size: 14px; line-height: 1.45; overflow-y: auto; }
.ch-compose.is-ext .composer { border-color: color-mix(in srgb, var(--t-amber) 60%, transparent); }
.ch-compose.is-ext .composer:focus-within { border-color: var(--t-amber); box-shadow: 0 0 0 3px var(--t-amber-bg); }
.ch-compose.is-ext.is-note .composer { border-color: var(--line-strong); border-style: dashed; }
.ch-compose.is-ext.is-note .composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ch-ext-bar { display: flex; align-items: center; gap: 7px; padding: 6px 8px 6px 12px; font-size: 12.5px; background: var(--t-amber-bg); color: var(--t-amber); border-bottom: 1px solid color-mix(in srgb, var(--t-amber) 22%, transparent); }
.ch-ext-bar > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-ext-bar strong { font-weight: 700; }
.ch-compose.is-note .ch-ext-bar { background: var(--surface-2); color: var(--text-2); border-bottom-color: var(--line); }
.ch-note-btn { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 6px; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); background: transparent; color: inherit; font-size: 12px; font-weight: 600; flex: none; }
.ch-note-btn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.ch-note-btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
.ch-note-btn svg.i { width: 12px; height: 12px; }
.ch-ai-btn { color: var(--t-purple); }
.ch-kb { white-space: nowrap; }

/* @ önerisi */
.ch-mpop { padding: 0; }
.ch-mpop-h { padding: 8px 12px 2px; font-size: 11.5px; font-weight: 650; color: var(--text-3); }
.ch-mpop .opt .avatar { width: 22px; height: 22px; }

/* ---------- Bağlam paneli ---------- */
.ch-ctx { width: 304px; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--surface-2); }
.ch-ctx-h { flex: none; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--line); }
.ch-ctx-h h3 { margin: 0; font-size: 14px; font-weight: 650; flex: 1; }
.ch-ctx-b { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 20px; overscroll-behavior: contain; }
.ch-ctx-b section { min-width: 0; }
.ch-kv { grid-template-columns: 96px 1fr; }
.ch-kv dt { display: flex; align-items: center; gap: 2px; }
.ch-kv .hint-i { width: 18px; height: 18px; }
.ch-link { height: 26px; padding: 0 6px; margin-left: -6px; max-width: 100%; justify-content: flex-start; }
.ch-link-a { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.ch-ctx-list { display: flex; flex-direction: column; background: var(--bg); border-radius: var(--r-m); overflow: hidden; border: 1px solid var(--line); }
.ch-ctx-list > * + * { border-top: 1px solid var(--line); }
.ch-ctx-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; text-align: left; color: var(--text); min-height: 44px; }
button.ch-ctx-row:hover { background: var(--hover); }
.ch-ctx-row svg.i { color: var(--text-3); flex: none; }
.ch-ctx-main { flex: 1; min-width: 0; }
.ch-ctx-main strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-ctx-main span { display: block; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-ctx-th { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex: none; }
.ch-ctx-fi { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.ch-ctx-empty { font-size: 12.5px; color: var(--text-3); padding: 2px 0; }
.ch-ctx .block-head .btn { margin-left: 4px; }
.ch-you { font-style: normal; font-weight: 500; color: var(--text-2); }

/* ---------- Diyalog yardımcıları ---------- */
.ch-auto { font-size: 10.5px; font-weight: 700; color: var(--t-gray); background: var(--t-gray-bg); padding: 1px 6px; border-radius: 4px; margin-left: 4px; letter-spacing: .02em; }
.ch-ro { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; color: var(--text-2); }
.ch-ro svg.i { width: 15px; height: 15px; }

/* ---------- AI Coworker sayfası ---------- */
.ch-ai-page { display: grid !important; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) minmax(0, .8fr); gap: 16px; }
.ch-runner { grid-column: 1 / -1; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--r-l); background: var(--surface-2); border: 1px solid var(--line); }
.ch-runner[data-state="offline"] { border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.ch-runner-id { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.ch-runner-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--t-green-bg); color: var(--t-green); flex: none; }
.ch-runner[data-state="busy"] .ch-runner-ic { background: var(--t-blue-bg); color: var(--t-blue); }
.ch-runner[data-state="offline"] .ch-runner-ic { background: var(--t-red-bg); color: var(--t-red); }
.ch-runner-id h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.ch-runner-id span { font-size: 12.5px; color: var(--text-2); }
.ch-runner-kv { display: flex; gap: 22px; margin: 0; flex: 1; flex-wrap: wrap; }
.ch-runner-kv div { min-width: 0; }
.ch-runner-kv dt { font-size: 11.5px; color: var(--text-2); }
.ch-runner-kv dd { margin: 2px 0 0; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ch-run-sw { font-weight: 600; }
.ch-p-q { grid-column: 1; grid-row: 2; }
.ch-p-log { grid-column: 1; grid-row: 3; }
.ch-p-tools { grid-column: 2; grid-row: 2 / 4; }
.ch-ai-page table.grid th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.ch-ai-page table.grid td { vertical-align: middle; }
.ch-ai-page table.grid th:first-child, .ch-ai-page table.grid td:first-child { padding-left: 16px; }
.ch-ai-page table.grid th:last-child, .ch-ai-page table.grid td:last-child { padding-right: 16px; }
.ch-q-t { min-width: 0; }
.ch-q-t strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.ch-q-t span { display: block; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px; }
.ch-q-err { color: var(--red); }
.ch-q-a { text-align: right; white-space: nowrap; }
.ch-lease { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.ch-tool { font: 12px var(--mono); color: var(--text); }
.ch-run-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--t-green-bg); color: var(--t-green); white-space: nowrap; }
.ch-run-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ch-run-pill[data-state="busy"] { background: var(--t-blue-bg); color: var(--t-blue); }
.ch-run-pill[data-state="offline"] { background: var(--t-red-bg); color: var(--t-red); }

/* ---------- Gömülü dizi (portal) ---------- */
.ch-embed-host { display: flex; flex-direction: column; min-height: 0; }
.ch-embed { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ch-embed .ch-thread.as-client .ch-msg.mine .ch-mh strong { color: var(--text); }

/* ---------- Duyarlı düzen ---------- */
@media (max-width: 1280px) {
  .ch-shell { grid-template-columns: 248px minmax(0, 1fr); }
  .ch-ctx { position: absolute; top: 0; right: 0; bottom: 0; z-index: 6; box-shadow: var(--shadow-modal); }
}
@media (max-width: 1100px) {
  .ch-ai-page { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(260px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr); }
  .ch-p-q, .ch-p-log, .ch-p-tools { grid-column: 1; grid-row: auto; }
  .ch-ai-page { overflow-y: auto !important; }
}
@media (max-width: 760px) {
  .ch-shell { grid-template-columns: minmax(0, 1fr); }
  .ch-shell:not(.has-ch) .ch-main { display: none; }
  .ch-shell.has-ch .ch-side { display: none; }
  .ch-side { border-right: 0; }
  .ch-side-scroll { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .ch-ctx { width: 100%; left: 0; }
  .ch-back { display: grid; margin-left: -6px; }
  .ch-head { padding: 8px 10px 8px 14px; gap: 8px; }
  .ch-head-ref, .ch-sub-txt { display: none; }
  .ch-msg { padding-left: 14px; padding-right: 14px; grid-template-columns: 30px minmax(0, 1fr); }
  .ch-gut .avatar.lg { width: 30px; height: 30px; }
  .ch-day, .ch-new { margin-left: 14px; margin-right: 14px; }
  .ch-compose { padding: 8px 12px calc(76px + env(safe-area-inset-bottom)); }
  .ch-kb, .ch-send-l { display: none; }
  .ch-img img { width: 140px; height: 100px; }
  .ch-ai-page { display: flex !important; flex-direction: column; overflow-y: auto !important; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .ch-ai-page .panel { flex: none; max-height: 70vh; }
  .ch-runner { gap: 14px; }
  .ch-runner-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; }
  .ch-runner-kv dd { font-size: 13px; }
  .ch-qt th:nth-child(5), .ch-qt td:nth-child(5), .ch-qt th:nth-child(2), .ch-qt td:nth-child(2) { display: none; }
  .ch-q-t strong, .ch-q-t span { max-width: 52vw; }
  .ch-ai-page .panel-body { overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) { .ch-spin { animation-duration: 2.4s; } }

.ch-ai-a a.btn, .ch-link-a { text-decoration: none; }

/* Sunucu modu: runner bağlı değil, cihazlar, eşleştirme kodu */
.ch-run-pill[data-state="not_connected"] { background: var(--surface-2); color: var(--text-2); }
.ch-runner[data-state="not_connected"] .ch-runner-ic { background: var(--surface); color: var(--text-2); }
.ch-dot[data-state="not_connected"] { background: var(--text-3); }
.ch-devs { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
.ch-dev { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12.5px; }
.ch-dev strong { font-weight: 650; }
.ch-dev span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  /* örnek UI'da da görülen sıkışma: runner kimliği ve sayaçlar telefonda tam satır */
  .ch-runner-id, .ch-runner-kv { flex: 1 1 100%; min-width: 0; }
}
.ch-pair-code { display: flex; align-items: center; gap: 10px; }
.ch-pair-code code { font: 600 22px var(--mono); letter-spacing: .08em; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); user-select: all; }
