/* Palco v2 — timeline viva única (chat + surfaces num fluxo só). Distinto de living.css. */

.palco-body { margin: 0; overflow: hidden; }

.palco {
  display: flex; flex-direction: column; height: 100vh;
  background:
    radial-gradient(80% 50% at 50% -10%, rgba(123,97,255,0.10), transparent 60%),
    var(--color-bg, #06060f);
}

/* ---- Header ---- */
.palco__top {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.palco__brand { font-weight: 700; letter-spacing: .5px; color: var(--color-accent, #00D4FF); }
.palco__newf { margin-left: auto; }
.palco__new {
  background: rgba(0,229,255,.12); color: var(--color-accent, #00D4FF);
  border: 1px solid rgba(0,229,255,.3); border-radius: 999px;
  padding: 5px 13px; font-size: 12px; cursor: pointer; transition: background .2s ease;
}
.palco__new:hover { background: rgba(0,229,255,.22); }
.palco__exit { margin-left: 14px; color: #6a6a80; font-size: 13px; text-decoration: none; }
.palco__exit:hover { color: #9a9ab0; }

/* ---- Timeline ---- */
.timeline {
  flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth;
  display: flex; flex-direction: column; gap: 16px;
  padding: 24px 16px 32px;
}
.timeline > .block { width: 100%; max-width: 820px; margin: 0 auto; }

/* Entrada de todo bloco */
.block { animation: block-in .42s cubic-bezier(.2,.7,.2,1); }
@keyframes block-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Saída animada (apagar suave) — adicionada via JS antes do Turbo remover */
.block.is-leaving {
  overflow: hidden; pointer-events: none;
  animation: block-out .4s forwards cubic-bezier(.4,0,.6,1);
}
@keyframes block-out {
  to { opacity: 0; transform: translateX(-16px) scale(.97); max-height: 0; margin: 0; }
}

/* ---- Mensagens ---- */
.block--msg { display: flex; }
.block--user { justify-content: flex-end; }
.block--assistant { justify-content: flex-start; }
.bubble {
  max-width: 80%; padding: 11px 15px; border-radius: 16px; font-size: 15px; line-height: 1.55;
  word-wrap: break-word;
}
.block--user .bubble { background: var(--color-purple, #7B61FF); color: #fff; border-bottom-right-radius: 5px; }
.block--assistant .bubble { background: var(--color-bg-elevated, #141424); color: #e7e7f0; border-bottom-left-radius: 5px; }
.bubble p { margin: 0 0 7px; } .bubble p:last-child { margin: 0; }

/* ---- Construção viva (semente → quadro → chips) ---- */
.builder { display: flex; }
.builder__frame {
  min-width: 220px; padding: 14px 16px; border-radius: 16px;
  background: rgba(20,20,40,0.6); border: 1px solid rgba(0,229,255,0.25);
  box-shadow: 0 0 30px rgba(0,229,255,0.08);
  transform-origin: left center; animation: bloom .55s cubic-bezier(.2,.8,.2,1);
}
@keyframes bloom {
  0%   { transform: scale(.25); border-radius: 50%; opacity: 0; }
  55%  { border-radius: 40%; opacity: 1; }
  100% { transform: scale(1); border-radius: 16px; }
}
.builder__head { display: flex; align-items: center; gap: 9px; color: #cfcfe6; font-size: 13.5px; }
.builder__orb {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #7BFFD4, #00E5FF 60%, #B47EFF);
  box-shadow: 0 0 14px rgba(0,229,255,.7); animation: orb-pulse 1.4s ease-in-out infinite;
}
@keyframes orb-pulse { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.25); opacity: 1; } }
.builder__title { text-transform: lowercase; letter-spacing: .3px; }

.build-steps { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.build-steps:empty { margin-top: 0; }
.build-step {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: #9a9ab0;
  animation: chip-in .35s cubic-bezier(.2,.7,.2,1);
}
@keyframes chip-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.build-step__icon { font-size: 14px; }

/* ---- Card de surface (inline) ---- */
.surface-card {
  border: 1px solid rgba(123,97,255,0.22); border-radius: 16px; overflow: hidden;
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(123,97,255,0.06), transparent 60%),
    var(--color-bg-card, #0d0d1a);
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.surface-card__bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.surface-card__title { font-weight: 600; color: #e7e7f0; }
.surface-card__meta { font-size: 11px; color: #6a6a80; font-family: var(--font-mono, monospace); }
.scard-btn {
  margin-left: auto; background: transparent; border: 1px solid rgba(255,255,255,.12);
  color: #9a9ab0; border-radius: 8px; width: 30px; height: 28px; cursor: pointer; font-size: 14px;
}
.scard-btn:hover { color: #e7e7f0; border-color: var(--color-accent, #00D4FF); }

.surface-card__body { position: relative; height: 440px; }
.surface-frame { width: 100%; height: 100%; border: 0; background: transparent; transition: opacity .45s ease; }
.surface-frame--loading { opacity: 0; }

/* Foco / expandido (tela cheia) */
.block--surface.block--expanded {
  position: fixed; inset: 0; z-index: 50; max-width: none; margin: 0; padding: 24px;
  background: rgba(4,4,12,.82); backdrop-filter: blur(4px);
  display: flex; animation: block-in .3s;
}
.block--surface.block--expanded .surface-card { flex: 1; display: flex; flex-direction: column; }
.block--surface.block--expanded .surface-card__body { flex: 1; height: auto; }

/* ---- Loading inline do card (cortina) ---- */
.stage-loader--inline {
  position: absolute; inset: 0; z-index: 3; background: var(--color-bg-card, #0d0d1a);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.stage-loader__orb {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7BFFD4, #00E5FF 55%, #B47EFF);
  box-shadow: 0 0 28px rgba(0,229,255,.55); animation: orb-bob 1.6s ease-in-out infinite;
}
@keyframes orb-bob { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-12px) scale(1.08); } }
.stage-loader__text { color: #9a9ab0; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }

/* ---- Dots ---- */
.dots { display: inline-flex; gap: 4px; }
.dots span { width: 5px; height: 5px; border-radius: 50%; background: #6a6a80; animation: blink 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

/* ---- Composer ---- */
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.06); background: rgba(6,6,15,.6);
}
.composer textarea {
  flex: 1; resize: none; max-height: 160px; padding: 12px 15px; font: inherit; font-size: 15px;
  color: #e7e7f0; background: var(--color-bg-card, #0d0d1a);
  border: 1px solid rgba(255,255,255,.1); border-radius: 14px;
  max-width: 820px; margin: 0 auto;
}
.composer textarea:focus { outline: none; border-color: var(--color-accent, #00D4FF); }
.composer__send {
  width: 46px; height: 46px; flex: none; border: none; border-radius: 14px; cursor: pointer;
  background: var(--color-accent, #00D4FF); color: #04141a; font-size: 16px;
}
.composer__send:hover { filter: brightness(1.1); }

/* ---- Feel (header) ---- */
.feel-ambient { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #9a9ab0; transition: all .4s ease; }
.feel-ambient__orb { width: 9px; height: 9px; border-radius: 50%; background: #7B61FF; box-shadow: 0 0 10px currentColor; }
.feel-ambient__label { text-transform: lowercase; letter-spacing: .4px; }
.feel-ambient--calm .feel-ambient__orb, .feel-ambient--relieved .feel-ambient__orb { background: #7BFFD4; }
.feel-ambient--focused .feel-ambient__orb { background: #00D4FF; }
.feel-ambient--ready .feel-ambient__orb { background: #00FF9D; }
.feel-ambient--amused .feel-ambient__orb, .feel-ambient--celebrating .feel-ambient__orb { background: #FFC73B; }
.feel-ambient--curious .feel-ambient__orb, .feel-ambient--proud .feel-ambient__orb { background: #B47EFF; }
.feel-ambient--tense .feel-ambient__orb, .feel-ambient--concerned .feel-ambient__orb { background: #FF4757; }

@media (prefers-reduced-motion: reduce) {
  .block, .builder__frame, .build-step, .block--surface.block--expanded { animation: none; }
}

/* ---- Massinha (organismo vivo) ---- */
.organism {
  position: relative; flex: none; overflow: hidden;
  transition: height .8s cubic-bezier(.22, 1, .36, 1);
}
.organism--hero   { height: min(46vh, 420px); }
.organism--docked { height: 132px; }
.organism__canvas { width: 100%; height: 100%; display: block; }
/* na conversa vazia a timeline some e a massinha respira no centro */
.organism--hero + .timeline:empty { flex: 1; }
