.chat-workspace-shell {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  color: #f7f4ff;
  background:
    radial-gradient(circle at 72% 18%, rgba(115, 77, 225, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(7, 8, 15, 0.92), rgba(5, 7, 13, 0.97));
}

.chat-workspace-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  position: relative;
  height: 100%;
  overflow: hidden;
}

.chat-workspace-body.is-history-open {
  grid-template-columns: 320px minmax(0, 1fr);
}

.chat-workspace-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-workspace-history-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(9, 10, 18, 0.98);
}

.chat-workspace-history-panel[hidden] {
  display: none !important;
}

.chat-workspace-history-panel.is-open {
  display: flex;
}

.chat-workspace-history-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-workspace-history-head strong {
  font-size: 14px;
  font-weight: 600;
}

.chat-workspace-history-close {
  border: 0;
  background: transparent;
  color: rgba(241, 236, 255, 0.72);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}

.chat-workspace-history-close:hover,
.chat-workspace-history-close:focus-visible {
  color: #f7f4ff;
  background: rgba(255, 255, 255, 0.08);
}

.chat-workspace-history-tools {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-workspace-history-search input {
  width: 100%;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.045);
  color: #f7f4ff;
  outline: none;
}

.chat-workspace-history-search input:focus {
  border-color: rgba(167, 139, 250, 0.6);
}

.chat-workspace-history-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.chat-workspace-history-filters button {
  min-width: 0;
  border: 0;
  border-radius: 8px;
  padding: 7px 5px;
  background: transparent;
  color: rgba(235, 227, 255, 0.52);
  font-size: 12px;
}

.chat-workspace-history-filters button:hover,
.chat-workspace-history-filters button.is-active {
  background: rgba(124, 92, 215, 0.2);
  color: #f7f4ff;
}

.chat-workspace-history-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
}

.chat-workspace-history-empty {
  margin: 0;
  padding: 18px 8px;
  text-align: center;
  color: rgba(235, 227, 255, 0.45);
  font-size: 13px;
}

.chat-workspace-history-retry {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 7px 10px;
  color: #f7f4ff;
  background: rgba(255, 255, 255, 0.06);
}

.chat-workspace-history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 3px;
  color: #f7f4ff;
  background: rgba(255, 255, 255, 0.04);
}

.chat-workspace-history-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-workspace-history-item.is-active {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(101, 73, 213, 0.22);
}

.chat-workspace-history-open {
  display: flex;
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 9px;
  padding: 8px 9px;
  text-align: left;
  color: inherit;
  background: transparent;
}

.chat-workspace-history-item-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.chat-workspace-history-item-title {
  width: 100%;
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-workspace-history-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.chat-workspace-history-kind {
  font-size: 10px;
  color: rgba(205, 188, 255, 0.72);
}

.chat-workspace-history-item-time {
  font-size: 11px;
  color: rgba(235, 227, 255, 0.45);
}

.chat-workspace-history-delete {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  color: rgba(235, 227, 255, 0.42);
  background: transparent;
  font-size: 18px;
}

.chat-workspace-history-delete:hover,
.chat-workspace-history-delete:focus-visible {
  color: #ffb4b4;
  background: rgba(255, 92, 92, 0.12);
}

.chat-workspace-shell[hidden] { display: none; }

.chat-workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.14);
  background:
    linear-gradient(180deg, rgba(18, 14, 36, 0.88), rgba(10, 11, 20, 0.72));
  backdrop-filter: blur(18px);
}

.chat-workspace-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-workspace-title > span {
  flex: 0 0 auto;
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(196, 181, 253, 0.45));
}

.chat-workspace-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-workspace-title strong {
  font-size: 17px;
  letter-spacing: 0.02em;
}

.chat-workspace-title small {
  color: rgba(237, 231, 255, 0.58);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-workspace-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.chat-workspace-actions button,
.chat-workspace-retry {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 9px 14px;
  color: #f8f5ff;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.chat-workspace-actions button:hover,
.chat-workspace-retry:hover { background: rgba(255, 255, 255, 0.11); }

.chat-workspace-messages {
  --xh-chat-column: min(880px, calc(100% - 48px));
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 28px 0 32px;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: center;
  box-sizing: border-box;
}

.chat-workspace-messages > .chat-workspace-empty,
.chat-workspace-messages > .chat-workspace-message {
  width: var(--xh-chat-column);
  max-width: var(--xh-chat-column);
  box-sizing: border-box;
}

.chat-workspace-empty {
  margin: auto;
  max-width: 640px;
  padding: 28px 18px 40px;
  text-align: center;
  color: rgba(241, 236, 255, 0.78);
}

.chat-workspace-empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}

.chat-workspace-empty-mark {
  display: block;
  font-size: 42px;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(196, 181, 253, 0.55));
}

.chat-workspace-empty h2 {
  margin: 0;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.chat-workspace-empty-lead {
  margin: 0;
  font-size: 15px;
  color: rgba(221, 214, 254, 0.78);
}

.chat-workspace-empty-capabilities {
  list-style: none;
  margin: 0 auto 22px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 460px;
}

.chat-workspace-empty-capabilities li {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  color: rgba(241, 236, 255, 0.88);
}

.chat-workspace-empty-capabilities li.is-wide {
  grid-column: 1 / -1;
}

.chat-workspace-empty-cta {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.72);
}

.chat-workspace-message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  margin: 0;
  animation: xhChatMessageIn 0.28s ease;
}

@keyframes xhChatMessageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-workspace-message.is-user {
  align-items: flex-end;
  max-width: var(--xh-chat-column);
}

.chat-workspace-message.is-assistant {
  align-items: stretch;
  max-width: var(--xh-chat-column);
}

.chat-workspace-message-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px;
  color: rgba(235, 227, 255, 0.48);
  font-size: 12px;
}

.chat-workspace-message-label time,
.chat-workspace-ai-time {
  color: rgba(235, 227, 255, 0.38);
  font-size: 11px;
  font-weight: 400;
}

.chat-workspace-message.is-user .chat-workspace-message-label {
  text-align: right;
}

.chat-workspace-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-workspace-message.is-user .chat-workspace-attachments {
  justify-content: flex-end;
}

.chat-workspace-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.45);
  font-size: 12px;
  color: rgba(235, 227, 255, 0.86);
}

.chat-workspace-attachment img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
}

.chat-workspace-attachment.is-video {
  flex-direction: column;
  align-items: stretch;
  max-width: min(280px, 72vw);
  padding: 6px;
}

.chat-workspace-attachment video {
  display: block;
  width: 100%;
  max-height: 220px;
  border-radius: 8px;
  background: #000;
}

.chat-workspace-message-card {
  border-radius: 20px;
  border: 1px solid rgba(167, 139, 250, 0.34);
  background:
    linear-gradient(160deg, rgba(88, 56, 170, 0.16), rgba(18, 16, 34, 0.72) 42%, rgba(10, 12, 24, 0.82));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 0 28px rgba(124, 92, 215, 0.16),
    0 18px 44px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  padding: 14px 16px 16px;
}

.chat-workspace-ai-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 10px;
}

.chat-workspace-ai-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
  color: #f3e8ff;
}

.chat-workspace-ai-model {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, 0.22);
  background: rgba(16, 185, 129, 0.08);
  color: rgba(209, 250, 229, 0.9);
  font-size: 11px;
}

.chat-workspace-ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.8);
}

.chat-workspace-ai-time {
  margin-left: auto;
}

.chat-workspace-message-card .chat-workspace-message-content {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: rgba(248, 245, 255, 0.94);
  font-size: 15px;
  line-height: 1.8;
}

.chat-workspace-action-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-workspace-action-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 232, 240, 0.78);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.chat-workspace-action-btn i {
  font-size: 14px;
  line-height: 1;
}

.chat-workspace-action-btn:hover {
  color: #fff;
  border-color: rgba(167, 139, 250, 0.42);
  background: rgba(124, 92, 255, 0.14);
  transform: translateY(-1px);
}

.chat-workspace-action-btn.is-saved {
  color: #fff;
  border-color: rgba(255, 122, 160, 0.45);
  background: rgba(255, 92, 138, 0.15);
}

.chat-workspace-message-content.is-markdown p {
  margin: 0 0 0.85em;
}

.chat-workspace-message-content.is-markdown p:last-child {
  margin-bottom: 0;
}

.chat-workspace-message-content.is-markdown h2,
.chat-workspace-message-content.is-markdown h3,
.chat-workspace-message-content.is-markdown h4 {
  margin: 0.9em 0 0.45em;
  color: #f5f3ff;
  font-weight: 650;
  line-height: 1.35;
}

.chat-workspace-message-content.is-markdown h2 { font-size: 1.2em; }
.chat-workspace-message-content.is-markdown h3 { font-size: 1.08em; }
.chat-workspace-message-content.is-markdown h4 { font-size: 1em; }

.chat-workspace-message-content.is-markdown ul {
  margin: 0.4em 0 0.9em;
  padding-left: 1.25em;
}

.chat-workspace-message-content.is-markdown li {
  margin: 0.25em 0;
}

.chat-workspace-message-content.is-markdown code {
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.chat-workspace-code {
  margin: 0.7em 0;
  padding: 12px 14px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  background: rgba(5, 8, 18, 0.72);
}

.chat-workspace-code code {
  padding: 0;
  background: transparent;
  color: rgba(237, 233, 254, 0.94);
  font-size: 0.86em;
  white-space: pre;
}

.chat-workspace-message-content.is-markdown a {
  color: #c4b5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-workspace-message.is-user .chat-workspace-message-content {
  width: fit-content;
  max-width: min(400px, 100%);
  margin-left: auto;
  border: 1px solid rgba(196, 181, 253, 0.28);
  border-radius: 18px 18px 6px 18px;
  padding: 12px 14px;
  line-height: 1.65;
  font-size: 14px;
  color: #faf8ff;
  background: linear-gradient(135deg, rgba(109, 74, 230, 0.94), rgba(147, 91, 214, 0.9));
  box-shadow: 0 12px 28px rgba(88, 48, 180, 0.28);
}

.chat-workspace-composer {
  width: min(880px, calc(100% - 48px));
  margin: 0 auto;
  padding: 6px 0 22px;
  position: relative;
  z-index: 4;
}

.chat-workspace-status {
  min-height: 22px;
  padding: 0 4px 6px;
  color: rgba(229, 219, 255, 0.58);
  font-size: 12px;
}

.chat-workspace-status.is-error {
  color: #ffaaa9;
}

.chat-workspace-retry {
  display: inline-flex;
  margin: 0 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 7px 12px;
  color: #f8f5ff;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.chat-workspace-retry[hidden] {
  display: none !important;
}

.chat-workspace-retry:hover {
  background: rgba(255, 255, 255, 0.11);
}

.chat-workspace-composer-wrap {
  width: 100%;
}

.chat-workspace-composer .xh-ai-composer-shell,
.chat-workspace-composer .chat-input-container {
  width: 100%;
  max-width: 100%;
  border-radius: 22px;
  border: 1px solid rgba(167, 139, 250, 0.28);
  background:
    linear-gradient(180deg, rgba(28, 22, 52, 0.72), rgba(12, 14, 28, 0.88));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 0 32px rgba(124, 92, 215, 0.14),
    0 18px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
}

.chat-workspace-composer .xh-ai-composer-shell:focus-within,
.chat-workspace-composer .chat-input-container:focus-within {
  border-color: rgba(196, 181, 253, 0.48);
  box-shadow:
    0 0 0 1px rgba(196, 181, 253, 0.12) inset,
    0 0 36px rgba(139, 92, 246, 0.22),
    0 18px 40px rgba(0, 0, 0, 0.3);
}

.chat-workspace-composer .composer-media-add {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 56px;
  min-height: 56px;
  border-radius: 14px;
  border: 1px dashed rgba(196, 181, 253, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(237, 231, 255, 0.82);
}

.chat-workspace-composer .composer-media-add-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(221, 214, 254, 0.72);
}

.chat-workspace-composer .chat-workspace-input,
.chat-workspace-composer #chatWsUserInput {
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  min-height: 56px;
}

.chat-workspace-composer .chat-workspace-input::placeholder,
.chat-workspace-composer #chatWsUserInput::placeholder {
  color: rgba(236, 229, 255, 0.4);
}

.chat-workspace-composer .toolbar-pill {
  border: 1px solid rgba(74, 222, 128, 0.2);
  background: rgba(16, 185, 129, 0.08);
}

.chat-workspace-composer .xh-ai-composer-toolbar .input-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-workspace-composer .chat-workspace-send.btn-send-agent {
  min-width: 0;
  padding: 0;
  border-radius: 50%;
}

.chat-workspace-composer .composer-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-workspace-composer .xh-charge-estimate-hint {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: rgba(148, 156, 176, 0.55);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.chat-workspace-composer .chat-workspace-send.btn-send-agent:disabled {
  cursor: wait;
  opacity: 0.6;
}

.chat-workspace-hint {
  display: none;
}

/* Thin dark scrollbars — only scrollable panes, avoid nested page scroll */
.chat-workspace-shell,
.chat-workspace-body,
.chat-workspace-main {
  overflow: hidden;
}

.chat-workspace-messages,
.chat-workspace-history-list,
.chat-workspace-code {
  scrollbar-width: thin;
  scrollbar-color: rgba(167, 139, 250, 0.35) transparent;
}

.chat-workspace-messages::-webkit-scrollbar,
.chat-workspace-history-list::-webkit-scrollbar,
.chat-workspace-code::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.chat-workspace-messages::-webkit-scrollbar-track,
.chat-workspace-history-list::-webkit-scrollbar-track,
.chat-workspace-code::-webkit-scrollbar-track {
  background: transparent;
}

.chat-workspace-messages::-webkit-scrollbar-thumb,
.chat-workspace-history-list::-webkit-scrollbar-thumb,
.chat-workspace-code::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.32);
  border-radius: 999px;
}

.chat-workspace-messages::-webkit-scrollbar-thumb:hover,
.chat-workspace-history-list::-webkit-scrollbar-thumb:hover,
.chat-workspace-code::-webkit-scrollbar-thumb:hover {
  background: rgba(196, 181, 253, 0.48);
}

/* Model menu lives in chat-workspace-mount; main.css .model-preset-menu is scoped elsewhere */
#chatWsModelMenu.model-preset-menu {
  position: fixed;
  z-index: 9999;
  min-width: 220px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

#chatWsModelMenu.model-preset-menu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#chatWsModelMenu.model-preset-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

#chatWsModelMenu.model-preset-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

#chatWsModelMenu.model-preset-menu .model-preset-check {
  display: none;
}

#chatWsModelMenu.model-preset-menu button.selected .model-preset-check {
  display: inline-flex;
}

@media (max-width: 640px) {
  .chat-workspace-header { align-items: flex-start; padding: 14px; }
  .chat-workspace-title { flex-wrap: wrap; gap: 6px 8px; }
  .chat-workspace-title small { width: 100%; }
  .chat-workspace-actions { flex-direction: column; }
  .chat-workspace-actions button { padding: 7px 10px; }
  .chat-workspace-body.is-history-open {
    grid-template-columns: minmax(0, 1fr);
  }
  .chat-workspace-history-panel.is-open {
    position: absolute;
    inset: 0;
    z-index: 6;
    width: min(100%, 360px);
    max-width: 360px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
  }
  .chat-workspace-messages,
  .chat-workspace-composer { width: 100%; }
  .chat-workspace-messages {
    padding-top: 20px;
    gap: 16px;
    --xh-chat-column: calc(100% - 24px);
  }
  .chat-workspace-message.is-user .chat-workspace-message-content {
    max-width: min(400px, 94%);
  }
  .chat-workspace-message.is-assistant { max-width: var(--xh-chat-column); }
  .chat-workspace-empty-capabilities { grid-template-columns: 1fr; }
  .chat-workspace-empty h2 { font-size: 28px; }
}

/* Streaming reveal caret — shared by workspace + advisor via XHStreamReveal */
.chat-workspace-message-content.is-streaming::after,
.advisor-msg__bubble.is-streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: currentColor;
  opacity: 0.55;
  animation: xh-stream-caret 0.9s steps(1, end) infinite;
}
@keyframes xh-stream-caret {
  50% { opacity: 0; }
}

/* Finalize-only math (KaTeX) — not used during streaming light paint */
.chat-workspace-message-content .xh-math-block,
.advisor-msg__bubble .xh-math-block {
  margin: 0.75em 0;
  overflow-x: auto;
  text-align: center;
}
.chat-workspace-message-content .xh-math-inline,
.advisor-msg__bubble .xh-math-inline {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
  overflow-x: auto;
}
.chat-workspace-message-content .katex,
.advisor-msg__bubble .katex {
  font-size: 1.05em;
  color: inherit;
}
.chat-workspace-message-content .xh-math.is-fallback,
.advisor-msg__bubble .xh-math.is-fallback {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  opacity: 0.9;
}
.chat-workspace-message-content .xh-math.is-display,
.advisor-msg__bubble .xh-math.is-display {
  display: block;
  padding: 0.5em 0;
}
