/* ── Chat panel — fixed overlay below header ──────────────────────────────── */
.chat-panel {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; right: 0;
  z-index: 50; background: var(--ps-off-white);
  display: flex; flex-direction: column;
  animation: chatSlideIn .22s cubic-bezier(.4,0,.2,1);
}
.chat-panel.hidden { display: none; }
@keyframes chatSlideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 700px) { .chat-panel { bottom: 56px; } }

/* ── Shared centred column — constrains content to 760px, bar stays full width ── */
.chat-center-col {
  width: 100%; max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding-left: 20px; padding-right: 20px; box-sizing: border-box;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.chat-header {
  background: var(--ps-sidebar);
  border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
  padding-top: 12px; padding-bottom: 12px;
}
.chat-back {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.7); font-family: var(--display); font-size: 12px;
  font-weight: 500; padding: 5px 12px; border-radius: var(--ps-radius-pill);
  cursor: pointer; transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.chat-back:hover { background: rgba(255,255,255,.15); color: white; }
.chat-persona-info { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.chat-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: #fff;
  background: var(--ps-azul);
}
.chat-persona-name { font-size: 14px; font-weight: 700; color: white; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-persona-role { font-size: 10.5px; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-model-badge {
  margin-left: auto; flex-shrink: 0;
  font-family: var(--mono); font-size: 10px; color: rgba(255,255,255,.35);
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--ps-radius-xs); padding: 3px 8px; white-space: nowrap;
}

/* ── Messages area ───────────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--ps-border); border-radius: 2px; }

/* Messages widen their padding on large screens to match the 760px channel */
@media (min-width: 860px) {
  .chat-messages {
    padding-left:  max(24px, calc(50% - 380px));
    padding-right: max(24px, calc(50% - 380px));
  }
}

.chat-bubble-wrap { display: flex; flex-direction: column; max-width: 78%; }
.chat-bubble-wrap.user  { align-self: flex-end; align-items: flex-end; }
.chat-bubble-wrap.assistant { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.65;
  word-break: break-word;
}
.chat-bubble.user {
  background: var(--ps-azul); color: white;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  background: var(--ps-surface); color: var(--ps-text-primary);
  border: 1.5px solid var(--ps-border); border-bottom-left-radius: 4px;
}
.chat-bubble p { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble strong { font-weight: 700; }
.chat-bubble em { font-style: italic; }
.chat-bubble code { font-family: var(--mono); font-size: 12px; background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px; }
.chat-bubble pre { background: rgba(0,0,0,.06); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.chat-bubble pre code { background: none; padding: 0; font-size: 12px; }

.chat-copy-btn {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 4px; padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-family: var(--sans); color: var(--ps-text-secondary);
  background: none; border: none; cursor: pointer;
  opacity: 0; transition: opacity .15s, color .15s, background .15s;
  line-height: 1;
}
.chat-bubble-wrap.assistant:hover .chat-copy-btn { opacity: 1; }
.chat-copy-btn:hover { color: var(--ps-text-primary); background: var(--ps-border); }
.chat-copy-btn.copied { color: var(--ps-verde); opacity: 1; }

.chat-cursor { display: inline-block; width: 2px; height: 14px; background: var(--ps-azul); border-radius: 1px; margin-left: 2px; vertical-align: text-bottom; animation: blink .7s step-end infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.chat-thinking { display: flex; align-items: center; gap: 5px; padding: 12px 16px; background: var(--ps-surface); border: 1.5px solid var(--ps-border); border-radius: 16px; border-bottom-left-radius: 4px; }
.chat-thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--ps-azul-light); animation: dotPulse 1.2s ease-in-out infinite; }
.chat-thinking span:nth-child(2) { animation-delay: .2s; }
.chat-thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes dotPulse { 0%,80%,100% { transform: scale(.8); opacity: .5; } 40% { transform: scale(1.1); opacity: 1; } }

/* ── Input area ──────────────────────────────────────────────────────────────── */
.chat-input-area {
  background: var(--ps-surface);
  border-top: 1.5px solid var(--ps-border); flex-shrink: 0;
  padding-top: 14px; padding-bottom: 14px;
}
.chat-input-area .chat-center-col { align-items: flex-end; }
.chat-input-wrap { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.chat-char-row { display: flex; align-items: center; gap: 8px; padding: 0 2px; }
.chat-char-bar { flex: 1; height: 2px; background: var(--ps-border); border-radius: 2px; overflow: hidden; }
.chat-char-fill { height: 100%; width: 0; border-radius: 2px; background: var(--ps-azul-light); transition: width .1s, background .3s; }
.chat-char-count { font-size: 10.5px; color: var(--ps-text-muted); font-family: var(--mono); white-space: nowrap; min-width: 28px; text-align: right; }
.chat-input {
  flex: none; width: 100%; border: 1.5px solid var(--ps-border); border-radius: 14px;
  padding: 10px 14px; font-family: var(--display); font-size: 14px;
  color: var(--ps-text-primary); background: var(--ps-off-white);
  outline: none; resize: none; line-height: 1.5; max-height: 160px;
  overflow-y: auto; transition: border-color .15s;
}
.chat-input:focus { border-color: var(--ps-azul); }
.chat-input::placeholder { color: var(--ps-text-muted); }
.chat-send {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--ps-azul); color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.chat-send:hover { background: var(--ps-azul-dark); transform: scale(1.05); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.chat-send svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

