/* ==========================================================================
   Main tab — Os chat panel. Uses the shared design tokens; no hardcoded
   colors/radii. The panel fills the space between the top padding and the
   fixed tab bar, with a scrolling transcript over a pinned composer.
   ========================================================================== */

.os-chat {
  display: flex;
  flex-direction: column;
  /* Fill the viewport minus the body's top (24) + bottom (96, clears tabbar). */
  height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 132px);
  min-height: 360px;
}

.os-chat__header {
  margin-bottom: 12px;
}

.os-chat__subtitle {
  margin: -8px 0 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ── Transcript ──────────────────────────────────────────────────────── */

.os-chat__messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px 8px;
}

.os-msg {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: var(--radius-card);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;       /* preserve Os's line breaks / bullet lists */
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.os-msg strong { font-weight: 700; color: var(--text-primary); }

.os-msg--user {
  align-self: flex-end;
  background: var(--surface-border-strong);
  color: var(--text-primary);
  border-bottom-right-radius: var(--radius-checkbox);
}

.os-msg--os {
  align-self: flex-start;
  background: var(--surface-card);
  color: var(--text-secondary);
  border-bottom-left-radius: var(--radius-checkbox);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
}

.os-msg--error {
  align-self: flex-start;
  background: var(--warning-tint);
  color: var(--warning);
  border-bottom-left-radius: var(--radius-checkbox);
}

/* Typing indicator — three pulsing dots */
.os-msg--typing { display: inline-flex; gap: 5px; align-items: center; }
.os-msg--typing span {
  width: 6px; height: 6px; border-radius: var(--radius-pill);
  background: var(--text-tertiary);
  animation: os-typing 1.2s var(--ease-in-out, ease-in-out) infinite;
}
.os-msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.os-msg--typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes os-typing {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Composer ────────────────────────────────────────────────────────── */

.os-chat__composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--surface-hairline);
}

.os-composer__input {
  flex: 1;
  resize: none;
  max-height: 140px;
  font-family: var(--font-body);
  line-height: 1.4;
}

.os-chat__composer .btn { flex-shrink: 0; }
