/* Keep these tokens on the chat route so lesson players and other workspaces
   retain their own styles. The production shell loads this sheet last. */
:where(.app:has(.chat-workspace)) {
  --chat-canvas: #f3f2fc;
  --chat-paper: #fff;
  --chat-ink: #24233e;
  --chat-muted: #58586e;
  --chat-line: #deddf0;
  --chat-shadow: #d4d2e7;
  --chat-indigo: #5147e8;
  --chat-indigo-hover: #463cce;
  --chat-indigo-base: #372cad;
  --chat-lavender: #e9e7fe;
  --chat-mint: #e6f8ef;
  --chat-mint-ink: #115a40;
  --chat-mint-line: #a7e0c6;
  --chat-radius: 16px;
  --chat-gutter: clamp(14px, 4vw, 64px);
  --chat-width: 1040px;
}

html.zxv4[data-zx-route="chat"] .zx-tabs button.on {
  color: #fff;
  background: var(--zx-indigo-d, #4040d4);
  border-radius: 10px 10px 0 0;
}

@media (min-width: 751px) {
  html.zxv4[data-zx-route="chat"] .app:not(.camp-page) {
    grid-template-columns: clamp(232px, 24vw, 368px) minmax(0, 1fr) !important;
  }

  html.zxv4[data-zx-route="chat"] .zx-tabs button {
    font-size: 14px;
  }
}

@media (max-width: 750px) {
  html.zxv4[data-zx-route="chat"] .zx-home {
    flex-shrink: 0;
    white-space: nowrap;
    padding-inline: 8px;
  }

  html.zxv4[data-zx-route="chat"] .zx-home svg:first-child {
    display: none;
  }

  html.zxv4[data-zx-route="chat"] .zx-crumb {
    flex: 1;
    gap: 5px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
  }

  html.zxv4[data-zx-route="chat"] .zx-crumb > .sep {
    display: none;
  }

  html.zxv4[data-zx-route="chat"] .zx-crumb > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html.zxv4[data-zx-route="chat"] .zx-right {
    gap: 6px;
  }
}

html.zxv4[data-zx-route="chat"] .app > .sidebar {
  background: #f5f4fd;
  border-color: #deddf0;
}

:where(.app:has(.chat-workspace)) .conversation-sidebar .new-conversation-btn,
.chat-workspace :is(.send, .visual-open, .chat-mode-indicator),
.chat-workspace .chat-mode-tabs:not([data-indicator-ready="true"]) button[aria-selected="true"] {
  background: var(--chat-indigo);
  color: #fff;
  box-shadow: 0 4px 0 var(--chat-indigo-base);
}

:where(.app:has(.chat-workspace)) .conversation-sidebar .new-conversation-btn {
  min-height: 46px;
  border-radius: 13px;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 750;
}

:where(.app:has(.chat-workspace)) .conversation-sidebar .new-conversation-btn:hover,
.chat-workspace :is(.send, .visual-open):hover:not(:disabled) {
  background: var(--chat-indigo-hover);
}

:where(.app:has(.chat-workspace)) .conversation-sidebar .conversation-search {
  min-height: 38px;
  border-radius: 12px;
  background: var(--chat-paper);
  border-color: var(--chat-line);
  box-shadow: 0 2px 0 var(--chat-shadow);
}

:where(.app:has(.chat-workspace)) .conversation-sidebar .conversation-search:focus-within {
  border-color: var(--chat-indigo);
  box-shadow: 0 0 0 2px var(--chat-lavender);
}

:where(.app:has(.chat-workspace)) .history-scroll > .history-row {
  background: var(--chat-paper);
  border-radius: 11px;
  margin-block: 4px;
  min-height: 35px;
}

:where(.app:has(.chat-workspace)) .history-row .history-item {
  font-size: 14px;
}

:where(.app:has(.chat-workspace)) .history-scroll > .history-row:hover {
  background: #efedff;
}

:where(.app:has(.chat-workspace)) .history-scroll > .history-row:has(.history-item.selected),
:where(.app:has(.chat-workspace)) .history-scroll > .project-item.active {
  background: #dfdcff;
}

:where(.app:has(.chat-workspace)) .history-row .history-item.selected {
  color: #33288c;
  font-weight: 700;
}

.chat-workspace {
  background: var(--chat-canvas);
  color: var(--chat-ink);
}

.chat-workspace :is(.chat-heading, .chat-mode-toolbar) {
  background: transparent;
  border-bottom-color: transparent;
}

.chat-workspace .chat-mode-tabs {
  background: #f9f8ff;
  border: 1px solid var(--chat-line);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--chat-shadow);
  padding-bottom: 5px;
}

.chat-workspace .chat-mode-tabs :is(button, .chat-mode-indicator) {
  border-radius: 10px;
}

.chat-workspace .chat-mode-tabs button {
  font-size: 14px;
}

.chat-workspace .chat-mode-indicator {
  bottom: 5px;
  box-shadow: 0 2px 0 var(--chat-indigo-base);
}

.chat-workspace .chat-mode-tabs button[aria-selected="true"] {
  color: #fff;
  font-weight: 750;
}

.chat-workspace .chat-scroll {
  padding: 18px var(--chat-gutter) 20px;
  scrollbar-gutter: stable;
}

.chat-workspace .chat-message {
  max-width: var(--chat-width);
  margin-bottom: 20px;
}

.chat-workspace .chat-message.user .message-text {
  background: var(--chat-indigo);
  color: #fff;
  border-radius: var(--chat-radius);
  padding: 10px 16px;
  font-size: clamp(15px, 1.15vw, 17px);
  font-weight: 650;
  box-shadow: 0 4px 0 var(--chat-indigo-base);
}

.chat-workspace .chat-message.assistant > .message-body > .small:first-child {
  color: var(--chat-muted);
  font-size: 13px;
  font-weight: 650;
  margin: 0 0 8px;
}

.chat-workspace .chat-message.assistant > .message-body > .message-text {
  background: var(--chat-paper);
  color: var(--chat-ink);
  padding: 12px 16px;
  font-size: clamp(15px, 1.1vw, 16px);
  line-height: 1.75;
  border: 1px solid var(--chat-line);
  border-radius: var(--chat-radius);
  box-shadow: 0 3px 0 var(--chat-shadow);
}

.chat-workspace .avatar.ai {
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--chat-paper);
  box-shadow: 0 3px 0 var(--chat-shadow);
}

.chat-workspace :is(.web-search-ready, .source-details) {
  background: var(--chat-mint);
  color: var(--chat-mint-ink);
  border: 1px solid var(--chat-mint-line);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--chat-mint-line);
  margin-top: 10px;
}

.chat-workspace :is(.web-search-ready .web-search-label, .source-details > summary) {
  color: var(--chat-mint-ink);
  font-size: 13px;
  font-weight: 700;
}

.chat-workspace .lesson-overview details {
  border: 1px solid var(--chat-line);
  border-radius: 12px;
  background: #faf9ff;
}

.chat-workspace .message-questions:has(> .text-button:only-child) {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.chat-workspace .message-questions > .text-button {
  display: inline-flex;
  margin-block: 8px 4px;
  padding: 6px 10px;
  border: 1px solid var(--chat-line);
  border-radius: 9px;
  background: var(--chat-paper);
  color: #4437ad;
}

.chat-workspace .message-questions + button.text-button {
  vertical-align: middle;
  margin: 6px 0 4px;
  padding: 7px 12px;
  border-radius: 10px;
  background: #ffb638;
  color: #492807;
  font-weight: 750;
  box-shadow: 0 3px 0 #cb7913;
}

.chat-workspace .visual-card:has(> .visual-open) {
  border: 1px solid #d3cef8;
  border-radius: 20px;
  background: var(--chat-lavender);
  padding: 0 18px 14px;
  box-shadow: 0 5px 0 var(--chat-indigo);
}

@media (min-width: 601px) {
  .chat-workspace .visual-card:has(> .visual-open) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 16px;
    align-items: center;
  }

  .chat-workspace .visual-card:has(> .visual-open) > :not(.visual-status, .visual-open) {
    grid-column: 1 / -1;
  }
}

.chat-workspace .visual-card:has(> .visual-open) > .section-head {
  display: block;
  margin: 0 -18px 8px;
}

.chat-workspace .visual-card:has(> .visual-open) > .section-head > div {
  display: grid;
  gap: 0;
}

.chat-workspace .visual-card:has(> .visual-open) > .section-head .badge {
  display: block;
  padding: 10px 18px;
  border: 0;
  border-radius: 0;
  background: #5148de;
  color: #fff;
  font-size: 15px;
  font-weight: 750;
}

.chat-workspace .visual-card:has(> .visual-open) > .section-head strong {
  padding: 10px 18px 0;
  color: var(--chat-ink);
  font-size: clamp(18px, 1.7vw, 24px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chat-workspace .visual-card:has(> .visual-open) > :is(p.small, .visual-status) {
  color: var(--chat-muted);
  font-size: 14px;
  line-height: 1.65;
}

.chat-workspace .visual-card > .visual-open {
  justify-self: end;
  border-color: transparent;
  border-radius: 11px;
  padding: 9px 14px;
  margin: 6px 0 8px;
  font-size: 14px;
  font-weight: 750;
}

.chat-workspace .composer-wrap {
  max-width: calc(var(--chat-width) + 2 * var(--chat-gutter));
  padding: 0 var(--chat-gutter) 16px;
  margin: 0 auto;
}

.chat-workspace .composer {
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  background: var(--chat-paper);
  box-shadow: 0 5px 0 var(--chat-shadow);
}

.chat-workspace .composer:focus-within {
  border-color: var(--chat-indigo);
  box-shadow: 0 5px 0 #bfb9ed, 0 0 0 2px #e3dfff;
}

.chat-workspace .composer textarea {
  font-size: 15px;
}

.chat-workspace .composer :is(select, .voice-input-button, .composer-attach-button) {
  border-color: var(--chat-line);
  border-radius: 9px;
  font-size: 13px;
}

.chat-workspace .send {
  flex-shrink: 0;
  border-radius: 12px;
  width: 38px;
  height: 38px;
}

.chat-workspace .send:disabled {
  background: #e8e5fa;
  color: #625c89;
  box-shadow: 0 3px 0 #d6d1ed;
}

:where(.chat-workspace, .app:has(.chat-workspace) .conversation-sidebar) :is(button, summary, select):focus-visible {
  outline: 2px solid #5147e8;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .chat-workspace .chat-scroll {
    padding-top: 12px;
    scrollbar-gutter: auto;
  }

  .chat-workspace .chat-message.assistant {
    gap: 8px;
  }

  .chat-workspace .chat-message.assistant > .message-body {
    max-width: none;
  }

  .chat-workspace .composer-bottom {
    align-items: flex-end;
  }

  .chat-workspace .composer :is(select, .voice-input-button, .composer-attach-button) {
    font-size: 12px;
  }

  .chat-workspace .visual-card > .visual-open {
    max-width: 100%;
  }
}
