/* ==========================================================================
   TMJ AI Kernel — progressive code/story blocks (desktop + mobile)
   ========================================================================== */

.tmj-ai-host,
.tmj-ai-reply {
  display: block;
  width: 100%;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.tmj-ai-p {
  margin: 0 0 0.55em;
  line-height: 1.45;
}
.tmj-ai-p:last-child {
  margin-bottom: 0;
}

.tmj-ai-inline {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(0, 255, 120, 0.18);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: #9dffc4;
}

/* ---- Live code card (open while streaming) ---- */
.tmj-ai-code {
  margin: 0.65em 0 0.85em;
  border: 1px solid rgba(0, 180, 90, 0.4);
  border-radius: 8px;
  overflow: hidden;
  background: #0b0f0c;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.tmj-ai-code.is-open {
  border-color: rgba(0, 255, 140, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 255, 120, 0.12), 0 4px 18px rgba(0, 0, 0, 0.4);
}
.tmj-ai-code__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #141a16, #0e1210);
  border-bottom: 1px solid rgba(0, 180, 90, 0.22);
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
}
.tmj-ai-code__lang {
  color: #6a9a7a;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  flex: 1;
}
.tmj-ai-code__state {
  color: #88eeb0;
  opacity: 0.85;
  font-size: 0.68rem;
}
.tmj-ai-code.is-open .tmj-ai-code__state {
  animation: tmj-ai-pulse 1.2s ease-in-out infinite;
}
.tmj-ai-code__copy {
  background: transparent;
  border: 1px solid rgba(0, 200, 100, 0.35);
  color: #88eeb0;
  border-radius: 4px;
  padding: 2px 8px;
  font: inherit;
  cursor: pointer;
}
.tmj-ai-code__copy:hover {
  background: rgba(0, 255, 120, 0.08);
}

.tmj-ai-code__pre,
.tmj-ai-code__pre.ace_editor {
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow: auto;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  background: #080b09 !important;
  color: #d4f5e0;
}
.tmj-ai-code__pre > code,
.tmj-ai-code__body {
  display: block;
  padding: 12px 14px;
  white-space: pre;
  tab-size: 2;
  min-height: 1.2em;
}

/* Ace static highlight inside code body */
.tmj-ai-code__body.ace_static_holder,
.tmj-ai-code__body .ace_static_highlight {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
}
.tmj-ai-code__body .ace_line {
  line-height: 1.45;
}

/* Streaming caret on reply */
.tmj-ai-reply.has-caret::after {
  content: '';
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: #00ff66;
  animation: tmj-ai-blink 0.8s infinite steps(2);
}

.tmj-ai-story.is-open {
  outline: 1px dashed rgba(0, 255, 140, 0.35);
}

@keyframes tmj-ai-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
@keyframes tmj-ai-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* ------------------------------------------------------------------
   Mobile: kernel is LOGIC only — keep existing mobile stage/bubble look.
   Tokens come from mobile app.css (--m-*). Do not force desktop neon chrome.
   ------------------------------------------------------------------ */
.m-ai-status.is-cold {
  color: #e0a06a;
}
.m-ai-status.is-cold .m-ai-dot {
  background: #e0a06a;
  box-shadow: 0 0 8px rgba(224, 160, 106, 0.55);
  animation: none;
}
.m-ai-status.is-online {
  color: var(--m-green-bright, #88ffaa);
}
.m-ai-status.is-online .m-ai-dot {
  background: var(--m-green-bright, #81b64c);
  box-shadow: 0 0 8px var(--m-green-bright, #81b64c);
}

/* Text host sits inside .m-ai-bubble — inherit bubble typography/colors */
.m-ai-bubble .m-ai-text.tmj-ai-host,
.m-ai-bubble .tmj-ai-reply {
  color: inherit;
  font-size: inherit;
  line-height: 1.45;
}

.m-ai-bubble .tmj-ai-p {
  margin: 0 0 0.45em;
  color: inherit;
}

.m-ai-bubble .tmj-ai-inline {
  background: rgba(0, 0, 0, 0.28);
  border-color: var(--m-border, rgba(129, 182, 76, 0.25));
  color: var(--m-green-bright, #c8f0a8);
}

/* Code cards: same card language as mobile bubbles, not desktop terminal slab */
.m-ai-bubble .tmj-ai-code {
  margin: 0.5em 0 0.35em;
  border: 1px solid var(--m-border, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: none;
  font-size: 0.78rem;
}
.m-ai-bubble .tmj-ai-code.is-open {
  border-color: var(--m-green-dim, rgba(129, 182, 76, 0.45));
  box-shadow: none;
}
.m-ai-bubble .tmj-ai-code__bar {
  background: rgba(0, 0, 0, 0.22);
  border-bottom-color: var(--m-border, rgba(255, 255, 255, 0.08));
  font-size: 0.65rem;
}
.m-ai-bubble .tmj-ai-code__lang {
  color: var(--m-muted, #9aaa90);
}
.m-ai-bubble .tmj-ai-code__state {
  color: var(--m-green-bright, #81b64c);
}
.m-ai-bubble .tmj-ai-code__copy {
  border-color: var(--m-border, rgba(255, 255, 255, 0.15));
  color: var(--m-green-bright, #81b64c);
  border-radius: 6px;
  padding: 3px 8px;
}
.m-ai-bubble .tmj-ai-code__pre,
.m-ai-bubble .tmj-ai-code__pre.ace_editor {
  max-height: 280px;
  background: rgba(0, 0, 0, 0.2) !important;
  color: var(--m-text, #e8f0e4);
  font-size: 0.75rem;
}
.m-ai-bubble .tmj-ai-code__pre > code,
.m-ai-bubble .tmj-ai-code__body {
  padding: 10px 12px;
}

/* Soft caret — matches mobile green, not desktop terminal block */
.m-ai-bubble .tmj-ai-reply.has-caret::after {
  background: var(--m-green-bright, #81b64c);
  border-radius: 1px;
}

/* Story open state — subtle, mobile */
.m-ai-bubble .tmj-ai-story.is-open {
  outline: 1px dashed var(--m-green-dim, rgba(129, 182, 76, 0.4));
  border-radius: 10px;
}
