:root {
  --chat-column-width: 920px;
}

html[data-yb-theme='dark'] {
  --chat-outgoing-fill: #163b3d;
  --chat-bubble-fill: #1b2a31;
  --chat-send-fill: #9bdecf;
  --chat-send-ink: #102620;
}

.workbench-chat-column,
:is(.ref-task-page .daily-chat, .ref-chat-shell .social-chat, .chat-layout .conversation, .room-workspace) .workbench-chat-column {
  width: 100%;
  max-width: var(--chat-column-width);
  min-width: 0;
  margin-inline: auto;
  box-sizing: border-box;
}

.workbench-chat-transcript {
  min-height: 0;
  min-width: 0;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable both-edges;
}

:is(.daily-chat .daily-message, .social-chat .social-message, .chat-layout .message, .room-workspace .room-message, .daily-chat .xiaoyu-concierge-turn) .workbench-chat-bubble {
  padding: 10px 14px;
  border: 1px solid var(--yb-line);
  border-radius: 6px 14px 14px;
  background: var(--chat-bubble-fill);
  color: var(--yb-ink);
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  box-shadow: none;
  animation: none;
}

:is(.daily-chat .daily-message, .social-chat .social-message, .chat-layout .message, .room-workspace .room-message, .daily-chat .xiaoyu-concierge-turn) .workbench-chat-bubble.workbench-chat-outgoing {
  padding: 8px 13px;
  border-color: transparent;
  border-radius: 14px 6px 14px 14px;
  background: var(--chat-outgoing-fill);
}

:is(.ref-home-workspace .ref-task-page .daily-chat, .ref-chat-shell .social-chat, .chat-layout, .room-workspace) .workbench-chat-composer {
  box-sizing: border-box;
  padding: 10px 12px 8px;
  border: 1px solid var(--yb-line-strong);
  border-radius: 16px;
  background: var(--yb-paper);
  box-shadow: none;
}

:is(.ref-home-workspace .ref-task-page .daily-chat, .ref-chat-shell .social-chat, .chat-layout, .room-workspace) .workbench-chat-composer:focus-within {
  border-color: var(--yb-water);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--yb-water) 12%, transparent);
}

:is(.ref-home-workspace .daily-chat, .ref-chat-shell .social-chat, .chat-layout, .room-workspace) .workbench-chat-composer > .workbench-chat-input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 5px 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--yb-ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  box-shadow: none;
}

:is(.daily-chat, .social-chat, .chat-layout, .room-workspace) .workbench-chat-input::placeholder { color: var(--yb-muted); }
.workbench-chat-input:focus-visible { outline: none; }

:is(.daily-chat, .social-chat, .chat-layout, .room-workspace) .workbench-chat-toolbar {
  min-width: 0;
  min-height: 36px;
  margin-top: 4px;
  gap: 5px;
}

:is(.ref-home-workspace .ref-task-page .daily-chat, .ref-chat-shell .social-chat, .chat-layout, .room-workspace) .workbench-chat-send {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chat-send-fill);
  color: var(--chat-send-ink);
  box-shadow: none;
}

:is(.ref-home-workspace .ref-task-page .daily-chat, .ref-chat-shell .social-chat, .chat-layout, .room-workspace) .workbench-chat-send:disabled {
  background: var(--yb-canvas);
  color: var(--yb-muted);
  opacity: .8;
}

.workbench-chat-reply-state {
  color: var(--yb-muted);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.workbench-chat-reply-state strong { color: var(--yb-ink); }

.workbench-reply-wait {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  min-height: 35px;
  width: fit-content;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--chat-bubble-fill);
  color: var(--yb-muted);
  font-size: 12px;
  line-height: 1.55;
}
.workbench-reply-wait.is-compact { min-height: 27px; padding: 3px 8px; }
.workbench-reply-wait-lead { display: inline-flex; align-items: center; flex: none; }
.workbench-reply-wait-dots { display: inline-flex; align-items: center; flex: none; gap: 4px; }
.workbench-reply-wait-dots > i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--yb-water);
  animation: workbench-reply-pulse 1.35s ease-in-out infinite both;
}
.workbench-reply-wait-dots > i:nth-child(2) { animation-delay: 150ms; }
.workbench-reply-wait-dots > i:nth-child(3) { animation-delay: 300ms; }

@keyframes workbench-reply-pulse {
  0%, 70%, 100% { opacity: .32; }
  28% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .workbench-reply-wait-dots > i { animation: none; opacity: .65; }
}
html[data-motion='off'] .workbench-reply-wait-dots > i { animation: none; opacity: .65; }

.daily-messages > .daily-progress.workbench-reply-wait {
  margin: 0 0 0 38px;
  padding: 5px 10px;
  border: 0;
  border-radius: 10px;
}

.workbench-chat-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 10px;
  color: var(--yb-muted);
  font-size: 12px;
  line-height: 1.4;
}

.workbench-chat-message-time {
  flex: none;
  margin-inline-start: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

html[data-yb-theme='dark'] :is(.workbench-chat-bubble, .workbench-chat-composer) {
  box-shadow: none !important;
}

html[data-yb-theme='dark'] .workbench-chat-bubble {
  background: var(--chat-bubble-fill) !important;
  border-color: var(--yb-line) !important;
  color: var(--yb-ink) !important;
}

html[data-yb-theme='dark'] .workbench-chat-bubble.workbench-chat-outgoing {
  background: var(--chat-outgoing-fill) !important;
  border-color: transparent !important;
}

html[data-yb-theme='dark'] .workbench-chat-input {
  background: transparent !important;
  border: 0 !important;
}

.chat-layout:has(.workbench-chat-transcript) {
  --chat-legacy-inset: clamp(14px, 3vw, 32px);
  width: 100%;
  max-width: none;
  min-width: 0;
}

.chat-layout > .workbench-chat-transcript {
  padding: 18px var(--chat-legacy-inset);
}

.chat-layout .workbench-chat-transcript > .workbench-chat-column,
.workbench-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chat-layout .workbench-chat-transcript > .workbench-chat-column { flex: 1; }
.workbench-chat-messages:empty { display: none; }


.chat-layout .workbench-chat-messages .message.user { max-width: min(86%, 580px); }

.chat-layout .workbench-chat-messages .assistant-label { margin-bottom: 6px; }

.chat-layout .workbench-chat-messages .message-body { width: fit-content; }

.chat-layout .workbench-chat-column > .workbench-chat-reply-state p { margin: 4px 0; }

.chat-layout .model-chat-error.workbench-chat-reply-state {
  padding: 8px 0;
  margin: 0;
  align-self: flex-end;
  max-width: min(100%, 520px);
}

.chat-layout .composer-wrap.workbench-chat-column {
  width: calc(100% - 2 * var(--chat-legacy-inset));
  padding: 6px 0 12px;
}

.chat-layout :is(.conversation, .composer-wrap):has(.workbench-chat-bubble, .workbench-chat-composer) {
  background: var(--yb-paper);
}


.chat-layout .workbench-chat-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  color: var(--yb-muted);
  border: 0;
  white-space: nowrap;
  font-size: 12px;
}

.room-workspace .room-transcript.workbench-chat-transcript {
  max-height: min(60vh, 620px);
  overflow-y: auto;
  padding: 8px 4px;
}

.room-workspace .room-message { margin-bottom: 16px; }
.room-workspace .room-message:last-child { margin-bottom: 0; }
.room-workspace .room-transcript > .workbench-reply-wait { margin-block: 8px 4px; }
.room-workspace .room-message-text { width: fit-content; max-width: min(100%, 640px); }
.room-workspace .room-message-author { margin-bottom: 4px; }
.room-workspace .room-message-copy { white-space: pre-wrap; }
.room-workspace .room-message-text > .workbench-chat-meta { margin-top: 4px; }
.room-workspace .room-message-user { flex-direction: row-reverse; }
.room-workspace .room-message-user .room-message-text { margin-inline-start: auto; }
.room-workspace .room-composer-footer { flex-direction: row; justify-content: flex-end; }
.room-workspace .room-next {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: var(--chat-column-width);
  margin: 16px auto 0;
  padding: 10px 12px;
}
.room-workspace .room-next > p { flex: 1 1 200px; margin: 0; }
.room-workspace .room-next > small { flex: 1 1 100%; margin: 0; }
.room-workspace .room-composer { margin-top: 12px; }

.daily-chat .xiaoyu-concierge-user > p:last-child { margin-bottom: 0; }
.daily-chat .xiaoyu-concierge-copy > .workbench-chat-bubble { width: fit-content; margin-bottom: 10px; }

@media (min-width: 1450px) {
  .reference-mode .social-app.ref-chat-shell {
    grid-template-columns: 75px var(--ref-sidebar-width, 303px) minmax(0, 1fr);
  }
  html[data-ref-sidebar='closed'] .reference-mode .social-app.ref-chat-shell {
    grid-template-columns: 75px 0 minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .workbench-chat-transcript { scrollbar-gutter: auto; }
  .chat-layout .workbench-chat-action > span { display: none; }
}
