/* #region zone:desk.style.thinking — ฟองกำลังคิด จุดพิมพ์ และข้อความที่ค่อยๆ ปรากฏ */
/* Bot bubble head: the Super_T/Luna label, then (later) the model badge on the same line. */
.chat-msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) 6px;
  margin-bottom: 3px;
}
.chat-msg-head .label {
  margin-bottom: 0;
}
.chat-extras:empty {
  display: none;
}
/* DUI-35: everything under an answer (action card, chips, model line, evidence, warning) shares one left edge and
   one vertical rhythm. */
.chat-extras {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.chat-msg .chat-extras > * {
  margin: 0;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 1.2em;
  vertical-align: middle;
}
/* Owner fix 09-26 (~10:00): almost no gap sat between "…N วิ" and the dots in the live thinking
   header (desk-thinking.js appends typingDots() straight after a text node) — add one here, scoped
   to that caller, since the bubble-reveal caller (desk-chat-bubble.js) replaces the text outright
   with just the dots and must keep no extra leading space. */
.chat-think-title .typing-dots {
  margin-left: var(--sp-2);
}
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: stDot 1.1s ease-in-out infinite;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes stDot {
  0%,
  70%,
  100% {
    opacity: 0.3;
    transform: none;
  }
  35% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* A reply being typed out: clickable to skip (the pointer says so), text fades in word by word. */
.chat-msg.is-typing,
.chat-msg.is-revealing {
  cursor: pointer;
}
.chat-msg.is-typing .chat-text {
  min-height: 1.6em;
}
@media (prefers-reduced-motion: reduce) {
  .typing-dots span {
    animation: none;
    opacity: 0.6;
  }
}
/* #endregion */

/* #region zone:desk.style.reply-chips — ชิปสัญญาณใต้คำตอบ (ค่าเดียวกับการ์ดแผน) */
/* Under a reply about a stock: ticker · เข้าแผน/รอ (the shared .sig-chip) · เข้า · SL · TP · TP2, as
   quiet hairline pills; numbers in the same mono as the plan card. */
.reply-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  white-space: normal;
}
.reply-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 24px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--u-radius-pill);
  background: var(--panel);
  font-size: var(--u-text-xs);
  line-height: 22px;
  white-space: nowrap;
}
.reply-chip-label {
  color: var(--muted);
  font-weight: 600;
}
.reply-chip-value {
  font-weight: 600;
  color: var(--text);
}
.reply-chip-ticker {
  font-weight: 700;
  color: var(--text);
  background: transparent;
}
.reply-chips .sig-chip {
  height: 24px;
  line-height: 22px;
}
/* #endregion */

/* #region zone:desk.style.model — ปุ่มสลับโมเดล OpenAI/Claude และป้ายโมเดลที่ตอบ */
/* Mark tints (--claude-fg/--claude-soft/--claude-line, both themes) moved to desk-tokens.css
   (2026-09-26, batch J) — one home per concept. */

/* Owner 2026-09-25 "ปรับปุ่ม claude gpt ให้เล็กลง" / "หุบตัวปุ่ม toggle ให้เล็กลง": two 14px marks in a
   28px-tall segmented control at the right end of the composer bar (the context chip and the token
   pill on its left); the names live in the tooltip/aria-label. */
.model-switch {
  display: inline-flex;
  gap: 1px;
  padding: 1px;
  flex-shrink: 0;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--u-radius-pill);
}
.usage-pill[hidden] + .model-switch {
  margin-left: auto;
}

.model-opt:not(.active):hover {
  background: var(--hover);
  color: var(--text);
}

.model-mark {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.model-opt[data-provider='claude'] .model-mark {
  color: var(--claude-fg);
}
/* The hint stays on one line (ellipsis) instead of growing the empty box to two lines
   (field-sizing sizes it by the placeholder). */
.chat-form textarea::placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* "Answered by" badge beside the bubble label. */
.reply-badge {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 7px;
  border-radius: var(--u-radius-pill);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: var(--u-text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.reply-badge.tone-claude {
  color: var(--claude-fg);
  background: var(--claude-soft);
  border-color: var(--claude-line);
}
.reply-badge.tone-fallback {
  color: var(--sig-wait-fg);
  background: var(--sig-wait-bg);
  border-color: var(--sig-wait-line);
}
/* #endregion */

/* #region zone:desk.style.think — กล่อง "กำลังคิด" แบบ Claude Code ระหว่างรอคำตอบ */
/* desk-thinking.js: a quiet block above the reply — a turning spark + "กำลังคิด… 12 วิ", then the real
   stage lines and the model's streamed thought text (muted, smaller, italic), ~6 lines visible with the
   older ones fading out at the top. Collapsed to "คิดอยู่ 12 วิ · ดูที่คิด" once the answer is in. */
.chat-think {
  align-self: flex-start;
  max-width: 88%;
  min-width: 0;
  color: var(--muted);
  font-size: var(--u-text-xs);
  animation: stIn 0.18s ease-out;
}
.chat-think-head {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 2px 9px 2px var(--sp-1);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  text-align: left;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}
.chat-think-head:disabled {
  opacity: 1;
  cursor: default;
}
.chat-think:not(.is-live) .chat-think-head:hover {
  background: var(--hover);
  color: var(--text);
}
.chat-think-glyph {
  position: relative;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.chat-think-glyph i {
  --turn: 0deg;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4.5px;
  height: 4.5px;
  margin: -2.25px 0 0 -2.25px;
  border-radius: 50%;
  background: var(--accent);
  transform: rotate(var(--turn)) translateY(-4.5px);
}
.chat-think-glyph i:nth-child(2) {
  --turn: 120deg;
  background: color-mix(in srgb, var(--accent) 72%, var(--text));
}
.chat-think-glyph i:nth-child(3) {
  --turn: 240deg;
  opacity: 0.7;
}
.chat-think:not(.is-live) .chat-think-glyph {
  display: none;
}
.chat-think-title {
  font-variant-numeric: tabular-nums;
}
.chat-think.is-live .chat-think-glyph i {
  animation: stThinkDots 1.6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.chat-think.is-live .chat-think-title {
  background: linear-gradient(
    90deg,
    var(--muted) 0%,
    var(--muted) 35%,
    var(--text) 50%,
    var(--muted) 65%,
    var(--muted) 100%
  );
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: stThinkShine 2.2s linear infinite;
}
.chat-think-more {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent-text);
  font-weight: 600;
}
.chat-think-more::before {
  content: '·';
  color: var(--faint);
  margin-right: 3px;
}
.chat-think-more::after {
  content: '›';
  font-size: 14px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.chat-think.is-open .chat-think-more::after {
  transform: rotate(90deg);
}
.chat-think-body {
  margin: 2px 0 0 10px;
  padding: 1px 0 1px var(--sp-3);
  border-left: 2px solid var(--line);
  max-height: calc(11.5px * 1.6 * 6);
  overflow: hidden;
  font-size: var(--u-text-xs);
  line-height: 1.6;
}
.chat-think-body.is-clipped {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 2.2em);
  mask-image: linear-gradient(to bottom, transparent 0, #000 2.2em);
}
.chat-think.is-open .chat-think-body {
  max-height: min(46vh, 360px);
  overflow: auto;
  -webkit-mask-image: none;
  mask-image: none;
}
.chat-think-step {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.chat-think.is-live .chat-think-step:last-child {
  color: var(--text);
}
.chat-think-caption {
  display: none;
  margin: 1px 0 0 var(--sp-6);
  font-size: var(--u-text-xs);
  color: var(--faint);
  letter-spacing: 0.01em;
}
.chat-think.has-thought.is-live .chat-think-caption,
.chat-think.has-thought.is-open .chat-think-caption {
  display: block;
}
.chat-think-text {
  margin: 2px 0 var(--sp-1);
  font-style: italic;
  color: var(--faint);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* #region zone:desk.style.think.trace — ขั้นตอนพร้อมตารางข้อมูลที่ย่อได้ในทุกความกว้าง */
.chat-think.has-trace {
  width: 100%;
  max-width: 100%;
}
.has-trace .chat-think-head {
  flex-wrap: wrap;
  max-width: 100%;
  min-height: var(--tap-min);
  column-gap: var(--sp-2);
}
.has-trace .chat-think-body {
  max-height: min(56vh, 500px);
  overflow: auto;
  mask-image: none;
  -webkit-mask-image: none;
  margin-left: var(--sp-1);
  padding-left: var(--sp-2);
}
.has-trace .chat-think-caption {
  display: none;
}
.chat-trace-summary {
  margin: 0 0 var(--sp-2);
  color: var(--muted);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.chat-trace-step {
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-1);
}
.chat-trace-step.has-rag {
  margin-top: var(--sp-2);
}
.chat-trace-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap-min);
  padding: var(--sp-1);
  cursor: pointer;
  list-style: none;
}
.chat-trace-head::-webkit-details-marker {
  display: none;
}
.chat-trace-head .ui-icon {
  flex-shrink: 0;
}
.chat-trace-title {
  flex: 1;
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}
.chat-trace-duration {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chat-trace-status {
  color: var(--muted);
  white-space: nowrap;
}
.chat-trace-step.is-fail .chat-trace-status,
.chat-trace-warning {
  color: var(--amber);
}
.chat-trace-facts {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.chat-trace-facts th,
.chat-trace-facts td {
  width: 50%;
  padding: var(--sp-1) var(--sp-2);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  border-top: 1px solid var(--line);
}
.chat-trace-facts th {
  color: var(--muted);
  font-weight: 500;
}
.chat-trace-label,
.chat-trace-value {
  display: block;
}
.chat-trace-value {
  color: var(--text);
}
.chat-trace-provenance,
.chat-trace-empty {
  color: var(--muted);
}
.chat-trace-thought summary {
  min-height: var(--tap-min);
  align-content: center;
  cursor: pointer;
}
.chat-trace-warning {
  display: inline-block;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}
/* #endregion */
@keyframes stThinkDots {
  0%,
  100% {
    transform: rotate(var(--turn)) translateY(-4.5px) scale(1);
  }
  30% {
    transform: rotate(calc(var(--turn) + 100deg)) translateY(-5.5px) scale(0.8);
  }
  55% {
    transform: rotate(calc(var(--turn) + 200deg)) translateY(-0.5px) scale(1.2);
  }
  78% {
    transform: rotate(calc(var(--turn) + 290deg)) translateY(-6px) scale(0.85);
  }
}
@keyframes stThinkShine {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -150% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-think {
    animation: none;
  }
  .chat-think.is-live .chat-think-glyph i {
    animation: none;
  }
  .chat-think.is-live .chat-think-title {
    animation: none;
    background: none;
    color: var(--muted);
  }
  .chat-think-more::after {
    transition: none;
  }
}
/* #endregion */

/* #region zone:desk.style.clear — ปุ่มล้างแชทที่หัวการ์ดแชท */
.chat-clear-btn {
  align-self: center;
  margin: -4px -6px -4px 0;
}
.chat-clear-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.chat-clear-btn:disabled:hover {
  background: transparent;
  color: var(--muted);
}
@media (pointer: coarse) {
  .chat-clear-btn {
    width: 36px;
    height: 36px;
  }
}
/* #endregion */

/* #region zone:desk.style.chat.lists — รายการหัวข้อย่อยในคำตอบแชท (- / 1.) เป็นลิสต์จริง */
/* Polish 2026-10-13: desk-chat-links.js turns "- item" and "1. item" runs into real <ul>/<ol>; the bubble keeps its
   pre-wrap line breaks for paragraphs, the list items wrap normally under a hanging marker. */
.chat-text .chat-list {
  margin: var(--sp-1) 0;
  padding-left: 1.4em;
  white-space: normal;
}
.chat-text .chat-list li + li {
  margin-top: 2px;
}
.chat-text .chat-list li::marker {
  color: var(--muted);
}
.chat-text .chat-para + .chat-para,
.chat-text .chat-list + .chat-para,
.chat-text .chat-para + .chat-list {
  margin-top: var(--sp-2);
}
/* #endregion */
