* {
  box-sizing: border-box;
}

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "HarmonyOS Sans SC", "HarmonyOS Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
    sans-serif;
  background: #f5f7fb;
  color: #111827;
}

.page {
  position: fixed;
  top: var(--app-offset-top, 0px);
  left: 0;
  right: 0;
  width: min(900px, var(--app-width, 100%));
  height: var(--app-height, 100dvh);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
}

.topbar {
  flex-shrink: 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid #eceff3;
}

.title {
  font-size: 16px;
  font-weight: 700;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px 16px 8px 16px;
}

.msg-row {
  display: flex;
  margin-bottom: 14px;
}

.msg-row.user {
  justify-content: flex-end;
}

.msg-row.assistant,
.msg-row.pending {
  justify-content: flex-start;
}

.user-bubble {
  max-width: 78%;
  background: #6e8a4e;
  color: #ffffff;
  padding: 10px 12px;
  border-radius: 14px;
  border-top-right-radius: 4px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.assistant-text {
  max-width: 86%;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.pending-text {
  color: #8a8f99;
  font-size: 13px;
}

.composer {
  flex-shrink: 0;
  border-top: 1px solid #eceff3;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.message-input {
  width: 100%;
  resize: none;
  min-height: 42px;
  max-height: 150px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  font-size: 16px;
  line-height: 1.5;
}

.message-input:focus {
  border-color: #6e8a4e;
}

.send-btn,
.stop-btn {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
}

.send-btn {
  width: 72px;
  background: #6e8a4e;
  color: #fff;
  font-size: 14px;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.stop-btn {
  width: 44px;
  background: #f1f3f6;
  color: #606671;
  font-size: 14px;
}

.stop-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  body {
    background: #ffffff;
  }

  .page {
    width: 100%;
    border-left: none;
    border-right: none;
  }

  .topbar {
    min-height: 48px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
  }

  .chat-list {
    padding: 12px 12px 8px 12px;
  }

  .user-bubble {
    max-width: 88%;
    font-size: 15px;
  }

  .assistant-text {
    max-width: 94%;
    font-size: 15px;
  }

  .composer {
    gap: 8px;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  body.keyboard-open .topbar {
    padding-top: 0;
  }

  body.keyboard-open .composer {
    padding-bottom: 8px;
  }

  .send-btn {
    width: 64px;
  }
}
