/* ============================================================
   chat.css — Mosaiq Studio Chat Panel 3-Zone Layout Stylesheet
   ============================================================ */

/* ── 1. CSS Custom Properties (chat-specific) ── */
:root {
  --warn-dim: rgba(245, 158, 11, 0.12);
  --skeleton-color: var(--bg-elevated);
}

/* ── 2. Keyframe Animations ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes reopen-flash {
  0%   { background-color: var(--warn-dim); }
  100% { background-color: transparent; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 3. 3-Zone Layout (.chat-layout) ── */
.chat-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 120px);
}

/* ── 4. Sidebar Zone ── */
.chat-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-standard);
  overflow-y: auto;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.chat-mobile-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

@media (max-width: 767px) {
  .chat-mobile-toggle {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

#conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

/* ── 4a. Sidebar Sections (Board Overview + Todo) ── */

.sidebar-section {
  border-top: 1px solid var(--border-subtle);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
  transition: background var(--transition);
}

.sidebar-section-header:hover {
  background: var(--bg-hover);
}

.sidebar-section-icon {
  font-size: 12px;
  line-height: 1;
}

.sidebar-section-title {
  flex: 1;
}

.sidebar-section-toggle {
  font-size: 10px;
  color: var(--text-quaternary);
  transition: transform 150ms;
}

.sidebar-section.collapsed .sidebar-section-toggle {
  transform: rotate(-90deg);
}

.sidebar-section.collapsed .sidebar-section-body {
  display: none;
}

.sidebar-section-body {
  padding: 0 8px 4px;
}

/* ── 4b. Board Section Items ── */

.board-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.board-item:hover {
  background: var(--bg-hover);
}

.board-item.active {
  background: var(--accent-dim);
}

.board-status-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--text-quaternary);
}

.board-status-dot.status-running {
  background: var(--warn);
}

.board-status-dot.status-done {
  background: var(--success, #22c55e);
}

.board-status-dot.status-ready {
  background: var(--accent);
}

.board-status-dot.status-todo {
  background: var(--text-quaternary);
}

.board-status-dot.status-blocked {
  background: var(--danger);
}

.board-status-dot.status-crashed {
  background: var(--danger);
}

.board-item-body {
  flex: 1;
  min-width: 0;
}

.board-item-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.board-item-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.board-assignee {
  display: inline-block;
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-tertiary);
  line-height: 1.6;
}

.board-priority {
  display: inline-block;
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-tertiary);
  line-height: 1.6;
  font-weight: 600;
}

.board-priority.prio-high {
  color: var(--danger);
}

.board-priority.prio-med {
  color: var(--warn);
}

.board-section-empty {
  font-size: 11px;
  color: var(--text-quaternary);
  text-align: center;
  padding: 8px 0;
}

/* ── 4c. Board Column Badges ── */

.board-column-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 0 8px;
}

.board-column-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.badge-count {
  font-weight: 700;
  color: var(--text-primary);
}

.board-recent-header {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0 2px;
}

.board-recent-task {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 4px;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.board-recent-task:hover {
  background: var(--bg-hover);
}

.task-status-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text-tertiary);
  flex-shrink: 0;
  font-weight: 500;
}

.task-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  color: var(--text-secondary);
}

.task-assignee {
  font-size: 10px;
  color: var(--text-quaternary);
  flex-shrink: 0;
}

/* ── 4d. Todo Task Items ── */

.todo-task-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 4px;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.todo-task-item:hover {
  background: var(--bg-hover);
}

.todo-checkbox {
  color: var(--text-quaternary);
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.todo-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  color: var(--text-secondary);
}

/* ── 5. Conversation Items (Teams style) ── */

.conv-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-md);
  position: relative;
  transition: background var(--transition);
}

.conv-item:hover {
  background: var(--bg-hover);
}

.conv-item.active {
  background: var(--accent-dim);
}

/* Needs-attention gradient flash — when LLM output awaits user decision */
.conv-item.needs-attention {
  animation: conv-attention-gradient 2s ease-in-out infinite;
}

.conv-item.needs-attention::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(59, 130, 246, 0.15), rgba(16, 185, 129, 0.1));
  animation: conv-attention-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes conv-attention-gradient {
  0%, 100% { background: var(--accent-dim); }
  50% { background: rgba(59, 130, 246, 0.12); }
}

@keyframes conv-attention-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Active left accent bar — like Teams */
.conv-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Avatar circle */
.conv-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.conv-avatar.status-running {
  background: var(--warn-dim);
}

.conv-avatar.status-done {
  background: rgba(34, 197, 94, 0.12);
}

/* Body container (title row + preview row) */
.conv-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Top row: title + badge/count */
.conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.conv-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.conv-meta-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Intent badge — small pill */
.conv-meta-right .intent-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.5;
  background: var(--badge-neutral-bg);
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Message count badge (like Teams unread count) */
.conv-msg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* Bottom row: message preview */
.conv-bottom {
  display: flex;
  align-items: center;
}

.conv-preview {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* Reopen badge */
.conv-item .reopen-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--warn-dim);
  color: var(--warn);
  font-weight: 600;
  margin-left: 4px;
}

/* Reopening flash */
.conv-item.reopening {
  animation: reopen-flash 2s ease-out;
}

/* Sidebar placeholder / error states */
.sidebar-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-quaternary);
  font-size: 13px;
}

.sidebar-error {
  text-align: center;
  padding: 16px;
  color: var(--danger);
  font-size: 12px;
}

.sidebar-error a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

/* ── 6. Thread Zone ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-thread-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#chat-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

#chat-messages {
  padding: 16px 20px;
}

/* ── 7. Message Bubbles ── */
.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 10px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-user {
  margin-left: auto;
  background: var(--accent-dim);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.msg-assistant,
.msg-mosaiq,
.msg-pm,
.msg-completion {
  margin-right: auto;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-border);
}

.msg-system {
  margin: 6px auto;
  color: var(--text-quaternary);
  font-size: 11px;
  text-align: center;
  max-width: 100%;
}

/* ── Loading indicator (bureaucratic phrases) ── */
.msg-loading {
  margin: 12px auto;
  text-align: center;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: msg-loading-fade-in 0.3s ease;
}

.msg-loading-dots {
  font-size: 18px;
  color: var(--text-tertiary);
  letter-spacing: 4px;
  animation: msg-loading-dot-pulse 1.2s ease-in-out infinite;
}

.msg-loading-phrase {
  font-size: 11px;
  color: var(--text-quaternary);
  font-style: italic;
  opacity: 0.7;
  transition: opacity 0.15s ease;
  max-width: 300px;
}

@keyframes msg-loading-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes msg-loading-dot-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.msg-error {
  margin: 8px auto;
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 11px;
  text-align: center;
  max-width: 90%;
  border-radius: var(--radius-md);
}

.msg-reopen {
  color: var(--warn);
  background: var(--warn-dim);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  margin: 6px auto;
  max-width: 90%;
  text-align: center;
}

/* ── 8. Input Bar ── */
.chat-input-bar {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-input-bar .chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  font-size: 14px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-standard);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.4;
  min-height: 42px;
  max-height: 140px;
}

#chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

#chat-input::placeholder {
  color: var(--text-quaternary);
}

#chat-send-btn {
  flex-shrink: 0;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity var(--transition);
}

#chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── 9. Empty / Waiting States ── */
#chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  text-align: center;
  padding: 16px 20px;
}

.chat-empty-icon {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 4px;
}

.chat-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-empty-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
  max-width: 360px;
}

.chat-waiting {
  display: none;
  margin-left: auto;
  font-size: 11px;
  color: var(--warn);
  animation: pulse 2s infinite;
}

/* ── 10. Skeleton Loading ── */
.skeleton-bubble {
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--skeleton-color);
  animation: shimmer 1.5s infinite;
  background-image: linear-gradient(
    90deg,
    var(--skeleton-color) 0%,
    var(--bg-hover) 50%,
    var(--skeleton-color) 100%
  );
  background-size: 200% 100%;
}

.skeleton-left  { align-self: flex-start; max-width: 60%; }
.skeleton-right { align-self: flex-end;  max-width: 60%; }

/* ── 11. Mobile Overlay ── */
.chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-drawer-overlay);
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
}

.chat-sidebar.overlay-open {
  transform: translateX(0);
}

@media (max-width: 767px) {
  .chat-mobile-toggle {
    display: block;
  }

  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    transition: transform 200ms ease;
    background: var(--bg-surface);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    width: 300px;
  }

  .chat-sidebar.overlay-open {
    transform: translateX(0);
  }

  .chat-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .chat-main {
    min-height: calc(100vh - 120px);
  }
}

@media (max-width: 640px) {
  .msg-bubble {
    max-width: 88%;
  }

  .msg-error {
    max-width: 95%;
  }
}

/* ═══════════════════════════════════════════════════════════════
   OBSERVABILITY — Context Menu + Bottom Drawer
   ═══════════════════════════════════════════════════════════════ */

/* ── Context Menu ── */
.obs-ctx-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-elevated);
  border: 1px solid var(--border-standard);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  min-width: 160px;
  padding: 4px 0;
  display: none;
}

.obs-ctx-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}

.obs-ctx-item:hover {
  background: var(--bg-hover);
}

/* ── Drawer Overlay + Drawer ── */
.obs-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer-overlay, 2000);
  background: rgba(6, 9, 18, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  opacity: 0;
  transition: opacity var(--duration-normal, 200ms) var(--ease-default, ease);
}

.obs-drawer-overlay.open {
  display: block;
  opacity: 1;
}

.obs-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60vh;
  max-height: 80vh;
  width: 100%;
  z-index: var(--z-drawer, 2100);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-standard);
  box-shadow: var(--shadow-elevated);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--duration-slow, 300ms) var(--ease-enter, cubic-bezier(0.16, 1, 0.3, 1));
}

.obs-drawer.open {
  transform: translateY(0);
}

.obs-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.obs-drawer__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.obs-drawer__content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.obs-drawer__content::-webkit-scrollbar {
  width: 4px;
}

.obs-drawer__content::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

/* ── Loading + Error + Empty ── */
.obs-loading {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-quaternary);
  font-size: 13px;
}

.obs-error {
  color: var(--danger);
  padding: 16px;
  font-size: 13px;
}

.obs-empty {
  color: var(--text-quaternary);
  padding: 24px 16px;
  font-size: 13px;
  text-align: center;
}

/* ── Summary Header ── */
.obs-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.obs-summary__card {
  flex: 1;
  min-width: 100px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.obs-summary__value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.obs-summary__label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Sections ── */
.obs-section {
  margin-bottom: 20px;
}

.obs-section__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Task Flow Diagram ── */
.obs-flow {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.obs-flow__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.obs-flow__task-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.obs-flow__nodes {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  overflow-x: auto;
  padding: 4px 0;
}

.obs-flow__arrow {
  color: var(--text-quaternary);
  font-size: 12px;
  flex-shrink: 0;
}

.obs-flow__node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: opacity var(--transition);
  white-space: nowrap;
}

.obs-flow__node:hover {
  opacity: 0.8;
}

.obs-flow__node--running,
.obs-flow__node--info {
  background: var(--warn-dim, rgba(245, 158, 11, 0.12));
  color: var(--warn, #f59e0b);
}

.obs-flow__node--done {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success, #22c55e);
}

.obs-flow__node--blocked,
.obs-flow__node--error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger, #ef4444);
}

.obs-flow__node--pending,
.obs-flow__node--neutral {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.obs-flow__empty {
  font-size: 11px;
  color: var(--text-quaternary);
  font-style: italic;
}

/* ── Token Breakdown Chart ── */
.obs-tokens {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.obs-tokens__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.obs-tokens__row--total {
  padding-top: 6px;
  margin-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.obs-tokens__label {
  width: 70px;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: capitalize;
  flex-shrink: 0;
}

.obs-tokens__bar-track {
  flex: 1;
  height: 16px;
  background: var(--bg-surface);
  border-radius: 3px;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.obs-tokens__bar {
  height: 100%;
  min-width: 0;
  transition: width 300ms ease;
}

.obs-tokens__bar--prompt {
  background: var(--accent, #6366f1);
}

.obs-tokens__bar--completion {
  background: var(--success, #22c55e);
}

.obs-tokens__bar--reasoning {
  background: var(--warn, #f59e0b);
}

.obs-tokens__count {
  width: 50px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.obs-tokens__legend {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 6px;
}

.obs-tokens__legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-tertiary);
}

.obs-tokens__legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ── Per-Turn Metrics Table ── */
.obs-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.obs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.obs-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-standard);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
}

.obs-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.obs-table tr:hover td {
  background: var(--bg-hover);
}

.obs-table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.obs-table__turn {
  font-weight: 600;
  color: var(--text-primary);
}

.obs-table__model {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Role badges in table */
.obs-role {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.5;
}

.obs-role--user {
  background: var(--accent-dim, rgba(99, 102, 241, 0.12));
  color: var(--accent, #6366f1);
}

.obs-role--assistant {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success, #22c55e);
}

.obs-role--system {
  background: var(--bg-hover);
  color: var(--text-tertiary);
}

.obs-role--tool,
.obs-role--tool_call {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warn, #f59e0b);
}

.obs-role--unknown {
  background: var(--bg-hover);
  color: var(--text-quaternary);
}

.obs-role--mosaiq {
  background: var(--accent-dim, rgba(168, 85, 247, 0.12));
  color: var(--accent, #a855f7);
}

.obs-role--pm {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa; /* TODO: promote to --info / --brand-blue token */
}
