.chat-shell {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1f1f1f;
  --muted: #737373;
  --line: #e9e9e9;
  --soft: #f6f6f6;
  --soft-2: #efefef;
  --composer: #303030;
  --composer-text: #f5f5f5;
  --accent: #ffffff;
  --danger: #9b1c1c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-shell,
.chat-shell * {
  box-sizing: border-box;
}

.chat-shell button,
.chat-shell textarea {
  font: inherit;
}

.chat-shell {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--bg);
  color: var(--text);
}

.chat-shell.drag-over::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.chat-shell .drop-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms ease, visibility 140ms ease;
  pointer-events: none;
  z-index: 2;
}

.chat-shell .drop-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.chat-shell .drop-overlay-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  transform: translateY(16px);
  transition: transform 140ms ease;
  text-align: center;
}

.chat-shell .drop-overlay.visible .drop-overlay-panel {
  transform: translateY(0);
}

.chat-shell .drop-overlay-icon {
  width: 176px;
  height: 176px;
  color: #3d57ff;
}

.chat-shell .drop-overlay-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chat-shell .drop-overlay-title {
  color: #111;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0;
}

.chat-shell .drop-overlay-caption {
  max-width: 460px;
  color: #3e3e3e;
  font-size: 18px;
  line-height: 1.4;
}

.chat-shell .messages {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 0px 24px 148px;
}

.chat-shell .message {
  display: flex;
  margin: 22px 0;
}

.chat-shell .message.user {
  justify-content: flex-end;
}

.chat-shell .message.assistant {
  justify-content: flex-start;
}

.chat-shell .user-message-content {
  display: grid;
  justify-items: end;
  gap: 8px;
  max-width: min(680px, 86%);
}

.chat-shell .message.generating .content::after {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  margin: 2px 0 0 2px;
  border: 2px solid var(--line);
  border-top-color: var(--text);
  border-radius: 50%;
  vertical-align: text-bottom;
  animation: model-generating 800ms linear infinite;
}

@keyframes model-generating {
  to {
    transform: rotate(360deg);
  }
}

.chat-shell .bubble {
  max-width: 100%;
  padding: 16px 22px;
  border-radius: 999px;
  background: var(--soft);
  line-height: 1.45;
  font-size: 18px;
}

.chat-shell .sent-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chat-shell .sent-attachment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  max-width: 384px;
  max-height: 256px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  color: inherit;
  text-decoration: none;
}

.chat-shell .sent-attachment.image-only {
  grid-template-columns: auto;
}

.chat-shell .sent-attachment:hover {
  background: var(--soft);
}

.chat-shell .sent-attachment:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.chat-shell .sent-attachment img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.chat-shell .sent-attachment span {
  overflow: hidden;
  padding: 9px 10px;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-shell .sent-attachment span:first-child {
  grid-column: 1 / -1;
}

.chat-shell .content {
  width: min(100%, 840px);
  line-height: 1.55;
  font-size: 18px;
}

.chat-shell .content h2 {
  margin: 28px 0 12px;
  font-size: 24px;
  line-height: 1.25;
}

.chat-shell .content p {
  margin: 0 0 14px;
}

.chat-shell .content h3,
.chat-shell .content h4 {
  margin: 24px 0 10px;
  line-height: 1.25;
}

.chat-shell .content h3 {
  font-size: 21px;
}

.chat-shell .content h4 {
  font-size: 18px;
}

.chat-shell .content ul,
.chat-shell .content ol {
  margin: 0 0 16px;
  padding-left: 26px;
}

.chat-shell .content li {
  margin: 7px 0;
}

.chat-shell .content blockquote {
  margin: 16px 0;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--line);
  color: #4f4f4f;
}

.chat-shell .content code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--soft-2);
  font: 0.92em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.chat-shell .content pre {
  overflow-x: auto;
  margin: 18px 0;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fafafa;
}

.chat-shell .content pre code {
  display: block;
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre;
}

.chat-shell .code-card {
  position: relative;
  overflow-x: auto;
  margin: 18px 0;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fafafa;
  font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.chat-shell .composer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100% - 32px, 980px);
  margin: 0 auto 16px;
}

.chat-shell .attachments {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 12px 10px;
}

.chat-shell .attachment {
  display: grid;
  grid-template-columns: auto 28px;
  align-items: center;
  min-width: 0;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.chat-shell .attachment.image-only {
  grid-template-columns: 52px 28px;
}

.chat-shell .attachment img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 7px 0 0 7px;
}

.chat-shell .attachment-name {
  min-width: 0;
  padding: 9px 10px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-shell .remove-attachment {
  width: 28px;
  height: 28px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.chat-shell .remove-attachment:hover {
  color: var(--danger);
}

.chat-shell .composer-bar {
  display: grid;
  grid-template-columns: 42px 1fr 48px;
  align-items: end;
  gap: 8px;
  min-height: 72px;
  padding: 12px;
  border-radius: 36px;
  background: var(--composer);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
}

.chat-shell .composer-bar.attachments-disabled {
  grid-template-columns: 1fr 48px;
}

.chat-shell .icon-button,
.chat-shell .send-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.chat-shell .icon-button {
  background: transparent;
  color: var(--composer-text);
  font-size: 31px;
  line-height: 1;
}

.chat-shell .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-shell .send-button {
  background: var(--accent);
  color: #111;
  font-size: 24px;
  transition: transform 150ms ease, opacity 150ms ease;
}

.chat-shell .send-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.chat-shell .send-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.chat-shell textarea {
  width: 100%;
  max-height: 180px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--composer-text);
  line-height: 1.45;
  padding: 12px 2px 10px;
}

.chat-shell textarea::placeholder {
  color: #aaa;
}

.chat-shell .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 700px) {
  .chat-shell .messages {
    padding: 28px 16px 132px;
  }

  .chat-shell .content,
  .chat-shell .bubble {
    font-size: 16px;
  }

  .chat-shell .user-message-content {
    max-width: 92%;
  }

  .chat-shell .content h2 {
    font-size: 20px;
  }

  .chat-shell .composer {
    width: min(100% - 16px, 980px);
    margin-bottom: 8px;
  }

  .chat-shell .composer-bar {
    grid-template-columns: 38px 1fr 44px;
    min-height: 64px;
    border-radius: 32px;
  }

  .chat-shell .composer-bar.attachments-disabled {
    grid-template-columns: 1fr 44px;
  }

  .chat-shell .icon-button,
  .chat-shell .send-button {
    width: 38px;
    height: 38px;
  }

  .chat-shell .drop-overlay-icon {
    width: 132px;
    height: 132px;
  }

  .chat-shell .drop-overlay-title {
    font-size: 26px;
  }

  .chat-shell .drop-overlay-caption {
    font-size: 16px;
  }
}
