/* YapThing open reading layout: keep the canvas spacious, the answers readable,
   and the composer aligned with the conversation on desktop and mobile. */
:root {
  --yap-chat-reading-width: 860px;
}
/* Scroll the full chat pane, not a narrow centered box. This keeps the scrollbar
   on the far right while existing JS auto-scrolls #messages unchanged.
   408px is half of the 816px text area (860px rail minus 44px gutters). */
body>main>.workspace>.messages {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 26px max(22px, calc(50% - 408px)) 30px !important;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  gap: 16px;
}
body>main>.workspace>.composer,
body>main>.workspace.yap-empty-chat>.composer {
  box-sizing: border-box;
  width: 100% !important;
  max-width: var(--yap-chat-reading-width) !important;
  margin-inline: auto !important;
  padding: 10px 22px max(18px, env(safe-area-inset-bottom)) !important;
  background: transparent !important;
  box-shadow: none !important;
}
/* Assistant responses read like prose; user turns retain compact YapThing bubbles. */
#messages > .message {
  min-width: 0;
  margin-bottom: 0 !important;
}
#messages > .message:not(.user):not(.yap-assistant-reply) {
  align-self: stretch;
  width: 100%;
  max-width: 100% !important;
  padding: 8px 0 12px !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
#messages > .message.user {
  max-width: min(76%, 650px);
  margin-left: auto;
  padding: 13px 17px !important;
}
#messages .message.yap-assistant-reply {
  max-width: calc(100% - 48px);
}
#messages .yap-prose,
#messages .yp-table-scroll,
#messages .yp-code-block {
  min-width: 0;
  max-width: 100%;
}
/* Tools, approvals and activity must stay inside the same reading rail. */
#messages > .yap-work-message,
#messages > .yap-upgrade-card {
  max-width: 100%;
}
@media (max-width: 700px) {
  body>main>.workspace>.messages {
    max-width: 100% !important;
    padding: 16px 12px 20px !important;
    gap: 13px;
  }
  body>main>.workspace>.composer,
  body>main>.workspace.yap-empty-chat>.composer {
    max-width: 100% !important;
    padding: 8px 11px max(12px, env(safe-area-inset-bottom)) !important;
  }
  #messages > .message.user { max-width: 90%; }
  #messages > .message:not(.user):not(.yap-assistant-reply) {
    padding-block: 5px 10px !important;
  }
}
