/* public/live-console.css — v0.37.0
 *
 * Live thinking, rebuilt as a structured conversation.
 *
 * Operator report, 2026-08-10:
 *   "Run section live thinking I am still not happy, its not user friendly,
 *    too much gaps as well in the lines which spreads too much and not user
 *    friendly to read. it should be like a chat box of Claude or any other AI
 *    app … user can easily see in short whats happening and able to expand
 *    the thinking … and it should pop up any inputs needed by claude or
 *    approval etc. I want it to be market ready this time."
 *
 * What changed:
 *   * The <pre> wall of `white-space: pre-wrap` text is gone. Lines are now
 *     grouped into collapsed cards — one line each until you open them — so
 *     a 400-line run reads as ~15 skimmable steps.
 *   * Line-height dropped 1.7 → 1.45 and the 24/28px padding tightened.
 *     That was the "too much gaps / spreads too much" complaint.
 *   * Approvals and questions render as pinned cards inside the stream
 *     instead of a banner somewhere else on the page.
 *
 * Loaded after the inline <style> in index.html, so equal-specificity rules
 * here win without !important.
 */

/* ── Stream container ─────────────────────────────────────────────────────
   Overrides the old <pre> block. The element is a <div> now, but the id
   selectors are kept identical so nothing else has to change. */
#live-thinking-content.lt-stream {
  margin: 0;
  padding: 10px 16px 16px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #0f172a;
  background: #fff;
  max-height: 62vh;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  scroll-behavior: smooth;
  position: relative;
}

/* Toolbar: expand/collapse everything + kind filters. Sticky so it stays
   reachable during a long run. */
.ltc-tools {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 -16px 10px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #f1f5f9;
}
.ltc-tool {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
}
.ltc-tool:hover { border-color: #cbd5e1; color: #334155; }
.ltc-tool.is-on { background: #f5f1ff; border-color: #c4b5fd; color: #6d28d9; }
.ltc-tools .ltc-sp { flex: 1; }

/* ── Cards ────────────────────────────────────────────────────────────── */

.ltc {
  border: 1px solid #eceff4;
  border-left: 3px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  margin: 0 0 6px;
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.ltc:hover { border-color: #dfe4ec; }

.ltc-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  user-select: none;
  min-height: 20px;
}
.ltc-head:focus-visible { outline: 2px solid #a78bfa; outline-offset: -2px; }
.ltc.no-body > .ltc-head { cursor: default; }

.ltc-ico {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 5px;
  line-height: 1;
}

.ltc-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: #1e293b;
  /* One line when collapsed — this is what makes a long run skimmable. */
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ltc.is-open > .ltc-head .ltc-title { -webkit-line-clamp: 3; }

.ltc-meta {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 1px 7px;
  margin-top: 1px;
}
.ltc-chev {
  flex: none;
  color: #b6bfcc;
  font-size: 10px;
  margin-top: 3px;
  transition: transform 140ms ease;
}
.ltc.is-open > .ltc-head .ltc-chev { transform: rotate(90deg); }
.ltc.no-body .ltc-chev { visibility: hidden; }

.ltc-body {
  display: none;
  padding: 2px 10px 9px 34px;
  border-top: 1px dashed #f1f5f9;
  margin-top: -1px;
}
.ltc.is-open > .ltc-body { display: block; }

.ltc-ln {
  font-size: 13px;
  line-height: 1.5;
  color: #475569;
  padding: 2px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ltc-ln + .ltc-ln { border-top: 1px solid #f8fafc; }

/* Per-kind accents. Deliberately low-saturation: the operator reads this for
   minutes at a time, and the only thing that should shout is an error. */
.ltc-action  { border-left-color: #60a5fa; }
.ltc-action  .ltc-ico { background: #e0efff; color: #1d4ed8; }
.ltc-result  { border-left-color: #34d399; }
.ltc-result  .ltc-ico { background: #dcfce7; color: #047857; }
.ltc-result  .ltc-title { color: #065f46; font-weight: 550; }
.ltc-think   { border-left-color: #c4b5fd; background: #fdfcff; }
.ltc-think   .ltc-ico { background: #ede9fe; color: #6d28d9; }
.ltc-think   .ltc-title { color: #64748b; font-style: italic; }
.ltc-think   .ltc-ln { color: #6b7280; font-style: italic; }
.ltc-error   { border-left-color: #f87171; background: #fffbfb; }
.ltc-error   .ltc-ico { background: #fee2e2; color: #b91c1c; }
.ltc-error   .ltc-title { color: #b91c1c; font-weight: 600; }
.ltc-error   .ltc-ln { color: #991b1b; }

/* System notes read as quiet dividers, not as steps. */
.ltc-system {
  border: 0;
  background: none;
  margin: 8px 0 6px;
  text-align: center;
}
.ltc-system .ltc-head { justify-content: center; padding: 0; cursor: default; }
.ltc-system .ltc-ico { display: none; }
.ltc-system .ltc-chev { display: none; }
.ltc-system .ltc-title {
  flex: 0 1 auto;
  font-size: 11.5px;
  color: #94a3b8;
  background: #f5f7fa;
  border-radius: 999px;
  padding: 2px 12px;
  -webkit-line-clamp: 2;
}

/* Freshly arrived card gets a one-shot tint so the eye finds it. */
@keyframes ltc-fresh {
  from { background: #f6f2ff; }
  to   { background: transparent; }
}
.ltc-fresh { animation: ltc-fresh 900ms ease-out; }

/* Filter state driven by the toolbar chips */
.lt-stream.f-action .ltc:not(.ltc-action):not(.ltc-ask),
.lt-stream.f-result .ltc:not(.ltc-result):not(.ltc-ask),
.lt-stream.f-think  .ltc:not(.ltc-think):not(.ltc-ask),
.lt-stream.f-error  .ltc:not(.ltc-error):not(.ltc-ask) { display: none; }

/* ── User messages ────────────────────────────────────────────────────── */

.ltc-user {
  border: 0;
  border-left: 0;
  background: none;
  display: flex;
  justify-content: flex-end;
  margin: 10px 0 8px;
}
.ltc-user-bubble {
  max-width: 82%;
  background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 8px 13px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 6px -2px rgba(124, 58, 237, .4);
}
.ltc-user-state {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  opacity: .8;
  text-align: right;
}

/* ── Ask / approval cards ─────────────────────────────────────────────── */

.ltc-ask {
  border: 1px solid #fcd34d;
  border-left: 3px solid #f59e0b;
  background: linear-gradient(180deg, #fffdf5 0%, #fffbeb 100%);
  border-radius: 12px;
  margin: 10px 0;
  box-shadow: 0 2px 10px -4px rgba(245, 158, 11, .45);
  animation: ltc-ask-in 220ms ease-out;
}
.ltc-ask.is-approval {
  border-color: #fca5a5;
  border-left-color: #ef4444;
  background: linear-gradient(180deg, #fffbfb 0%, #fef2f2 100%);
  box-shadow: 0 2px 10px -4px rgba(239, 68, 68, .4);
}
@keyframes ltc-ask-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.ltc-ask-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #b45309;
}
.ltc-ask.is-approval .ltc-ask-head { color: #b91c1c; }
.ltc-ask-head .ltc-pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: ltc-pulse 1.5s infinite;
}
@keyframes ltc-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(1.35); }
}

.ltc-ask-q {
  padding: 0 14px 10px;
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ltc-ask-sub {
  padding: 0 14px 10px;
  font-size: 12px;
  color: #78716c;
}
.ltc-ask-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 14px 12px;
}
.ltc-ask-actions textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 60px;
  padding: 8px 11px;
  border: 1px solid #e7d9b5;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  background: #fff;
  outline: none;
  resize: vertical;
}
.ltc-ask-actions textarea:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
}
.ltc-btn {
  padding: 7px 16px;
  border: 0;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 120ms ease;
}
.ltc-btn:hover:not(:disabled) { filter: brightness(1.07); }
.ltc-btn:disabled { opacity: .55; cursor: not-allowed; }
.ltc-btn-approve { background: #059669; color: #fff; }
.ltc-btn-reject  { background: #fff; color: #b91c1c; border: 1px solid #fca5a5; }
.ltc-btn-send    { background: #7c3aed; color: #fff; }
.ltc-ask-note { font-size: 12px; color: #92400e; }

/* ── Jump-to-latest ───────────────────────────────────────────────────── */

#lt-jump {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 5;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  color: #6d28d9;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px -4px rgba(15, 23, 42, .25);
}
#lt-jump.is-on { display: inline-flex; }
#lt-jump:hover { background: #f5f1ff; }

/* ── Empty / idle state ───────────────────────────────────────────────── */

.ltc-idle {
  padding: 34px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.6;
}
.ltc-idle strong { display: block; color: #64748b; font-size: 14px; margin-bottom: 4px; }

/* ── Stage bar: make it sticky and tighter ────────────────────────────── */
#live-thinking-stages {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(6px);
}

/* Legacy classes kept alive so any cached copy of live-thinking.js that
   still emits <span class="lt-line"> degrades to readable text instead of
   an unstyled run-on. */
.lt-stream .lt-line { display: block; padding: 2px 0; font-size: 13.5px; }
.lt-stream .lt-think-group { margin: 4px 0; }

@media (max-width: 720px) {
  #live-thinking-content.lt-stream { padding: 8px 10px 12px; font-size: 13.5px; }
  .ltc-body { padding-left: 20px; }
  .ltc-user-bubble { max-width: 92%; }
}
