/* =====================================================================
   STF Studio Hub — LLM Agent chat page
   Full-height chat that fills .tb-content. Messages scroll; input fixed.
   ===================================================================== */
.llm-root {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg-1); overflow: hidden;
}

/* ---- header ---- */
.llm-head {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px 14px 28px;
  border-bottom: 1px solid var(--border-1); flex: none;
  background: color-mix(in srgb, var(--bg-1) 90%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
}
.llm-head-id { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.llm-head-ava { position: relative; flex: none; width: 34px; height: 34px; }
.llm-head-ava img {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: block;
  border: 1px solid var(--border-1);
}
.llm-head-status {
  position: absolute; right: -1px; bottom: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--stf-success); border: 2px solid var(--bg-1);
}
.llm-head-ava.thinking .llm-head-status { background: var(--stf-amber); animation: llm-pulse 1.1s ease-in-out infinite; }
.llm-head-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.llm-head-name { font-size: 14px; font-weight: 600; color: var(--fg-1); letter-spacing: -0.01em; }
.llm-head-sub { font-size: 11px; color: var(--fg-4); letter-spacing: 0.04em; font-family: var(--font-mono); }
.llm-clear {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 12px; font-weight: 500; color: var(--fg-3);
  border: 1px solid var(--border-1); background: var(--bg-1); border-radius: var(--radius-pill);
  padding: 5px 14px; cursor: pointer; transition: all var(--dur-fast) var(--ease-stf);
}
.llm-clear:hover { color: var(--fg-1); border-color: var(--fg-3); }
.llm-clear svg { width: 13px; height: 13px; }
.llm-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.llm-close { padding: 5px 9px; }
.llm-close svg { width: 14px; height: 14px; }

/* ---- floating launcher (bottom-right circle) ---- */
.stf-stef-launcher {
  position: fixed; right: 24px; bottom: 22px; z-index: 110;
  width: 48px; height: 48px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-1); background: var(--bg-2); cursor: pointer;
  display: grid; place-items: center; overflow: visible;
  box-shadow: var(--shadow-md);
  transition: transform 120ms var(--ease-stf), box-shadow var(--dur-fast) var(--ease-stf), border-color var(--dur-fast) var(--ease-stf);
}
.stf-stef-launcher img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.stf-stef-launcher:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); border-color: var(--fg-3); }
.stf-stef-launcher-dot {
  position: absolute; right: 1px; bottom: 1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--stf-success); border: 2px solid var(--bg-2);
}

/* ---- docked window (bottom-right) ---- */
.stf-stef-dock {
  position: fixed; right: 24px; bottom: 22px; z-index: 120;
  width: 396px; max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 44px));
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-overlay);
  animation: stf-stef-rise 0.24s var(--ease-stf) both;
}
.stf-stef-dock .llm-root { border-radius: inherit; }
.stf-stef-dock .llm-head { padding: 12px 16px; }
.stf-stef-dock .llm-msg,
.stf-stef-dock .llm-bar { padding-left: 16px; padding-right: 16px; }
.stf-stef-dock .llm-bubble { max-width: 88%; }
@keyframes stf-stef-rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 520px) {
  .stf-stef-dock { right: 12px; left: 12px; width: auto; bottom: 12px; height: min(72vh, 560px); }
  .stf-stef-launcher { right: 16px; bottom: 16px; }
}

/* ---- thread (scrolling) ---- */
.llm-thread {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 28px 0 20px;
  display: flex; flex-direction: column; gap: 2px;
}

/* welcome / empty state */
.llm-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; flex: 1; padding: 40px 28px; text-align: center; color: var(--fg-3);
}
.llm-welcome-mark {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border-1); background: var(--bg-2); overflow: hidden;
}
.llm-welcome-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.llm-welcome h2 { font-family: var(--font-display); font-weight: 300; font-size: 26px; letter-spacing: -0.02em; color: var(--fg-1); margin: 0; }
.llm-welcome p { font-size: 13.5px; line-height: 1.6; max-width: 44ch; margin: 0; }
.llm-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.llm-chip {
  font-size: 12px; font-weight: 500; color: var(--fg-2); padding: 7px 15px;
  border: 1px solid var(--border-1); border-radius: var(--radius-pill); background: var(--bg-2);
  cursor: pointer; transition: all var(--dur-fast) var(--ease-stf); white-space: nowrap;
}
.llm-chip:hover { border-color: var(--stf-blueprint); color: var(--stf-blueprint); background: var(--stf-blueprint-faint); }

/* message rows */
.llm-msg {
  display: flex; flex-direction: column; gap: 5px; padding: 6px 28px;
  animation: llm-rise 0.2s var(--ease-stf) both;
}
.llm-msg.user { align-items: flex-end; }
.llm-msg.assistant { align-items: flex-start; }

.llm-msg-who {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-4);
  font-family: var(--font-mono); padding: 0 4px;
}

.llm-bubble {
  max-width: min(640px, 76%); padding: 13px 16px;
  font-size: 13.5px; line-height: 1.65; color: var(--fg-1);
  border-radius: var(--radius-lg); border: 1px solid var(--border-1);
  white-space: pre-wrap; word-break: break-word; text-wrap: pretty;
}
.llm-msg.user .llm-bubble {
  background: color-mix(in srgb, var(--stf-blueprint) 10%, var(--bg-2));
  border-color: color-mix(in srgb, var(--stf-blueprint) 28%, var(--border-1));
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-xs) var(--radius-lg);
}
.llm-msg.assistant .llm-bubble {
  background: var(--bg-2);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-xs);
}

/* inline code */
.llm-bubble code {
  font-family: var(--font-mono); font-size: 12.5px; padding: 1px 5px;
  background: var(--bg-3); border-radius: 4px; color: var(--stf-blueprint);
}

/* code block */
.llm-code {
  background: var(--bg-3); border: 1px solid var(--border-1); border-radius: var(--radius-md);
  margin: 8px 0; overflow: hidden;
}
.llm-code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; border-bottom: 1px solid var(--border-1);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--fg-4);
}
.llm-code pre {
  margin: 0; padding: 12px 14px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--fg-1);
  overflow-x: auto; white-space: pre;
}
.llm-code-copy {
  background: none; border: none; cursor: pointer; color: var(--fg-4); padding: 2px 6px;
  border-radius: var(--radius-sm); font-size: 11px; font-family: var(--font-mono);
  display: inline-flex; align-items: center; gap: 5px;
  transition: color var(--dur-fast) var(--ease-stf);
}
.llm-code-copy:hover { color: var(--fg-1); }

/* thinking animation */
.llm-thinking {
  display: flex; align-items: center; gap: 5px; padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--border-1);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-xs);
  max-width: 80px;
}
.llm-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--fg-3);
  animation: llm-bounce 1.2s ease-in-out infinite;
}
.llm-dot:nth-child(2) { animation-delay: 0.16s; }
.llm-dot:nth-child(3) { animation-delay: 0.32s; }

/* ---- input bar ---- */
.llm-bar {
  flex: none; padding: 14px 28px 20px;
  border-top: 1px solid var(--border-1); background: var(--bg-1);
}
.llm-bar-inner {
  display: flex; align-items: flex-end; gap: 10px;
  border: 1px solid var(--border-1); border-radius: var(--radius-lg);
  background: var(--bg-2); padding: 10px 12px 10px 16px;
  transition: border-color var(--dur-fast) var(--ease-stf), box-shadow var(--dur-fast) var(--ease-stf);
}
.llm-bar-inner:focus-within {
  border-color: var(--stf-blueprint);
  box-shadow: 0 0 0 3px var(--stf-blueprint-faint);
}
.llm-textarea {
  flex: 1; min-width: 0; resize: none; border: none; background: transparent; outline: none;
  font: inherit; font-size: 13.5px; color: var(--fg-1); line-height: 1.5;
  max-height: 160px; overflow-y: auto;
}
.llm-textarea::-webkit-resizer { display: none; }
.llm-textarea::-webkit-inner-spin-button, .llm-textarea::-webkit-outer-spin-button { display: none; margin: 0; }
.llm-textarea::placeholder { color: var(--fg-4); }
.llm-send {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: var(--radius-md);
  border: none; background: var(--fg-1); color: var(--bg-1); cursor: pointer;
  transition: background var(--dur-fast) var(--ease-stf), opacity var(--dur-fast) var(--ease-stf), transform 120ms var(--ease-stf);
}
.llm-send:hover:not(:disabled) { background: color-mix(in srgb, var(--fg-1) 88%, transparent); transform: scale(1.04); }
.llm-send:disabled { opacity: 0.35; cursor: default; }
.llm-send svg { width: 16px; height: 16px; }
.llm-bar-hint { font-size: 10.5px; color: var(--fg-4); margin-top: 8px; text-align: center; letter-spacing: 0.02em; }

/* ---- keyframes ---- */
@keyframes llm-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }
@keyframes llm-pulse { 0%,100%{opacity:1} 50%{opacity:0.45} }
@keyframes llm-rise { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
