.app-shell--chat {
  height: 100dvh;
}

.app-shell--chat .mobile-menu { display: none; }

.app-shell--chat .app-body {
  background: #fff;
  color: #171717;
  min-height: 0;
}

.app-shell--chat .app-main {
  display: flex;
  overflow: hidden;
  min-height: 0;
  padding: 0;
}

.app-shell--chat .chat {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  min-height: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.chat__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

.app-shell--chat .chat__stream {
  width: min(100%, 816px);
  min-height: 100%;
  margin: 0 auto;
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 40px;
  overflow: visible;
}

.chat__turn {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: 0;
  scroll-margin: 24px;
}

.chat .message {
  width: 100%;
  min-width: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.65;
  white-space: normal;
  overflow-wrap: anywhere;
}

.chat .message--user {
  align-self: flex-end;
  width: fit-content;
  max-width: 85%;
  padding: 10px 18px;
  border-radius: 24px;
  background: #eaf3ff;
  color: #18334f;
  white-space: pre-wrap;
}

.chat .message--error {
  color: #a12b23;
}

.chat .message--pending {
  color: #777;
  animation: pulse 1.6s ease-in-out infinite;
}

.chat__empty {
  margin: auto 0;
  padding: 48px 0;
  text-align: center;
}

.chat__empty h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 500;
  letter-spacing: -.035em;
}

.chat__empty p {
  margin: 0;
  color: #777;
  font-size: 15px;
}

.chat__dock {
  flex: none;
  position: relative;
  width: min(100%, 816px);
  margin: 0 auto;
  padding: 0 24px max(12px, env(safe-area-inset-bottom));
  background: #fff;
}

.chat__dock::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -24px;
  height: 24px;
  pointer-events: none;
  background: linear-gradient(transparent, #fff);
}

.chat .chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 10px 10px 20px;
  border: 1px solid #e5e5e5;
  border-radius: 30px;
  background: #fff;
  box-shadow: 0 4px 24px #0000000d;
  transition: border-color .15s, box-shadow .15s;
}

.chat__composer:focus-within {
  border-color: #c8c8c8;
  box-shadow: 0 4px 24px #00000012;
}

.chat__input {
  display: block;
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 200px;
  resize: none;
  border: 0;
  outline: none;
  padding: 6px 0;
  background: transparent;
  color: #171717;
  font: 16px/24px Arial, Helvetica, sans-serif;
}

.chat__input::placeholder { color: #888; }

.chat__send, .chat__latest {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #171717;
  color: #fff;
  cursor: pointer;
  transition: background .15s, transform .15s;
}

.chat__send:hover:not(:disabled) { background: #383838; transform: translateY(-1px); }
.chat__send:disabled { background: #ececec; color: #aaa; cursor: default; }
.chat__send:focus-visible, .chat__latest:focus-visible { outline: 2px solid #397ee8; outline-offset: 3px; }

.chat__latest {
  position: absolute;
  top: -54px;
  left: calc(50% - 18px);
  border: 1px solid #e5e5e5;
  background: #fff;
  color: #333;
  box-shadow: 0 2px 8px #0000000d;
}

.chat__latest:hover { background: #f4f4f4; }
.chat__hint { margin: 8px 0 0; text-align: center; font-size: 11px; line-height: 16px; color: #888; }

.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 18px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 {
  margin: 28px 0 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -.015em;
}
.markdown h1 { font-size: 26px; }
.markdown h2 { font-size: 22px; }
.markdown h3 { font-size: 18px; }
.markdown h4, .markdown h5, .markdown h6 { font-size: 16px; }
.markdown strong { font-weight: 700; }
.markdown ul, .markdown ol { margin: 12px 0 20px; padding-left: 30px; }
.markdown ul { list-style: disc; }
.markdown ol { list-style: decimal; }
.markdown li { padding-left: 2px; margin: 6px 0; }
.markdown li > p { margin: 8px 0; }
.markdown li > ul, .markdown li > ol { margin: 6px 0; }
.markdown blockquote { margin: 20px 0; padding: 2px 0 2px 18px; border-left: 3px solid #dedede; color: #666; }
.markdown blockquote p:last-child { margin-bottom: 0; }
.markdown a { color: #2466b5; text-decoration: underline; text-underline-offset: 3px; }
.markdown code { padding: 2px 5px; border-radius: 5px; background: #f2f2f2; font: .875em/1.6 var(--font-mono); }
.markdown pre { max-width: 100%; margin: 20px 0; padding: 18px 20px; overflow-x: auto; border-radius: 12px; background: #f6f6f6; white-space: pre; overflow-wrap: normal; }
.markdown pre code { padding: 0; border-radius: 0; background: none; font-size: 13px; }
.markdown table { display: block; max-width: 100%; width: max-content; margin: 20px 0; overflow-x: auto; border-collapse: collapse; font-size: 14px; }
.markdown th, .markdown td { padding: 10px 14px; border: 1px solid #e5e5e5; text-align: left; }
.markdown th { background: #f7f7f7; font-weight: 600; }
.markdown hr { margin: 28px 0; border: 0; border-top: 1px solid #e5e5e5; }
.markdown img { max-width: 100%; height: auto; border-radius: 12px; }

@media (max-width: 800px) {
  .app-shell--chat .mobile-menu { display: inline-flex; }
  .app-shell--chat .chat__stream { padding: 24px 16px 32px; gap: 32px; }
  .chat__scroll { scrollbar-gutter: auto; }
  .chat__turn { gap: 24px; }
  .chat__dock { padding-left: 12px; padding-right: 12px; }
  .chat .message--user { max-width: 92%; padding: 10px 16px; }
  .chat__send { width: 40px; height: 40px; }
  .chat__input { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat .message--pending { animation: none; }
  .chat__composer, .chat__send, .chat__latest { transition: none; }
}
