* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: Inter, Arial, sans-serif;
  background: #ffffff;
  color: #1d1d1b;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.chat-frame {
  width: min(100vw, 390px);
  height: 100dvh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-logo {
  height: 88px;
  flex: 0 0 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
  gap: 12px;
}

.logo {
  font-size: 19px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.reset-button {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1;
}

.reset-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-view.empty {
  justify-content: center;
}

.empty-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 32px 24px;
  text-align: center;
}

.empty-body[hidden] {
  display: none;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: #fef5e0;
  color: #f5b731;
  display: grid;
  place-items: center;
  padding: 0;
}

.mark svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.7;
  display: block;
  overflow: visible;
}

.welcome-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.welcome-copy h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.welcome-copy p {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.45;
  max-width: 326px;
}

.conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 16px 18px;
}

.message-row {
  width: 100%;
  display: flex;
}

.message-row.right {
  justify-content: flex-end;
}

.bubble,
.processing {
  width: min(304px, calc(100vw - 48px));
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.45;
}

.bubble p,
.processing p {
  margin: 0;
}

.user p {
  white-space: pre-wrap;
}

.assistant {
  background: #f9f9f9;
  border: 1px solid #f3f4f6;
  padding: 14px 16px;
  color: #1d1d1b;
}

.assistant > :first-child,
.user > :first-child {
  margin-top: 0;
}

.assistant > :last-child,
.user > :last-child {
  margin-bottom: 0;
}

.assistant ul,
.assistant ol {
  margin: 10px 0;
  padding-left: 20px;
}

.assistant li + li {
  margin-top: 4px;
}

.assistant strong {
  font-weight: 700;
}

.user {
  background: #1d1d1b;
  color: #ffffff;
  padding: 12px 12px 14px;
}

.message-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.message-image {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(229, 231, 235, 0.35);
  cursor: pointer;
}

.message-image-fallback {
  width: 72px;
  min-height: 72px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f9f9f9;
  color: #374151;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  text-decoration: none;
}

.message-image-fallback-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.message-image-fallback-name {
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.processing {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 12px 14px;
}

.stage-current {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-current strong {
  font-size: 13px;
  font-weight: 550;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #f5b73144;
  border-top-color: #f5b731;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.composer-wrap {
  flex: 0 0 auto;
  background: #ffffffee;
  border-top: 1px solid #f3f4f6;
  padding: 12px 16px 20px;
}

.composer {
  min-height: 56px;
  width: 100%;
  background: #f9f9f9;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 10px 10px 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 20px;
  height: 20px;
  color: #6b7280;
  flex: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.upload {
  cursor: pointer;
}

.composer-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.composer-previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-feedback {
  font-size: 12px;
  line-height: 1.35;
  color: #6b7280;
}

.composer-preview-wrap {
  position: relative;
  width: 52px;
  height: 52px;
}

.composer-preview {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}

.composer-preview-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: #1d1d1b;
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}

.message-input {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: #1d1d1b;
  font-size: 15px;
  line-height: 1.35;
  min-height: 24px;
  max-height: 132px;
  padding: 0 0 2px;
  display: block;
}

.message-input::placeholder {
  color: #9ca3af;
}

.send {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 8px;
  flex: 0 0 36px;
  align-self: center;
}

.send svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.send.active {
  background: #f5b731;
  color: #1d1d1b;
}

.upload svg {
  width: 100%;
  height: 100%;
}

.send.disabled {
  background: #d1d5db;
  color: #ffffff;
  cursor: not-allowed;
}

.overlay {
  position: fixed;
  inset: 0;
  background: #00000066;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(100%, 620px);
  border-radius: 20px;
  background: #ffffff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 32px #00000033;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.modal-head button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 17px;
  background: #f9f9f9;
  color: #6b7280;
  padding: 8px;
}

.modal-head button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.modal-image {
  width: 100%;
  max-height: min(70vh, 430px);
  border-radius: 16px;
  object-fit: cover;
  display: block;
}

.mobile-modal {
  width: min(100%, 354px);
}

.hidden {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 700px) {
  .screen {
    align-items: flex-start;
  }

  .chat-frame {
    width: min(100vw, 680px);
  }

  .top-logo {
    height: 96px;
    flex-basis: 96px;
    padding: 24px 20px 8px;
  }

  .conversation {
    gap: 20px;
    padding: 10px 48px 20px;
  }

  .bubble,
  .processing {
    width: 500px;
    font-size: 15px;
  }

  .user {
    padding: 14px 14px 16px;
  }

  .empty-body {
    padding: 0 82px 36px;
    gap: 20px;
  }

  .mark {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    padding: 0;
  }

  .mark svg {
    width: 32px;
    height: 32px;
    stroke-width: 1.7;
    display: block;
    overflow: visible;
  }

  .welcome-copy p {
    font-size: 15px;
  }
}

@media (max-width: 699px) {
  .top-logo {
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }

  .composer-wrap {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .assistant a,
  .assistant p,
  .assistant li,
  .assistant code {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
